ghc-lib-parser-9.12.2.20250421: 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 Source #

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

typeCmmType :: Platform -> NvUnaryType -> CmmType Source #

typeForeignHint :: NvUnaryType -> ForeignHint Source #

primRepForeignHint :: PrimRep -> ForeignHint Source #

zeroCLit :: Platform -> CmmLit Source #

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

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

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

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

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) Source #

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 Source #

Build a data-segment data block

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

mkStgWordCLit :: Platform -> StgWord -> CmmLit Source #

mkIntExpr :: Platform -> Int -> CmmExpr Source #

zeroExpr :: Platform -> CmmExpr Source #

mkLblExpr :: CLabel -> CmmExpr Source #

cmmRegOff :: CmmReg -> Int -> CmmExpr Source #

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

cmmLabelOff :: CLabel -> Int -> CmmLit Source #

cmmOffsetLit :: CmmLit -> Int -> CmmLit Source #

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

cmmRegOffB :: CmmReg -> ByteOff -> CmmExpr Source #

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

cmmLabelOffB :: CLabel -> ByteOff -> CmmLit Source #

cmmOffsetLitB :: CmmLit -> ByteOff -> CmmLit Source #

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

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

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

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

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

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

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

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

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

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

cmmLoadBWord :: Platform -> CmmExpr -> CmmExpr Source #

Load a naturally-aligned non-pointer word.

cmmLoadGCWord :: Platform -> CmmExpr -> CmmExpr Source #

Load a naturally-aligned GC pointer.

cmmNegate :: Platform -> CmmExpr -> CmmExpr Source #

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

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

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

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

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

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

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

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

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

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

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

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

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

cmmToWord :: Platform -> CmmExpr -> CmmExpr Source #

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

baseExpr :: Platform -> CmmExpr Source #

spExpr :: Platform -> CmmExpr Source #

hpExpr :: Platform -> CmmExpr Source #

spLimExpr :: Platform -> CmmExpr Source #

hpLimExpr :: Platform -> CmmExpr Source #

currentTSOExpr :: Platform -> CmmExpr Source #

currentNurseryExpr :: Platform -> CmmExpr Source #

cccsExpr :: Platform -> CmmExpr Source #

cmmTagMask :: Platform -> CmmExpr Source #

cmmPointerMask :: Platform -> CmmExpr Source #

cmmUntag :: Platform -> CmmExpr -> CmmExpr Source #

cmmIsTagged :: Platform -> CmmExpr -> CmmExpr Source #

cmmIsNotTagged :: Platform -> CmmExpr -> CmmExpr Source #

cmmConstrTag1 :: Platform -> CmmExpr -> CmmExpr Source #

mAX_PTR_TAG :: Platform -> Int Source #

tAG_MASK :: Platform -> Int Source #

regsOverlap :: Platform -> 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.

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

regUsedIn :: Platform -> 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].

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

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

# 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' Source #

ofBlockMap :: BlockId -> LabelMap CmmBlock -> CmmGraph Source #

toBlockMap :: CmmGraph -> LabelMap CmmBlock Source #

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

toBlockList :: CmmGraph -> [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 GHC.Cmm.Node. -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 #

mapGraphNodes1 :: (forall (e :: Extensibility) (x :: Extensibility). 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