decomp: github.com/decomp/decomp/graph/cfg Index | Files

package cfg

import "github.com/decomp/decomp/graph/cfg"

Package cfg provides access to control flow graphs of LLVM IR functions.

Index

Package Files

cfg.go decode.go dom.go encode.go

type Attrs Uses

type Attrs map[string]string

Attrs specifies a set of DOT attributes as key-value pairs.

func (Attrs) Attributes Uses

func (a Attrs) Attributes() []encoding.Attribute

Attributes returns the DOT attributes of a node or edge.

type DominatorTree Uses

type DominatorTree struct {
    flow.DominatorTree
}

A DominatorTree represents a dominator tree.

func NewDom Uses

func NewDom(g graph.Directed, entry graph.Node) DominatorTree

NewDom returns a new dominator tree based on the given graph.

func (DominatorTree) Dominates Uses

func (dt DominatorTree) Dominates(a, b graph.Node) bool

Dominates reports whether A dominates B.

type Edge Uses

type Edge struct {
    graph.Edge
    // Edge label.
    Label string
}

Edge represents an edge of a control flow graph.

func (*Edge) Attributes Uses

func (e *Edge) Attributes() []encoding.Attribute

Attributes returns the attributes of the edge.

func (*Edge) SetAttribute Uses

func (e *Edge) SetAttribute(attr encoding.Attribute) error

SetAttribute sets the attribute of the edge.

type Graph Uses

type Graph struct {
    *simple.DirectedGraph
    // contains filtered or unexported fields
}

Graph represents a control flow graph.

func New Uses

func New(f *ir.Func) *Graph

New returns a new control flow graph based on the given function.

func ParseFile Uses

func ParseFile(path string) (*Graph, error)

ParseFile parses the given Graphviz DOT file into a control flow graph.

func (*Graph) AddNode Uses

func (g *Graph) AddNode(n graph.Node)

AddNode adds the given node to the graph. If the node is an entry node, the graph entry node is updated.

func (*Graph) Entry Uses

func (g *Graph) Entry() graph.Node

Entry returns the entry node of the control flow graph.

func (*Graph) NewEdge Uses

func (g *Graph) NewEdge(from, to graph.Node) graph.Edge

NewEdge returns a new Edge from the source to the destination node.

func (*Graph) NewEdgeWithLabel Uses

func (g *Graph) NewEdgeWithLabel(from, to graph.Node, label string) *Edge

NewEdgeWithLabel returns a new edge from the source to the destination node in the graph, or the existing edge if already present.

func (*Graph) NewNode Uses

func (g *Graph) NewNode() graph.Node

NewNode returns a new graph node with a unique arbitrary ID.

func (*Graph) NewNodeWithLabel Uses

func (g *Graph) NewNodeWithLabel(label string) *Node

NewNodeWithLabel returns a new node with the given basic block label in the graph, or the existing node if already present.

func (*Graph) NodeByLabel Uses

func (g *Graph) NodeByLabel(label string) (*Node, bool)

NodeByLabel returns the node with the given basic block label in the graph. The boolean return value indicates success.

func (*Graph) RemoveNode Uses

func (g *Graph) RemoveNode(n graph.Node)

RemoveNode removes n from the graph, as well as any edges attached to it. If the node is not in the graph it is a no-op.

func (*Graph) SetEntry Uses

func (g *Graph) SetEntry(entry graph.Node)

SetEntry sets the entry node of the control flow graph.

func (*Graph) SetNodeLabel Uses

func (g *Graph) SetNodeLabel(n graph.Node, label string)

SetNodeLabel sets the basic block label of the node.

type Node Uses

type Node struct {
    graph.Node
    // Basic block label.
    Label string
    // DOT attributes.
    Attrs
    // contains filtered or unexported fields
}

Node represents a node of a control flow graph.

func (*Node) Attributes Uses

func (n *Node) Attributes() []encoding.Attribute

Attributes returns the DOT attributes of the node.

func (*Node) DOTID Uses

func (n *Node) DOTID() string

DOTID returns the DOT node ID of the node.

func (*Node) SetAttribute Uses

func (n *Node) SetAttribute(attr encoding.Attribute) error

SetAttribute sets the attribute of the node.

func (*Node) SetDOTID Uses

func (n *Node) SetDOTID(id string)

SetDOTID sets the DOT node ID of the node.

Package cfg imports 13 packages (graph) and is imported by 3 packages. Updated 2020-01-15. Refresh now. Tools for package owners.