DescriptionPNaCl: Add support for GCC/LLVM vector extensions
Add limited SIMD support for 128-bit wide SIMD for integers of size
8/16/32 and 32-bit floating-point, and operations that can be expressed
through GCC/LLVM vector extensions:
* http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
* http://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors
64-bit integers and floating-point are currently missing and will be
added in a later CL.
Boolean vectors are represented as one bit per vector element, and the
number of elements in a boolean vector matches that of the supported
types (4, 8, 16).
256-bit and 512-bit vectors will take some work to support and may not
be supported in the near future.
Supported operations are:
unary +, -
++, --
+, -, *, /, %
&, |, ^, ~
>>, <<
!, &&, ||
==, !=, >, <, >=, <=
=
Vector types are usually defined in C/C++ with:
__attribute__((vector_size(VEC_BYTES)))
Note that this includes some conversions, but only to/from supported
types.
Note that this CL doesn't specify all undefined behavior, and future CLs
will ensure that undefined behavior for vectors matches that of
scalars. Worth noting are div/mod by zero (specified in PNaCl as
trapping), shift by bitwidth or greater (currently unspecified, see bug
3604), out-of-bounds conversions, signed over/underflow.
The CL does ensure that undefined behavior due to alignment is the same
as for scalars by breaking up vector load/store into element-wise scalar
load/store. This pattern should be recognized by backends which support
unaligned vector load/store, but no effort was put into making sure that
this is the case.
Undefined behavior due to out-of-bounds vector indexing is eliminated by
going through the stack. This should also be recognized by backends.
Vector constant immediate aren't supported, and instead go through loads
from the constant global array.
No intrinsics on vectors are currently supported, they will be added by
later CLs.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2205
Testing:
TEST= (cd ./toolchain_build/out/llvm_i686_linux_work/ && ninja check)
TEST= ./scons run_simd_ref_test bitcode=1 && ./scons run_simd_native_test bitcode=1
* I also have an extra scons test for which I is in a separate CL:
- https://codereview.chromium.org/222483002
* We should also make sure that the GCC torture tests for vector extensions are enabled.
Reviewers:
* For PNaCl bitcode reader/writer:
- kschimpf
* For PNaCl ABI and general passes:
- jvoung, mseaborn, dschuff
* For testing and vector support:
- nfullagar
* FYI on ABI change for Subzero:
- stichnot, eliben, sehr
R=dschuff@chromium.org, jvoung@chromium.org, eliben@chromium.org, kschimpf@chromium.org, mseaborn@chromium.org, nfullagar@chromium.org, sehr@chromium.org, stichnot@chromium.org
Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-llvm.git;a=commit;h=7fea37f
Patch Set 1 #
Total comments: 12
Patch Set 2 : Address kschimpf's comments. #Patch Set 3 : Remove TODOs that were done. #
Total comments: 59
Patch Set 4 : Address outstanding comments. #Patch Set 5 : "ConstantInsertExtractElementIndex now forces out-of-range constant indices to be in range instead … #
Total comments: 8
Patch Set 6 : Disallow vector pointer types. #Patch Set 7 : Add a vector bitcode test for NaCl. #Patch Set 8 : Address dschuff's comments. #
Total comments: 13
Patch Set 9 : Address jvoung's comments. #
Total comments: 6
Patch Set 10 : Address jvoung's comments. #Messages
Total messages: 23 (0 generated)
|