CmmUtils

ghc-8.10.7: The GHC API

Safe Haskell | None
Language | Haskell2010

CmmUtils

Contents

- Operations that probably don't belong here
- Ticks

Synopsis

- primRepCmmType :: DynFlags -> PrimRep -> CmmType
- slotCmmType :: DynFlags -> SlotTy -> CmmType
- typeCmmType :: DynFlags -> UnaryType -> CmmType
- typeForeignHint :: UnaryType -> ForeignHint
- primRepForeignHint :: PrimRep -> ForeignHint
- zeroCLit :: DynFlags -> CmmLit
- mkIntCLit :: DynFlags -> Int -> CmmLit
- mkWordCLit :: DynFlags -> Integer -> CmmLit
- packHalfWordsCLit :: DynFlags -> StgHalfWord -> StgHalfWord -> CmmLit
- mkByteStringCLit :: CLabel -> ByteString -> (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
- cmmUShrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmSLtWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmNeWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmEqWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmOrWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAndWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmSubWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAddWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmMulWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmQuotWord :: DynFlags -> CmmExpr -> CmmExpr -> CmmExpr
- cmmToWord :: DynFlags -> CmmExpr -> CmmExpr
- cmmMkAssign :: DynFlags -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr)
- isTrivialCmmExpr :: CmmExpr -> Bool
- hasNoGlobalRegs :: CmmExpr -> Bool
- isLit :: CmmExpr -> Bool
- isComparisonExpr :: CmmExpr -> Bool
- baseExpr :: CmmExpr
- spExpr :: CmmExpr
- hpExpr :: CmmExpr
- spLimExpr :: CmmExpr
- hpLimExpr :: CmmExpr
- currentTSOExpr :: CmmExpr
- currentNurseryExpr :: CmmExpr
- cccsExpr :: CmmExpr
- 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 -> [LocalReg] -> Liveness
- modifyGraph :: (Graph n C C -> Graph n' C C) -> GenCmmGraph n -> GenCmmGraph n'
- ofBlockMap :: BlockId -> LabelMap CmmBlock -> CmmGraph
- toBlockMap :: CmmGraph -> LabelMap CmmBlock
- ofBlockList :: BlockId -> [CmmBlock] -> CmmGraph
- toBlockList :: CmmGraph -> [CmmBlock]
- bodyToBlockList :: Body CmmNode -> [CmmBlock]
- toBlockListEntryFirst :: CmmGraph -> [CmmBlock]
- toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock]
- foldlGraphBlocks :: (a -> CmmBlock -> 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
- revPostorder :: CmmGraph -> [CmmBlock]
- mapGraphNodes1 :: (forall e x. CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph
- blockTicks :: Block CmmNode C C -> [CmmTickish]

# Documentation

primRepCmmType :: DynFlags -> PrimRep -> CmmType Source #

slotCmmType :: DynFlags -> SlotTy -> CmmType Source #

typeCmmType :: DynFlags -> UnaryType -> CmmType Source #

typeForeignHint :: UnaryType -> ForeignHint Source #

primRepForeignHint :: PrimRep -> ForeignHint Source #

zeroCLit :: DynFlags -> CmmLit Source #

mkIntCLit :: DynFlags -> Int -> CmmLit Source #

mkWordCLit :: DynFlags -> Integer -> CmmLit Source #

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

mkByteStringCLit :: CLabel -> ByteString -> (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 statically 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 #

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

cmmSLtWord :: 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 #

cmmSubWord :: 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 #

cmmMkAssign :: DynFlags -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr) Source #

isTrivialCmmExpr :: CmmExpr -> Bool Source #

hasNoGlobalRegs :: CmmExpr -> Bool Source #

isLit :: CmmExpr -> Bool Source #

isComparisonExpr :: CmmExpr -> Bool Source #

baseExpr :: CmmExpr Source #

spExpr :: CmmExpr Source #

hpExpr :: CmmExpr Source #

spLimExpr :: CmmExpr Source #

hpLimExpr :: CmmExpr Source #

currentTSOExpr :: CmmExpr Source #

currentNurseryExpr :: CmmExpr Source #

cccsExpr :: CmmExpr 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 #10521 and Note [Overlapping global registers].

mkLiveness :: DynFlags -> [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 -> LabelMap CmmBlock -> CmmGraph Source #

toBlockMap :: CmmGraph -> LabelMap 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 defined in cmm/CmmNode.hs. -GBM

foldlGraphBlocks :: (a -> CmmBlock -> 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 #

revPostorder :: CmmGraph -> [CmmBlock] Source #

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

# Ticks

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

Extract all tick annotations from the given block