ref: 53712aa0fc95a84fa36b4960aeef98ceee6859bc
parent: 7462d862115db5b21243a451c4a3e9fa6b4265f9
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Feb 8 19:02:19 EST 2015
Fix int->float conversion.
--- a/6/insns.def
+++ b/6/insns.def
@@ -255,7 +255,7 @@
Use(.l={1}),
Def(.l={2}))
Insn(Icvttsi2sd,
- "\tcvttsi2sd%2t %x,%f\n",
+ "\tcvtsi2s%2t %x,%f\n",
"\tCVTTS%2T2SD %X,%F\n",
Use(.l={1}),
Def(.l={2}))
--- a/6/isel.c
+++ b/6/isel.c
@@ -759,17 +759,13 @@
break;
case Oint2flt:
a = selexpr(s, args[0]);
- b = locreg(ModeQ);
r = locreg(mode(n));
- g(s, Imovs, a, b, NULL);
- g(s, Icvttsi2sd, b, r, NULL);
+ g(s, Icvttsi2sd, a, r, NULL);
break;
case Oflt2int:
a = selexpr(s, args[0]);
- b = locreg(ModeQ);
r = locreg(mode(n));
- g(s, Icvttsd2si, a, b, NULL);
- g(s, Imov, b, r, NULL);
+ g(s, Icvttsd2si, a, r, NULL);
break;
case Oflt2flt:
--- a/6/simp.c
+++ b/6/simp.c
@@ -916,7 +916,7 @@
case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64:
case Tyint: case Tyuint: case Tylong: case Tyulong:
case Tychar: case Tybyte:
- r = mkexpr(val->loc, Oflt2int, rval(s, val, NULL), NULL);
+ r = mkexpr(val->loc, Oint2flt, rval(s, val, NULL), NULL);
r->expr.type = to;
break;
case Tyflt32: case Tyflt64:
--- a/libstd/fmt.myr
+++ b/libstd/fmt.myr
@@ -226,11 +226,9 @@
b = buf[n:]
/* FIXME(ori): bug, b[n:].len fails since b[n:] isn't an lval */
n += flt64bfmt(buf[n:], f_val, 0, b.len)
- /* FIXME: flt casts are currently broken
| 'F':
(F_val, ap) = vanext(ap)
- n += fltfmt(buf[n:], F_val castto(flt64))
- */
+ n += flt64bfmt(buf[n:], F_val castto(flt64), 0, b.len)
/* format integers */
| 'b':
if signed