Add a coercion/cast operator to CMM
While trying to implement casts between floating-point and integral types #4092 (closed)) @rwbarton suggested the following CMM:
stg_wordToFloatzh(W_ w)
{
D_ d;
STK_CHK_P_LL(WDS(1), stg_wordToFloatzh, w);
Sp(-1) = w;
d = Sp(-1);
return (d);
}
This code works outside of GHC, but when I try to add it as rts/CastFloatWord.cmm
the CMM linter complains with:
Cmm lint error:
in basic block c5
in assignment:
_c2::F64 = I64[Sp + -1 * 8];
Reg ty: F64
Rhs ty: I64
Program was:
{offset
c6: // global
_c1::I64 = R1;
//tick src<rts/CastFloatWord.cmm:(7,1)-(13,1)>
if (Sp - 1 * 8 < SpLim) goto c3; else goto c5;
c3: // global
//tick src<rts/CastFloatWord.cmm:9:35-100>
R1 = _c1::I64;
R2 = stg_wordToFloatzh;
call stg_gc_prim_p_ll(R1, R2) args: 8, res: 0, upd: 8;
c5: // global
I64[Sp + -1 * 8] = _c1::I64;
_c2::F64 = I64[Sp + -1 * 8];
D1 = _c2::F64;
call (P64[(old + 8)])(D1) args: 8, res: 0, upd: 8;
}
For hand written CMM code like this, it would be nice to have a cast/coercion to allow this code to pass the linter.
Looking for suggestions as to the syntax. I suspect that it would be best if the destination type was made explicit in the cast operation.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |