14 #ifndef MLIR_REWRITE_BYTECODE_H_
15 #define MLIR_REWRITE_BYTECODE_H_
20 namespace pdl_interp {
51 template <
typename... Args>
53 Args &&...patternArgs)
54 :
Pattern(std::forward<Args>(patternArgs)...), rewriterAddr(rewriterAddr),
55 configSet(configSet) {}
89 std::vector<const void *> memory;
95 std::vector<OwningOpRange> opRangeMemory;
99 std::vector<TypeRange> typeRangeMemory;
102 std::vector<llvm::OwningArrayRef<Type>> allocatedTypeRangeMemory;
106 std::vector<ValueRange> valueRangeMemory;
109 std::vector<llvm::OwningArrayRef<Value>> allocatedValueRangeMemory;
114 std::vector<unsigned> loopIndex;
118 std::vector<PatternBenefit> currentPatternBenefits;
159 SmallVector<std::unique_ptr<PDLPatternConfigSet>> configs,
161 llvm::StringMap<PDLConstraintFunction> constraintFns,
162 llvm::StringMap<PDLRewriteFunction> rewriteFns);
197 std::vector<const void *> uniquedData;
209 std::vector<PDLConstraintFunction> constraintFunctions;
210 std::vector<PDLRewriteFunction> rewriteFunctions;
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation is the basic unit of execution within MLIR.
This class contains a set of configurations for a specific pattern.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
This class contains all of the data related to a pattern, but does not contain any methods or logic f...
This class contains the mutable state of a bytecode instance.
void updatePatternBenefit(unsigned patternIndex, PatternBenefit benefit)
Set the new benefit for a bytecode pattern.
void cleanupAfterMatchAndRewrite()
Cleanup any allocated state after a match/rewrite has been completed.
All of the data pertaining to a specific pattern within the bytecode.
ByteCodeAddr getRewriterAddr() const
Return the bytecode address of the rewriter for this pattern.
PDLPatternConfigSet * getConfigSet() const
Return the configuration set for this pattern, or null if there is none.
static PDLByteCodePattern create(pdl_interp::RecordMatchOp matchOp, PDLPatternConfigSet *configSet, ByteCodeAddr rewriterAddr)
The bytecode class is also the interpreter.
ArrayRef< PDLByteCodePattern > getPatterns() const
Return the patterns held by the bytecode.
void match(Operation *op, PatternRewriter &rewriter, SmallVectorImpl< MatchResult > &matches, PDLByteCodeMutableState &state) const
Run the pattern matcher on the given root operation, collecting the matched patterns in matches.
PDLByteCode(ModuleOp module, SmallVector< std::unique_ptr< PDLPatternConfigSet >> configs, const DenseMap< Operation *, PDLPatternConfigSet * > &configMap, llvm::StringMap< PDLConstraintFunction > constraintFns, llvm::StringMap< PDLRewriteFunction > rewriteFns)
Create a ByteCode instance from the given module containing operations in the PDL interpreter dialect...
void initializeMutableState(PDLByteCodeMutableState &state) const
Initialize the given state such that it can be used to execute the current bytecode.
LogicalResult rewrite(PatternRewriter &rewriter, const MatchResult &match, PDLByteCodeMutableState &state) const
Run the rewriter of the given pattern that was previously matched in match.
uint16_t ByteCodeField
Use generic bytecode types.
llvm::OwningArrayRef< Operation * > OwningOpRange
This header declares functions that assist transformations in the MemRef dialect.
This class represents an efficient way to signal success or failure.
Each successful match returns a MatchResult, which contains information necessary to execute the rewr...
MatchResult & operator=(const MatchResult &)=delete
PatternBenefit benefit
The current benefit of the pattern that was matched.
const PDLByteCodePattern * pattern
The originating pattern that was matched.
SmallVector< TypeRange, 0 > typeRangeValues
Memory used for the range input values.
MatchResult(Location loc, const PDLByteCodePattern &pattern, PatternBenefit benefit)
SmallVector< ValueRange, 0 > valueRangeValues
MatchResult & operator=(MatchResult &&)=default
SmallVector< const void * > values
Memory values defined in the matcher that are passed to the rewriter.
Location location
The location of operations to be replaced.
MatchResult(MatchResult &&other)=default
MatchResult(const MatchResult &)=delete