shithub: scc

Download patch

ref: 91e5d483f7533538e544cb2b0d213f954872b70d
parent: 0c1914a98db6a6e1dc72e1d26624ae97e10e6211
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Nov 5 01:08:05 EDT 2021

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.

--- a/src/cmd/cc/cc2/target/qbe/code.c
+++ b/src/cmd/cc/cc2/target/qbe/code.c
@@ -281,14 +281,16 @@
 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