Re: Understanding arm_sve.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 15 Jan 2025, at 15:51, David Aldrich <david.aldrich.ntml@xxxxxxxxx> wrote:
> 
> On Wed, Jan 15, 2025 at 1:54 PM Kyrylo Tkachov <ktkachov@xxxxxxxxxx> wrote:
>> 
>> Hi David,
>> 
>>> On 15 Jan 2025, at 13:33, David Aldrich via Gcc-help <gcc-help@xxxxxxxxxxx> wrote:
>>> 
>>> Hi
>>> 
>>> The gcc Arm compiler aarch64-linux-gnu (v14) provides the following
>>> Arm intrinsics header file:
>>> 
>>> \usr\lib\gcc\aarch64-linux-gnu\14\include\arm_sve.h
>>> 
>>> However,  this header file uses a pragma to generate the definitions:
>>> 
>>> /* NOTE: This implementation of arm_sve.h is intentionally short.  It does
>>>  not define the SVE types and intrinsic functions directly in C and C++
>>>  code, but instead uses the following pragma to tell GCC to insert the
>>>  necessary type and function definitions itself.  The net effect is the
>>>  same, and the file is a complete implementation of arm_sve.h.  */
>>> #pragma GCC aarch64 "arm_sve.h"
>>> 
>>> I don't understand how this works.
>>> 
>> 
>> The idea is that rather than implementing every ACLE intrinsic as a wrapper around an builtin, annotated with attributes like always_inline etc the compiler injects
>> the necessary intrinsic definitions directly into the language when it encounters this aarch64-specific pragma.
>> This has a number of advantages, among others:
>> * It avoids having to parse a large regular .h file during compilation
>> * It allows the compiler to handle some of the more elaborate features of SVE intrinsics such as overloading and type deduction during name resolution.
>> * It allows for more powerful custom validation of intrinsic arguments (like enforcing strict compile-time literal arguments for vector lanes) and more helpful error message
>> 
>>> I would like to inspect the actual definitions of the intrinsics. Is
>>> it possible to view the actual definitions?
>>> 
>> 
>> The downside is there’s no single self-contained file that interested readers can look at.
>> You can find the code that creates these definitions for SVE in the GCC source in the files named aarch64-sve-builtins-*.cc under the gcc/config/aarch64 subdirectory:
>> https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/config/aarch64;h=7f0aea8187549eefa9c3c6d046a3f56183dc2a69;hb=HEAD
>> 
>> Thanks,
>> Kyrill
>> 
> 
> Hi Kyrill
> 
> Thanks very much for your explanation. I looked at
> aarch64-sve-builtins-*.cc but don't think it will help me.
> 
> Unfortunately, another downside is that IDE assistance such as
> Microsoft Visual Studio's Intellisense can't provide help with these
> functions, unless the internal compiler understands how to generate
> the definitions, which is unlikely.
> 

I see. I guess it depends on what exactly you’re after. If you want a human-readable/searchable reference of the available SVE intrinsics then the intrinsics documentation is the better resource:
https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:@navigationhierarchiessimdisa=[sve] <https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:@navigationhierarchiessimdisa=%5Bsve%5D>
That page describes everything that the user should care about in the intrinsic: name, type signature, expected assembly, argument preparation etc.

If you want something that a tool would parse then for the Neon/Advanced SIMD intrinsics there is a CSV-style list in the ACLE GitHub:
https://github.com/ARM-software/acle/blob/main/neon_intrinsics/advsimd.md
But I’m not sure if there’s such a resource for the SVE ones.

The contents of the compiler-provided headers like arm_sve.h, arm_neon.h and others aren’t intended to be user-legible and are considered to be an implementation detail so I wouldn’t try relying on their exact contents unless it’s for your personal education.

Thanks,
Kyrill

> Best regards
> David





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux