Commit bc394e5a by Uros Bizjak Committed by Uros Bizjak

mpx-os-support.h: New file.

	* gcc.target/i386/mpx/mpx-os-support.h: New file.
	* gcc.target/i386/mpx/mpx-check.h: Include mpx-os-support.h.

From-SVN: r251683
parent fc3664b1
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.
2017-09-04 Bernd Edlinger <bernd.edlinger@hotmail.de> 2017-09-04 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR target/77308 PR target/77308
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "cpuid.h" #include "cpuid.h"
#include "mpx-os-support.h"
static int static int
__attribute__ ((noinline)) __attribute__ ((noinline))
...@@ -16,16 +16,6 @@ mpx_test (int, const char **); ...@@ -16,16 +16,6 @@ mpx_test (int, const char **);
#define DEBUG #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 static int
check_osxsave (void) check_osxsave (void)
{ {
...@@ -44,7 +34,7 @@ main (int argc, const char **argv) ...@@ -44,7 +34,7 @@ main (int argc, const char **argv)
return NORUNRES; return NORUNRES;
/* Run MPX test only if host has MPX support. */ /* 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); mpx_test (argc, argv);
else else
{ {
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment