GSQRT, GSIN, GCOS, GTAN: if result size is float (as opposed to double),
truncate the result to that length by writing it into memory and
getting it back again (duh!), since that's what gcc does.
Currently, implementation of GITOF et al use the stack, so are
incompatible with current ccall implementation. When the latter
Currently, implementation of GITOF et al use the stack, so are
incompatible with current ccall implementation. When the latter
- is fixed, GITOF et al should present no problem.
+ is fixed, GITOF et al should present no problem. Same issue
+ applies to GCOS, GSIN, GTAN, GSQRT if they have to truncate their
+ result to 32-bit float.
-- nofib/real/hidden gets slightly different FP answers from the
via-C route; possibly due to exp/log not being done in-line.
-- nofib/real/hidden gets slightly different FP answers from the
via-C route; possibly due to exp/log not being done in-line.
= pprG g (hcat [gtab, gpush src 0, text " ; fabs ; ", gpop dst 1])
pprInstr g@(GNEG sz src dst)
= pprG g (hcat [gtab, gpush src 0, text " ; fchs ; ", gpop dst 1])
= pprG g (hcat [gtab, gpush src 0, text " ; fabs ; ", gpop dst 1])
pprInstr g@(GNEG sz src dst)
= pprG g (hcat [gtab, gpush src 0, text " ; fchs ; ", gpop dst 1])
pprInstr g@(GSQRT sz src dst)
pprInstr g@(GSQRT sz src dst)
- = pprG g (hcat [gtab, gpush src 0, text " ; fsqrt ; ", gpop dst 1])
+ = pprG g (hcat [gtab, gpush src 0, text " ; fsqrt"] $$
+ hcat [gtab, gcoerceto sz, gpop dst 1])
pprInstr g@(GSIN sz src dst)
pprInstr g@(GSIN sz src dst)
- = pprG g (hcat [gtab, gpush src 0, text " ; fsin ; ", gpop dst 1])
+ = pprG g (hcat [gtab, gpush src 0, text " ; fsin"] $$
+ hcat [gtab, gcoerceto sz, gpop dst 1])
pprInstr g@(GCOS sz src dst)
pprInstr g@(GCOS sz src dst)
- = pprG g (hcat [gtab, gpush src 0, text " ; fcos ; ", gpop dst 1])
-
+ = pprG g (hcat [gtab, gpush src 0, text " ; fcos"] $$
+ hcat [gtab, gcoerceto sz, gpop dst 1])
pprInstr g@(GTAN sz src dst)
= pprG g (hcat [gtab, text "ffree %st(6) ; ",
gpush src 0, text " ; fptan ; ",
pprInstr g@(GTAN sz src dst)
= pprG g (hcat [gtab, text "ffree %st(6) ; ",
gpush src 0, text " ; fptan ; ",
- text " fstp %st(0) ; ", gpop dst 1])
+ text " fstp %st(0)"] $$
+ hcat [gtab, gcoerceto sz, gpop dst 1])
pprInstr g@(GADD sz src1 src2 dst)
= pprG g (hcat [gtab, gpush src1 0,
pprInstr g@(GADD sz src1 src2 dst)
= pprG g (hcat [gtab, gpush src1 0,
]
--------------------------
]
--------------------------
+
+-- coerce %st(0) to the specified size
+gcoerceto DF = empty
+gcoerceto F = text "subl $4,%esp ; fstps (%esp) ; flds (%esp) ; addl $4,%esp ; "
+
gpush reg offset
= hcat [text "ffree %st(7) ; fld ", greg reg offset]
gpop reg offset
gpush reg offset
= hcat [text "ffree %st(7) ; fld ", greg reg offset]
gpop reg offset