brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 0b1dab9 Raw
80 lines · plain
1// REQUIRES: arm-emulator2 3// DEFINE: %{compile} = mlir-opt %s \4// DEFINE:   --arm-sve-legalize-vector-storage --convert-vector-to-scf --convert-scf-to-cf  --convert-vector-to-llvm='enable-arm-sve' \5// DEFINE:   --expand-strided-metadata    --lower-affine --convert-to-llvm --finalize-memref-to-llvm  --reconcile-unrealized-casts \6// DEFINE: -o %t7 8// DEFINE: %{entry_point} = main9 10// DEFINE: %{run} = %mcr_aarch64_cmd %t -e %{entry_point} -entry-point-result=void  --march=aarch64 --mattr="+sve" \11// DEFINE:    -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils,%native_mlir_arm_runner_utils12 13// RUN: rm -f %t && %{compile} && %{run} | FileCheck %s14 15// Test the transfer_read with vector type with a non-trailing scalable16// dimension as transformed by the pattern LegalizeTransferRead.17 18func.func @transfer_read_scalable_non_trailing(%M : memref<?x8xi8>) attributes {no_inline} {19  // Read an LLVM-illegal vector20  %c0 = arith.constant 0 : index21  %c0_i8 = arith.constant 0 : i822  %A = vector.transfer_read %M[%c0, %c0], %c0_i8 {in_bounds = [true, true]} : memref<?x8xi8>, vector<[4]x8xi8>23 24  // Print the vector, for verification.25  %B = vector.shape_cast %A : vector<[4]x8xi8> to vector<[32]xi8>26  func.call @printVec(%B) : (vector<[32]xi8>) -> ()27 28  return29}30 31func.func @main() {32 33  %c0 = arith.constant 0 : index34 35// Prepare an 8x8 buffer with test data. The test performs two reads36// of a [4]x8 vector from the buffer. One read, with vector length 128 bits,37// reads the first half the buffer. The other read, with vector length38// 256 bits, reads the entire buffer.39  %T = arith.constant dense<[[11, 12, 13, 14, 15, 16, 17, 18],40                             [21, 22, 23, 24, 25, 26, 27, 28],41                             [31, 32, 33, 34, 35, 36, 37, 38],42                             [41, 42, 43, 44, 45, 46, 47, 48],43                             [51, 52, 53, 54, 55, 56, 57, 58],44                             [61, 62, 63, 64, 65, 66, 67, 68],45                             [71, 72, 73, 74, 75, 76, 77, 78],46                             [81, 82, 83, 84, 85, 86, 87, 88]]> : vector<8x8xi8>47 48  %M = memref.alloca() : memref<8x8xi8>49  vector.transfer_write %T, %M[%c0, %c0] : vector<8x8xi8>, memref<8x8xi8>50  %MM = memref.cast %M : memref<8x8xi8> to memref<?x8xi8>51 52// CHECK-LABEL: Result(VL128):53// CHECK:( 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28 )54// CHECK:( 31, 32, 33, 34, 35, 36, 37, 38, 41, 42, 43, 44, 45, 46, 47, 48 )55  vector.print str "Result(VL128):\n"56  %c128 = arith.constant 128 : i3257  func.call @setArmVLBits(%c128) : (i32) -> ()58  func.call @transfer_read_scalable_non_trailing(%MM) : (memref<?x8xi8>) -> ()59 60// CHECK-LABEL: Result(VL256):61// CHECK: ( 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 41, 42, 43, 44, 45, 46, 47, 48 )62// CHECK: ( 51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 68, 71, 72, 73, 74, 75, 76, 77, 78, 81, 82, 83, 84, 85, 86, 87, 88 )63  vector.print str "Result(VL256):\n"64  %c256 = arith.constant 256 : i3265  func.call @setArmVLBits(%c256) : (i32) -> ()66  func.call @transfer_read_scalable_non_trailing(%MM) : (memref<?x8xi8>) -> ()67 68  return69}70 71func.func private @printVec(%v : vector<[32]xi8>) {72  %v0 = vector.scalable.extract %v[0] : vector<[16]xi8> from vector<[32]xi8>73  %v1 = vector.scalable.extract %v[16] : vector<[16]xi8> from vector<[32]xi8>74  vector.print %v0 : vector<[16]xi8>75  vector.print %v1 : vector<[16]xi8>76  return77}78 79func.func private @setArmVLBits(%bits : i32)80