From 431a35c2cd744e9c53cc401928f193aae6fbb109 Mon Sep 17 00:00:00 2001 From: "Paul A. Clarke" Date: Mon, 11 May 2020 15:52:56 -0500 Subject: [PATCH] Clarify content regarding operators - Explicitly mention that there are no default conversions. - Clarify that binary operations are on like types. - Clarify requirements for the ternary operator and add an example. Asserting that the clarified content is clear enough, Fixes #11. Signed-off-by: Paul A. Clarke --- Intrinsics_Reference/ch_biendian.xml | 38 +++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Intrinsics_Reference/ch_biendian.xml b/Intrinsics_Reference/ch_biendian.xml index b18f13f..c446aec 100644 --- a/Intrinsics_Reference/ch_biendian.xml +++ b/Intrinsics_Reference/ch_biendian.xml @@ -187,7 +187,8 @@ vector double g = (vector double) { 3.5, -24.6 }; One vector type may be cast to another vector type without restriction. Such a cast is simply a reinterpretation of the - bits, and does not change the data. + bits, and does not change the data. There are no default + conversions for vector types. Compilers are expected to recognize and optimize multiple @@ -494,12 +495,14 @@ register vector double vd = vec_splats(*double_ptr); valid for pointers to vector types. - The traditional C/C++ operators are defined on vector types - for unary and binary +, - unary and binary –, binary *, binary - %, and binary / as well as the unary - and binary shift, logical and comparison operators, and the - ternary ?: operator. These operators perform their + The traditional C/C++ unary operators (+ + -, and ~), are defined on vector types. + The traditional C/C++ binary operators (+, + -, *, %, /, + shift, logical, and comparison) and the ternary operator + (?:) + are defined on like vector types. + Other than ?:, these operators perform their operations "elementwise" on the base elements of the operands, as follows. @@ -532,6 +535,27 @@ a = a + b; vector signed int a, b; a = vec_add (a, b); + + For the ternary operator (?:), the first operand must + be an integral type, used to select between the second and third + operands which must be of the same vector type. + The result of the ternary operator will also have that type. + For example, + +int test_value; +vector signed int a, b, r; +r = test_value ? a : b; + + produces the same result as + +int test_value; +vector signed int a, b, r; +if (test_value) + r = a; +else + r = b; + + Further, the array reference operator may be applied to vector data types, yielding an l-value corresponding to the specified -- 2.34.1