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

Unified Diff: native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst

Issue 293093004: PNaCl SIMD documentation: fix vector-scalar examples, currently unsupported by LLVM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst
diff --git a/native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst b/native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst
index 3bece15a604112ad7c03177c38828e8d686e47ab..337a962bc192bea08577afccb493760b5f3a6a7b 100644
--- a/native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst
+++ b/native_client_sdk/src/doc/reference/pnacl-c-cpp-language-support.rst
@@ -232,9 +232,8 @@ Vector types can be used through the ``vector_size`` attribute:
v4s a = {1,2,3,4};
v4s b = {5,6,7,8};
v4s c, d, e;
- c = b + 1; /* c = b + {1,1,1,1}; */
- d = 2 * b; /* d = {2,2,2,2} * b; */
- e = c + d;
+ c = a + b; /* c = {6,8,10,12} */
+ d = b >> a; /* d = {2,1,0,0} */
Vector comparisons are represented as a bitmask as wide as the compared
elements of all ``0`` or all ``1``:
@@ -335,21 +334,32 @@ to the number of indices specified.
// identity operation - return 4-element vector v1.
__builtin_shufflevector(v1, v1, 0, 1, 2, 3)
- // "Splat" element 0 of V1 into a 4-element result.
- __builtin_shufflevector(V1, V1, 0, 0, 0, 0)
+ // "Splat" element 0 of v1 into a 4-element result.
+ __builtin_shufflevector(v1, v1, 0, 0, 0, 0)
- // Reverse 4-element vector V1.
- __builtin_shufflevector(V1, V1, 3, 2, 1, 0)
+ // Reverse 4-element vector v1.
+ __builtin_shufflevector(v1, v1, 3, 2, 1, 0)
- // Concatenate every other element of 4-element vectors V1 and V2.
- __builtin_shufflevector(V1, V2, 0, 2, 4, 6)
+ // Concatenate every other element of 4-element vectors v1 and v2.
+ __builtin_shufflevector(v1, v2, 0, 2, 4, 6)
- // Concatenate every other element of 8-element vectors V1 and V2.
- __builtin_shufflevector(V1, V2, 0, 2, 4, 6, 8, 10, 12, 14)
+ // Concatenate every other element of 8-element vectors v1 and v2.
+ __builtin_shufflevector(v1, v2, 0, 2, 4, 6, 8, 10, 12, 14)
// Shuffle v1 with some elements being undefined
__builtin_shufflevector(v1, v1, 3, -1, 1, -1)
+One common use of ``__builtin_shufflevector`` is to perform
+vector-scalar operations:
+
+.. naclcode::
+
+ typedef int v4s __attribute__((vector_size(16)));
+ v4s shift_right_by(v4s shift_me, int shift_amount) {
+ v4s tmp = {shift_amount};
+ return shift_me >> __builtin_shuffle_vector(tmp, tmp, 0, 0, 0, 0);
+ }
+
Auto-Vectorization
------------------
« no previous file with comments | « native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698