aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-10-05 17:51:57 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-10-05 17:51:57 +0000
commit7fc9c2e52f66a2b8aa101ef918829046f8f517e8 (patch)
tree2d06104b346a0aad0d48b96c8d6627ba7d88daed /libgo
parentd5a9895595c126a5fa8b41c222f330908c3a7e72 (diff)
downloadgcc-7fc9c2e52f66a2b8aa101ef918829046f8f517e8.zip
gcc-7fc9c2e52f66a2b8aa101ef918829046f8f517e8.tar.gz
gcc-7fc9c2e52f66a2b8aa101ef918829046f8f517e8.tar.bz2
libgo: use inline assembly in favor of call to _xgetbv()
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 From-SVN: r264882
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/internal/cpu/cpu_gccgo.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libgo/go/internal/cpu/cpu_gccgo.c b/libgo/go/internal/cpu/cpu_gccgo.c
index 6625ddc..1d5b492 100644
--- a/libgo/go/internal/cpu/cpu_gccgo.c
+++ b/libgo/go/internal/cpu/cpu_gccgo.c
@@ -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;
}