MLIR
17.0.0git
|
This class contains all of the necessary data for a set of PDL patterns, or pattern rewrites specified in the form of the PDL dialect. More...
#include "mlir/IR/PatternMatch.h"
Public Member Functions | |
PDLPatternModule ()=default | |
PDLPatternModule (OwningOpRef< ModuleOp > module) | |
Construct a PDL pattern with the given module and configurations. More... | |
template<typename... ConfigsT> | |
PDLPatternModule (OwningOpRef< ModuleOp > module, ConfigsT &&...patternConfigs) | |
void | mergeIn (PDLPatternModule &&other) |
Merge the state in other into this pattern module. More... | |
ModuleOp | getModule () |
Return the internal PDL module of this pattern. More... | |
void | registerConstraintFunction (StringRef name, PDLConstraintFunction constraintFn) |
Register a constraint function with PDL. More... | |
template<typename ConstraintFnT > | |
void | registerConstraintFunction (StringRef name, ConstraintFnT &&constraintFn) |
void | registerRewriteFunction (StringRef name, PDLRewriteFunction rewriteFn) |
Register a rewrite function with PDL. More... | |
template<typename RewriteFnT > | |
void | registerRewriteFunction (StringRef name, RewriteFnT &&rewriteFn) |
const llvm::StringMap< PDLConstraintFunction > & | getConstraintFunctions () const |
Return the set of the registered constraint functions. More... | |
llvm::StringMap< PDLConstraintFunction > | takeConstraintFunctions () |
const llvm::StringMap< PDLRewriteFunction > & | getRewriteFunctions () const |
Return the set of the registered rewrite functions. More... | |
llvm::StringMap< PDLRewriteFunction > | takeRewriteFunctions () |
SmallVector< std::unique_ptr< PDLPatternConfigSet > > | takeConfigs () |
Return the set of the registered pattern configs. More... | |
DenseMap< Operation *, PDLPatternConfigSet * > | takeConfigMap () |
void | clear () |
Clear out the patterns and functions within this module. More... | |
This class contains all of the necessary data for a set of PDL patterns, or pattern rewrites specified in the form of the PDL dialect.
This PDL module contained by this pattern may contain any number of pdl.pattern
operations.
Definition at line 1427 of file PatternMatch.h.
|
default |
|
inline |
Construct a PDL pattern with the given module and configurations.
Definition at line 1432 of file PatternMatch.h.
|
inline |
Definition at line 1435 of file PatternMatch.h.
|
inline |
Clear out the patterns and functions within this module.
Definition at line 1536 of file PatternMatch.h.
Referenced by mlir::RewritePatternSet::clear().
|
inline |
Return the set of the registered constraint functions.
Definition at line 1513 of file PatternMatch.h.
|
inline |
Return the internal PDL module of this pattern.
Definition at line 1447 of file PatternMatch.h.
References mlir::OwningOpRef< OpTy >::get().
Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().
|
inline |
Return the set of the registered rewrite functions.
Definition at line 1520 of file PatternMatch.h.
void PDLPatternModule::mergeIn | ( | PDLPatternModule && | other | ) |
Merge the state in other
into this pattern module.
Definition at line 156 of file PatternMatch.cpp.
References registerConstraintFunction(), and registerRewriteFunction().
Referenced by mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::insert().
|
inline |
Definition at line 1474 of file PatternMatch.h.
References mlir::detail::pdl_function_builder::buildConstraintFn(), and registerConstraintFunction().
void PDLPatternModule::registerConstraintFunction | ( | StringRef | name, |
PDLConstraintFunction | constraintFn | ||
) |
Register a constraint function with PDL.
A constraint function may be specified in one of two ways:
LogicalResult (PatternRewriter &, ArrayRef<PDLValue>)
In this overload the arguments of the constraint function are passed via the low-level PDLValue form.
LogicalResult (PatternRewriter &, ValueTs... values)
In this form the arguments of the constraint function are passed via the expected high level C++ type. In this form, the framework will automatically unwrap PDLValues and convert them to the expected ValueTs. For example, if the constraint function accepts a Operation *
, the framework will automatically cast the input PDLValue. In the case of a StringRef
, the framework will automatically unwrap the argument as a StringAttr and pass the underlying string value. To see the full list of supported types, or to see how to add handling for custom types, view the definition of ProcessPDLValue
above.
Definition at line 198 of file PatternMatch.cpp.
Referenced by mergeIn(), and registerConstraintFunction().
void PDLPatternModule::registerRewriteFunction | ( | StringRef | name, |
PDLRewriteFunction | rewriteFn | ||
) |
Register a rewrite function with PDL.
A rewrite function may be specified in one of two ways:
void (PatternRewriter &, PDLResultList &, ArrayRef<PDLValue>)
In this overload the arguments of the constraint function are passed via the low-level PDLValue form, and the results are manually appended to the given result list.
ResultT (PatternRewriter &, ValueTs... values)
In this form the arguments and result of the rewrite function are passed via the expected high level C++ type. In this form, the framework will automatically unwrap the PDLValues arguments and convert them to the expected ValueTs. It will also automatically handle the processing and packaging of the result value to the result list. For example, if the rewrite function takes a Operation *
, the framework will automatically cast the input PDLValue. In the case of a StringRef
, the framework will automatically unwrap the argument as a StringAttr and pass the underlying string value. In the reverse case, if the rewrite returns a StringRef or std::string, it will automatically package this as a StringAttr and append it to the result list. To see the full list of supported types, or to see how to add handling for custom types, view the definition of ProcessPDLValue
above.
Definition at line 207 of file PatternMatch.cpp.
Referenced by mergeIn(), mlir::registerConversionPDLFunctions(), and registerRewriteFunction().
|
inline |
Definition at line 1507 of file PatternMatch.h.
References mlir::detail::pdl_function_builder::buildRewriteFn(), and registerRewriteFunction().
|
inline |
Definition at line 1531 of file PatternMatch.h.
Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().
|
inline |
Return the set of the registered pattern configs.
Definition at line 1528 of file PatternMatch.h.
Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().
|
inline |
Definition at line 1516 of file PatternMatch.h.
Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().
|
inline |
Definition at line 1523 of file PatternMatch.h.
Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().