[mlir] Declare promised interfaces for the ConvertToLLVM extension (#76341)

This PR adds promised interface declarations for
`ConvertToLLVMPatternInterface` in all the dialects that support the
`ConvertToLLVM` dialect extension.

Promised interfaces allow a dialect to declare that it will have an
implementation of a particular interface, crashing the program if one
isn't provided when the interface is used.
This commit is contained in:
Justin Fargnoli 2024-01-08 20:19:18 -08:00 committed by GitHub
parent 700a1928bb
commit b43c50490c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 0 deletions

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/IR/Builders.h"
@ -44,6 +45,7 @@ void arith::ArithDialect::initialize() {
#include "mlir/Dialect/Arith/IR/ArithOpsAttributes.cpp.inc"
>();
addInterfaces<ArithInlinerInterface>();
declarePromisedInterface<ArithDialect, ConvertToLLVMPatternInterface>();
}
/// Materialize an integer or floating point constant.

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/IR/Builders.h"
@ -26,6 +27,7 @@ void complex::ComplexDialect::initialize() {
#define GET_ATTRDEF_LIST
#include "mlir/Dialect/Complex/IR/ComplexAttributes.cpp.inc"
>();
declarePromisedInterface<ComplexDialect, ConvertToLLVMPatternInterface>();
}
Operation *complex::ComplexDialect::materializeConstant(OpBuilder &builder,

View File

@ -8,6 +8,7 @@
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
@ -67,6 +68,7 @@ void ControlFlowDialect::initialize() {
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc"
>();
addInterfaces<ControlFlowInlinerInterface>();
declarePromisedInterface<ControlFlowDialect, ConvertToLLVMPatternInterface>();
}
//===----------------------------------------------------------------------===//

View File

@ -8,6 +8,7 @@
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/IRMapping.h"
@ -41,6 +42,7 @@ void FuncDialect::initialize() {
#include "mlir/Dialect/Func/IR/FuncOps.cpp.inc"
>();
declarePromisedInterface<FuncDialect, DialectInlinerInterface>();
declarePromisedInterface<FuncDialect, ConvertToLLVMPatternInterface>();
}
/// Materialize a single constant operation from a given attribute value with

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Index/IR/IndexDialect.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
using namespace mlir;
using namespace mlir::index;
@ -18,6 +19,7 @@ using namespace mlir::index;
void IndexDialect::initialize() {
registerAttributes();
registerOperations();
declarePromisedInterface<IndexDialect, ConvertToLLVMPatternInterface>();
}
//===----------------------------------------------------------------------===//

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Transforms/InliningUtils.h"
@ -34,4 +35,5 @@ void mlir::math::MathDialect::initialize() {
#include "mlir/Dialect/Math/IR/MathOps.cpp.inc"
>();
addInterfaces<MathInlinerInterface>();
declarePromisedInterface<MathDialect, ConvertToLLVMPatternInterface>();
}

View File

@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
@ -41,6 +42,7 @@ void mlir::memref::MemRefDialect::initialize() {
#include "mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc"
>();
addInterfaces<MemRefInlinerInterface>();
declarePromisedInterface<MemRefDialect, ConvertToLLVMPatternInterface>();
}
/// Finds the unique dealloc operation (if one exists) for `allocValue`.

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Transforms/InliningUtils.h"
#include "mlir/IR/Builders.h"
@ -45,6 +46,7 @@ void UBDialect::initialize() {
#include "mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc"
>();
addInterfaces<UBInlinerInterface>();
declarePromisedInterface<UBDialect, ConvertToLLVMPatternInterface>();
}
Operation *UBDialect::materializeConstant(OpBuilder &builder, Attribute value,