CmmNode

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

CmmNode

Contents

- Tick scopes

Synopsis

- data CmmNode e x where
  - CmmEntry :: !Label -> CmmTickScope -> CmmNode C O
  - CmmComment :: FastString -> CmmNode O O
  - CmmTick :: !CmmTickish -> CmmNode O O
  - CmmUnwind :: [(GlobalReg, Maybe CmmExpr)] -> CmmNode O O
  - CmmAssign :: !CmmReg -> !CmmExpr -> CmmNode O O
  - CmmStore :: !CmmExpr -> !CmmExpr -> CmmNode O O
  - CmmUnsafeForeignCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmNode O O
  - CmmBranch :: !Label -> CmmNode O C
  - CmmCondBranch :: {..} -> CmmNode O C
  - CmmSwitch :: CmmExpr -> SwitchTargets -> CmmNode O C
  - CmmCall :: {..} -> CmmNode O C
  - CmmForeignCall :: {..} -> CmmNode O C
- type CmmFormal = LocalReg
- type CmmActual = CmmExpr
- type CmmTickish = Tickish ()
- type UpdFrameOffset = ByteOff
- data Convention
  - = NativeDirectCall
  - | NativeNodeCall
  - | NativeReturn
  - | Slow
  - | GC
- data ForeignConvention = ForeignConvention CCallConv [ForeignHint] [ForeignHint] CmmReturnInfo
- data ForeignTarget
  - = ForeignTarget CmmExpr ForeignConvention
  - | PrimTarget CallishMachOp
- foreignTargetHints :: ForeignTarget -> ([ForeignHint], [ForeignHint])
- data CmmReturnInfo
  - = CmmMayReturn
  - | CmmNeverReturns
- mapExp :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x
- mapExpDeep :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x
- wrapRecExp :: (CmmExpr -> CmmExpr) -> CmmExpr -> CmmExpr
- foldExp :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z
- foldExpDeep :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z
- wrapRecExpf :: (CmmExpr -> z -> z) -> CmmExpr -> z -> z
- mapExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x)
- mapExpDeepM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x)
- wrapRecExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmExpr -> Maybe CmmExpr
- mapSuccessors :: (Label -> Label) -> CmmNode O C -> CmmNode O C
- data CmmTickScope
  - = GlobalScope
  - | SubScope !Unique CmmTickScope
  - | CombinedScope CmmTickScope CmmTickScope
- isTickSubScope :: CmmTickScope -> CmmTickScope -> Bool
- combineTickScopes :: CmmTickScope -> CmmTickScope -> CmmTickScope

# Documentation

data CmmNode e x where #

Constructors

CmmEntry :: !Label -> CmmTickScope -> CmmNode C O |
CmmComment :: FastString -> CmmNode O O |
CmmTick :: !CmmTickish -> CmmNode O O |
CmmUnwind :: [(GlobalReg, Maybe CmmExpr)] -> CmmNode O O |
CmmAssign :: !CmmReg -> !CmmExpr -> CmmNode O O |
CmmStore :: !CmmExpr -> !CmmExpr -> CmmNode O O |
CmmUnsafeForeignCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmNode O O |
CmmBranch :: !Label -> CmmNode O C |
CmmCondBranch |
Fields :: { cml_pred :: CmmExpr , cml_true, cml_false :: !Label , cml_likely :: Maybe Bool } -> CmmNode O C
CmmSwitch :: CmmExpr -> SwitchTargets -> CmmNode O C |
CmmCall |
Fields :: { cml_target :: CmmExpr , cml_cont :: Maybe Label , cml_args_regs :: [GlobalReg] , cml_args :: ByteOff , cml_ret_args :: ByteOff , cml_ret_off :: ByteOff } -> CmmNode O C
CmmForeignCall |
Fields :: { tgt :: ForeignTarget , res :: [CmmFormal] , args :: [CmmActual] , succ :: !Label , ret_args :: ByteOff , ret_off :: ByteOff , intrbl :: Bool } -> CmmNode O C

Instances

