From e30fab31e1935dc5a4154a0dab9cc61c8708953c Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Mon, 5 Oct 2015 17:23:54 -0400 Subject: factor some utility functions/data in util.c --- lisc/spill.c | 47 +++++------------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'lisc/spill.c') diff --git a/lisc/spill.c b/lisc/spill.c index 5642b5a..710ce9a 100644 --- a/lisc/spill.c +++ b/lisc/spill.c @@ -111,35 +111,6 @@ fillcost(Fn *fn) } } -int -bcnt(Bits *b) /* glad I can pull it :) */ -{ - const uint64_t m1 = 0x5555555555555555; - const uint64_t m2 = 0x3333333333333333; - const uint64_t m3 = 0x0f0f0f0f0f0f0f0f; - const uint64_t m4 = 0x00ff00ff00ff00ff; - const uint64_t m5 = 0x0000ffff0000ffff; - const uint64_t m6 = 0x00000000ffffffff; - uint64_t tmp; - int z, i; - - i = 0; - for (z=0; zt[z]; - if (!tmp) - continue; - tmp = (tmp&m1) + (tmp>> 1&m1); - tmp = (tmp&m2) + (tmp>> 2&m2); - tmp = (tmp&m3) + (tmp>> 4&m3); - tmp = (tmp&m4) + (tmp>> 8&m4); - tmp = (tmp&m5) + (tmp>>16&m5); - tmp = (tmp&m6) + (tmp>>32&m6); - i += tmp; - } - return i; -} - -extern Ins insb[NIns], *curi; /* shared work buffer */ static Bits *f; /* temps to prioritize in registers (for tcmp1) */ static Tmp *tmp; /* current temporaries (for tcmpX) */ static int ntmp; /* current # of temps (for limit) */ @@ -197,21 +168,13 @@ slot(int t) return SLOT(s); } -static void -emit(Ins i) -{ - if (curi == insb) - diag("spill: too many instructions"); - *--curi = i; -} - static void store(Ref r, int s) { if (tmp[r.val].wide) - emit((Ins){OStorel, 0, R, {r, SLOT(s)}}); + emit(OStorel, 0, R, r, SLOT(s)); else - emit((Ins){OStorew, 0, R, {r, SLOT(s)}}); + emit(OStorew, 0, R, r, SLOT(s)); } static int @@ -248,7 +211,7 @@ limit(Bits *b, int k, Bits *fst) if (curi) { t = tarr[i]; w = tmp[t].wide; - emit((Ins){OLoad, w, TMP(t), {slot(t)}}); + emit(OLoad, w, TMP(t), slot(t), R); } } return t; @@ -304,7 +267,7 @@ dopm(Blk *b, Ins *i, Bits *v) } else limit(v, NReg, 0); do - emit(*--i1); + emiti(*--i1); while (i1 != i); return i; } @@ -423,7 +386,7 @@ spill(Fn *fn) j -= setloc(&i->arg[1], &v, &w); if (s != -1) store(i->to, s); - emit(*i); + emiti(*i); } for (p=b->phi; p; p=p->link) { -- cgit 1.4.1