Skip to content

Commit b2fd306

Browse files
committed
address review comments
1 parent 689249d commit b2fd306

File tree

7 files changed

+18
-46
lines changed

7 files changed

+18
-46
lines changed

mlir/include/mlir/IR/OpImplementation.h

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,33 +1602,15 @@ class OpAsmParser : public AsmParser {
16021602
SmallVectorImpl<Value> &result) {
16031603
size_t operandSize = llvm::range_size(operands);
16041604
size_t typeSize = llvm::range_size(types);
1605-
if (operandSize == typeSize) {
1606-
for (auto [operand, type] : llvm::zip_equal(operands, types))
1607-
if (resolveOperand(operand, type, result))
1608-
return failure();
1609-
return success();
1610-
}
1611-
1612-
InFlightDiagnostic diag = emitError(loc)
1613-
<< "number of operands and types do not match";
1614-
std::string lesserQuantityText = "operand";
1615-
if (operandSize != 1)
1616-
lesserQuantityText += "s";
1617-
std::string higherQuantityText = "type";
1618-
if (typeSize != 1)
1619-
higherQuantityText += "s";
1620-
1621-
size_t lesserQuantity = operandSize;
1622-
size_t higherQuantity = typeSize;
1623-
if (operandSize > typeSize) {
1624-
std::swap(lesserQuantity, higherQuantity);
1625-
std::swap(lesserQuantityText, higherQuantityText);
1626-
}
1605+
if (operandSize != typeSize)
1606+
return emitError(loc)
1607+
<< "number of operands and types do not match: got " << operandSize
1608+
<< " operands and " << typeSize << " types";
16271609

1628-
diag.attachNote() << "got " << higherQuantity << " " << higherQuantityText
1629-
<< " but only " << lesserQuantity << " "
1630-
<< lesserQuantityText;
1631-
return diag;
1610+
for (auto [operand, type] : llvm::zip_equal(operands, types))
1611+
if (resolveOperand(operand, type, result))
1612+
return failure();
1613+
return success();
16321614
}
16331615

16341616
/// Parses an affine map attribute where dims and symbols are SSA operands.

