CmmUtils

ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

CmmUtils

Contents

- Operations that probably don't belong here
- Ticks

Synopsis

- primRepCmmType :: DynFlags -> PrimRep -> CmmType
- primRepForeignHint :: PrimRep -> ForeignHint
- typeCmmType :: DynFlags -> UnaryType -> CmmType
- typeForeignHint :: UnaryType -> ForeignHint
- zeroCLit :: DynFlags -> CmmLit
- mkIntCLit :: DynFlags -> Int -> CmmLit
- mkWordCLit :: DynFlags -> Integer -> CmmLit
- packHalfWordsCLit :: DynFlags -> StgHalfWord -> StgHalfWord -> CmmLit
- mkByteStringCLit :: Unique -> [Word8] -> (CmmLit, GenCmmDecl CmmStatics info stmt)
- mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt
- mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt
- mkStgWordCLit :: DynFlags -> StgWord -> CmmLit
- mkIntExpr :: DynFlags -> Int -> CmmExpr
- zeroExpr :: DynFlags -> CmmExpr
- mkLblExpr :: CLabel -> CmmExpr
- cmmRegOff :: CmmReg -> Int -> CmmExpr
- cmmOffset :: DynFlags -> CmmExpr -> Int -> CmmExpr
- cmmLabelOff :: CLabel -> Int -> CmmLit
- cmmOffsetLit :: CmmLit -> Int -> CmmLit
- cmmOffsetExpr :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr
- cmmOffsetB :: DynFlags -> CmmExpr -> ByteOff -> CmmExpr
- cmmLabelOffB :: CLabel -> ByteOff -> CmmLit
- cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit
- cmmOffsetExprB :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmRegOffW :: DynFlags -> CmmReg -> WordOff -> CmmExpr
- cmmOffsetW :: DynFlags -> CmmExpr -> WordOff -> CmmExpr
- cmmLabelOffW :: DynFlags -> CLabel -> WordOff -> CmmLit
- cmmOffsetLitW :: DynFlags -> CmmLit -> WordOff -> CmmLit
- cmmOffsetExprW :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmIndex :: DynFlags -> Width -> CmmExpr -> Int -> CmmExpr
- cmmIndexExpr :: DynFlags -> Width -> CmmExpr -> CmmExpr -> CmmExpr
- cmmLoadIndex :: DynFlags -> CmmType -> CmmExpr -> Int -> CmmExpr
- cmmLoadIndexW :: DynFlags -> CmmExpr -> Int -> CmmType -> CmmExpr
- cmmNegate :: DynFlags -> CmmExpr -> CmmExpr
- cmmULtWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUGeWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUGtWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmSubWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmNeWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmEqWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmOrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAndWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUShrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAddWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmMulWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmQuotWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmToWord :: DynFlags -> CmmExpr -> CmmExpr
- isTrivialCmmExpr :: CmmExpr -> Bool
- hasNoGlobalRegs :: CmmExpr -> Bool
- blankWord :: DynFlags -> CmmStatic
- cmmTagMask :: DynFlags -> CmmExpr
- cmmPointerMask :: DynFlags -> CmmExpr
- cmmUntag :: DynFlags -> CmmExpr -> CmmExpr
- cmmIsTagged :: DynFlags -> CmmExpr -> CmmExpr
- cmmConstrTag1 :: DynFlags -> CmmExpr -> CmmExpr
- regsOverlap :: DynFlags -> CmmReg -> CmmReg -> Bool
- regUsedIn :: DynFlags -> CmmReg -> CmmExpr -> Bool
- mkLiveness :: DynFlags -> [Maybe LocalReg] -> Liveness
- modifyGraph :: (Graph n C C -> Graph n' C C) -> GenCmmGraph n -> GenCmmGraph n'
- ofBlockMap :: BlockId -> BlockEnv CmmBlock -> CmmGraph
- toBlockMap :: CmmGraph -> BlockEnv CmmBlock
- insertBlock :: CmmBlock -> BlockEnv CmmBlock -> BlockEnv CmmBlock
- ofBlockList :: BlockId -> [CmmBlock] -> CmmGraph
- toBlockList :: CmmGraph -> [CmmBlock]
- bodyToBlockList :: Body CmmNode -> [CmmBlock]
- toBlockListEntryFirst :: CmmGraph -> [CmmBlock]
- toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock]
- foldGraphBlocks :: (CmmBlock -> a -> a) -> a -> CmmGraph -> a
- mapGraphNodes :: (CmmNode C O -> CmmNode C O, CmmNode O O -> CmmNode O O, CmmNode O C -> CmmNode O C) -> CmmGraph -> CmmGraph
- postorderDfs :: CmmGraph -> [CmmBlock]
- mapGraphNodes1 :: (forall e x. CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph
- analFwd :: DataflowLattice f -> FwdTransfer n f -> FwdPass UniqSM n f
- analBwd :: DataflowLattice f -> BwdTransfer n f -> BwdPass UniqSM n f
- analRewFwd :: DataflowLattice f -> FwdTransfer n f -> FwdRewrite UniqSM n f -> FwdPass UniqSM n f
- analRewBwd :: DataflowLattice f -> BwdTransfer n f -> BwdRewrite UniqSM n f -> BwdPass UniqSM n f
- dataflowPassFwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> UniqSM (GenCmmGraph n, BlockEnv f)
- dataflowPassBwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> BwdPass UniqSM n f -> UniqSM (GenCmmGraph n, BlockEnv f)
- dataflowAnalFwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> BlockEnv f
- dataflowAnalBwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> BwdPass UniqSM n f -> BlockEnv f
- dataflowAnalFwdBlocks :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> UniqSM (BlockEnv f)
- blockTicks :: Block CmmNode C C -> [CmmTickish]

# Documentation

primRepCmmType :: DynFlags -> PrimRep -> CmmType Source

primRepForeignHint :: PrimRep -> ForeignHint Source

typeCmmType :: DynFlags -> UnaryType -> CmmType Source

typeForeignHint :: UnaryType -> ForeignHint Source

zeroCLit :: DynFlags -> CmmLit Source

mkIntCLit :: DynFlags -> Int -> CmmLit Source

mkWordCLit :: DynFlags -> Integer -> CmmLit Source

packHalfWordsCLit :: DynFlags -> StgHalfWord -> StgHalfWord -> CmmLit Source

mkByteStringCLit :: Unique -> [Word8] -> (CmmLit, GenCmmDecl CmmStatics info stmt) Source

mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt Source

mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt Source

mkStgWordCLit :: DynFlags -> StgWord -> CmmLit Source

mkIntExpr :: DynFlags -> Int -> CmmExpr Source

zeroExpr :: DynFlags -> CmmExpr Source

mkLblExpr :: CLabel -> CmmExpr Source

cmmRegOff :: CmmReg -> Int -> CmmExpr Source

cmmOffset :: DynFlags -> CmmExpr -> Int -> CmmExpr Source

cmmLabelOff :: CLabel -> Int -> CmmLit Source

cmmOffsetLit :: CmmLit -> Int -> CmmLit Source

cmmOffsetExpr :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr Source

cmmOffsetB :: DynFlags -> CmmExpr -> ByteOff -> CmmExpr Source

cmmLabelOffB :: CLabel -> ByteOff -> CmmLit Source

cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit Source

cmmOffsetExprB :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmRegOffW :: DynFlags -> CmmReg -> WordOff -> CmmExpr Source

cmmOffsetW :: DynFlags -> CmmExpr -> WordOff -> CmmExpr Source

cmmLabelOffW :: DynFlags -> CLabel -> WordOff -> CmmLit Source

cmmOffsetLitW :: DynFlags -> CmmLit -> WordOff -> CmmLit Source

cmmOffsetExprW :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmIndex :: DynFlags -> Width -> CmmExpr -> Int -> CmmExpr Source

Useful for creating an index into an array, with a staticaly known offset. The type is the element type; used for making the multiplier

cmmIndexExpr :: DynFlags -> Width -> CmmExpr -> CmmExpr -> CmmExpr Source

Useful for creating an index into an array, with an unknown offset.

cmmLoadIndex :: DynFlags -> CmmType -> CmmExpr -> Int -> CmmExpr Source

cmmLoadIndexW :: DynFlags -> CmmExpr -> Int -> CmmType -> CmmExpr Source

cmmNegate :: DynFlags -> CmmExpr -> CmmExpr Source

cmmULtWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmUGeWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmUGtWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmSubWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmNeWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmEqWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmOrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmAndWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmUShrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmAddWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmMulWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmQuotWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr Source

cmmToWord :: DynFlags -> CmmExpr -> CmmExpr Source

isTrivialCmmExpr :: CmmExpr -> Bool Source

hasNoGlobalRegs :: CmmExpr -> Bool Source

blankWord :: DynFlags -> CmmStatic Source

cmmTagMask :: DynFlags -> CmmExpr Source

cmmPointerMask :: DynFlags -> CmmExpr Source

cmmUntag :: DynFlags -> CmmExpr -> CmmExpr Source

cmmIsTagged :: DynFlags -> CmmExpr -> CmmExpr Source

cmmConstrTag1 :: DynFlags -> CmmExpr -> CmmExpr Source

regsOverlap :: DynFlags -> CmmReg -> CmmReg -> Bool Source

Returns True if the two STG registers overlap on the specified platform, in the sense that writing to one will clobber the other. This includes the case that the two registers are the same STG register. See Note [Overlapping global registers] for details.

regUsedIn :: DynFlags -> CmmReg -> CmmExpr -> Bool Source

Returns True if the STG register is used by the expression, in the sense that a store to the register might affect the value of the expression.

We must check for overlapping registers and not just equal registers here, otherwise CmmSink may incorrectly reorder assignments that conflict due to overlap. See Trac #10521 and Note [Overlapping global registers].

mkLiveness :: DynFlags -> [Maybe LocalReg] -> Liveness Source

# Operations that probably don't belong here

modifyGraph :: (Graph n C C -> Graph n' C C) -> GenCmmGraph n -> GenCmmGraph n' Source

ofBlockMap :: BlockId -> BlockEnv CmmBlock -> CmmGraph Source

toBlockMap :: CmmGraph -> BlockEnv CmmBlock Source

insertBlock :: CmmBlock -> BlockEnv CmmBlock -> BlockEnv CmmBlock Source

ofBlockList :: BlockId -> [CmmBlock] -> CmmGraph Source

toBlockList :: CmmGraph -> [CmmBlock] Source

bodyToBlockList :: Body CmmNode -> [CmmBlock] Source

toBlockListEntryFirst :: CmmGraph -> [CmmBlock] Source

like `toBlockList`, but the entry block always comes first

toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock] Source

Like `toBlockListEntryFirst`, but we strive to ensure that we order blocks so that the false case of a conditional jumps to the next block in the output list of blocks. This matches the way OldCmm blocks were output since in OldCmm the false case was a fallthrough, whereas in Cmm conditional branches have both true and false successors. Block ordering can make a big difference in performance in the LLVM backend. Note that we rely crucially on the order of successors returned for CmmCondBranch by the NonLocal instance for CmmNode defind in cmm/CmmNode.hs. -GBM

foldGraphBlocks :: (CmmBlock -> a -> a) -> a -> CmmGraph -> a Source

mapGraphNodes :: (CmmNode C O -> CmmNode C O, CmmNode O O -> CmmNode O O, CmmNode O C -> CmmNode O C) -> CmmGraph -> CmmGraph Source

postorderDfs :: CmmGraph -> [CmmBlock] Source

mapGraphNodes1 :: (forall e x. CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph Source

analFwd :: DataflowLattice f -> FwdTransfer n f -> FwdPass UniqSM n f Source

analBwd :: DataflowLattice f -> BwdTransfer n f -> BwdPass UniqSM n f Source

analRewFwd :: DataflowLattice f -> FwdTransfer n f -> FwdRewrite UniqSM n f -> FwdPass UniqSM n f Source

analRewBwd :: DataflowLattice f -> BwdTransfer n f -> BwdRewrite UniqSM n f -> BwdPass UniqSM n f Source

dataflowPassFwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> UniqSM (GenCmmGraph n, BlockEnv f) Source

dataflowPassBwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> BwdPass UniqSM n f -> UniqSM (GenCmmGraph n, BlockEnv f) Source

dataflowAnalFwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> BlockEnv f Source

dataflowAnalBwd :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> BwdPass UniqSM n f -> BlockEnv f Source

dataflowAnalFwdBlocks :: NonLocal n => GenCmmGraph n -> [(BlockId, f)] -> FwdPass UniqSM n f -> UniqSM (BlockEnv f) Source

# Ticks

blockTicks :: Block CmmNode C C -> [CmmTickish] Source

Extract all tick annotations from the given block