Show / Hide Table of Contents

    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.

    Inheritance
    System.Object
    Optimization
    IntraproceduralOptimization
    ConstantPropagation
    Inherited Members
    IntraproceduralOptimization.IsCheckpoint
    IntraproceduralOptimization.ApplyAsync(MethodBody, OptimizationState)
    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.Transforms
    Assembly: Flame.Compiler.dll
    Syntax
    public sealed class ConstantPropagation : IntraproceduralOptimization

    Constructors

    | Improve this Doc View Source

    ConstantPropagation()

    Creates a constant propagation transform that uses the default evaluation function.

    Declaration
    public ConstantPropagation()
    | Improve this Doc View Source

    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 null if the instruction cannot be evaluated; otherwise, it returns the constant to which it was evaluated.

    Properties

    | Improve this Doc View Source

    Evaluate

    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 Source

    Apply(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
    IntraproceduralOptimization.Apply(FlowGraph)
    | Improve this Doc View Source

    EvaluateDefault(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

    null if the instruction cannot be evaluated; otherwise, the constant to which the instruction evaluates.

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX