* [PATCH, testsuite]: Avoid magic constants in gcc.target/i386/avx-os-support.h
@ 2012-06-06 18:35 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2012-06-06 18:35 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
Hello!
2012-06-06 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/avx-os-support.h (XCR_XFEATURE_ENABLED_MASK): New.
(XSTATE_FP): Ditto.
(XSTATE_SSE): Ditto.
(XSTATE_YMM): Ditto.
(avx_os_support): Use new defines.
Tested on x86_64-pc-linux-gnu AVX target, committed to mainline SVN.
Uros.
[-- Attachment #2: t.diff.txt --]
[-- Type: text/plain, Size: 700 bytes --]
Index: avx-os-support.h
===================================================================
--- avx-os-support.h (revision 188268)
+++ avx-os-support.h (working copy)
@@ -1,10 +1,18 @@
/* Check if the OS supports executing AVX instructions. */
+#define XCR_XFEATURE_ENABLED_MASK 0x0
+
+#define XSTATE_FP 0x1
+#define XSTATE_SSE 0x2
+#define XSTATE_YMM 0x4
+
static int
avx_os_support (void)
{
unsigned int eax, edx;
+ unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
- __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
- return (eax & 6) == 6;
+ __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx));
+
+ return (eax & (XSTATE_SSE | XSTATE_YMM)) == (XSTATE_SSE | XSTATE_YMM);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-06 18:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-06 18:35 [PATCH, testsuite]: Avoid magic constants in gcc.target/i386/avx-os-support.h Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).