summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-09 12:13:19 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:30 -0400
commita69fe2c6c53ecad229c4477d541721084bba02df (patch)
tree805dc3e9807d0fc13697fbc23e849c7b086cc445
parente234a7a18854fdd49e1fcde53c696ebbf5478d7a (diff)
downloadroux-a69fe2c6c53ecad229c4477d541721084bba02df.tar.gz
ugly support for store/load
-rw-r--r--lisc/emit.c29
-rw-r--r--lisc/isel.c27
2 files changed, 51 insertions, 5 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 7d62363..2e76209 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -170,16 +170,35 @@ eins(Ins i, Fn *fn, FILE *f)
eop("mov", i.arg[0], i.to, fn, f);
break;
case OStore:
- s = rtoa[i.arg[0].val];
+ if (rtype(i.arg[0]) == RCon) {
+ fprintf(f, "\tmovl ");
+ eref(i.arg[0], fn, f);
+ fprintf(f, ", ");
+ } else {
+ assert(rtype(i.arg[0]) == RReg);
+ fprintf(f, "\tmov %%%s, ", rtoa[i.arg[0].val]);
+ }
goto Store;
case OStores:
- s = rsub[BASE(i.arg[0].val)].s;
+ if (rtype(i.arg[0]) == RCon) {
+ fprintf(f, "\tmovw ");
+ eref(i.arg[0], fn, f);
+ fprintf(f, ", ");
+ } else {
+ assert(rtype(i.arg[0]) == RReg);
+ fprintf(f, "\tmovw %%%s, ", rsub[BASE(i.arg[0].val)].s);
+ }
goto Store;
case OStoreb:
- s = rsub[BASE(i.arg[0].val)].b;
+ if (rtype(i.arg[0]) == RCon) {
+ fprintf(f, "\tmovb ");
+ eref(i.arg[0], fn, f);
+ fprintf(f, ", ");
+ } else {
+ assert(rtype(i.arg[0]) == RReg);
+ fprintf(f, "\tmovb %%%s, ", rsub[BASE(i.arg[0].val)].b);
+ }
Store:
- assert(rtype(i.arg[0]) == RReg);
- fprintf(f, "\tmov %s, ", s);
emem(i.arg[1], fn, f);
fprintf(f, "\n");
break;
diff --git a/lisc/isel.c b/lisc/isel.c
index 36466ee..30c9b1f 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -117,6 +117,33 @@ sel(Ins i, Fn *fn)
case OCopy:
emit(i.op, i.to, i.arg[0], i.arg[1]);
break;
+ case OStore:
+ case OStoreb:
+ case OStores:
+ r0 = i.arg[0];
+ goto Load;
+ case OLoad:
+ case OLoadss:
+ case OLoadus:
+ case OLoadsb:
+ case OLoadub:
+ r0 = i.arg[0];
+ if (rtype(r0) == RCon) {
+ t = newtmp(TLong, fn);
+ r0 = TMP(t);
+ }
+ Load:
+ r1 = i.arg[1];
+ if (rtype(r1) == RCon) {
+ t = newtmp(TLong, fn);
+ r1 = TMP(t);
+ }
+ emit(i.op, i.to, r0, r1);
+ if (!req(r0, i.arg[0]))
+ emit(OCopy, r0, i.arg[0], R);
+ if (!req(r1, i.arg[1]))
+ emit(OCopy, r1, i.arg[1], R);
+ break;
case ONop:
break;
default: