On Sun, Feb 19, 2012 at 8:04 PM, Aaron Ballman <[email protected]>wrote:

> Here's what we've figured out so far.
>
> Several platform SDK header files include intrin.h from Visual Studio.
>  This file declares all of the intrinsics used by MSVC, including
> chip-specific intrinsics (MMX, SSE, etc) as well as
> platform-independent intrinsics (Interlocked***, etc).
>
> A full list of intrinsics is documented on MSDN at
> <http://msdn.microsoft.com/en-us/library/26td21ds.aspx> and
> <http://msdn.microsoft.com/en-US/library/w5405h95(v=vs.100).aspx>
>
> We need to come up with our own intrin.h that supports Microsoft's so
> that we can compile Win32 applications (and Microsoft's STL
> implementation).


Here is an initial cut at adding an MSVC compatible 'intrin.h' builtin
header. I've left a FIXME to fill in the MS-specific intrinsics. This
should at least provide a place to begin fleshing out the intrinsics.
diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
index 78141a3..f8c0309 100644
--- a/lib/Headers/CMakeLists.txt
+++ b/lib/Headers/CMakeLists.txt
@@ -8,6 +8,7 @@ set(files
   float.h
   fma4intrin.h
   immintrin.h
+  intrin.h
   iso646.h
   limits.h
   lzcntintrin.h
diff --git a/lib/Headers/intrin.h b/lib/Headers/intrin.h
new file mode 100644
index 0000000..a4d3638
--- /dev/null
+++ b/lib/Headers/intrin.h
@@ -0,0 +1,63 @@
+/*===---- intrin.h - Microsoft VS compatible X86 intrinsics -----------------===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+/* Unless we're compiling targeting MSVC platform, this header shouldn't even
+ * *exist*. If there is a system header with the same name, defer to that,
+ * etherwise produce an error for the user.
+ */
+#ifndef _MSC_VER
+# if defined(__has_inclued_next) && __has_inclued_next(<intrin.h>)
+#  include_next <intrin.h>
+# else
+#  error The <intrin.h> builtin header is for use when targeting Windows and \
+         provides MSVC compatible intrinsic declarations. It shouldn't be used \
+         on non-Windows targets. Instead, see <x86intrin.h> which is supported \
+         by Clang, GCC, and ICC on all platforms.
+# endif
+#else /* _MSC_VER */
+
+#ifndef __INTRIN_H
+#define __INTRIN_H
+
+/* These headers need to be provided by intrin.h in case users depend on any of
+ * their contents.
+ */
+#include <crtdefs.h>
+#include <setjmp.h>
+#include <stddef.h>
+
+/* Microsoft includes all of the intrinsics, and then restricts their
+ * availability based on the particular target CPU; with Clang te rely on the
+ * guarded includes used in our generic x86intrin header to pull in the
+ * intrinsic declarations / definitions which should be available for the
+ * target CPU variant.
+ */
+#include <x86intrin.h>
+
+/* FIXME: We need to provide declarations for Microsoft-specific intrinsics in
+ * addition to the chip-vendor intrinsics provided by x86intrin.h.
+ */
+
+#endif /* __INTRIN_H */
+
+#endif /* _MSC_VER */
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to