From 7a7a5f480312b997dcac0e4cc3befb502e54c836 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Mon, 14 Mar 2022 10:40:30 +0100 Subject: improve consistency in abis --- arm64/abi.c | 15 ++++++--------- rv64/abi.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arm64/abi.c b/arm64/abi.c index b6b4612..0e4b941 100644 --- a/arm64/abi.c +++ b/arm64/abi.c @@ -397,6 +397,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) ldregs(c->reg, c->cls, c->nreg, i->arg[1], fn); } + /* populate the stack */ off = 0; for (i=i0, c=ca; iclass & Cstk) == 0) @@ -456,9 +457,9 @@ selpar(Fn *fn, Ins *i0, Ins *i1) } t = tmp; - for (i=i0, c=ca, s=2; iop == Oparc - && (c->class & Cptr) == 0) { + s = 2; + for (i=i0, c=ca; iop == Oparc && !(c->class & Cptr)) { if (c->class & Cstk) { fn->tmp[i->to.val].slot = -s; s += c->size / 8; @@ -468,15 +469,11 @@ selpar(Fn *fn, Ins *i0, Ins *i1) emit(Ocopy, c->cls[n], *t++, r, R); } } else if (c->class & Cstk) { - r = newtmp("abi", Kl, fn); - emit(Oload, *c->cls, i->to, r, R); - emit(Oaddr, Kl, r, SLOT(-s), R); + emit(Oload, *c->cls, i->to, SLOT(-s), R); s++; } else { - r = TMP(*c->reg); - emit(Ocopy, *c->cls, i->to, r, R); + emit(Ocopy, *c->cls, i->to, TMP(*c->reg), R); } - } if (!req(R, env)) die("todo: env calls"); diff --git a/rv64/abi.c b/rv64/abi.c index ddcba9d..d937fe8 100644 --- a/rv64/abi.c +++ b/rv64/abi.c @@ -425,17 +425,20 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) if (!stk) return; + /* populate the stack */ + off = 0; r = newtmp("abi", Kl, fn); - for (i=i0, c=ca, off=0; iop == Oargv || !(c->class & Cstk)) continue; if (i->op == Oarg) { r1 = newtmp("abi", Kl, fn); emit(Ostorew+i->cls, Kw, R, i->arg[0], r1); if (i->cls == Kw) { - /* TODO: we only need this sign extension - * for subtyped l temporaries passed as w - * arguments (see rv64/isel.c:fixarg) + /* TODO: we only need this sign + * extension for l temps passed + * as w arguments + * (see rv64/isel.c:fixarg) */ curi->op = Ostorel; curi->arg[0] = newtmp("abi", Kl, fn); @@ -530,8 +533,9 @@ selpar(Fn *fn, Ins *i0, Ins *i1) } else if (c->class & Cstk1) { emit(Oload, *c->cls, i->to, SLOT(-s), R); s++; - } else + } else { emit(Ocopy, *c->cls, i->to, TMP(*c->reg), R); + } return (Params){ .stk = s, -- cgit 1.4.1