diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-12-12 17:36:15 +0100 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-12-12 22:16:33 +0100 |
commit | c0f25aeae3ef5d5f4b6bc5678f8d8ce40597d673 (patch) | |
tree | 26b78f6db8a8fd46005ce94835b0135a6df4eef7 /arm64 | |
parent | 2ec355df6adc457303fcf2076b559fefd80ee593 (diff) | |
download | roux-c0f25aeae3ef5d5f4b6bc5678f8d8ce40597d673.tar.gz |
new rsval() helper for signed Refs
The .val field is signed in RSlot. Add a new dedicated function to fetch it as a signed int.
Diffstat (limited to 'arm64')
-rw-r--r-- | arm64/emit.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/arm64/emit.c b/arm64/emit.c index 4a0316c..5113c66 100644 --- a/arm64/emit.c +++ b/arm64/emit.c @@ -138,9 +138,11 @@ rname(int r, int k) } static uint64_t -slot(int s, E *e) +slot(Ref r, E *e) { - s = ((int32_t)s << 3) >> 3; + int s; + + s = rsval(r); if (s == -1) return 16 + e->frame; if (s < 0) { @@ -234,7 +236,7 @@ emitf(char *s, Ins *i, E *e) fprintf(e->f, "[%s]", rname(r.val, Kl)); break; case RSlot: - fprintf(e->f, "[x29, %"PRIu64"]", slot(r.val, e)); + fprintf(e->f, "[x29, %"PRIu64"]", slot(r, e)); break; } break; @@ -333,7 +335,7 @@ fixarg(Ref *pr, int sz, E *e) r = *pr; if (rtype(r) == RSlot) { - s = slot(r.val, e); + s = slot(r, e); if (s > sz * 4095u) { i = &(Ins){Oaddr, Kl, TMP(IP0), {r}}; emitins(i, e); @@ -410,7 +412,7 @@ emitins(Ins *i, E *e) case Oaddr: assert(rtype(i->arg[0]) == RSlot); rn = rname(i->to.val, Kl); - s = slot(i->arg[0].val, e); + s = slot(i->arg[0], e); if (s <= 4095) fprintf(e->f, "\tadd\t%s, x29, #%"PRIu64"\n", rn, s); else if (s <= 65535) |