Struct PeepholeRewriteRule<TInstruction>
A rewrite rule as used by a peephole optimizer.
Inherited Members
Namespace: Flame.Compiler.Target
Assembly: Flame.Compiler.dll
Syntax
public struct PeepholeRewriteRule<TInstruction>
Type Parameters
Name | Description |
---|---|
TInstruction | The type of target-specific instruction to rewrite. |
Constructors
| Improve this Doc View SourcePeepholeRewriteRule(IReadOnlyList<Predicate<TInstruction>>, Func<IReadOnlyList<TInstruction>, IReadOnlyList<TInstruction>>)
Creates a peephole rewrite rule.
Declaration
public PeepholeRewriteRule(IReadOnlyList<Predicate<TInstruction>> pattern, Func<IReadOnlyList<TInstruction>, IReadOnlyList<TInstruction>> rewrite)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyList<System.Predicate<TInstruction>> | pattern | The pattern to match on, specified as a list of predicates. The rewrite rule is considered to be applicable if and only if every pattern in the list is a match. |
System.Func<System.Collections.Generic.IReadOnlyList<TInstruction>, System.Collections.Generic.IReadOnlyList<TInstruction>> | rewrite | A function that rewrites instructions that match the pattern. |
PeepholeRewriteRule(IReadOnlyList<Predicate<TInstruction>>, Predicate<IReadOnlyList<TInstruction>>, Func<IReadOnlyList<TInstruction>, IReadOnlyList<TInstruction>>)
Creates a peephole rewrite rule.
Declaration
public PeepholeRewriteRule(IReadOnlyList<Predicate<TInstruction>> pattern, Predicate<IReadOnlyList<TInstruction>> macroPattern, Func<IReadOnlyList<TInstruction>, IReadOnlyList<TInstruction>> rewrite)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyList<System.Predicate<TInstruction>> | pattern | The pattern to match on, specified as a list of predicates. The rewrite rule only considered to be applicable if every pattern in the list is a match. list is a match. |
System.Predicate<System.Collections.Generic.IReadOnlyList<TInstruction>> | macroPattern | A "macro-pattern" that decides if a sequence of
instructions can be rewritten by the rewrite rule,
assuming that every instruction in the sequence
already adheres to |
System.Func<System.Collections.Generic.IReadOnlyList<TInstruction>, System.Collections.Generic.IReadOnlyList<TInstruction>> | rewrite | A function that rewrites instructions that match the pattern. |
Properties
| Improve this Doc View SourceMacroPattern
Gets a "macro-pattern" that decides if a sequence of instructions can be rewritten by the rewrite rule, assuming that every instruction in the sequence already adheres to the pattern.
Declaration
public Predicate<IReadOnlyList<TInstruction>> MacroPattern { get; }
Property Value
Type | Description |
---|---|
System.Predicate<System.Collections.Generic.IReadOnlyList<TInstruction>> | A predicate on a sequence of instructions. |
Pattern
Gets the pattern to match on, specified as a list of predicates. The rewrite rule is only considered to be applicable if every pattern in the list is a match.
Declaration
public IReadOnlyList<Predicate<TInstruction>> Pattern { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<System.Predicate<TInstruction>> | A list of instruction-matching predicates. |
Rewrite
Rewrites a list of instructions matching the pattern specified by this rewrite rule.
Declaration
public Func<IReadOnlyList<TInstruction>, IReadOnlyList<TInstruction>> Rewrite { get; }
Property Value
Type | Description |
---|---|
System.Func<System.Collections.Generic.IReadOnlyList<TInstruction>, System.Collections.Generic.IReadOnlyList<TInstruction>> | A function that rewrites instructions. |