= StData (promote_to_word (getAmodeRep amode)) [a2stix amode]
-- We need to promote any item smaller than a word to a word
- promote_to_word Int8Rep = IntRep
- promote_to_word CharRep = IntRep
- promote_to_word other = other
+ promote_to_word pk
+ | sizeOf pk >= sizeOf IntRep = pk
+ | otherwise = IntRep
upd_reqd = closureUpdReqd cl_info
= StPrim IntAddOp [
base,
let s = shift pk
- in ASSERT(toInteger s == expectJust "MachCode" (exactLog2 (sizeOf pk)))
- if s == 0 then off else StPrim SllOp [off, StInt s]
+ in if s == 0 then off else StPrim SllOp [off, StInt (toInteger s)]
]
where
- shift DoubleRep = 3::Integer
- shift CharRep = 2::Integer
- shift Int8Rep = 0::Integer
- shift _ = IF_ARCH_alpha(3,2)
+ shift :: PrimRep -> Int
+ shift rep = case (fromInteger (sizeOf rep) :: Int) of
+ 1 -> 0
+ 2 -> 1
+ 4 -> 2
+ 8 -> 3
+ other -> pprPanic "MachCode.mangleIndexTree.shift: unhandled rep size"
+ (int other)
\end{code}
\begin{code}
primCode ls IndexOffForeignObjOp_Int64 rs = primCode_IndexOffForeignObjOp Int64Rep ls rs
primCode ls IndexOffForeignObjOp_Word64 rs = primCode_IndexOffForeignObjOp Word64Rep ls rs
+primCode ls WriteOffAddrOp_Word8 rs = primCode_WriteOffAddrOp Word8Rep ls rs
primCode ls WriteOffAddrOp_Char rs = primCode_WriteOffAddrOp Word8Rep ls rs
primCode ls WriteOffAddrOp_Int rs = primCode_WriteOffAddrOp IntRep ls rs
primCode ls WriteOffAddrOp_Word rs = primCode_WriteOffAddrOp WordRep ls rs