MLIR  18.0.0git
Public Member Functions | List of all members
mlir::PDLPatternModule Class Reference

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< PDLConstraintFunctiontakeConstraintFunctions ()
 
const llvm::StringMap< PDLRewriteFunction > & getRewriteFunctions () const
 Return the set of the registered rewrite functions. More...
 
llvm::StringMap< PDLRewriteFunctiontakeRewriteFunctions ()
 
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...
 

Detailed Description

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 1533 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ PDLPatternModule() [1/3]

mlir::PDLPatternModule::PDLPatternModule ( )
default

◆ PDLPatternModule() [2/3]

mlir::PDLPatternModule::PDLPatternModule ( OwningOpRef< ModuleOp >  module)
inline

Construct a PDL pattern with the given module and configurations.

Definition at line 1538 of file PatternMatch.h.

◆ PDLPatternModule() [3/3]

template<typename... ConfigsT>
mlir::PDLPatternModule::PDLPatternModule ( OwningOpRef< ModuleOp >  module,
ConfigsT &&...  patternConfigs 
)
inline

Definition at line 1541 of file PatternMatch.h.

Member Function Documentation

◆ clear()

void mlir::PDLPatternModule::clear ( )
inline

Clear out the patterns and functions within this module.

Definition at line 1642 of file PatternMatch.h.

Referenced by mlir::RewritePatternSet::clear().

◆ getConstraintFunctions()

const llvm::StringMap<PDLConstraintFunction>& mlir::PDLPatternModule::getConstraintFunctions ( ) const
inline

Return the set of the registered constraint functions.

Definition at line 1619 of file PatternMatch.h.

◆ getModule()

ModuleOp mlir::PDLPatternModule::getModule ( )
inline

Return the internal PDL module of this pattern.

Definition at line 1553 of file PatternMatch.h.

References mlir::OwningOpRef< OpTy >::get().

Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().

◆ getRewriteFunctions()

const llvm::StringMap<PDLRewriteFunction>& mlir::PDLPatternModule::getRewriteFunctions ( ) const
inline

Return the set of the registered rewrite functions.

Definition at line 1626 of file PatternMatch.h.

◆ mergeIn()

void PDLPatternModule::mergeIn ( PDLPatternModule &&  other)

Merge the state in other into this pattern module.

Definition at line 158 of file PatternMatch.cpp.

References registerConstraintFunction(), and registerRewriteFunction().

Referenced by mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::insert().

◆ registerConstraintFunction() [1/2]

template<typename ConstraintFnT >
void mlir::PDLPatternModule::registerConstraintFunction ( StringRef  name,
ConstraintFnT &&  constraintFn 
)
inline

◆ registerConstraintFunction() [2/2]

void PDLPatternModule::registerConstraintFunction ( StringRef  name,
PDLConstraintFunction  constraintFn 
)

Register a constraint function with PDL.

A constraint function may be specified in one of two ways:

In this overload the arguments of the constraint function are passed via the low-level PDLValue form.

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 200 of file PatternMatch.cpp.

Referenced by mergeIn(), mlir::transform::PDLMatchHooks::mergeInPDLMatchHooks(), and registerConstraintFunction().

◆ registerRewriteFunction() [1/2]

void PDLPatternModule::registerRewriteFunction ( StringRef  name,
PDLRewriteFunction  rewriteFn 
)

Register a rewrite function with PDL.

A rewrite function may be specified in one of two ways:

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.

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 209 of file PatternMatch.cpp.

Referenced by mergeIn(), mlir::registerConversionPDLFunctions(), and registerRewriteFunction().

◆ registerRewriteFunction() [2/2]

template<typename RewriteFnT >
void mlir::PDLPatternModule::registerRewriteFunction ( StringRef  name,
RewriteFnT &&  rewriteFn 
)
inline

◆ takeConfigMap()

DenseMap<Operation *, PDLPatternConfigSet *> mlir::PDLPatternModule::takeConfigMap ( )
inline

◆ takeConfigs()

SmallVector<std::unique_ptr<PDLPatternConfigSet> > mlir::PDLPatternModule::takeConfigs ( )
inline

Return the set of the registered pattern configs.

Definition at line 1634 of file PatternMatch.h.

Referenced by mlir::FrozenRewritePatternSet::FrozenRewritePatternSet().

◆ takeConstraintFunctions()

llvm::StringMap<PDLConstraintFunction> mlir::PDLPatternModule::takeConstraintFunctions ( )
inline

◆ takeRewriteFunctions()

llvm::StringMap<PDLRewriteFunction> mlir::PDLPatternModule::takeRewriteFunctions ( )
inline

The documentation for this class was generated from the following files: