[PATCH] D77056: [Sema] Allow non-member operators for sizeless SVE types

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 8 13:27:08 PST 2021


rsmith added a comment.

In D77056#2465936 <https://reviews.llvm.org/D77056#2465936>, @rsandifo-arm wrote:

> Either way, I realise this isn't great style.  It just seems like a practical compromise between the rock of classes having a constant size and the hard place of vectors having a variable length.

I don't think this is just a question of style; it's a severe limitation to language functionality. In a very broad sense, you would not be able to use these types with templates. For example, even if you define an `operator<` between `svint8_t`, you can't use `std::min` between two `svint8_t`'s. And people are going to try to work around that by defining the operators first, then `#include`ing the algorithms in question, which will lead to ODR issues, will break when C++ modules is enabled, and so on.

It's also a little unclear to me what the motivation for this is. Do you really want to permit (for example) an `operator+` between sizeless vectors that does something other than element-wise addition? If not, then why do we not instead directly provide built-in support for these operators, as we do for all our other vector types?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77056/new/

https://reviews.llvm.org/D77056



More information about the cfe-commits mailing list