Reimplement __readeflags and __writeeflags on top of intrinsics

Lean on LLVM to provide this functionality now that it provides the
necessary intrinsics.

llvm-svn: 256686
This commit is contained in:
David Majnemer 2016-01-01 06:50:08 +00:00
parent 011980cd50
commit 30f9bfd574
2 changed files with 11 additions and 28 deletions

View File

@ -41,6 +41,13 @@ TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "")
TARGET_BUILTIN(__builtin_ia32_undef256, "V4d", "nc", "")
TARGET_BUILTIN(__builtin_ia32_undef512, "V8d", "nc", "")
// FLAGS
//
TARGET_BUILTIN(__builtin_ia32_readeflags_u32, "Ui", "n", "")
TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "ULLi", "n", "")
TARGET_BUILTIN(__builtin_ia32_writeeflags_u32, "vUi", "n", "")
TARGET_BUILTIN(__builtin_ia32_writeeflags_u64, "vULLi", "n", "")
// 3DNow!
//
TARGET_BUILTIN(__builtin_ia32_femms, "v", "", "3dnow")

View File

@ -32,50 +32,26 @@
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;
return __builtin_ia32_readeflags_u64();
}
static __inline__ void __attribute__((__always_inline__, __nodebug__))
__writeeflags(unsigned long long __f)
{
__asm__ __volatile__ ("pushq %0\n\t"
"popf\n"
:
:"r"(__f)
:"flags"
);
__builtin_ia32_writeeflags_u64(__f);
}
#else /* !__x86_64__ */
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;
return __builtin_ia32_readeflags_u32();
}
static __inline__ void __attribute__((__always_inline__, __nodebug__))
__writeeflags(unsigned int __f)
{
__asm__ __volatile__ ("pushl %0\n\t"
"popf\n"
:
:"r"(__f)
:"flags"
);
__builtin_ia32_writeeflags_u32(__f);
}
#endif /* !__x86_64__ */