[clang][aarch64] ACLE: Support implicit casts between GNU and SVE vectors
authorCullen Rhodes <cullen.rhodes@arm.com>
Fri, 11 Sep 2020 15:18:44 +0000 (15:18 +0000)
committerCullen Rhodes <cullen.rhodes@arm.com>
Thu, 17 Sep 2020 09:35:30 +0000 (09:35 +0000)
commit9218f9283802b2d1ff33c490761fdb925b1e56d9
tree83af8d4e02c499b238091cf794fbf7c9798de041
parentc687af0c30b4dbdc9f614d5e061c888238e0f9c5
[clang][aarch64] ACLE: Support implicit casts between GNU and SVE vectors

This patch adds support for implicit casting between GNU vectors and SVE
vectors when `__ARM_FEATURE_SVE_BITS==N`, as defined by the Arm C
Language Extensions (ACLE, version 00bet5, section 3.7.3.3) for SVE [1].

This behavior makes it possible to use GNU vectors with ACLE functions
that operate on VLAT. For example:

  typedef int8_t vec __attribute__((vector_size(32)));
  vec f(vec x) { return svasrd_x(svptrue_b8(), x, 1); }

Tests are also added for implicit casting between GNU and fixed-length
SVE vectors created by the 'arm_sve_vector_bits' attribute. This
behavior makes it possible to use VLST with existing interfaces that
operate on GNUT. For example:

  typedef int8_t vec1 __attribute__((vector_size(32)));
  void f(vec1);
  #if __ARM_FEATURE_SVE_BITS==256 && __ARM_FEATURE_SVE_VECTOR_OPERATORS
  typedef svint8_t vec2 __attribute__((arm_sve_vector_bits(256)));
  void g(vec2 x) { f(x); } // OK
  #endif

The `__ARM_FEATURE_SVE_VECTOR_OPERATORS` feature macro indicates
interoperability with the GNU vector extension. This is the first patch
providing support for this feature, which once complete will be enabled
by the `-msve-vector-bits` flag, as the `__ARM_FEATURE_SVE_BITS` feature
currently is.

[1] https://developer.arm.com/documentation/100987/latest

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D87607
clang/lib/AST/ASTContext.cpp
clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
clang/test/Sema/attr-arm-sve-vector-bits.c
clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp