With updated patch I fixed one test failed due to changed line numbers in 
warning message.

http://llvm-reviews.chandlerc.com/D2468

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2468?vs=6313&id=6314#toc

Files:
  lib/Headers/Intrin.h
  test/Headers/ms-intrin.cpp

Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -21,17 +21,65 @@
  *===-----------------------------------------------------------------------===
  */
 
-/* Only include this if we're compiling for the windows platform. */
-#ifndef _MSC_VER
-#include_next <Intrin.h>
-#else
-
 #ifndef __INTRIN_H
 #define __INTRIN_H
 
 /* First include the standard intrinsics. */
 #include <x86intrin.h>
 
+#ifndef _MSC_VER
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__, 
__nodebug__))
+__readeflags(void)
+{
+  unsigned long long res = 0;
+  __asm__ __volatile__ ("pushf\n\t"
+                        "popq %0\n"
+                        :"=r"(res)
+                        :
+                        :
+                       );
+  return res;
+}
+
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+__writeeflags(unsigned long long __f)
+{
+  __asm__ __volatile__ ("pushq %0\n\t"
+                        "popf\n"
+                        :
+                        :"r"(__f)
+                        :"flags"
+                       );
+}
+
+#else
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__readeflags(void)
+{
+  unsigned int res = 0;
+  __asm__ __volatile__ ("pushf\n\t"
+                        "popl %0\n"
+                        :"=r"(res)
+                        :
+                        :
+                       );
+  return res;
+}
+
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+__writeeflags(unsigned int __f)
+{
+  __asm__ __volatile__ ("pushl %0\n\t"
+                        "popf\n"
+                        :
+                        :"r"(__f)
+                        :"flags"
+                       );
+}
+#endif
+#else
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -780,5 +828,5 @@
 }
 #endif
 
-#endif /* __INTRIN_H */
 #endif /* _MSC_VER */
+#endif /* __INTRIN_H */
Index: test/Headers/ms-intrin.cpp
===================================================================
--- test/Headers/ms-intrin.cpp
+++ test/Headers/ms-intrin.cpp
@@ -18,7 +18,7 @@
   _WriteBarrier();      // expected-warning {{is deprecated: use other 
intrinsics or C++11 atomics instead}}
   // FIXME: It'd be handy if we didn't have to hardcode the line number in
   // intrin.h.
-  // [email protected]:754 {{'_ReadWriteBarrier' has been explicitly 
marked deprecated here}}
-  // [email protected]:759 {{'_ReadBarrier' has been explicitly marked 
deprecated here}}
-  // [email protected]:764 {{'_WriteBarrier' has been explicitly marked 
deprecated here}}
+  // [email protected]:802 {{'_ReadWriteBarrier' has been explicitly 
marked deprecated here}}
+  // [email protected]:807 {{'_ReadBarrier' has been explicitly marked 
deprecated here}}
+  // [email protected]:812 {{'_WriteBarrier' has been explicitly marked 
deprecated here}}
 }
Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -21,17 +21,65 @@
  *===-----------------------------------------------------------------------===
  */
 
-/* Only include this if we're compiling for the windows platform. */
-#ifndef _MSC_VER
-#include_next <Intrin.h>
-#else
-
 #ifndef __INTRIN_H
 #define __INTRIN_H
 
 /* First include the standard intrinsics. */
 #include <x86intrin.h>
 
+#ifndef _MSC_VER
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__readeflags(void)
+{
+  unsigned long long res = 0;
+  __asm__ __volatile__ ("pushf\n\t"
+                        "popq %0\n"
+                        :"=r"(res)
+                        :
+                        :
+                       );
+  return res;
+}
+
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+__writeeflags(unsigned long long __f)
+{
+  __asm__ __volatile__ ("pushq %0\n\t"
+                        "popf\n"
+                        :
+                        :"r"(__f)
+                        :"flags"
+                       );
+}
+
+#else
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__readeflags(void)
+{
+  unsigned int res = 0;
+  __asm__ __volatile__ ("pushf\n\t"
+                        "popl %0\n"
+                        :"=r"(res)
+                        :
+                        :
+                       );
+  return res;
+}
+
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+__writeeflags(unsigned int __f)
+{
+  __asm__ __volatile__ ("pushl %0\n\t"
+                        "popf\n"
+                        :
+                        :"r"(__f)
+                        :"flags"
+                       );
+}
+#endif
+#else
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -780,5 +828,5 @@
 }
 #endif
 
-#endif /* __INTRIN_H */
 #endif /* _MSC_VER */
+#endif /* __INTRIN_H */
Index: test/Headers/ms-intrin.cpp
===================================================================
--- test/Headers/ms-intrin.cpp
+++ test/Headers/ms-intrin.cpp
@@ -18,7 +18,7 @@
   _WriteBarrier();      // expected-warning {{is deprecated: use other intrinsics or C++11 atomics instead}}
   // FIXME: It'd be handy if we didn't have to hardcode the line number in
   // intrin.h.
-  // [email protected]:754 {{'_ReadWriteBarrier' has been explicitly marked deprecated here}}
-  // [email protected]:759 {{'_ReadBarrier' has been explicitly marked deprecated here}}
-  // [email protected]:764 {{'_WriteBarrier' has been explicitly marked deprecated here}}
+  // [email protected]:802 {{'_ReadWriteBarrier' has been explicitly marked deprecated here}}
+  // [email protected]:807 {{'_ReadBarrier' has been explicitly marked deprecated here}}
+  // [email protected]:812 {{'_WriteBarrier' has been explicitly marked deprecated here}}
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to