diff options
author | Erich Keane <erich.keane@intel.com> | 2019-12-05 06:17:39 -0800 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2020-01-13 13:27:20 -0800 |
commit | 349636d2bfc39a5c81a835a95d203a42d9f9301a (patch) | |
tree | c759730bf327f0a94c57cca11db5870a5eaf7a09 /clang/docs | |
parent | 4268e4f4b84b85266426e99050d31ec63f3ce8aa (diff) | |
download | bcm5719-llvm-349636d2bfc39a5c81a835a95d203a42d9f9301a.tar.gz bcm5719-llvm-349636d2bfc39a5c81a835a95d203a42d9f9301a.zip |
Implement VectorType conditional operator GNU extension.
GCC supports the conditional operator on VectorTypes that acts as a
'select' in C++ mode. This patch implements the support. Types are
converted as closely to GCC's behavior as possible, though in a few
places consistency with our existing vector type support was preferred.
Note that this implementation is different from the OpenCL version in a
number of ways, so it unfortunately required a different implementation.
First, the SEMA rules and promotion rules are significantly different.
Secondly, GCC implements COND[i] != 0 ? LHS[i] : RHS[i] (where i is in
the range 0- VectorSize, for each element). In OpenCL, the condition is
COND[i] < 0 ? LHS[i]: RHS[i].
In the process of implementing this, it was also required to make the
expression COND ? LHS : RHS type dependent if COND is type dependent,
since the type is now dependent on the condition. For example:
T ? 1 : 2;
Is not typically type dependent, since the result can be deduced from
the operands. HOWEVER, if T is a VectorType now, it could change this
to a 'select' (basically a swizzle with a non-constant mask) with the 1
and 2 being promoted to vectors themselves.
While this is a change, it is NOT a standards incompatible change. Based
on my (and D. Gregor's, at the time of writing the code) reading of the
standard, the expression is supposed to be type dependent if ANY
sub-expression is type dependent.
Differential Revision: https://reviews.llvm.org/D71463
Diffstat (limited to 'clang/docs')
-rw-r--r-- | clang/docs/LanguageExtensions.rst | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 0bd87903f34..f1df9dd93f9 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -465,28 +465,33 @@ The table below shows the support for each operation by vector extension. A dash indicates that an operation is not accepted according to a corresponding specification. -============================== ======= ======= ======= ======= - Operator OpenCL AltiVec GCC NEON -============================== ======= ======= ======= ======= -[] yes yes yes -- -unary operators +, -- yes yes yes -- -++, -- -- yes yes yes -- -+,--,*,/,% yes yes yes -- -bitwise operators &,|,^,~ yes yes yes -- ->>,<< yes yes yes -- -!, &&, || yes -- -- -- -==, !=, >, <, >=, <= yes yes -- -- -= yes yes yes yes -:? yes -- -- -- -sizeof yes yes yes yes -C-style cast yes yes yes no -reinterpret_cast yes no yes no -static_cast yes no yes no -const_cast no no no no -============================== ======= ======= ======= ======= +============================== ======= ======= ============= ======= + Operator OpenCL AltiVec GCC NEON +============================== ======= ======= ============= ======= +[] yes yes yes -- +unary operators +, -- yes yes yes -- +++, -- -- yes yes yes -- ++,--,*,/,% yes yes yes -- +bitwise operators &,|,^,~ yes yes yes -- +>>,<< yes yes yes -- +!, &&, || yes -- yes [#]_ -- +==, !=, >, <, >=, <= yes yes yes -- += yes yes yes yes +:? [#]_ yes -- yes -- +sizeof yes yes yes yes +C-style cast yes yes yes no +reinterpret_cast yes no yes no +static_cast yes no yes no +const_cast no no no no +============================== ======= ======= ============= ======= See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`. +.. [#] unary operator ! is not implemented, however && and || are. +.. [#] While OpenCL and GCC vectors both implement the comparison operator(?:) as a + 'select', they operate somewhat differently. OpenCL selects based on signedness of + the condition operands, but GCC vectors use normal bool conversions (that is, != 0). + Half-Precision Floating Point ============================= |