From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH, i386 testsuite]: Introduce gcc.target/i386/mpx/mpx-os-support.h
Date: Mon, 04 Sep 2017 18:35:00 -0000 [thread overview]
Message-ID: <CAFULd4a9mRAO2-TnBQieBnQtNcAO17Ly4vqS=U9m-4NPt_DZEA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 237 bytes --]
2017-09-04 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/mpx/mpx-os-support.h: New file.
* gcc.target/i386/mpx/mpx-check.h: Include mpx-os-support.h.
Tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN.
Uros.
[-- Attachment #2: t.diff.txt --]
[-- Type: text/plain, Size: 1549 bytes --]
Index: gcc.target/i386/mpx/mpx-check.h
===================================================================
--- gcc.target/i386/mpx/mpx-check.h (revision 251661)
+++ gcc.target/i386/mpx/mpx-check.h (working copy)
@@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-
#include "cpuid.h"
+#include "mpx-os-support.h"
static int
__attribute__ ((noinline))
@@ -16,16 +16,6 @@
#define DEBUG
-#define XSTATE_BNDREGS (1 << 3)
-
-/* This should be an intrinsic, but isn't. */
-static int xgetbv (unsigned x)
-{
- unsigned eax, edx;
- asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (x));
- return eax;
-}
-
static int
check_osxsave (void)
{
@@ -44,7 +34,7 @@
return NORUNRES;
/* Run MPX test only if host has MPX support. */
- if (check_osxsave () && (ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS))
+ if (check_osxsave () && (ebx & bit_MPX) && mpx_os_support ())
mpx_test (argc, argv);
else
{
Index: gcc.target/i386/mpx/mpx-os-support.h
===================================================================
--- gcc.target/i386/mpx/mpx-os-support.h (nonexistent)
+++ gcc.target/i386/mpx/mpx-os-support.h (working copy)
@@ -0,0 +1,16 @@
+/* Check if the OS supports executing MPX instructions. */
+
+#define XCR_XFEATURE_ENABLED_MASK 0x0
+
+#define XSTATE_BNDREGS 0x8
+
+static int
+mpx_os_support (void)
+{
+ unsigned int eax, edx;
+ unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
+
+ __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx));
+
+ return (eax & XSTATE_BNDREGS) != 0;
+}
reply other threads:[~2017-09-04 18:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFULd4a9mRAO2-TnBQieBnQtNcAO17Ly4vqS=U9m-4NPt_DZEA@mail.gmail.com' \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).