Skip to content

Commit d90100b

Browse files
committed
[MLIR][TableGen] Use arg index in InferredResultType constructor.
`InferredResultType` construct expects an "result and arg"-style index (with results negative and args positive), and not a results index (results nonegative).
1 parent 99612a3 commit d90100b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

mlir/lib/TableGen/Operator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ void Operator::populateTypeInferenceInfo(
503503
for (int otherResultIndex : resultIndices) {
504504
if (resultIndex == otherResultIndex)
505505
continue;
506-
inference[resultIndex].sources.emplace_back(otherResultIndex,
507-
"$_self");
506+
inference[resultIndex].sources.emplace_back(
507+
InferredResultType::unmapResultIndex(otherResultIndex), "$_self");
508508
}
509509
}
510510
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,27 @@ def OpL4 : NS_Op<"two_inference_edges", [
180180
// CHECK: inferredReturnTypes[1] = odsInferredType1
181181
// CHECK: inferredReturnTypes[2] = odsInferredType2
182182

183+
def OpL5 : NS_Op<"op_with_same_but_unconstraint_results",
184+
[AllTypesMatch<["result_a", "result_b"]>]> {
185+
let results = (outs AnyType:$result_a, AnyType:$result_b);
186+
}
187+
188+
// CHECK-NOT: LogicalResult OpL5::inferReturnTypes
189+
190+
def OpL6 : NS_Op<"op_with_same_and_constraint_results",
191+
[AllTypesMatch<["result_a", "result_b", "result_c"]>]> {
192+
let results = (outs AnyType:$result_a, AnyType:$result_b, I32:$result_c);
193+
}
194+
195+
// CHECK-LABEL: LogicalResult OpL6::inferReturnTypes
196+
// CHECK-NOT: }
197+
// CHECK: odsInferredType0 = odsBuilder.getIntegerType(32);
198+
// CHECK: odsInferredType1 = odsBuilder.getIntegerType(32);
199+
// CHECK: odsInferredType2 = odsBuilder.getIntegerType(32);
200+
// CHECK: inferredReturnTypes[0] = odsInferredType0;
201+
// CHECK: inferredReturnTypes[1] = odsInferredType1;
202+
// CHECK: inferredReturnTypes[2] = odsInferredType2;
203+
183204
def OpM : NS_Op<"mix_diff_size_variadic_and_normal_results_op", [AttrSizedResultSegments]> {
184205
let results = (outs Variadic<AnyTensor>:$output1, AnyTensor:$output2, Optional<AnyTensor>:$output3);
185206
}

0 commit comments

Comments
 (0)