public static Block Conclusion(int stackLocals, Set <Arg> registers) { if (stackLocals == 0) { return(new Block(LL <Instr> .From( Popq(RBP), Retq() ), "conclusion")); } int offset = stackLocals * 8 + (stackLocals % 2 == 1 ? 8 : 0); LL <Instr> instrs = LL <Instr> .From( Addq(offset, RSP), Popq(RBP), Retq() ); return(new Block(instrs, "conclusion")); }
public static Block Prelude(int stackLocals, Set <Arg> registers) { if (stackLocals == 0) { return(new Block(LL <Instr> .From( Pushq(RBP), Movq(RSP, RBP), Jmpq("start") ), "_main")); } int offset = stackLocals * 8 + (stackLocals % 2 == 1 ? 8 : 0); LL <Instr> instrs = LL <Instr> .From( Pushq(RBP), Movq(RSP, RBP), Subq(offset, RSP), Jmpq("start") ); return(new Block(instrs, "_main")); }