shithub: mc

Download patch

ref: 8c9f5f83949e388b615c71f619d966613e4b08de
parent: 82c7706dac42e23b8ceaf66894bce536a5e3f231
author: Ori Bernstein <[email protected]>
date: Sun Dec 29 20:32:01 EST 2013

Fix float generation up a bit more.

    We now get compiling, but buggy, code generated for sqrt.
    It seems we're hitting a register allocation issue.

--- a/6/insns.def
+++ b/6/insns.def
@@ -34,6 +34,7 @@
 Insn(Iadd,      "\tadd%t %x,%r\n",              Use(.l={1,2}),                  Def(.l={2}))
 Insn(Isub,      "\tsub%t %x,%r\n",              Use(.l={1,2}),                  Def(.l={2}))
 Insn(Iimul,     "\timul%t %x,%r\n",             Use(.l={1,2}),                  Def(.l={2}))
+/* there is no imul for 8 bit values. */
 Insn(Iimul_r,   "\timul%t %r\n",                Use(.l={1},.r={Ral}),           Def(.r={Rax}))
 Insn(Imul,      "\tmul%t %r\n",                 Use(.l={1},.r={Reax}),          Def(.r={Reax,Redx}))
 Insn(Idiv,      "\tdiv%t %r\n",                 Use(.l={1},.r={Reax,Redx}),     Def(.r={Reax,Redx}))
@@ -64,10 +65,10 @@
 Insn(Imovs,      "\tmovs%1t %x,%x\n",           Use(.l={1}),                    Def(.l={2}))
 Insn(Icvttsd2si, "\tcvttsd2si%2t %x,%r\n",      Use(.l={1}),                    Def(.l={2}))
 Insn(Icvttsi2sd, "\tcvttsi2sd%2t %x,%f\n",      Use(.l={1}),                    Def(.l={2}))
-Insn(Iadds,      "\tadds%t %x,%f\n",            Use(.l={1},.r={Reax,Redx}),     Def(.r={Reax,Redx}))
-Insn(Isubs,      "\tsubs%t %x,%f\n",            Use(.l={1},.r={Reax,Redx}),     Def(.r={Reax,Redx}))
+Insn(Iadds,      "\tadds%t %x,%f\n",            Use(.l={1,2}),                  Def(.l={2}))
+Insn(Isubs,      "\tsubs%t %x,%f\n",            Use(.l={1,2}),                  Def(.l={2}))
 Insn(Imuls,      "\tmuls%t %x,%f\n",            Use(.l={1,2}),                  Def(.l={2}))
-Insn(Idivs,      "\tdivs%t %x,%f\n",            Use(.l={1},.r={Reax,Redx}),     Def(.r={Reax,Redx}))
+Insn(Idivs,      "\tdivs%t %x,%f\n",            Use(.l={1,2}),                  Def(.l={2}))
 Insn(Icomis,     "\tcomis%t %x,%f\n",           Use(.l={1,2}),                  Def())
 Insn(Ixorp,      "\tmuls%t %x,%f\n",            Use(.l={1,2}),                  Def(.l={2}))
 
--- a/6/simp.c
+++ b/6/simp.c
@@ -1389,10 +1389,12 @@
             break;
         case Oneg:
             if (istyfloat(exprtype(n))) {
-                t = mkexpr(n->line, Olit, mkfloat(n->line, -1.0), NULL);
-                t->expr.type = n->expr.type;
-                u = simplit(s, t, &s->blobs, &s->nblobs);
-                r = mkexpr(n->line, Ofmul, u, args[0], NULL);
+                t =mkfloat(n->line, -1.0); 
+                u = mkexpr(n->line, Olit, t, NULL);
+                t->lit.type = n->expr.type;
+                u->expr.type = n->expr.type;
+                v = simplit(s, u, &s->blobs, &s->nblobs);
+                r = mkexpr(n->line, Ofmul, v, args[0], NULL);
                 r->expr.type = n->expr.type;
             } else {
                 r = visit(s, n);