[Mlir-commits] [mlir] [mlir] Reorder `declarePromisedInterface()` operands (PR #86628)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 25 22:58:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-gpu
Author: Justin Fargnoli (justinfargnoli)
<details>
<summary>Changes</summary>
Reorder the template operands of `declarePromisedInterface()` to match `declarePromisedInterfaces()`.
---
Full diff: https://github.com/llvm/llvm-project/pull/86628.diff
18 Files Affected:
- (modified) mlir/include/mlir/IR/Dialect.h (+2-2)
- (modified) mlir/lib/Dialect/Arith/IR/ArithDialect.cpp (+3-3)
- (modified) mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp (+3-3)
- (modified) mlir/lib/Dialect/Func/IR/FuncOps.cpp (+2-2)
- (modified) mlir/lib/Dialect/GPU/IR/GPUDialect.cpp (+2-2)
- (modified) mlir/lib/Dialect/Index/IR/IndexDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp (+2-2)
- (modified) mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp (+6-6)
- (modified) mlir/lib/Dialect/Math/IR/MathDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp (+2-2)
- (modified) mlir/lib/Dialect/SCF/IR/SCF.cpp (+1-1)
- (modified) mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp (+1-1)
- (modified) mlir/lib/Dialect/UB/IR/UBOps.cpp (+1-1)
- (modified) mlir/lib/Dialect/Vector/IR/VectorOps.cpp (+2-2)
- (modified) mlir/unittests/IR/InterfaceAttachmentTest.cpp (+2-2)
``````````diff
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..042acf61009000 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..5d11f8f6cc458b 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 4780ec09b81b9b..0a1a0da5f05d09 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -1047,8 +1047,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 5ca9510408c301..dda1c800c182be 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>());
``````````
</details>
https://github.com/llvm/llvm-project/pull/86628
More information about the Mlir-commits
mailing list