Show / Hide Table of Contents

    Class FlowGraphBuilder

    A mutable view of an immutable control-flow graph.

    Inheritance
    System.Object
    FlowGraphBuilder
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Flame.Compiler
    Assembly: Flame.Compiler.dll
    Syntax
    public sealed class FlowGraphBuilder

    Constructors

    | Improve this Doc View Source

    FlowGraphBuilder()

    Creates a control-flow graph builder that contains only an empty entry point block.

    Declaration
    public FlowGraphBuilder()
    | Improve this Doc View Source

    FlowGraphBuilder(FlowGraph)

    Creates a control-flow graph builder from an immutable control-flow graph.

    Declaration
    public FlowGraphBuilder(FlowGraph graph)
    Parameters
    Type Name Description
    FlowGraph graph

    An immutable control-flow graph.

    Properties

    | Improve this Doc View Source

    AnonymousInstructions

    Gets a sequence of all anonymous instructions defined by block flow in this control-flow graph.

    Declaration
    public IEnumerable<InstructionBuilder> AnonymousInstructions { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<InstructionBuilder>

    All anonymous instructions.

    | Improve this Doc View Source

    BasicBlocks

    Gets a sequence of all basic blocks in this control-flow graph.

    Declaration
    public IEnumerable<BasicBlockBuilder> BasicBlocks { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<BasicBlockBuilder>

    All basic blocks.

    | Improve this Doc View Source

    BasicBlockTags

    Gets a sequence of all basic block tags in this control-flow graph.

    Declaration
    public IEnumerable<BasicBlockTag> BasicBlockTags { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<BasicBlockTag>
    | Improve this Doc View Source

    EntryPoint

    Gets the entry point block.

    Declaration
    public BasicBlockBuilder EntryPoint { get; }
    Property Value
    Type Description
    BasicBlockBuilder

    The entry point block.

    | Improve this Doc View Source

    EntryPointTag

    Gets the tag of the entry point block.

    Declaration
    public BasicBlockTag EntryPointTag { get; set; }
    Property Value
    Type Description
    BasicBlockTag

    The tag of the entry point block.

    | Improve this Doc View Source

    Instructions

    Gets a sequence of all instructions defined in this control-flow graph, including both named and anonymous instructions.

    Declaration
    public IEnumerable<InstructionBuilder> Instructions { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<InstructionBuilder>

    All instructions in this control-flow graph.

    | Improve this Doc View Source

    InstructionTags

    Gets a sequence of all instruction tags in this control-flow graph.

    Declaration
    public IEnumerable<ValueTag> InstructionTags { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<ValueTag>
    | Improve this Doc View Source

    NamedInstructions

    Gets a sequence of all named instructions in this control-flow graph. Anonymous instructions as defined by block flow are not included.

    Declaration
    public IEnumerable<NamedInstructionBuilder> NamedInstructions { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<NamedInstructionBuilder>

    All named instructions.

    | Improve this Doc View Source

    ParameterTags

    Gets a sequence of all parameter tags in this control-flow graph.

    Declaration
    public IEnumerable<ValueTag> ParameterTags { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<ValueTag>
    | Improve this Doc View Source

    ValueTags

    Gets a sequence of all value tags in this control-flow graph. This sequence includes both instruction values and basic block parameter values.

    Declaration
    public IEnumerable<ValueTag> ValueTags { get; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<ValueTag>

    Methods

    | Improve this Doc View Source

    AddAnalysis<T>(IFlowGraphAnalysis<T>)

    Registers a flow graph analysis with this graph.

    Declaration
    public void AddAnalysis<T>(IFlowGraphAnalysis<T> analysis)
    Parameters
    Type Name Description
    IFlowGraphAnalysis<T> analysis

    The analysis to register.

    Type Parameters
    Name Description
    T

    The type of result produced by the analysis.

    | Improve this Doc View Source

    AddBasicBlock()

    Adds an empty basic block to this flow-graph builder.

    Declaration
    public BasicBlockBuilder AddBasicBlock()
    Returns
    Type Description
    BasicBlockBuilder

    An empty basic block builder.

    | Improve this Doc View Source

    AddBasicBlock(String)

    Adds an empty basic block to this flow-graph builder.

    Declaration
    public BasicBlockBuilder AddBasicBlock(string name)
    Parameters
    Type Name Description
    System.String name

    The (preferred) name of the basic block's tag.

    Returns
    Type Description
    BasicBlockBuilder

    An empty basic block builder.

    | Improve this Doc View Source

    ContainsBasicBlock(BasicBlockTag)

    Checks if this control-flow graph contains a basic block with a particular tag.

    Declaration
    public bool ContainsBasicBlock(BasicBlockTag tag)
    Parameters
    Type Name Description
    BasicBlockTag tag

    The basic block's tag.

    Returns
    Type Description
    System.Boolean

    true if this control-flow graph contains a basic block with the given tag; otherwise, false.

    | Improve this Doc View Source

    ContainsBlockParameter(ValueTag)

    Checks if this control-flow graph contains a basic block parameter with a particular tag.

    Declaration
    public bool ContainsBlockParameter(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The parameter's tag.

    Returns
    Type Description
    System.Boolean

    true if this control-flow graph contains a basic block parameter with the given tag; otherwise, false.

    | Improve this Doc View Source

    ContainsInstruction(ValueTag)

    Checks if this control-flow graph contains an instruction with a particular tag.

    Declaration
    public bool ContainsInstruction(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The instruction's tag.

    Returns
    Type Description
    System.Boolean

    true if this control-flow graph contains an instruction with the given tag; otherwise, false.

    | Improve this Doc View Source

    ContainsValue(ValueTag)

    Checks if this control-flow graph contains an instruction or basic block parameter with a particular tag.

    Declaration
    public bool ContainsValue(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The value's tag.

    Returns
    Type Description
    System.Boolean

    true if this control-flow graph contains a value with the given tag; otherwise, false.

    | Improve this Doc View Source

    GetAnalysisFor<T>()

    Gets the analysis, registered with this control-flow graph, that produced a particular type of result.

    Declaration
    public IFlowGraphAnalysis<T> GetAnalysisFor<T>()
    Returns
    Type Description
    IFlowGraphAnalysis<T>

    An analysis.

    Type Parameters
    Name Description
    T

    The type of analysis result that is sought.

    | Improve this Doc View Source

    GetAnalysisResult<T>()

    Gets an analysis result based on its type.

    Declaration
    public T GetAnalysisResult<T>()
    Returns
    Type Description
    T

    An analysis result.

    Type Parameters
    Name Description
    T

    The type of analysis result to fetch or compute.

    | Improve this Doc View Source

    GetBasicBlock(BasicBlockTag)

    Gets the basic block with a particular tag.

    Declaration
    public BasicBlockBuilder GetBasicBlock(BasicBlockTag tag)
    Parameters
    Type Name Description
    BasicBlockTag tag

    The basic block's tag.

    Returns
    Type Description
    BasicBlockBuilder

    A basic block.

    | Improve this Doc View Source

    GetInstruction(InstructionBuilder)

    Gets this control flow graph builder's equivalent of a shared instruction in another control flow graph.

    Declaration
    public InstructionBuilder GetInstruction(InstructionBuilder instruction)
    Parameters
    Type Name Description
    InstructionBuilder instruction

    The instruction builder to find an equivalent for.

    Returns
    Type Description
    InstructionBuilder

    An instruction builder.

    | Improve this Doc View Source

    GetInstruction(ValueTag)

    Gets the instruction with a particular tag.

    Declaration
    public NamedInstructionBuilder GetInstruction(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The instruction's tag.

    Returns
    Type Description
    NamedInstructionBuilder

    A named instruction.

    | Improve this Doc View Source

    GetValueParent(ValueTag)

    Gets basic block that defines a value with a particular tag.

    Declaration
    public BasicBlockBuilder GetValueParent(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The tag of the value to look for.

    Returns
    Type Description
    BasicBlockBuilder

    The basic block that defines the value.

    | Improve this Doc View Source

    GetValueType(ValueTag)

    Gets the type of a value in this graph.

    Declaration
    public IType GetValueType(ValueTag tag)
    Parameters
    Type Name Description
    ValueTag tag

    The value's tag.

    Returns
    Type Description
    IType

    The value's type.

    | Improve this Doc View Source

    HasAnalysisFor<T>()

    Tells if this flow graph has an analysis that produces a particular type of result.

    Declaration
    public bool HasAnalysisFor<T>()
    Returns
    Type Description
    System.Boolean

    true if a registered analysis produces a result of type T; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of analysis result that is sought.

    | Improve this Doc View Source

    Include(FlowGraph, Func<ReturnFlow, BasicBlockBuilder, BlockFlow>)

    Includes a control-flow graph in this control-flow graph. Any values and blocks defined by the graph to include are renamed in order to avoid conflicts with tags in this graph.

    Declaration
    public BasicBlockTag Include(FlowGraph graph, Func<ReturnFlow, BasicBlockBuilder, BlockFlow> rewriteReturnFlow)
    Parameters
    Type Name Description
    FlowGraph graph

    The graph to include in this graph.

    System.Func<ReturnFlow, BasicBlockBuilder, BlockFlow> rewriteReturnFlow

    Rewrites 'return' flow.

    Returns
    Type Description
    BasicBlockTag

    The tag of the imported graph's entry point.

    | Improve this Doc View Source

    Include(FlowGraph, Func<ReturnFlow, BasicBlockBuilder, BlockFlow>, Branch)

    Includes a control-flow graph in this control-flow graph. Any values and blocks defined by the graph to include are renamed in order to avoid conflicts with tags in this graph. Instructions that may throw an exception are wrapped in 'try' flow.

    Declaration
    public BasicBlockTag Include(FlowGraph graph, Func<ReturnFlow, BasicBlockBuilder, BlockFlow> rewriteReturnFlow, Branch exceptionBranch)
    Parameters
    Type Name Description
    FlowGraph graph

    The graph to include in this graph.

    System.Func<ReturnFlow, BasicBlockBuilder, BlockFlow> rewriteReturnFlow

    Rewrites 'return' flow.

    Branch exceptionBranch

    The branch to take when an exception is thrown by an instruction in graph. Instructions are not wrapped in 'try' flow if this parameter is set to null.

    Returns
    Type Description
    BasicBlockTag

    The tag of the imported graph's entry point.

    | Improve this Doc View Source

    RemoveBasicBlock(BasicBlockTag)

    Removes the basic block with a particular tag from this control-flow graph.

    Declaration
    public void RemoveBasicBlock(BasicBlockTag tag)
    Parameters
    Type Name Description
    BasicBlockTag tag

    The basic block's tag.

    | Improve this Doc View Source

    RemoveDefinitions(IEnumerable<ValueTag>)

    Removes the definitions for a set of values from this flow graph.

    Declaration
    public void RemoveDefinitions(IEnumerable<ValueTag> valuesToRemove)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<ValueTag> valuesToRemove

    A set of values whose definitions are to be eliminated from the flow graph. These values can refer to instructions and basic block parameters.

    | Improve this Doc View Source

    RemoveInstruction(ValueTag)

    Removes a particular instruction from this control-flow graph. Returns a new control-flow graph that does not contain the instruction.

    Declaration
    public void RemoveInstruction(ValueTag instructionTag)
    Parameters
    Type Name Description
    ValueTag instructionTag

    The tag of the instruction to remove.

    | Improve this Doc View Source

    RemoveInstructionDefinitions(IEnumerable<ValueTag>)

    Removes the definitions for a set of instructions from this flow graph.

    Declaration
    public void RemoveInstructionDefinitions(IEnumerable<ValueTag> instructionsToRemove)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<ValueTag> instructionsToRemove

    A set of values whose definitions are to be eliminated from the flow graph. These values may only refer to instructions.

    | Improve this Doc View Source

    ReplaceUses(IReadOnlyDictionary<ValueTag, ValueTag>)

    Replaces all uses of values with other values. The values to replace are encoded as keys in a dictionary and the values to replace them with as values in that same dictionary.

    Declaration
    public void ReplaceUses(IReadOnlyDictionary<ValueTag, ValueTag> replacementMap)
    Parameters
    Type Name Description
    System.Collections.Generic.IReadOnlyDictionary<ValueTag, ValueTag> replacementMap

    A mapping of values to replacement values.

    | Improve this Doc View Source

    ToImmutable()

    Turns this control-flow graph builder into an immutable control-flow graph.

    Declaration
    public FlowGraph ToImmutable()
    Returns
    Type Description
    FlowGraph

    An immutable control-flow graph.

    | Improve this Doc View Source

    Transform(IntraproceduralOptimization)

    Applies an intraprocedural optimization to this flow graph.

    Declaration
    public void Transform(IntraproceduralOptimization optimization)
    Parameters
    Type Name Description
    IntraproceduralOptimization optimization

    The transform to apply.

    | Improve this Doc View Source

    Transform(IntraproceduralOptimization[])

    Applies a sequence of intraprocedural optimizations to this flow graph.

    Declaration
    public void Transform(params IntraproceduralOptimization[] optimizations)
    Parameters
    Type Name Description
    IntraproceduralOptimization[] optimizations

    The transforms to apply.

    | Improve this Doc View Source

    Transform(IEnumerable<IntraproceduralOptimization>)

    Applies a sequence of intraprocedural optimizations to this flow graph.

    Declaration
    public void Transform(IEnumerable<IntraproceduralOptimization> optimizations)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<IntraproceduralOptimization> optimizations

    The transforms to apply.

    | Improve this Doc View Source

    TryForkAndMerge(Func<FlowGraphBuilder, Boolean>)

    Applies a function to a copy of this control-flow graph and either incorporates those changes into this control-flow graph or discards them, depending on the Boolean value returned by the transforming function.

    Declaration
    public bool TryForkAndMerge(Func<FlowGraphBuilder, bool> transform)
    Parameters
    Type Name Description
    System.Func<FlowGraphBuilder, System.Boolean> transform

    A function that takes a copy of this control-flow graph and modifies it. If the function returns true, then this control-flow graph is set to the modified version created by the function; otherwise, this control-flow graph is left unchanged.

    Returns
    Type Description
    System.Boolean

    transform's return value.

    | Improve this Doc View Source

    TryGetAnalysisResult<T>(out T)

    Tries to get an analysis result of a particular type.

    Declaration
    public bool TryGetAnalysisResult<T>(out T result)
    Parameters
    Type Name Description
    T result

    The analysis result, if one can be fetched or computed.

    Returns
    Type Description
    System.Boolean

    true if there is an analyzer to compute the result; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of analysis result to fetch or compute.

    | Improve this Doc View Source

    TryGetInstruction(ValueTag, out NamedInstructionBuilder)

    Tries to get an instruction with a particular tag, if it exists in this control-flow graph.

    Declaration
    public bool TryGetInstruction(ValueTag tag, out NamedInstructionBuilder result)
    Parameters
    Type Name Description
    ValueTag tag

    The instruction's tag.

    NamedInstructionBuilder result

    The named instruction, if it exists in this control-flow graph.

    Returns
    Type Description
    System.Boolean

    true if the instruction exists; otherwise, false.

    Extension Methods

    ExceptionDelayabilityExtensions.CanDelayExceptions(FlowGraphBuilder, ValueTag)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX