Example 7. The __x128_t Container Type

#include <c6x.h> #include <stdio.h> __x128_t mpy_four_way_example(__x128_t s, int a, int b, int c, int d) { __x128_t t = _ito128(a, b, c, d); // Pack values into a __x128_t __x128_t results = _qmpy32(s, t); // Perform a four-way SIMD multiply int lowest32 = _get32_128(results, 0); // Extract lowest reg of __x128_t int highest32 = _get32_128(results, 3); // Extract highest reg of __x128_t printf("lowest = %d\n", lowest32); printf("highest = %d\n", highest32); return results; }

NOTE

Include c6x.h With Type __x128_t or __float2_t

When using the __x128_t container type, or __float2_t typedef, or any intrinsics involving __float2_t, you must include c6x.h.

Table 8-8 Vector-in-Scalar Support C/C++ Compiler v7.2 Intrinsics

C/C++ Compiler Intrinsic Description
Creation
__x128_t _ito128 (unsigned src1, unsigned src2, unsigned src3,
     unsigned src4);
Creates __x128_t from (u)int (reg+3, reg+2, reg+1, reg+0)
__x128_t _fto128 (float src1, float src2, float src3, float src4); Creates __x128_t from float (reg+3, reg+2, reg+1, reg+0)
__x128_t _llto128 (long long src1, long long src2); Creates __x128_t from two long longs
__x128_t _dto128 (double src1, double src2); Creates __x128_t from two doubles
__x128_t _f2to128(__float2_t src1, __float2_t src2); Creates __x128_t from two __float2_t objects. This is defined as a macro. You must include c6x.h.
__x128_t _dup32_128 (int src); Creates __x128_t from duplicating src1
__float2_t _ftof2(float src1, float src2); Creates __float2_t from two floats. This is defined as a macro. You must include c6x.h.
Extraction
float _hif (double src); Extracts upper float from double
float _lof (double src); Extracts lower float from double
float _hif2(__float2_t src); Extracts upper float from __float2_t. This is defined as a macro. You must include c6x.h.
float _lof2(__float2_t src); Extracts lower float from __float2_t. This is defined as a macro. You must include c6x.h.
long long _hi128 (__x128_t src); Extracts upper two registers of register quad
double _hid128 (__x128_t src); Extracts upper two registers of register quad
__float2_t _hif2_128(__x128_t src); Extracts upper two registers of register quad. This is defined as a macro. You must include c6x.h.
long long _lo128 (__x128_t src); Extracts lower two registers of register quad
double _lod128 (__x128_t src); Extracts lower two registers of register quad
__float2_t _lof2_128(__x128_t src); Extracts lower two registers of register quad. This is defined as a macro. You must include c6x.h.
unsigned _get32_128 (__x128_t src, 0); Extracts first register of register quad (base reg + 0)
unsigned _get32_128 (__x128_t src, 1); Extracts second register of register quad (base reg + 1)
unsigned _get32_128 (__x128_t src, 2); Extracts third register of register quad (base reg + 2)
unsigned _get32_128 (__x128_t src, 3); Extracts fourth register of register quad (base reg + 3)
float _get32f_128 (__x128_t src, 0); Extracts first register of register quad (base reg + 0)
float _get32f_128 (__x128_t src, 1); Extracts second register of register quad (base reg + 1)
float _get32f_128 (__x128_t src, 2); Extracts third register of register quad (base reg + 2)
float _get32f_128 (__x128_t src, 3); Extracts fourth register of register quad (base reg + 3)