Security Scol plugin
|
Support functions for PowerPC and vector operations. More...
Go to the source code of this file.
Macros | |
#define | CONST_V8_CAST(x) ((unsigned char*)(x)) |
Cast array to vector pointer. | |
#define | CONST_V32_CAST(x) ((unsigned int*)(x)) |
Cast array to vector pointer. | |
#define | CONST_V64_CAST(x) ((unsigned long long*)(x)) |
Cast array to vector pointer. | |
#define | NCONST_V8_CAST(x) ((unsigned char*)(x)) |
Cast array to vector pointer. | |
#define | NCONST_V32_CAST(x) ((unsigned int*)(x)) |
Cast array to vector pointer. | |
#define | NCONST_V64_CAST(x) ((unsigned long long*)(x)) |
Cast array to vector pointer. | |
Support functions for PowerPC and vector operations.
This header provides an agnostic interface into Clang, GCC and IBM XL C/C++ compilers modulo their different built-in functions for accessing vector instructions.
The abstractions are necessary to support back to GCC 4.8 and XLC 11 and 12. GCC 4.8 and 4.9 are still popular, and they are the default compiler for GCC112, GCC119 and others on the compile farm. Older IBM XL C/C++ compilers also have the need due to lack of vec_xl
and vec_xst
support on some platforms. Modern compilers provide best support and don't need many of the hacks below.
The library is tested with the following PowerPC machines and compilers. GCC110, GCC111, GCC112, GCC119 and GCC135 are provided by the GCC Compile Farm
GCC135, Linux, POWER9, GCC 7.0
12 machines are used for testing because the three compilers form five or six profiles. The profiles are listed below.
late LLVM Clang (traditional Clang compiler)
The LLVM front-end makes it tricky to write portable code because LLVM pretends to be other compilers but cannot consume other compiler's builtins. When using XLC with -qxlcompatmacros the compiler pretends to be GCC, Clang and XLC all at once but it can only consume it's variety of builtins.
At Crypto++ 8.0 the various Vector{FuncName}
were renamed to Vec{FuncName}
. For example, VectorAnd
was changed to VecAnd
. The name change helped consolidate two slightly different implementations.
At Crypto++ 8.3 the library added select 64-bit functions for 32-bit Altivec. For example, VecAdd64
and VecSub64
take 32-bit vectors and adds or subtracts them as if there were vectors with two 64-bit elements. The functions dramtically improve performance for some algorithms on some platforms, like SIMON128 and SPECK128 on Power6 and earlier. For example, SPECK128 improved from 70 cpb to 10 cpb on an old PowerMac. Use the functions like shown below.
#if defined(_ARCH_PWR8) # define speck128_t uint64x2_p #else # define speck128_t uint32x4_p #endif speck128_t rk, x1, x2, y1, y2; rk = (speck128_t)VecLoadAligned(ptr); x1 = VecRotateRight64<8>(x1); x1 = VecAdd64(x1, y1); ...
Definition in file ppc_simd.h.
#define CONST_V32_CAST | ( | x | ) | ((unsigned int*)(x)) |
Cast array to vector pointer.
CONST_V32_CAST casts a const array to a vector pointer for a word array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 151 of file ppc_simd.h.
#define CONST_V64_CAST | ( | x | ) | ((unsigned long long*)(x)) |
Cast array to vector pointer.
CONST_V64_CAST casts a const array to a vector pointer for a double word array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 157 of file ppc_simd.h.
#define CONST_V8_CAST | ( | x | ) | ((unsigned char*)(x)) |
Cast array to vector pointer.
CONST_V8_CAST casts a const array to a vector pointer for a byte array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 145 of file ppc_simd.h.
#define NCONST_V32_CAST | ( | x | ) | ((unsigned int*)(x)) |
Cast array to vector pointer.
NCONST_V32_CAST casts an array to a vector pointer for a word array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 169 of file ppc_simd.h.
#define NCONST_V64_CAST | ( | x | ) | ((unsigned long long*)(x)) |
Cast array to vector pointer.
NCONST_V64_CAST casts an array to a vector pointer for a double word array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 175 of file ppc_simd.h.
#define NCONST_V8_CAST | ( | x | ) | ((unsigned char*)(x)) |
Cast array to vector pointer.
NCONST_V8_CAST casts an array to a vector pointer for a byte array. The Power ABI says source arrays are non-const, so this define removes the const. XLC++ will fail the compile if the source array is const.
Definition at line 163 of file ppc_simd.h.