aboutsummaryrefslogtreecommitdiff
path: root/amd64/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2017-06-06 10:09:31 -0400
committerQuentin Carbonneaux <[email protected]>2017-06-06 10:09:31 -0400
commit5dcf8c14cbefb3f96262e5fbe5168cfe48e6fd3a (patch)
tree0261a28ea1457d1c1841c3530ef10470f4487a0f /amd64/emit.c
parent66288673cdce588bf81612c0599047665afefce7 (diff)
fix floating-point division
It never worked until today.
Diffstat (limited to 'amd64/emit.c')
-rw-r--r--amd64/emit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index cd485bb..4d4d3be 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -405,6 +405,16 @@ emitins(Ins i, Fn *fn, FILE *f)
break;
}
goto Table;
+ case Odiv:
+ /* adjust the instruction when the conversion to
+ * a 2-address division is impossible */
+ if (req(i.to, i.arg[1])) {
+ i.arg[1] = TMP(XMM0+15);
+ emitf("mov%k %=, %1", &i, fn, f);
+ emitf("mov%k %0, %=", &i, fn, f);
+ i.arg[0] = i.to;
+ }
+ goto Table;
case Ocopy:
/* make sure we don't emit useless copies,
* also, we can use a trick to load 64-bits