Using Vector Instructions Through Built-In Functions - Red Hat ENTERPRISE LINUX 4 Manual

Hide thumbs Also See for ENTERPRISE LINUX 4:
Table of Contents

Advertisement

Chapter 6. Extensions to the C Language Family

6.43. Using vector instructions through built-in functions

On some targets, the instruction set contains SIMD vector instructions that operate on multiple values
contained in one large register at the same time. For example, on the i386 the MMX, 3Dnow! and SSE
extensions can be used this way.
The first step in using these extensions is to provide the necessary data types. This should be done
using an appropriate
typedef int v4si __attribute__ ((mode(V4SI)));
The base type
is effectively ignored by the compiler, the actual properties of the new type
int
are defined by the
__attribute__
have the form
;
V
n
nB
of the individual elements. The following can be used as base modes:
QI
An integer that is as wide as the smallest addressable unit, usually 8 bits.
HI
An integer, twice as wide as a QI mode integer, usually 16 bits.
SI
An integer, four times as wide as a QI mode integer, usually 32 bits.
DI
An integer, eight times as wide as a QI mode integer, usually 64 bits.
SF
A floating point value, as wide as a SI mode integer, usually 32 bits.
DF
A floating point value, as wide as a DI mode integer, usually 64 bits.
Specifying a combination that is not valid for the current architecture will cause GCC to synthesize
the instructions using a narrower mode. For example, if you specify a variable of type
architecture does not allow for this specific SIMD type, GCC will produce code that uses 4
The types defined in this manner can be used with a subset of normal C operations. Currently, GCC
will allow using the following operators on these types:
.
~
The operations behave like C++
elements of the operands. For example, in the code below, each of the 4 elements in
to the corresponding 4 elements in
typedef int v4si __attribute__ ((mode(V4SI)));
v4si a, b, c;
c = a + b;
:
typedef
. It defines the machine mode to be used; for vector types these
should be the number of elements in the vector, and
valarrays
and the resulting vector will be stored in
b
+, -, *, /, unary minus, ^, |, &,
. Addition is defined as the addition of the corresponding
should be the base mode
B
and your
V4SI
SIs
will be added
a
.
c
207
v4si
.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?

Table of Contents