[PATCH] D128461: [X86] Simplify __cpuid_count
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 23 13:52:39 PDT 2022
MaskRay created this revision.
Herald added subscribers: jsji, StephenFan, pengfei.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Use the x86-32 implementation for x86-64, i.e. replace =r plus xchgq with =b.
Using =r seems like a workaround when RBX as a base register did not
work well =b (2014-09 416efb5f909e45f67ee81d382a708fc41666c5c6), likely
no longer relevant today.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128461
Files:
clang/lib/Headers/cpuid.h
Index: clang/lib/Headers/cpuid.h
===================================================================
--- clang/lib/Headers/cpuid.h
+++ clang/lib/Headers/cpuid.h
@@ -235,7 +235,6 @@
#define bit_WBNOINVD 0x00000200
-#if __i386__
#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
__asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
: "0"(__leaf))
@@ -243,22 +242,6 @@
#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \
__asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
: "0"(__leaf), "2"(__count))
-#else
-/* x86-64 uses %rbx as the base register, so preserve it. */
-#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
- __asm(" xchgq %%rbx,%q1\n" \
- " cpuid\n" \
- " xchgq %%rbx,%q1" \
- : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
- : "0"(__leaf))
-
-#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \
- __asm(" xchgq %%rbx,%q1\n" \
- " cpuid\n" \
- " xchgq %%rbx,%q1" \
- : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
- : "0"(__leaf), "2"(__count))
-#endif
static __inline int __get_cpuid_max (unsigned int __leaf, unsigned int *__sig)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128461.439526.patch
Type: text/x-patch
Size: 1284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220623/a258a8f8/attachment.bin>
More information about the cfe-commits
mailing list