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
Implements
Inherited Members
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
| Improve this Doc View SourceAnalyze(FlowGraph)
Declaration
public RegisterAllocation<TRegister> Analyze(FlowGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| FlowGraph | graph |
Returns
| Type | Description |
|---|---|
| RegisterAllocation<TRegister> |
AnalyzeWithUpdates(FlowGraph, RegisterAllocation<TRegister>, IReadOnlyList<FlowGraphUpdate>)
Declaration
public RegisterAllocation<TRegister> AnalyzeWithUpdates(FlowGraph graph, RegisterAllocation<TRegister> previousResult, IReadOnlyList<FlowGraphUpdate> updates)
Parameters
| Type | Name | Description |
|---|---|---|
| FlowGraph | graph | |
| RegisterAllocation<TRegister> | previousResult | |
| System.Collections.Generic.IReadOnlyList<FlowGraphUpdate> | updates |
Returns
| Type | Description |
|---|---|
| RegisterAllocation<TRegister> |
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. |
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 |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
Implementations may override this method to suppress register allocation for values that are, e.g., stored on an evaluation stack.
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 |
|---|---|
| System.Boolean |
|
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. |
| System.Collections.Generic.IEnumerable<TRegister> | registers | A set of registers that are eligible for recycling. |
| TRegister | result | A register to recycle, if any. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|