mlir/test/Dialect/LLVMIR/invalid.mlir

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,14 @@ func.func @alloca_non_integer_alignment() {
9191
// -----
9292

9393
func.func @gep_missing_input_result_type(%pos : i64, %base : !llvm.ptr) {
94-
// expected-error@+2 {{number of operands and types do not match}}
95-
// expected-note@+1 {{got 2 operands but only 0 types}}
94+
// expected-error@+1 {{number of operands and types do not match: got 2 operands and 0 types}}
9695
llvm.getelementptr %base[%pos] : () -> (), i64
9796
}
9897

9998
// -----
10099

101100
func.func @gep_missing_input_type(%pos : i64, %base : !llvm.ptr) {
102-
// expected-error@+2 {{number of operands and types do not match}}
103-
// expected-note@+1 {{got 2 operands but only 0 types}}
101+
// expected-error@+1 {{number of operands and types do not match: got 2 operands and 0 types}}
104102
llvm.getelementptr %base[%pos] : () -> (!llvm.ptr), i64
105103
}
106104

mlir/test/Dialect/Linalg/transform-ops-invalid.mlir

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ transform.sequence failures(propagate) {
7777
transform.sequence failures(propagate) {
7878
^bb0(%arg0: !transform.any_op):
7979
%0 = transform.param.constant 2 : i64 -> !transform.param<i64>
80-
// expected-error@+2 {{custom op 'transform.structured.vectorize' number of operands and types do not match}}
81-
// expected-note@below {{got 2 types but only 1 operand}}
80+
// expected-error@+1 {{custom op 'transform.structured.vectorize' number of operands and types do not match: got 1 operands and 2 types}}
8281
transform.structured.vectorize %arg0 vector_sizes [%0, 2] : !transform.any_op, !transform.param<i64>, !transform.param<i64>
8382

8483
}

mlir/test/Dialect/SCF/invalid.mlir

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ func.func @parallel_more_results_than_reduces(
247247

248248
func.func @parallel_more_results_than_initial_values(
249249
%arg0 : index, %arg1: index, %arg2: index) {
250-
// expected-error@+2 {{'scf.parallel' number of operands and types do not match}}
251-
// expected-note@+1 {{got 1 type but only 0 operands}}
250+
// expected-error@+1 {{'scf.parallel' number of operands and types do not match: got 0 operands and 1 types}}
252251
%res = scf.parallel (%i0) = (%arg0) to (%arg1) step (%arg2) -> f32 {
253252
scf.reduce(%arg0 : index) {
254253
^bb0(%lhs: index, %rhs: index):
@@ -610,8 +609,7 @@ func.func @wrong_num_results(%in: tensor<100xf32>, %out: tensor<100xf32>) {
610609
%c1 = arith.constant 1 : index
611610
%num_threads = arith.constant 100 : index
612611

613-
// expected-error@+2 {{number of operands and types do not match}}
614-
// expected-note@+1 {{got 2 types but only 1 operand}}
612+
// expected-error@+1 {{number of operands and types do not match: got 1 operands and 2 types}}
615613
%result:2 = scf.forall (%thread_idx) in (%num_threads) shared_outs(%o = %out) -> (tensor<100xf32>, tensor<100xf32>) {
616614
%1 = tensor.extract_slice %in[%thread_idx][1][1] : tensor<100xf32> to tensor<1xf32>
617615
scf.forall.in_parallel {

mlir/test/Dialect/SPIRV/IR/memory-ops.mlir

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ func.func @access_chain_non_composite() -> () {
5757

5858
func.func @access_chain_no_indices(%index0 : i32) -> () {
5959
%0 = spirv.Variable : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>
60-
// expected-error @+2 {{custom op 'spirv.AccessChain' number of operands and types do not match}}
61-
// expected-note @+1 {{got 1 type but only 0 operands}}
60+
// expected-error @+1 {{custom op 'spirv.AccessChain' number of operands and types do not match: got 0 operands and 1 types}}
6261
%1 = spirv.AccessChain %0[] : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>, i32 -> !spirv.ptr<f32, Function>
6362
return
6463
}
@@ -76,8 +75,7 @@ func.func @access_chain_missing_comma(%index0 : i32) -> () {
7675

7776
func.func @access_chain_invalid_indices_types_count(%index0 : i32) -> () {
7877
%0 = spirv.Variable : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>
79-
// expected-error @+2 {{custom op 'spirv.AccessChain' number of operands and types do not match}}
80-
// expected-note @+1 {{got 2 types but only 1 operand}}
78+
// expected-error @+1 {{custom op 'spirv.AccessChain' number of operands and types do not match: got 1 operands and 2 types}}
8179
%1 = spirv.AccessChain %0[%index0] : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>, i32, i32 -> !spirv.ptr<!spirv.array<4xf32>, Function>
8280
return
8381
}
@@ -86,8 +84,7 @@ func.func @access_chain_invalid_indices_types_count(%index0 : i32) -> () {
8684

8785
func.func @access_chain_missing_indices_type(%index0 : i32) -> () {
8886
%0 = spirv.Variable : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>
89-
// expected-error @+2 {{custom op 'spirv.AccessChain' number of operands and types do not match}}
90-
// expected-note @+1 {{got 2 operands but only 1 type}}
87+
// expected-error @+1 {{custom op 'spirv.AccessChain' number of operands and types do not match: got 2 operands and 1 types}}
9188
%1 = spirv.AccessChain %0[%index0, %index0] : !spirv.ptr<!spirv.array<4x!spirv.array<4xf32>>, Function>, i32 -> !spirv.ptr<f32, Function>
9289
return
9390
}

mlir/test/Dialect/Tensor/invalid.mlir

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ func.func @tensor.from_elements_wrong_result_type() {
9090
// -----
9191

9292
func.func @tensor.from_elements_wrong_elements_count() {
93-
// expected-error@+3 {{number of operands and types do not match}}
94-
// expected-note@+2 {{got 2 types but only 1 operand}}
93+
// expected-error@+2 {{number of operands and types do not match: got 1 operands and 2 types}}
9594
%c0 = arith.constant 0 : index
9695
%0 = tensor.from_elements %c0 : tensor<2xindex>
9796
return

mlir/test/Dialect/Vector/invalid.mlir

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,8 +1803,7 @@ func.func @deinterleave_scalable_rank_fail(%vec : vector<2x[4]xf32>) {
18031803
// -----
18041804

18051805
func.func @invalid_from_elements(%a: f32) {
1806-
// expected-error @+2 {{'vector.from_elements' number of operands and types do not match}}
1807-
// expected-note @+1 {{got 2 types but only 1 operand}}
1806+
// expected-error @+1 {{'vector.from_elements' number of operands and types do not match: got 1 operands and 2 types}}
18081807
vector.from_elements %a : vector<2xf32>
18091808
return
18101809
}

0 commit comments

Comments
 (0)