MLIR 22.0.0git
mlir::OperationPass< OpT > Class Template Reference

Pass to transform an operation of a specific type. More...

#include "mlir/Pass/Pass.h"

Inherits mlir::Pass.

Inherited by mlir::InterfacePass< mlir::FunctionOpInterface >, mlir::InterfacePass< FunctionOpInterface >, mlir::LLVM::impl::LLVMTargetToDataLayoutBase< TargetToDataLayoutPass >, mlir::LLVM::impl::LLVMTargetToTargetFeaturesBase< TargetToTargetFeaturesPass >, mlir::PassWrapper< OpToOpPassAdaptor, OperationPass<> >, mlir::amdgpu::impl::AmdgpuFoldMemRefOpsPassBase< AmdgpuFoldMemRefOpsPass >, mlir::amdgpu::impl::AmdgpuMaskedloadToLoadPassBase< AmdgpuMaskedloadToLoadPass >, mlir::InterfacePass< InterfaceT >, mlir::LLVM::impl::LLVMLegalizeForExportPassBase< DerivedT >, mlir::LLVM::impl::LLVMTargetToDataLayoutBase< DerivedT >, mlir::LLVM::impl::LLVMTargetToTargetFeaturesBase< DerivedT >, mlir::LLVM::impl::NVVMOptimizeForTargetPassBase< DerivedT >, mlir::affine::impl::AffineExpandIndexOpsAsAffineBase< DerivedT >, mlir::affine::impl::AffineExpandIndexOpsBase< DerivedT >, mlir::affine::impl::AffineLoopFusionBase< DerivedT >, mlir::amdgpu::impl::AmdgpuEmulateAtomicsPassBase< DerivedT >, mlir::amdgpu::impl::AmdgpuFoldMemRefOpsPassBase< DerivedT >, mlir::amdgpu::impl::AmdgpuMaskedloadToLoadPassBase< DerivedT >, mlir::amdgpu::impl::AmdgpuResolveStridedMetadataPassBase< DerivedT >, mlir::arith::impl::ArithEmulateUnsupportedFloatsBase< DerivedT >, mlir::arith::impl::ArithEmulateWideIntBase< DerivedT >, mlir::arith::impl::ArithExpandOpsPassBase< DerivedT >, mlir::arith::impl::ArithIntRangeNarrowingBase< DerivedT >, mlir::arith::impl::ArithIntRangeOptsBase< DerivedT >, mlir::arith::impl::ArithUnsignedWhenEquivalentPassBase< DerivedT >, mlir::bufferization::impl::BufferDeallocationSimplificationPassBase< DerivedT >, mlir::bufferization::impl::EmptyTensorEliminationPassBase< DerivedT >, mlir::bufferization::impl::EmptyTensorToAllocTensorPassBase< DerivedT >, mlir::bufferization::impl::LowerDeallocationsPassBase< DerivedT >, mlir::bufferization::impl::OwnershipBasedBufferDeallocationPassBase< DerivedT >, mlir::emitc::impl::FormExpressionsPassBase< DerivedT >, mlir::emitc::impl::WrapFuncInClassPassBase< DerivedT >, mlir::impl::ArithToAMDGPUConversionPassBase< DerivedT >, mlir::impl::ArithToArmSMEConversionPassBase< DerivedT >, mlir::impl::ArithToLLVMConversionPassBase< DerivedT >, mlir::impl::AsyncRuntimePolicyBasedRefCountingPassBase< DerivedT >, mlir::impl::AsyncRuntimeRefCountingOptPassBase< DerivedT >, mlir::impl::AsyncRuntimeRefCountingPassBase< DerivedT >, mlir::impl::BubbleDownMemorySpaceCastsBase< DerivedT >, mlir::impl::CSEBase< DerivedT >, mlir::impl::CanonicalizerBase< DerivedT >, mlir::impl::CompositeFixedPointPassBase< DerivedT >, mlir::impl::ControlFlowSinkBase< DerivedT >, mlir::impl::ConvertAMDGPUToROCDLPassBase< DerivedT >, mlir::impl::ConvertArithToEmitCBase< DerivedT >, mlir::impl::ConvertArithToSPIRVPassBase< DerivedT >, mlir::impl::ConvertArmNeon2dToIntrPassBase< DerivedT >, mlir::impl::ConvertArmSMEToSCFPassBase< DerivedT >, mlir::impl::ConvertBufferizationToMemRefPassBase< DerivedT >, mlir::impl::ConvertComplexToLLVMPassBase< DerivedT >, mlir::impl::ConvertComplexToSPIRVPassBase< DerivedT >, mlir::impl::ConvertComplexToStandardPassBase< DerivedT >, mlir::impl::ConvertControlFlowToSPIRVPassBase< DerivedT >, mlir::impl::ConvertElementwiseToLinalgPassBase< DerivedT >, mlir::impl::ConvertFuncToSPIRVPassBase< DerivedT >, mlir::impl::ConvertIndexToLLVMPassBase< DerivedT >, mlir::impl::ConvertIndexToSPIRVPassBase< DerivedT >, mlir::impl::ConvertLinalgToAffineLoopsPassBase< DerivedT >, mlir::impl::ConvertLinalgToLoopsPassBase< DerivedT >, mlir::impl::ConvertLinalgToParallelLoopsPassBase< DerivedT >, mlir::impl::ConvertMathToEmitCBase< DerivedT >, mlir::impl::ConvertMathToLLVMPassBase< DerivedT >, mlir::impl::ConvertMathToSPIRVPassBase< DerivedT >, mlir::impl::ConvertMathToXeVMBase< DerivedT >, mlir::impl::ConvertMemRefToSPIRVPassBase< DerivedT >, mlir::impl::ConvertNVGPUToNVVMPassBase< DerivedT >, mlir::impl::ConvertNVVMToLLVMPassBase< DerivedT >, mlir::impl::ConvertParallelLoopToGpuPassBase< DerivedT >, mlir::impl::ConvertShapeConstraintsPassBase< DerivedT >, mlir::impl::ConvertShardToMPIPassBase< DerivedT >, mlir::impl::ConvertTensorToSPIRVPassBase< DerivedT >, mlir::impl::ConvertToEmitCBase< DerivedT >, mlir::impl::ConvertToLLVMPassBase< DerivedT >, mlir::impl::ConvertVectorToAMXBase< DerivedT >, mlir::impl::ConvertVectorToArmSMEPassBase< DerivedT >, mlir::impl::ConvertVectorToGPUBase< DerivedT >, mlir::impl::ConvertVectorToLLVMPassBase< DerivedT >, mlir::impl::ConvertVectorToSCFBase< DerivedT >, mlir::impl::ConvertVectorToSPIRVPassBase< DerivedT >, mlir::impl::ConvertVectorToXeGPUBase< DerivedT >, mlir::impl::ConvertXeGPUToXeVMPassBase< DerivedT >, mlir::impl::ConvertXeVMToLLVMPassBase< DerivedT >, mlir::impl::GenerateRuntimeVerificationBase< DerivedT >, mlir::impl::GpuDecomposeMemrefsPassBase< DerivedT >, mlir::impl::GpuLaunchSinkIndexComputationsPassBase< DerivedT >, mlir::impl::GpuModuleToBinaryPassBase< DerivedT >, mlir::impl::GpuNVVMAttachTargetBase< DerivedT >, mlir::impl::GpuROCDLAttachTargetBase< DerivedT >, mlir::impl::GpuSPIRVAttachTargetBase< DerivedT >, mlir::impl::GpuXeVMAttachTargetBase< DerivedT >, mlir::impl::InlinerBase< DerivedT >, mlir::impl::LiftControlFlowToSCFPassBase< DerivedT >, mlir::impl::LinalgBlockPackMatmulBase< DerivedT >, mlir::impl::LinalgElementwiseOpFusionPassBase< DerivedT >, mlir::impl::LinalgFoldIntoElementwisePassBase< DerivedT >, mlir::impl::LinalgFoldUnitExtentDimsPassBase< DerivedT >, mlir::impl::LinalgGeneralizeNamedOpsPassBase< DerivedT >, mlir::impl::LinalgInlineScalarOperandsPassBase< DerivedT >, mlir::impl::LinalgMorphOpsPassBase< DerivedT >, mlir::impl::LinalgSpecializeGenericOpsPassBase< DerivedT >, mlir::impl::LocationSnapshotBase< DerivedT >, mlir::impl::LoopInvariantCodeMotionBase< DerivedT >, mlir::impl::LoopInvariantSubsetHoistingBase< DerivedT >, mlir::impl::LowerAffinePassBase< DerivedT >, mlir::impl::MapMemRefStorageClassBase< DerivedT >, mlir::impl::Mem2RegBase< DerivedT >, mlir::impl::PrintOpStatsBase< DerivedT >, mlir::impl::ReconcileUnrealizedCastsPassBase< DerivedT >, mlir::impl::ReductionTreePassBase< DerivedT >, mlir::impl::RemoveDeadValuesBase< DerivedT >, mlir::impl::SCCPBase< DerivedT >, mlir::impl::SCFForLoopCanonicalizationBase< DerivedT >, mlir::impl::SCFForLoopPeelingBase< DerivedT >, mlir::impl::SCFForLoopRangeFoldingBase< DerivedT >, mlir::impl::SCFForLoopSpecializationBase< DerivedT >, mlir::impl::SCFForToWhileLoopBase< DerivedT >, mlir::impl::SCFForallToForLoopBase< DerivedT >, mlir::impl::SCFForallToParallelLoopBase< DerivedT >, mlir::impl::SCFParallelForToNestedForsBase< DerivedT >, mlir::impl::SCFParallelLoopFusionBase< DerivedT >, mlir::impl::SCFParallelLoopSpecializationBase< DerivedT >, mlir::impl::SCFParallelLoopTilingBase< DerivedT >, mlir::impl::SCFToControlFlowPassBase< DerivedT >, mlir::impl::SCFToEmitCBase< DerivedT >, mlir::impl::SCFToSPIRVBase< DerivedT >, mlir::impl::SROABase< DerivedT >, mlir::impl::SimplifyDepthwiseConvPassBase< DerivedT >, mlir::impl::StripDebugInfoBase< DerivedT >, mlir::impl::SymbolDCEBase< DerivedT >, mlir::impl::SymbolPrivatizeBase< DerivedT >, mlir::impl::TestSCFParallelLoopCollapsingBase< DerivedT >, mlir::impl::TopologicalSortBase< DerivedT >, mlir::impl::TosaToArithPassBase< DerivedT >, mlir::impl::TosaToSCFPassBase< DerivedT >, mlir::impl::TosaToTensorPassBase< DerivedT >, mlir::impl::UBToLLVMConversionPassBase< DerivedT >, mlir::impl::UBToSPIRVConversionPassBase< DerivedT >, mlir::impl::ViewOpGraphBase< DerivedT >, mlir::math::impl::MathExpandOpsPassBase< DerivedT >, mlir::math::impl::MathExtendToSupportedTypesBase< DerivedT >, mlir::math::impl::MathSincosFusionPassBase< DerivedT >, mlir::math::impl::MathUpliftToFMABase< DerivedT >, mlir::memref::impl::ExpandOpsPassBase< DerivedT >, mlir::memref::impl::ExpandReallocPassBase< DerivedT >, mlir::memref::impl::ExpandStridedMetadataPassBase< DerivedT >, mlir::memref::impl::FlattenMemrefsPassBase< DerivedT >, mlir::memref::impl::FoldMemRefAliasOpsPassBase< DerivedT >, mlir::memref::impl::MemRefEmulateWideIntBase< DerivedT >, mlir::memref::impl::ReifyResultShapesPassBase< DerivedT >, mlir::memref::impl::ResolveRankedShapeTypeResultDimsPassBase< DerivedT >, mlir::memref::impl::ResolveShapedTypeResultDimsPassBase< DerivedT >, mlir::nvgpu::impl::OptimizeSharedMemoryBase< DerivedT >, mlir::quant::impl::StripFuncQuantTypesBase< DerivedT >, mlir::spirv::impl::SPIRVCanonicalizeGLPassBase< DerivedT >, mlir::tensor::impl::FoldTensorSubsetOpsPassBase< DerivedT >, mlir::transform::impl::CheckUsesPassBase< DerivedT >, mlir::transform::impl::InferEffectsPassBase< DerivedT >, mlir::transform::impl::InterpreterPassBase< DerivedT >, mlir::transform::impl::PreloadLibraryPassBase< DerivedT >, mlir::xegpu::impl::XeGPUBlockingBase< DerivedT >, mlir::xegpu::impl::XeGPUFoldAliasOpsBase< DerivedT >, mlir::xegpu::impl::XeGPUOptimizeBlockLoadsBase< DerivedT >, mlir::xegpu::impl::XeGPUPropagateLayoutBase< DerivedT >, mlir::xegpu::impl::XeGPUSubgroupDistributeBase< DerivedT >, mlir::xegpu::impl::XeGPUVectorLinearizeBase< DerivedT >, and mlir::xegpu::impl::XeGPUWgToSgDistributeBase< DerivedT >.

Public Member Functions

 ~OperationPass () override=default
Public Member Functions inherited from mlir::Pass
virtual ~Pass ()=default
TypeID getTypeID () const
 Returns the unique identifier that corresponds to this pass.
const PassInfolookupPassInfo () const
 Returns the pass info for this pass, or null if unknown.
virtual StringRef getName () const =0
 Returns the derived pass name.
virtual void getDependentDialects (DialectRegistry &registry) const
 Register dependent dialects for the current pass.
virtual StringRef getArgument () const
 Return the command line argument used when registering this pass.
virtual StringRef getDescription () const
 Return the command line description used when registering this pass.
std::optional< StringRef > getOpName () const
 Returns the name of the operation that this pass operates on, or std::nullopt if this is a generic OperationPass.
virtual LogicalResult initializeOptions (StringRef options, function_ref< LogicalResult(const Twine &)> errorHandler)
 Attempt to initialize the options of this pass from the given string.
void printAsTextualPipeline (raw_ostream &os, bool pretty=false)
 Prints out the pass in the textual representation of pipelines.
ArrayRef< Statistic * > getStatistics () const
 Returns the main statistics for this pass instance.
MutableArrayRef< Statistic * > getStatistics ()
const PassgetThreadingSibling () const
 Returns the thread sibling of this pass.
const PassgetThreadingSiblingOrThis () const
 Returns the thread sibling of this pass, or the pass itself it has no sibling.

Protected Member Functions

 OperationPass (TypeID passID)
 OperationPass (const OperationPass &)=default
OperationPassoperator= (const OperationPass &)=delete
 OperationPass (OperationPass &&)=delete
OperationPassoperator= (OperationPass &&)=delete
bool canScheduleOn (RegisteredOperationName opName) const final
 Indicate if the current pass can be scheduled on the given operation type.
OpT getOperation ()
 Return the current operation being transformed.
template<typename AnalysisT>
AnalysisT & getAnalysis ()
 Query an analysis for the current operation of the specific derived operation type.
Protected Member Functions inherited from mlir::Pass
 Pass (TypeID passID, std::optional< StringRef > opName=std::nullopt)
 Pass (const Pass &other)
Passoperator= (const Pass &)=delete
 Pass (Pass &&)=delete
Passoperator= (Pass &&)=delete
detail::PassExecutionStategetPassState ()
 Returns the current pass state.
MLIRContextgetContext ()
 Return the MLIR context for the current operation being transformed.
virtual void runOnOperation ()=0
 The polymorphic API that runs the pass over the currently held operation.
virtual LogicalResult initialize (MLIRContext *context)
 Initialize any complex state necessary for running this pass.
LogicalResult runPipeline (OpPassManager &pipeline, Operation *op)
 Schedule an arbitrary pass pipeline on the provided operation.
std::unique_ptr< Passclone () const
 A clone method to create a copy of this pass.
OperationgetOperation ()
 Return the current operation being transformed.
void signalPassFailure ()
 Signal that some invariant was broken when running.
template<typename AnalysisT>
AnalysisT & getAnalysis ()
 Query an analysis for the current ir unit.
template<typename AnalysisT, typename OpT>
AnalysisT & getAnalysis ()
 Query an analysis for the current ir unit of a specific derived operation type.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedAnalysis ()
 Query a cached instance of an analysis for the current ir unit if one exists.
void markAllAnalysesPreserved ()
 Mark all analyses as preserved.
template<typename... AnalysesT>
void markAnalysesPreserved ()
 Mark the provided analyses as preserved.
void markAnalysesPreserved (TypeID id)
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis (Operation *parent)
 Returns the analysis for the given parent operation if it exists.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis ()
 Returns the analysis for the parent operation if it exists.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedChildAnalysis (Operation *child)
 Returns the analysis for the given child operation if it exists.
template<typename AnalysisT>
AnalysisT & getChildAnalysis (Operation *child)
 Returns the analysis for the given child operation, or creates it if it doesn't exist.
template<typename AnalysisT, typename OpTy>
AnalysisT & getChildAnalysis (OpTy child)
 Returns the analysis for the given child operation of specific derived operation type, or creates it if it doesn't exist.
AnalysisManager getAnalysisManager ()
 Returns the current analysis manager.
virtual std::unique_ptr< PassclonePass () const =0
 Create a copy of this pass, ignoring statistics and options.
void copyOptionValuesFrom (const Pass *other)
 Copy the option values from 'other', which is another instance of this pass.

Static Protected Member Functions

static bool classof (const Pass *pass)
 Support isa/dyn_cast functionality.

Detailed Description

template<typename OpT = void>
class mlir::OperationPass< OpT >

Pass to transform an operation of a specific type.

Operation passes must not:

  • modify any other operations within the parent region, as other threads may be manipulating them concurrently.
  • modify any state within the parent operation, this includes adding additional operations.

Derived operation passes are expected to provide the following:

Definition at line 356 of file Pass.h.

Constructor & Destructor Documentation

◆ ~OperationPass()

template<typename OpT = void>
mlir::OperationPass< OpT >::~OperationPass ( )
overridedefault

◆ OperationPass() [1/3]

template<typename OpT = void>
mlir::OperationPass< OpT >::OperationPass ( TypeID passID)
inlineprotected

Definition at line 361 of file Pass.h.

References mlir::Pass::Pass().

Referenced by OperationPass(), OperationPass(), operator=(), and operator=().

◆ OperationPass() [2/3]

template<typename OpT = void>
mlir::OperationPass< OpT >::OperationPass ( const OperationPass< OpT > & )
protecteddefault

References OperationPass().

◆ OperationPass() [3/3]

template<typename OpT = void>
mlir::OperationPass< OpT >::OperationPass ( OperationPass< OpT > && )
protecteddelete

References OperationPass().

Member Function Documentation

◆ canScheduleOn()

template<typename OpT = void>
bool mlir::OperationPass< OpT >::canScheduleOn ( RegisteredOperationName opName) const
inlinefinalprotectedvirtual

Indicate if the current pass can be scheduled on the given operation type.

Implements mlir::Pass.

Definition at line 373 of file Pass.h.

References mlir::Pass::getOpName().

◆ classof()

template<typename OpT = void>
bool mlir::OperationPass< OpT >::classof ( const Pass * pass)
inlinestaticprotected

Support isa/dyn_cast functionality.

Definition at line 368 of file Pass.h.

References mlir::Pass::getOpName(), and mlir::Pass::Pass().

◆ getAnalysis()

template<typename OpT = void>
template<typename AnalysisT>
AnalysisT & mlir::OperationPass< OpT >::getAnalysis ( )
inlineprotected

Query an analysis for the current operation of the specific derived operation type.

Definition at line 383 of file Pass.h.

References mlir::Pass::getAnalysis().

Referenced by mlir::impl::AsyncRuntimePolicyBasedRefCountingPassBase< DerivedT >::getName().

◆ getOperation()

◆ operator=() [1/2]

template<typename OpT = void>
OperationPass & mlir::OperationPass< OpT >::operator= ( const OperationPass< OpT > & )
protecteddelete

References OperationPass().

◆ operator=() [2/2]

template<typename OpT = void>
OperationPass & mlir::OperationPass< OpT >::operator= ( OperationPass< OpT > && )
protecteddelete

References OperationPass().


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