Skip to content

Commit

Permalink
fixup! [clang][RISCV] Enable RVV with function attribute __attribute_…
Browse files Browse the repository at this point in the history
…_((target("arch=+v")))
  • Loading branch information
4vtomat committed Mar 6, 2024
1 parent 0edc7d9 commit 70faceb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
22 changes: 22 additions & 0 deletions clang/test/CodeGen/RISCV/riscv-func-attr-target-err.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
// RUN: not %clang_cc1 -triple riscv64 -target-feature +zifencei -target-feature +m -target-feature +a \
// RUN: -emit-llvm %s 2>&1 | FileCheck %s

#include <riscv_vector.h>

void test_builtin() {
// CHECK: error: '__builtin_rvv_vsetvli' needs target feature zve32x
__riscv_vsetvl_e8m8(1);
}

void test_rvv_i32_type() {
// CHECK: error: RISC-V type 'vint32m1_t' (aka '__rvv_int32m1_t') requires the 'zve32x' extension
vint32m1_t v;
}

void test_rvv_f32_type() {
// CHECK: error: RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension
vfloat32m1_t v;
}

void test_rvv_f64_type() {
// CHECK: error: RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension
vfloat64m1_t v;
}

// CHECK: error: duplicate 'arch=' in the 'target' attribute string;
__attribute__((target("arch=rv64gc;arch=rv64gc_zbb"))) void testMultiArchSelectLast() {}
// CHECK: error: duplicate 'cpu=' in the 'target' attribute string;
Expand Down
33 changes: 33 additions & 0 deletions clang/test/CodeGen/RISCV/riscv-func-attr-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// RUN: -target-feature -relax -target-feature -zfa \
// RUN: -emit-llvm %s -o - | FileCheck %s

#include <riscv_vector.h>

// CHECK-LABEL: define dso_local void @testDefault
// CHECK-SAME: () #0 {
void testDefault() {}
Expand Down Expand Up @@ -35,6 +37,34 @@ testAttrFullArchAndAttrCpu() {}
// CHECK-SAME: () #8 {
__attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}

__attribute__((target("arch=+zve32x")))
void test_builtin_w_zve32x() {
// CHECK-LABEL: test_builtin_w_zve32x
// CHECK-SAME: #9
__riscv_vsetvl_e8m8(1);
}

__attribute__((target("arch=+zve32x")))
void test_rvv_i32_type_w_zve32x() {
// CHECK-LABEL: test_rvv_i32_type_w_zve32x
// CHECK-SAME: #9
vint32m1_t v;
}

__attribute__((target("arch=+zve32f")))
void test_rvv_f32_type_w_zve32f() {
// CHECK-LABEL: test_rvv_f32_type_w_zve32f
// CHECK-SAME: #11
vfloat32m1_t v;
}

__attribute__((target("arch=+zve64d")))
void test_rvv_f64_type_w_zve64d() {
// CHECK-LABEL: test_rvv_f64_type_w_zve64d
// CHECK-SAME: #12
vfloat64m1_t v;
}

//.
// CHECK: attributes #0 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zifencei,-relax,-zbb,-zfa" }
// 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" }
Expand All @@ -46,3 +76,6 @@ __attribute__((target("cpu=sifive-u54"))) void testAttrCpuOnly() {}
// CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+m,+save-restore,+zbb,+zifencei,-relax,-zfa" }
// CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+m,+save-restore,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" }
// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" "target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zicsr,+zifencei,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}" }
// CHECK: attributes #9 = { {{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zicsr,+zifencei,+zve32x,+zvl32b,-relax,-zbb,-zfa" }
// CHECK: attributes #11 = { {{.*}}"target-features"="+64bit,+a,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zvl32b,-relax,-zbb,-zfa" }
// CHECK: attributes #12 = { {{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl32b,+zvl64b,-relax,-zbb,-zfa" }
41 changes: 0 additions & 41 deletions clang/test/Sema/riscv-function-target-attr.c

This file was deleted.

0 comments on commit 70faceb

Please sign in to comment.