scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 2e0c505310dff236c393bba8b04edc1cdfb4740e
parent 9e36c90c046cc1bd1b9ba069f669ee3828596766
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Nov 2021 05:08:05 +0100

cc2/qbe: Print alignment always

Alignment is not really needed because the alignment of
aggregates is the highest alignment in qbe, and we always
print data of only one size. Explicit alignment is added
to make easier in the future to add C11 alignment operators.

Diffstat:
Msrc/cmd/cc/cc2/target/qbe/code.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cmd/cc/cc2/target/qbe/code.c b/src/cmd/cc/cc2/target/qbe/code.c @@ -281,14 +281,16 @@ size2asm(Type *tp) void defglobal(Symbol *sym) { + Type *tp = &sym->type; + if (sym->kind == SEXTRN) return; if (sym->kind == SGLOB) fputs("export ", stdout); - printf("data %s = {\n", symname(sym)); + printf("data %s = align %d {\n", symname(sym), tp->align); if (sym->type.flags & INITF) return; - printf("\tz\t%lu\n}\n", sym->type.size); + printf("\tz\t%lu\n}\n", tp->size); } void