[gcc(refs/users/ibuclaw/heads/darwin)] libphobos: Use raw byte sequence instead of xgetbv

Iain Buclaw ibuclaw@gcc.gnu.org
Mon Jan 11 11:39:28 GMT 2021


https://gcc.gnu.org/g:580ad7746983e73c1453039ee87b876de6f4d711

commit 580ad7746983e73c1453039ee87b876de6f4d711
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Dec 3 23:52:11 2020 +0100

    libphobos: Use raw byte sequence instead of xgetbv

Diff:
---
 libphobos/libdruntime/core/cpuid.d | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libphobos/libdruntime/core/cpuid.d b/libphobos/libdruntime/core/cpuid.d
index 2ba13b55bf1..109fd3b9efc 100644
--- a/libphobos/libdruntime/core/cpuid.d
+++ b/libphobos/libdruntime/core/cpuid.d
@@ -771,7 +771,10 @@ void cpuidX86()
     if (cf.miscfeatures & OSXSAVE_BIT)
     {
         version (GNU) asm pure nothrow @nogc {
-            "xgetbv" : "=a" (a), "=d" (d) : "c" (0);
+            /* Old assemblers do not recognize xgetbv, and there is no easy way
+             * to conditionally compile based on the assembler used, so use the
+             * raw .byte sequence instead.  */
+            ".byte 0x0f, 0x01, 0xd0" : "=a" (a), "=d" (d) : "c" (0);
         } else asm pure nothrow @nogc {
             mov ECX, 0;
             xgetbv;


More information about the Gcc-cvs mailing list