[Mlir-commits] [mlir] [NFC][mlir] Reorder `declarePromisedInterface()` operands (PR #86628)
Justin Fargnoli
llvmlistbot at llvm.org
Tue Mar 26 11:52:04 PDT 2024
https://github.com/justinfargnoli updated https://github.com/llvm/llvm-project/pull/86628
>From c711414e90862c927a45cd1f166e3b09caf36d27 Mon Sep 17 00:00:00 2001
From: justinfargnoli <justinfargnoli at gmail.com>
Date: Mon, 25 Mar 2024 22:41:40 -0700
Subject: [PATCH 1/2] Reorder declarePromisedInterface() operands
---
mlir/include/mlir/IR/Dialect.h | 4 ++--
mlir/lib/Dialect/Arith/IR/ArithDialect.cpp | 6 +++---
mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp | 2 +-
mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp | 6 +++---
mlir/lib/Dialect/Func/IR/FuncOps.cpp | 4 ++--
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 4 ++--
mlir/lib/Dialect/Index/IR/IndexDialect.cpp | 2 +-
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 4 ++--
mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp | 2 +-
mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp | 12 ++++++------
mlir/lib/Dialect/Math/IR/MathDialect.cpp | 2 +-
mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp | 4 ++--
mlir/lib/Dialect/SCF/IR/SCF.cpp | 2 +-
mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp | 2 +-
mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp | 2 +-
mlir/lib/Dialect/UB/IR/UBOps.cpp | 2 +-
mlir/lib/Dialect/Vector/IR/VectorOps.cpp | 4 ++--
mlir/unittests/IR/InterfaceAttachmentTest.cpp | 4 ++--
18 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h
index 6c8a170a03c72d..f7c1f4df16fc48 100644
--- a/mlir/include/mlir/IR/Dialect.h
+++ b/mlir/include/mlir/IR/Dialect.h
@@ -210,7 +210,7 @@ class Dialect {
/// registration. The promised interface type can be an interface of any type
/// not just a dialect interface, i.e. it may also be an
/// AttributeInterface/OpInterface/TypeInterface/etc.
- template <typename ConcreteT, typename InterfaceT>
+ template <typename InterfaceT, typename ConcreteT>
void declarePromisedInterface() {
unresolvedPromisedInterfaces.insert(
{TypeID::get<ConcreteT>(), InterfaceT::getInterfaceID()});
@@ -221,7 +221,7 @@ class Dialect {
// declarePromisedInterfaces<FunctionOpInterface, MyFuncType1, MyFuncType2>()
template <typename InterfaceT, typename... ConcreteT>
void declarePromisedInterfaces() {
- (declarePromisedInterface<ConcreteT, InterfaceT>(), ...);
+ (declarePromisedInterface<InterfaceT, ConcreteT>(), ...);
}
/// Checks if the given interface, which is attempting to be used, is a
diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index 6a593185ccedce..00568b0c3afc67 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -48,9 +48,9 @@ void arith::ArithDialect::initialize() {
#include "mlir/Dialect/Arith/IR/ArithOpsAttributes.cpp.inc"
>();
addInterfaces<ArithInlinerInterface>();
- declarePromisedInterface<ArithDialect, ConvertToLLVMPatternInterface>();
- declarePromisedInterface<SelectOp,
- bufferization::BufferDeallocationOpInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, ArithDialect>();
+ declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
+ SelectOp>();
declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
IndexCastOp, SelectOp>();
declarePromisedInterfaces<ValueBoundsOpInterface, AddIOp, ConstantOp, SubIOp,
diff --git a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
index ca57171af156f9..0bdcf434e062fe 100644
--- a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
+++ b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
@@ -40,7 +40,7 @@ void complex::ComplexDialect::initialize() {
#define GET_ATTRDEF_LIST
#include "mlir/Dialect/Complex/IR/ComplexAttributes.cpp.inc"
>();
- declarePromisedInterface<ComplexDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, ComplexDialect>();
addInterfaces<ComplexInlinerInterface>();
}
diff --git a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
index c6b02b9703e75f..b8c1fe53df1bf1 100644
--- a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
+++ b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
@@ -70,11 +70,11 @@ void ControlFlowDialect::initialize() {
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc"
>();
addInterfaces<ControlFlowInlinerInterface>();
- declarePromisedInterface<ControlFlowDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, ControlFlowDialect>();
declarePromisedInterfaces<bufferization::BufferizableOpInterface, BranchOp,
CondBranchOp>();
- declarePromisedInterface<CondBranchOp,
- bufferization::BufferDeallocationOpInterface>();
+ declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
+ CondBranchOp>();
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
index ed2ecfe9d0fb51..95589e8989e27a 100644
--- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp
+++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp
@@ -42,8 +42,8 @@ void FuncDialect::initialize() {
#define GET_OP_LIST
#include "mlir/Dialect/Func/IR/FuncOps.cpp.inc"
>();
- declarePromisedInterface<FuncDialect, DialectInlinerInterface>();
- declarePromisedInterface<FuncDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<DialectInlinerInterface, FuncDialect>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, FuncDialect>();
declarePromisedInterfaces<bufferization::BufferizableOpInterface, CallOp,
FuncOp, ReturnOp>();
}
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index a02eca8b11790c..f1b9ca5c500208 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -216,8 +216,8 @@ void GPUDialect::initialize() {
#include "mlir/Dialect/GPU/IR/GPUOpsAttributes.cpp.inc"
>();
addInterfaces<GPUInlinerInterface>();
- declarePromisedInterface<TerminatorOp,
- bufferization::BufferDeallocationOpInterface>();
+ declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
+ TerminatorOp>();
}
static std::string getSparseHandleKeyword(SparseHandleKind kind) {
diff --git a/mlir/lib/Dialect/Index/IR/IndexDialect.cpp b/mlir/lib/Dialect/Index/IR/IndexDialect.cpp
index d631afa63b9a2a..183d0e33b2523b 100644
--- a/mlir/lib/Dialect/Index/IR/IndexDialect.cpp
+++ b/mlir/lib/Dialect/Index/IR/IndexDialect.cpp
@@ -19,7 +19,7 @@ using namespace mlir::index;
void IndexDialect::initialize() {
registerAttributes();
registerOperations();
- declarePromisedInterface<IndexDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, IndexDialect>();
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index 9e8407451a0855..94197e473ce012 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -1044,8 +1044,8 @@ void NVVMDialect::initialize() {
// Support unknown operations because not all NVVM operations are
// registered.
allowUnknownOperations();
- declarePromisedInterface<NVVMDialect, ConvertToLLVMPatternInterface>();
- declarePromisedInterface<NVVMTargetAttr, gpu::TargetAttrInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, NVVMDialect>();
+ declarePromisedInterface<gpu::TargetAttrInterface, NVVMTargetAttr>();
}
LogicalResult NVVMDialect::verifyOperationAttribute(Operation *op,
diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
index 0f2e75cd7e8bc7..65b770ae326106 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
@@ -247,7 +247,7 @@ void ROCDLDialect::initialize() {
// Support unknown operations because not all ROCDL operations are registered.
allowUnknownOperations();
- declarePromisedInterface<ROCDLTargetAttr, gpu::TargetAttrInterface>();
+ declarePromisedInterface<gpu::TargetAttrInterface, ROCDLTargetAttr>();
}
LogicalResult ROCDLDialect::verifyOperationAttribute(Operation *op,
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
index a6936fde43709d..9e50c355c50417 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp
@@ -123,16 +123,16 @@ void mlir::linalg::LinalgDialect::initialize() {
addInterfaces<LinalgInlinerInterface>();
- declarePromisedInterface<GenericOp, mesh::ShardingInterface>();
+ declarePromisedInterface<mesh::ShardingInterface, GenericOp>();
declarePromisedInterfaces<mesh::ShardingInterface,
#define GET_OP_LIST
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
>();
- declarePromisedInterface<CopyOp, SubsetOpInterface>();
- declarePromisedInterface<CopyOp, SubsetInsertionOpInterface>();
- declarePromisedInterface<IndexOp, ValueBoundsOpInterface>();
- declarePromisedInterface<linalg::GenericOp, TilingInterface>();
- declarePromisedInterface<linalg::GenericOp, PartialReductionOpInterface>();
+ declarePromisedInterface<SubsetOpInterface, CopyOp>();
+ declarePromisedInterface<SubsetInsertionOpInterface, CopyOp>();
+ declarePromisedInterface<ValueBoundsOpInterface, IndexOp>();
+ declarePromisedInterface<TilingInterface, linalg::GenericOp>();
+ declarePromisedInterface<PartialReductionOpInterface, linalg::GenericOp>();
declarePromisedInterfaces<TilingInterface,
#define GET_OP_LIST
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"
diff --git a/mlir/lib/Dialect/Math/IR/MathDialect.cpp b/mlir/lib/Dialect/Math/IR/MathDialect.cpp
index a71b24cb1b9737..285b5ca5940500 100644
--- a/mlir/lib/Dialect/Math/IR/MathDialect.cpp
+++ b/mlir/lib/Dialect/Math/IR/MathDialect.cpp
@@ -35,5 +35,5 @@ void mlir::math::MathDialect::initialize() {
#include "mlir/Dialect/Math/IR/MathOps.cpp.inc"
>();
addInterfaces<MathInlinerInterface>();
- declarePromisedInterface<MathDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, MathDialect>();
}
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp
index 41082a85a485f2..3a8bd12ba25863 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp
@@ -47,14 +47,14 @@ void mlir::memref::MemRefDialect::initialize() {
#include "mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc"
>();
addInterfaces<MemRefInlinerInterface>();
- declarePromisedInterface<MemRefDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, MemRefDialect>();
declarePromisedInterfaces<bufferization::AllocationOpInterface, AllocOp,
AllocaOp, ReallocOp>();
declarePromisedInterfaces<RuntimeVerifiableOpInterface, CastOp, ExpandShapeOp,
LoadOp, ReinterpretCastOp, StoreOp, SubViewOp>();
declarePromisedInterfaces<ValueBoundsOpInterface, AllocOp, AllocaOp, CastOp,
DimOp, GetGlobalOp, RankOp, SubViewOp>();
- declarePromisedInterface<MemRefType, DestructurableTypeInterface>();
+ declarePromisedInterface<DestructurableTypeInterface, MemRefType>();
}
/// Finds the unique dealloc operation (if one exists) for `allocValue`.
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index ddb9676eb4f628..5bca8e85f889d9 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -79,7 +79,7 @@ void SCFDialect::initialize() {
declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConditionOp,
ExecuteRegionOp, ForOp, IfOp, IndexSwitchOp,
ForallOp, InParallelOp, WhileOp, YieldOp>();
- declarePromisedInterface<ForOp, ValueBoundsOpInterface>();
+ declarePromisedInterface<ValueBoundsOpInterface, ForOp>();
}
/// Default callback for IfOp builders. Inserts a yield without arguments.
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
index e914f46bdef643..72488d6e5d0b09 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
@@ -135,7 +135,7 @@ void SPIRVDialect::initialize() {
// Allow unknown operations because SPIR-V is extensible.
allowUnknownOperations();
- declarePromisedInterface<TargetEnvAttr, gpu::TargetAttrInterface>();
+ declarePromisedInterface<gpu::TargetAttrInterface, TargetEnvAttr>();
}
std::string SPIRVDialect::getAttributeName(Decoration decoration) {
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp b/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp
index 4b3156728cc979..002077753b1324 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp
@@ -62,7 +62,7 @@ void TensorDialect::initialize() {
ParallelInsertSliceOp>();
declarePromisedInterfaces<SubsetInsertionOpInterface, InsertSliceOp,
ParallelInsertSliceOp>();
- declarePromisedInterface<ExtractSliceOp, SubsetExtractionOpInterface>();
+ declarePromisedInterface<SubsetExtractionOpInterface, ExtractSliceOp>();
declarePromisedInterfaces<TilingInterface, PadOp, PackOp, UnPackOp>();
declarePromisedInterfaces<ValueBoundsOpInterface, CastOp, DimOp, EmptyOp,
ExtractSliceOp, PadOp, RankOp>();
diff --git a/mlir/lib/Dialect/UB/IR/UBOps.cpp b/mlir/lib/Dialect/UB/IR/UBOps.cpp
index 3a2010cdcb5c7c..5b2cfe7bf42642 100644
--- a/mlir/lib/Dialect/UB/IR/UBOps.cpp
+++ b/mlir/lib/Dialect/UB/IR/UBOps.cpp
@@ -46,7 +46,7 @@ void UBDialect::initialize() {
#include "mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc"
>();
addInterfaces<UBInlinerInterface>();
- declarePromisedInterface<UBDialect, ConvertToLLVMPatternInterface>();
+ declarePromisedInterface<ConvertToLLVMPatternInterface, UBDialect>();
}
Operation *UBDialect::materializeConstant(OpBuilder &builder, Attribute value,
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 35296824246eb6..e566bfacf37984 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -382,8 +382,8 @@ void VectorDialect::initialize() {
YieldOp>();
declarePromisedInterfaces<SubsetOpInterface, TransferReadOp,
TransferWriteOp>();
- declarePromisedInterface<TransferReadOp, SubsetExtractionOpInterface>();
- declarePromisedInterface<TransferWriteOp, SubsetInsertionOpInterface>();
+ declarePromisedInterface<SubsetExtractionOpInterface, TransferReadOp>();
+ declarePromisedInterface<SubsetInsertionOpInterface, TransferWriteOp>();
}
/// Materialize a single constant operation from a given attribute value with
diff --git a/mlir/unittests/IR/InterfaceAttachmentTest.cpp b/mlir/unittests/IR/InterfaceAttachmentTest.cpp
index 16de34c45ec6e0..58049a9969e3ab 100644
--- a/mlir/unittests/IR/InterfaceAttachmentTest.cpp
+++ b/mlir/unittests/IR/InterfaceAttachmentTest.cpp
@@ -431,8 +431,8 @@ TEST(InterfaceAttachmentTest, PromisedInterfaces) {
attr.hasPromiseOrImplementsInterface<TestExternalAttrInterface>());
// Add a promise `TestExternalAttrInterface`.
- testDialect->declarePromisedInterface<test::SimpleAAttr,
- TestExternalAttrInterface>();
+ testDialect->declarePromisedInterface<TestExternalAttrInterface,
+ test::SimpleAAttr>();
EXPECT_TRUE(
attr.hasPromiseOrImplementsInterface<TestExternalAttrInterface>());
>From 2a0520c01273719bba923811bc00be377cac8ad7 Mon Sep 17 00:00:00 2001
From: justinfargnoli <justinfargnoli at gmail.com>
Date: Mon, 25 Mar 2024 22:47:20 -0700
Subject: [PATCH 2/2] White space changes
---
mlir/lib/Dialect/Arith/IR/ArithDialect.cpp | 2 +-
mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index 00568b0c3afc67..042acf61009000 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -49,7 +49,7 @@ void arith::ArithDialect::initialize() {
>();
addInterfaces<ArithInlinerInterface>();
declarePromisedInterface<ConvertToLLVMPatternInterface, ArithDialect>();
- declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
+ declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
SelectOp>();
declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
IndexCastOp, SelectOp>();
diff --git a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
index b8c1fe53df1bf1..5d11f8f6cc458b 100644
--- a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
+++ b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
@@ -73,7 +73,7 @@ void ControlFlowDialect::initialize() {
declarePromisedInterface<ConvertToLLVMPatternInterface, ControlFlowDialect>();
declarePromisedInterfaces<bufferization::BufferizableOpInterface, BranchOp,
CondBranchOp>();
- declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
+ declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
CondBranchOp>();
}
More information about the Mlir-commits
mailing list