Safe Haskell | Safe-Inferred |
---|
- data Graph a = Graph {
- graphEntry :: Label
- graphNodes :: Map Label (Node a)
- data Node a = Node {
- nodeLabel :: Label
- nodeInstrs :: Seq AnnotInstr
- nodeAnnot :: a
- graphOfBlocks :: a -> [Block] -> Maybe (Graph a)
- blocksOfGraph :: Graph a -> [Block]
- labelsOfGraph :: Graph a -> [Label]
- lookupNodeOfGraph :: Graph a -> Label -> Maybe (Node a)
- modifyNodeOfGraph :: Label -> (Node a -> Node a) -> Graph a -> Graph a
- mapNodesOfGraph :: (Node a -> Node b) -> Graph a -> Graph b
- mapAnnotsOfGraph :: (a -> b) -> Graph a -> Graph b
- blockOfNode :: Node a -> Block
- childrenOfNode :: Node a -> Set Label
Block Graphs
Llvm block graph. We use this form for transformations, as it makes it easy to find blocks and attach annotations to them.
Graph | |
|
Show a => Show (Graph a) |
A block of instructions, and an optional annotation.
Node | |
|
Show a => Show (Node a) |
Graph Utils
graphOfBlocks :: a -> [Block] -> Maybe (Graph a)Source
Convert a list of blocks to a block graph.
blocksOfGraph :: Graph a -> [Block]Source
Flatten a graph back into a list of blocks.
labelsOfGraph :: Graph a -> [Label]Source
Get the set of all block labels in a graph.
lookupNodeOfGraph :: Graph a -> Label -> Maybe (Node a)Source
Lookup a node from the graph, or Nothing
if it can't be found.
:: Label | Label of node to modify. |
-> (Node a -> Node a) | Function to apply to the node. |
-> Graph a | |
-> Graph a |
Apply a function to a single node in the graoh.
mapNodesOfGraph :: (Node a -> Node b) -> Graph a -> Graph bSource
Apply a function to every node in the graph.
mapAnnotsOfGraph :: (a -> b) -> Graph a -> Graph bSource
Apply a function to every node annotation in the graph.
Node Utils
childrenOfNode :: Node a -> Set LabelSource
Get the children of a node.