works now.
emit "li32 %out.1, 0"
cost 8;
- out:(iret)reg = FROMF.I(in:(dret)reg)
+ out:(iret)reg = FROMSF.I(in:(dret)reg)
with corrupted(volatile)
emit "bl .fromf2i"
cost 4;
- out:(iret)reg = FROMD.I(in:(dret)reg)
+ out:(int)reg = FROMSD.I(in:(double)reg)
+ with preserved(%in)
+ emit "fctiwz %in, %in"
+ emit "stfdu %in, -8(sp)"
+ emit "lwz %out, 4(sp)"
+ emit "addi sp, sp, 8"
+ cost 16;
+
+ out:(int)reg = FROMUD.I(in:(double)reg)
with corrupted(volatile)
- emit "bl .fromd2i"
+ emit "stfdu %in, -8(sp)"
+ emit "bl .cfu8"
+ emit "lwz %out, 0(sp)"
+ emit "addi sp, sp, 4"
+ cost 16;
+
+ out:(lret)reg = FROMSF.L(in:(fret)reg)
+ with corrupted(volatile)
+ emit "bl .fromf2l"
cost 4;
- out:(lret)reg = FROMF.L(in:(fret)reg)
+ out:(lret)reg = FROMUF.I(in:(fret)reg)
with corrupted(volatile)
emit "bl .fromf2l"
cost 4;
case op_cii: simple_convert(IR_FROMSI); break;
case op_ciu: simple_convert(IR_FROMSI); break;
case op_cui: simple_convert(IR_FROMUI); break;
- case op_cfu: simple_convert(IR_FROMF); break; /* FIXME: technically wrong */
- case op_cfi: simple_convert(IR_FROMF); break;
+ case op_cfu: simple_convert(IR_FROMUF); break;
+ case op_cfi: simple_convert(IR_FROMSF); break;
case op_cif: simple_convert(IR_FROMSI); break;
case op_cuf: simple_convert(IR_FROMUI); break;
- case op_cff: simple_convert(IR_FROMF); break;
+ case op_cff: simple_convert(IR_FROMSF); break;
case op_cmp:
push(
--- /dev/null
+#include "test.h"
+
+/* Constants in globals to defeat constant folding. */
+double one = 1.0;
+double zero = 0.0;
+double minusone = -1.0;
+double big = 2147483647.0;
+double minusbig = -2147483648.0;
+
+/* Bypasses the CRT, so there's no stdio or BSS initialisation. */
+void _m_a_i_n(void)
+{
+ ASSERT((int)zero == 0);
+ ASSERT((int)one == 1);
+ ASSERT((int)minusone == -1);
+ ASSERT((int)big == 2147483647);
+ ASSERT((int)minusbig == -2147483648);
+
+ finished();
+}
\ No newline at end of file
--- /dev/null
+#include "test.h"
+
+/* Constants in globals to defeat constant folding. */
+double one = 1.0;
+double zero = 0.0;
+double big = 4294967295.0;
+
+/* Bypasses the CRT, so there's no stdio or BSS initialisation. */
+void _m_a_i_n(void)
+{
+ ASSERT((unsigned int)zero == 0);
+ ASSERT((unsigned int)one == 1);
+ ASSERT((unsigned int)big == 4294967295);
+
+ finished();
+}
\ No newline at end of file
S ?=L. FROMUL
S ?=I. FROMSI
S ?=L. FROMSL
-S ?=F. FROMF
-S ?=D. FROMD
+S ?=F. FROMUF
+S ?=D. FROMUD
+S ?=F. FROMSF
+S ?=D. FROMSD
S L=II FROMIPAIR
S I=L. FROML0
S I=L. FROML1