[hackers] [scc] [cc2-qbe] Small stetic changes to the output of qbe || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 16 Apr 2016 09:42:20 +0200 (CEST)

commit 162486162929c82a4c92763e7ad488c064d4142c
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Fri Apr 15 15:24:20 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Fri Apr 15 15:39:48 2016 +0200

    [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
    }

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 0d3db65..fbac10f 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -191,19 +191,22 @@ writeout(void)
 {
         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));
-
- puts(")\n{");
+ 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(")");
 
         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);
         }
Received on Sat Apr 16 2016 - 09:42:20 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 16 2016 - 09:48:43 CEST