[PATCH] Implement __readeflags and __writeeflags intrinsics
Alexey Volkov
avolkov.intel at gmail.com
Mon Feb 10 04:59:15 PST 2014
Ping
I also rebased patch to the current trunk.
Hi echristo, rnk, whunt,
http://llvm-reviews.chandlerc.com/D2468
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2468?vs=6314&id=6965#toc
Files:
lib/Headers/Intrin.h
Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -21,11 +21,6 @@
*===-----------------------------------------------------------------------===
*/
-/* 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
@@ -35,6 +30,60 @@
/* For the definition of jmp_buf. */
#include <setjmp.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
@@ -906,5 +955,5 @@
}
#endif
-#endif /* __INTRIN_H */
#endif /* _MSC_VER */
+#endif /* __INTRIN_H */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2468.4.patch
Type: text/x-patch
Size: 2023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140210/2f37077b/attachment.bin>
More information about the cfe-commits
mailing list