[PATCH] Added _rdtsc intrinsics

Robert Khasanov rob.khasanov at gmail.com
Fri Mar 28 08:48:29 PDT 2014


Hi rnk, echristo,

This patch moves _rdtsc() intrinsics from Intrin.h to ia32intrin.h as it used on windows and linux.




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

Files:
  lib/Headers/Intrin.h
  lib/Headers/ia32intrin.h

Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -976,12 +976,6 @@
   __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
   return ((unsigned __int64)__edx << 32) | __eax;
 }
-static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))
-__rdtsc(void) {
-  unsigned int __eax, __edx;
-  __asm__ ("rdtsc" : "=a" (__eax), "=d" (__edx));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
 __halt(void) {
   __asm__ volatile ("hlt");
Index: lib/Headers/ia32intrin.h
===================================================================
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -79,4 +79,14 @@
 }
 #endif /* !__x86_64__ */
 
+/* __rdtsc */
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__rdtsc(void) {
+  unsigned int __eax, __edx;
+  __asm__ ("rdtsc" : "=a" (__eax), "=d" (__edx));
+  return ((unsigned long long)__edx << 32) | __eax;
+}
+
+#define _rdtsc() __rdtsc()
+
 #endif /* __IA32INTRIN_H */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3212.1.patch
Type: text/x-patch
Size: 1167 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140328/a4af1f40/attachment.bin>


More information about the cfe-commits mailing list