]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgo: use inline assembly in favor of call to _xgetbv()
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Oct 2018 17:51:57 +0000 (17:51 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Oct 2018 17:51:57 +0000 (17:51 +0000)
    Use inline assembly in the implementation of internal_cpu.xgetbv as
    opposed to a call to the intrinsic _xgetbv(), since non-gcc compilers
    (e.g. clang) may or may not have support for it.

    Reviewed-on: https://go-review.googlesource.com/c/140137

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264882 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
libgo/go/internal/cpu/cpu_gccgo.c

index b28c8d333ef78e9e756a41041c929c70b92d9ebd..2c7a860c8a8ffa7991bfef87a39e646455f1cb82 100644 (file)
@@ -1,4 +1,4 @@
-9f4cf23e716bcf65e071260afa032a64acd3fdde
+d0739c13ca3686df1f8d0fae7c6c5caaed058503
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 6625ddccabb208e6d82947087b6895589df95360..1d5b492a7877f762e1bc3c920c490a9a3819b60d 100644 (file)
@@ -52,12 +52,18 @@ struct xgetbv_ret xgetbv(void)
 #pragma GCC target("xsave")
 
 struct xgetbv_ret xgetbv(void) {
-       long long r;
        struct xgetbv_ret ret;
 
-       r = _xgetbv(0);
-       ret.eax = r & 0xffffffff;
-       ret.edx = r >> 32;
+        // At some point, use call to _xgetbv() instead:
+        //
+        //       long long r = _xgetbv(0);
+        //       ret.eax = r & 0xffffffff;
+        //       ret.edx = r >> 32;
+        //
+        unsigned int __eax, __edx, __xcr_no = 0;
+        __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
+        ret.eax = __eax;
+        ret.edx = __edx;
        return ret;
 }