Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Issue 221693002: PNaCl: Add support for GCC/LLVM vector extensions (Closed)

Created:
6 years, 8 months ago by JF
Modified:
6 years, 8 months ago
CC:
native-client-reviews_googlegroups.com
Base URL:
http://git.chromium.org/native_client/pnacl-llvm.git@master
Visibility:
Public.

Description

PNaCl: 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. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2258 lines, -78 lines) Patch
M include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h View 1 2 3 2 chunks +3 lines, -3 lines 0 comments Download
M include/llvm/InitializePasses.h View 2 chunks +3 lines, -0 lines 0 comments Download
M include/llvm/Transforms/NaCl.h View 2 chunks +3 lines, -0 lines 0 comments Download
M lib/Analysis/NaCl/PNaClABITypeChecker.h View 1 chunk +3 lines, -0 lines 0 comments Download
M lib/Analysis/NaCl/PNaClABITypeChecker.cpp View 2 chunks +26 lines, -1 line 0 comments Download
M lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp View 1 2 3 4 5 10 chunks +57 lines, -15 lines 0 comments Download
M lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp View 1 2 3 2 chunks +46 lines, -0 lines 0 comments Download
M lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp View 3 chunks +19 lines, -2 lines 0 comments Download
M lib/Transforms/NaCl/CMakeLists.txt View 2 chunks +3 lines, -0 lines 0 comments Download
A lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp View 1 2 3 4 5 6 7 1 chunk +183 lines, -0 lines 0 comments Download
A lib/Transforms/NaCl/FixVectorLoadStoreAlignment.cpp View 1 2 3 1 chunk +235 lines, -0 lines 0 comments Download
M lib/Transforms/NaCl/FlattenGlobals.cpp View 1 chunk +2 lines, -1 line 0 comments Download
A lib/Transforms/NaCl/GlobalizeConstantVectors.cpp View 1 2 3 4 5 6 7 8 1 chunk +129 lines, -0 lines 0 comments Download
M lib/Transforms/NaCl/PNaClABISimplify.cpp View 1 chunk +10 lines, -0 lines 0 comments Download
A test/NaCl/Bitcode/vector.ll View 1 2 3 4 5 6 1 chunk +38 lines, -0 lines 0 comments Download
M test/NaCl/PNaClABI/abi-i1-operations.ll View 1 2 3 4 5 2 chunks +101 lines, -13 lines 0 comments Download
M test/NaCl/PNaClABI/abi-small-arguments.ll View 1 chunk +2 lines, -2 lines 0 comments Download
A test/NaCl/PNaClABI/function-signatures.ll View 1 2 3 4 5 6 7 8 9 1 chunk +181 lines, -0 lines 0 comments Download
M test/NaCl/PNaClABI/instructions.ll View 1 2 3 4 5 6 7 8 7 chunks +195 lines, -40 lines 0 comments Download
M test/NaCl/PNaClABI/types.ll View 3 chunks +65 lines, -1 line 0 comments Download
A test/Transforms/NaCl/constant-insert-extract-element-index.ll View 1 2 3 4 5 6 7 1 chunk +425 lines, -0 lines 0 comments Download
A test/Transforms/NaCl/fix-vector-load-store-alignment.ll View 1 2 3 4 5 6 7 8 9 1 chunk +351 lines, -0 lines 0 comments Download
A test/Transforms/NaCl/globalize-constant-vectors.ll View 1 2 3 4 5 6 7 8 1 chunk +175 lines, -0 lines 0 comments Download
M tools/opt/opt.cpp View 2 chunks +3 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (0 generated)
JF
6 years, 8 months ago (2014-04-02 00:12:55 UTC) #1
Karl
https://codereview.chromium.org/221693002/diff/1/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h File include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h (right): https://codereview.chromium.org/221693002/diff/1/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h#newcode340 include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h:340: FUNC_CODE_INST_EXTRACTVAL = 26, // Not used in PNaCl. Fix ...
6 years, 8 months ago (2014-04-02 15:56:22 UTC) #2
Mark Seaborn
Could you split this into more manageable pieces? i.e. Change the ABI checker in a ...
6 years, 8 months ago (2014-04-02 16:09:47 UTC) #3
JF
On 2014/04/02 16:09:47, Mark Seaborn wrote: > Could you split this into more manageable pieces? ...
6 years, 8 months ago (2014-04-02 16:56:19 UTC) #4
JF
Updated, PTAL. Also see the CL related to tightening the PNaCl reader's accepted record sizes ...
6 years, 8 months ago (2014-04-02 18:37:12 UTC) #5
Jim Stichnoth
On 2014/04/02 16:09:47, Mark Seaborn wrote: > Could you split this into more manageable pieces? ...
6 years, 8 months ago (2014-04-02 21:20:20 UTC) #6
Jim Stichnoth
https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp File lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp#newcode333 lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp:333: (Op0VTy && Op0VTy->getElementType()->isIntegerTy(1))) Is it possible to reasonably restructure ...
6 years, 8 months ago (2014-04-04 23:08:17 UTC) #7
jvoung (off chromium)
https://codereview.chromium.org/221693002/diff/40001/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h File include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h (right): https://codereview.chromium.org/221693002/diff/40001/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h#newcode319 include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h:319: FUNC_CODE_INST_EXTRACTELT = 6, // EXTRACTELT: [opty, opval, opval] no ...
6 years, 8 months ago (2014-04-04 23:20:21 UTC) #8
jvoung (off chromium)
https://codereview.chromium.org/221693002/diff/40001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp File lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp#newcode111 lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp:111: ElemTy, ConstantInt::get(Type::getInt32Ty(M->getContext()), On 2014/04/04 23:20:21, jvoung (cr) wrote: > ...
6 years, 8 months ago (2014-04-07 15:40:11 UTC) #9
Mark Seaborn
https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp File lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp#newcode91 lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp:91: // * a pointer to a valid PNaCl vector ...
6 years, 8 months ago (2014-04-09 15:03:03 UTC) #10
JF
I've addressed all outstanding comments except Mark's request for bitcode tests and removing vector pointers ...
6 years, 8 months ago (2014-04-15 01:52:27 UTC) #11
JF
As suggested by jvoung I changed ConstantInsertExtractElementIndex so that it now forces out-of-range constant indices ...
6 years, 8 months ago (2014-04-15 17:38:25 UTC) #12
JF
https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp File lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp#newcode91 lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp:91: // * a pointer to a valid PNaCl vector ...
6 years, 8 months ago (2014-04-15 18:22:14 UTC) #13
JF
https://codereview.chromium.org/221693002/diff/40001/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp File lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp#newcode288 lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp:288: case Type::VectorTyID: { On 2014/04/09 15:03:03, Mark Seaborn wrote: ...
6 years, 8 months ago (2014-04-15 20:22:36 UTC) #14
Derek Schuff
https://codereview.chromium.org/221693002/diff/80001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp File lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp (right): https://codereview.chromium.org/221693002/diff/80001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp#newcode114 lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp:114: const APInt &Idx = cast<ConstantInt>(getInsertExtractElementIdx(I))->getValue(); 80 col https://codereview.chromium.org/221693002/diff/80001/test/Transforms/NaCl/constant-insert-extract-element-index.ll File ...
6 years, 8 months ago (2014-04-15 20:30:42 UTC) #15
JF
https://codereview.chromium.org/221693002/diff/80001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp File lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp (right): https://codereview.chromium.org/221693002/diff/80001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp#newcode114 lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp:114: const APInt &Idx = cast<ConstantInt>(getInsertExtractElementIdx(I))->getValue(); On 2014/04/15 20:30:43, Derek ...
6 years, 8 months ago (2014-04-15 20:43:25 UTC) #16
jvoung (off chromium)
looks mostly good to me https://codereview.chromium.org/221693002/diff/40001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp File lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp (right): https://codereview.chromium.org/221693002/diff/40001/lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp#newcode65 lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp:65: "Force insert and extract ...
6 years, 8 months ago (2014-04-16 00:10:26 UTC) #17
JF
All outstanding comments are currently addressed. https://codereview.chromium.org/221693002/diff/140001/lib/Transforms/NaCl/GlobalizeConstantVectors.cpp File lib/Transforms/NaCl/GlobalizeConstantVectors.cpp (right): https://codereview.chromium.org/221693002/diff/140001/lib/Transforms/NaCl/GlobalizeConstantVectors.cpp#newcode12 lib/Transforms/NaCl/GlobalizeConstantVectors.cpp:12: // rely on ...
6 years, 8 months ago (2014-04-16 20:48:06 UTC) #18
jvoung (off chromium)
Otherwise LGTM. We haven't really used a field in the bitcode header (plus flags to ...
6 years, 8 months ago (2014-04-16 22:03:11 UTC) #19
JF
https://codereview.chromium.org/221693002/diff/160001/lib/Transforms/NaCl/FixVectorLoadStoreAlignment.cpp File lib/Transforms/NaCl/FixVectorLoadStoreAlignment.cpp (right): https://codereview.chromium.org/221693002/diff/160001/lib/Transforms/NaCl/FixVectorLoadStoreAlignment.cpp#newcode211 lib/Transforms/NaCl/FixVectorLoadStoreAlignment.cpp:211: VecStore->isVolatile()); On 2014/04/16 22:03:12, jvoung (cr) wrote: > Can ...
6 years, 8 months ago (2014-04-16 22:35:35 UTC) #20
Derek Schuff
lgtm
6 years, 8 months ago (2014-04-16 22:45:27 UTC) #21
JF
I also got a verbal LGTM from Karl.
6 years, 8 months ago (2014-04-16 23:17:41 UTC) #22
JF
6 years, 8 months ago (2014-04-16 23:18:05 UTC) #23
Message was sent while issue was closed.
Committed patchset #10 manually as r7fea37f (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698