-- ;
CmmNop -> semi
- -- // text
+ -- // text
CmmComment s -> text "//" <+> ftext s
-- reg = expr;
--
-- switch [0 .. n] (expr) { case ... ; }
--
--- N.B. we remove 'Nothing's from the list of branches, as they don't
--- seem to make sense currently. This may change, if they are defined in
--- some way.
---
genSwitch :: CmmExpr -> [Maybe BlockId] -> SDoc
genSwitch expr maybe_ids
- = let ids = [ i | Just i <- maybe_ids ]
- pairs = groupBy snds (zip [0 .. ] ids )
+ = let pairs = groupBy snds (zip [0 .. ] maybe_ids )
in hang (hcat [ ptext SLIT("switch [0 .. ")
- , int (length ids - 1)
+ , int (length maybe_ids - 1)
, ptext SLIT("] ")
, if isTrivialCmmExpr expr
then pprExpr expr
where
snds a b = (snd a) == (snd b)
- caseify :: [(Int,BlockId)] -> SDoc
+ caseify :: [(Int,Maybe BlockId)] -> SDoc
+ caseify ixs@((i,Nothing):_)
+ = ptext SLIT("/* impossible: ") <> hcat (intersperse comma (map (int.fst) ixs))
+ <> ptext SLIT(" */")
caseify as
= let (is,ids) = unzip as
in hsep [ ptext SLIT("case")
, hcat (punctuate comma (map int is))
, ptext SLIT(": goto")
- , pprBlockId (head ids) <> semi ]
+ , pprBlockId (head [ id | Just id <- ids]) <> semi ]
-- --------------------------------------------------------------------------
-- Expressions
CmmLit lit -> pprLit1 lit
CmmLoad expr rep -> ppr rep <> brackets( ppr expr )
CmmReg reg -> ppr reg
+ CmmRegOff reg off -> parens (ppr reg <+> char '+' <+> int off)
CmmMachOp mop args -> genMachOp mop args
- e -> parens (pprExpr e)
genMachOp :: MachOp -> [CmmExpr] -> SDoc
genMachOp mop args
MO_Xor _ -> Just $ char '^'
MO_Not _ -> Just $ char '~'
MO_S_Neg _ -> Just $ char '-' -- there is no unsigned neg :)
- MO_Not _ -> Just $ char '~'
_ -> Nothing
-- --------------------------------------------------------------------------
CmmFloat f rep -> hsep [ rational f, dcolon, ppr rep ]
CmmLabel clbl -> pprCLabel clbl
CmmLabelOff clbl i -> pprCLabel clbl <> ppr_offset i
+ CmmLabelDiffOff clbl1 clbl2 i -> pprCLabel clbl1 <> char '-'
+ <> pprCLabel clbl2 <> ppr_offset i
pprLit1 lit@(CmmLabelOff clbl i) = parens (pprLit lit)
pprLit1 lit = pprLit lit
GCEnter1 -> ptext SLIT("stg_gc_enter_1")
GCFun -> ptext SLIT("stg_gc_fun")
BaseReg -> ptext SLIT("BaseReg")
-
- _ -> panic $ "PprCmm.pprGlobalReg: unknown global reg"
+ PicBaseReg -> ptext SLIT("PicBaseReg")
-- --------------------------------------------------------------------------
-- data sections
Text -> section <+> doubleQuotes (ptext SLIT("text"))
Data -> section <+> doubleQuotes (ptext SLIT("data"))
ReadOnlyData -> section <+> doubleQuotes (ptext SLIT("readonly"))
+ RelocatableReadOnlyData
+ -> section <+> doubleQuotes (ptext SLIT("relreadonly"))
UninitialisedData -> section <+> doubleQuotes (ptext SLIT("uninitialised"))
OtherSection s' -> section <+> doubleQuotes (text s')
where