qute-0.1.0: A software analysis framework built around the QBE intermediate language.
Safe HaskellNone
LanguageGHC2021

Language.QBE.Analysis.CFG

Synopsis

Control Flow Graph

type Label = Key Source #

Representation of a node in the CFG.

data CFG Source #

A representation of the control-flow within a FuncDef.

build :: FuncDef -> CFG Source #

Construct a CFG for a given function.

identToLabel :: CFG -> BlockIdent -> Label Source #

Convert a BlockIdent to a CFG node Label.

This function is partial, on an invalid Label, an error is thrown.

labelToIdent :: CFG -> Label -> BlockIdent Source #

Convert a CFG node Label to a BlockIdent.

This function is partial, on an invalid Label, an error is thrown.

labelToBlock :: CFG -> Label -> Block Source #

Utility function to convert a node Label to a Block. Performs two \(O(\log n)\) lookups internally.

This function is partial, on an invalid Label, an error is thrown.

lookupSuccs :: CFG -> Label -> [Label] Source #

Mapping of Label to its successors in the CFG, represented as an ordered list of zero, one, or two elements. A list with two elements represents a conditional jump where the left child is the is the true branch and the right child is the false branch. A list wih a single element signifies an unconditional jump. If the given node does not have any successors an empty list is returned.

This function is partial, on an invalid Label, an error is thrown.

Graph Representation

nodes :: CFG -> [Label] Source #

Returns a list of all graph nodes in an unspecified order.

edges :: CFG -> [(Label, Label)] Source #

Returns a list of graph edges in an unspecified order.

bounds :: CFG -> Bounds Source #

Returns the bounds of the CFG. This is useful, for example, to build a subgraph using buildG.

Dominator Analysis

startNode :: CFG -> Label Source #

Determine the entry node of the CFG. Useful, for example, to generated a Rooted representation for the control-flow graph.