Commit e5d9aaa2 authored by Simon Marlow's avatar Simon Marlow

Pad static literals to word size in the code generator

parent 23e4e103
......@@ -145,7 +145,6 @@ pprTop top@(CmmData _section (CmmDataLabel lbl : lits)) =
-- these shouldn't appear?
pprTop (CmmData _ _) = panic "PprC.pprTop: can't handle this data"
-- --------------------------------------------------------------------------
-- BasicBlocks are self-contained entities: they always end in a jump.
--
......@@ -426,7 +425,13 @@ pprLit1 other = pprLit other
pprStatics :: [CmmStatic] -> [SDoc]
pprStatics [] = []
pprStatics (CmmStaticLit (CmmFloat f F32) : rest)
-- floats are padded to a word, see #1852
| wORD_SIZE == 8, CmmStaticLit (CmmInt 0 I32) : rest' <- rest
= pprLit1 (floatToWord f) : pprStatics rest'
| wORD_SIZE == 4
= pprLit1 (floatToWord f) : pprStatics rest
| otherwise
= pprPanic "pprStatics: float" (vcat (map (\(CmmStaticLit l) -> ppr (cmmLitRep l)) rest))
pprStatics (CmmStaticLit (CmmFloat f F64) : rest)
= map pprLit1 (doubleToWords f) ++ pprStatics rest
pprStatics (CmmStaticLit (CmmInt i I64) : rest)
......
......@@ -231,7 +231,7 @@ mkStaticClosure :: CLabel -> CostCentreStack -> [CmmLit]
mkStaticClosure info_lbl ccs payload padding_wds static_link_field saved_info_field
= [CmmLabel info_lbl]
++ variable_header_words
++ payload
++ concatMap padLitToWord payload
++ padding_wds
++ static_link_field
++ saved_info_field
......@@ -241,6 +241,17 @@ mkStaticClosure info_lbl ccs payload padding_wds static_link_field saved_info_fi
++ staticParHdr
++ staticProfHdr ccs
++ staticTickyHdr
padLitToWord :: CmmLit -> [CmmLit]
padLitToWord lit = lit : padding pad_length
where rep = cmmLitRep lit
pad_length = wORD_SIZE - machRepByteWidth rep :: Int
padding n | n <= 0 = []
| n `rem` 2 /= 0 = CmmInt 0 I8 : padding (n-1)
| n `rem` 4 /= 0 = CmmInt 0 I16 : padding (n-2)
| n `rem` 8 /= 0 = CmmInt 0 I32 : padding (n-4)
| otherwise = CmmInt 0 I64 : padding (n-8)
\end{code}
%************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment