MLIR  16.0.0git
Classes | Public Member Functions | List of all members
mlir::detail::PDLByteCode Class Reference

The bytecode class is also the interpreter. More...

#include "Rewrite/ByteCode.h"

Classes

struct  MatchResult
 Each successful match returns a MatchResult, which contains information necessary to execute the rewriter and indicates the originating pattern. More...
 

Public Member Functions

 PDLByteCode (ModuleOp module, llvm::StringMap< PDLConstraintFunction > constraintFns, llvm::StringMap< PDLRewriteFunction > rewriteFns)
 Create a ByteCode instance from the given module containing operations in the PDL interpreter dialect. More...
 
ArrayRef< PDLByteCodePatterngetPatterns () const
 Return the patterns held by the bytecode. More...
 
void initializeMutableState (PDLByteCodeMutableState &state) const
 Initialize the given state such that it can be used to execute the current bytecode. More...
 
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. More...
 
void rewrite (PatternRewriter &rewriter, const MatchResult &match, PDLByteCodeMutableState &state) const
 Run the rewriter of the given pattern that was previously matched in match. More...
 

Detailed Description

The bytecode class is also the interpreter.

Contains the bytecode itself, the static info, addresses of the rewriter functions, the interpreter memory buffer, and the execution context.

Definition at line 120 of file ByteCode.h.

Constructor & Destructor Documentation

◆ PDLByteCode()

PDLByteCode::PDLByteCode ( ModuleOp  module,
llvm::StringMap< PDLConstraintFunction constraintFns,
llvm::StringMap< PDLRewriteFunction rewriteFns 
)

Create a ByteCode instance from the given module containing operations in the PDL interpreter dialect.

Definition at line 1017 of file ByteCode.cpp.

References generator.

Member Function Documentation

◆ getPatterns()

ArrayRef<PDLByteCodePattern> mlir::detail::PDLByteCode::getPatterns ( ) const
inline

Return the patterns held by the bytecode.

Definition at line 155 of file ByteCode.h.

References rewrite().

◆ initializeMutableState()

void PDLByteCode::initializeMutableState ( PDLByteCodeMutableState state) const

◆ match()

void PDLByteCode::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.

Definition at line 2171 of file ByteCode.cpp.

Referenced by mlir::PatternApplicator::matchAndRewrite().

◆ rewrite()

void PDLByteCode::rewrite ( PatternRewriter rewriter,
const MatchResult match,
PDLByteCodeMutableState state 
) const

Run the rewriter of the given pattern that was previously matched in match.

Run the rewriter of the given pattern on the root operation op.

Definition at line 2194 of file ByteCode.cpp.

References copy(), mlir::detail::PDLByteCodePattern::getRewriterAddr(), mlir::detail::PDLByteCode::MatchResult::location, mlir::detail::PDLByteCode::MatchResult::pattern, and mlir::detail::PDLByteCode::MatchResult::values.

Referenced by mlir::PatternApplicator::matchAndRewrite().


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