commit 90138539bce046fa8746c326841d2fc7e4e8c20d
parent 059d378b9d4115061647b8efae95b3a7dc54abe2
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 4 Feb 2016 12:21:45 -0500
fix emit bugs for binops
Diffstat:
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/lisc/emit.c b/lisc/emit.c
@@ -41,11 +41,11 @@ static struct {
short cls;
char *asm;
} omap[] = {
- { OAdd, Ka, "+add%k %1, %0" },
- { OSub, Ka, "-sub%k %1, %0" },
- { OAnd, Ki, "+and%k %1, %0" },
- { OMul, Ki, "+imul%k %1, %0" },
- { ODiv, Ka, "-div%k %1, %0" },
+ { OAdd, Ka, "+add%k %1, %=" },
+ { OSub, Ka, "-sub%k %1, %=" },
+ { OAnd, Ki, "+and%k %1, %=" },
+ { OMul, Ki, "+imul%k %1, %=" },
+ { ODiv, Ka, "-div%k %1, %=" },
{ OStorel, Ki, "movq %L0, %M1" },
{ OStorew, Ki, "movl %W0, %M1" },
{ OStoreh, Ki, "movw %H0, %M1" },
@@ -187,8 +187,6 @@ emitf(char *s, Ins *i, Fn *fn, FILE *f)
Mem *m;
Con off;
- fputc('\t', f);
-
switch (*s) {
case '+':
if (req(i->arg[1], i->to)) {
@@ -200,11 +198,12 @@ emitf(char *s, Ins *i, Fn *fn, FILE *f)
case '-':
if (req(i->arg[1], i->to) && !req(i->arg[0], i->to))
diag("emit: cannot convert to 2-address");
- emitcopy(i->arg[0], i->to, i->cls, fn, f);
+ emitcopy(i->to, i->arg[0], i->cls, fn, f);
s++;
break;
}
+ fputc('\t', f);
Next:
while ((c = *s++) != '%')
if (!c) {