Class StackInstructionStreamBuilder<TInstruction>
An instruction stream builder that manages data transfer using a combination of stack slots and explicit register loads/stores, as commonly offered by stack machines.
Inherited Members
Namespace: Flame.Compiler.Target
Assembly: Flame.Compiler.dll
Syntax
public class StackInstructionStreamBuilder<TInstruction> : InstructionStreamBuilder<TInstruction>
Type Parameters
| Name | Description |
|---|---|
| TInstruction | The type of instruction to generate. |
Constructors
| Edit this page View SourceStackInstructionStreamBuilder(ILinearInstructionSelector<TInstruction>)
Creates a stack machine instruction stream builder.
Declaration
protected StackInstructionStreamBuilder(ILinearInstructionSelector<TInstruction> instructionSelector)
Parameters
| Type | Name | Description |
|---|---|---|
| ILinearInstructionSelector<TInstruction> | instructionSelector | The instruction selector to use. This instruction selector must also be a stack instruction selector. |
Methods
| Edit this page View SourceCreate<TSelector>(TSelector)
Creates a linear instruction stream builder.
Declaration
public static StackInstructionStreamBuilder<TInstruction> Create<TSelector>(TSelector instructionSelector) where TSelector : ILinearInstructionSelector<TInstruction>, IStackInstructionSelector<TInstruction>
Parameters
| Type | Name | Description |
|---|---|---|
| TSelector | instructionSelector | The instruction selector to use. |
Returns
| Type | Description |
|---|---|
| StackInstructionStreamBuilder<TInstruction> |
Type Parameters
| Name | Description |
|---|---|
| TSelector |
GetStackContentsOnEntry(BasicBlock)
Gets the contents of the evaluation stack just before a basic block's first instruction is executed.
Declaration
protected virtual IEnumerable<ValueTag> GetStackContentsOnEntry(BasicBlock block)
Parameters
| Type | Name | Description |
|---|---|---|
| BasicBlock | block | The basic block to inspect. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ValueTag> | A sequence of values that represent the contents of the stack. |
ShouldMaterializeOnUse(NamedInstruction)
Tells if an instruction should always be materialized when it is used rather than when it is defined.
Declaration
protected virtual bool ShouldMaterializeOnUse(NamedInstruction instruction)
Parameters
| Type | Name | Description |
|---|---|---|
| NamedInstruction | instruction | An instruction to inspect. |
Returns
| Type | Description |
|---|---|
| bool |
|
ToInstructionStream(BasicBlock, IReadOnlyDictionary<ValueTag, SelectedInstructions<TInstruction>>, SelectedFlowInstructions<TInstruction>)
Creates a linear sequence of instructions for a basic block based on selected instructions for named instructions and block flow.
Declaration
protected override IReadOnlyList<TInstruction> ToInstructionStream(BasicBlock block, IReadOnlyDictionary<ValueTag, SelectedInstructions<TInstruction>> instructions, SelectedFlowInstructions<TInstruction> flow)
Parameters
| Type | Name | Description |
|---|---|---|
| BasicBlock | block | The basic blocks to place. |
| IReadOnlyDictionary<ValueTag, SelectedInstructions<TInstruction>> | instructions | A mapping of named instructions to their selected instructions. Named instructions that do not appear in this mapping should not be selected. |
| SelectedFlowInstructions<TInstruction> | flow | Selected instructions for |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<TInstruction> | A linear sequence of instructions. |