[PATCH] Add implementations of __readfs{byte, word, dword, qword} to Intrin.h
Reid Kleckner
rnk at google.com
Thu Jan 23 11:03:18 PST 2014
This is the address space extension for accessing TLS:
http://clang.llvm.org/docs/LanguageExtensions.html#x86-x86-64-language-extensions
That's a lot cleaner. Let's do that.
On Thu, Jan 23, 2014 at 10:38 AM, Hans Wennborg <hans at chromium.org> wrote:
> Addressed rnk's comments.
>
> Chandler: can you provide a pointer to the address space technique you
> mentioned?
>
> Hi rnk, whunt,
>
> http://llvm-reviews.chandlerc.com/D2606
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D2606?vs=6606&id=6607#toc
>
> 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 __offset) {
> + unsigned char __result;
> + __asm__ ("movb %%fs:(%1), %0" : "=r" (__result) : "r" (__offset));
> + return __result;
> +}
> +static __inline__ unsigned long __attribute__((__always_inline__,
> __nodebug__))
> +__readfsdword(unsigned long __offset) {
> + unsigned long __result;
> + __asm__ ("movl %%fs:(%1), %0" : "=r" (__result) : "r" (__offset));
> + return __result;
> +}
> +static __inline__ unsigned __int64 __attribute__((__always_inline__,
> __nodebug__))
> +__readfsqword(unsigned long __offset) {
> + unsigned __int64 __result;
> + __asm__ ("movq %%fs:(%1), %0" : "=r" (__result) : "r" (__offset));
> + return __result;
> +}
> +static __inline__ unsigned short __attribute__((__always_inline__,
> __nodebug__))
> +__readfsword(unsigned long __offset) {
> + unsigned short __result;
> + __asm__ ("movw %%fs:(%1), %0" : "=r" (__result) : "r" (__offset));
> + return __result;
> +}
>
> +/*----------------------------------------------------------------------------*\
> |* Misc
>
> \*----------------------------------------------------------------------------*/
> static __inline__ void * __attribute__((__always_inline__, __nodebug__))
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/b035579e/attachment.html>
More information about the cfe-commits
mailing list