[hackers] [scc] [cc2] Do not use size2asm in default initializer || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 4 Apr 2016 17:49:44 +0200 (CEST)

commit bc901dae9adb6c246563a6647ae983087a93642f
Author: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
AuthorDate: Mon Apr 4 16:39:57 2016 +0200
Commit: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
CommitDate: Mon Apr 4 16:48:03 2016 +0200

    [cc2] Do not use size2asm in default initializer
    
    QBE IR lacks fill with value command, so the previous
    implementation was wrong. This implementation takes
    the approach of using always a fill command with any
    non initialized data. It is simpler for us, and it
    is simpler for QBE.

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 1d3d0d7..0d2b5c4 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -34,6 +34,8 @@ size2asm(Type *tp)
 {
         char *s;
 
+ /* In qbe we can ignore the aligment because it handles it */
+
         if (tp->flags & STRF) {
                 abort();
         } else {
_AT_@ -51,11 +53,10 @@ size2asm(Type *tp)
                         s = "q\t";
                         break;
                 default:
- s = "z\t%llu\t";
- break;
+ abort();
                 }
         }
- printf(s, (unsigned long long) tp->size);
+ fputs(s, stdout);
 }
 
 void
_AT_@ -65,12 +66,10 @@ defsym(Symbol *sym, int alloc)
                 return;
         if (sym->kind == GLOB)
                 fputs("export ", stdout);
- printf("data %c%s = {\n", sigil(sym), sym->name);
+ printf("data $%s = {\n", sym->name);
         if (sym->type.flags & INITF)
                 return;
- putchar('\t');
- size2asm(&sym->type);
- puts("0\n}");
+ printf("\tz\t%llu\n}\n", (unsigned long long) sym->type.size);
 }
 
 void
Received on Mon Apr 04 2016 - 17:49:44 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 04 2016 - 18:00:18 CEST