https://github.com/Alcaro updated https://github.com/llvm/llvm-project/pull/127331
>From 90e3f502e582f44cd19e1b8b71d218330b13c9e4 Mon Sep 17 00:00:00 2001 From: Alcaro <float...@muncher.se> Date: Sat, 15 Feb 2025 16:05:40 +0100 Subject: [PATCH 1/2] [clang][x86] Support -masm=intel in cpuid.h --- clang/lib/Headers/cpuid.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h index 2601aa5724f05..d8ace39d4e7d1 100644 --- a/clang/lib/Headers/cpuid.h +++ b/clang/lib/Headers/cpuid.h @@ -268,16 +268,16 @@ #else /* x86-64 uses %rbx as the base register, so preserve it. */ #define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ - __asm(" xchgq %%rbx,%q1\n" \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ " cpuid\n" \ - " xchgq %%rbx,%q1" \ + " xchg{q|} {%%|}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" \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ " cpuid\n" \ - " xchgq %%rbx,%q1" \ + " xchg{q|} {%%|}rbx,%q1" \ : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ : "0"(__leaf), "2"(__count)) #endif @@ -289,18 +289,18 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf, #ifdef __i386__ int __cpuid_supported; - __asm(" pushfl\n" - " popl %%eax\n" - " movl %%eax,%%ecx\n" - " xorl $0x00200000,%%eax\n" - " pushl %%eax\n" - " popfl\n" - " pushfl\n" - " popl %%eax\n" - " movl $0,%0\n" - " cmpl %%eax,%%ecx\n" + __asm(" pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {%%eax,%%ecx|ecx,eax}\n" + " xor{l|} {$0x00200000,%%eax|eax,0x00200000}\n" + " push{l|} {%%|}eax\n" + " popf{l|d}\n" + " pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {$0,%0|%0,0}\n" + " cmp{l|} {%%eax,%%ecx|ecx,eax}\n" " je 1f\n" - " movl $1,%0\n" + " mov{l|} {$1,%0|%0,1}\n" "1:" : "=r" (__cpuid_supported) : : "eax", "ecx"); if (!__cpuid_supported) >From ca0728b407af361559f954d9f25498c4af905dec Mon Sep 17 00:00:00 2001 From: Alcaro <float...@muncher.se> Date: Sat, 15 Feb 2025 16:41:57 +0100 Subject: [PATCH 2/2] fix indentation --- clang/lib/Headers/cpuid.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h index d8ace39d4e7d1..cd7d06ab29009 100644 --- a/clang/lib/Headers/cpuid.h +++ b/clang/lib/Headers/cpuid.h @@ -268,17 +268,18 @@ #else /* x86-64 uses %rbx as the base register, so preserve it. */ #define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ - __asm(" xchg{q|} {%%|}rbx,%q1\n" \ - " cpuid\n" \ - " xchg{q|} {%%|}rbx,%q1" \ - : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ +#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ + " cpuid\n" \ + " xchg{q|} {%%|}rbx,%q1" \ + : "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ : "0"(__leaf)) -#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ - __asm(" xchg{q|} {%%|}rbx,%q1\n" \ - " cpuid\n" \ - " xchg{q|} {%%|}rbx,%q1" \ - : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ +#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ + " cpuid\n" \ + " xchg{q|} {%%|}rbx,%q1" \ + : "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ : "0"(__leaf), "2"(__count)) #endif @@ -302,7 +303,9 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf, " je 1f\n" " mov{l|} {$1,%0|%0,1}\n" "1:" - : "=r" (__cpuid_supported) : : "eax", "ecx"); + : "=r"(__cpuid_supported) + : + : "eax", "ecx"); if (!__cpuid_supported) return 0; #endif _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits