Search Results for

    Show / Hide Table of Contents

    Class GreedyRegisterAllocator<TRegister>

    An analysis that greedily allocates registers to values. The set of values is assumed to be unbounded: the analysis is allowed to "create" an arbitrarily large amount of registers.

    Inheritance
    object
    GreedyRegisterAllocator<TRegister>
    Implements
    IFlowGraphAnalysis<RegisterAllocation<TRegister>>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Flame.Compiler.Analysis
    Assembly: Flame.Compiler.dll
    Syntax
    public abstract class GreedyRegisterAllocator<TRegister> : IFlowGraphAnalysis<RegisterAllocation<TRegister>>
    Type Parameters
    Name Description
    TRegister

    The type of register allocated to values.

    Methods

    | Edit this page View Source

    Analyze(FlowGraph)

    Analyzes a flow graph from scratch.

    Declaration
    public RegisterAllocation<TRegister> Analyze(FlowGraph graph)
    Parameters
    Type Name Description
    FlowGraph graph

    The flow graph to analyze.

    Returns
    Type Description
    RegisterAllocation<TRegister>

    The analysis' output.

    | Edit this page View Source

    AnalyzeWithUpdates(FlowGraph, RegisterAllocation<TRegister>, IReadOnlyList<FlowGraphUpdate>)

    Analyzes a flow graph based on the flow graph, the previous result, and a list of updates that were applied to the graph since the previous result.

    Declaration
    public RegisterAllocation<TRegister> AnalyzeWithUpdates(FlowGraph graph, RegisterAllocation<TRegister> previousResult, IReadOnlyList<FlowGraphUpdate> updates)
    Parameters
    Type Name Description
    FlowGraph graph

    The current version of the flow graph to analyze.

    RegisterAllocation<TRegister> previousResult

    A previous result produced by this analysis.

    IReadOnlyList<FlowGraphUpdate> updates

    A list of updates that were applied to the flow graph since the previous result was computed.

    Returns
    Type Description
    RegisterAllocation<TRegister>

    The analysis' output, which must be equal to a call to Analyze.

    | Edit this page View Source

    CreateRegister(IType)

    Creates a brand new register for a value of a particular type.

    Declaration
    protected abstract TRegister CreateRegister(IType type)
    Parameters
    Type Name Description
    IType type

    The type of value to create a register for.

    Returns
    Type Description
    TRegister

    A register suitable for the value.

    | Edit this page View Source

    RequiresRegister(ValueTag, FlowGraph)

    Tells if a register should be allocated for a particular value.

    Declaration
    protected virtual bool RequiresRegister(ValueTag value, FlowGraph graph)
    Parameters
    Type Name Description
    ValueTag value

    The value for which register allocation may or may not be necessary.

    FlowGraph graph

    The control flow graph that defines value.

    Returns
    Type Description
    bool

    true if a register must be allocated to value; otherwise, false.

    Remarks

    Implementations may override this method to suppress register allocation for values that are, e.g., stored on an evaluation stack.

    | Edit this page View Source

    TryGetPreallocatedRegister(ValueTag, FlowGraph, out TRegister)

    Tries to get a preallocated register for a particular value. If it exists, then the preallocated register will be used for the value, no questions asked. The preallocated register may be reused.

    Declaration
    protected virtual bool TryGetPreallocatedRegister(ValueTag value, FlowGraph graph, out TRegister register)
    Parameters
    Type Name Description
    ValueTag value

    The value that may have a preallocated register.

    FlowGraph graph

    The graph that defines the value.

    TRegister register

    A preallocated register, if any.

    Returns
    Type Description
    bool

    true if there is a preallocated register for value; otherwise, false.

    | Edit this page View Source

    TryRecycleRegister(IType, IEnumerable<TRegister>, out TRegister)

    Tries to recycle a register from a set of registers.

    Declaration
    protected abstract bool TryRecycleRegister(IType type, IEnumerable<TRegister> registers, out TRegister result)
    Parameters
    Type Name Description
    IType type

    The type of value to store in the recycled register.

    IEnumerable<TRegister> registers

    A set of registers that are eligible for recycling.

    TRegister result

    A register to recycle, if any.

    Returns
    Type Description
    bool

    true if a register has been selected for recyling; otherwise, false.

    Implements

    IFlowGraphAnalysis<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX