Is it a typedef?
Yes!
__m128d
is a data type that the compiler will hopefully store in a XMM 128 bit register when optimizing (if not optimizing it away as @PeterCordes commented). It's not inherently different from an int
or long
, which the compiler will hopefully store in integer registers when optimizing.
The actual definition is compiler-specific; code that intends to be portable between MSVC and the other major compilers that implement Intel's intrinsics should avoid depending on the details of the definition.
MSVC defines vector types as a union of arrays of different element sizes.
In compilers that implement GNU C extensions (gcc and clang), it is typedef'ed as a 16-byte GNU C native vector of double
s:
// From gcc 7.3's emmintrin.h (SSE2 extensions). SSE1 stuff in xmmintrin.h
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
in <emmintrin.h>
, as @Default commented.
The may_alias
attribute tells the compiler that __m128d*
can alias other types the same way that char*
can, for the purposes of optimization based on C++ strict-aliasing rules.
Example of usage: (initialization is portable between MSVC and other compilers)
__m128d a2 = { -1.388539L, 0.0L };
For __m128
, check the Intel forum and <xmmintrin.h>
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…