ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Cmm.Utils

Contents

- Operations that probably don't belong here
- Ticks

Synopsis

- primRepCmmType :: Platform -> PrimRep -> CmmType
- slotCmmType :: Platform -> SlotTy -> CmmType
- typeCmmType :: Platform -> NvUnaryType -> CmmType
- typeForeignHint :: NvUnaryType -> ForeignHint
- primRepForeignHint :: PrimRep -> ForeignHint
- zeroCLit :: Platform -> CmmLit
- mkIntCLit :: Platform -> Int -> CmmLit
- mkWordCLit :: Platform -> Integer -> CmmLit
- packHalfWordsCLit :: Platform -> StgHalfWord -> StgHalfWord -> CmmLit
- mkByteStringCLit :: forall (raw :: Bool) info stmt. CLabel -> ByteString -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt)
- mkFileEmbedLit :: forall (raw :: Bool) info stmt. CLabel -> FilePath -> Int -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt)
- mkDataLits :: forall (raw :: Bool) info stmt. Section -> CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt
- mkRODataLits :: forall (raw :: Bool) info stmt. CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt
- mkStgWordCLit :: Platform -> StgWord -> CmmLit
- mkIntExpr :: Platform -> Int -> CmmExpr
- zeroExpr :: Platform -> CmmExpr
- mkLblExpr :: CLabel -> CmmExpr
- cmmRegOff :: CmmReg -> Int -> CmmExpr
- cmmOffset :: Platform -> CmmExpr -> Int -> CmmExpr
- cmmLabelOff :: CLabel -> Int -> CmmLit
- cmmOffsetLit :: CmmLit -> Int -> CmmLit
- cmmOffsetExpr :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr
- cmmOffsetB :: Platform -> CmmExpr -> ByteOff -> CmmExpr
- cmmLabelOffB :: CLabel -> ByteOff -> CmmLit
- cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit
- cmmOffsetExprB :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmRegOffW :: Platform -> CmmReg -> WordOff -> CmmExpr
- cmmOffsetW :: Platform -> CmmExpr -> WordOff -> CmmExpr
- cmmLabelOffW :: Platform -> CLabel -> WordOff -> CmmLit
- cmmOffsetLitW :: Platform -> CmmLit -> WordOff -> CmmLit
- cmmOffsetExprW :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmIndex :: Platform -> Width -> CmmExpr -> Int -> CmmExpr
- cmmIndexExpr :: Platform -> Width -> CmmExpr -> CmmExpr -> CmmExpr
- cmmLoadIndex :: Platform -> CmmType -> CmmExpr -> Int -> CmmExpr
- cmmLoadIndexW :: Platform -> CmmExpr -> Int -> CmmType -> CmmExpr
- cmmLoadBWord :: Platform -> CmmExpr -> CmmExpr
- cmmLoadGCWord :: Platform -> CmmExpr -> CmmExpr
- cmmNegate :: Platform -> CmmExpr -> CmmExpr
- cmmULtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUGeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUGtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmUShrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmSLtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmNeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmEqWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmOrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAndWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmSubWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmAddWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmMulWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmQuotWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr
- cmmToWord :: Platform -> CmmExpr -> CmmExpr
- cmmMkAssign :: Platform -> CmmExpr -> Unique -> (CmmNode O O, CmmExpr)
- baseExpr :: Platform -> CmmExpr
- spExpr :: Platform -> CmmExpr
- hpExpr :: Platform -> CmmExpr
- spLimExpr :: Platform -> CmmExpr
- hpLimExpr :: Platform -> CmmExpr
- currentTSOExpr :: Platform -> CmmExpr
- currentNurseryExpr :: Platform -> CmmExpr
- cccsExpr :: Platform -> CmmExpr
- cmmTagMask :: Platform -> CmmExpr
- cmmPointerMask :: Platform -> CmmExpr
- cmmUntag :: Platform -> CmmExpr -> CmmExpr
- cmmIsTagged :: Platform -> CmmExpr -> CmmExpr
- cmmIsNotTagged :: Platform -> CmmExpr -> CmmExpr
- cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr
- mAX_PTR_TAG :: Platform -> Int
- tAG_MASK :: Platform -> Int
- regsOverlap :: Platform -> CmmReg -> CmmReg -> Bool
- globalRegsOverlap :: Platform -> GlobalReg -> GlobalReg -> Bool
- regUsedIn :: Platform -> CmmReg -> CmmExpr -> Bool
- globalRegUsedIn :: Platform -> GlobalReg -> CmmExpr -> Bool
- mkLiveness :: Platform -> [LocalReg] -> Liveness
- modifyGraph :: forall (n :: Extensibility -> Extensibility -> Type) (n' :: Extensibility -> Extensibility -> Type). (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]
- 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
- mapGraphNodes1 :: (forall (e :: Extensibility) (x :: Extensibility). CmmNode e x -> CmmNode e x) -> CmmGraph -> CmmGraph
- blockTicks :: Block CmmNode C C -> [CmmTickish]

# Documentation

primRepCmmType :: Platform -> PrimRep -> CmmType #

slotCmmType :: Platform -> SlotTy -> CmmType #

typeCmmType :: Platform -> NvUnaryType -> CmmType #

typeForeignHint :: NvUnaryType -> ForeignHint #

primRepForeignHint :: PrimRep -> ForeignHint #

zeroCLit :: Platform -> CmmLit #

mkIntCLit :: Platform -> Int -> CmmLit #

mkWordCLit :: Platform -> Integer -> CmmLit #

packHalfWordsCLit :: Platform -> StgHalfWord -> StgHalfWord -> CmmLit #

mkByteStringCLit :: forall (raw :: Bool) info stmt. CLabel -> ByteString -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) #

