-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][RISCV] Support function attribute __attribute__((target("+att…
…r"))) It is currently not possible to use "RVV type" and "RVV intrinsics" if the "zve32x" is not enabled globally. However in some cases we may want to use them only in some functions, for instance: ``` #include <riscv_vector.h> __attribute__((target("+zve32x"))) vint32m1_t rvv_add(vint32m1_t v1, vint32m1_t v2, size_t vl) { return __riscv_vadd(v1, v2, vl); } int other_add(int i1, int i2) { return i1 + i2; } ``` , it is supposed to be compilable even the vector is not specified, e.g. `clang -target riscv64 -march=rv64gc -S test.c`.
- Loading branch information
Showing
10 changed files
with
73 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o - | ||
// RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -S -verify %s -o - | ||
|
||
unsigned int orc_b_64(unsigned int a) { | ||
return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 'RV64'}} | ||
return __builtin_riscv_orc_b_64(a); // expected-error {{'__builtin_riscv_orc_b_64' needs target feature zbb,64bit}} | ||
} |
12 changes: 4 additions & 8 deletions
12
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -verify %s -o - | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +zbkb -S -verify %s -o - | ||
|
||
#include <stdint.h> | ||
|
||
uint32_t zip(uint32_t rs1) | ||
uint32_t zip_unzip(uint32_t rs1) | ||
{ | ||
return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires: 'RV32'}} | ||
} | ||
|
||
uint32_t unzip(uint32_t rs1) | ||
{ | ||
return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires: 'RV32'}} | ||
(void)__builtin_riscv_zip_32(rs1); // expected-error {{'__builtin_riscv_zip_32' needs target feature zbkb,32bit}} | ||
return __builtin_riscv_unzip_32(rs1); // expected-error {{'__builtin_riscv_unzip_32' needs target feature zbkb,32bit}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py | ||
// RUN: %clang_cc1 -triple riscv64 -S -verify %s | ||
|
||
// REQUIRES: riscv-registered-target | ||
#include <riscv_vector.h> | ||
|
||
void test_builtin() { | ||
__riscv_vsetvl_e8m8(1); // expected-error {{'__builtin_rvv_vsetvli' needs target feature zve32x}} | ||
} | ||
|
||
__attribute__((target("+zve32x"))) | ||
void test_builtin_w_zve32x() { | ||
__riscv_vsetvl_e8m8(1); | ||
} | ||
|
||
void test_rvv_i32_type() { | ||
vint32m1_t v; // expected-error {{RISC-V type 'vint32m1_t' (aka '__rvv_int32m1_t') requires the 'zve32x' extension}} | ||
} | ||
|
||
__attribute__((target("+zve32x"))) | ||
void test_rvv_i32_type_w_zve32x() { | ||
vint32m1_t v; | ||
} | ||
|
||
void test_rvv_f32_type() { | ||
vfloat32m1_t v; // expected-error {{RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension}} | ||
} | ||
|
||
__attribute__((target("+zve32f"))) | ||
void test_rvv_f32_type_w_zve32f() { | ||
vfloat32m1_t v; | ||
} | ||
|
||
void test_rvv_f64_type() { | ||
vfloat64m1_t v; // expected-error {{RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64x' extension}} | ||
} | ||
|
||
__attribute__((target("+zve64d"))) | ||
void test_rvv_f64_type_w_zve64d() { | ||
vfloat64m1_t v; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters