commit 9986c9218f691f5d6f579a6d31a3b03776297d2c
parent 5a1b9579ce4562d0ca27ffa815ac32e36eb8a38a
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 23 Jun 2021 11:07:16 -0400
gen: fix more issues with qbe subtypes
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/gen.c b/src/gen.c
@@ -514,7 +514,7 @@ gen_expr_access(struct gen_context *ctx,
address_object(ctx, expr, &src);
if (src.indirect) {
gen_loadtemp(ctx, &temp, &src,
- qtype_for_type(ctx, expr->result, false),
+ qtype_for_type(ctx, expr->result, true),
type_is_signed(expr->result));
gen_store(ctx, out, &temp);
} else {
diff --git a/src/qbe.c b/src/qbe.c
@@ -256,6 +256,14 @@ pushi(struct qbe_func *func, const struct qbe_value *out,
struct qbe_statement stmt = {0};
va_list ap;
va_start(ap, instr);
+
+ struct qbe_value hack;
+ if (out && (out->type->stype == Q_BYTE || out->type->stype == Q_HALF)) {
+ hack = *out;
+ hack.type = &qbe_word;
+ out = &hack;
+ }
+
va_geni(&stmt, instr, out, ap);
va_end(ap);
push(&func->body, &stmt);
diff --git a/src/qtype.c b/src/qtype.c
@@ -302,7 +302,6 @@ qtype_for_type(struct gen_context *ctx, const struct type *type, bool extended)
}
// Fallthrough
case STORAGE_BOOL:
- case STORAGE_ENUM:
case STORAGE_I32:
case STORAGE_U32:
case STORAGE_RUNE:
@@ -317,7 +316,11 @@ qtype_for_type(struct gen_context *ctx, const struct type *type, bool extended)
case STORAGE_F32:
case STORAGE_F64:
case STORAGE_VOID:
- return qtype_for_xtype(qstype_for_type(type), false);
+ return qtype_for_xtype(qstype_for_type(type), extended);
+ case STORAGE_ENUM:
+ return qtype_for_type(ctx,
+ builtin_type_for_storage(type->_enum.storage, true),
+ extended);
case STORAGE_ARRAY:
case STORAGE_SLICE:
case STORAGE_STRING:
@@ -327,7 +330,7 @@ qtype_for_type(struct gen_context *ctx, const struct type *type, bool extended)
case STORAGE_UNION:
return lookup_aggregate(ctx, type);
case STORAGE_FUNCTION:
- return qtype_for_xtype(Q__AGGREGATE, false);
+ return qtype_for_xtype(Q__AGGREGATE, extended);
case STORAGE_ALIAS:
return qtype_for_type(ctx, type->alias.type, extended);
case STORAGE_FCONST: