https://sourceware.org/bugzilla/show_bug.cgi?id=33660

            Bug ID: 33660
           Summary: C++filt should demangle vector function ABI too!
                    (_ZGVbN2v_sin)
           Product: binutils
           Version: 2.45
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: arthur200126 at gmail dot com
  Target Milestone: ---

glibc and other vector-math libraries have for a long time adopted a "vector
function ABI" which uses Itanium's _ZGV namespace to describe vectorized
variants of functions. Examples include:

* _ZGVbN2v_sin
* _ZGVbM4ua16vl__Z3fooPffi -- can be used with regular C++ mangling!

etc.

Descriptions of the mangling rules are somewhat partial, but GCC is able to
produce these names organically if one adds `#pragma omp declare simd ...`
before a function declaration.

Useful documents include:
*
https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt
-- describes the ABI on x86-64 as well as the pragma syntax required to produce
it on GCC
*
https://github.com/llvm/llvm-project/blob/13a39eaa0bcf6c439e8b59571f4afe593d658623/llvm/lib/IR/VFABIDemangler.cpp
-- describes the ABI on x86-64 and ARM
* https://cdrdv2-public.intel.com/679047/Intel-ABI-Vector-Function-v0.9.8.pdf
-- describes Intel's intentions wrt what syntax should be used by the compiler,
not used by GCC but is used by ICC

Godbolt link with these names being produced: https://godbolt.org/z/nYTx6anhq

* * *

Now an obvious questions is "what should we demangle to?", because the pragma
say nothing about the ISA-class (the "b" part right after _ZGV, indicating
SSE/128-bit regs) and whether mask is used (the "N" part after the b). A
speculative demangle that will definitely not compile (but does get the point
across) might be:

* _Pragma("omp declare simd simdlen(2) __vector(#1) __nomask") sin -- because
we do not know the parameter name, the made-up "__vector" property uses an
argument number 
* _Pragma("omp declare simd simdlen(4) uniform(#1) aligned(#1:16) __vector(#2)
linear(#3:1)") foo(float*, float, int) -- compare to the original declaration,
`#pragma omp declare simd uniform(q) aligned(q:16) linear(k:1)\nfloat foo(float
*q, float x, int k)`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to