scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit bc901dae9adb6c246563a6647ae983087a93642f
parent c31b21ec255e921b3f48d6b18fa0cbbd7922aa06
Author: Roberto E. Vargas Caballero <roberto.vargas@igrid-td.com>
Date:   Mon,  4 Apr 2016 16:39:57 +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.

Diffstat:
cc2/arch/qbe/code.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -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 { @@ -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 @@ -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