<div dir="ltr"><div>Does gcc provide this intrinsic?</div><div><br></div><div>Is this assembly correct for x86_64?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 28, 2014 at 8:48 AM, Robert Khasanov <span dir="ltr"><<a href="mailto:rob.khasanov@gmail.com" target="_blank">rob.khasanov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rnk, echristo,<br>
<br>
This patch moves _rdtsc() intrinsics from Intrin.h to ia32intrin.h as it used on windows and linux.<br>
<br>
<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D3212" target="_blank">http://llvm-reviews.chandlerc.com/D3212</a><br>
<br>
Files:<br>
lib/Headers/Intrin.h<br>
lib/Headers/ia32intrin.h<br>
<br>
Index: lib/Headers/Intrin.h<br>
===================================================================<br>
--- lib/Headers/Intrin.h<br>
+++ lib/Headers/Intrin.h<br>
@@ -976,12 +976,6 @@<br>
__asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));<br>
return ((unsigned __int64)__edx << 32) | __eax;<br>
}<br>
-static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))<br>
-__rdtsc(void) {<br>
- unsigned int __eax, __edx;<br>
- __asm__ ("rdtsc" : "=a" (__eax), "=d" (__edx));<br>
- return ((unsigned __int64)__edx << 32) | __eax;<br>
-}<br>
static __inline__ void __attribute__((__always_inline__, __nodebug__))<br>
__halt(void) {<br>
__asm__ volatile ("hlt");<br>
Index: lib/Headers/ia32intrin.h<br>
===================================================================<br>
--- lib/Headers/ia32intrin.h<br>
+++ lib/Headers/ia32intrin.h<br>
@@ -79,4 +79,14 @@<br>
}<br>
#endif /* !__x86_64__ */<br>
<br>
+/* __rdtsc */<br>
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))<br>
+__rdtsc(void) {<br>
+ unsigned int __eax, __edx;<br>
+ __asm__ ("rdtsc" : "=a" (__eax), "=d" (__edx));<br>
+ return ((unsigned long long)__edx << 32) | __eax;<br>
+}<br>
+<br>
+#define _rdtsc() __rdtsc()<br>
+<br>
#endif /* __IA32INTRIN_H */<br>
</blockquote></div><br></div>