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

Safe HaskellSafe
LanguageHaskell98

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

Instances

Show a => Show (Graph a) Source # 

Methods

showsPrec :: Int -> Graph a -> ShowS #

show :: Graph a -> String #

showList :: [Graph a] -> ShowS #

data Node a Source #

A block of instructions, and an optional annotation.

Constructors

Node 

Fields

Instances

Show a => Show (Node a) Source # 

Methods

showsPrec :: Int -> Node a -> ShowS #

show :: Node a -> String #

showList :: [Node a] -> ShowS #

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.

modifyNodeOfGraph Source #

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 b Source #

Apply a function to every node in the graph.

mapAnnotsOfGraph :: (a -> b) -> Graph a -> Graph b Source #

Apply a function to every node annotation in the graph.

Node Utils

blockOfNode :: Node a -> Block Source #

Convert a Node to Block form, dropping any annotation.

childrenOfNode :: Node a -> Set Label Source #

Get the children of a node.