Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function attribute for standard vector calling convention variant: riscv_vector_cc #67

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

kito-cheng
Copy link
Collaborator

@kito-cheng kito-cheng commented Feb 1, 2024

Standard vector calling convention variant has landed in psABI now, and the implementation also merged into GCC trunk, LLVM part are also under reviewing, and this attribute has mentioned during the discussion, but seems like we don't document that yet.


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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

riscv-c-api.md Outdated Show resolved Hide resolved
…scv_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));
```
@kito-cheng
Copy link
Collaborator Author

ChangeLog:

  • Fix typo

Copy link
Collaborator

@cmuellner cmuellner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
But I haven't checked the compiler side (are there patches or is this upstream?).

@sorear
Copy link

sorear commented Feb 2, 2024

(copying my comment from #68 since it applies to both)

Stylistically, since this is a well-defined RISC-V specific ABI attribute independent of any GNU extensions, I wonder if it should be [[riscv:vector_cc]] instead of [[gnu:riscv_vector_cc]]. Probably not since other architectures still seem to be using attributes in the compiler-specific namespace?

I believe that this needs to be included in C++ function pointer mangling to support natural uses (although this doesn't work on aarch64). Do the rules for that need to be specified here?

LGTM otherwise.

@kito-cheng
Copy link
Collaborator Author

Update:

  • Added C++11 and C23 style syntax

@kito-cheng
Copy link
Collaborator Author

Added C++11 and C23 style syntax.

Let me ask our folks to implement that in LLVM and GCC.

hubot pushed a commit to gcc-mirror/gcc that referenced this pull request Mar 1, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
XYenChi pushed a commit to XYenChi/gcc that referenced this pull request Mar 8, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 11, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 13, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 13, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 13, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 13, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/ruyi-gcc that referenced this pull request Mar 15, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
yulong18 pushed a commit to yulong18/ruyisdk-gcc that referenced this pull request Mar 17, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
Liaoshihua pushed a commit to Liaoshihua/gcc that referenced this pull request Mar 19, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
XYenChi pushed a commit to XYenChi/gcc that referenced this pull request Mar 25, 2024
Standard vector calling convention variant will only enabled when function
has vector argument or returning 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.

void foo() __attribute__((riscv_vector_cc));
[[riscv::vector_cc]] void foo(); // For C++11 and C23

For more details please reference the below link.
riscv-non-isa/riscv-c-api-doc#67

gcc/ChangeLog:

	* config/riscv/riscv.cc (TARGET_GNU_ATTRIBUTES): Add riscv_vector_cc
	attribute to riscv_attribute_table.
	(riscv_vector_cc_function_p): Return true if FUNC is a riscv_vector_cc function.
	(riscv_fntype_abi): Add riscv_vector_cc attribute check.
	* doc/extend.texi: Add riscv_vector_cc attribute description.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/attribute-riscv_vector_cc-error.C: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-callee-saved.c: New test.
	* gcc.target/riscv/rvv/base/attribute-riscv_vector_cc-error.c: New test.
@kito-cheng
Copy link
Collaborator Author

GCC and clang/LLVM implementation has merged into trunk[1][2]

[1] gcc-mirror/gcc@4547628
[2] llvm/llvm-project#77560

@kito-cheng kito-cheng merged commit a4821a3 into riscv-non-isa:master Apr 15, 2024
@kito-cheng kito-cheng deleted the riscv_vector_cc branch April 15, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants