[PATCH] Added _rdtsc intrinsics

Reid Kleckner rnk at google.com
Fri Mar 28 14:11:22 PDT 2014


lgtm


On Fri, Mar 28, 2014 at 2:06 PM, Robert Khasanov <rob.khasanov at gmail.com>wrote:

> Yes, this intrinsic is also implemented in gcc in ia32intrin.h.
> According ISA this instruction is valid for x86_64: the only difference is
> that high 32 bits of rax and rdx become zero, low 32 bits are the same as
> in 32 bit.
>
> суббота, 29 марта 2014 г. пользователь Reid Kleckner написал:
>
> 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/9a74be9b/attachment.html>


More information about the cfe-commits mailing list