protected Operation(IROpCodes opcode, VirtualRegister target) { if (target == null) throw new ArgumentNullException("target"); else Target = target; this.opcode = opcode; }
public UnaryOperation(IROpCodes opcode, VirtualRegister target, GenericOperand operand) : base(opcode, target) { if (operand == null) { throw new ArgumentNullException("operand"); } else { Operand = operand; } switch (opcode) { case IROpCodes.NEG: case IROpCodes.ABS: Util.CheckArgumentType(Util.SIntTypes.Concat(Util.RealTypes), target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.NOT: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.SQRT: case IROpCodes.RSQRT: Util.CheckArgumentType(Util.RealTypes, target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.SIN: case IROpCodes.COS: case IROpCodes.LG2: case IROpCodes.EX2: Util.CheckArgumentType(typeof(float), target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.MOV: Util.CheckArgumentType(target.DataType, operand.DataType, "operand"); break; case IROpCodes.CVT: if (!(Util.NumericTypes.Contains(operand.DataType) && Util.NumericTypes.Contains(target.DataType)) || target.DataType == operand.DataType) { throw new InvalidCastException(string.Format("There is no conversion from {0} to {1}", operand.DataType.Format(), target.DataType.Format())); } break; default: throw new InvalidOperationException(); } }
protected Operation(IROpCodes opcode, VirtualRegister target) { if (target == null) { throw new ArgumentNullException("target"); } else { Target = target; } this.opcode = opcode; }
public BinaryOperation(IROpCodes opcode, VirtualRegister target, GenericOperand left, GenericOperand right) : base(opcode, target) { if (left == null) throw new ArgumentNullException("left"); else LeftOperand = left; if (right == null) throw new ArgumentNullException("right"); else RightOperand = right; switch (opcode) { case IROpCodes.ADD: case IROpCodes.SUB: case IROpCodes.MUL: case IROpCodes.DIV: case IROpCodes.MIN: case IROpCodes.MAX: Util.CheckArgumentType(Util.NumericTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.REM: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.AND: case IROpCodes.OR: case IROpCodes.XOR: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.EQ: case IROpCodes.NE: case IROpCodes.GE: case IROpCodes.GT: case IROpCodes.LE: case IROpCodes.LT: Util.CheckArgumentType(typeof(int), target.DataType, "target"); Util.CheckArgumentType(Util.NumericTypes, left.DataType, "left"); Util.CheckArgumentType(left.DataType, right.DataType, "right"); break; default: throw new InvalidOperationException(); } }
public IntrinsicFunctionAttribute(IROpCodes opcode) { OpCode = opcode; }
public BinaryOperation(IROpCodes opcode, VirtualRegister target, GenericOperand left, GenericOperand right) : base(opcode, target) { if (left == null) { throw new ArgumentNullException("left"); } else { LeftOperand = left; } if (right == null) { throw new ArgumentNullException("right"); } else { RightOperand = right; } switch (opcode) { case IROpCodes.ADD: case IROpCodes.SUB: case IROpCodes.MUL: case IROpCodes.DIV: case IROpCodes.MIN: case IROpCodes.MAX: Util.CheckArgumentType(Util.NumericTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.REM: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.AND: case IROpCodes.OR: case IROpCodes.XOR: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); Util.CheckArgumentType(target.DataType, left.DataType, "left"); Util.CheckArgumentType(target.DataType, right.DataType, "right"); break; case IROpCodes.EQ: case IROpCodes.NE: case IROpCodes.GE: case IROpCodes.GT: case IROpCodes.LE: case IROpCodes.LT: Util.CheckArgumentType(typeof(int), target.DataType, "target"); Util.CheckArgumentType(Util.NumericTypes, left.DataType, "left"); Util.CheckArgumentType(left.DataType, right.DataType, "right"); break; default: throw new InvalidOperationException(); } }
public UnaryOperation(IROpCodes opcode, VirtualRegister target, GenericOperand operand) : base(opcode, target) { if (operand == null) throw new ArgumentNullException("operand"); else Operand = operand; switch (opcode) { case IROpCodes.NEG: case IROpCodes.ABS: Util.CheckArgumentType(Util.SIntTypes.Concat(Util.RealTypes), target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.NOT: Util.CheckArgumentType(Util.IntegralTypes, target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.SQRT: case IROpCodes.RSQRT: Util.CheckArgumentType(Util.RealTypes, target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.SIN: case IROpCodes.COS: case IROpCodes.LG2: case IROpCodes.EX2: Util.CheckArgumentType(typeof(float), target.DataType, "target"); goto case IROpCodes.MOV; case IROpCodes.MOV: Util.CheckArgumentType(target.DataType, operand.DataType, "operand"); break; case IROpCodes.CVT: if (!(Util.NumericTypes.Contains(operand.DataType) && Util.NumericTypes.Contains(target.DataType)) || target.DataType == operand.DataType) throw new InvalidCastException(string.Format("There is no conversion from {0} to {1}", operand.DataType.Format(), target.DataType.Format())); break; default: throw new InvalidOperationException(); } }