private void SetUp(OpConvertUToF op, SpirvInstructionTreeBuilder treeBuilder) { ResultType = treeBuilder.ResolveType(op.IdResultType); UnsignedValue = treeBuilder.GetNode(op.UnsignedValue); SetUpDecorations(op, treeBuilder); }
public NestedInstruction(Node node, SpirvInstructionsBuilderBase builder) { switch (node.OpCode) { case Op.OpAccessChain: { var n = (AccessChain)node; var instruction = new OpAccessChain(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpInBoundsAccessChain: { var n = (InBoundsAccessChain)node; var instruction = new OpInBoundsAccessChain(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpPtrAccessChain: { var n = (PtrAccessChain)node; var instruction = new OpPtrAccessChain(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Element = builder.Visit(n.Element); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpInBoundsPtrAccessChain: { var n = (InBoundsPtrAccessChain)node; var instruction = new OpInBoundsPtrAccessChain(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Element = builder.Visit(n.Element); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpVectorShuffle: { var n = (VectorShuffle)node; var instruction = new OpVectorShuffle(); _instruction = instruction; instruction.Vector1 = builder.Visit(n.Vector1); instruction.Vector2 = builder.Visit(n.Vector2); instruction.Components = builder.Visit(n.Components); break; } case Op.OpCompositeExtract: { var n = (CompositeExtract)node; var instruction = new OpCompositeExtract(); _instruction = instruction; instruction.Composite = builder.Visit(n.Composite); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpCompositeInsert: { var n = (CompositeInsert)node; var instruction = new OpCompositeInsert(); _instruction = instruction; instruction.Object = builder.Visit(n.Object); instruction.Composite = builder.Visit(n.Composite); instruction.Indexes = builder.Visit(n.Indexes); break; } case Op.OpConvertFToU: { var n = (ConvertFToU)node; var instruction = new OpConvertFToU(); _instruction = instruction; instruction.FloatValue = builder.Visit(n.FloatValue); break; } case Op.OpConvertFToS: { var n = (ConvertFToS)node; var instruction = new OpConvertFToS(); _instruction = instruction; instruction.FloatValue = builder.Visit(n.FloatValue); break; } case Op.OpConvertSToF: { var n = (ConvertSToF)node; var instruction = new OpConvertSToF(); _instruction = instruction; instruction.SignedValue = builder.Visit(n.SignedValue); break; } case Op.OpConvertUToF: { var n = (ConvertUToF)node; var instruction = new OpConvertUToF(); _instruction = instruction; instruction.UnsignedValue = builder.Visit(n.UnsignedValue); break; } case Op.OpUConvert: { var n = (UConvert)node; var instruction = new OpUConvert(); _instruction = instruction; instruction.UnsignedValue = builder.Visit(n.UnsignedValue); break; } case Op.OpSConvert: { var n = (SConvert)node; var instruction = new OpSConvert(); _instruction = instruction; instruction.SignedValue = builder.Visit(n.SignedValue); break; } case Op.OpFConvert: { var n = (FConvert)node; var instruction = new OpFConvert(); _instruction = instruction; instruction.FloatValue = builder.Visit(n.FloatValue); break; } case Op.OpQuantizeToF16: { var n = (QuantizeToF16)node; var instruction = new OpQuantizeToF16(); _instruction = instruction; instruction.Value = builder.Visit(n.Value); break; } case Op.OpConvertPtrToU: { var n = (ConvertPtrToU)node; var instruction = new OpConvertPtrToU(); _instruction = instruction; instruction.Pointer = builder.Visit(n.Pointer); break; } case Op.OpConvertUToPtr: { var n = (ConvertUToPtr)node; var instruction = new OpConvertUToPtr(); _instruction = instruction; instruction.IntegerValue = builder.Visit(n.IntegerValue); break; } case Op.OpPtrCastToGeneric: { var n = (PtrCastToGeneric)node; var instruction = new OpPtrCastToGeneric(); _instruction = instruction; instruction.Pointer = builder.Visit(n.Pointer); break; } case Op.OpGenericCastToPtr: { var n = (GenericCastToPtr)node; var instruction = new OpGenericCastToPtr(); _instruction = instruction; instruction.Pointer = builder.Visit(n.Pointer); break; } case Op.OpBitcast: { var n = (Bitcast)node; var instruction = new OpBitcast(); _instruction = instruction; instruction.Operand = builder.Visit(n.Operand); break; } case Op.OpSNegate: { var n = (SNegate)node; var instruction = new OpSNegate(); _instruction = instruction; instruction.Operand = builder.Visit(n.Operand); break; } case Op.OpFNegate: { var n = (FNegate)node; var instruction = new OpFNegate(); _instruction = instruction; instruction.Operand = builder.Visit(n.Operand); break; } case Op.OpIAdd: { var n = (IAdd)node; var instruction = new OpIAdd(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFAdd: { var n = (FAdd)node; var instruction = new OpFAdd(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpISub: { var n = (ISub)node; var instruction = new OpISub(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFSub: { var n = (FSub)node; var instruction = new OpFSub(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpIMul: { var n = (IMul)node; var instruction = new OpIMul(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFMul: { var n = (FMul)node; var instruction = new OpFMul(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpUDiv: { var n = (UDiv)node; var instruction = new OpUDiv(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSDiv: { var n = (SDiv)node; var instruction = new OpSDiv(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFDiv: { var n = (FDiv)node; var instruction = new OpFDiv(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpUMod: { var n = (UMod)node; var instruction = new OpUMod(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSRem: { var n = (SRem)node; var instruction = new OpSRem(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSMod: { var n = (SMod)node; var instruction = new OpSMod(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFRem: { var n = (FRem)node; var instruction = new OpFRem(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpFMod: { var n = (FMod)node; var instruction = new OpFMod(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpLogicalEqual: { var n = (LogicalEqual)node; var instruction = new OpLogicalEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpLogicalNotEqual: { var n = (LogicalNotEqual)node; var instruction = new OpLogicalNotEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpLogicalOr: { var n = (LogicalOr)node; var instruction = new OpLogicalOr(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpLogicalAnd: { var n = (LogicalAnd)node; var instruction = new OpLogicalAnd(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSelect: { var n = (Select)node; var instruction = new OpSelect(); _instruction = instruction; instruction.Condition = builder.Visit(n.Condition); instruction.Object1 = builder.Visit(n.Object1); instruction.Object2 = builder.Visit(n.Object2); break; } case Op.OpIEqual: { var n = (IEqual)node; var instruction = new OpIEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpINotEqual: { var n = (INotEqual)node; var instruction = new OpINotEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpUGreaterThan: { var n = (UGreaterThan)node; var instruction = new OpUGreaterThan(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSGreaterThan: { var n = (SGreaterThan)node; var instruction = new OpSGreaterThan(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpUGreaterThanEqual: { var n = (UGreaterThanEqual)node; var instruction = new OpUGreaterThanEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSGreaterThanEqual: { var n = (SGreaterThanEqual)node; var instruction = new OpSGreaterThanEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpULessThan: { var n = (ULessThan)node; var instruction = new OpULessThan(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSLessThan: { var n = (SLessThan)node; var instruction = new OpSLessThan(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpULessThanEqual: { var n = (ULessThanEqual)node; var instruction = new OpULessThanEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpSLessThanEqual: { var n = (SLessThanEqual)node; var instruction = new OpSLessThanEqual(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpShiftRightLogical: { var n = (ShiftRightLogical)node; var instruction = new OpShiftRightLogical(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Shift = builder.Visit(n.Shift); break; } case Op.OpShiftRightArithmetic: { var n = (ShiftRightArithmetic)node; var instruction = new OpShiftRightArithmetic(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Shift = builder.Visit(n.Shift); break; } case Op.OpShiftLeftLogical: { var n = (ShiftLeftLogical)node; var instruction = new OpShiftLeftLogical(); _instruction = instruction; instruction.Base = builder.Visit(n.Base); instruction.Shift = builder.Visit(n.Shift); break; } case Op.OpBitwiseOr: { var n = (BitwiseOr)node; var instruction = new OpBitwiseOr(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpBitwiseXor: { var n = (BitwiseXor)node; var instruction = new OpBitwiseXor(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpBitwiseAnd: { var n = (BitwiseAnd)node; var instruction = new OpBitwiseAnd(); _instruction = instruction; instruction.Operand1 = builder.Visit(n.Operand1); instruction.Operand2 = builder.Visit(n.Operand2); break; } case Op.OpNot: { var n = (Not)node; var instruction = new OpNot(); _instruction = instruction; instruction.Operand = builder.Visit(n.Operand); break; } default: throw new NotImplementedException(node.OpCode + " is not implemented yet."); } }