-
Notifications
You must be signed in to change notification settings - Fork 165
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
Name mangling for standard vector calling convention #422
base: master
Are you sure you want to change the base?
Conversation
Add extra name mangling rule for standard vector calling convention on C++ ABI, fortunately the Itanium C++ ABI already defined mangling rule for ABI tag, so we just need to define the ABI tag name. Example for the mangling rule: ```c __attribute__((riscv_vector_cc)) void foo(); // _Z3fooB15riscv_vector_ccv with this mangling rule // _Z3foov without this mangling rule ```
@@ -433,6 +433,10 @@ NOTE: `setjmp`/`longjmp` follow the standard calling convention, which clobbers | |||
all vector registers. Hence, the standard vector calling convention variant | |||
won't disrupt the `jmp_buf` ABI. | |||
|
|||
NOTE: Functions that use the standard vector calling convention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to specially mangle the names of functions that use the vector calling convention. While arguably useful for function multi-versioning and the [[gnu::target_version]]
attribute in particular, this is orthogonal to C++ overload resolution.
We do need to mangle function pointer types that use the vector calling convention, whether or not the function taking the parameter itself uses the vector calling convention, to allow overloading a function that takes arguments with different ABIs.
=== Name Mangling for Standard Calling Convention Variant | ||
|
||
Function use standard calling convention variant have to append extra ABI tag to | ||
the function name mangling, the rule are same as the "ABI tags" section in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ABI tags (B) are used for the GNU abi_tag extension, which uses a string that is entirely under the control of a library author. It is probably wrong to use for architecture-specific features, and it does not fix my original example since it cannot be used on unnamed entities.
I was originally thinking of using a vendor-defined pointer qualifier as defined in 5.1.5.1 Qualified types, but the closest existing thing to what I'm asking for is the definition of Dx in 5.1.5.3 Function types. We may need upstream guidance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I thought it work? https://gcc.godbolt.org/z/95shE9a13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(let me read the Itanium C++ ABI more carefully again)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f
and g
in your example have the same calling convention, so there's no need for the compiler to generate two versions. If you add __attribute__((aarch64_sve_pcs))
to g
, it breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, I got your main point: it should mangling function (pointer) type, not function name, I thought abi_tag works for function type but it only decorate/mangling function name.
I filed itanium-cxx-abi/cxx-abi#178 to maybe get an expert opinion. Hope that isn't overstepping. |
Thanks for doing this, I think you are better person to create that since you have more context than me on this, will support you on that PR if needed :) |
swiftcall in clang appears to already have the behavior we need. |
Change to draft since this PR is not intend to merge so far, but we may keep this PR for keep tracking and/or discuss this issue. |
Oh, I should reply after read the PR, I didn't notice there is some discussion within the PR, anyway let me find some time to update and update this PR later. (@sorear you can create another PR if you are interested since I may deal with other stuffs around the psABI repo first) |
Not really spec related, but kinda bookmark for myself: clang implementation for Swift name mangling: |
Add extra name mangling rule for standard vector calling convention on C++ ABI, fortunately the Itanium C++ ABI already defined mangling rule for ABI tag, so we just need to define the ABI tag name.
Example for the mangling rule: