// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s // TODO(b/133530217): Add more tests after switching to the generic parser. //===----------------------------------------------------------------------===// // ArrayType //===----------------------------------------------------------------------===// // CHECK: func @scalar_array_type(!spv.array<16 x f32>, !spv.array<8 x i32>) func @scalar_array_type(!spv.array<16xf32>, !spv.array<8 x i32>) -> () // CHECK: func @vector_array_type(!spv.array<32 x vector<4xf32>>) func @vector_array_type(!spv.array< 32 x vector<4xf32> >) -> () // CHECK: func @array_type_stride(!spv.array<4 x !spv.array<4 x f32 [4]> [128]>) func @array_type_stride(!spv.array< 4 x !spv.array<4 x f32 [4]> [128]>) -> () // ----- // expected-error @+1 {{expected '<'}} func @missing_left_angle_bracket(!spv.array 4xf32>) -> () // ----- // expected-error @+1 {{expected single integer for array element count}} func @missing_count(!spv.array) -> () // ----- // expected-error @+1 {{expected 'x' in dimension list}} func @missing_x(!spv.array<4 f32>) -> () // ----- // expected-error @+1 {{expected non-function type}} func @missing_element_type(!spv.array<4x>) -> () // ----- // expected-error @+1 {{expected non-function type}} func @cannot_parse_type(!spv.array<4xblabla>) -> () // ----- // expected-error @+1 {{expected single integer for array element count}} func @more_than_one_dim(!spv.array<4x3xf32>) -> () // ----- // expected-error @+1 {{only 1-D vector allowed but found 'vector<4x3xf32>'}} func @non_1D_vector(!spv.array<4xvector<4x3xf32>>) -> () // ----- // expected-error @+1 {{cannot use 'tensor<4xf32>' to compose SPIR-V types}} func @tensor_type(!spv.array<4xtensor<4xf32>>) -> () // ----- // expected-error @+1 {{cannot use 'bf16' to compose SPIR-V types}} func @bf16_type(!spv.array<4xbf16>) -> () // ----- // expected-error @+1 {{only 1/8/16/32/64-bit integer type allowed but found 'i256'}} func @i256_type(!spv.array<4xi256>) -> () // ----- // expected-error @+1 {{cannot use 'index' to compose SPIR-V types}} func @index_type(!spv.array<4xindex>) -> () // ----- // expected-error @+1 {{cannot use '!llvm.i32' to compose SPIR-V types}} func @llvm_type(!spv.array<4x!llvm.i32>) -> () // ----- // expected-error @+1 {{ArrayStride must be greater than zero}} func @array_type_zero_stide(!spv.array<4xi32 [0]>) -> () // ----- // expected-error @+1 {{expected array length greater than 0}} func @array_type_zero_length(!spv.array<0xf32>) -> () // ----- //===----------------------------------------------------------------------===// // PointerType //===----------------------------------------------------------------------===// // CHECK: @bool_ptr_type(!spv.ptr) func @bool_ptr_type(!spv.ptr) -> () // CHECK: @scalar_ptr_type(!spv.ptr) func @scalar_ptr_type(!spv.ptr) -> () // CHECK: @vector_ptr_type(!spv.ptr, PushConstant>) func @vector_ptr_type(!spv.ptr,PushConstant>) -> () // ----- // expected-error @+1 {{expected '<'}} func @missing_left_angle_bracket(!spv.ptr f32, Uniform>) -> () // ----- // expected-error @+1 {{expected ','}} func @missing_comma(!spv.ptr) -> () // ----- // expected-error @+1 {{expected non-function type}} func @missing_pointee_type(!spv.ptr<, Uniform>) -> () // ----- // expected-error @+1 {{unknown storage class: SomeStorageClass}} func @unknown_storage_class(!spv.ptr) -> () // ----- //===----------------------------------------------------------------------===// // RuntimeArrayType //===----------------------------------------------------------------------===// // CHECK: func @scalar_runtime_array_type(!spv.rtarray, !spv.rtarray) func @scalar_runtime_array_type(!spv.rtarray, !spv.rtarray) -> () // CHECK: func @vector_runtime_array_type(!spv.rtarray>) func @vector_runtime_array_type(!spv.rtarray< vector<4xf32> >) -> () // ----- // expected-error @+1 {{expected '<'}} func @missing_left_angle_bracket(!spv.rtarray f32>) -> () // ----- // expected-error @+1 {{expected non-function type}} func @missing_element_type(!spv.rtarray<>) -> () // ----- // expected-error @+1 {{expected non-function type}} func @redundant_count(!spv.rtarray<4xf32>) -> () // ----- //===----------------------------------------------------------------------===// // ImageType //===----------------------------------------------------------------------===// // CHECK: func @image_parameters_1D(!spv.image) func @image_parameters_1D(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_one_element(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_two_elements(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_three_elements(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_four_elements(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_five_elements(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_six_elements(!spv.image) -> () // ----- // expected-error @+1 {{expected '<'}} func @image_parameters_delimiter(!spv.image f32, Dim1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unknown>) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_nocomma_1(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_nocomma_2(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_nocomma_3(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_nocomma_4(!spv.image) -> () // ----- // expected-error @+1 {{expected ','}} func @image_parameters_nocomma_5(!spv.image) -> () // ----- //===----------------------------------------------------------------------===// // StructType //===----------------------------------------------------------------------===// // CHECK: func @struct_type(!spv.struct) func @struct_type(!spv.struct) -> () // CHECK: func @struct_type2(!spv.struct) func @struct_type2(!spv.struct) -> () // CHECK: func @struct_type_simple(!spv.struct>) func @struct_type_simple(!spv.struct>) -> () // CHECK: func @struct_type_with_offset(!spv.struct) func @struct_type_with_offset(!spv.struct) -> () // CHECK: func @nested_struct(!spv.struct>) func @nested_struct(!spv.struct>) // CHECK: func @nested_struct_with_offset(!spv.struct [4]>) func @nested_struct_with_offset(!spv.struct [4]>) // CHECK: func @struct_type_with_decoration(!spv.struct) func @struct_type_with_decoration(!spv.struct) // CHECK: func @struct_type_with_decoration_and_offset(!spv.struct) func @struct_type_with_decoration_and_offset(!spv.struct) // CHECK: func @struct_type_with_decoration2(!spv.struct) func @struct_type_with_decoration2(!spv.struct) // CHECK: func @struct_type_with_decoration3(!spv.struct) func @struct_type_with_decoration3(!spv.struct) // CHECK: func @struct_type_with_decoration4(!spv.struct) func @struct_type_with_decoration4(!spv.struct) // CHECK: func @struct_type_with_decoration5(!spv.struct) func @struct_type_with_decoration5(!spv.struct) // CHECK: func @struct_type_with_decoration6(!spv.struct>) func @struct_type_with_decoration6(!spv.struct>) // CHECK: func @struct_type_with_decoration7(!spv.struct [4]>) func @struct_type_with_decoration7(!spv.struct [4]>) // CHECK: func @struct_type_with_decoration8(!spv.struct>) func @struct_type_with_decoration8(!spv.struct>) // CHECK: func @struct_empty(!spv.struct<>) func @struct_empty(!spv.struct<>) // ----- // expected-error @+1 {{layout specification must be given for all members}} func @struct_type_missing_offset1((!spv.struct) -> () // ----- // expected-error @+1 {{layout specification must be given for all members}} func @struct_type_missing_offset2(!spv.struct) -> () // ----- // expected-error @+1 {{expected '>'}} func @struct_type_missing_comma1(!spv.struct) -> () // ----- // expected-error @+1 {{expected '>'}} func @struct_type_missing_comma2(!spv.struct) -> () // ----- // expected-error @+1 {{unbalanced '>' character in pretty dialect name}} func @struct_type_neg_offset(!spv.struct) -> () // ----- // expected-error @+1 {{unbalanced ']' character in pretty dialect name}} func @struct_type_neg_offset(!spv.struct) -> () // ----- // expected-error @+1 {{expected ']'}} func @struct_type_neg_offset(!spv.struct) -> () // ----- // expected-error @+1 {{expected valid keyword}} func @struct_type_neg_offset(!spv.struct) -> () // ----- // expected-error @+1 {{expected ','}} func @struct_type_missing_comma(!spv.struct) // ----- // expected-error @+1 {{expected ']'}} func @struct_type_missing_comma(!spv.struct)