Outputable CmmGraph # |
Instance details Defined in PprCmm Methods ppr :: CmmGraph -> SDoc # pprPrec :: Rational -> CmmGraph -> SDoc #
NonLocal CmmNode # |
Instance details Defined in CmmNode Methods entryLabel :: CmmNode C x -> Label # successors :: CmmNode e C -> [Label] #
DefinerOfRegs GlobalReg (CmmNode e x) # |
Instance details Defined in CmmNode Methods foldRegsDefd :: DynFlags -> (b -> GlobalReg -> b) -> b -> CmmNode e x -> b #
DefinerOfRegs LocalReg (CmmNode e x) # |
Instance details Defined in CmmNode Methods foldRegsDefd :: DynFlags -> (b -> LocalReg -> b) -> b -> CmmNode e x -> b #
UserOfRegs GlobalReg (CmmNode e x) # |
Instance details Defined in CmmNode Methods foldRegsUsed :: DynFlags -> (b -> GlobalReg -> b) -> b -> CmmNode e x -> b #
UserOfRegs LocalReg (CmmNode e x) # |
Instance details Defined in CmmNode Methods foldRegsUsed :: DynFlags -> (b -> LocalReg -> b) -> b -> CmmNode e x -> b #
Eq (CmmNode e x) # |
Instance details Defined in CmmNode Methods (==) :: CmmNode e x -> CmmNode e x -> Bool # (/=) :: CmmNode e x -> CmmNode e x -> Bool #
Outputable (CmmNode e x) # |
Instance details Defined in PprCmm Methods ppr :: CmmNode e x -> SDoc # pprPrec :: Rational -> CmmNode e x -> SDoc #
Outputable (Block CmmNode C C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C C -> SDoc # pprPrec :: Rational -> Block CmmNode C C -> SDoc #
Outputable (Block CmmNode C O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode C O -> SDoc # pprPrec :: Rational -> Block CmmNode C O -> SDoc #
Outputable (Block CmmNode O C) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O C -> SDoc # pprPrec :: Rational -> Block CmmNode O C -> SDoc #
Outputable (Block CmmNode O O) # |
Instance details Defined in PprCmm Methods ppr :: Block CmmNode O O -> SDoc # pprPrec :: Rational -> Block CmmNode O O -> SDoc #
Outputable (Graph CmmNode e x) # |
Instance details Defined in PprCmm Methods ppr :: Graph CmmNode e x -> SDoc # pprPrec :: Rational -> Graph CmmNode e x -> SDoc #

type CmmFormal = LocalReg #

type CmmActual = CmmExpr #

type CmmTickish = Tickish () #

Tickish in Cmm context (annotations only)

type UpdFrameOffset = ByteOff #

data Convention #

A convention maps a list of values (function arguments or return values) to registers or stack locations.

Constructors

NativeDirectCall | top-level Haskell functions use `NativeDirectCall`, which maps arguments to registers starting with R2, according to how many registers are available on the platform. This convention ignores R1, because for a top-level function call the function closure is implicit, and doesn't need to be passed.
NativeNodeCall | non-top-level Haskell functions, which pass the address of the function closure in R1 (regardless of whether R1 is a real register or not), and the rest of the arguments in registers or on the stack.
NativeReturn | a native return. The convention for returns depends on how many values are returned: for just one value returned, the appropriate register is used (R1, F1, etc.). regardless of whether it is a real register or not. For multiple values returned, they are mapped to registers or the stack.
Slow | Slow entry points: all args pushed on the stack
GC | Entry to the garbage collector: uses the node reg! (TODO: I don't think we need this --SDM)

Instances

Eq Convention # |
Instance details Defined in CmmNode Methods (==) :: Convention -> Convention -> Bool # (/=) :: Convention -> Convention -> Bool #
Outputable Convention # |
Instance details Defined in PprCmm Methods ppr :: Convention -> SDoc # pprPrec :: Rational -> Convention -> SDoc #

data ForeignConvention #

Constructors

ForeignConvention CCallConv [ForeignHint] [ForeignHint] CmmReturnInfo |

Instances

Eq ForeignConvention # |
Instance details Defined in CmmNode Methods (==) :: ForeignConvention -> ForeignConvention -> Bool # (/=) :: ForeignConvention -> ForeignConvention -> Bool #
Outputable ForeignConvention # |
Instance details Defined in PprCmm Methods ppr :: ForeignConvention -> SDoc # pprPrec :: Rational -> ForeignConvention -> SDoc #

data ForeignTarget #

Constructors

ForeignTarget CmmExpr ForeignConvention |
PrimTarget CallishMachOp |

Instances

Eq ForeignTarget # |
Instance details Defined in CmmNode Methods (==) :: ForeignTarget -> ForeignTarget -> Bool # (/=) :: ForeignTarget -> ForeignTarget -> Bool #
Outputable ForeignTarget # |
Instance details Defined in PprCmm Methods ppr :: ForeignTarget -> SDoc # pprPrec :: Rational -> ForeignTarget -> SDoc #
(Ord r, UserOfRegs r CmmReg) => UserOfRegs r ForeignTarget # |
Instance details Defined in CmmNode Methods foldRegsUsed :: DynFlags -> (b -> r -> b) -> b -> ForeignTarget -> b #

foreignTargetHints :: ForeignTarget -> ([ForeignHint], [ForeignHint]) #

data CmmReturnInfo #

Constructors

CmmMayReturn |
CmmNeverReturns |

Instances

Eq CmmReturnInfo # |
Instance details Defined in CmmNode Methods (==) :: CmmReturnInfo -> CmmReturnInfo -> Bool # (/=) :: CmmReturnInfo -> CmmReturnInfo -> Bool #
Outputable CmmReturnInfo # |
Instance details Defined in PprCmm Methods ppr :: CmmReturnInfo -> SDoc # pprPrec :: Rational -> CmmReturnInfo -> SDoc #

mapExp :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x #

mapExpDeep :: (CmmExpr -> CmmExpr) -> CmmNode e x -> CmmNode e x #

wrapRecExp :: (CmmExpr -> CmmExpr) -> CmmExpr -> CmmExpr #

foldExp :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z #

foldExpDeep :: (CmmExpr -> z -> z) -> CmmNode e x -> z -> z #

wrapRecExpf :: (CmmExpr -> z -> z) -> CmmExpr -> z -> z #

mapExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x) #

mapExpDeepM :: (CmmExpr -> Maybe CmmExpr) -> CmmNode e x -> Maybe (CmmNode e x) #

wrapRecExpM :: (CmmExpr -> Maybe CmmExpr) -> CmmExpr -> Maybe CmmExpr #

mapSuccessors :: (Label -> Label) -> CmmNode O C -> CmmNode O C #

# Tick scopes

data CmmTickScope #

Tick scope identifier, allowing us to reason about what annotations in a Cmm block should scope over. We especially take care to allow optimisations to reorganise blocks without losing tick association in the process.

Constructors

GlobalScope | The global scope is the "root" of the scope graph. Every scope is a sub-scope of the global scope. It doesn't make sense to add ticks to this scope. On the other hand, this means that setting this scope on a block means no ticks apply to it.
SubScope !Unique CmmTickScope | Constructs a new sub-scope to an existing scope. This allows us to translate Core-style scoping rules (see `tickishScoped`) into the Cmm world. Suppose the following code: tick1 case ... of A -> tick2 ... B -> tick3 ... We want the top-level tick annotation to apply to blocks generated for the A and B alternatives. We can achieve that by generating tick1 into a block with scope a, while the code for alternatives A and B gets generated into sub-scopes a/b and a/c respectively.
CombinedScope CmmTickScope CmmTickScope | A combined scope scopes over everything that the two given scopes cover. It is therefore a sub-scope of either scope. This is required for optimisations. Consider common block elimination: A -> tick2 case ... of C -> [common] B -> tick3 case ... of D -> [common] We will generate code for the C and D alternatives, and figure out afterwards that it's actually common code. Scoping rules dictate that the resulting common block needs to be covered by both tick2 and tick3, therefore we need to construct a scope that is a child to *both* scope. Now we can do that - if we assign the scopes ac and bd to the common-ed up blocks, the new block could have a combined tick scope ac+bd, which both tick2 and tick3 apply to.

Instances

Eq CmmTickScope # |
Instance details Defined in CmmNode Methods (==) :: CmmTickScope -> CmmTickScope -> Bool # (/=) :: CmmTickScope -> CmmTickScope -> Bool #
Ord CmmTickScope # |
Instance details Defined in CmmNode Methods compare :: CmmTickScope -> CmmTickScope -> Ordering # (<) :: CmmTickScope -> CmmTickScope -> Bool # (<=) :: CmmTickScope -> CmmTickScope -> Bool # (>) :: CmmTickScope -> CmmTickScope -> Bool # (>=) :: CmmTickScope -> CmmTickScope -> Bool # max :: CmmTickScope -> CmmTickScope -> CmmTickScope # min :: CmmTickScope -> CmmTickScope -> CmmTickScope #
Outputable CmmTickScope # |
Instance details Defined in CmmNode Methods ppr :: CmmTickScope -> SDoc # pprPrec :: Rational -> CmmTickScope -> SDoc #

isTickSubScope :: CmmTickScope -> CmmTickScope -> Bool #

Checks whether two tick scopes are sub-scopes of each other. True if the two scopes are equal.

combineTickScopes :: CmmTickScope -> CmmTickScope -> CmmTickScope #

Combine two tick scopes. The new scope should be sub-scope of both parameters. We simplfy automatically if one tick scope is a sub-scope of the other already.