MLIR  16.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 > pdlModule)
 Construct a PDL pattern with the given module. More...
 
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 ()
 
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 1253 of file PatternMatch.h.

Constructor & Destructor Documentation

◆ PDLPatternModule() [1/2]

mlir::PDLPatternModule::PDLPatternModule ( )
default

◆ PDLPatternModule() [2/2]

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

Construct a PDL pattern with the given module.

Definition at line 1258 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 1346 of file PatternMatch.h.

◆ getConstraintFunctions()

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

Return the set of the registered constraint functions.

Definition at line 1331 of file PatternMatch.h.

◆ getModule()

ModuleOp mlir::PDLPatternModule::getModule ( )
inline

Return the internal PDL module of this pattern.

Definition at line 1265 of file PatternMatch.h.

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

◆ mergeIn()

void PDLPatternModule::mergeIn ( PDLPatternModule &&  other)

Merge the state in other into this pattern module.

Definition at line 156 of file PatternMatch.cpp.

References mlir::Block::end(), and mlir::Block::getOperations().

◆ registerConstraintFunction() [1/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 182 of file PatternMatch.cpp.

◆ registerConstraintFunction() [2/2]

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

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

◆ registerRewriteFunction() [2/2]

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

◆ 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: