question about coercions between primitive types in STG level
Ömer Sinan Ağacan
omeragacan at gmail.com
Sun Dec 6 18:24:36 UTC 2015
In my compiler pass(D1559, see ElimUbxSums.hs) I'm doing some unsafe coercions
at the STG level. It works fine for lifted types, but for unlifted ones I'm
having some problems. What I'm trying to do is given a number of primitive
types I'm finding the one with biggest size, and then generating a constructor
that takes this biggest primitive type as argument.
The problem is that this is not working very well - GHC is generating illegal
instructions that try to load a F32 value to a register allocated for I64,
using movss instruction.
CoreLint is catching this error and printing this:
Cmm lint error:
in basic block c1hF
_g16W::I64 = 4.5 :: W32; // CmmAssign
Reg ty: I64
Rhs ty: F32
So I have two questions about this:
1. Is there a way to safely do this? What are my options here? What I'm trying
to do is to use a single data constructor field for different primitive
types. The field is guaranteed to be as big as necessary.
2. In the Cmm code shown above, the type annotation is showing `W32` but in the
error message it says `F32`. I'm confused about this, is this error message
given because the sizes don't match? (64bits vs 32bits) Why the type
annotation says W32 while the value has type F32?
More information about the ghc-devs