public static Tile Dec_Reg() { return(makeUnopTile <DecOperatorNode, RegisterNode> ( (regNode, root, left) => new [] { InstructionFactory.Dec(left), InstructionFactory.Move(regNode, left) } )); }
// reg1 = reg2 - const public static Tile Reg_SubConst() { return(new Tile(typeof(AssignmentNode), new[] { makeTile <RegisterNode> (), makeTile <SubOperatorNode> ( makeTile <RegisterNode> (), makeTile <ConstantNode <long> > () ) }, (regNode, node) => { var root = node as AssignmentNode; var reg1 = root.Target as RegisterNode; var subop = root.Source as SubOperatorNode; var reg2 = subop.LeftOperand as RegisterNode; var val = subop.RightOperand as ConstantNode <long>; // reg = reg - 1 -> reg-- if (reg1 == reg2 && val.Value == 1L) { return new[] { InstructionFactory.Dec(reg1), InstructionFactory.Move(regNode, reg1) }; } else { return new[] { InstructionFactory.Move(reg1, reg2), // r = left InstructionFactory.Sub(reg1, val), // r = left - right InstructionFactory.Move(regNode, reg1) }; } } )); }