We make a top-level decl for the string, and return a label pointing to it

mkFileEmbedLit :: forall (raw :: Bool) info stmt. CLabel -> FilePath -> Int -> (CmmLit, GenCmmDecl (GenCmmStatics raw) info stmt) #

We make a top-level decl for the embedded binary file, and return a label pointing to it

mkDataLits :: forall (raw :: Bool) info stmt. Section -> CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt #

Build a data-segment data block

mkRODataLits :: forall (raw :: Bool) info stmt. CLabel -> [CmmLit] -> GenCmmDecl (GenCmmStatics raw) info stmt #

mkStgWordCLit :: Platform -> StgWord -> CmmLit #

mkIntExpr :: Platform -> Int -> CmmExpr #

zeroExpr :: Platform -> CmmExpr #

mkLblExpr :: CLabel -> CmmExpr #

cmmRegOff :: CmmReg -> Int -> CmmExpr #

cmmOffset :: Platform -> CmmExpr -> Int -> CmmExpr #

cmmLabelOff :: CLabel -> Int -> CmmLit #

cmmOffsetLit :: CmmLit -> Int -> CmmLit #

cmmOffsetExpr :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr #

cmmOffsetB :: Platform -> CmmExpr -> ByteOff -> CmmExpr #

cmmLabelOffB :: CLabel -> ByteOff -> CmmLit #

cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit #

cmmOffsetExprB :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmRegOffW :: Platform -> CmmReg -> WordOff -> CmmExpr #

cmmOffsetW :: Platform -> CmmExpr -> WordOff -> CmmExpr #

cmmLabelOffW :: Platform -> CLabel -> WordOff -> CmmLit #

cmmOffsetLitW :: Platform -> CmmLit -> WordOff -> CmmLit #

cmmOffsetExprW :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmIndex :: Platform -> Width -> CmmExpr -> Int -> CmmExpr #

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 :: Platform -> Width -> CmmExpr -> CmmExpr -> CmmExpr #

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

cmmLoadIndex :: Platform -> CmmType -> CmmExpr -> Int -> CmmExpr #

cmmLoadIndexW :: Platform -> CmmExpr -> Int -> CmmType -> CmmExpr #

cmmLoadBWord :: Platform -> CmmExpr -> CmmExpr #

Load a naturally-aligned non-pointer word.

cmmLoadGCWord :: Platform -> CmmExpr -> CmmExpr #

Load a naturally-aligned GC pointer.

cmmNegate :: Platform -> CmmExpr -> CmmExpr #

cmmULtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmUGeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmUGtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmUShrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmSLtWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmNeWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmEqWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmOrWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmAndWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmSubWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmAddWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmMulWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmQuotWord :: Platform -> CmmExpr -> CmmExpr -> CmmExpr #

cmmToWord :: Platform -> CmmExpr -> CmmExpr #

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

baseExpr :: Platform -> CmmExpr #

spExpr :: Platform -> CmmExpr #

hpExpr :: Platform -> CmmExpr #

spLimExpr :: Platform -> CmmExpr #

hpLimExpr :: Platform -> CmmExpr #

currentTSOExpr :: Platform -> CmmExpr #

currentNurseryExpr :: Platform -> CmmExpr #

cccsExpr :: Platform -> CmmExpr #

cmmTagMask :: Platform -> CmmExpr #

cmmPointerMask :: Platform -> CmmExpr #

cmmUntag :: Platform -> CmmExpr -> CmmExpr #

cmmIsTagged :: Platform -> CmmExpr -> CmmExpr #

cmmIsNotTagged :: Platform -> CmmExpr -> CmmExpr #

cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr #

mAX_PTR_TAG :: Platform -> Int #

tAG_MASK :: Platform -> Int #

regsOverlap :: Platform -> CmmReg -> CmmReg -> Bool #

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.

globalRegsOverlap :: Platform -> GlobalReg -> GlobalReg -> Bool #

regUsedIn :: Platform -> CmmReg -> CmmExpr -> Bool #

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].

globalRegUsedIn :: Platform -> GlobalReg -> CmmExpr -> Bool #

mkLiveness :: Platform -> [LocalReg] -> Liveness #

# Operations that probably don't belong here

modifyGraph :: forall (n :: Extensibility -> Extensibility -> Type) (n' :: Extensibility -> Extensibility -> Type). (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] #

toBlockListEntryFirst :: CmmGraph -> [CmmBlock] #

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

toBlockListEntryFirstFalseFallthrough :: CmmGraph -> [CmmBlock] #

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 GHC.Cmm.Node. -GBM

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 #

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

# Ticks

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

Extract all tick annotations from the given block