[clang] [Clang] Treat `ext_vector_type` as a regular type attribute (PR #130177)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 6 16:10:16 PST 2025


jhuber6 wrote:

> I'm not super thrilled about NOT having to introduce a type name, I'm not looking forward to the exciting world of `void foo(int __attribute__((ext_vector_type(4))) x)` replacing `void foo(int4 x)`.

This makes introducing a type name easier because you can use `using` with templates. But I really don't think that it makes sense to restrict this to `only` typedef, it's even listed as a FIXME in the original patch.

> I am extremely not at ease with flipping this to be a C++ attribute. Back in the dawn of time, C++ attributes were meant to be non-semantic / removable with no effect. This has kindof become muddled throughout the years, and we're probably moving away from that, and yes you have namespaced it, but I'd like such things to not be super cute and to remain clearly double prefix scary things.

I think https://github.com/llvm/llvm-project/commit/301eb6b68f30074ee3a90e2dfbd11dfd87076323 tried to solve some of those issues. A lot of type / expression level attributes are expected to be droppable, but we have tons of existing ones that definitely aren't. E.g. address spaces and the fifty different vector types for each target. I could force it to be double prefixed, but this really still should be a type level attribute, since it maps 1-to-1 with the LLVM vector type. I'd greatly prefer not to arbitrarily restrict it though, since it would be a major outlier.

https://github.com/llvm/llvm-project/pull/130177


More information about the cfe-commits mailing list