harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit dc63b8ccfc2adecfba21bb09cd9a1917ae4e2dd0
parent 5a2e9c05ef30cec7218bf8d93e37b81900cf6932
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 27 Dec 2020 14:42:38 -0500

gen: fix store for indirect sources

And break aggregate types for now because I have no fucking clue, jesus
christ live is pain

Diffstat:
Msrc/gen.c | 37+++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -129,18 +129,21 @@ gen_store(struct gen_context *ctx, const struct qbe_value *dest, const struct qbe_value *src) { - assert(src && !src->indirect); // Invariant if (!dest) { // no-op return; } - const struct qbe_type *qtype = dest->type; - assert(qtype->stype != Q__VOID); // Invariant - assert(qtype->stype != Q__AGGREGATE); // TODO + assert(src->type->stype != Q__VOID + && dest->type->stype != Q__VOID); // Invariant + assert(src->type->stype != Q__AGGREGATE + && dest->type->stype != Q__AGGREGATE); // TODO: Fuck me + assert(!src->indirect); if (dest->indirect) { - pushi(ctx->current, NULL, store_for_type(qtype->stype), src, dest, NULL); + pushi(ctx->current, NULL, + store_for_type(src->type->stype), + src, dest, NULL); } else { pushi(ctx->current, dest, Q_COPY, src, NULL); } @@ -152,15 +155,16 @@ gen_load(struct gen_context *ctx, const struct qbe_value *src, bool is_signed) { - const struct qbe_type *qtype = dest->type; - assert(qtype->stype != Q__VOID); // Invariant - - if (src->type->stype == Q__AGGREGATE) { - assert(src->indirect && !dest->indirect); - pushi(ctx->current, dest, Q_COPY, src, NULL); - } else if (src->indirect) { - pushi(ctx->current, dest, load_for_type( - qtype->stype, is_signed), src, NULL); + assert(src->type->stype != Q__VOID + && dest->type->stype != Q__VOID); // Invariant + assert(src->type->stype != Q__AGGREGATE + && dest->type->stype != Q__AGGREGATE); // TODO: Fuck me + + assert(!dest->indirect); + if (src->indirect) { + pushi(ctx->current, dest, + load_for_type(dest->type->stype, is_signed), + src, NULL); } else { pushi(ctx->current, dest, Q_COPY, src, NULL); } @@ -189,8 +193,9 @@ gen_expr_access_ident(struct gen_context *ctx, struct qbe_value src = {0}, temp = {0}; qval_for_object(ctx, &src, obj); if (src.indirect) { - gen_loadtemp(ctx, &temp, &src, src.type, - type_is_signed(obj->type)); + gen_loadtemp(ctx, &temp, &src, + qtype_for_type(ctx, obj->type, true), + type_is_signed(obj->type)); gen_store(ctx, out, &temp); } else { gen_store(ctx, out, &src);