aboutsummaryrefslogtreecommitdiffhomepage
path: root/x86_64/isel.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-18 08:50:47 +0100
committerlemon <lsof@mailbox.org>2025-12-18 08:50:47 +0100
commitd43993dfaa1cf9b684583a0c9266e18ea61abb4d (patch)
tree4472cf1bfe63fbce17815fea4da1cb9c818288a9 /x86_64/isel.c
parentbfc03147a0cdac72250819443b529b379572471c (diff)
x86_64: for vararg calls, write to EAX in isel
Also, in regalloc ensure fixed intervals are sorted
Diffstat (limited to 'x86_64/isel.c')
-rw-r--r--x86_64/isel.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/x86_64/isel.c b/x86_64/isel.c
index 67a4358..22a1290 100644
--- a/x86_64/isel.c
+++ b/x86_64/isel.c
@@ -126,6 +126,7 @@ selcall(struct function *fn, struct instr *ins, struct block *blk, int *curi)
int iarg = *curi - 1;
enum irclass cls;
uint argstksiz = alignup(call->argstksiz, 16);
+ int nsse = 0;
for (int i = call->narg - 1; i >= 0; --i) {
struct abiarg abi = call->abiarg[i];
@@ -139,6 +140,7 @@ selcall(struct function *fn, struct instr *ins, struct block *blk, int *curi)
if (!abi.isstk) {
assert(!abi.ty.isagg);
*arg = mkinstr(Omove, call->abiarg[i].ty.cls, mkref(RREG, abi.reg), arg->r);
+ if (abi.reg >= XMM0) ++nsse;
} else {
union ref adr = mkaddr((struct addr){mkref(RREG, RSP), .disp = abi.stk});
int iargsave = iarg;
@@ -165,10 +167,9 @@ selcall(struct function *fn, struct instr *ins, struct block *blk, int *curi)
else if (isintcon(ins->l))
ins->l = insertinstr(blk, (*curi)++, mkinstr(Ocopy, KPTR, ins->l));
- if (call->vararg >= 0 && ins->l.t == RTMP) {
- /* variadic calls write number of sse regs used to AL, so mark it as clobbered such that
- * the function pointer of an indirect calls does not get allocated to RAX by regalloc */
- insertinstr(blk, (*curi)++, mkinstr(Omove, KPTR, mkref(RREG, RAX), mkref(RREG, RAX)));
+ if (call->vararg >= 0) {
+ /* variadic calls write number of sse regs used to AL */
+ insertinstr(blk, (*curi)++, mkinstr(Omove, KI32, mkref(RREG, RAX), mkref(RICON, nsse), .keep=1));
}
cls = ins->cls;
ins->cls = 0;