ref: b5f5fb997e89d3189022f62f51b5cc4fbf6d9bbb
parent: fc8f4fd0225d1806fe8e25d8ce847ca1abc219d1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Apr 15 11:24:20 EDT 2016
[cc2-qbe] Small stetic changes to the output of qbe
After this commit we have a beatitul output for something like
$ cc1 | cc2
int
func(int a, int b)
{
int c;
c = a + c;
}
^D
export function h $func(h %a,h %b)
%c h= alloc2 2
$.1 w= load %a
$.2 w= load %c
$.3 w= add $.1,$.2
storew $.3,%c
}
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -191,19 +191,22 @@
{Symbol *p;
Type *tp;
+ char *sep;
if (curfun->kind == GLOB)
fputs("export ", stdout);- printf("function %s %s(\n", size2asm(&curfun->rtype), symname(curfun));+ printf("function %s %s(", size2asm(&curfun->rtype), symname(curfun));- for (p = locals; p && p->type.flags & PARF; p = p->next)
- printf("\t%s %s,\n", size2asm(&p->type), symname(p));+ for (sep = "", p = locals; p; p = p->next, sep = ",") {+ if ((p->type.flags & PARF) == 0)
+ break;
+ printf("%s%s %s", sep, size2asm(&p->type), symname(p));+ }
+ puts(")");- puts(")\n{");-
for ( ; p && p->id != TMPSYM; p = p->next) {tp = &p->type;
- printf("\t%s %s= alloc%lld %lld\n",+ printf("\t%s %s=\talloc%lld\t%lld\n",symname(p), size2asm(tp),
(long long) tp->size, (long long) tp->align);
}
--
⑨