From 3aa930dc7dae8931f5f29bc4956028f6f3cade44 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Thu, 1 Feb 2024 15:32:42 +0800 Subject: [PATCH 1/2] Function attribute for standard vector calling convention variant: riscv_vector_cc Standard vector calling convention variant will only enabled when function has vector argument or returing value by default, however user may also want to invoke function without that during a vectorized loop at some situation, but it will cause a huge performance penalty due to vector register store/restore. So user can declare function with this riscv_vector_cc attribute like below, that could enforce function will use standard vector calling convention variant. ```c void foo() __attribute__((riscv_vector_cc)); ``` --- riscv-c-api.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/riscv-c-api.md b/riscv-c-api.md index c2300f6..6b6dd51 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -318,6 +318,12 @@ __attribute__((target("arch=+v"))) int foo(void) { return 0; } __attribute__((target("arch=+zbb"))) int foo(void) { return 1; } ``` +### `__attribute__((riscv_vector_cc))` + +Functions declared with this attribute will use to the standard vector calling +convention variant as defined in the RISC-V psABI, even if the function has +vector arguments or a return value. + ## Intrinsic Functions Intrinsic functions (or intrinsics or built-ins) are expanded into instruction sequences by compilers. From cf54e25df565142ac262f40dada6534d9526689b Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Fri, 2 Feb 2024 21:09:48 +0800 Subject: [PATCH 2/2] Add C++11 and C23 style syntax for riscv_vector_cc --- riscv-c-api.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/riscv-c-api.md b/riscv-c-api.md index 6b6dd51..c149681 100644 --- a/riscv-c-api.md +++ b/riscv-c-api.md @@ -318,7 +318,14 @@ __attribute__((target("arch=+v"))) int foo(void) { return 0; } __attribute__((target("arch=+zbb"))) int foo(void) { return 1; } ``` -### `__attribute__((riscv_vector_cc))` +### riscv_vector_cc + +Supported Syntaxes: +| Style | Syntax | +| ------ | ----------------------------------- | +| GNU | `__attribute__((riscv_vector_cc)))` | +| C++11 | `[[riscv::vector_cc]]` | +| C23 | `[[riscv::vector_cc]]` | Functions declared with this attribute will use to the standard vector calling convention variant as defined in the RISC-V psABI, even if the function has