1// RUN: mlir-opt %s -split-input-file -verify-diagnostics 2 3func @load_too_many_subscripts(%arg0: memref<?x?xf32>, %arg1: index, %arg2: index, %arg3: index) { 4 // expected-error@+1 {{expects the number of subscripts to be equal to memref rank}} 5 "affine.load"(%arg0, %arg1, %arg2, %arg3) : (memref<?x?xf32>, index, index, index) -> f32 6} 7 8// ----- 9 10func @load_too_many_subscripts_map(%arg0: memref<?x?xf32>, %arg1: index, %arg2: index, %arg3: index) { 11 // expected-error@+1 {{op expects as many subscripts as affine map inputs}} 12 "affine.load"(%arg0, %arg1, %arg2, %arg3) 13 {map = affine_map<(i, j) -> (i, j)> } : (memref<?x?xf32>, index, index, index) -> f32 14} 15 16// ----- 17 18func @load_too_few_subscripts(%arg0: memref<?x?xf32>, %arg1: index) { 19 // expected-error@+1 {{expects the number of subscripts to be equal to memref rank}} 20 "affine.load"(%arg0, %arg1) : (memref<?x?xf32>, index) -> f32 21} 22 23// ----- 24 25func @load_too_few_subscripts_map(%arg0: memref<?x?xf32>, %arg1: index) { 26 // expected-error@+1 {{op expects as many subscripts as affine map inputs}} 27 "affine.load"(%arg0, %arg1) 28 {map = affine_map<(i, j) -> (i, j)> } : (memref<?x?xf32>, index) -> f32 29} 30 31// ----- 32 33func @store_too_many_subscripts(%arg0: memref<?x?xf32>, %arg1: index, %arg2: index, 34 %arg3: index, %val: f32) { 35 // expected-error@+1 {{expects the number of subscripts to be equal to memref rank}} 36 "affine.store"(%val, %arg0, %arg1, %arg2, %arg3) : (f32, memref<?x?xf32>, index, index, index) -> () 37} 38 39// ----- 40 41func @store_too_many_subscripts_map(%arg0: memref<?x?xf32>, %arg1: index, %arg2: index, 42 %arg3: index, %val: f32) { 43 // expected-error@+1 {{op expects as many subscripts as affine map inputs}} 44 "affine.store"(%val, %arg0, %arg1, %arg2, %arg3) 45 {map = affine_map<(i, j) -> (i, j)> } : (f32, memref<?x?xf32>, index, index, index) -> () 46} 47 48// ----- 49 50func @store_too_few_subscripts(%arg0: memref<?x?xf32>, %arg1: index, %val: f32) { 51 // expected-error@+1 {{expects the number of subscripts to be equal to memref rank}} 52 "affine.store"(%val, %arg0, %arg1) : (f32, memref<?x?xf32>, index) -> () 53} 54 55// ----- 56 57func @store_too_few_subscripts_map(%arg0: memref<?x?xf32>, %arg1: index, %val: f32) { 58 // expected-error@+1 {{op expects as many subscripts as affine map inputs}} 59 "affine.store"(%val, %arg0, %arg1) 60 {map = affine_map<(i, j) -> (i, j)> } : (f32, memref<?x?xf32>, index) -> () 61} 62 63// ----- 64 65func @load_non_affine_index(%arg0 : index) { 66 %0 = memref.alloc() : memref<10xf32> 67 affine.for %i0 = 0 to 10 { 68 %1 = muli %i0, %arg0 : index 69 // expected-error@+1 {{op index must be a dimension or symbol identifier}} 70 %v = affine.load %0[%1] : memref<10xf32> 71 } 72 return 73} 74 75// ----- 76 77func @store_non_affine_index(%arg0 : index) { 78 %0 = memref.alloc() : memref<10xf32> 79 %1 = constant 11.0 : f32 80 affine.for %i0 = 0 to 10 { 81 %2 = muli %i0, %arg0 : index 82 // expected-error@+1 {{op index must be a dimension or symbol identifier}} 83 affine.store %1, %0[%2] : memref<10xf32> 84 } 85 return 86} 87 88// ----- 89 90func @invalid_prefetch_rw(%i : index) { 91 %0 = memref.alloc() : memref<10xf32> 92 // expected-error@+1 {{rw specifier has to be 'read' or 'write'}} 93 affine.prefetch %0[%i], rw, locality<0>, data : memref<10xf32> 94 return 95} 96 97// ----- 98 99func @invalid_prefetch_cache_type(%i : index) { 100 %0 = memref.alloc() : memref<10xf32> 101 // expected-error@+1 {{cache type has to be 'data' or 'instr'}} 102 affine.prefetch %0[%i], read, locality<0>, false : memref<10xf32> 103 return 104} 105 106// ----- 107 108func @dma_start_non_affine_src_index(%arg0 : index) { 109 %0 = memref.alloc() : memref<100xf32> 110 %1 = memref.alloc() : memref<100xf32, 2> 111 %2 = memref.alloc() : memref<1xi32, 4> 112 %c0 = constant 0 : index 113 %c64 = constant 64 : index 114 affine.for %i0 = 0 to 10 { 115 %3 = muli %i0, %arg0 : index 116 // expected-error@+1 {{op src index must be a dimension or symbol identifier}} 117 affine.dma_start %0[%3], %1[%i0], %2[%c0], %c64 118 : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4> 119 } 120 return 121} 122 123// ----- 124 125func @dma_start_non_affine_dst_index(%arg0 : index) { 126 %0 = memref.alloc() : memref<100xf32> 127 %1 = memref.alloc() : memref<100xf32, 2> 128 %2 = memref.alloc() : memref<1xi32, 4> 129 %c0 = constant 0 : index 130 %c64 = constant 64 : index 131 affine.for %i0 = 0 to 10 { 132 %3 = muli %i0, %arg0 : index 133 // expected-error@+1 {{op dst index must be a dimension or symbol identifier}} 134 affine.dma_start %0[%i0], %1[%3], %2[%c0], %c64 135 : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4> 136 } 137 return 138} 139 140// ----- 141 142func @dma_start_non_affine_tag_index(%arg0 : index) { 143 %0 = memref.alloc() : memref<100xf32> 144 %1 = memref.alloc() : memref<100xf32, 2> 145 %2 = memref.alloc() : memref<1xi32, 4> 146 %c0 = constant 0 : index 147 %c64 = constant 64 : index 148 affine.for %i0 = 0 to 10 { 149 %3 = muli %i0, %arg0 : index 150 // expected-error@+1 {{op tag index must be a dimension or symbol identifier}} 151 affine.dma_start %0[%i0], %1[%arg0], %2[%3], %c64 152 : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4> 153 } 154 return 155} 156 157// ----- 158 159func @dma_wait_non_affine_tag_index(%arg0 : index) { 160 %0 = memref.alloc() : memref<100xf32> 161 %1 = memref.alloc() : memref<100xf32, 2> 162 %2 = memref.alloc() : memref<1xi32, 4> 163 %c0 = constant 0 : index 164 %c64 = constant 64 : index 165 affine.for %i0 = 0 to 10 { 166 %3 = muli %i0, %arg0 : index 167 // expected-error@+1 {{op index must be a dimension or symbol identifier}} 168 affine.dma_wait %2[%3], %c64 : memref<1xi32, 4> 169 } 170 return 171} 172