Skip to content

Commit 7dd2f4b

Browse files
phisiartjpienaar
authored andcommitted
Let MLIR ODS also support generating build() functions without result type parameters when the op contains regions.
Regions were intentionally left unsupported: llvm@398f04a Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D136232
1 parent 878d541 commit 7dd2f4b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

mlir/test/mlir-tblgen/op-result.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
3131
// CHECK: if (::mlir::succeeded(OpB::inferReturnTypes(odsBuilder.getContext(),
3232
// CHECK: odsState.location, odsState.operands,
3333
// CHECK: odsState.attributes.getDictionary(odsState.getContext()),
34-
// CHECK: /*regions=*/{}, inferredReturnTypes)))
34+
// CHECK: odsState.regions, inferredReturnTypes)))
3535
// CHECK: odsState.addTypes(inferredReturnTypes);
3636

3737
def OpC : NS_Op<"three_normal_result_op", []> {

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,13 +1583,12 @@ void OpEmitter::genSeparateArgParamBuilder() {
15831583
// Generate builder that infers type too.
15841584
// TODO: Subsume this with general checking if type can be
15851585
// inferred automatically.
1586-
// TODO: Expand to handle regions.
15871586
body << formatv(R"(
15881587
::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
15891588
if (::mlir::succeeded({0}::inferReturnTypes(odsBuilder.getContext(),
15901589
{1}.location, {1}.operands,
15911590
{1}.attributes.getDictionary({1}.getContext()),
1592-
/*regions=*/{{}, inferredReturnTypes)))
1591+
{1}.regions, inferredReturnTypes)))
15931592
{1}.addTypes(inferredReturnTypes);
15941593
else
15951594
::llvm::report_fatal_error("Failed to infer result type(s).");)",
@@ -1660,7 +1659,7 @@ void OpEmitter::genSeparateArgParamBuilder() {
16601659
// ambiguous function detection will elide those ones.
16611660
for (auto attrType : attrBuilderType) {
16621661
emit(attrType, TypeParamKind::Separate, /*inferType=*/false);
1663-
if (canInferType(op) && op.getNumRegions() == 0)
1662+
if (canInferType(op))
16641663
emit(attrType, TypeParamKind::None, /*inferType=*/true);
16651664
emit(attrType, TypeParamKind::Collective, /*inferType=*/false);
16661665
}

0 commit comments

Comments
 (0)