scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 8f5c9ee749a797d0af3c8d2d96c9c3961f8f5544
parent b42ed545c1ed74508795acf70986f2c848defeca
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 20 Mar 2015 17:33:25 -0400

Simplify generate()

Allmost all the functions will have stack frame, so it is
better to remove test that we were doing.

Diffstat:
Mcc2/cgen.c | 32+++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -399,30 +399,24 @@ applycgen(Node *np) void generate(void) { - extern char odebug; uint8_t size = curfun->u.f.locals; - char frame = size != 0 || odebug; - - if (frame) { - code(PUSH, NULL, &regs[IX]); - code(MOV, &regs[IX], &regs[SP]); - if (size > 6) { - code(MOV, &regs[HL], imm(-size)); - code(ADD, &regs[HL], &regs[SP]); - code(MOV, &regs[SP], &regs[HL]); - } else { - for (; size != 0; size-= 2) - code(PUSH, NULL, &regs[HL]); - } + + code(PUSH, NULL, &regs[IX]); + code(MOV, &regs[IX], &regs[SP]); + if (size > 6) { + code(MOV, &regs[HL], imm(-size)); + code(ADD, &regs[HL], &regs[SP]); + code(MOV, &regs[SP], &regs[HL]); + } else { + for (; size != 0; size-= 2) + code(PUSH, NULL, &regs[HL]); } apply(applycgen); - if (frame) { - code(MOV, &regs[SP], &regs[IX]); - code(POP, &regs[IX], NULL); - code(RET, NULL, NULL); - } + code(MOV, &regs[SP], &regs[IX]); + code(POP, &regs[IX], NULL); + code(RET, NULL, NULL); } /*