Name mangling for standard vector calling convention#422
Name mangling for standard vector calling convention#422kito-cheng wants to merge 1 commit intomasterfrom
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 ```
| 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.
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.
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.
Wait, I thought it work? https://gcc.godbolt.org/z/95shE9a13
There was a problem hiding this comment.
(let me read the Itanium C++ ABI more carefully again)
There was a problem hiding this comment.
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.
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: |
|
LGTM, and do we need a version number in the doc to deal possible future version changes. |
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: