[Dwarf-discuss] ISSUE: CPU vector types.

Pedro Alves pedro@palves.net
Tue Apr 4 11:14:33 GMT 2023


On 2023-04-04 11:09 a.m., Pedro Alves wrote:
> On 2023-04-04 12:22 a.m., Kyle Huey wrote:
>> On Mon, Apr 3, 2023 at 12:42 PM Pedro Alves via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org <mailto:dwarf-discuss@lists.dwarfstd.org>> wrote:
>>
>>     Hi Ben,
>>
>>     On 2023-03-24 6:19 p.m., Ben Woodard via Dwarf-discuss wrote:
>>
>>     > I will admit that in its current state it is a work in progress. My original intent was to simply
>>     > codify the existing behavior as implemented by GCC and LLVM (and probably other compilers) moving it
>>     > from a vendor attribute to something that was in the standard.
>>
>>     In light of the recent discussion, I was thinking how it would help if the
>>     proposal was laid out in terms of vector types instead of hardware registers.
>>
>>
>> I think the proposed language here is a bit too C/C++ centric.
> 
> This is introducing the need for the attribute.  The audience is the committee, not DWARF spec readers,
> because none of this text would end up in the spec.  It is just setting the ground.  It is true that other
> languages have vector types as well, but I'd think that even if only C/C++ had them, that would
> not be reason to not support the types.  But we can certainly tweak the language to cover other languages.

Here's what I would suggest.

~~~~~~~~~
Vector types

Some languages support vector data types, which are not possible to
represent today in standard DWARF.  In very broad strokes, a vector is
an array of values.  These can be allocated to a SIMD vector register,
if available, either permanently or temporarily, and operations on
vectors make use of SIMD instructions, again if available.

For example, as an extension to C and C++, GCC supports defining
vector data types as described here:

  https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html

In this C/C++ extension, vector types are similar to arrays, and you
can index and initialize them similarly, but they have some important
differences.  For example:

- C arrays automatically decay to pointers.  Vector types do not.

- You can pass vector types by value to functions, and likewise
  functions can return vector types by value.  You can not do either
  with C arrays.

- Vector types can be used with a subset of normal C operations: +, -,
  *, /, unary minus, ^, |, &, ~, %.  For example, addition is defined as
  the addition of the corresponding elements of the operands.

A debugger that supports C/C++ expression evaluation will want to be
able to support these vector operations on vector objects too.

Vector types appear on function prototypes, so they have their own
mangling scheme in the Itanium ABI.

Other vendors have similar C/C++ extensions.  For example, Motorola’s
Altivec C/C++ Language Extensions, which predates GCC's extensions.

To distinguish these vector types from regular C arrays, GCC's DWARF
describes a vector type as an array with the DW_AT_GNU_vector
attribute.  Clang also supports the GCC vector extensions, and
describes the vector types in DWARF using the same attribute as GCC.
Support for this DWARF extension has been implemented in GDB for well
over a decade.

Other languages have support for vector types, with similar ABI and/or
API implications, and so DW_AT_GNU_vector is also used for languages
beyond C/C++ today.

This proposal standardizes the existing behavior.
~~~~~~~~~


More information about the Dwarf-discuss mailing list