From b33febc25cce5c836bad952da472f6a54e777ed8 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Fri, 23 Oct 2015 11:28:45 -0400 Subject: prepare for using memory refs --- lisc/isel.c | 18 ++++++------------ lisc/lisc.h | 20 ++++++++++++-------- lisc/parse.c | 7 ++----- 3 files changed, 20 insertions(+), 25 deletions(-) (limited to 'lisc') diff --git a/lisc/isel.c b/lisc/isel.c index 9235c83..5bbbab1 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -14,7 +14,6 @@ */ typedef struct ANum ANum; -typedef struct Addr Addr; typedef struct AClass AClass; struct ANum { @@ -22,13 +21,6 @@ struct ANum { Ins *i; }; -struct Addr { - Con offset; - Ref base; - Ref index; - int scale; -}; - static void amatch(Addr *, Ref, ANum *, Fn *, int); static int @@ -83,7 +75,7 @@ rslot(Ref r, Fn *fn) static void sel(Ins i, ANum *an, Fn *fn) { - static char logS[] = {[1] = 0, [2] = 1, [4] = 2, [8] = 3}; + static char logS[] = {[2] = 1, [4] = 2, [8] = 3}; Ins *i0; Ref r0, r1; int n, x, s, w; @@ -145,7 +137,7 @@ sel(Ins i, ANum *an, Fn *fn) i.arg[0] = SLOT(cpy[0].s); cpy[0].s = -1; } - goto Emit; + break; case OXPush: case OCall: case OSAlloc: @@ -158,6 +150,7 @@ sel(Ins i, ANum *an, Fn *fn) case_OExt: Emit: emiti(i); +#if 0 for (n=0; n<2; n++) { /* fuse memory loads into arithmetic * operations when the sizes match @@ -183,6 +176,7 @@ Emit: emit(x, 0, R, r1, a.index); } } +#endif for (n=0; n<2; n++) { /* load constants that do not fit in * a 32bit signed integer into a @@ -674,8 +668,8 @@ anumber(ANum *ai, Blk *b, Con *con) continue; a1 = aref(i->arg[0], ai); a2 = aref(i->arg[1], ai); - t1 = a1 != 1 & a1 != 2; - t2 = a2 != 1 & a2 != 2; + t1 = a1 != 1 && a1 != 2; + t2 = a2 != 1 && a2 != 2; if (i->op == OAdd) { a = add[n1 = a1][n2 = a2]; if (t1 && a < add[0][a2]) diff --git a/lisc/lisc.h b/lisc/lisc.h index f5283a8..166c18c 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -16,6 +16,7 @@ typedef struct Phi Phi; typedef struct Blk Blk; typedef struct Tmp Tmp; typedef struct Con Con; +typedef struct Addr Mem; typedef struct Fn Fn; typedef struct Typ Typ; typedef struct Dat Dat; @@ -178,14 +179,6 @@ enum Op { OXSet, OXSet1 = OXSet + NCmp-1, OXTest, - OXScale01, /* memory addressing */ - OXScale02, - OXScale04, - OXScale08, - OXScale11, - OXScale12, - OXScale14, - OXScale18, NOp }; @@ -265,12 +258,23 @@ struct Con { int64_t val; }; +typedef struct Addr Addr; + +struct Addr { /* x64 addressing */ + Con offset; + Ref base; + Ref index; + int scale; +}; + struct Fn { Blk *start; Tmp *tmp; Con *con; + Mem *mem; int ntmp; int ncon; + int nmem; int nblk; int retty; Blk **rpo; diff --git a/lisc/parse.c b/lisc/parse.c index c09f6e3..d0ac325 100644 --- a/lisc/parse.c +++ b/lisc/parse.c @@ -32,11 +32,6 @@ OpDesc opdesc[NOp] = { [OAlloc+1] = { "alloc8", 1 }, [OAlloc+2] = { "alloc16", 1 }, -#define X(n) [OXScale##n] = { "ofid" #n, 0 } - X(01), X(02), X(04), X(08), - X(11), X(12), X(14), X(18), -#undef X - #define X(t) \ [OLoad+T##t] = { "load" #t, 0 }, \ [OExt+T##t] = { "ext" #t, 1 }, @@ -624,8 +619,10 @@ parsefn() err("last block misses jump"); fn->tmp = tmp; fn->con = con; + fn->mem = vnew(0, sizeof fn->mem[0]); fn->ntmp = ntmp; fn->ncon = ncon; + fn->nmem = 0; fn->nblk = nblk; fn->rpo = 0; return fn; -- cgit 1.4.1