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

Richard Sandiford via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 30 07:33:13 PDT 2020


rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, danielkiss, psnobl, rkruppe, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
rsandifo-arm edited the summary of this revision.

SVE types are defined to be opaque built-in types that by default
can only be used via intrinsics.  One consequence of this is that
the types provide no built-in versions of the unary and binary
arithmetic operators.

Instead, we'd like to allow users to define non-member operators
for SVE types, in much the same way as for enumeration types.
This specifically means:

- replacing "enumeration" in sections [over.match.oper] and [over.oper] of the C++ standard with wording that includes both enumerations and SVE types.

- extending the enumeration handling of operator= in [over.built] to include SVE types.

This feature is defined by a to-be-published update to the SVE ACLE spec.
The feature is optional and its availability can be tested by the
preprocessor condition:

  __ARM_FEATURE_SVE_NONMEMBER_OPERATORS==1

An alternative would be to build the operators into the compiler.
However, we didn't want to do that for several reasons:

- Some of the operators would not be performance-portable. (E.g. %, and the 8-bit and 16-bit integer versions of /.) The SVE ACLE is supposed to be a low-level, almost asm-level interface to the architecture, so synthesising this kind of operation seems out-of-place.

- SVE types cannot be used in structures, so unlike with normal vector types, the user doesn't have the option of using a wrapper class to opt out of the standard handling.

- If in future we do want to provide a core group of operators in a standard header file/module, we could use this extension to write it.

The patch triggers a duplicate warning for:

  ref_int8 = ref_int8;

but it seemed better to fix that separately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77056

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/sizeless-1.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77056.253586.patch
Type: text/x-patch
Size: 13259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200330/faece38c/attachment-0001.bin>


More information about the cfe-commits mailing list