Skip to content

Commit

Permalink
[MLIR][Doc] Prepend "Variadic of" in front of variadic operands (#69285)
Browse files Browse the repository at this point in the history
Table of Operands for operations like:

https://mlir.llvm.org/docs/Dialects/MemRef/#operands-6

Don't distinguish variadic ODS operands from others right now.

After this change, it'll print:

| Operand      | Description       |
| dynamicSizes | Variadic of index |

instead of:

| Operand      | Description |
| dynamicSizes | index       |
  • Loading branch information
joker-eph committed Oct 17, 2023
1 parent e9b9a1d commit 3472d4d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion flang/test/Fir/invalid.fir
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func.func @bad_array_modify(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %
func.func @slice_must_be_integral() {
%0 = arith.constant 42 : i32
%1 = fir.field_index field, !fir.type<t(param:i32){field:i32}> (%0 : i32)
// expected-error@+1 {{'fir.slice' op operand #0 must be any integer, but got '!fir.field'}}
// expected-error@+1 {{'fir.slice' op operand #0 must be variadic of any integer, but got '!fir.field'}}
%2 = fir.slice %1, %1, %1 : (!fir.field, !fir.field, !fir.field) -> !fir.slice<1>
return
}
Expand Down
4 changes: 2 additions & 2 deletions flang/test/HLFIR/invalid.fir
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ func.func @bad_concat(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<!fir.cha
// -----
func.func @bad_concat_2(%arg0: !fir.ref<!fir.array<100x!fir.char<1,10>>>, %arg1: !fir.ref<!fir.array<100x!fir.char<1,20>>>) {
%c30 = arith.constant 30 : index
// expected-error@+1 {{'hlfir.concat' op operand #0 must be any character scalar type, but got '!fir.ref<!fir.array<100x!fir.char<1,10>>>'}}
// expected-error@+1 {{'hlfir.concat' op operand #0 must be variadic of any character scalar type, but got '!fir.ref<!fir.array<100x!fir.char<1,10>>>'}}
%0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>, index) -> (!hlfir.expr<100x!fir.char<1,30>>)
return
}

// -----
func.func @bad_concat_3(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<i32>) {
%c30 = arith.constant 30 : index
// expected-error@+1 {{'hlfir.concat' op operand #1 must be any character scalar type, but got '!fir.ref<i32>'}}
// expected-error@+1 {{'hlfir.concat' op operand #1 must be variadic of any character scalar type, but got '!fir.ref<i32>'}}
%0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.char<1,10>>, !fir.ref<i32>, index) -> (!hlfir.expr<!fir.char<1,30>>)
return
}
Expand Down
3 changes: 2 additions & 1 deletion mlir/include/mlir/IR/CommonTypeConstraints.td
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class DialectType<Dialect d, Pred condition, string descr = "",

// A variadic type constraint. It expands to zero or more of the base type. This
// class is used for supporting variadic operands/results.
class Variadic<Type type> : TypeConstraint<type.predicate, type.summary,
class Variadic<Type type> : TypeConstraint<type.predicate,
"variadic of " # type.summary,
type.cppClassName> {
Type baseType = type;
int minSize = 0;
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Dialect/Affine/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
func.func @affine_apply_operand_non_index(%arg0 : i32) {
// Custom parser automatically assigns all arguments the `index` so we must
// use the generic syntax here to exercise the verifier.
// expected-error@+1 {{op operand #0 must be index, but got 'i32'}}
// expected-error@+1 {{op operand #0 must be variadic of index, but got 'i32'}}
%0 = "affine.apply"(%arg0) {map = affine_map<(d0) -> (d0)>} : (i32) -> (index)
return
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Dialect/LLVMIR/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func.func @call_non_llvm() {
// -----

func.func @call_non_llvm_arg(%arg0 : tensor<*xi32>) {
// expected-error@+1 {{'llvm.call' op operand #0 must be LLVM dialect-compatible type}}
// expected-error@+1 {{'llvm.call' op operand #0 must be variadic of LLVM dialect-compatible type}}
"llvm.call"(%arg0) : (tensor<*xi32>) -> ()
llvm.return
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/Dialect/Linalg/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func.func @illegal_fill_memref_with_tensor_return
func.func @illegal_fill_tensor_with_memref_return
(%arg0 : tensor<?x?xf32>, %arg1 : f32) -> memref<?x?xf32>
{
// expected-error @+1 {{result #0 must be ranked tensor of any type values, but got 'memref<?x?xf32>'}}
// expected-error @+1 {{result #0 must be variadic of ranked tensor of any type values, but got 'memref<?x?xf32>'}}
%0 = linalg.fill ins(%arg1 : f32) outs(%arg0 : tensor<?x?xf32>) -> memref<?x?xf32>
return %0 : memref<?x?xf32>
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/IR/operand.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func.func @correct_variadic_operand(%arg0: tensor<f32>, %arg1: f32) {
// -----

func.func @error_in_first_variadic_operand(%arg0: tensor<f32>, %arg1: f32) {
// expected-error @+1 {{operand #1 must be tensor of any type}}
// expected-error @+1 {{operand #1 must be variadic of tensor of any type}}
"test.mixed_normal_variadic_operand"(%arg0, %arg1, %arg0, %arg0, %arg0) : (tensor<f32>, f32, tensor<f32>, tensor<f32>, tensor<f32>) -> ()
return
}
Expand All @@ -29,7 +29,7 @@ func.func @error_in_normal_operand(%arg0: tensor<f32>, %arg1: f32) {
// -----

func.func @error_in_second_variadic_operand(%arg0: tensor<f32>, %arg1: f32) {
// expected-error @+1 {{operand #3 must be tensor of any type}}
// expected-error @+1 {{operand #3 must be variadic of tensor of any type}}
"test.mixed_normal_variadic_operand"(%arg0, %arg0, %arg0, %arg1, %arg0) : (tensor<f32>, tensor<f32>, tensor<f32>, f32, tensor<f32>) -> ()
return
}
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/IR/result.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func.func @correct_variadic_result() -> tensor<f32> {
// -----

func.func @error_in_first_variadic_result() -> tensor<f32> {
// expected-error @+1 {{result #1 must be tensor of any type}}
// expected-error @+1 {{result #1 must be variadic of tensor of any type}}
%0:5 = "test.mixed_normal_variadic_result"() : () -> (tensor<f32>, f32, tensor<f32>, tensor<f32>, tensor<f32>)
return %0#4 : tensor<f32>
}
Expand All @@ -29,7 +29,7 @@ func.func @error_in_normal_result() -> tensor<f32> {
// -----

func.func @error_in_second_variadic_result() -> tensor<f32> {
// expected-error @+1 {{result #3 must be tensor of any type}}
// expected-error @+1 {{result #3 must be variadic of tensor of any type}}
%0:5 = "test.mixed_normal_variadic_result"() : () -> (tensor<f32>, tensor<f32>, tensor<f32>, f32, tensor<f32>)
return %0#4 : tensor<f32>
}
Expand Down

0 comments on commit 3472d4d

Please sign in to comment.