Class ConstantPropagation
A transform that evaluates non-effectful instructions at compile-time and propagates their results. Essentially just an implementation of sparse conditional constant propagation.
Inherited Members
Namespace: Flame.Compiler.Transforms
Assembly: Flame.Compiler.dll
Syntax
public sealed class ConstantPropagation : IntraproceduralOptimization
Constructors
| Improve this Doc View SourceConstantPropagation()
Creates a constant propagation transform that uses the default evaluation function.
Declaration
public ConstantPropagation()
ConstantPropagation(Func<InstructionPrototype, IReadOnlyList<Constant>, Constant>)
Creates a constant propagation transform that uses a particular evaluation function.
Declaration
public ConstantPropagation(Func<InstructionPrototype, IReadOnlyList<Constant>, Constant> evaluate)
Parameters
Type | Name | Description |
---|---|---|
System.Func<InstructionPrototype, System.Collections.Generic.IReadOnlyList<Constant>, Constant> | evaluate | The evaluation function to use. It evaluates an instruction that
takes a list of constant arguments. It returns |
Properties
| Improve this Doc View SourceEvaluate
Evaluates an instruction that takes a list of constant arguments.
Returns null
if the instruction cannot be evaluated.
Declaration
public Func<InstructionPrototype, IReadOnlyList<Constant>, Constant> Evaluate { get; }
Property Value
Type | Description |
---|---|
System.Func<InstructionPrototype, System.Collections.Generic.IReadOnlyList<Constant>, Constant> |
Methods
| Improve this Doc View SourceApply(FlowGraph)
Applies this intraprocedural optimization to a flow graph.
Declaration
public override FlowGraph Apply(FlowGraph graph)
Parameters
Type | Name | Description |
---|---|---|
FlowGraph | graph | The flow graph to transform. |
Returns
Type | Description |
---|---|
FlowGraph | A transformed flow graph. |
Overrides
| Improve this Doc View SourceEvaluateDefault(InstructionPrototype, IReadOnlyList<Constant>)
The default constant instruction evaluation function.
Declaration
public static Constant EvaluateDefault(InstructionPrototype prototype, IReadOnlyList<Constant> arguments)
Parameters
Type | Name | Description |
---|---|---|
InstructionPrototype | prototype | The prorotype of the instruction to evaluate. |
System.Collections.Generic.IReadOnlyList<Constant> | arguments | A list of arguments to the instruction, all of which must be constants. |
Returns
Type | Description |
---|---|
Constant |
|