[Mlir-commits] [mlir] 74145d5 - [MLIR] Combine the 2 overloads of FuncOp::build() into one.
Rahul Joshi
llvmlistbot at llvm.org
Tue Jul 7 18:22:45 PDT 2020
Author: Rahul Joshi
Date: 2020-07-07T18:22:22-07:00
New Revision: 74145d584126da2ce7a836d9b2240d56442f3ea1
URL: https://github.com/llvm/llvm-project/commit/74145d584126da2ce7a836d9b2240d56442f3ea1
DIFF: https://github.com/llvm/llvm-project/commit/74145d584126da2ce7a836d9b2240d56442f3ea1.diff
LOG: [MLIR] Combine the 2 overloads of FuncOp::build() into one.
- This will eliminate the need to pass an empty `ArrayRef<NamedAttribute>{}` when
no named attributes are required on the function.
Differential Revision: https://reviews.llvm.org/D83356
Added:
Modified:
mlir/include/mlir/IR/Function.h
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
mlir/lib/IR/Function.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h
index f50a1cf8c63a..60ae8497d8d7 100644
--- a/mlir/include/mlir/IR/Function.h
+++ b/mlir/include/mlir/IR/Function.h
@@ -51,10 +51,8 @@ class FuncOp
ArrayRef<MutableDictionaryAttr> argAttrs);
static void build(OpBuilder &builder, OperationState &result, StringRef name,
- FunctionType type, ArrayRef<NamedAttribute> attrs);
- static void build(OpBuilder &builder, OperationState &result, StringRef name,
- FunctionType type, ArrayRef<NamedAttribute> attrs,
- ArrayRef<MutableDictionaryAttr> argAttrs);
+ FunctionType type, ArrayRef<NamedAttribute> attrs = {},
+ ArrayRef<MutableDictionaryAttr> argAttrs = {});
/// Operation hooks.
static ParseResult parse(OpAsmParser &parser, OperationState &result);
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index d6908680d798..1ebf48174aaf 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
@@ -124,8 +124,7 @@ LogicalResult ConvertGpuLaunchFuncToVulkanLaunchFunc::declareVulkanLaunchFunc(
// Declare vulkan launch function.
builder.create<FuncOp>(
loc, kVulkanLaunch,
- FunctionType::get(vulkanLaunchTypes, ArrayRef<Type>{}, loc->getContext()),
- ArrayRef<NamedAttribute>{});
+ FunctionType::get(vulkanLaunchTypes, {}, loc->getContext()));
return success();
}
diff --git a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
index 75b8466ff7fd..43f9d8825327 100644
--- a/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
+++ b/mlir/lib/Conversion/LinalgToStandard/LinalgToStandard.cpp
@@ -79,8 +79,7 @@ static FlatSymbolRefAttr getLibraryCallSymbolRef(Operation *op,
rewriter.setInsertionPoint(module.getBody(),
std::prev(module.getBody()->end()));
FuncOp funcOp =
- rewriter.create<FuncOp>(op->getLoc(), fnNameAttr.getValue(), libFnType,
- ArrayRef<NamedAttribute>{});
+ rewriter.create<FuncOp>(op->getLoc(), fnNameAttr.getValue(), libFnType);
// Insert a function attribute that will trigger the emission of the
// corresponding `_mlir_ciface_xxx` interface so that external libraries see
// a normalized ABI. This interface is added during std to llvm conversion.
diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index 305022dd8451..09c9441bb110 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -42,18 +42,16 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
}
void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
- FunctionType type, ArrayRef<NamedAttribute> attrs) {
+ FunctionType type, ArrayRef<NamedAttribute> attrs,
+ ArrayRef<MutableDictionaryAttr> argAttrs) {
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder.getStringAttr(name));
result.addAttribute(getTypeAttrName(), TypeAttr::get(type));
result.attributes.append(attrs.begin(), attrs.end());
result.addRegion();
-}
-void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
- FunctionType type, ArrayRef<NamedAttribute> attrs,
- ArrayRef<MutableDictionaryAttr> argAttrs) {
- build(builder, result, name, type, attrs);
+ if (argAttrs.empty())
+ return;
assert(type.getNumInputs() == argAttrs.size());
SmallString<8> argAttrName;
for (unsigned i = 0, e = type.getNumInputs(); i != e; ++i)
More information about the Mlir-commits
mailing list