I'm trying to compile a C application on a Mac. I use SSE4 and AES-NI intrinsics.
In Linux, I just call gcc with the -msse4 and -maes flags and include the wmmintrin.h header and I can call SSE intrinsics like _mm_add_epi64(a,b)
or AES-NI intrinsics like _mm_aesenc_si128(a, b)
and everything works fine.
On the Mac, it's harder, because Apple replaces GCC with llvm-gcc which does not support AES-NI yet. So SSE4 intrinsics work fine, but not the AES ones. Even inline assembly calls to the AES instructions are not recognized.
Intel has lots of AES example code on their website, but it's for Linux and Windows only.
I did notice the RDRAND instruction is also unsupported by llvm-gcc but Intel provides a workaround for that by using a C macro which expands into raw machine byte code. (See the rdrand.h example file in this Intel library)
Unfortunately there is no similar provided workaround for the AES-NI instructions, probably because the instructions have arguments and can't be evaluated as static machine code bytes.
Programs do exist that use AES-NI on the Mac, including Apple's own File Vault, so there must be some method that works!
To make my question concrete, how would I get the following simple call to compile using the latest Mac gcc-llvm 4.2 (latest public release in Mountain Lion xcode 4.4.1):
__m128i A, B, C;
/* A, B, C initialized here... */
A = _mm_aesenc_si128(B, C);
Thanks for any help!
gcc
. – Ingunna