commit 1271c751ed83ba792b706dfcfe96180f49c8a894
parent 69dc9dd9819765dd1f1cf34b1b84197aa10feb78
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date: Sun, 26 Dec 2021 16:32:11 +0100
emit alignment info when present
Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Diffstat:
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/emit.c b/src/emit.c
@@ -305,6 +305,9 @@ emit_data(struct qbe_def *def, FILE *out)
} else {
fprintf(out, "section \".data.%s\" ", def->name);
}
+ if (def->data.align != ALIGN_UNDEFINED) {
+ fprintf(out, "align %lu ", def->data.align);
+ }
fprintf(out, "{ ");
struct qbe_data_item *item = &def->data.items;
diff --git a/src/gen.c b/src/gen.c
@@ -1600,6 +1600,7 @@ gen_const_string_at(struct gen_context *ctx,
struct qbe_def *def = xcalloc(1, sizeof(struct qbe_def));
def->name = global.name;
def->kind = Q_DATA;
+ def->data.align = ALIGN_UNDEFINED;
def->data.items.type = QD_STRING;
def->data.items.str = xcalloc(1, len);
memcpy(def->data.items.str, val, len);
@@ -3127,6 +3128,7 @@ gen_data_item(struct gen_context *ctx, struct expression *expr,
def = xcalloc(1, sizeof(struct qbe_def));
def->name = gen_name(ctx, "strdata.%d");
def->kind = Q_DATA;
+ def->data.align = ALIGN_UNDEFINED;
def->data.items.type = QD_STRING;
def->data.items.str = xcalloc(1, expr->constant.string.len);
def->data.items.sz = expr->constant.string.len;
@@ -3157,6 +3159,7 @@ gen_data_item(struct gen_context *ctx, struct expression *expr,
def = xcalloc(1, sizeof(struct qbe_def));
def->name = gen_name(ctx, "sldata.%d");
def->kind = Q_DATA;
+ def->data.align = ALIGN_UNDEFINED;
size_t len = 0;
struct qbe_data_item *subitem = &def->data.items;
@@ -3323,6 +3326,7 @@ gen_global_decl(struct gen_context *ctx, const struct declaration *decl)
}
struct qbe_def *qdef = xcalloc(1, sizeof(struct qbe_def));
qdef->kind = Q_DATA;
+ qdef->data.align = ALIGN_UNDEFINED;
qdef->exported = decl->exported;
qdef->name = ident_to_sym(&decl->ident);
gen_data_item(ctx, global->value, &qdef->data.items);