diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-08 18:06:47 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:30 -0400 |
commit | 76bf96b2682190686e2f570405ae8762a8791c55 (patch) | |
tree | 1beab449b06fd53b1adcf40262e0f903c3ebbaba /lisc/spill.c | |
parent | 9966a181c13928bd145ee35a945520f94c3cd61d (diff) | |
download | roux-76bf96b2682190686e2f570405ae8762a8791c55.tar.gz |
add nmem to opdesc for use in the spiller
This new machine-independent mechanism might not be general enough in the long term but, now, it provides a flexible way to inform the spiller about the maximum number of arguments of an instruction that can be spill locations.
Diffstat (limited to 'lisc/spill.c')
-rw-r--r-- | lisc/spill.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lisc/spill.c b/lisc/spill.c index 3ca297a..14b33c5 100644 --- a/lisc/spill.c +++ b/lisc/spill.c @@ -223,7 +223,7 @@ limit(Bits *b, int k, Bits *fst) return t; } -static void +static int setloc(Ref *pr, Bits *v, Bits *w) { int t; @@ -242,7 +242,7 @@ setloc(Ref *pr, Bits *v, Bits *w) BSET(br, pr->val); } if (rtype(*pr) != RTmp) - return; + return 0; t = pr->val; BSET(*v, t); if (limit(v, nreg, w) == t) @@ -250,10 +250,13 @@ setloc(Ref *pr, Bits *v, Bits *w) * it was not live so we don't * have to reload it */ curi++; - if (!BGET(*v, t)) + if (!BGET(*v, t)) { *pr = slot(t); - else + return 1; + } else { BSET(*w, t); + return 0; + } } /* spill code insertion @@ -361,18 +364,13 @@ spill(Fn *fn) case -1:; } w = (Bits){{0}}; - setloc(&i->arg[0], &v, &w); - if (i->op == OXCmpw || i->op == OXCmpl) - if (rtype(i->arg[0]) == RSlot) { - /* <arch> - * we make sure that comparisons - * do not get their two operands - * in memory slots - */ - assert(rtype(i->arg[1]) == RTmp); + j = opdesc[i->op].nmem; + if (!j && rtype(i->arg[0]) == RTmp) + BSET(w, i->arg[0].val); + j -= setloc(&i->arg[0], &v, &w); + if (!j && rtype(i->arg[1]) == RTmp) BSET(w, i->arg[1].val); - } - setloc(&i->arg[1], &v, &w); + j -= setloc(&i->arg[1], &v, &w); if (s) emit(OStore, R, i->to, SLOT(s)); emit(i->op, i->to, i->arg[0], i->arg[1]); |