This patch series implements C/C++ operators on SVE's svbool_t ACLE type.
Following is a spec that describes the semantics when operators are applied
to svbool_t.
svbool_t is an SVE ACLE type that is a vector of non-standard booleans.
svbool_t[i] is a boolean type.
Initialization:
svbool_t pg = {c0, c1, c2, ..., cn}; // ci is either a compile-time constant
// or a runtime expression.
This is equivalent to
pg[0] = c0;
pg[1] = c1;
..
pg[n] = cn;
etc.
This is similar to writing:
_Bool p[4] = {1, 4.2, 0, ..., 'a'};
Eg.
svbool_t pg = {1, 4.2, 0, ..., 'a'};
will be translated to:
pg[0] = 1;
pg[1] = 1;
pg[2] = 0;
...
pg[n] = 1;
IoW, ci implicitly converts to boolean.
For SVE sizeless types, num of elements in the initializer cannot exceed minimum
vector length (16bits).
Bitwise ops: &, |, ~, ^
svbool_t = svbool_t <op> svbool_t
svbool_t = svbool_t <op> c // c is a scalar
svbool_t temp = {c, c, ..., c}
svbool_t = svbool_t <op> temp
Logical Ops: ==, !=
The result of a logical operation between 2 svbool_t is another vector svbool_t
i.e.
svbool_t = svbool_t <op> svbool_t
svbool_t <op> scalar eg. svbool_t != <constant> is equiv to:
_Bool temp1 = <constant> != 0 // Compile-time constant.
_Bool temp2 = temp1
svbool_t temp3 = {temp2, temp2, ... }
svbool_t = svbool_t <op> temp3
Ternary op:
svbool_t_expr ? svbool_t : svbool_t;
c ? svbool_t : svbool_t; // c is a scalar
The operation is similar to the GNU vector ternary op:
res = {svbool_t[0] != 0 ? v1[0] : v2[0], svbool_t[1] != 0 ? v1[1] : v2[1], ..}
svbool_t_expr ? t1 : t2; // Here, even if t1, t2 and svbool_t_expr have the
same number of elements, it will be diagnosed as error if t1 and t2 sizes are
different from svbool_t.
Conditional ops:
Result of svbool_t conditional ops is a vector of type svbool_t just like in the
case of a GNU vector.
!svbool_t is equivalent to
svbool_t == 0
svbool_t && svbool_t is equivalent to:
svbool_t != 0 & svbool_t != 0
svbool_t || svbool_t is equiv to:
svbool_t != 0 | svbool_t != 0
Address-of: & on svbool_t[i] is not allowed.
sizeof(): sizeof (svbool_t[i]) is precision / 8 + 1
[] operator:
svbool_t[i] indexes bit i from the LSBit of svbool_t. For eg. svbool[4] indexes
the 5th bit from LSBit of svbool_t. The type of svbool_t[i] is boolean.
Tejas Belagod (6):
c: Add front-end hook for related vector type.
AArch64: Support C/C++ operations on svbool_t
GIMPLE: Support TARGET_MEM_REF when walking ADDR_EXPR trees.
c/cp/GIMPLE: Add support for index ops on svbool_t.
AArch64: Update test to reflect new message
AArch64: Update existing test with svbool_t operations
gcc/c-family/c-common.cc | 64 ++-
gcc/c-family/c-common.h | 2 +
gcc/c/c-objc-common.h | 2 +
gcc/c/c-typeck.cc | 43 +-
gcc/config/aarch64/aarch64-sve-builtins.cc | 5 +-
gcc/config/aarch64/aarch64-sve.md | 62 +++
gcc/config/aarch64/aarch64.cc | 92 +++-
gcc/cp/call.cc | 3 +-
gcc/cp/cp-objcp-common.h | 2 +
gcc/cp/cvt.cc | 11 +-
gcc/cp/typeck.cc | 45 +-
gcc/gimple-fold.cc | 5 +
gcc/gimple-walk.cc | 4 +
gcc/gimplify.cc | 68 +++
gcc/langhooks-def.h | 2 +
gcc/langhooks.h | 4 +
gcc/testsuite/g++.dg/ext/sve-sizeless-1.C | 10 +
gcc/testsuite/g++.dg/ext/sve-sizeless-2.C | 21 +
.../sve/acle/general-c++/gnu_vectors_1.C | 138 +++++-
.../sve/acle/general-c++/gnu_vectors_2.C | 138 +++++-
.../sve/acle/general-c/gnu_vectors_1.c | 133 +++++-
.../sve/acle/general-c/gnu_vectors_2.c | 133 +++++-
.../aarch64/sve/acle/general-c/sizeless-1.c | 14 +-
.../aarch64/sve/acle/general-c/sizeless-2.c | 32 ++
.../aarch64/sve/acle/general-c/svcount_1.c | 2 +-
.../aarch64/sve/acle/general/cops_bool.c | 396 ++++++++++++++++++
26 files changed, 1385 insertions(+), 46 deletions(-)
create mode 100644
gcc/testsuite/gcc.target/aarch64/sve/acle/general/cops_bool.c
--
2.25.1