This patch attempts to redo what was tried in r278783, but was reverted.
These intrinsics should be available on non-windows platforms with "xsave" feature check. But on Windows platforms they shouldn't have feature check since that's how MSVC behaves.
To accomplish this I've added a MS builtin with no feature check. And a normal gcc builtin with a feature check. When _MSC_VER is not defined _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.
I've moved the forward declarations from intrin.h to immintrin.h to match the MSDN documentation and used that as the header file for the MS builtin.
I'm not super happy with this implementation, and I'm open to suggestions for better ways to do it.
I think we should try to simplify immintrin.h and push this complexity into xsaveintrin.h. Since it is small (i.e. not avx512intrin.h), we don't really need this !defined(_MSC_VER) || __has_feature(modules) check to improve compile time. If you rewrite it to:
Then xsaveintrin.h can do the XSAVE macro feature check internally.