1// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s 2 3// expected-error @+1 {{found unsupported 'spv.something' attribute on operation}} 4func @unknown_attr_on_op() attributes { 5 spv.something = 64 6} { return } 7 8// ----- 9 10// expected-error @+1 {{found unsupported 'spv.something' attribute on region argument}} 11func @unknown_attr_on_region(%arg: i32 {spv.something}) { 12 return 13} 14 15// ----- 16 17// expected-error @+1 {{found unsupported 'spv.something' attribute on region result}} 18func @unknown_attr_on_region() -> (i32 {spv.something}) { 19 %0 = constant 10.0 : f32 20 return %0: f32 21} 22 23// ----- 24 25//===----------------------------------------------------------------------===// 26// spv.entry_point_abi 27//===----------------------------------------------------------------------===// 28 29// expected-error @+1 {{'spv.entry_point_abi' attribute must be a dictionary attribute containing one 32-bit integer elements attribute: 'local_size'}} 30func @spv_entry_point() attributes { 31 spv.entry_point_abi = 64 32} { return } 33 34// ----- 35 36// expected-error @+1 {{'spv.entry_point_abi' attribute must be a dictionary attribute containing one 32-bit integer elements attribute: 'local_size'}} 37func @spv_entry_point() attributes { 38 spv.entry_point_abi = {local_size = 64} 39} { return } 40 41// ----- 42 43func @spv_entry_point() attributes { 44 // CHECK: {spv.entry_point_abi = {local_size = dense<[64, 1, 1]> : vector<3xi32>}} 45 spv.entry_point_abi = {local_size = dense<[64, 1, 1]>: vector<3xi32>} 46} { return } 47 48// ----- 49 50//===----------------------------------------------------------------------===// 51// spv.interface_var_abi 52//===----------------------------------------------------------------------===// 53 54// expected-error @+1 {{'spv.interface_var_abi' attribute must be a dictionary attribute containing three 32-bit integer attributes: 'descriptor_set', 'binding', and 'storage_class'}} 55func @interface_var( 56 %arg0 : f32 {spv.interface_var_abi = 64} 57) { return } 58 59// ----- 60 61// expected-error @+1 {{'spv.interface_var_abi' attribute must be a dictionary attribute containing three 32-bit integer attributes: 'descriptor_set', 'binding', and 'storage_class'}} 62func @interface_var( 63 %arg0 : f32 {spv.interface_var_abi = {binding = 0: i32}} 64) { return } 65 66// ----- 67 68// CHECK: {spv.interface_var_abi = {binding = 0 : i32, descriptor_set = 0 : i32, storage_class = 12 : i32}} 69func @interface_var( 70 %arg0 : f32 {spv.interface_var_abi = {binding = 0 : i32, 71 descriptor_set = 0 : i32, 72 storage_class = 12 : i32}} 73) { return } 74 75// ----- 76 77// expected-error @+1 {{'spv.interface_var_abi' attribute must be a dictionary attribute containing three 32-bit integer attributes: 'descriptor_set', 'binding', and 'storage_class'}} 78func @interface_var() -> (f32 {spv.interface_var_abi = 64}) 79{ 80 %0 = constant 10.0 : f32 81 return %0: f32 82} 83 84// ----- 85 86// expected-error @+1 {{'spv.interface_var_abi' attribute must be a dictionary attribute containing three 32-bit integer attributes: 'descriptor_set', 'binding', and 'storage_class'}} 87func @interface_var() -> (f32 {spv.interface_var_abi = {binding = 0: i32}}) 88{ 89 %0 = constant 10.0 : f32 90 return %0: f32 91} 92 93// ----- 94 95// CHECK: {spv.interface_var_abi = {binding = 0 : i32, descriptor_set = 0 : i32, storage_class = 12 : i32}} 96func @interface_var() -> (f32 {spv.interface_var_abi = { 97 binding = 0 : i32, descriptor_set = 0 : i32, storage_class = 12 : i32}}) 98{ 99 %0 = constant 10.0 : f32 100 return %0: f32 101} 102 103// ----- 104 105//===----------------------------------------------------------------------===// 106// spv.target_env 107//===----------------------------------------------------------------------===// 108 109// expected-error @+1 {{'spv.target_env' must be a dictionary attribute containing one 32-bit integer attribute 'version', one string array attribute 'extensions', and one 32-bit integer array attribute 'capabilities'}} 110func @target_env_wrong_type() attributes { 111 spv.target_env = 64 112} { return } 113 114// ----- 115 116// expected-error @+1 {{'spv.target_env' must be a dictionary attribute containing one 32-bit integer attribute 'version', one string array attribute 'extensions', and one 32-bit integer array attribute 'capabilities'}} 117func @target_env_missing_fields() attributes { 118 spv.target_env = {version = 0: i32} 119} { return } 120 121// ----- 122 123// expected-error @+1 {{'spv.target_env' must be a dictionary attribute containing one 32-bit integer attribute 'version', one string array attribute 'extensions', and one 32-bit integer array attribute 'capabilities'}} 124func @target_env_wrong_extension_type() attributes { 125 spv.target_env = {version = 0: i32, extensions = [32: i32], capabilities = [1: i32]} 126} { return } 127 128// ----- 129 130// expected-error @+1 {{'spv.target_env' must be a dictionary attribute containing one 32-bit integer attribute 'version', one string array attribute 'extensions', and one 32-bit integer array attribute 'capabilities'}} 131func @target_env_wrong_extension() attributes { 132 spv.target_env = {version = 0: i32, extensions = ["SPV_Something"], capabilities = [1: i32]} 133} { return } 134 135// ----- 136 137func @target_env() attributes { 138 // CHECK: spv.target_env = {capabilities = [1 : i32], extensions = ["SPV_KHR_storage_buffer_storage_class"], version = 0 : i32} 139 spv.target_env = {version = 0: i32, extensions = ["SPV_KHR_storage_buffer_storage_class"], capabilities = [1: i32]} 140} { return } 141 142// ----- 143 144// expected-error @+1 {{'spv.target_env' must be a dictionary attribute containing one 32-bit integer attribute 'version', one string array attribute 'extensions', and one 32-bit integer array attribute 'capabilities'}} 145func @target_env_extra_fields() attributes { 146 spv.target_env = {version = 0: i32, extensions = ["SPV_KHR_storage_buffer_storage_class"], capabilities = [1: i32], extra = 32} 147} { return } 148