// reg1 = reg2 + const public static Tile Reg_AddConst() { return(new Tile(typeof(AssignmentNode), new[] { makeTile <RegisterNode> (), makeTile <AddOperatorNode> ( makeTile <RegisterNode> (), makeTile <ConstantNode <long> > () ) }, (regNode, node) => { var root = node as AssignmentNode; var reg1 = root.Target as RegisterNode; var addop = root.Source as AddOperatorNode; var reg2 = addop.LeftOperand as RegisterNode; var val = addop.RightOperand as ConstantNode <long>; // reg = reg + 1 -> reg++ if (reg1 == reg2 && val.Value == 1L) { return new[] { InstructionFactory.Inc(reg1), InstructionFactory.Move(regNode, reg1) }; } else { return new[] { InstructionFactory.Move(reg1, reg2), // r = left InstructionFactory.Add(reg1, val), // r = left + right InstructionFactory.Move(regNode, reg1) }; } } )); }