diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-09-01 19:03:53 +0200 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-09-01 19:03:53 +0200 |
commit | f135a0b1fdfd22b0f32e5021ab4e486e681129a1 (patch) | |
tree | 001a0107513023c73b2034a75374bfa26b646bd8 /arm64/emit.c | |
parent | 8dddb971d923fa19dced39013e6d4a39676e065a (diff) | |
download | roux-f135a0b1fdfd22b0f32e5021ab4e486e681129a1.tar.gz |
use direct bl calls on arm64
This generates tidier code and is pic friendly because it lets the linker trampoline calls to dynlinked libs.
Diffstat (limited to 'arm64/emit.c')
-rw-r--r-- | arm64/emit.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/arm64/emit.c b/arm64/emit.c index ec4d350..694abf3 100644 --- a/arm64/emit.c +++ b/arm64/emit.c @@ -306,10 +306,11 @@ fixarg(Ref *pr, int sz, E *e) static void emitins(Ins *i, E *e) { - char *rn; + char *l, *p, *rn; uint64_t s; int o; Ref r; + Con *c; switch (i->op) { default: @@ -355,7 +356,8 @@ emitins(Ins *i, E *e) assert(isreg(i->to)); switch (rtype(i->arg[0])) { case RCon: - loadcon(&e->fn->con[i->arg[0].val], i->to.val, i->cls, e->f); + c = &e->fn->con[i->arg[0].val]; + loadcon(c, i->to.val, i->cls, e->f); break; case RSlot: i->op = Oload; @@ -386,6 +388,16 @@ emitins(Ins *i, E *e) rn, s & 0xFFFF, rn, s >> 16, rn, rn ); break; + case Ocall: + if (rtype(i->arg[0]) != RCon) + goto Table; + c = &e->fn->con[i->arg[0].val]; + if (c->type != CAddr || c->bits.i) + die("invalid call argument"); + l = str(c->label); + p = l[0] == '"' ? "" : T.assym; + fprintf(e->f, "\tbl\t%s%s\n", p, l); + break; case Osalloc: emitf("sub sp, sp, %0", i, e); if (!req(i->to, R)) |