brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 5e27893 Raw
158 lines · plain
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics2 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) -> f327}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) -> f3215}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 : index40    // expected-error@+1 {{op operand cannot be used as a dimension id}}41    %v = affine.load %0[%1] : memref<10xf32>42  }43  return44}45 46// -----47 48func.func @store_non_affine_index(%arg0 : index) {49  %0 = memref.alloc() : memref<10xf32>50  %1 = arith.constant 11.0 : f3251  affine.for %i0 = 0 to 10 {52    %2 = arith.muli %i0, %arg0 : index53    // expected-error@+1 {{op operand cannot be used as a dimension id}}54    affine.store %1, %0[%2] : memref<10xf32>55  }56  return57}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  return66}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  return75}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 : index84  %c64 = arith.constant 64 : index85  affine.for %i0 = 0 to 10 {86    %3 = arith.muli %i0, %arg0 : index87    // expected-error@+1 {{op src index must be a valid dimension or symbol identifier}}88    affine.dma_start %0[%3], %1[%i0], %2[%c0], %c6489        : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4>90  }91  return92}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 : index101  %c64 = arith.constant 64 : index102  affine.for %i0 = 0 to 10 {103    %3 = arith.muli %i0, %arg0 : index104    // expected-error@+1 {{op dst index must be a valid dimension or symbol identifier}}105    affine.dma_start %0[%i0], %1[%3], %2[%c0], %c64106        : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4>107  }108  return109}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 : index118  %c64 = arith.constant 64 : index119  affine.for %i0 = 0 to 10 {120    %3 = arith.muli %i0, %arg0 : index121    // expected-error@+1 {{op tag index must be a valid dimension or symbol identifier}}122    affine.dma_start %0[%i0], %1[%arg0], %2[%3], %c64123        : memref<100xf32>, memref<100xf32, 2>, memref<1xi32, 4>124  }125  return126}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 : index135  %c64 = arith.constant 64 : index136  affine.for %i0 = 0 to 10 {137    %3 = arith.muli %i0, %arg0 : index138    // 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  return142}143 144// -----145 146func.func @invalid_symbol() {147  %alloc = memref.alloc() {alignment = 64 : i64} : memref<23x26xf32>148  affine.for %arg1 = 0 to 1 {149    affine.for %arg2 = 0 to 26 {150      affine.for %arg3 = 0 to 23 {151        affine.load %alloc[symbol(%arg1) * 23 + symbol(%arg3), %arg2] : memref<23x26xf32>152        // expected-error@above {{op operand cannot be used as a symbol}}153      }154    }155  }156  return157}158