diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-07-31 10:21:10 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:29 -0400 |
commit | d8d17705c4f525314471f5526ef3328dd41625cd (patch) | |
tree | 9b0f9b2a90918f16647898e296f303407a95725e /lisc/emit.c | |
parent | 1a78659dfab54d808fbc568d6b7ff5e4012695c0 (diff) | |
download | roux-d8d17705c4f525314471f5526ef3328dd41625cd.tar.gz |
clean the commutativity + fix bug in emit
The commutativity information only makes sense for arithmetic expressions. To account for that, I introduced a new tri-valued boolean type B3. Memory operations, for example, will receive an undefined commutativity trit. The code emitter was buggy when rega emitted instructions like 'rax = add 1, rax', this is now fixed using the commutativity information (we rewrite it in 'rax = add rax, 1').
Diffstat (limited to 'lisc/emit.c')
-rw-r--r-- | lisc/emit.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index 141c3f2..6a485a7 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -57,6 +57,15 @@ eins(Ins i, Fn *fn, FILE *f) switch (i.op) { case OAdd: case OSub: + if (req(i.to, i.arg[1])) + switch (opdesc[i.op].comm) { + case T: + i.arg[1] = i.arg[0]; + i.arg[0] = i.to; + break; + default: + diag("emit: instruction can't be encoded"); + } if (!req(i.to, i.arg[0])) eop("mov", i.arg[0], i.to, fn, f); eop(opi[i.op], i.arg[1], i.to, fn, f); |