shithub: scc

Download patch

ref: 8f5c9ee749a797d0af3c8d2d96c9c3961f8f5544
parent: b42ed545c1ed74508795acf70986f2c848defeca
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Mar 20 13:33:25 EDT 2015

Simplify generate()

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

--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -399,30 +399,24 @@
 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);
 }
 
 /*