Skip to content

Commit f4d33d9

Browse files
committed
fixup! [clang][RISCV] Enable RVV with function attribute __attribute__((target("arch=+v")))
1 parent f1d1262 commit f4d33d9

File tree

3 files changed

+55
-41
lines changed

3 files changed

+55
-41
lines changed

clang/test/CodeGen/RISCV/riscv-func-attr-target-err.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
// RUN: not %clang_cc1 -triple riscv64 -target-feature +zifencei -target-feature +m -target-feature +a \
33
// RUN: -emit-llvm %s 2>&1 | FileCheck %s
44

5+
#include <riscv_vector.h>
6+
7+
void test_builtin() {
8+
// CHECK: error: '__builtin_rvv_vsetvli' needs target feature zve32x
9+
__riscv_vsetvl_e8m8(1);
10+
}
11+
12+
void test_rvv_i32_type() {
13+
// CHECK: error: RISC-V type 'vint32m1_t' (aka '__rvv_int32m1_t') requires the 'zve32x' extension
14+
vint32m1_t v;
15+
}
16+
17+
void test_rvv_f32_type() {
18+
// CHECK: error: RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension
19+
vfloat32m1_t v;
20+
}
21+
22+
void test_rvv_f64_type() {
23+
// CHECK: error: RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension
24+
vfloat64m1_t v;
25+
}
26+
527
// CHECK: error: duplicate 'arch=' in the 'target' attribute string;
628
__attribute__((target("arch=rv64gc;arch=rv64gc_zbb"))) void testMultiArchSelectLast() {}
729
// CHECK: error: duplicate 'cpu=' in the 'target' attribute string;

clang/test/CodeGen/RISCV/riscv-func-attr-target.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// RUN: -target-feature -relax -target-feature -zfa \
55
// RUN: -emit-llvm %s -o - | FileCheck %s
66

7+
#include <riscv_vector.h>
8+
79
// CHECK-LABEL: define dso_local void @testDefault
810
// CHECK-SAME: () #0 {
911
void testDefault() {}
@@ -35,6 +37,34 @@ testAttrFullArchAndAttrCpu() {}
3537
// CHECK-SAME: () #8 {
3638
__attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}
3739

40+
__attribute__((target("arch=+zve32x")))
41+
void test_builtin_w_zve32x() {
42+
// CHECK-LABEL: test_builtin_w_zve32x
43+
// CHECK-SAME: #9
44+
__riscv_vsetvl_e8m8(1);
45+
}
46+
47+
__attribute__((target("arch=+zve32x")))
48+
void test_rvv_i32_type_w_zve32x() {
49+
// CHECK-LABEL: test_rvv_i32_type_w_zve32x
50+
// CHECK-SAME: #9
51+
vint32m1_t v;
52+
}
53+
54+
__attribute__((target("arch=+zve32f")))
55+
void test_rvv_f32_type_w_zve32f() {
56+
// CHECK-LABEL: test_rvv_f32_type_w_zve32f
57+
// CHECK-SAME: #11
58+
vfloat32m1_t v;
59+
}
60+
61+
__attribute__((target("arch=+zve64d")))
62+
void test_rvv_f64_type_w_zve64d() {
63+
// CHECK-LABEL: test_rvv_f64_type_w_zve64d
64+
// CHECK-SAME: #12
65+
vfloat64m1_t v;
66+
}
67+
3868
//.
3969
// CHECK: attributes #0 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei,-relax,-zbb,-zfa" }
4070
// CHECK: attributes #1 = { {{.*}}"target-cpu"="rocket-rv64" "target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zbb,-zfa" "tune-cpu"="generic-rv64" }
@@ -46,3 +76,6 @@ __attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}
4676
// CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei,-relax,-zfa" }
4777
// CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+m,+save-restore,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" }
4878
// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zicsr,+zifencei,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" }
79+
// CHECK: attributes #9 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zicsr,+zifencei,+zve32x,+zvl32b,-relax,-zbb,-zfa" }
80+
// CHECK: attributes #11 = { {{.*}}"target-features"="+64bit,+a,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zvl32b,-relax,-zbb,-zfa" }
81+
// CHECK: attributes #12 = { {{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl32b,+zvl64b,-relax,-zbb,-zfa" }

clang/test/Sema/riscv-function-target-attr.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)