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