ddc-core-llvm-0.4.1.3: Disciplined Disciple Compiler LLVM code generator.

Safe HaskellSafe-Inferred

DDC.Llvm.Graph

Contents

Synopsis

Block Graphs

data Graph a Source

Llvm block graph. We use this form for transformations, as it makes it easy to find blocks and attach annotations to them.

Constructors

Graph 

Fields

graphEntry :: Label

The entry node for the block graph.

graphNodes :: Map Label (Node a)

Internal nodes.

Instances

Show a => Show (Graph a) 

data Node a Source

A block of instructions, and an optional annotation.

Constructors

Node 

Fields

nodeLabel :: Label

Block label for the node.

nodeInstrs :: Seq AnnotInstr

Statements in this node, with meta-data annotations.

nodeAnnot :: a

Optional annotation on the node.

Instances

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.

modifyNodeOfGraphSource

Arguments

:: 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

blockOfNode :: Node a -> BlockSource

Convert a Node to Block form, dropping any annotation.

childrenOfNode :: Node a -> Set LabelSource

Get the children of a node.