| 1 |
// ----------------------------------------------------------------------------- |
| 2 |
// Tests for the -mrvv-vector-bits flag |
| 3 |
// ----------------------------------------------------------------------------- |
| 4 |
|
| 5 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 6 |
// RUN: -mrvv-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-128 %s |
| 7 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 8 |
// RUN: -mrvv-vector-bits=256 2>&1 | FileCheck --check-prefix=CHECK-256 %s |
| 9 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 10 |
// RUN: -mrvv-vector-bits=512 2>&1 | FileCheck --check-prefix=CHECK-512 %s |
| 11 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 12 |
// RUN: -mrvv-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s |
| 13 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 14 |
// RUN: -mrvv-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s |
| 15 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 16 |
// RUN: -mrvv-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-SCALABLE %s |
| 17 |
|
| 18 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv_zvl256b \ |
| 19 |
// RUN: -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-256 %s |
| 20 |
// RUN: %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv_zvl512b \ |
| 21 |
// RUN: -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-512 %s |
| 22 |
|
| 23 |
// CHECK-128: "-mvscale-max=2" "-mvscale-min=2" |
| 24 |
// CHECK-256: "-mvscale-max=4" "-mvscale-min=4" |
| 25 |
// CHECK-512: "-mvscale-max=8" "-mvscale-min=8" |
| 26 |
// CHECK-1024: "-mvscale-max=16" "-mvscale-min=16" |
| 27 |
// CHECK-2048: "-mvscale-max=32" "-mvscale-min=32" |
| 28 |
|
| 29 |
// CHECK-SCALABLE-NOT: "-mvscale-min= |
| 30 |
// CHECK-SCALABLE-NOT: "-mvscale-max= |
| 31 |
|
| 32 |
// Error out if an unsupported value is passed to -mrvv-vector-bits. |
| 33 |
// ----------------------------------------------------------------------------- |
| 34 |
// RUN: not %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 35 |
// RUN: -mrvv-vector-bits=16 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s |
| 36 |
// RUN: not %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 37 |
// RUN: -mrvv-vector-bits=A 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s |
| 38 |
// RUN: not %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc_zve64x \ |
| 39 |
// RUN: -mrvv-vector-bits=131072 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s |
| 40 |
// RUN: not %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gc \ |
| 41 |
// RUN: -mrvv-vector-bits=zvl 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s |
| 42 |
// RUN: not %clang -c %s -### --target=riscv64-linux-gnu -march=rv64gcv \ |
| 43 |
// RUN: -mrvv-vector-bits=64 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s |
| 44 |
|
| 45 |
// CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option '-mrvv-vector-bits=' |
| 46 |
|
| 47 |
// Error if using attribute without -mrvv-vector-bits=<bits> or if using -mrvv-vector-bits=<bits>+ syntax |
| 48 |
// ----------------------------------------------------------------------------- |
| 49 |
// RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \ |
| 50 |
// RUN: -march=rv64gc_zve64x 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s |
| 51 |
// RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \ |
| 52 |
// RUN: -march=rv64gc_zve64x -mrvv-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s |
| 53 |
|
| 54 |
typedef __rvv_int32m1_t vint32m1_t; |
| 55 |
typedef vint32m1_t noflag __attribute__((riscv_rvv_vector_bits(256))); |
| 56 |
|
| 57 |
// CHECK-NO-FLAG-ERROR: error: 'riscv_rvv_vector_bits' is only supported when '-mrvv-vector-bits=<bits>' is specified with a value of "zvl" or a power 2 in the range [64,65536] |
| 58 |
|
| 59 |
// Error if attribute vector size != -mrvv-vector-bits |
| 60 |
// ----------------------------------------------------------------------------- |
| 61 |
// RUN: not %clang -c %s -o /dev/null -target riscv64-linux-gnu \ |
| 62 |
// RUN: -march=rv64gc_zve64x -mrvv-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-BAD-VECTOR-SIZE-ERROR %s |
| 63 |
|
| 64 |
typedef vint32_t bad_vector_size __attribute__((riscv_rvv_vector_bits(256))); |
| 65 |
|
| 66 |
// CHECK-BAD-VECTOR-SIZE-ERROR: error: invalid RVV vector size '256', expected size is '128' based on LMUL of type and '-mrvv-vector-bits' |