[PATCH] Implement __readeflags and __writeeflags intrinsics
Alexey Volkov
avolkov.intel at gmail.com
Tue Dec 24 03:09:21 PST 2013
Hi all,
This patch implements __readeflags and __writeeflags intrinsics for x86 arch.
Alexey Volkov
Intel Corporation
http://llvm-reviews.chandlerc.com/D2468
Files:
lib/Headers/immintrin.h
Index: lib/Headers/immintrin.h
===================================================================
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -115,4 +115,58 @@
#include <shaintrin.h>
#endif
+/* These intrinsics are defined in Intrin.h on Windows. */
+#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
+#endif /* _MSC_VER */
+
#endif /* __IMMINTRIN_H */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2468.1.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131224/9ba39f84/attachment.bin>
More information about the cfe-commits
mailing list