[mlir] Move FunctionInterfaces to Interfaces directory and inherit from CallableOpInterface
Functions are always callable operations and thus every operation implementing the `FunctionOpInterface` also implements the `CallableOpInterface`. The only exception was the FuncOp in the toy example. To make implementation of the `FunctionOpInterface` easier, this commit lets `FunctionOpInterface` inherit from `CallableOpInterface` and merges some of their methods. More precisely, the `CallableOpInterface` has methods to get the argument and result attributes and a method to get the result types of the callable region. These methods are always implemented the same way as their analogues in `FunctionOpInterface` and thus this commit moves all the argument and result attribute handling methods to the callable interface as well as the methods to get the argument and result types. The `FuntionOpInterface` then does not have to declare them as well, but just inherits them from the `CallableOpInterface`. Adding the inheritance relation also required to move the `FunctionOpInterface` from the IR directory to the Interfaces directory since IR should not depend on Interfaces. Reviewed By: jpienaar, springerm Differential Revision: https://reviews.llvm.org/D157988
This commit is contained in:
@@ -731,9 +731,14 @@ interface section goes as follows:
|
||||
- `void setCalleeFromCallable(CallInterfaceCallable)`
|
||||
* `CallableOpInterface` - Used to represent the target callee of call.
|
||||
- `Region * getCallableRegion()`
|
||||
- `ArrayRef<Type> getCallableResults()`
|
||||
- `ArrayAttr getCallableArgAttrs()`
|
||||
- `ArrayAttr getCallableResAttrs()`
|
||||
- `ArrayRef<Type> getArgumentTypes()`
|
||||
- `ArrayRef<Type> getResultsTypes()`
|
||||
- `ArrayAttr getArgAttrsAttr()`
|
||||
- `ArrayAttr getResAttrsAttr()`
|
||||
- `void setArgAttrsAttr(ArrayAttr)`
|
||||
- `void setResAttrsAttr(ArrayAttr)`
|
||||
- `Attribute removeArgAttrsAttr()`
|
||||
- `Attribute removeResAttrsAttr()`
|
||||
|
||||
##### RegionKindInterfaces
|
||||
|
||||
|
||||
@@ -165,22 +165,6 @@ GenericCallOp. This means that we just need to provide a definition:
|
||||
/// 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<Type> 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
|
||||
|
||||
@@ -20,6 +20,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
target_link_libraries(toyc-ch2
|
||||
PRIVATE
|
||||
MLIRAnalysis
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
MLIRSideEffectInterfaces
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@ def FuncOp : Toy_Op<"func", [
|
||||
"StringRef":$name, "FunctionType":$type,
|
||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
|
||||
>];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
// FunctionOpInterface Methods
|
||||
@@ -154,7 +155,10 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -27,6 +27,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
target_link_libraries(toyc-ch3
|
||||
PRIVATE
|
||||
MLIRAnalysis
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
MLIRPass
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,6 +31,7 @@ target_link_libraries(toyc-ch4
|
||||
MLIRAnalysis
|
||||
MLIRCastInterfaces
|
||||
MLIRCallInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
MLIRPass
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 CastOp : Toy_Op<"cast", [
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def FuncOp : Toy_Op<"func", [
|
||||
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
|
||||
IsolatedFromAbove
|
||||
FunctionOpInterface, IsolatedFromAbove
|
||||
]> {
|
||||
let summary = "user defined function operation";
|
||||
let description = [{
|
||||
@@ -173,6 +172,7 @@ def FuncOp : Toy_Op<"func", [
|
||||
"StringRef":$name, "FunctionType":$type,
|
||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
|
||||
>];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
// FunctionOpInterface Methods
|
||||
@@ -183,7 +183,10 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
}
|
||||
|
||||
@@ -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 @@ void FuncOp::print(mlir::OpAsmPrinter &p) {
|
||||
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<mlir::Type> 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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -36,6 +36,7 @@ target_link_libraries(toyc-ch5
|
||||
MLIRAnalysis
|
||||
MLIRCallInterfaces
|
||||
MLIRCastInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
MLIRPass
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 CastOp : Toy_Op<"cast", [
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def FuncOp : Toy_Op<"func", [
|
||||
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
|
||||
IsolatedFromAbove
|
||||
FunctionOpInterface, IsolatedFromAbove
|
||||
]> {
|
||||
let summary = "user defined function operation";
|
||||
let description = [{
|
||||
@@ -183,6 +182,9 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
/// Returns the region on the function operation that is callable.
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
|
||||
@@ -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 @@ void FuncOp::print(mlir::OpAsmPrinter &p) {
|
||||
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<mlir::Type> 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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -50,6 +50,7 @@ target_link_libraries(toyc-ch6
|
||||
MLIRCallInterfaces
|
||||
MLIRCastInterfaces
|
||||
MLIRExecutionEngine
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLLVMCommonConversion
|
||||
MLIRLLVMDialect
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 CastOp : Toy_Op<"cast", [
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def FuncOp : Toy_Op<"func", [
|
||||
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
|
||||
IsolatedFromAbove
|
||||
FunctionOpInterface, IsolatedFromAbove
|
||||
]> {
|
||||
let summary = "user defined function operation";
|
||||
let description = [{
|
||||
@@ -183,6 +182,9 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
/// Returns the region on the function operation that is callable.
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
|
||||
@@ -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 @@ void FuncOp::print(mlir::OpAsmPrinter &p) {
|
||||
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<mlir::Type> 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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -49,6 +49,7 @@ target_link_libraries(toyc-ch7
|
||||
MLIRCallInterfaces
|
||||
MLIRCastInterfaces
|
||||
MLIRExecutionEngine
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLLVMCommonConversion
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 CastOp : Toy_Op<"cast", [
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def FuncOp : Toy_Op<"func", [
|
||||
DeclareOpInterfaceMethods<CallableOpInterface>, FunctionOpInterface,
|
||||
IsolatedFromAbove
|
||||
FunctionOpInterface, IsolatedFromAbove
|
||||
]> {
|
||||
let summary = "user defined function operation";
|
||||
let description = [{
|
||||
@@ -207,6 +206,8 @@ def FuncOp : Toy_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
|
||||
@@ -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 @@ void FuncOp::print(mlir::OpAsmPrinter &p) {
|
||||
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<mlir::Type> 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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -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 <memory>
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ include "mlir/Interfaces/InferTypeOpInterface.td"
|
||||
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_ExecuteOp :
|
||||
}
|
||||
|
||||
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 @@ def Async_FuncOp : Async_Op<"func",
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
// CallableOpInterface
|
||||
// FunctionOpInterface Methods
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// Returns the region on the current operation that is callable. This may
|
||||
@@ -163,27 +162,6 @@ def Async_FuncOp : Async_Op<"func",
|
||||
::mlir::Region *getCallableRegion() { return isExternal() ? nullptr
|
||||
: &getBody(); }
|
||||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<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.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ include "mlir/IR/OpAsmInterface.td"
|
||||
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 ConstantOp : Func_Op<"constant",
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
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 @@ def FuncOp : Func_Op<"func", [
|
||||
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 @@ def FuncOp : Func_Op<"func", [
|
||||
/// function.
|
||||
::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }
|
||||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<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 function.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -20,7 +20,7 @@ include "mlir/Dialect/GPU/IR/CompilationAttrs.td"
|
||||
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 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> 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"; }
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -17,7 +17,7 @@ include "mlir/Dialect/LLVMIR/LLVMAttrDefs.td"
|
||||
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_ComdatOp : LLVM_Op<"comdat", [NoTerminator, NoRegionArguments, SymbolTa
|
||||
}
|
||||
|
||||
def LLVM_LLVMFuncOp : LLVM_Op<"func", [
|
||||
AutomaticAllocationScope, IsolatedFromAbove, FunctionOpInterface,
|
||||
CallableOpInterface
|
||||
AutomaticAllocationScope, IsolatedFromAbove, FunctionOpInterface
|
||||
]> {
|
||||
let summary = "LLVM dialect function.";
|
||||
|
||||
@@ -1420,36 +1419,15 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getParams(); }
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> 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<Type> getCallableResults() {
|
||||
ArrayRef<Type> getResultTypes() {
|
||||
if (::llvm::isa<LLVM::LLVMVoidType>(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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -15,7 +15,7 @@ include "mlir/Dialect/MLProgram/IR/MLProgramTypes.td"
|
||||
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 @@ class MLProgram_Op<string mnemonic, list<Trait> traits = []> :
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
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 @@ def MLProgram_FuncOp : MLProgram_Op<"func", [
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
// CallableOpInterface
|
||||
// FunctionOpInterface Methods
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// Returns the region on the current operation that is callable. This may
|
||||
@@ -69,26 +69,6 @@ def MLProgram_FuncOp : MLProgram_Op<"func", [
|
||||
return isExternal() ? nullptr : &getBody();
|
||||
}
|
||||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<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 function.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
@@ -390,7 +370,7 @@ def MLProgram_GlobalStoreGraphOp : MLProgram_Op<"global_store_graph", [
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
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 @@ def MLProgram_SubgraphOp : MLProgram_Op<"subgraph", [
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
//===------------------------------------------------------------------===//
|
||||
// CallableOpInterface
|
||||
// FunctionOpInterface Methods
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// Returns the region on the current operation that is callable. This may
|
||||
@@ -430,26 +410,6 @@ def MLProgram_SubgraphOp : MLProgram_Op<"subgraph", [
|
||||
/// function.
|
||||
::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }
|
||||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<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 function.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 @@ def PDLInterp_FuncOp : PDLInterp_Op<"func", [
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
Region *getCallableRegion() { return &getBody(); }
|
||||
}];
|
||||
let hasCustomAssemblyFormat = 1;
|
||||
let skipDefaultBuilders = 1;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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_ExecutionModeOp : SPIRV_Op<"ExecutionMode", [InModuleScope]> {
|
||||
// -----
|
||||
|
||||
def SPIRV_FuncOp : SPIRV_Op<"func", [
|
||||
AutomaticAllocationScope, DeclareOpInterfaceMethods<CallableOpInterface>,
|
||||
FunctionOpInterface, InModuleScope, IsolatedFromAbove
|
||||
AutomaticAllocationScope, FunctionOpInterface,
|
||||
InModuleScope, IsolatedFromAbove
|
||||
]> {
|
||||
let summary = "Declare or define a function";
|
||||
|
||||
@@ -315,12 +315,6 @@ def SPIRV_FuncOp : SPIRV_Op<"func", [
|
||||
let autogenSerialization = 0;
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
/// Returns the argument types of this function.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> 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 @@ def SPIRV_FuncOp : SPIRV_Op<"func", [
|
||||
/// 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<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
/// Returns the result types of this function.
|
||||
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||
|
||||
// CallableOpInterface
|
||||
Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td"
|
||||
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_FunctionLibraryOp : Shape_Op<"function_library",
|
||||
}
|
||||
|
||||
def Shape_FuncOp : Shape_Op<"func",
|
||||
[AffineScope, AutomaticAllocationScope, CallableOpInterface,
|
||||
[AffineScope, AutomaticAllocationScope,
|
||||
FunctionOpInterface, IsolatedFromAbove, OpAsmOpInterface]> {
|
||||
let summary = "Shape function";
|
||||
let description = [{
|
||||
@@ -1062,7 +1062,7 @@ def Shape_FuncOp : Shape_Op<"func",
|
||||
ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<DictionaryAttr> argAttrs);
|
||||
//===------------------------------------------------------------------===//
|
||||
// CallableOpInterface
|
||||
// FunctionOpInterface Methods
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// Returns the region on the current operation that is callable. This may
|
||||
@@ -1072,28 +1072,6 @@ def Shape_FuncOp : Shape_Op<"func",
|
||||
return isExternal() ? nullptr : &getBody();
|
||||
}
|
||||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<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 function.
|
||||
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,7 +14,7 @@ include "mlir/Interfaces/CastInterfaces.td"
|
||||
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 MergeHandlesOp : TransformDialectOp<"merge_handles",
|
||||
}
|
||||
|
||||
def NamedSequenceOp : TransformDialectOp<"named_sequence",
|
||||
[CallableOpInterface,
|
||||
FunctionOpInterface,
|
||||
[FunctionOpInterface,
|
||||
IsolatedFromAbove,
|
||||
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
|
||||
DeclareOpInterfaceMethods<TransformOpInterface>]> {
|
||||
@@ -850,19 +849,9 @@ def NamedSequenceOp : TransformDialectOp<"named_sequence",
|
||||
::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);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -41,12 +41,6 @@ mlir_tablegen(BuiltinTypeInterfaces.h.inc -gen-type-interface-decls)
|
||||
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)
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace mlir {
|
||||
class Attribute;
|
||||
class TupleType;
|
||||
class Type;
|
||||
class TypeRange;
|
||||
class Value;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -67,6 +68,17 @@ LogicalResult verifyCompatibleShapes(TypeRange types);
|
||||
/// Dimensions are compatible if all non-dynamic dims are equal.
|
||||
LogicalResult verifyCompatibleDims(ArrayRef<int64_t> 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<unsigned> indices,
|
||||
TypeRange newTypes, SmallVectorImpl<Type> &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<Type> &storage);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utility Iterators
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -4,6 +4,7 @@ add_mlir_interface(ControlFlowInterfaces)
|
||||
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)
|
||||
|
||||
@@ -90,26 +90,58 @@ def CallableOpInterface : OpInterface<"CallableOpInterface"> {
|
||||
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 argument attributes for all callable region arguments or
|
||||
null if there are none.
|
||||
}],
|
||||
"::mlir::ArrayAttr", "getCallableArgAttrs"
|
||||
>,
|
||||
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 result attributes for all callable region results 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", "getCallableResAttrs"
|
||||
>
|
||||
"::mlir::ArrayAttr", "getArgAttrsAttr", (ins),
|
||||
/*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>,
|
||||
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 region results. Alternatively, the method can return
|
||||
null to indicate that the region has no result attributes.
|
||||
}],
|
||||
"::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; }]>,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 @@ void eraseFunctionResults(FunctionOpInterface op,
|
||||
/// 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<unsigned> indices,
|
||||
TypeRange newTypes, SmallVectorImpl<Type> &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<Type> &storage);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Function Argument Attribute.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -245,6 +236,6 @@ LogicalResult verifyTrait(ConcreteOp op) {
|
||||
// Tablegen Interface Declarations
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/IR/FunctionOpInterfaces.h.inc"
|
||||
#include "mlir/Interfaces/FunctionInterfaces.h.inc"
|
||||
|
||||
#endif // MLIR_IR_FUNCTIONINTERFACES_H
|
||||
@@ -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 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> {
|
||||
}],
|
||||
"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 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> {
|
||||
ArrayRef<unsigned> argIndices, TypeRange argTypes,
|
||||
ArrayRef<unsigned> resultIndices, TypeRange resultTypes) {
|
||||
SmallVector<Type> 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 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> {
|
||||
Type getTypeWithoutArgsAndResults(
|
||||
const BitVector &argIndices, const BitVector &resultIndices) {
|
||||
SmallVector<Type> 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<Type> 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<Type> resultStorage;
|
||||
TypeRange newResultTypes = function_interface_impl::filterTypesOut(
|
||||
TypeRange newResultTypes = filterTypesOut(
|
||||
$_op.getResultTypes(), resultIndices, resultStorage);
|
||||
return $_op.cloneTypeWith($_op.getArgumentTypes(), newResultTypes);
|
||||
}
|
||||
@@ -604,4 +560,4 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> {
|
||||
let verify = "return function_interface_impl::verifyTrait(cast<ConcreteOp>($_op));";
|
||||
}
|
||||
|
||||
#endif // MLIR_IR_FUNCTIONINTERFACES_TD_
|
||||
#endif // MLIR_INTERFACES_FUNCTIONINTERFACES_TD_
|
||||
@@ -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 <optional>
|
||||
|
||||
@@ -48,6 +48,7 @@ add_mlir_library(MLIRAnalysis
|
||||
MLIRCallInterfaces
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRDataLayoutInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferIntRangeInterface
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRLoopLikeInterface
|
||||
|
||||
@@ -11,6 +11,7 @@ add_mlir_conversion_library(MLIRMemRefToSPIRV
|
||||
MLIRConversionPassIncGen
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRMemRefDialect
|
||||
MLIRPass
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ add_mlir_dialect_library(MLIRAsyncDialect
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRDialect
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
|
||||
@@ -548,7 +548,7 @@ createAsyncDispatchFunction(ParallelComputeFunction &computeFunc,
|
||||
operands[2] = end;
|
||||
|
||||
executeBuilder.create<func::CallOp>(executeLoc, func.getSymName(),
|
||||
func.getCallableResults(), operands);
|
||||
func.getResultTypes(), operands);
|
||||
executeBuilder.create<async::YieldOp>(executeLoc, ValueRange());
|
||||
};
|
||||
|
||||
@@ -569,7 +569,7 @@ createAsyncDispatchFunction(ParallelComputeFunction &computeFunc,
|
||||
computeFuncOperands.append(forwardedInputs.begin(), forwardedInputs.end());
|
||||
|
||||
b.create<func::CallOp>(computeFunc.func.getSymName(),
|
||||
computeFunc.func.getCallableResults(),
|
||||
computeFunc.func.getResultTypes(),
|
||||
computeFuncOperands);
|
||||
b.create<func::ReturnOp>(ValueRange());
|
||||
|
||||
@@ -616,7 +616,7 @@ static void doAsyncDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter,
|
||||
appendBlockComputeOperands(operands);
|
||||
|
||||
b.create<func::CallOp>(parallelComputeFunction.func.getSymName(),
|
||||
parallelComputeFunction.func.getCallableResults(),
|
||||
parallelComputeFunction.func.getResultTypes(),
|
||||
operands);
|
||||
b.create<scf::YieldOp>();
|
||||
};
|
||||
@@ -635,8 +635,7 @@ static void doAsyncDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter,
|
||||
appendBlockComputeOperands(operands);
|
||||
|
||||
b.create<func::CallOp>(asyncDispatchFunction.getSymName(),
|
||||
asyncDispatchFunction.getCallableResults(),
|
||||
operands);
|
||||
asyncDispatchFunction.getResultTypes(), operands);
|
||||
|
||||
// Wait for the completion of all parallel compute operations.
|
||||
b.create<AwaitAllOp>(group);
|
||||
@@ -694,7 +693,7 @@ doSequentialDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter,
|
||||
auto executeBodyBuilder = [&](OpBuilder &executeBuilder,
|
||||
Location executeLoc, ValueRange executeArgs) {
|
||||
executeBuilder.create<func::CallOp>(executeLoc, compute.getSymName(),
|
||||
compute.getCallableResults(),
|
||||
compute.getResultTypes(),
|
||||
computeFuncOperands(iv));
|
||||
executeBuilder.create<async::YieldOp>(executeLoc, ValueRange());
|
||||
};
|
||||
@@ -710,7 +709,7 @@ doSequentialDispatch(ImplicitLocOpBuilder &b, PatternRewriter &rewriter,
|
||||
b.create<scf::ForOp>(c1, blockCount, c1, ValueRange(), loopBuilder);
|
||||
|
||||
// Call parallel compute function for the first block in the caller thread.
|
||||
b.create<func::CallOp>(compute.getSymName(), compute.getCallableResults(),
|
||||
b.create<func::CallOp>(compute.getSymName(), compute.getResultTypes(),
|
||||
computeFuncOperands(c0));
|
||||
|
||||
// Wait for the completion of all async compute operations.
|
||||
|
||||
@@ -161,16 +161,15 @@ static CoroMachinery setupCoroMachinery(func::FuncOp func) {
|
||||
|
||||
// We treat TokenType as state update marker to represent side-effects of
|
||||
// async computations
|
||||
bool isStateful = isa<TokenType>(func.getCallableResults().front());
|
||||
bool isStateful = isa<TokenType>(func.getResultTypes().front());
|
||||
|
||||
std::optional<Value> retToken;
|
||||
if (isStateful)
|
||||
retToken.emplace(builder.create<RuntimeCreateOp>(TokenType::get(ctx)));
|
||||
|
||||
llvm::SmallVector<Value, 4> retValues;
|
||||
ArrayRef<Type> resValueTypes = isStateful
|
||||
? func.getCallableResults().drop_front()
|
||||
: func.getCallableResults();
|
||||
ArrayRef<Type> resValueTypes =
|
||||
isStateful ? func.getResultTypes().drop_front() : func.getResultTypes();
|
||||
for (auto resType : resValueTypes)
|
||||
retValues.emplace_back(
|
||||
builder.create<RuntimeCreateOp>(resType).getResult());
|
||||
|
||||
@@ -15,6 +15,7 @@ add_mlir_dialect_library(MLIRAsyncTransforms
|
||||
MLIRArithDialect
|
||||
MLIRAsyncDialect
|
||||
MLIRFuncDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRPass
|
||||
MLIRSCFDialect
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,6 +19,7 @@ add_mlir_dialect_library(MLIRBufferizationDialect
|
||||
MLIRDestinationStyleOpInterface
|
||||
MLIRDialect
|
||||
MLIRFuncDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRSparseTensorDialect
|
||||
MLIRTensorDialect
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -11,6 +11,7 @@ add_mlir_dialect_library(MLIRBufferizationTransformOps
|
||||
MLIRIR
|
||||
MLIRBufferizationDialect
|
||||
MLIRBufferizationTransforms
|
||||
MLIRFunctionInterfaces
|
||||
MLIRLinalgDialect
|
||||
MLIRParser
|
||||
MLIRPDLDialect
|
||||
|
||||
@@ -27,6 +27,7 @@ add_mlir_dialect_library(MLIRBufferizationTransforms
|
||||
MLIRBufferizationDialect
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRFuncDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
MLIRMemRefDialect
|
||||
|
||||
@@ -10,6 +10,7 @@ add_mlir_dialect_library(MLIRFuncDialect
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRCallInterfaces
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
MLIRSideEffectInterfaces
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -37,6 +37,7 @@ add_mlir_dialect_library(MLIRGPUDialect
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRArithDialect
|
||||
MLIRDLTIDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferIntRangeInterface
|
||||
MLIRIR
|
||||
MLIRMemRefDialect
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -32,6 +32,7 @@ add_mlir_dialect_library(MLIRLLVMDialect
|
||||
MLIRCallInterfaces
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRDataLayoutInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
MLIRMemorySlotInterfaces
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -21,6 +21,7 @@ add_mlir_dialect_library(MLIRLinalgDialect
|
||||
MLIRBufferizationDialect
|
||||
MLIRDestinationStyleOpInterface
|
||||
MLIRDialectUtils
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -19,6 +19,7 @@ add_mlir_dialect_library(MLIRLinalgTransformOps
|
||||
MLIRBufferizationDialect
|
||||
MLIRBufferizationTransforms
|
||||
MLIRFuncDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLinalgDialect
|
||||
MLIRLinalgTransforms
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ add_mlir_dialect_library(MLIRMLProgramDialect
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRDialect
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,6 +8,7 @@ add_mlir_dialect_library(MLIRPDLInterpDialect
|
||||
MLIRPDLInterpOpsIncGen
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRPDLDialect
|
||||
MLIRInferTypeOpInterface
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -13,6 +13,7 @@ add_mlir_dialect_library(MLIRSCFDialect
|
||||
MLIRArithDialect
|
||||
MLIRBufferizationDialect
|
||||
MLIRControlFlowDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLoopLikeInterface
|
||||
MLIRSideEffectInterfaces
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -37,6 +37,7 @@ add_mlir_dialect_library(MLIRSPIRVDialect
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRParser
|
||||
MLIRSideEffectInterfaces
|
||||
|
||||
@@ -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 @@ void spirv::FuncOp::build(OpBuilder &builder, OperationState &state,
|
||||
state.addRegion();
|
||||
}
|
||||
|
||||
// CallableOpInterface
|
||||
Region *spirv::FuncOp::getCallableRegion() {
|
||||
return isExternal() ? nullptr : &getBody();
|
||||
}
|
||||
|
||||
// CallableOpInterface
|
||||
ArrayRef<Type> 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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -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 <optional>
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
@@ -18,6 +18,7 @@ add_mlir_dialect_library(MLIRShapeDialect
|
||||
MLIRControlFlowInterfaces
|
||||
MLIRDialect
|
||||
MLIRFuncDialect
|
||||
MLIRFunctionInterfaces
|
||||
MLIRInferTypeOpInterface
|
||||
MLIRIR
|
||||
MLIRSideEffectInterfaces
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -13,6 +13,7 @@ add_mlir_dialect_library(MLIRTransformDialect
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRCastInterfaces
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLLVMCommonConversion
|
||||
MLIRLLVMDialect
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -7,6 +7,7 @@ add_mlir_dialect_library(MLIRTransformDialectTransforms
|
||||
MLIRTransformDialectTransformsIncGen
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRFunctionInterfaces
|
||||
MLIRTransformDialect
|
||||
MLIRIR
|
||||
MLIRPass
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 @@ FunctionType FunctionType::getWithArgsAndResults(
|
||||
ArrayRef<unsigned> argIndices, TypeRange argTypes,
|
||||
ArrayRef<unsigned> resultIndices, TypeRange resultTypes) {
|
||||
SmallVector<Type> 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
|
||||
FunctionType::getWithoutArgsAndResults(const BitVector &argIndices,
|
||||
const BitVector &resultIndices) {
|
||||
SmallVector<Type> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ add_mlir_library(MLIRIR
|
||||
DialectResourceBlobManager.cpp
|
||||
Dominance.cpp
|
||||
ExtensibleDialect.cpp
|
||||
FunctionImplementation.cpp
|
||||
FunctionInterfaces.cpp
|
||||
IntegerSet.cpp
|
||||
Location.cpp
|
||||
MLIRContext.cpp
|
||||
|
||||
@@ -172,3 +172,33 @@ Type OperandElementTypeIterator::mapElement(Value value) const {
|
||||
Type ResultElementTypeIterator::mapElement(Value value) const {
|
||||
return llvm::cast<ShapedType>(value.getType()).getElementType();
|
||||
}
|
||||
|
||||
TypeRange mlir::insertTypesInto(TypeRange oldTypes, ArrayRef<unsigned> indices,
|
||||
TypeRange newTypes,
|
||||
SmallVectorImpl<Type> &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<Type> &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;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ set(LLVM_OPTIONAL_SOURCES
|
||||
DataLayoutInterfaces.cpp
|
||||
DerivedAttributeOpInterface.cpp
|
||||
DestinationStyleOpInterface.cpp
|
||||
FunctionImplementation.cpp
|
||||
FunctionInterfaces.cpp
|
||||
InferIntRangeInterface.cpp
|
||||
InferTypeOpInterface.cpp
|
||||
LoopLikeInterface.cpp
|
||||
@@ -43,9 +45,38 @@ add_mlir_interface_library(CopyOpInterface)
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/IR/FunctionInterfaces.h"
|
||||
#include "mlir/Interfaces/FunctionInterfaces.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace mlir;
|
||||
// Tablegen Interface Definitions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/IR/FunctionOpInterfaces.cpp.inc"
|
||||
#include "mlir/Interfaces/FunctionInterfaces.cpp.inc"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Function Arguments and Results.
|
||||
@@ -317,36 +317,6 @@ void function_interface_impl::eraseFunctionResults(
|
||||
op.setFunctionTypeAttr(TypeAttr::get(newType));
|
||||
}
|
||||
|
||||
TypeRange function_interface_impl::insertTypesInto(
|
||||
TypeRange oldTypes, ArrayRef<unsigned> indices, TypeRange newTypes,
|
||||
SmallVectorImpl<Type> &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<Type> &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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -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;
|
||||
|
||||
@@ -9,6 +9,7 @@ add_mlir_library(MLIRLspServerLib
|
||||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRBytecodeWriter
|
||||
MLIRFunctionInterfaces
|
||||
MLIRIR
|
||||
MLIRLspServerSupportLib
|
||||
MLIRParser
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user