I really can't get what "keyword" like __m128d
is in C++.
I'm using MSVC, and it says: The __m128d data type, for use with the Streaming SIMD Extensions 2 instructions intrinsics, is defined in <emmintrin.h>
.
So, is it a Data Type? typedef
? If I do:
#include <emmintrin.h>
int main() {
__m128d x;
}
I can't see the defination on <emmintrin.h>
. It seems a keyword
of compiler? Does it automatically convert that keyword to somethings like "move register xmm0" etc? Or which kind of operation does?
It doesn't seems a data type at all.
Can someone shine me?
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 anint
orlong
, 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:in
<emmintrin.h>
, as @Default commented.The
may_alias
attribute tells the compiler that__m128d*
can alias other types the same way thatchar*
can, for the purposes of optimization based on C++ strict-aliasing rules.Example of usage: (initialization is portable between MSVC and other compilers)
For
__m128
, check the Intel forum and<xmmintrin.h>
.