[PATCH] Added _rdtsc intrinsics

Reid Kleckner rnk at google.com
Fri Mar 28 13:19:28 PDT 2014


Does gcc provide this intrinsic?

Is this assembly correct for x86_64?


On Fri, Mar 28, 2014 at 8:48 AM, Robert Khasanov <rob.khasanov at gmail.com>wrote:

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140328/847d97d5/attachment.html>


More information about the cfe-commits mailing list