diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -731,9 +731,14 @@ - `void setCalleeFromCallable(CallInterfaceCallable)` * `CallableOpInterface` - Used to represent the target callee of call. - `Region * getCallableRegion()` - - `ArrayRef getCallableResults()` - - `ArrayAttr getCallableArgAttrs()` - - `ArrayAttr getCallableResAttrs()` + - `ArrayRef getArgumentTypes()` + - `ArrayRef getResultsTypes()` + - `ArrayAttr getArgAttrsAttr()` + - `ArrayAttr getResAttrsAttr()` + - `void setArgAttrsAttr(ArrayAttr)` + - `void setResAttrsAttr(ArrayAttr)` + - `Attribute removeArgAttrsAttr()` + - `Attribute removeResAttrsAttr()` ##### RegionKindInterfaces diff --git a/mlir/docs/Tutorials/Toy/Ch-4.md b/mlir/docs/Tutorials/Toy/Ch-4.md --- a/mlir/docs/Tutorials/Toy/Ch-4.md +++ b/mlir/docs/Tutorials/Toy/Ch-4.md @@ -165,22 +165,6 @@ /// Returns the region on the function operation that is callable. Region *FuncOp::getCallableRegion() { return &getBody(); } -/// Returns the results types that the callable region produces when -/// executed. -ArrayRef FuncOp::getCallableResults() { return getType().getResults(); } - -/// Returns the argument attributes for all callable region arguments or -/// null if there are none. -ArrayAttr FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -/// Returns the result attributes for all callable region results or -/// null if there are none. -ArrayAttr FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - // .... /// Return the callee of the generic call operation, this is required by the diff --git a/mlir/examples/toy/Ch2/CMakeLists.txt b/mlir/examples/toy/Ch2/CMakeLists.txt --- a/mlir/examples/toy/Ch2/CMakeLists.txt +++ b/mlir/examples/toy/Ch2/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries(toyc-ch2 PRIVATE MLIRAnalysis + MLIRFunctionInterfaces MLIRIR MLIRParser MLIRSideEffectInterfaces diff --git a/mlir/examples/toy/Ch2/include/toy/Dialect.h b/mlir/examples/toy/Ch2/include/toy/Dialect.h --- a/mlir/examples/toy/Ch2/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch2/include/toy/Dialect.h @@ -16,9 +16,9 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" /// Include the auto-generated header file containing the declaration of the toy diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -14,7 +14,7 @@ #define TOY_OPS include "mlir/IR/OpBase.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td" @@ -144,6 +144,7 @@ "StringRef":$name, "FunctionType":$type, CArg<"ArrayRef", "{}">:$attrs) >]; + let extraClassDeclaration = [{ //===------------------------------------------------------------------===// // FunctionOpInterface Methods @@ -154,7 +155,10 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + Region *getCallableRegion() { return &getBody(); } }]; + let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; } diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -15,8 +15,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" using namespace mlir; using namespace mlir::toy; diff --git a/mlir/examples/toy/Ch3/CMakeLists.txt b/mlir/examples/toy/Ch3/CMakeLists.txt --- a/mlir/examples/toy/Ch3/CMakeLists.txt +++ b/mlir/examples/toy/Ch3/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(toyc-ch3 PRIVATE MLIRAnalysis + MLIRFunctionInterfaces MLIRIR MLIRParser MLIRPass diff --git a/mlir/examples/toy/Ch3/include/toy/Dialect.h b/mlir/examples/toy/Ch3/include/toy/Dialect.h --- a/mlir/examples/toy/Ch3/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch3/include/toy/Dialect.h @@ -16,9 +16,9 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" /// Include the auto-generated header file containing the declaration of the toy diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td" @@ -153,6 +153,9 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + /// Returns the region on the current operation that is callable. + ::mlir::Region *getCallableRegion() { return &getBody(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -15,8 +15,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" using namespace mlir; using namespace mlir::toy; diff --git a/mlir/examples/toy/Ch4/CMakeLists.txt b/mlir/examples/toy/Ch4/CMakeLists.txt --- a/mlir/examples/toy/Ch4/CMakeLists.txt +++ b/mlir/examples/toy/Ch4/CMakeLists.txt @@ -31,6 +31,7 @@ MLIRAnalysis MLIRCastInterfaces MLIRCallInterfaces + MLIRFunctionInterfaces MLIRIR MLIRParser MLIRPass diff --git a/mlir/examples/toy/Ch4/include/toy/Dialect.h b/mlir/examples/toy/Ch4/include/toy/Dialect.h --- a/mlir/examples/toy/Ch4/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch4/include/toy/Dialect.h @@ -17,10 +17,10 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/CastInterfaces.td" @@ -141,8 +141,7 @@ //===----------------------------------------------------------------------===// def FuncOp : Toy_Op<"func", [ - DeclareOpInterfaceMethods, FunctionOpInterface, - IsolatedFromAbove + FunctionOpInterface, IsolatedFromAbove ]> { let summary = "user defined function operation"; let description = [{ @@ -173,6 +172,7 @@ "StringRef":$name, "FunctionType":$type, CArg<"ArrayRef", "{}">:$attrs) >]; + let extraClassDeclaration = [{ //===------------------------------------------------------------------===// // FunctionOpInterface Methods @@ -183,7 +183,10 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + Region *getCallableRegion() { return &getBody(); } }]; + let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; } diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -15,8 +15,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Transforms/InliningUtils.h" using namespace mlir; @@ -298,27 +298,6 @@ getArgAttrsAttrName(), getResAttrsAttrName()); } -/// Returns the region on the function operation that is callable. -mlir::Region *FuncOp::getCallableRegion() { return &getBody(); } - -/// Returns the results types that the callable region produces when -/// executed. -llvm::ArrayRef FuncOp::getCallableResults() { - return getFunctionType().getResults(); -} - -/// Returns the argument attributes for all callable region arguments or -/// null if there are none. -ArrayAttr FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -/// Returns the result attributes for all callable region results or -/// null if there are none. -ArrayAttr FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - //===----------------------------------------------------------------------===// // GenericCallOp //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch5/CMakeLists.txt b/mlir/examples/toy/Ch5/CMakeLists.txt --- a/mlir/examples/toy/Ch5/CMakeLists.txt +++ b/mlir/examples/toy/Ch5/CMakeLists.txt @@ -36,6 +36,7 @@ MLIRAnalysis MLIRCallInterfaces MLIRCastInterfaces + MLIRFunctionInterfaces MLIRIR MLIRParser MLIRPass diff --git a/mlir/examples/toy/Ch5/include/toy/Dialect.h b/mlir/examples/toy/Ch5/include/toy/Dialect.h --- a/mlir/examples/toy/Ch5/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch5/include/toy/Dialect.h @@ -17,10 +17,10 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/CastInterfaces.td" @@ -141,8 +141,7 @@ //===----------------------------------------------------------------------===// def FuncOp : Toy_Op<"func", [ - DeclareOpInterfaceMethods, FunctionOpInterface, - IsolatedFromAbove + FunctionOpInterface, IsolatedFromAbove ]> { let summary = "user defined function operation"; let description = [{ @@ -183,6 +182,9 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + /// Returns the region on the function operation that is callable. + Region *getCallableRegion() { return &getBody(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -15,8 +15,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Transforms/InliningUtils.h" using namespace mlir; @@ -298,27 +298,6 @@ getArgAttrsAttrName(), getResAttrsAttrName()); } -/// Returns the region on the function operation that is callable. -mlir::Region *FuncOp::getCallableRegion() { return &getBody(); } - -/// Returns the results types that the callable region produces when -/// executed. -llvm::ArrayRef FuncOp::getCallableResults() { - return getFunctionType().getResults(); -} - -/// Returns the argument attributes for all callable region arguments or -/// null if there are none. -ArrayAttr FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -/// Returns the result attributes for all callable region results or -/// null if there are none. -ArrayAttr FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - //===----------------------------------------------------------------------===// // GenericCallOp //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt --- a/mlir/examples/toy/Ch6/CMakeLists.txt +++ b/mlir/examples/toy/Ch6/CMakeLists.txt @@ -50,6 +50,7 @@ MLIRCallInterfaces MLIRCastInterfaces MLIRExecutionEngine + MLIRFunctionInterfaces MLIRIR MLIRLLVMCommonConversion MLIRLLVMDialect diff --git a/mlir/examples/toy/Ch6/include/toy/Dialect.h b/mlir/examples/toy/Ch6/include/toy/Dialect.h --- a/mlir/examples/toy/Ch6/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch6/include/toy/Dialect.h @@ -17,10 +17,10 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/CastInterfaces.td" @@ -141,8 +141,7 @@ //===----------------------------------------------------------------------===// def FuncOp : Toy_Op<"func", [ - DeclareOpInterfaceMethods, FunctionOpInterface, - IsolatedFromAbove + FunctionOpInterface, IsolatedFromAbove ]> { let summary = "user defined function operation"; let description = [{ @@ -183,6 +182,9 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + /// Returns the region on the function operation that is callable. + Region *getCallableRegion() { return &getBody(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -15,8 +15,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Transforms/InliningUtils.h" using namespace mlir; @@ -298,27 +298,6 @@ getArgAttrsAttrName(), getResAttrsAttrName()); } -/// Returns the region on the function operation that is callable. -mlir::Region *FuncOp::getCallableRegion() { return &getBody(); } - -/// Returns the results types that the callable region produces when -/// executed. -llvm::ArrayRef FuncOp::getCallableResults() { - return getFunctionType().getResults(); -} - -/// Returns the argument attributes for all callable region arguments or -/// null if there are none. -ArrayAttr FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -/// Returns the result attributes for all callable region results or -/// null if there are none. -ArrayAttr FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - //===----------------------------------------------------------------------===// // GenericCallOp //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt --- a/mlir/examples/toy/Ch7/CMakeLists.txt +++ b/mlir/examples/toy/Ch7/CMakeLists.txt @@ -49,6 +49,7 @@ MLIRCallInterfaces MLIRCastInterfaces MLIRExecutionEngine + MLIRFunctionInterfaces MLIRIR MLIRLLVMCommonConversion MLIRLLVMToLLVMIRTranslation diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h --- a/mlir/examples/toy/Ch7/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h @@ -17,10 +17,10 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "toy/ShapeInferenceInterface.h" diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -13,7 +13,7 @@ #ifndef TOY_OPS #define TOY_OPS -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/CastInterfaces.td" @@ -165,8 +165,7 @@ //===----------------------------------------------------------------------===// def FuncOp : Toy_Op<"func", [ - DeclareOpInterfaceMethods, FunctionOpInterface, - IsolatedFromAbove + FunctionOpInterface, IsolatedFromAbove ]> { let summary = "user defined function operation"; let description = [{ @@ -207,6 +206,8 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + Region *getCallableRegion() { return &getBody(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -16,8 +16,8 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Transforms/InliningUtils.h" using namespace mlir; @@ -327,27 +327,6 @@ getArgAttrsAttrName(), getResAttrsAttrName()); } -/// Returns the region on the function operation that is callable. -mlir::Region *FuncOp::getCallableRegion() { return &getBody(); } - -/// Returns the results types that the callable region produces when -/// executed. -llvm::ArrayRef FuncOp::getCallableResults() { - return getFunctionType().getResults(); -} - -/// Returns the argument attributes for all callable region arguments or -/// null if there are none. -ArrayAttr FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -/// Returns the result attributes for all callable region results or -/// null if there are none. -ArrayAttr FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - //===----------------------------------------------------------------------===// // GenericCallOp //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h --- a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h +++ b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h @@ -8,7 +8,7 @@ #ifndef MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_ #define MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_ -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Support/LLVM.h" #include diff --git a/mlir/include/mlir/Dialect/Async/IR/Async.h b/mlir/include/mlir/Dialect/Async/IR/Async.h --- a/mlir/include/mlir/Dialect/Async/IR/Async.h +++ b/mlir/include/mlir/Dialect/Async/IR/Async.h @@ -19,12 +19,12 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td --- a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td +++ b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td @@ -20,7 +20,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/IR/SymbolInterfaces.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/OpAsmInterface.td" @@ -105,8 +105,7 @@ } def Async_FuncOp : Async_Op<"func", - [CallableOpInterface, FunctionOpInterface, - IsolatedFromAbove, OpAsmOpInterface]> { + [FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface]> { let summary = "async function operation"; let description = [{ An async function is like a normal function, but supports non-blocking @@ -154,7 +153,7 @@ let extraClassDeclaration = [{ //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -163,27 +162,6 @@ ::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ArrayRef getCallableResults() { return getFunctionType() - .getResults(); } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this async function. ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.h b/mlir/include/mlir/Dialect/Func/IR/FuncOps.h --- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.h +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.h @@ -13,11 +13,11 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td --- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td @@ -14,7 +14,7 @@ include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" @@ -224,7 +224,7 @@ //===----------------------------------------------------------------------===// def FuncOp : Func_Op<"func", [ - AffineScope, AutomaticAllocationScope, CallableOpInterface, + AffineScope, AutomaticAllocationScope, FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface ]> { let summary = "An operation with a name containing a single `SSACFG` region"; @@ -304,7 +304,7 @@ void cloneInto(FuncOp dest, IRMapping &mapper); //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -312,26 +312,6 @@ /// function. ::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ArrayRef getCallableResults() { return getFunctionType().getResults(); } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this function. ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h b/mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h --- a/mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h +++ b/mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h @@ -20,10 +20,10 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferIntRangeInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td @@ -20,7 +20,7 @@ include "mlir/Dialect/GPU/IR/ParallelLoopMapperAttr.td" include "mlir/Dialect/GPU/TransformOps/GPUDeviceMappingAttr.td" include "mlir/IR/EnumAttr.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/DataLayoutInterfaces.td" include "mlir/Interfaces/InferIntRangeInterface.td" @@ -415,6 +415,8 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + Region *getCallableRegion() { return &getBody(); } + /// Returns the keywords used in the custom syntax for this Op. static StringRef getWorkgroupKeyword() { return "workgroup"; } static StringRef getPrivateKeyword() { return "private"; } diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -20,13 +20,13 @@ #include "mlir/Dialect/LLVMIR/LLVMTypes.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/TypeSupport.h" #include "mlir/IR/Types.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Support/ThreadLocalCache.h" diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -17,7 +17,7 @@ include "mlir/Dialect/LLVMIR/LLVMEnums.td" include "mlir/Dialect/LLVMIR/LLVMOpBase.td" include "mlir/IR/EnumAttr.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" @@ -1339,8 +1339,7 @@ } def LLVM_LLVMFuncOp : LLVM_Op<"func", [ - AutomaticAllocationScope, IsolatedFromAbove, FunctionOpInterface, - CallableOpInterface + AutomaticAllocationScope, IsolatedFromAbove, FunctionOpInterface ]> { let summary = "LLVM dialect function."; @@ -1420,36 +1419,15 @@ ArrayRef getArgumentTypes() { return getFunctionType().getParams(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getFunctionType().getReturnTypes(); } - - //===------------------------------------------------------------------===// - // CallableOpInterface - //===------------------------------------------------------------------===// - - /// Returns the callable region, which is the function body. If the function - /// is external, returns null. - Region *getCallableRegion(); - - /// Returns the callable result type, which is the single function return - /// type if it is not void, or an empty array if the function's return type - /// is void, as void is not assignable to a value. - ArrayRef getCallableResults() { + ArrayRef getResultTypes() { if (::llvm::isa(getFunctionType().getReturnType())) return {}; return getFunctionType().getReturnTypes(); } - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } + /// Returns the callable region, which is the function body. If the function + /// is external, returns null. + Region *getCallableRegion(); }]; let hasCustomAssemblyFormat = 1; diff --git a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgram.h b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgram.h --- a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgram.h +++ b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgram.h @@ -12,13 +12,13 @@ #include "mlir/Dialect/MLProgram/IR/MLProgramAttributes.h" #include "mlir/Dialect/MLProgram/IR/MLProgramTypes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/RegionKindInterface.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td --- a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td +++ b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td @@ -15,7 +15,7 @@ include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/RegionKindInterface.td" include "mlir/IR/SymbolInterfaces.td" @@ -27,7 +27,7 @@ //===----------------------------------------------------------------------===// def MLProgram_FuncOp : MLProgram_Op<"func", [ - CallableOpInterface, FunctionOpInterface, IsolatedFromAbove, + FunctionOpInterface, IsolatedFromAbove, RegionKindInterface, Symbol ]> { let summary = "Function containing a single `SSACFG` region"; @@ -59,7 +59,7 @@ let extraClassDeclaration = [{ //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -69,26 +69,6 @@ return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ArrayRef getCallableResults() { return getFunctionType().getResults(); } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this function. ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } @@ -390,7 +370,7 @@ //===----------------------------------------------------------------------===// def MLProgram_SubgraphOp : MLProgram_Op<"subgraph", [ - CallableOpInterface, FunctionOpInterface, HasOnlyGraphRegion, + FunctionOpInterface, HasOnlyGraphRegion, IsolatedFromAbove, RegionKindInterface, SingleBlock, Symbol ]> { let summary = "An function containing a single `Graph` region"; @@ -422,7 +402,7 @@ let extraClassDeclaration = [{ //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -430,26 +410,6 @@ /// function. ::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ArrayRef getCallableResults() { return getFunctionType().getResults(); } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this function. ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterp.h b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterp.h --- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterp.h +++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterp.h @@ -17,8 +17,8 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/Dialect/PDL/IR/PDL.h" #include "mlir/Dialect/PDL/IR/PDLTypes.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td --- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td +++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td @@ -14,7 +14,7 @@ #define MLIR_DIALECT_PDLINTERP_IR_PDLINTERPOPS include "mlir/Dialect/PDL/IR/PDLTypes.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/SideEffectInterfaces.td" @@ -677,6 +677,8 @@ /// Returns the result types of this function. ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + Region *getCallableRegion() { return &getBody(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h @@ -18,10 +18,10 @@ #include "mlir/Dialect/SPIRV/IR/SPIRVOpTraits.h" #include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpImplementation.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "llvm/Support/PointerLikeTypeTraits.h" diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td @@ -18,7 +18,7 @@ include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.td" include "mlir/Dialect/SPIRV/IR/SPIRVBase.td" include "mlir/IR/BuiltinAttributeInterfaces.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/OpAsmInterface.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" @@ -257,8 +257,8 @@ // ----- def SPIRV_FuncOp : SPIRV_Op<"func", [ - AutomaticAllocationScope, DeclareOpInterfaceMethods, - FunctionOpInterface, InModuleScope, IsolatedFromAbove + AutomaticAllocationScope, FunctionOpInterface, + InModuleScope, IsolatedFromAbove ]> { let summary = "Declare or define a function"; @@ -315,12 +315,6 @@ let autogenSerialization = 0; let extraClassDeclaration = [{ - /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } - - /// Returns the result types of this function. - ArrayRef getResultTypes() { return getFunctionType().getResults(); } - /// Hook for FunctionOpInterface, called after verifying that the 'type' /// attribute is present and checks if it holds a function type. Ensures /// getType, getNumArguments, and getNumResults can be called safely @@ -330,6 +324,19 @@ /// type and the presence of the (potentially empty) function body. /// Ensures SPIR-V specific semantics. LogicalResult verifyBody(); + + //===------------------------------------------------------------------===// + // FunctionOpInterface Methods + //===------------------------------------------------------------------===// + + /// Returns the argument types of this function. + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } + + /// Returns the result types of this function. + ArrayRef getResultTypes() { return getFunctionType().getResults(); } + + // CallableOpInterface + Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); } }]; } diff --git a/mlir/include/mlir/Dialect/Shape/IR/Shape.h b/mlir/include/mlir/Dialect/Shape/IR/Shape.h --- a/mlir/include/mlir/Dialect/Shape/IR/Shape.h +++ b/mlir/include/mlir/Dialect/Shape/IR/Shape.h @@ -17,13 +17,13 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -20,7 +20,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/IR/OpAsmInterface.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/SymbolInterfaces.td" //===----------------------------------------------------------------------===// @@ -1031,7 +1031,7 @@ } def Shape_FuncOp : Shape_Op<"func", - [AffineScope, AutomaticAllocationScope, CallableOpInterface, + [AffineScope, AutomaticAllocationScope, FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface]> { let summary = "Shape function"; let description = [{ @@ -1062,7 +1062,7 @@ ArrayRef attrs, ArrayRef argAttrs); //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -1072,28 +1072,6 @@ return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ArrayRef getCallableResults() { - return getFunctionType().getResults(); - } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this function. ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h --- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h @@ -15,7 +15,6 @@ #include "mlir/Dialect/Transform/IR/TransformDialect.h" #include "mlir/Dialect/Transform/IR/TransformInterfaces.h" #include "mlir/Dialect/Transform/IR/TransformTypes.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" @@ -23,6 +22,7 @@ #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/LoopLikeInterface.h" namespace mlir { diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td --- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td @@ -14,7 +14,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/OpAsmInterface.td" include "mlir/IR/RegionKindInterface.td" include "mlir/IR/SymbolInterfaces.td" @@ -799,8 +799,7 @@ } def NamedSequenceOp : TransformDialectOp<"named_sequence", - [CallableOpInterface, - FunctionOpInterface, + [FunctionOpInterface, IsolatedFromAbove, DeclareOpInterfaceMethods, DeclareOpInterfaceMethods]> { @@ -850,19 +849,9 @@ ::llvm::ArrayRef<::mlir::Type> getResultTypes() { return getFunctionType().getResults(); } - ::mlir::Region *getCallableRegion() { return &getBody(); } - ::llvm::ArrayRef<::mlir::Type> getCallableResults() { - return getFunctionType().getResults(); - } - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } }]; } diff --git a/mlir/include/mlir/IR/CMakeLists.txt b/mlir/include/mlir/IR/CMakeLists.txt --- a/mlir/include/mlir/IR/CMakeLists.txt +++ b/mlir/include/mlir/IR/CMakeLists.txt @@ -41,12 +41,6 @@ mlir_tablegen(BuiltinTypeInterfaces.cpp.inc -gen-type-interface-defs) add_public_tablegen_target(MLIRBuiltinTypeInterfacesIncGen) -set(LLVM_TARGET_DEFINITIONS FunctionInterfaces.td) -mlir_tablegen(FunctionOpInterfaces.h.inc -gen-op-interface-decls) -mlir_tablegen(FunctionOpInterfaces.cpp.inc -gen-op-interface-defs) -add_public_tablegen_target(MLIRFunctionInterfacesIncGen) -add_dependencies(mlir-generic-headers MLIRFunctionInterfacesIncGen) - set(LLVM_TARGET_DEFINITIONS TensorEncoding.td) mlir_tablegen(TensorEncInterfaces.h.inc -gen-attr-interface-decls) mlir_tablegen(TensorEncInterfaces.cpp.inc -gen-attr-interface-defs) diff --git a/mlir/include/mlir/IR/TypeUtilities.h b/mlir/include/mlir/IR/TypeUtilities.h --- a/mlir/include/mlir/IR/TypeUtilities.h +++ b/mlir/include/mlir/IR/TypeUtilities.h @@ -21,6 +21,7 @@ class Attribute; class TupleType; class Type; +class TypeRange; class Value; //===----------------------------------------------------------------------===// @@ -67,6 +68,17 @@ /// Dimensions are compatible if all non-dynamic dims are equal. LogicalResult verifyCompatibleDims(ArrayRef dims); +/// Insert a set of `newTypes` into `oldTypes` at the given `indices`. If any +/// types are inserted, `storage` is used to hold the new type list. The new +/// type list is returned. `indices` must be sorted by increasing index. +TypeRange insertTypesInto(TypeRange oldTypes, ArrayRef indices, + TypeRange newTypes, SmallVectorImpl &storage); + +/// Filters out any elements referenced by `indices`. If any types are removed, +/// `storage` is used to hold the new type list. Returns the new type list. +TypeRange filterTypesOut(TypeRange types, const BitVector &indices, + SmallVectorImpl &storage); + //===----------------------------------------------------------------------===// // Utility Iterators //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt --- a/mlir/include/mlir/Interfaces/CMakeLists.txt +++ b/mlir/include/mlir/Interfaces/CMakeLists.txt @@ -4,6 +4,7 @@ add_mlir_interface(CopyOpInterface) add_mlir_interface(DerivedAttributeOpInterface) add_mlir_interface(DestinationStyleOpInterface) +add_mlir_interface(FunctionInterfaces) add_mlir_interface(InferIntRangeInterface) add_mlir_interface(InferTypeOpInterface) add_mlir_interface(LoopLikeInterface) diff --git a/mlir/include/mlir/Interfaces/CallInterfaces.td b/mlir/include/mlir/Interfaces/CallInterfaces.td --- a/mlir/include/mlir/Interfaces/CallInterfaces.td +++ b/mlir/include/mlir/Interfaces/CallInterfaces.td @@ -90,26 +90,58 @@ return null in the case of an external callable object, e.g. an external function. }], - "::mlir::Region *", "getCallableRegion" - >, + "::mlir::Region *", "getCallableRegion">, InterfaceMethod<[{ - Returns the results types that the callable region produces when - executed. - }], - "::llvm::ArrayRef<::mlir::Type>", "getCallableResults" - >, + Returns the callable's argument types based exclusively on the type (to + allow for this method may be called on function declarations). + }], + "::llvm::ArrayRef<::mlir::Type>", "getArgumentTypes">, + InterfaceMethod<[{ + Returns the callable's result types based exclusively on the type (to + allow for this method may be called on function declarations). + }], + "::llvm::ArrayRef<::mlir::Type>", "getResultTypes">, + InterfaceMethod<[{ - Returns the argument attributes for all callable region arguments or - null if there are none. + Get the array of argument attribute dictionaries. The method should + return an array attribute containing only dictionary attributes equal in + number to the number of region arguments. Alternatively, the method can + return null to indicate that the region has no argument attributes. }], - "::mlir::ArrayAttr", "getCallableArgAttrs" - >, + "::mlir::ArrayAttr", "getArgAttrsAttr", (ins), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, InterfaceMethod<[{ - Returns the result attributes for all callable region results or null - if there are none. + Get the array of result attribute dictionaries. The method should return + an array attribute containing only dictionary attributes equal in number + to the number of region results. Alternatively, the method can return + null to indicate that the region has no result attributes. }], - "::mlir::ArrayAttr", "getCallableResAttrs" - > + "::mlir::ArrayAttr", "getResAttrsAttr", (ins), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, + InterfaceMethod<[{ + Set the array of argument attribute dictionaries. + }], + "void", "setArgAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, + InterfaceMethod<[{ + Set the array of result attribute dictionaries. + }], + "void", "setResAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, + InterfaceMethod<[{ + Remove the array of argument attribute dictionaries. This is the same as + setting all argument attributes to an empty dictionary. The method should + return the removed attribute. + }], + "::mlir::Attribute", "removeArgAttrsAttr", (ins), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, + InterfaceMethod<[{ + Remove the array of result attribute dictionaries. This is the same as + setting all result attributes to an empty dictionary. The method should + return the removed attribute. + }], + "::mlir::Attribute", "removeResAttrsAttr", (ins), + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, ]; } diff --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/Interfaces/FunctionImplementation.h rename from mlir/include/mlir/IR/FunctionImplementation.h rename to mlir/include/mlir/Interfaces/FunctionImplementation.h --- a/mlir/include/mlir/IR/FunctionImplementation.h +++ b/mlir/include/mlir/Interfaces/FunctionImplementation.h @@ -15,8 +15,8 @@ #ifndef MLIR_IR_FUNCTIONIMPLEMENTATION_H_ #define MLIR_IR_FUNCTIONIMPLEMENTATION_H_ -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/OpImplementation.h" +#include "mlir/Interfaces/FunctionInterfaces.h" namespace mlir { diff --git a/mlir/include/mlir/IR/FunctionInterfaces.h b/mlir/include/mlir/Interfaces/FunctionInterfaces.h rename from mlir/include/mlir/IR/FunctionInterfaces.h rename to mlir/include/mlir/Interfaces/FunctionInterfaces.h --- a/mlir/include/mlir/IR/FunctionInterfaces.h +++ b/mlir/include/mlir/Interfaces/FunctionInterfaces.h @@ -18,6 +18,8 @@ #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/SymbolTable.h" +#include "mlir/IR/TypeUtilities.h" +#include "mlir/Interfaces/CallInterfaces.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallString.h" @@ -76,17 +78,6 @@ /// Set a FunctionOpInterface operation's type signature. void setFunctionType(FunctionOpInterface op, Type newType); -/// Insert a set of `newTypes` into `oldTypes` at the given `indices`. If any -/// types are inserted, `storage` is used to hold the new type list. The new -/// type list is returned. `indices` must be sorted by increasing index. -TypeRange insertTypesInto(TypeRange oldTypes, ArrayRef indices, - TypeRange newTypes, SmallVectorImpl &storage); - -/// Filters out any elements referenced by `indices`. If any types are removed, -/// `storage` is used to hold the new type list. Returns the new type list. -TypeRange filterTypesOut(TypeRange types, const BitVector &indices, - SmallVectorImpl &storage); - //===----------------------------------------------------------------------===// // Function Argument Attribute. //===----------------------------------------------------------------------===// @@ -245,6 +236,6 @@ // Tablegen Interface Declarations //===----------------------------------------------------------------------===// -#include "mlir/IR/FunctionOpInterfaces.h.inc" +#include "mlir/Interfaces/FunctionOpInterfaces.h.inc" #endif // MLIR_IR_FUNCTIONINTERFACES_H diff --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/Interfaces/FunctionInterfaces.td rename from mlir/include/mlir/IR/FunctionInterfaces.td rename to mlir/include/mlir/Interfaces/FunctionInterfaces.td --- a/mlir/include/mlir/IR/FunctionInterfaces.td +++ b/mlir/include/mlir/Interfaces/FunctionInterfaces.td @@ -11,16 +11,19 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_IR_FUNCTIONINTERFACES_TD_ -#define MLIR_IR_FUNCTIONINTERFACES_TD_ +#ifndef MLIR_INTERFACES_FUNCTIONINTERFACES_TD_ +#define MLIR_INTERFACES_FUNCTIONINTERFACES_TD_ include "mlir/IR/SymbolInterfaces.td" +include "mlir/Interfaces/CallInterfaces.td" //===----------------------------------------------------------------------===// // FunctionOpInterface //===----------------------------------------------------------------------===// -def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> { +def FunctionOpInterface : OpInterface<"FunctionOpInterface", [ + Symbol, CallableOpInterface + ]> { let cppNamespace = "::mlir"; let description = [{ This interfaces provides support for interacting with operations that @@ -60,53 +63,6 @@ }], "void", "setFunctionTypeAttr", (ins "::mlir::TypeAttr":$type)>, - InterfaceMethod<[{ - Get the array of argument attribute dictionaries. The method should return - an array attribute containing only dictionary attributes equal in number - to the number of function arguments. Alternatively, the method can return - null to indicate that the function has no argument attributes. - }], - "::mlir::ArrayAttr", "getArgAttrsAttr">, - InterfaceMethod<[{ - Get the array of result attribute dictionaries. The method should return - an array attribute containing only dictionary attributes equal in number - to the number of function results. Alternatively, the method can return - null to indicate that the function has no result attributes. - }], - "::mlir::ArrayAttr", "getResAttrsAttr">, - InterfaceMethod<[{ - Set the array of argument attribute dictionaries. - }], - "void", "setArgAttrsAttr", (ins "::mlir::ArrayAttr":$attrs)>, - InterfaceMethod<[{ - Set the array of result attribute dictionaries. - }], - "void", "setResAttrsAttr", (ins "::mlir::ArrayAttr":$attrs)>, - InterfaceMethod<[{ - Remove the array of argument attribute dictionaries. This is the same as - setting all argument attributes to an empty dictionary. The method should - return the removed attribute. - }], - "::mlir::Attribute", "removeArgAttrsAttr">, - InterfaceMethod<[{ - Remove the array of result attribute dictionaries. This is the same as - setting all result attributes to an empty dictionary. The method should - return the removed attribute. - }], - "::mlir::Attribute", "removeResAttrsAttr">, - - InterfaceMethod<[{ - Returns the function argument types based exclusively on - the type (to allow for this method may be called on function - declarations). - }], - "::llvm::ArrayRef<::mlir::Type>", "getArgumentTypes">, - InterfaceMethod<[{ - Returns the function result types based exclusively on - the type (to allow for this method may be called on function - declarations). - }], - "::llvm::ArrayRef<::mlir::Type>", "getResultTypes">, InterfaceMethod<[{ Returns a clone of the function type with the given argument and result types. @@ -376,9 +332,9 @@ ArrayRef argIndices, TypeRange argTypes, ArrayRef resultIndices, TypeRange resultTypes) { SmallVector argStorage, resultStorage; - TypeRange newArgTypes = function_interface_impl::insertTypesInto( + TypeRange newArgTypes = insertTypesInto( $_op.getArgumentTypes(), argIndices, argTypes, argStorage); - TypeRange newResultTypes = function_interface_impl::insertTypesInto( + TypeRange newResultTypes = insertTypesInto( $_op.getResultTypes(), resultIndices, resultTypes, resultStorage); return $_op.cloneTypeWith(newArgTypes, newResultTypes); } @@ -389,21 +345,21 @@ Type getTypeWithoutArgsAndResults( const BitVector &argIndices, const BitVector &resultIndices) { SmallVector argStorage, resultStorage; - TypeRange newArgTypes = function_interface_impl::filterTypesOut( + TypeRange newArgTypes = filterTypesOut( $_op.getArgumentTypes(), argIndices, argStorage); - TypeRange newResultTypes = function_interface_impl::filterTypesOut( + TypeRange newResultTypes = filterTypesOut( $_op.getResultTypes(), resultIndices, resultStorage); return $_op.cloneTypeWith(newArgTypes, newResultTypes); } Type getTypeWithoutArgs(const BitVector &argIndices) { SmallVector argStorage; - TypeRange newArgTypes = function_interface_impl::filterTypesOut( + TypeRange newArgTypes = filterTypesOut( $_op.getArgumentTypes(), argIndices, argStorage); return $_op.cloneTypeWith(newArgTypes, $_op.getResultTypes()); } Type getTypeWithoutResults(const BitVector &resultIndices) { SmallVector resultStorage; - TypeRange newResultTypes = function_interface_impl::filterTypesOut( + TypeRange newResultTypes = filterTypesOut( $_op.getResultTypes(), resultIndices, resultStorage); return $_op.cloneTypeWith($_op.getArgumentTypes(), newResultTypes); } @@ -604,4 +560,4 @@ let verify = "return function_interface_impl::verifyTrait(cast($_op));"; } -#endif // MLIR_IR_FUNCTIONINTERFACES_TD_ +#endif // MLIR_INTERFACES_FUNCTIONINTERFACES_TD_ diff --git a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp --- a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp +++ b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp @@ -8,9 +8,9 @@ #include "mlir/Analysis/AliasAnalysis/LocalAliasAnalysis.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Matchers.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Interfaces/ViewLikeInterface.h" #include diff --git a/mlir/lib/Analysis/CMakeLists.txt b/mlir/lib/Analysis/CMakeLists.txt --- a/mlir/lib/Analysis/CMakeLists.txt +++ b/mlir/lib/Analysis/CMakeLists.txt @@ -48,6 +48,7 @@ MLIRCallInterfaces MLIRControlFlowInterfaces MLIRDataLayoutInterfaces + MLIRFunctionInterfaces MLIRInferIntRangeInterface MLIRInferTypeOpInterface MLIRLoopLikeInterface diff --git a/mlir/lib/Conversion/MemRefToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/MemRefToSPIRV/CMakeLists.txt --- a/mlir/lib/Conversion/MemRefToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/MemRefToSPIRV/CMakeLists.txt @@ -11,6 +11,7 @@ MLIRConversionPassIncGen LINK_LIBS PUBLIC + MLIRFunctionInterfaces MLIRIR MLIRMemRefDialect MLIRPass diff --git a/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp b/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp --- a/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp +++ b/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp @@ -20,7 +20,7 @@ #include "mlir/Dialect/SPIRV/IR/TargetAndABI.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Transforms/DialectConversion.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Debug.h" diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -9,8 +9,8 @@ #include "mlir/Dialect/Async/IR/Async.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/IRMapping.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/Dialect/Async/IR/CMakeLists.txt b/mlir/lib/Dialect/Async/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Async/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Async/IR/CMakeLists.txt @@ -9,6 +9,7 @@ LINK_LIBS PUBLIC MLIRControlFlowInterfaces + MLIRFunctionInterfaces MLIRDialect MLIRInferTypeOpInterface MLIRIR diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp @@ -548,7 +548,7 @@ operands[2] = end; executeBuilder.create(executeLoc, func.getSymName(), - func.getCallableResults(), operands); + func.getResultTypes(), operands); executeBuilder.create(executeLoc, ValueRange()); }; @@ -569,7 +569,7 @@ computeFuncOperands.append(forwardedInputs.begin(), forwardedInputs.end()); b.create(computeFunc.func.getSymName(), - computeFunc.func.getCallableResults(), + computeFunc.func.getResultTypes(), computeFuncOperands); b.create(ValueRange()); @@ -616,7 +616,7 @@ appendBlockComputeOperands(operands); b.create(parallelComputeFunction.func.getSymName(), - parallelComputeFunction.func.getCallableResults(), + parallelComputeFunction.func.getResultTypes(), operands); b.create(); }; @@ -635,8 +635,7 @@ appendBlockComputeOperands(operands); b.create(asyncDispatchFunction.getSymName(), - asyncDispatchFunction.getCallableResults(), - operands); + asyncDispatchFunction.getResultTypes(), operands); // Wait for the completion of all parallel compute operations. b.create(group); @@ -694,7 +693,7 @@ auto executeBodyBuilder = [&](OpBuilder &executeBuilder, Location executeLoc, ValueRange executeArgs) { executeBuilder.create(executeLoc, compute.getSymName(), - compute.getCallableResults(), + compute.getResultTypes(), computeFuncOperands(iv)); executeBuilder.create(executeLoc, ValueRange()); }; @@ -710,7 +709,7 @@ b.create(c1, blockCount, c1, ValueRange(), loopBuilder); // Call parallel compute function for the first block in the caller thread. - b.create(compute.getSymName(), compute.getCallableResults(), + b.create(compute.getSymName(), compute.getResultTypes(), computeFuncOperands(c0)); // Wait for the completion of all async compute operations. diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp @@ -161,16 +161,15 @@ // We treat TokenType as state update marker to represent side-effects of // async computations - bool isStateful = isa(func.getCallableResults().front()); + bool isStateful = isa(func.getResultTypes().front()); std::optional retToken; if (isStateful) retToken.emplace(builder.create(TokenType::get(ctx))); llvm::SmallVector retValues; - ArrayRef resValueTypes = isStateful - ? func.getCallableResults().drop_front() - : func.getCallableResults(); + ArrayRef resValueTypes = + isStateful ? func.getResultTypes().drop_front() : func.getResultTypes(); for (auto resType : resValueTypes) retValues.emplace_back( builder.create(resType).getResult()); diff --git a/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Async/Transforms/CMakeLists.txt @@ -15,6 +15,7 @@ MLIRArithDialect MLIRAsyncDialect MLIRFuncDialect + MLIRFunctionInterfaces MLIRIR MLIRPass MLIRSCFDialect diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp --- a/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp @@ -11,7 +11,7 @@ #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Transforms/InliningUtils.h" using namespace mlir; diff --git a/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt @@ -18,6 +18,7 @@ MLIRDestinationStyleOpInterface MLIRDialect MLIRFuncDialect + MLIRFunctionInterfaces MLIRIR MLIRSparseTensorDialect MLIRTensorDialect diff --git a/mlir/lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp b/mlir/lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp --- a/mlir/lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp +++ b/mlir/lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp @@ -17,7 +17,7 @@ #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/Dialect/Transform/IR/TransformDialect.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" using namespace mlir; using namespace mlir::bufferization; diff --git a/mlir/lib/Dialect/Bufferization/TransformOps/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/TransformOps/CMakeLists.txt --- a/mlir/lib/Dialect/Bufferization/TransformOps/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/TransformOps/CMakeLists.txt @@ -11,6 +11,7 @@ MLIRIR MLIRBufferizationDialect MLIRBufferizationTransforms + MLIRFunctionInterfaces MLIRLinalgDialect MLIRParser MLIRPDLDialect diff --git a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt @@ -27,6 +27,7 @@ MLIRBufferizationDialect MLIRControlFlowInterfaces MLIRFuncDialect + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR MLIRMemRefDialect diff --git a/mlir/lib/Dialect/Func/IR/CMakeLists.txt b/mlir/lib/Dialect/Func/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Func/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Func/IR/CMakeLists.txt @@ -10,6 +10,7 @@ LINK_LIBS PUBLIC MLIRCallInterfaces MLIRControlFlowInterfaces + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR MLIRSideEffectInterfaces diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp --- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp +++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp @@ -10,13 +10,13 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/IRMapping.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/IR/Value.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Support/MathExtras.h" #include "mlir/Transforms/InliningUtils.h" #include "llvm/ADT/APFloat.h" diff --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt --- a/mlir/lib/Dialect/GPU/CMakeLists.txt +++ b/mlir/lib/Dialect/GPU/CMakeLists.txt @@ -37,6 +37,7 @@ LINK_LIBS PUBLIC MLIRArithDialect MLIRDLTIDialect + MLIRFunctionInterfaces MLIRInferIntRangeInterface MLIRIR MLIRMemRefDialect diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -20,11 +20,11 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Transforms/InliningUtils.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt --- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt +++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt @@ -32,6 +32,7 @@ MLIRCallInterfaces MLIRControlFlowInterfaces MLIRDataLayoutInterfaces + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR MLIRMemorySlotInterfaces diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -21,9 +21,9 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/Matchers.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/TypeSwitch.h" diff --git a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt @@ -21,6 +21,7 @@ MLIRBufferizationDialect MLIRDestinationStyleOpInterface MLIRDialectUtils + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR MLIRParser diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgDialect.cpp @@ -20,7 +20,7 @@ #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Parser/Parser.h" #include "mlir/Support/LLVM.h" #include "mlir/Transforms/InliningUtils.h" diff --git a/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt b/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/TransformOps/CMakeLists.txt @@ -19,6 +19,7 @@ MLIRBufferizationDialect MLIRBufferizationTransforms MLIRFuncDialect + MLIRFunctionInterfaces MLIRIR MLIRLinalgDialect MLIRLinalgTransforms diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp @@ -13,7 +13,7 @@ #include "mlir/Dialect/Linalg/TransformOps/Syntax.h" #include "mlir/Dialect/Transform/IR/MatchInterfaces.h" #include "mlir/IR/BuiltinAttributes.h" -#include "mlir/IR/FunctionImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormatVariadic.h" diff --git a/mlir/lib/Dialect/MLProgram/IR/CMakeLists.txt b/mlir/lib/Dialect/MLProgram/IR/CMakeLists.txt --- a/mlir/lib/Dialect/MLProgram/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/MLProgram/IR/CMakeLists.txt @@ -13,6 +13,7 @@ LINK_LIBS PUBLIC MLIRDialect MLIRControlFlowInterfaces + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR ) diff --git a/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp b/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp --- a/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp +++ b/mlir/lib/Dialect/MLProgram/IR/MLProgramOps.cpp @@ -8,7 +8,7 @@ #include "mlir/Dialect/MLProgram/IR/MLProgram.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/FunctionImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" using namespace mlir; using namespace mlir::ml_program; diff --git a/mlir/lib/Dialect/PDLInterp/IR/CMakeLists.txt b/mlir/lib/Dialect/PDLInterp/IR/CMakeLists.txt --- a/mlir/lib/Dialect/PDLInterp/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/PDLInterp/IR/CMakeLists.txt @@ -8,6 +8,7 @@ MLIRPDLInterpOpsIncGen LINK_LIBS PUBLIC + MLIRFunctionInterfaces MLIRIR MLIRPDLDialect MLIRInferTypeOpInterface diff --git a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp --- a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp +++ b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp @@ -10,7 +10,7 @@ #include "mlir/Dialect/PDL/IR/PDLTypes.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" using namespace mlir; using namespace mlir::pdl_interp; diff --git a/mlir/lib/Dialect/SCF/IR/CMakeLists.txt b/mlir/lib/Dialect/SCF/IR/CMakeLists.txt --- a/mlir/lib/Dialect/SCF/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/SCF/IR/CMakeLists.txt @@ -13,6 +13,7 @@ MLIRArithDialect MLIRBufferizationDialect MLIRControlFlowDialect + MLIRFunctionInterfaces MLIRIR MLIRLoopLikeInterface MLIRSideEffectInterfaces diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -15,10 +15,10 @@ #include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/BuiltinAttributes.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IRMapping.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Support/MathExtras.h" #include "mlir/Transforms/InliningUtils.h" #include "llvm/ADT/MapVector.h" diff --git a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt --- a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt @@ -37,6 +37,7 @@ LINK_LIBS PUBLIC MLIRControlFlowInterfaces + MLIRFunctionInterfaces MLIRIR MLIRParser MLIRSideEffectInterfaces diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -23,11 +23,11 @@ #include "mlir/Dialect/SPIRV/IR/TargetAndABI.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpImplementation.h" #include "mlir/IR/Operation.h" #include "mlir/IR/TypeUtilities.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" @@ -1011,26 +1011,6 @@ state.addRegion(); } -// CallableOpInterface -Region *spirv::FuncOp::getCallableRegion() { - return isExternal() ? nullptr : &getBody(); -} - -// CallableOpInterface -ArrayRef spirv::FuncOp::getCallableResults() { - return getFunctionType().getResults(); -} - -// CallableOpInterface -::mlir::ArrayAttr spirv::FuncOp::getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); -} - -// CallableOpInterface -::mlir::ArrayAttr spirv::FuncOp::getCallableResAttrs() { - return getResAttrs().value_or(nullptr); -} - //===----------------------------------------------------------------------===// // spirv.GLFClampOp //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp @@ -10,9 +10,9 @@ #include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h" #include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Operation.h" #include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include using namespace mlir; diff --git a/mlir/lib/Dialect/Shape/IR/CMakeLists.txt b/mlir/lib/Dialect/Shape/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Shape/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Shape/IR/CMakeLists.txt @@ -18,6 +18,7 @@ MLIRControlFlowInterfaces MLIRDialect MLIRFuncDialect + MLIRFunctionInterfaces MLIRInferTypeOpInterface MLIRIR MLIRSideEffectInterfaces diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -17,10 +17,10 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/DialectImplementation.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/Matchers.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/TypeUtilities.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Transforms/InliningUtils.h" #include "llvm/ADT/SetOperations.h" #include "llvm/ADT/SmallString.h" diff --git a/mlir/lib/Dialect/Transform/IR/CMakeLists.txt b/mlir/lib/Dialect/Transform/IR/CMakeLists.txt --- a/mlir/lib/Dialect/Transform/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Transform/IR/CMakeLists.txt @@ -13,6 +13,7 @@ LINK_LIBS PUBLIC MLIRCastInterfaces + MLIRFunctionInterfaces MLIRIR MLIRLLVMCommonConversion MLIRLLVMDialect diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp --- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp @@ -18,10 +18,10 @@ #include "mlir/Dialect/Transform/IR/TransformTypes.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dominance.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/PatternMatch.h" #include "mlir/IR/Verifier.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "mlir/Pass/PassRegistry.h" diff --git a/mlir/lib/Dialect/Transform/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Transform/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Transform/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Transform/Transforms/CMakeLists.txt @@ -7,6 +7,7 @@ MLIRTransformDialectTransformsIncGen LINK_LIBS PUBLIC + MLIRFunctionInterfaces MLIRTransformDialect MLIRIR MLIRPass diff --git a/mlir/lib/Dialect/Transform/Transforms/InferEffects.cpp b/mlir/lib/Dialect/Transform/Transforms/InferEffects.cpp --- a/mlir/lib/Dialect/Transform/Transforms/InferEffects.cpp +++ b/mlir/lib/Dialect/Transform/Transforms/InferEffects.cpp @@ -10,8 +10,8 @@ #include "mlir/Dialect/Transform/Transforms/Passes.h" #include "mlir/Dialect/Transform/IR/TransformInterfaces.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Visitors.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "llvm/ADT/DenseSet.h" diff --git a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp --- a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp +++ b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp @@ -15,9 +15,9 @@ #include "mlir/Dialect/Transform/IR/TransformDialect.h" #include "mlir/Dialect/Transform/IR/TransformInterfaces.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Verifier.h" #include "mlir/IR/Visitors.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Parser/Parser.h" #include "mlir/Pass/Pass.h" #include "mlir/Support/FileUtilities.h" diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp --- a/mlir/lib/IR/BuiltinTypes.cpp +++ b/mlir/lib/IR/BuiltinTypes.cpp @@ -14,9 +14,8 @@ #include "mlir/IR/BuiltinDialect.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" -#include "mlir/IR/OpImplementation.h" #include "mlir/IR/TensorEncoding.h" +#include "mlir/IR/TypeUtilities.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/Sequence.h" @@ -179,10 +178,10 @@ ArrayRef argIndices, TypeRange argTypes, ArrayRef resultIndices, TypeRange resultTypes) { SmallVector argStorage, resultStorage; - TypeRange newArgTypes = function_interface_impl::insertTypesInto( - getInputs(), argIndices, argTypes, argStorage); - TypeRange newResultTypes = function_interface_impl::insertTypesInto( - getResults(), resultIndices, resultTypes, resultStorage); + TypeRange newArgTypes = + insertTypesInto(getInputs(), argIndices, argTypes, argStorage); + TypeRange newResultTypes = + insertTypesInto(getResults(), resultIndices, resultTypes, resultStorage); return clone(newArgTypes, newResultTypes); } @@ -191,10 +190,9 @@ FunctionType::getWithoutArgsAndResults(const BitVector &argIndices, const BitVector &resultIndices) { SmallVector argStorage, resultStorage; - TypeRange newArgTypes = function_interface_impl::filterTypesOut( - getInputs(), argIndices, argStorage); - TypeRange newResultTypes = function_interface_impl::filterTypesOut( - getResults(), resultIndices, resultStorage); + TypeRange newArgTypes = filterTypesOut(getInputs(), argIndices, argStorage); + TypeRange newResultTypes = + filterTypesOut(getResults(), resultIndices, resultStorage); return clone(newArgTypes, newResultTypes); } diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt --- a/mlir/lib/IR/CMakeLists.txt +++ b/mlir/lib/IR/CMakeLists.txt @@ -17,8 +17,6 @@ DialectResourceBlobManager.cpp Dominance.cpp ExtensibleDialect.cpp - FunctionImplementation.cpp - FunctionInterfaces.cpp IntegerSet.cpp Location.cpp MLIRContext.cpp diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -172,3 +172,33 @@ Type ResultElementTypeIterator::mapElement(Value value) const { return llvm::cast(value.getType()).getElementType(); } + +TypeRange mlir::insertTypesInto(TypeRange oldTypes, ArrayRef indices, + TypeRange newTypes, + SmallVectorImpl &storage) { + assert(indices.size() == newTypes.size() && + "mismatch between indice and type count"); + if (indices.empty()) + return oldTypes; + + auto fromIt = oldTypes.begin(); + for (auto it : llvm::zip(indices, newTypes)) { + const auto toIt = oldTypes.begin() + std::get<0>(it); + storage.append(fromIt, toIt); + storage.push_back(std::get<1>(it)); + fromIt = toIt; + } + storage.append(fromIt, oldTypes.end()); + return storage; +} + +TypeRange mlir::filterTypesOut(TypeRange types, const BitVector &indices, + SmallVectorImpl &storage) { + if (indices.none()) + return types; + + for (unsigned i = 0, e = types.size(); i < e; ++i) + if (!indices[i]) + storage.emplace_back(types[i]); + return storage; +} diff --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt --- a/mlir/lib/Interfaces/CMakeLists.txt +++ b/mlir/lib/Interfaces/CMakeLists.txt @@ -6,6 +6,8 @@ DataLayoutInterfaces.cpp DerivedAttributeOpInterface.cpp DestinationStyleOpInterface.cpp + FunctionImplementation.cpp + FunctionInterfaces.cpp InferIntRangeInterface.cpp InferTypeOpInterface.cpp LoopLikeInterface.cpp @@ -43,9 +45,38 @@ add_mlir_interface_library(DataLayoutInterfaces) add_mlir_interface_library(DerivedAttributeOpInterface) add_mlir_interface_library(DestinationStyleOpInterface) + +add_mlir_library(MLIRFunctionInterfaces + FunctionInterfaces.cpp + FunctionImplementation.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces + + DEPENDS + MLIRFunctionInterfacesIncGen + + LINK_LIBS PUBLIC + MLIRIR +) + add_mlir_interface_library(InferIntRangeInterface) add_mlir_interface_library(InferTypeOpInterface) -add_mlir_interface_library(LoopLikeInterface) + +add_mlir_library(MLIRLoopLikeInterface + LoopLikeInterface.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces + + DEPENDS + MLIRLoopLikeInterfaceIncGen + + LINK_LIBS PUBLIC + MLIRIR + MLIRFunctionInterfaces +) + add_mlir_interface_library(MemorySlotInterfaces) add_mlir_interface_library(ParallelCombiningOpInterface) add_mlir_interface_library(RuntimeVerifiableOpInterface) diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/Interfaces/FunctionImplementation.cpp rename from mlir/lib/IR/FunctionImplementation.cpp rename to mlir/lib/Interfaces/FunctionImplementation.cpp --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/Interfaces/FunctionImplementation.cpp @@ -6,10 +6,10 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/FunctionImplementation.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/IR/Builders.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/SymbolTable.h" +#include "mlir/Interfaces/FunctionInterfaces.h" using namespace mlir; diff --git a/mlir/lib/IR/FunctionInterfaces.cpp b/mlir/lib/Interfaces/FunctionInterfaces.cpp rename from mlir/lib/IR/FunctionInterfaces.cpp rename to mlir/lib/Interfaces/FunctionInterfaces.cpp --- a/mlir/lib/IR/FunctionInterfaces.cpp +++ b/mlir/lib/Interfaces/FunctionInterfaces.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" using namespace mlir; @@ -14,7 +14,7 @@ // Tablegen Interface Definitions //===----------------------------------------------------------------------===// -#include "mlir/IR/FunctionOpInterfaces.cpp.inc" +#include "mlir/Interfaces/FunctionOpInterfaces.cpp.inc" //===----------------------------------------------------------------------===// // Function Arguments and Results. @@ -317,36 +317,6 @@ op.setFunctionTypeAttr(TypeAttr::get(newType)); } -TypeRange function_interface_impl::insertTypesInto( - TypeRange oldTypes, ArrayRef indices, TypeRange newTypes, - SmallVectorImpl &storage) { - assert(indices.size() == newTypes.size() && - "mismatch between indice and type count"); - if (indices.empty()) - return oldTypes; - - auto fromIt = oldTypes.begin(); - for (auto it : llvm::zip(indices, newTypes)) { - const auto toIt = oldTypes.begin() + std::get<0>(it); - storage.append(fromIt, toIt); - storage.push_back(std::get<1>(it)); - fromIt = toIt; - } - storage.append(fromIt, oldTypes.end()); - return storage; -} - -TypeRange function_interface_impl::filterTypesOut( - TypeRange types, const BitVector &indices, SmallVectorImpl &storage) { - if (indices.none()) - return types; - - for (unsigned i = 0, e = types.size(); i < e; ++i) - if (!indices[i]) - storage.emplace_back(types[i]); - return storage; -} - //===----------------------------------------------------------------------===// // Function type signature. //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Interfaces/LoopLikeInterface.cpp b/mlir/lib/Interfaces/LoopLikeInterface.cpp --- a/mlir/lib/Interfaces/LoopLikeInterface.cpp +++ b/mlir/lib/Interfaces/LoopLikeInterface.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Interfaces/LoopLikeInterface.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "llvm/ADT/DenseSet.h" using namespace mlir; diff --git a/mlir/lib/Tools/mlir-lsp-server/CMakeLists.txt b/mlir/lib/Tools/mlir-lsp-server/CMakeLists.txt --- a/mlir/lib/Tools/mlir-lsp-server/CMakeLists.txt +++ b/mlir/lib/Tools/mlir-lsp-server/CMakeLists.txt @@ -9,6 +9,7 @@ LINK_LIBS PUBLIC MLIRBytecodeWriter + MLIRFunctionInterfaces MLIRIR MLIRLspServerSupportLib MLIRParser diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -12,8 +12,8 @@ #include "mlir/AsmParser/AsmParserState.h" #include "mlir/AsmParser/CodeComplete.h" #include "mlir/Bytecode/BytecodeWriter.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Operation.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Parser/Parser.h" #include "mlir/Tools/lsp-server-support/Logging.h" #include "mlir/Tools/lsp-server-support/SourceMgrUtils.h" diff --git a/mlir/lib/Transforms/CMakeLists.txt b/mlir/lib/Transforms/CMakeLists.txt --- a/mlir/lib/Transforms/CMakeLists.txt +++ b/mlir/lib/Transforms/CMakeLists.txt @@ -29,6 +29,7 @@ LINK_LIBS PUBLIC MLIRAnalysis MLIRCopyOpInterface + MLIRFunctionInterfaces MLIRLoopLikeInterface MLIRMemorySlotInterfaces MLIRPass diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp --- a/mlir/lib/Transforms/RemoveDeadValues.cpp +++ b/mlir/lib/Transforms/RemoveDeadValues.cpp @@ -37,7 +37,6 @@ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/Dialect.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IRMapping.h" #include "mlir/IR/OperationSupport.h" #include "mlir/IR/SymbolTable.h" @@ -46,6 +45,7 @@ #include "mlir/IR/Visitors.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Interfaces/SideEffectInterfaces.h" #include "mlir/Pass/Pass.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/lib/Transforms/Utils/CMakeLists.txt b/mlir/lib/Transforms/Utils/CMakeLists.txt --- a/mlir/lib/Transforms/Utils/CMakeLists.txt +++ b/mlir/lib/Transforms/Utils/CMakeLists.txt @@ -17,6 +17,7 @@ LINK_LIBS PUBLIC MLIRAnalysis MLIRControlFlowInterfaces + MLIRFunctionInterfaces MLIRLoopLikeInterface MLIRSideEffectInterfaces MLIRRewrite diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -10,9 +10,9 @@ #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/IRMapping.h" #include "mlir/IR/Iterators.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Rewrite/PatternApplicator.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -166,7 +166,7 @@ SmallVector argAttrs( callable.getCallableRegion()->getNumArguments(), builder.getDictionaryAttr({})); - if (ArrayAttr arrayAttr = callable.getCallableArgAttrs()) { + if (ArrayAttr arrayAttr = callable.getArgAttrsAttr()) { assert(arrayAttr.size() == argAttrs.size()); for (auto [idx, attr] : llvm::enumerate(arrayAttr)) argAttrs[idx] = cast(attr); @@ -191,7 +191,7 @@ // Unpack the result attributes if there are any. SmallVector resAttrs(results.size(), builder.getDictionaryAttr({})); - if (ArrayAttr arrayAttr = callable.getCallableResAttrs()) { + if (ArrayAttr arrayAttr = callable.getResAttrsAttr()) { assert(arrayAttr.size() == resAttrs.size()); for (auto [idx, attr] : llvm::enumerate(arrayAttr)) resAttrs[idx] = cast(attr); @@ -434,7 +434,7 @@ if (src->empty()) return failure(); auto *entryBlock = &src->front(); - ArrayRef callableResultTypes = callable.getCallableResults(); + ArrayRef callableResultTypes = callable.getResultTypes(); // Make sure that the number of arguments and results matchup between the call // and the region. diff --git a/mlir/test/Dialect/LLVMIR/parameter-attrs-invalid.mlir b/mlir/test/Dialect/LLVMIR/parameter-attrs-invalid.mlir --- a/mlir/test/Dialect/LLVMIR/parameter-attrs-invalid.mlir +++ b/mlir/test/Dialect/LLVMIR/parameter-attrs-invalid.mlir @@ -195,7 +195,7 @@ // Result attributes -// expected-error@below {{cannot attach result attributes to functions with a void return}} +// expected-error@below {{expects result attribute array to have the same number of elements as the number of function results, got 1, but expected 0}} llvm.func @void_def() -> (!llvm.void {llvm.noundef}) // ----- diff --git a/mlir/test/lib/Analysis/CMakeLists.txt b/mlir/test/lib/Analysis/CMakeLists.txt --- a/mlir/test/lib/Analysis/CMakeLists.txt +++ b/mlir/test/lib/Analysis/CMakeLists.txt @@ -22,6 +22,7 @@ LINK_LIBS PUBLIC MLIRAffineDialect MLIRAnalysis + MLIRFunctionInterfaces MLIRMemRefDialect MLIRPass MLIRTestDialect diff --git a/mlir/test/lib/Analysis/TestAliasAnalysis.cpp b/mlir/test/lib/Analysis/TestAliasAnalysis.cpp --- a/mlir/test/lib/Analysis/TestAliasAnalysis.cpp +++ b/mlir/test/lib/Analysis/TestAliasAnalysis.cpp @@ -14,7 +14,7 @@ #include "TestAliasAnalysis.h" #include "mlir/Analysis/AliasAnalysis.h" #include "mlir/Analysis/AliasAnalysis/LocalAliasAnalysis.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Analysis/TestCFGLoopInfo.cpp b/mlir/test/lib/Analysis/TestCFGLoopInfo.cpp --- a/mlir/test/lib/Analysis/TestCFGLoopInfo.cpp +++ b/mlir/test/lib/Analysis/TestCFGLoopInfo.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/CFGLoopInfo.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Analysis/TestMatchReduction.cpp b/mlir/test/lib/Analysis/TestMatchReduction.cpp --- a/mlir/test/lib/Analysis/TestMatchReduction.cpp +++ b/mlir/test/lib/Analysis/TestMatchReduction.cpp @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// #include "mlir/Analysis/SliceAnalysis.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -70,6 +70,7 @@ MLIRDialect MLIRDLTIDialect MLIRFuncDialect + MLIRFunctionInterfaces MLIRFuncTransforms MLIRIR MLIRInferIntRangeInterface diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -19,7 +19,6 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Diagnostics.h" #include "mlir/IR/ExtensibleDialect.h" -#include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/MLIRContext.h" #include "mlir/IR/ODSSupport.h" #include "mlir/IR/OperationSupport.h" @@ -27,6 +26,7 @@ #include "mlir/IR/TypeUtilities.h" #include "mlir/IR/Verifier.h" #include "mlir/Interfaces/CallInterfaces.h" +#include "mlir/Interfaces/FunctionImplementation.h" #include "mlir/Interfaces/InferIntRangeInterface.h" #include "mlir/Support/LogicalResult.h" #include "mlir/Transforms/FoldUtils.h" diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -14,7 +14,7 @@ include "mlir/Dialect/DLTI/DLTIBase.td" include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td" include "mlir/IR/EnumAttr.td" -include "mlir/IR/FunctionInterfaces.td" +include "mlir/Interfaces/FunctionInterfaces.td" include "mlir/IR/OpBase.td" include "mlir/IR/OpAsmInterface.td" include "mlir/IR/PatternBase.td" @@ -525,8 +525,7 @@ }]; } -def ConversionFuncOp : TEST_Op<"conversion_func_op", [CallableOpInterface, - FunctionOpInterface]> { +def ConversionFuncOp : TEST_Op<"conversion_func_op", [FunctionOpInterface]> { let arguments = (ins SymbolNameAttr:$sym_name, TypeAttrOf:$function_type, OptionalAttr:$arg_attrs, @@ -536,7 +535,7 @@ let extraClassDeclaration = [{ //===------------------------------------------------------------------===// - // CallableOpInterface + // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the region on the current operation that is callable. This may @@ -546,28 +545,6 @@ return isExternal() ? nullptr : &getBody(); } - /// Returns the results types that the callable region produces when - /// executed. - ::mlir::ArrayRef<::mlir::Type> getCallableResults() { - return getFunctionType().getResults(); - } - - /// Returns the argument attributes for all callable region arguments or - /// null if there are none. - ::mlir::ArrayAttr getCallableArgAttrs() { - return getArgAttrs().value_or(nullptr); - } - - /// Returns the result attributes for all callable region results or - /// null if there are none. - ::mlir::ArrayAttr getCallableResAttrs() { - return getResAttrs().value_or(nullptr); - } - - //===------------------------------------------------------------------===// - // FunctionOpInterface Methods - //===------------------------------------------------------------------===// - /// Returns the argument types of this async function. ::mlir::ArrayRef<::mlir::Type> getArgumentTypes() { return getFunctionType().getInputs(); @@ -592,14 +569,11 @@ let extraClassDeclaration = [{ ::mlir::Region *getCallableRegion() { return &getBody(); } - ::llvm::ArrayRef<::mlir::Type> getCallableResults() { + ::llvm::ArrayRef<::mlir::Type> getResultTypes() { return ::llvm::cast<::mlir::FunctionType>(getType()).getResults(); } - ::mlir::ArrayAttr getCallableArgAttrs() { - return nullptr; - } - ::mlir::ArrayAttr getCallableResAttrs() { - return nullptr; + ::llvm::ArrayRef<::mlir::Type> getArgumentTypes() { + return ::llvm::cast<::mlir::FunctionType>(getType()).getInputs(); } }]; } diff --git a/mlir/test/lib/IR/CMakeLists.txt b/mlir/test/lib/IR/CMakeLists.txt --- a/mlir/test/lib/IR/CMakeLists.txt +++ b/mlir/test/lib/IR/CMakeLists.txt @@ -30,6 +30,7 @@ MLIRPass MLIRBytecodeReader MLIRBytecodeWriter + MLIRFunctionInterfaces MLIRTestDialect ) diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -8,8 +8,8 @@ #include "mlir/Dialect/Arith/IR/Arith.h" #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Matchers.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/mlir/test/lib/IR/TestVisitors.cpp b/mlir/test/lib/IR/TestVisitors.cpp --- a/mlir/test/lib/IR/TestVisitors.cpp +++ b/mlir/test/lib/IR/TestVisitors.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "mlir/IR/BuiltinOps.h" -#include "mlir/IR/FunctionInterfaces.h" #include "mlir/IR/Iterators.h" +#include "mlir/Interfaces/FunctionInterfaces.h" #include "mlir/Pass/Pass.h" using namespace mlir; diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -225,7 +225,7 @@ td_file = "include/mlir/IR/BuiltinOps.td", deps = [ ":BuiltinDialectTdFiles", - ":FunctionInterfacesTdFiles", + ":OpBaseTdFiles", ], ) @@ -267,9 +267,12 @@ td_library( name = "FunctionInterfacesTdFiles", - srcs = ["include/mlir/IR/FunctionInterfaces.td"], + srcs = ["include/mlir/Interfaces/FunctionInterfaces.td"], includes = ["include"], - deps = [":OpBaseTdFiles"], + deps = [ + ":CallInterfacesTdFiles", + ":OpBaseTdFiles", + ], ) gentbl_cc_library( @@ -277,17 +280,36 @@ tbl_outs = [ ( ["-gen-op-interface-decls"], - "include/mlir/IR/FunctionOpInterfaces.h.inc", + "include/mlir/Interfaces/FunctionOpInterfaces.h.inc", ), ( ["-gen-op-interface-defs"], - "include/mlir/IR/FunctionOpInterfaces.cpp.inc", + "include/mlir/Interfaces/FunctionOpInterfaces.cpp.inc", ), ], tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/FunctionInterfaces.td", + td_file = "include/mlir/Interfaces/FunctionInterfaces.td", deps = [ - ":OpBaseTdFiles", + ":FunctionInterfacesTdFiles", + ], +) + +cc_library( + name = "FunctionOpInterfaces", + srcs = [ + "lib/Interfaces/FunctionImplementation.cpp", + "lib/Interfaces/FunctionInterfaces.cpp", + ], + hdrs = [ + "include/mlir/Interfaces/FunctionImplementation.h", + "include/mlir/Interfaces/FunctionInterfaces.h", + ], + includes = ["include"], + deps = [ + ":CallOpInterfaces", + ":FunctionInterfacesIncGen", + ":IR", + "//llvm:Support", ], ) @@ -324,7 +346,6 @@ ":BytecodeOpInterfaceIncGen", ":CallOpInterfacesIncGen", ":DataLayoutInterfacesIncGen", - ":FunctionInterfacesIncGen", ":InferTypeOpInterfaceIncGen", ":OpAsmInterfaceIncGen", ":RegionKindInterfaceIncGen", @@ -3278,6 +3299,7 @@ deps = [ ":AsyncOpsIncGen", ":ControlFlowInterfaces", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":SideEffectInterfaces", @@ -3608,6 +3630,7 @@ ":ControlFlowDialect", ":ControlFlowInterfaces", ":FuncDialect", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":LoopLikeInterface", @@ -3686,6 +3709,7 @@ hdrs = ["include/mlir/Interfaces/LoopLikeInterface.h"], includes = ["include"], deps = [ + ":FunctionOpInterfaces", ":IR", ":LoopLikeInterfaceIncGen", "//llvm:Support", @@ -3853,6 +3877,7 @@ ":ControlFlowInterfaces", ":Dialect", ":FuncDialect", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":MLIRShapeCanonicalizationIncGen", @@ -4044,6 +4069,7 @@ ":ControlFlowDialect", ":ControlFlowInterfaces", ":FuncIncGen", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":SideEffectInterfaces", @@ -4435,6 +4461,7 @@ deps = [ ":AsmParser", ":BytecodeWriter", + ":FunctionOpInterfaces", ":IR", ":MlirLspServerSupportLib", ":Parser", @@ -4615,6 +4642,7 @@ ":CallOpInterfaces", ":ControlFlowInterfaces", ":DataLayoutInterfaces", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":LLVMDialectInterfaceIncGen", @@ -4815,6 +4843,7 @@ deps = [ ":ArithDialect", ":DLTIDialect", + ":FunctionOpInterfaces", ":GPUBaseIncGen", ":GPUCompilationAttrInterfacesIncGen", ":GPUOpsIncGen", @@ -5902,6 +5931,7 @@ ]), includes = ["include"], deps = [ + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":PDLDialect", @@ -6109,6 +6139,7 @@ deps = [ ":CommonFolders", ":ControlFlowInterfaces", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":Parser", @@ -6704,6 +6735,7 @@ includes = ["include"], deps = [ ":ControlFlowInterfaces", + ":FunctionOpInterfaces", ":IR", ":LoopLikeInterface", ":MemorySlotInterfaces", @@ -7030,6 +7062,7 @@ deps = [ ":Analysis", ":ControlFlowInterfaces", + ":FunctionOpInterfaces", ":IR", ":LoopLikeInterface", ":MemorySlotInterfaces", @@ -7068,6 +7101,7 @@ ":ComplexDialect", ":ConversionPassIncGen", ":FuncDialect", + ":FunctionOpInterfaces", ":GPUDialect", ":GPUTransforms", ":IR", @@ -7357,6 +7391,7 @@ ":ArithDialect", ":ConversionPassIncGen", ":FuncDialect", + ":FunctionOpInterfaces", ":IR", ":MemRefDialect", ":Pass", @@ -7668,6 +7703,7 @@ ":CallOpInterfaces", ":ControlFlowInterfaces", ":DataLayoutInterfaces", + ":FunctionOpInterfaces", ":IR", ":InferIntRangeInterface", ":LoopLikeInterface", @@ -9718,6 +9754,7 @@ ":DestinationStyleOpInterface", ":DialectUtils", ":FuncDialect", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":LinalgEnumsIncGen", @@ -9758,6 +9795,7 @@ ":BufferizationTransforms", ":DialectUtils", ":FuncDialect", + ":FunctionOpInterfaces", ":GPUDialect", ":IR", ":LinalgDialect", @@ -10689,6 +10727,7 @@ ":CastInterfaces", ":ControlFlowInterfaces", ":ConvertToLLVM", + ":FunctionOpInterfaces", ":IR", ":LLVMCommonConversion", ":LLVMDialect", @@ -10787,6 +10826,7 @@ hdrs = glob(["include/mlir/Dialect/Transform/Transforms/*.h"]), deps = [ ":Analysis", + ":FunctionOpInterfaces", ":IR", ":Parser", ":Pass", @@ -11708,6 +11748,7 @@ includes = ["include"], deps = [ ":ControlFlowInterfaces", + ":FunctionOpInterfaces", ":IR", ":MLProgramAttributesIncGen", ":MLProgramOpsIncGen", @@ -11870,6 +11911,7 @@ ":BufferizationEnumsIncGen", ":BufferizationTransformOpsIncGen", ":BufferizationTransforms", + ":FunctionOpInterfaces", ":IR", ":LinalgDialect", ":MemRefDialect", @@ -11926,6 +11968,7 @@ ":CopyOpInterface", ":DestinationStyleOpInterface", ":FuncDialect", + ":FunctionOpInterfaces", ":IR", ":InferTypeOpInterface", ":MemRefDialect", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel @@ -58,6 +58,7 @@ ":ToyOpsIncGen", "//llvm:Support", "//mlir:Analysis", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:Parser", "//mlir:SideEffectInterfaces", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel @@ -74,6 +74,7 @@ ":ToyOpsIncGen", "//llvm:Support", "//mlir:Analysis", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:Parser", "//mlir:Pass", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel @@ -97,6 +97,7 @@ "//llvm:Support", "//mlir:Analysis", "//mlir:CastInterfaces", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:Parser", "//mlir:Pass", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel @@ -104,6 +104,7 @@ "//mlir:CastInterfaces", "//mlir:FuncDialect", "//mlir:FuncExtensions", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:MemRefDialect", "//mlir:Parser", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel @@ -113,6 +113,7 @@ "//mlir:FuncDialect", "//mlir:FuncExtensions", "//mlir:FuncToLLVM", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:LLVMCommonConversion", "//mlir:LLVMDialect", diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel @@ -113,6 +113,7 @@ "//mlir:FuncDialect", "//mlir:FuncExtensions", "//mlir:FuncToLLVM", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:LLVMCommonConversion", "//mlir:LLVMDialect", diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -96,6 +96,7 @@ "//mlir:Analysis", "//mlir:ControlFlowInterfaces", "//mlir:FuncDialect", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:MemRefDialect", "//mlir:Pass", @@ -391,6 +392,7 @@ "//mlir:DialectUtils", "//mlir:FuncDialect", "//mlir:FuncTransforms", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:InferIntRangeInterface", "//mlir:InferTypeOpInterface", @@ -419,6 +421,7 @@ "//mlir:BytecodeReader", "//mlir:BytecodeWriter", "//mlir:FuncDialect", + "//mlir:FunctionOpInterfaces", "//mlir:IR", "//mlir:LinalgDialect", "//mlir:Parser",