diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-03 14:05:21 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:30 -0400 |
commit | 0c20fda622ee9f7170ab327b3c5ce30cc177e10b (patch) | |
tree | 69f0ecd215b64edbc0fdc64f151f0ebe401364c9 /lisc/isel.c | |
parent | 9456200d91840b09cb876146c271c5cbe503d767 (diff) | |
download | roux-0c20fda622ee9f7170ab327b3c5ce30cc177e10b.tar.gz |
use regs of the correct type in isel
Diffstat (limited to 'lisc/isel.c')
-rw-r--r-- | lisc/isel.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lisc/isel.c b/lisc/isel.c index 4fad703..f08288d 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -42,18 +42,26 @@ newtmp(int type, Fn *fn) static void sel(Ins *i, Fn *fn) { + Ref r0, r1, ra, rd; int t; - Ref r0, r1; switch (i->op) { case ODiv: - r0 = REG(RAX); - r1 = REG(RDX); - if (0) { case ORem: - r0 = REG(RDX); - r1 = REG(RAX); - } + switch (fn->tmp[i->to.val].type) { + default: + diag("isel: invalid division"); + case TWord: + ra = REG(EAX); + rd = REG(EDX); + break; + case TLong: + ra = REG(RAX); + rd = REG(RDX); + break; + } + r0 = i->op == ODiv ? ra : rd; + r1 = i->op == ODiv ? rd : ra; emit(OCopy, i->to, r0, R); emit(OCopy, R, r1, R); if (rtype(i->arg[1]) == RCon) { @@ -65,8 +73,8 @@ sel(Ins *i, Fn *fn) } else r0 = i->arg[1]; emit(OXDiv, R, r0, R); - emit(OSign, REG(RDX), REG(RAX), R); - emit(OCopy, REG(RAX), i->arg[0], R); + emit(OSign, rd, ra, R); + emit(OCopy, ra, i->arg[0], R); if (rtype(i->arg[1]) == RCon) emit(OCopy, r0, i->arg[1], R); break; |