[hackers] [scc] [cc2-qbe] Add emission of local variables || Roberto E. Vargas Caballero
commit e5165d704e5d8d7c7ee23bb884f2aacf6cb722a4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Apr 15 15:55:11 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Apr 15 15:55:11 2016 +0200
[cc2-qbe] Add emission of local variables
Local variables must be allocated in the current stack of the defined
function.
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index e8840ce..883f8a7 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -164,15 +164,24 @@ void
writeout(void)
{
Symbol *p;
+ Type *tp;
if (curfun->kind == GLOB)
fputs("export ", stdout);
- printf("function %s $%s(", size2asm(&curfun->rtype), symname(curfun));
+ printf("function %s %s(\n", size2asm(&curfun->rtype), symname(curfun));
for (p = locals; p && p->type.flags & PARF; p = p->next)
- printf("%s %s,", size2asm(&p->type), symname(p));
+ printf("\t%s %s,\n", size2asm(&p->type), symname(p));
+
+ puts(")\n{");
+
+ for ( ; p; p = p->next) {
+ tp = &p->type;
+ printf("\t%s %s= alloc%d %d\n",
+ symname(p), size2asm(tp), tp->size, tp->align);
+ }
+
- puts("){");
puts("}");
}
Received on Fri Apr 15 2016 - 15:57:55 CEST
This archive was generated by hypermail 2.3.0
: Fri Apr 15 2016 - 16:00:21 CEST