[PATCH] Add implementations of __readfs{byte, word, dword, qword} to Intrin.h
Chandler Carruth
chandlerc at google.com
Thu Jan 23 10:11:59 PST 2014
Why not use the address space technique? David seemed to find that worked
well.
On Jan 23, 2014 9:18 AM, "Hans Wennborg" <hans at chromium.org> wrote:
> Hi whunt, rnk,
>
> Please take a look. I always worry about getting the mov operands
> backwards :)
>
> http://llvm-reviews.chandlerc.com/D2606
>
> Files:
> lib/Headers/Intrin.h
>
> Index: lib/Headers/Intrin.h
> ===================================================================
> --- lib/Headers/Intrin.h
> +++ lib/Headers/Intrin.h
> @@ -101,9 +101,13 @@
> unsigned long __readcr8(void);
> unsigned int __readdr(unsigned int);
> unsigned int __readeflags(void);
> +static __inline__
> unsigned char __readfsbyte(unsigned long);
> +static __inline__
> unsigned long __readfsdword(unsigned long);
> +static __inline__
> unsigned __int64 __readfsqword(unsigned long);
> +static __inline__
> unsigned short __readfsword(unsigned long);
> unsigned __int64 __readmsr(unsigned long);
> unsigned __int64 __readpmc(unsigned long);
> @@ -767,6 +771,33 @@
> __asm__ volatile ("" : : : "memory");
> }
>
> /*----------------------------------------------------------------------------*\
> +|* readfs
>
> +\*----------------------------------------------------------------------------*/
> +static __inline__ unsigned char __attribute__((__always_inline__,
> __nodebug__))
> +__readfsbyte(unsigned long __addr) {
> + unsigned char __result;
> + __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
> + return __result;
> +}
> +static __inline__ unsigned long __attribute__((__always_inline__,
> __nodebug__))
> +__readfsdword(unsigned long __addr) {
> + unsigned long __result;
> + __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
> + return __result;
> +}
> +static __inline__ unsigned __int64 __attribute__((__always_inline__,
> __nodebug__))
> +__readfsqword(unsigned long __addr) {
> + unsigned __int64 __result;
> + __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
> + return __result;
> +}
> +static __inline__ unsigned short __attribute__((__always_inline__,
> __nodebug__))
> +__readfsword(unsigned long __addr) {
> + unsigned short __result;
> + __asm__ ("mov %%fs:(%1), %0" : "=r" (__result) : "r" (__addr));
> + return __result;
> +}
>
> +/*----------------------------------------------------------------------------*\
> |* Misc
>
> \*----------------------------------------------------------------------------*/
> static __inline__ void * __attribute__((__always_inline__, __nodebug__))
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/41a13483/attachment.html>
More information about the cfe-commits
mailing list