Skip to content

[MLIR][NFC] Retire let constructor for passes in Conversion directory (part1) #127403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Support/InitFIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ inline void registerMLIRPassesForFortranTools() {
mlir::affine::registerAffineLoopTilingPass();
mlir::affine::registerAffineDataCopyGenerationPass();

mlir::registerConvertAffineToStandardPass();
mlir::registerLowerAffinePass();
}

/// Register the interfaces needed to lower to LLVM IR.
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Passes/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm,
pm, fir::createStackReclaim);
// convert control flow to CFG form
fir::addCfgConversionPass(pm, pc);
pm.addPass(mlir::createConvertSCFToCFPass());
pm.addPass(mlir::createSCFToControlFlowPass());

pm.addPass(mlir::createCanonicalizerPass(config));
pm.addPass(fir::createSimplifyRegionLite());
Expand Down
4 changes: 1 addition & 3 deletions mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LLVMTypeConverter;
class RewritePatternSet;
class Pass;

#define GEN_PASS_DECL_CONVERTAMDGPUTOROCDL
#define GEN_PASS_DECL_CONVERTAMDGPUTOROCDLPASS
#include "mlir/Conversion/Passes.h.inc"

/// Note: The ROCDL target does not support the LLVM bfloat type at this time
Expand All @@ -28,8 +28,6 @@ void populateAMDGPUToROCDLConversionPatterns(const LLVMTypeConverter &converter,
RewritePatternSet &patterns,
amdgpu::Chipset chipset);

std::unique_ptr<Pass> createConvertAMDGPUToROCDLPass();

} // namespace mlir

#endif // MLIR_CONVERSION_AMDGPUTOROCDL_AMDGPUTOROCDL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace affine {
class AffineForOp;
} // namespace affine

#define GEN_PASS_DECL_CONVERTAFFINETOSTANDARD
#define GEN_PASS_DECL_LOWERAFFINEPASS
#include "mlir/Conversion/Passes.h.inc"

/// Collect a set of patterns to convert from the Affine dialect to the Standard
Expand All @@ -44,11 +44,6 @@ Value lowerAffineLowerBound(affine::AffineForOp op, OpBuilder &builder);
/// standard arithmetic operations.
Value lowerAffineUpperBound(affine::AffineForOp op, OpBuilder &builder);

/// Lowers affine control flow operations (ForStmt, IfStmt and AffineApplyOp)
/// to equivalent lower-level constructs (flow of basic blocks and arithmetic
/// primitives).
std::unique_ptr<Pass> createLowerAffinePass();

} // namespace mlir

#endif // MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H
2 changes: 1 addition & 1 deletion mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SPIRVTypeConverter;
class RewritePatternSet;
class Pass;

#define GEN_PASS_DECL_CONVERTARITHTOSPIRV
#define GEN_PASS_DECL_CONVERTARITHTOSPIRVPASS
#include "mlir/Conversion/Passes.h.inc"

namespace arith {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ namespace mlir {
class Pass;
class RewritePatternSet;

#define GEN_PASS_DECL_CONVERTARMNEON2DTOINTR
#define GEN_PASS_DECL_CONVERTARMNEON2DTOINTRPASS
#include "mlir/Conversion/Passes.h.inc"

/// Populates patterns for the lowering of Arm NEON 2D ops to intrinsics.
/// See createConvertArmNeon2dToIntrPass.
void populateConvertArmNeon2dToIntrPatterns(RewritePatternSet &patterns);

/// Creates a pass to lower Arm NEON 2D ops to intrinsics, i.e.
/// equivalent ops operating on flattened 1D vectors and mapping more
/// directly to the corresponding Arm NEON instruction.
std::unique_ptr<Pass> createConvertArmNeon2dToIntrPass();

} // namespace mlir

#endif // MLIR_CONVERSION_ARMNEON2DTOINTR_ARMNEON2DTOINTR_H_
5 changes: 1 addition & 4 deletions mlir/include/mlir/Conversion/ArmSMEToSCF/ArmSMEToSCF.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ namespace mlir {
class Pass;
class RewritePatternSet;

#define GEN_PASS_DECL_CONVERTARMSMETOSCF
#define GEN_PASS_DECL_CONVERTARMSMETOSCFPASS
#include "mlir/Conversion/Passes.h.inc"

/// Collect a set of patterns to convert from the ArmSME dialect to SCF.
void populateArmSMEToSCFConversionPatterns(RewritePatternSet &patterns);

/// Create a pass to convert a subset of ArmSME ops to SCF.
std::unique_ptr<Pass> createConvertArmSMEToSCFPass();

} // namespace mlir

#endif // MLIR_CONVERSION_ARMSMETOSCF_ARMSMETOSCF_H_
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
namespace mlir {
class ModuleOp;

#define GEN_PASS_DECL_CONVERTBUFFERIZATIONTOMEMREF
#define GEN_PASS_DECL_CONVERTBUFFERIZATIONTOMEMREFPASS
#include "mlir/Conversion/Passes.h.inc"

std::unique_ptr<Pass> createBufferizationToMemRefPass();
} // namespace mlir

#endif // MLIR_CONVERSION_BUFFERIZATIONTOMEMREF_BUFFERIZATIONTOMEMREF_H
4 changes: 1 addition & 3 deletions mlir/include/mlir/Conversion/ComplexToLibm/ComplexToLibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef MLIR_CONVERSION_COMPLEXTOLIBM_COMPLEXTOLIBM_H_
#define MLIR_CONVERSION_COMPLEXTOLIBM_COMPLEXTOLIBM_H_

#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

namespace mlir {
Expand All @@ -22,9 +23,6 @@ class OperationPass;
void populateComplexToLibmConversionPatterns(RewritePatternSet &patterns,
PatternBenefit benefit);

/// Create a pass to convert Complex operations to libm calls.
std::unique_ptr<OperationPass<ModuleOp>> createConvertComplexToLibmPass();

} // namespace mlir

#endif // MLIR_CONVERSION_COMPLEXTOLIBM_COMPLEXTOLIBM_H_
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace mlir {
class RewritePatternSet;
class Pass;

#define GEN_PASS_DECL_CONVERTCOMPLEXTOSTANDARD
#define GEN_PASS_DECL_CONVERTCOMPLEXTOSTANDARDPASS
#include "mlir/Conversion/Passes.h.inc"

/// Populate the given list with patterns that convert from Complex to Standard.
Expand All @@ -25,11 +25,6 @@ void populateComplexToStandardConversionPatterns(
mlir::complex::ComplexRangeFlags complexRange =
mlir::complex::ComplexRangeFlags::improved);

/// Create a pass to convert Complex operations to the Standard dialect.
std::unique_ptr<Pass> createConvertComplexToStandardPass();
std::unique_ptr<Pass>
createConvertComplexToStandardPass(ConvertComplexToStandardOptions options);

} // namespace mlir

#endif // MLIR_CONVERSION_COMPLEXTOSTANDARD_COMPLEXTOSTANDARD_H_
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
namespace mlir {
class ModuleOp;

#define GEN_PASS_DECL_CONVERTCONTROLFLOWTOSPIRV
#define GEN_PASS_DECL_CONVERTCONTROLFLOWTOSPIRVPASS
#include "mlir/Conversion/Passes.h.inc"

/// Creates a pass to convert ControlFlow ops to SPIR-V ops.
std::unique_ptr<OperationPass<>> createConvertControlFlowToSPIRVPass();

} // namespace mlir

#endif // MLIR_CONVERSION_CONTROLFLOWTOSPIRV_CONTROLFLOWTOSPIRVPASS_H
8 changes: 2 additions & 6 deletions mlir/include/mlir/Conversion/ConvertToLLVM/ToLLVMPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@

#include "mlir/Pass/Pass.h"

#define GEN_PASS_DECL_CONVERTTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"

namespace mlir {

/// Create a pass that performs dialect conversion to LLVM for all dialects
/// implementing `ConvertToLLVMPatternInterface`.
std::unique_ptr<Pass> createConvertToLLVMPass();
#define GEN_PASS_DECL_CONVERTTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"

/// Register the extension that will load dependent dialects for LLVM
/// conversion. This is useful to implement a pass similar to "convert-to-llvm".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
namespace mlir {
class ModuleOp;

#define GEN_PASS_DECL_CONVERTFUNCTOSPIRV
#define GEN_PASS_DECL_CONVERTFUNCTOSPIRVPASS
#include "mlir/Conversion/Passes.h.inc"

/// Creates a pass to convert Func ops to SPIR-V ops.
std::unique_ptr<OperationPass<>> createConvertFuncToSPIRVPass();

} // namespace mlir

#endif // MLIR_CONVERSION_FUNCTOSPIRV_FUNCTOSPIRVPASS_H
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#define MLIR_CONVERSION_LINALGTOSTANDARD_LINALGTOSTANDARD_H_

#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

namespace mlir {
class ModuleOp;
template <typename T>
class OperationPass;

#define GEN_PASS_DECL_CONVERTLINALGTOSTANDARD
#define GEN_PASS_DECL_CONVERTLINALGTOSTANDARDPASS
#include "mlir/Conversion/Passes.h.inc"

namespace linalg {
Expand Down Expand Up @@ -46,10 +47,6 @@ class LinalgOpToLibraryCallRewrite
void populateLinalgToStandardConversionPatterns(RewritePatternSet &patterns);

} // namespace linalg

/// Create a pass to convert Linalg operations to the Standard dialect.
std::unique_ptr<OperationPass<ModuleOp>> createConvertLinalgToStandardPass();

} // namespace mlir

#endif // MLIR_CONVERSION_LINALGTOSTANDARD_LINALGTOSTANDARD_H_
6 changes: 2 additions & 4 deletions mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@
#define MLIR_CONVERSION_MATHTOLIBM_MATHTOLIBM_H_

#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"

namespace mlir {
template <typename T>
class OperationPass;

#define GEN_PASS_DECL_CONVERTMATHTOLIBM
#define GEN_PASS_DECL_CONVERTMATHTOLIBMPASS
#include "mlir/Conversion/Passes.h.inc"

/// Populate the given list with patterns that convert from Math to Libm calls.
/// If log1pBenefit is present, use it instead of benefit for the Log1p op.
void populateMathToLibmConversionPatterns(RewritePatternSet &patterns,
PatternBenefit benefit = 1);

/// Create a pass to convert Math operations to libm calls.
std::unique_ptr<OperationPass<ModuleOp>> createConvertMathToLibmPass();

} // namespace mlir

#endif // MLIR_CONVERSION_MATHTOLIBM_MATHTOLIBM_H_
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
namespace mlir {
class ModuleOp;

#define GEN_PASS_DECL_CONVERTMATHTOSPIRV
#define GEN_PASS_DECL_CONVERTMATHTOSPIRVPASS
#include "mlir/Conversion/Passes.h.inc"

/// Creates a pass to convert Math ops to SPIR-V ops.
std::unique_ptr<OperationPass<>> createConvertMathToSPIRVPass();

} // namespace mlir

#endif // MLIR_CONVERSION_MATHTOSPIRV_MATHTOSPIRVPASS_H
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ namespace mlir {
class ModuleOp;

#define GEN_PASS_DECL_MAPMEMREFSTORAGECLASS
#define GEN_PASS_DECL_CONVERTMEMREFTOSPIRV
#define GEN_PASS_DECL_CONVERTMEMREFTOSPIRVPASS
#include "mlir/Conversion/Passes.h.inc"

/// Creates a pass to map numeric MemRef memory spaces to symbolic SPIR-V
/// storage classes. The mapping is read from the command-line option.
std::unique_ptr<OperationPass<>> createMapMemRefStorageClassPass();

/// Creates a pass to convert MemRef ops to SPIR-V ops.
std::unique_ptr<OperationPass<>> createConvertMemRefToSPIRVPass();

} // namespace mlir

#endif // MLIR_CONVERSION_MEMREFTOSPIRV_MEMREFTOSPIRVPASS_H
4 changes: 0 additions & 4 deletions mlir/include/mlir/Conversion/MeshToMPI/MeshToMPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class Pass;
#define GEN_PASS_DECL_CONVERTMESHTOMPIPASS
#include "mlir/Conversion/Passes.h.inc"

/// Lowers Mesh communication operations (updateHalo, AllGater, ...)
/// to MPI primitives.
std::unique_ptr<::mlir::Pass> createConvertMeshToMPIPass();

} // namespace mlir

#endif // MLIR_CONVERSION_MESHTOMPI_MESHTOMPI_H
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef MLIR_CONVERSION_OPENACCTOSCF_CONVERTOPENACCTOSCF_H
#define MLIR_CONVERSION_OPENACCTOSCF_CONVERTOPENACCTOSCF_H

#include "mlir/Pass/Pass.h"
#include <memory>

namespace mlir {
Expand All @@ -16,16 +17,13 @@ template <typename T>
class OperationPass;
class RewritePatternSet;

#define GEN_PASS_DECL_CONVERTOPENACCTOSCF
#define GEN_PASS_DECL_CONVERTOPENACCTOSCFPASS
#include "mlir/Conversion/Passes.h.inc"

/// Collect the patterns to convert from the OpenACC dialect to OpenACC with
/// SCF dialect.
void populateOpenACCToSCFConversionPatterns(RewritePatternSet &patterns);

/// Create a pass to convert the OpenACC dialect into the LLVMIR dialect.
std::unique_ptr<OperationPass<ModuleOp>> createConvertOpenACCToSCFPass();

} // namespace mlir

#endif // MLIR_CONVERSION_OPENACCTOSCF_CONVERTOPENACCTOSCF_H
8 changes: 3 additions & 5 deletions mlir/include/mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef MLIR_CONVERSION_PDLTOPDLINTERP_PDLTOPDLINTERP_H
#define MLIR_CONVERSION_PDLTOPDLINTERP_PDLTOPDLINTERP_H

#include "mlir/Pass/Pass.h"
#include "mlir/Support/LLVM.h"

namespace mlir {
Expand All @@ -22,16 +23,13 @@ template <typename OpT>
class OperationPass;
class PDLPatternConfigSet;

#define GEN_PASS_DECL_CONVERTPDLTOPDLINTERP
#define GEN_PASS_DECL_CONVERTPDLTOPDLINTERPPASS
#include "mlir/Conversion/Passes.h.inc"

/// Creates and returns a pass to convert PDL ops to PDL interpreter ops.
std::unique_ptr<OperationPass<ModuleOp>> createPDLToPDLInterpPass();

/// Creates and returns a pass to convert PDL ops to PDL interpreter ops.
/// `configMap` holds a map of the configurations for each pattern being
/// compiled.
std::unique_ptr<OperationPass<ModuleOp>> createPDLToPDLInterpPass(
std::unique_ptr<OperationPass<ModuleOp>> createConvertPDLToPDLInterpPass(
DenseMap<Operation *, PDLPatternConfigSet *> &configMap);

} // namespace mlir
Expand Down
Loading