ghc-7.8.2: The GHC API

Safe Haskell | None
Language | Haskell98

MkGraph

Synopsis

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

# Documentation

type CmmAGraph = OrdList CgStmt

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; see `labelAGraph`.

data CgStmt

Constructors

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

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

catAGraphs :: [CmmAGraph] -> CmmAGraph

mkLabel :: BlockId -> CmmAGraph

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

mkMiddle :: CmmNode O O -> CmmAGraph

creates an open AGraph from a given node

mkLast :: CmmNode O C -> CmmAGraph

created a closed AGraph from a given node

outOfLine :: BlockId -> CmmAGraph -> CmmAGraph

A labelled code block; should end in a last node

lgraphOfAGraph :: CmmAGraph -> UniqSM CmmGraph

allocate a fresh label for the entry point

labelAGraph :: BlockId -> CmmAGraph -> CmmGraph

use the given BlockId as the label of the entry point

stackStubExpr :: Width -> CmmExpr

mkNop :: CmmAGraph

mkAssign :: CmmReg -> CmmExpr -> CmmAGraph

mkStore :: CmmExpr -> CmmExpr -> CmmAGraph

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

mkFinalCall :: DynFlags -> CmmExpr -> CCallConv -> [CmmActual] -> UpdFrameOffset -> CmmAGraph

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

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

mkJump :: DynFlags -> Convention -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph

mkJumpExtra :: DynFlags -> Convention -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> [CmmActual] -> CmmAGraph

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

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

mkCbranch :: CmmExpr -> BlockId -> BlockId -> CmmAGraph

mkSwitch :: CmmExpr -> [Maybe BlockId] -> CmmAGraph

mkReturn :: DynFlags -> CmmExpr -> [CmmActual] -> UpdFrameOffset -> CmmAGraph

mkComment :: FastString -> CmmAGraph

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

mkBranch :: BlockId -> CmmAGraph

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

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

noExtraStack :: [CmmActual]

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

data Transfer

Constructors

Call |
JumpRet |
Jump |
Ret |

Instances

Eq Transfer |