MkGraph

ghc-8.4.0.20180204: The GHC API

Safe Haskell | None
Language | Haskell2010

MkGraph

Synopsis

- type CmmAGraph = OrdList CgStmt
- type CmmAGraphScoped = (CmmAGraph, CmmTickScope)
- data CgStmt
  - = CgLabel BlockId CmmTickScope
  - | CgStmt (CmmNode O O)
  - | CgLast (CmmNode O C)
  - | CgFork BlockId CmmAGraph CmmTickScope
- (<*>) :: CmmAGraph -> CmmAGraph -> CmmAGraph
- catAGraphs :: [CmmAGraph] -> CmmAGraph
- mkLabel :: BlockId -> CmmTickScope -> CmmAGraph
- mkMiddle :: CmmNode O O -> CmmAGraph
- mkLast :: CmmNode O C -> CmmAGraph
- outOfLine :: BlockId -> CmmAGraphScoped -> CmmAGraph
- lgraphOfAGraph :: CmmAGraphScoped -> UniqSM CmmGraph
- labelAGraph :: BlockId -> CmmAGraphScoped -> CmmGraph
- stackStubExpr :: Width -> CmmExpr
- mkNop :: CmmAGraph
- mkAssign :: CmmReg -> CmmExpr -> CmmAGraph
- mkStore :: CmmExpr -> CmmExpr -> CmmAGraph
- mkUnsafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmAGraph
- mkFinalCall :: DynFlags -> CmmExpr -> CCallConv -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph
- mkCallReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph
- mkJumpReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> CmmAGraph
- mkJump :: DynFlags -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph
- mkJumpExtra :: DynFlags -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph
- mkRawJump :: DynFlags -> CmmExpr -> UpdFrameOffset -> [GlobalReg] -> CmmAGraph
- mkCbranch :: CmmExpr -> BlockId -> BlockId -> Maybe Bool -> CmmAGraph
- mkSwitch :: CmmExpr -> SwitchTargets -> CmmAGraph
- mkReturn :: DynFlags -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph
- mkComment :: FastString -> CmmAGraph
- mkCallEntry :: DynFlags -> Convention -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph)
- mkBranch :: BlockId -> CmmAGraph
- mkUnwind :: GlobalReg -> CmmExpr -> CmmAGraph
- copyInOflow :: DynFlags -> Convention -> Area -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph)
- copyOutOflow :: DynFlags -> Convention -> Transfer -> Area -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> (Int, [GlobalReg], CmmAGraph)
- noExtraStack :: [CmmExpr]
- toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff -> ByteOff -> [GlobalReg] -> CmmAGraph
- data Transfer
  - = Call
  - | JumpRet
  - | Jump
  - | Ret

# Documentation

type CmmAGraph = OrdList CgStmt Source #

CmmAGraph is a chunk of code consisting of:

- ordinary statements (assignments, stores etc.)
- jumps
- labels
- out-of-line labelled blocks

The semantics is that control falls through labels and out-of-line blocks. Everything after a jump up to the next label is by definition unreachable code, and will be discarded.

Two CmmAGraphs can be stuck together with *, with the meaning that control flows from the first to the second.

A `CmmAGraph` can be turned into a `CmmGraph` (closed at both ends) by providing a label for the entry point and a tick scope; see `labelAGraph`.

type CmmAGraphScoped = (CmmAGraph, CmmTickScope) Source #

Unlabeled graph with tick scope

data CgStmt Source #

Constructors

CgLabel BlockId CmmTickScope |
CgStmt (CmmNode O O) |
CgLast (CmmNode O C) |
CgFork BlockId CmmAGraph CmmTickScope |

(<*>) :: CmmAGraph -> CmmAGraph -> CmmAGraph Source #

catAGraphs :: [CmmAGraph] -> CmmAGraph Source #

mkLabel :: BlockId -> CmmTickScope -> CmmAGraph Source #

created a sequence "goto id; id:" as an AGraph

mkMiddle :: CmmNode O O -> CmmAGraph Source #

creates an open AGraph from a given node

mkLast :: CmmNode O C -> CmmAGraph Source #

created a closed AGraph from a given node

outOfLine :: BlockId -> CmmAGraphScoped -> CmmAGraph Source #

A labelled code block; should end in a last node

lgraphOfAGraph :: CmmAGraphScoped -> UniqSM CmmGraph Source #

allocate a fresh label for the entry point

labelAGraph :: BlockId -> CmmAGraphScoped -> CmmGraph Source #

use the given BlockId as the label of the entry point

stackStubExpr :: Width -> CmmExpr Source #

mkNop :: CmmAGraph Source #

mkAssign :: CmmReg -> CmmExpr -> CmmAGraph Source #

mkStore :: CmmExpr -> CmmExpr -> CmmAGraph Source #

mkUnsafeCall :: ForeignTarget -> [CmmFormal] -> [CmmActual] -> CmmAGraph Source #

mkFinalCall :: DynFlags -> CmmExpr -> CCallConv -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph Source #

mkCallReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph Source #

mkJumpReturnsTo :: DynFlags -> CmmExpr -> Convention -> [CmmExpr] -> BlockId -> ByteOff -> UpdFrameOffset -> CmmAGraph Source #

mkJump :: DynFlags -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph Source #

mkJumpExtra :: DynFlags -> Convention -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> CmmAGraph Source #

mkRawJump :: DynFlags -> CmmExpr -> UpdFrameOffset -> [GlobalReg] -> CmmAGraph Source #

A jump where the caller says what the live GlobalRegs are. Used for low-level hand-written Cmm.

mkCbranch :: CmmExpr -> BlockId -> BlockId -> Maybe Bool -> CmmAGraph Source #

mkSwitch :: CmmExpr -> SwitchTargets -> CmmAGraph Source #

mkReturn :: DynFlags -> CmmExpr -> [CmmExpr] -> UpdFrameOffset -> CmmAGraph Source #

mkComment :: FastString -> CmmAGraph Source #

mkCallEntry :: DynFlags -> Convention -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) Source #

mkBranch :: BlockId -> CmmAGraph Source #

mkUnwind :: GlobalReg -> CmmExpr -> CmmAGraph Source #

Construct a `CmmUnwind` node for the given register and unwinding expression.

copyInOflow :: DynFlags -> Convention -> Area -> [CmmFormal] -> [CmmFormal] -> (Int, [GlobalReg], CmmAGraph) Source #

copyOutOflow :: DynFlags -> Convention -> Transfer -> Area -> [CmmExpr] -> UpdFrameOffset -> [CmmExpr] -> (Int, [GlobalReg], CmmAGraph) Source #

noExtraStack :: [CmmExpr] Source #

toCall :: CmmExpr -> Maybe BlockId -> UpdFrameOffset -> ByteOff -> ByteOff -> [GlobalReg] -> CmmAGraph Source #

data Transfer Source #

Constructors

Call |
JumpRet |
Jump |
Ret |

Instances

Eq Transfer # |
Instance details Methods (==) :: Transfer -> Transfer -> Bool # (/=) :: Transfer -> Transfer -> Bool #