[Mlir-commits] [mlir] 7dd2f4b - Let MLIR ODS also support generating build() functions without result type parameters when the op contains regions.
Jacques Pienaar
llvmlistbot at llvm.org
Fri Oct 21 10:10:00 PDT 2022
Author: Zhixun Tan
Date: 2022-10-21T10:09:52-07:00
New Revision: 7dd2f4bc009d23548b75cef3c05f97fe8b243e00
URL: https://github.com/llvm/llvm-project/commit/7dd2f4bc009d23548b75cef3c05f97fe8b243e00
DIFF: https://github.com/llvm/llvm-project/commit/7dd2f4bc009d23548b75cef3c05f97fe8b243e00.diff
LOG: Let MLIR ODS also support generating build() functions without result type parameters when the op contains regions.
Regions were intentionally left unsupported: https://github.com/llvm/llvm-project/commit/398f04aa49109fd5d1eff2c1946a2956dc6b29c6
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D136232
Added:
Modified:
mlir/test/mlir-tblgen/op-result.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index 90876fe2e38d0..33bbfec821083 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -31,7 +31,7 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
// CHECK: if (::mlir::succeeded(OpB::inferReturnTypes(odsBuilder.getContext(),
// CHECK: odsState.location, odsState.operands,
// CHECK: odsState.attributes.getDictionary(odsState.getContext()),
-// CHECK: /*regions=*/{}, inferredReturnTypes)))
+// CHECK: odsState.regions, inferredReturnTypes)))
// CHECK: odsState.addTypes(inferredReturnTypes);
def OpC : NS_Op<"three_normal_result_op", []> {
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 85326ecfd0c50..0d90cdcb05aa6 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1583,13 +1583,12 @@ void OpEmitter::genSeparateArgParamBuilder() {
// Generate builder that infers type too.
// TODO: Subsume this with general checking if type can be
// inferred automatically.
- // TODO: Expand to handle regions.
body << formatv(R"(
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
if (::mlir::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
{1}.location, {1}.operands,
{1}.attributes.getDictionary({1}.getContext()),
- /*regions=*/{{}, inferredReturnTypes)))
+ {1}.regions, inferredReturnTypes)))
{1}.addTypes(inferredReturnTypes);
else
::llvm::report_fatal_error("Failed to infer result type(s).");)",
@@ -1660,7 +1659,7 @@ void OpEmitter::genSeparateArgParamBuilder() {
// ambiguous function detection will elide those ones.
for (auto attrType : attrBuilderType) {
emit(attrType, TypeParamKind::Separate, /*inferType=*/false);
- if (canInferType(op) && op.getNumRegions() == 0)
+ if (canInferType(op))
emit(attrType, TypeParamKind::None, /*inferType=*/true);
emit(attrType, TypeParamKind::Collective, /*inferType=*/false);
}
More information about the Mlir-commits
mailing list