[PATCH] Implement __readeflags and __writeeflags intrinsics
Reid Kleckner
rnk at google.com
Thu Dec 26 11:14:59 PST 2013
Can you define these in lib/Headers/Intrin.h? See the existing prototypes
for __readeflags etc.
On Tue, Dec 24, 2013 at 3:09 AM, Alexey Volkov <avolkov.intel at gmail.com>wrote:
> Hi all,
>
> This patch implements __readeflags and __writeeflags intrinsics for x86
> arch.
>
> Alexey Volkov
> Intel Corporation
>
> http://llvm-reviews.chandlerc.com/D2468
>
> Files:
> lib/Headers/immintrin.h
>
> Index: lib/Headers/immintrin.h
> ===================================================================
> --- lib/Headers/immintrin.h
> +++ lib/Headers/immintrin.h
> @@ -115,4 +115,58 @@
> #include <shaintrin.h>
> #endif
>
> +/* These intrinsics are defined in Intrin.h on Windows. */
> +#ifndef _MSC_VER
> +#ifdef __x86_64__
> +static __inline__ unsigned long long __attribute__((__always_inline__,
> __nodebug__))
> +__readeflags(void)
> +{
> + unsigned long long res = 0;
> + __asm__ __volatile__ ("pushf\n\t"
> + "popq %0\n"
> + :"=r"(res)
> + :
> + :
> + );
> + return res;
> +}
> +
> +static __inline__ void __attribute__((__always_inline__, __nodebug__))
> +__writeeflags(unsigned long long __f)
> +{
> + __asm__ __volatile__ ("pushq %0\n\t"
> + "popf\n"
> + :
> + :"r"(__f)
> + :"flags"
> + );
> +}
> +
> +#else
> +static __inline__ unsigned int __attribute__((__always_inline__,
> __nodebug__))
> +__readeflags(void)
> +{
> + unsigned int res = 0;
> + __asm__ __volatile__ ("pushf\n\t"
> + "popl %0\n"
> + :"=r"(res)
> + :
> + :
> + );
> + return res;
> +}
> +
> +static __inline__ void __attribute__((__always_inline__, __nodebug__))
> +__writeeflags(unsigned int __f)
> +{
> + __asm__ __volatile__ ("pushl %0\n\t"
> + "popf\n"
> + :
> + :"r"(__f)
> + :"flags"
> + );
> +}
> +#endif
> +#endif /* _MSC_VER */
> +
> #endif /* __IMMINTRIN_H */
>
> _______________________________________________
> 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/20131226/7865f319/attachment.html>
More information about the cfe-commits
mailing list