|
|
22033d |
2015-12-24 Kirill Yukhin <kirill.yukhin@intel.com>
|
|
|
22033d |
|
|
|
22033d |
* common/config/i386/i386-common.c (OPTION_MASK_ISA_PKU_SET): New.
|
|
|
22033d |
(OPTION_MASK_ISA_PKU_UNSET): Ditto.
|
|
|
22033d |
(ix86_handle_option): Handle OPT_mpku.
|
|
|
22033d |
* config.gcc: Add pkuintrin.h to i[34567]86-*-* and x86_64-*-*
|
|
|
22033d |
targets.
|
|
|
22033d |
* config/i386/cpuid.h (host_detect_local_cpu): Detect PKU feature.
|
|
|
22033d |
* config/i386/i386-c.c (ix86_target_macros_internal): Handle PKU ISA
|
|
|
22033d |
flag.
|
|
|
22033d |
* config/i386/i386.c (ix86_target_string): Add "-mpku" to
|
|
|
22033d |
ix86_target_opts.
|
|
|
22033d |
(ix86_option_override_internal): Define PTA_PKU, mention new key
|
|
|
22033d |
in skylake-avx512. Handle new ISA bits.
|
|
|
22033d |
(ix86_valid_target_attribute_inner_p): Add "pku".
|
|
|
22033d |
(enum ix86_builtins): Add IX86_BUILTIN_RDPKRU and IX86_BUILTIN_WRPKRU.
|
|
|
22033d |
(builtin_description bdesc_special_args[]): Add new built-ins.
|
|
|
22033d |
* config/i386/i386.h (define TARGET_PKU): New.
|
|
|
22033d |
(define TARGET_PKU_P): Ditto.
|
|
|
22033d |
* config/i386/i386.md (define_c_enum "unspecv"): Add UNSPEC_PKU.
|
|
|
22033d |
(define_expand "rdpkru"): New.
|
|
|
22033d |
(define_insn "*rdpkru"): Ditto.
|
|
|
22033d |
(define_expand "wrpkru"): Ditto.
|
|
|
22033d |
(define_insn "*wrpkru"): Ditto.
|
|
|
22033d |
* config/i386/i386.opt (mpku): Ditto.
|
|
|
22033d |
* config/i386/pkuintrin.h: New file.
|
|
|
22033d |
* config/i386/x86intrin.h: Include pkuintrin.h
|
|
|
22033d |
* doc/extend.texi: Describe new built-ins.
|
|
|
22033d |
* doc/invoke.texi: Describe new switches.
|
|
|
22033d |
|
|
|
22033d |
* g++.dg/other/i386-2.C: Add -mpku.
|
|
|
22033d |
* g++.dg/other/i386-3.C: Ditto.
|
|
|
22033d |
* gcc.target/i386/rdpku-1.c: New test.
|
|
|
22033d |
* gcc.target/i386/sse-12.c: Add -mpku.
|
|
|
22033d |
* gcc.target/i386/sse-13.c: Ditto.
|
|
|
22033d |
* gcc.target/i386/sse-22.c: Ditto.
|
|
|
22033d |
* gcc.target/i386/sse-33.c: Ditto.
|
|
|
22033d |
* gcc.target/i386/wrpku-1.c: New test.
|
|
|
22033d |
|
|
|
22033d |
--- gcc/config.gcc (revision 231943)
|
|
|
22033d |
+++ gcc/config.gcc (revision 231945)
|
|
|
22033d |
@@ -368,7 +368,7 @@ i[34567]86-*-*)
|
|
|
22033d |
lzcntintrin.h bmiintrin.h bmi2intrin.h tbmintrin.h
|
|
|
22033d |
avx2intrin.h fmaintrin.h f16cintrin.h rtmintrin.h
|
|
|
22033d |
xtestintrin.h rdseedintrin.h prfchwintrin.h adxintrin.h
|
|
|
22033d |
- fxsrintrin.h xsaveintrin.h xsaveoptintrin.h"
|
|
|
22033d |
+ fxsrintrin.h xsaveintrin.h xsaveoptintrin.h pkuintrin.h"
|
|
|
22033d |
;;
|
|
|
22033d |
x86_64-*-*)
|
|
|
22033d |
cpu_type=i386
|
|
|
22033d |
@@ -383,7 +383,7 @@ x86_64-*-*)
|
|
|
22033d |
lzcntintrin.h bmiintrin.h tbmintrin.h bmi2intrin.h
|
|
|
22033d |
avx2intrin.h fmaintrin.h f16cintrin.h rtmintrin.h
|
|
|
22033d |
xtestintrin.h rdseedintrin.h prfchwintrin.h adxintrin.h
|
|
|
22033d |
- fxsrintrin.h xsaveintrin.h xsaveoptintrin.h"
|
|
|
22033d |
+ fxsrintrin.h xsaveintrin.h xsaveoptintrin.h pkuintrin.h"
|
|
|
22033d |
need_64bit_hwint=yes
|
|
|
22033d |
;;
|
|
|
22033d |
ia64-*-*)
|
|
|
22033d |
--- gcc/common/config/i386/i386-common.c (revision 231943)
|
|
|
22033d |
+++ gcc/common/config/i386/i386-common.c (revision 231945)
|
|
|
22033d |
@@ -98,6 +98,7 @@ along with GCC; see the file COPYING3.
|
|
|
22033d |
#define OPTION_MASK_ISA_RDRND_SET OPTION_MASK_ISA_RDRND
|
|
|
22033d |
#define OPTION_MASK_ISA_F16C_SET \
|
|
|
22033d |
(OPTION_MASK_ISA_F16C | OPTION_MASK_ISA_AVX_SET)
|
|
|
22033d |
+#define OPTION_MASK_ISA_PKU_SET OPTION_MASK_ISA_PKU
|
|
|
22033d |
|
|
|
22033d |
/* Define a set of ISAs which aren't available when a given ISA is
|
|
|
22033d |
disabled. MMX and SSE ISAs are handled separately. */
|
|
|
22033d |
@@ -164,6 +165,7 @@ along with GCC; see the file COPYING3.
|
|
|
22033d |
#define OPTION_MASK_ISA_FSGSBASE_UNSET OPTION_MASK_ISA_FSGSBASE
|
|
|
22033d |
#define OPTION_MASK_ISA_RDRND_UNSET OPTION_MASK_ISA_RDRND
|
|
|
22033d |
#define OPTION_MASK_ISA_F16C_UNSET OPTION_MASK_ISA_F16C
|
|
|
22033d |
+#define OPTION_MASK_ISA_PKU_UNSET OPTION_MASK_ISA_PKU
|
|
|
22033d |
|
|
|
22033d |
/* Implement TARGET_HANDLE_OPTION. */
|
|
|
22033d |
|
|
|
22033d |
@@ -659,6 +661,19 @@ ix86_handle_option (struct gcc_options *
|
|
|
22033d |
}
|
|
|
22033d |
return true;
|
|
|
22033d |
|
|
|
22033d |
+ case OPT_mpku:
|
|
|
22033d |
+ if (value)
|
|
|
22033d |
+ {
|
|
|
22033d |
+ opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PKU_SET;
|
|
|
22033d |
+ opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_PKU_SET;
|
|
|
22033d |
+ }
|
|
|
22033d |
+ else
|
|
|
22033d |
+ {
|
|
|
22033d |
+ opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_PKU_UNSET;
|
|
|
22033d |
+ opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_PKU_UNSET;
|
|
|
22033d |
+ }
|
|
|
22033d |
+ return true;
|
|
|
22033d |
+
|
|
|
22033d |
/* Comes from final.c -- no real reason to change it. */
|
|
|
22033d |
#define MAX_CODE_ALIGN 16
|
|
|
22033d |
|
|
|
22033d |
--- gcc/config/i386/i386.h (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/i386.h (revision 231945)
|
|
|
22033d |
@@ -80,6 +80,7 @@ see the files COPYING3 and COPYING.RUNTI
|
|
|
22033d |
#define TARGET_FXSR TARGET_ISA_FXSR
|
|
|
22033d |
#define TARGET_XSAVE TARGET_ISA_XSAVE
|
|
|
22033d |
#define TARGET_XSAVEOPT TARGET_ISA_XSAVEOPT
|
|
|
22033d |
+#define TARGET_PKU TARGET_ISA_PKU
|
|
|
22033d |
|
|
|
22033d |
#define TARGET_LP64 TARGET_ABI_64
|
|
|
22033d |
#define TARGET_X32 TARGET_ABI_X32
|
|
|
22033d |
--- gcc/config/i386/i386.md (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/i386.md (revision 231945)
|
|
|
22033d |
@@ -224,6 +224,9 @@ (define_c_enum "unspecv" [
|
|
|
22033d |
UNSPECV_XTEST
|
|
|
22033d |
|
|
|
22033d |
UNSPECV_NLGR
|
|
|
22033d |
+
|
|
|
22033d |
+ ;; For RDPKRU and WRPKRU support
|
|
|
22033d |
+ UNSPECV_PKU
|
|
|
22033d |
])
|
|
|
22033d |
|
|
|
22033d |
;; Constants to represent rounding modes in the ROUND instruction
|
|
|
22033d |
@@ -18289,6 +18292,48 @@ (define_insn "xtest_1"
|
|
|
22033d |
[(set_attr "type" "other")
|
|
|
22033d |
(set_attr "length" "3")])
|
|
|
22033d |
|
|
|
22033d |
+;; RDPKRU and WRPKRU
|
|
|
22033d |
+
|
|
|
22033d |
+(define_expand "rdpkru"
|
|
|
22033d |
+ [(parallel
|
|
|
22033d |
+ [(set (match_operand:SI 0 "register_operand")
|
|
|
22033d |
+ (unspec_volatile:SI [(match_dup 1)] UNSPECV_PKU))
|
|
|
22033d |
+ (set (match_dup 2) (const_int 0))])]
|
|
|
22033d |
+ "TARGET_PKU"
|
|
|
22033d |
+{
|
|
|
22033d |
+ operands[1] = force_reg (SImode, const0_rtx);
|
|
|
22033d |
+ operands[2] = gen_reg_rtx (SImode);
|
|
|
22033d |
+})
|
|
|
22033d |
+
|
|
|
22033d |
+(define_insn "*rdpkru"
|
|
|
22033d |
+ [(set (match_operand:SI 0 "register_operand" "=a")
|
|
|
22033d |
+ (unspec_volatile:SI [(match_operand:SI 2 "register_operand" "c")]
|
|
|
22033d |
+ UNSPECV_PKU))
|
|
|
22033d |
+ (set (match_operand:SI 1 "register_operand" "=d")
|
|
|
22033d |
+ (const_int 0))]
|
|
|
22033d |
+ "TARGET_PKU"
|
|
|
22033d |
+ "rdpkru"
|
|
|
22033d |
+ [(set_attr "type" "other")])
|
|
|
22033d |
+
|
|
|
22033d |
+(define_expand "wrpkru"
|
|
|
22033d |
+ [(unspec_volatile:SI
|
|
|
22033d |
+ [(match_operand:SI 0 "register_operand")
|
|
|
22033d |
+ (match_dup 1) (match_dup 2)] UNSPECV_PKU)]
|
|
|
22033d |
+ "TARGET_PKU"
|
|
|
22033d |
+{
|
|
|
22033d |
+ operands[1] = force_reg (SImode, const0_rtx);
|
|
|
22033d |
+ operands[2] = force_reg (SImode, const0_rtx);
|
|
|
22033d |
+})
|
|
|
22033d |
+
|
|
|
22033d |
+(define_insn "*wrpkru"
|
|
|
22033d |
+ [(unspec_volatile:SI
|
|
|
22033d |
+ [(match_operand:SI 0 "register_operand" "a")
|
|
|
22033d |
+ (match_operand:SI 1 "register_operand" "d")
|
|
|
22033d |
+ (match_operand:SI 2 "register_operand" "c")] UNSPECV_PKU)]
|
|
|
22033d |
+ "TARGET_PKU"
|
|
|
22033d |
+ "wrpkru"
|
|
|
22033d |
+ [(set_attr "type" "other")])
|
|
|
22033d |
+
|
|
|
22033d |
(include "mmx.md")
|
|
|
22033d |
(include "sse.md")
|
|
|
22033d |
(include "sync.md")
|
|
|
22033d |
--- gcc/config/i386/pkuintrin.h (revision 0)
|
|
|
22033d |
+++ gcc/config/i386/pkuintrin.h (revision 231945)
|
|
|
22033d |
@@ -0,0 +1,45 @@
|
|
|
22033d |
+/* Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
22033d |
+
|
|
|
22033d |
+ This file is part of GCC.
|
|
|
22033d |
+
|
|
|
22033d |
+ GCC is free software; you can redistribute it and/or modify
|
|
|
22033d |
+ it under the terms of the GNU General Public License as published by
|
|
|
22033d |
+ the Free Software Foundation; either version 3, or (at your option)
|
|
|
22033d |
+ any later version.
|
|
|
22033d |
+
|
|
|
22033d |
+ GCC is distributed in the hope that it will be useful,
|
|
|
22033d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
22033d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
22033d |
+ GNU General Public License for more details.
|
|
|
22033d |
+
|
|
|
22033d |
+ Under Section 7 of GPL version 3, you are granted additional
|
|
|
22033d |
+ permissions described in the GCC Runtime Library Exception, version
|
|
|
22033d |
+ 3.1, as published by the Free Software Foundation.
|
|
|
22033d |
+
|
|
|
22033d |
+ You should have received a copy of the GNU General Public License and
|
|
|
22033d |
+ a copy of the GCC Runtime Library Exception along with this program;
|
|
|
22033d |
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
22033d |
+ <http://www.gnu.org/licenses/>. */
|
|
|
22033d |
+
|
|
|
22033d |
+#if !defined _X86INTRIN_H_INCLUDED
|
|
|
22033d |
+# error "Never use <pkuintrin.h> directly; include <x86intrin.h> instead."
|
|
|
22033d |
+#endif
|
|
|
22033d |
+
|
|
|
22033d |
+#ifndef _PKUINTRIN_H_INCLUDED
|
|
|
22033d |
+#define _PKUINTRIN_H_INCLUDED
|
|
|
22033d |
+
|
|
|
22033d |
+extern __inline unsigned int
|
|
|
22033d |
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
|
|
22033d |
+_rdpkru_u32(void)
|
|
|
22033d |
+{
|
|
|
22033d |
+ return __builtin_ia32_rdpkru ();
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+extern __inline void
|
|
|
22033d |
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
|
|
22033d |
+_wrpkru(unsigned int key)
|
|
|
22033d |
+{
|
|
|
22033d |
+ return __builtin_ia32_wrpkru (key);
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+#endif /* _PKUINTRIN_H_INCLUDED */
|
|
|
22033d |
--- gcc/config/i386/cpuid.h (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/cpuid.h (revision 231945)
|
|
|
22033d |
@@ -74,6 +74,10 @@
|
|
|
22033d |
#define bit_RDSEED (1 << 18)
|
|
|
22033d |
#define bit_ADX (1 << 19)
|
|
|
22033d |
|
|
|
22033d |
+/* %ecx */
|
|
|
22033d |
+#define bit_PKU (1 << 3)
|
|
|
22033d |
+#define bit_OSPKE (1 << 4)
|
|
|
22033d |
+
|
|
|
22033d |
/* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */
|
|
|
22033d |
#define bit_XSAVEOPT (1 << 0)
|
|
|
22033d |
|
|
|
22033d |
--- gcc/config/i386/x86intrin.h (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/x86intrin.h (revision 231945)
|
|
|
22033d |
@@ -119,4 +119,8 @@
|
|
|
22033d |
|
|
|
22033d |
#include <adxintrin.h>
|
|
|
22033d |
|
|
|
22033d |
+#ifdef __PKU__
|
|
|
22033d |
+#include <pkuintrin.h>
|
|
|
22033d |
+#endif
|
|
|
22033d |
+
|
|
|
22033d |
#endif /* _X86INTRIN_H_INCLUDED */
|
|
|
22033d |
--- gcc/config/i386/i386-c.c (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/i386-c.c (revision 231945)
|
|
|
22033d |
@@ -348,6 +348,8 @@ ix86_target_macros_internal (HOST_WIDE_I
|
|
|
22033d |
def_or_undef (parse_in, "__XSAVE__");
|
|
|
22033d |
if (isa_flag & OPTION_MASK_ISA_XSAVEOPT)
|
|
|
22033d |
def_or_undef (parse_in, "__XSAVEOPT__");
|
|
|
22033d |
+ if (isa_flag & OPTION_MASK_ISA_PKU)
|
|
|
22033d |
+ def_or_undef (parse_in, "__PKU__");
|
|
|
22033d |
if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
|
|
|
22033d |
def_or_undef (parse_in, "__SSE_MATH__");
|
|
|
22033d |
if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
|
|
|
22033d |
--- gcc/config/i386/i386.opt (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/i386.opt (revision 231945)
|
|
|
22033d |
@@ -626,3 +626,7 @@ Split 32-byte AVX unaligned store
|
|
|
22033d |
mrtm
|
|
|
22033d |
Target Report Mask(ISA_RTM) Var(ix86_isa_flags) Save
|
|
|
22033d |
Support RTM built-in functions and code generation
|
|
|
22033d |
+
|
|
|
22033d |
+mpku
|
|
|
22033d |
+Target Report Mask(ISA_PKU) Var(ix86_isa_flags) Save
|
|
|
22033d |
+Support PKU built-in functions and code generation
|
|
|
22033d |
--- gcc/config/i386/driver-i386.c (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/driver-i386.c (revision 231945)
|
|
|
22033d |
@@ -408,6 +408,7 @@ const char *host_detect_local_cpu (int a
|
|
|
22033d |
unsigned int has_rdrnd = 0, has_f16c = 0, has_fsgsbase = 0;
|
|
|
22033d |
unsigned int has_rdseed = 0, has_prfchw = 0, has_adx = 0;
|
|
|
22033d |
unsigned int has_osxsave = 0, has_fxsr = 0, has_xsave = 0, has_xsaveopt = 0;
|
|
|
22033d |
+ unsigned int has_pku = 0;
|
|
|
22033d |
|
|
|
22033d |
bool arch;
|
|
|
22033d |
|
|
|
22033d |
@@ -479,6 +480,8 @@ const char *host_detect_local_cpu (int a
|
|
|
22033d |
has_fsgsbase = ebx & bit_FSGSBASE;
|
|
|
22033d |
has_rdseed = ebx & bit_RDSEED;
|
|
|
22033d |
has_adx = ebx & bit_ADX;
|
|
|
22033d |
+
|
|
|
22033d |
+ has_pku = ecx & bit_OSPKE;
|
|
|
22033d |
}
|
|
|
22033d |
|
|
|
22033d |
if (max_level >= 13)
|
|
|
22033d |
@@ -855,12 +858,13 @@ const char *host_detect_local_cpu (int a
|
|
|
22033d |
const char *fxsr = has_fxsr ? " -mfxsr" : " -mno-fxsr";
|
|
|
22033d |
const char *xsave = has_xsave ? " -mxsave" : " -mno-xsave";
|
|
|
22033d |
const char *xsaveopt = has_xsaveopt ? " -mxsaveopt" : " -mno-xsaveopt";
|
|
|
22033d |
+ const char *pku = has_pku ? " -mpku" : " -mno-pku";
|
|
|
22033d |
|
|
|
22033d |
options = concat (options, cx16, sahf, movbe, ase, pclmul,
|
|
|
22033d |
popcnt, abm, lwp, fma, fma4, xop, bmi, bmi2,
|
|
|
22033d |
tbm, avx, avx2, sse4_2, sse4_1, lzcnt, rtm,
|
|
|
22033d |
hle, rdrnd, f16c, fsgsbase, rdseed, prfchw, adx,
|
|
|
22033d |
- fxsr, xsave, xsaveopt, NULL);
|
|
|
22033d |
+ fxsr, xsave, xsaveopt, pku, NULL);
|
|
|
22033d |
}
|
|
|
22033d |
|
|
|
22033d |
done:
|
|
|
22033d |
--- gcc/config/i386/i386.c (revision 231943)
|
|
|
22033d |
+++ gcc/config/i386/i386.c (revision 231945)
|
|
|
22033d |
@@ -2632,6 +2632,7 @@ ix86_target_string (HOST_WIDE_INT isa, i
|
|
|
22033d |
{ "-mrtm", OPTION_MASK_ISA_RTM },
|
|
|
22033d |
{ "-mxsave", OPTION_MASK_ISA_XSAVE },
|
|
|
22033d |
{ "-mxsaveopt", OPTION_MASK_ISA_XSAVEOPT },
|
|
|
22033d |
+ { "-mpku", OPTION_MASK_ISA_PKU },
|
|
|
22033d |
};
|
|
|
22033d |
|
|
|
22033d |
/* Flag options. */
|
|
|
22033d |
@@ -2905,6 +2906,7 @@ ix86_option_override_internal (bool main
|
|
|
22033d |
#define PTA_FXSR (HOST_WIDE_INT_1 << 37)
|
|
|
22033d |
#define PTA_XSAVE (HOST_WIDE_INT_1 << 38)
|
|
|
22033d |
#define PTA_XSAVEOPT (HOST_WIDE_INT_1 << 39)
|
|
|
22033d |
+#define PTA_PKU (HOST_WIDE_INT_1 << 60)
|
|
|
22033d |
|
|
|
22033d |
/* if this reaches 64, need to widen struct pta flags below */
|
|
|
22033d |
|
|
|
22033d |
@@ -3429,6 +3431,9 @@ ix86_option_override_internal (bool main
|
|
|
22033d |
if (processor_alias_table[i].flags & PTA_XSAVEOPT
|
|
|
22033d |
&& !(ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVEOPT))
|
|
|
22033d |
ix86_isa_flags |= OPTION_MASK_ISA_XSAVEOPT;
|
|
|
22033d |
+ if (processor_alias_table[i].flags & PTA_PKU
|
|
|
22033d |
+ && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_PKU))
|
|
|
22033d |
+ ix86_isa_flags |= OPTION_MASK_ISA_PKU;
|
|
|
22033d |
if (processor_alias_table[i].flags & (PTA_PREFETCH_SSE | PTA_SSE))
|
|
|
22033d |
x86_prefetch_sse = true;
|
|
|
22033d |
|
|
|
22033d |
@@ -4220,6 +4225,7 @@ ix86_valid_target_attribute_inner_p (tre
|
|
|
22033d |
IX86_ATTR_ISA ("fxsr", OPT_mfxsr),
|
|
|
22033d |
IX86_ATTR_ISA ("xsave", OPT_mxsave),
|
|
|
22033d |
IX86_ATTR_ISA ("xsaveopt", OPT_mxsaveopt),
|
|
|
22033d |
+ IX86_ATTR_ISA ("pku", OPT_mpku),
|
|
|
22033d |
|
|
|
22033d |
/* enum options */
|
|
|
22033d |
IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_),
|
|
|
22033d |
@@ -27042,6 +27048,10 @@ enum ix86_builtins
|
|
|
22033d |
IX86_BUILTIN_CPU_IS,
|
|
|
22033d |
IX86_BUILTIN_CPU_SUPPORTS,
|
|
|
22033d |
|
|
|
22033d |
+ /* PKU instructions. */
|
|
|
22033d |
+ IX86_BUILTIN_RDPKRU,
|
|
|
22033d |
+ IX86_BUILTIN_WRPKRU,
|
|
|
22033d |
+
|
|
|
22033d |
IX86_BUILTIN_MAX
|
|
|
22033d |
};
|
|
|
22033d |
|
|
|
22033d |
@@ -27357,6 +27367,10 @@ static const struct builtin_description
|
|
|
22033d |
{ OPTION_MASK_ISA_RTM, CODE_FOR_xbegin, "__builtin_ia32_xbegin", IX86_BUILTIN_XBEGIN, UNKNOWN, (int) UNSIGNED_FTYPE_VOID },
|
|
|
22033d |
{ OPTION_MASK_ISA_RTM, CODE_FOR_xend, "__builtin_ia32_xend", IX86_BUILTIN_XEND, UNKNOWN, (int) VOID_FTYPE_VOID },
|
|
|
22033d |
{ OPTION_MASK_ISA_RTM, CODE_FOR_xtest, "__builtin_ia32_xtest", IX86_BUILTIN_XTEST, UNKNOWN, (int) INT_FTYPE_VOID },
|
|
|
22033d |
+
|
|
|
22033d |
+ /* RDPKRU and WRPKRU. */
|
|
|
22033d |
+ { OPTION_MASK_ISA_PKU, CODE_FOR_rdpkru, "__builtin_ia32_rdpkru", IX86_BUILTIN_RDPKRU, UNKNOWN, (int) UNSIGNED_FTYPE_VOID },
|
|
|
22033d |
+ { OPTION_MASK_ISA_PKU, CODE_FOR_wrpkru, "__builtin_ia32_wrpkru", IX86_BUILTIN_WRPKRU, UNKNOWN, (int) VOID_FTYPE_UNSIGNED },
|
|
|
22033d |
};
|
|
|
22033d |
|
|
|
22033d |
/* Builtins with variable number of arguments. */
|
|
|
22033d |
--- gcc/doc/extend.texi (revision 231943)
|
|
|
22033d |
+++ gcc/doc/extend.texi (revision 231945)
|
|
|
22033d |
@@ -10996,6 +10996,13 @@ void __builtin_ia32_xabort (status)
|
|
|
22033d |
int __builtin_ia32_xtest ()
|
|
|
22033d |
@end smallexample
|
|
|
22033d |
|
|
|
22033d |
+The following built-in functions are available when @option{-mpku} is used.
|
|
|
22033d |
+They generate reads and writes to PKRU.
|
|
|
22033d |
+@smallexample
|
|
|
22033d |
+void __builtin_ia32_wrpkru (unsigned int)
|
|
|
22033d |
+unsigned int __builtin_ia32_rdpkru ()
|
|
|
22033d |
+@end smallexample
|
|
|
22033d |
+
|
|
|
22033d |
@node X86 transactional memory intrinsics
|
|
|
22033d |
@subsection X86 transaction memory intrinsics
|
|
|
22033d |
|
|
|
22033d |
--- gcc/doc/invoke.texi (revision 231943)
|
|
|
22033d |
+++ gcc/doc/invoke.texi (revision 231945)
|
|
|
22033d |
@@ -645,7 +645,7 @@ Objective-C and Objective-C++ Dialects}.
|
|
|
22033d |
-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
|
|
|
22033d |
-mavx2 -maes -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma @gol
|
|
|
22033d |
-msse4a -m3dnow -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop -mlzcnt @gol
|
|
|
22033d |
--mbmi2 -mrtm -mlwp -mthreads @gol
|
|
|
22033d |
+-mbmi2 -mrtm -mlwp -mpku -mthreads @gol
|
|
|
22033d |
-mno-align-stringops -minline-all-stringops @gol
|
|
|
22033d |
-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
|
|
|
22033d |
-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
|
|
|
22033d |
@@ -14326,6 +14326,8 @@ preferred alignment to @option{-mpreferr
|
|
|
22033d |
@itemx -mlzcnt
|
|
|
22033d |
@itemx -mno-lzcnt
|
|
|
22033d |
@itemx -mrtm
|
|
|
22033d |
+@itemx -mpku
|
|
|
22033d |
+@itemx -mno-pku
|
|
|
22033d |
@itemx -mtbm
|
|
|
22033d |
@itemx -mno-tbm
|
|
|
22033d |
@opindex mmmx
|
|
|
22033d |
@@ -14336,7 +14338,7 @@ preferred alignment to @option{-mpreferr
|
|
|
22033d |
@opindex mno-3dnow
|
|
|
22033d |
These switches enable or disable the use of instructions in the MMX, SSE,
|
|
|
22033d |
SSE2, SSE3, SSSE3, SSE4.1, AVX, AVX2, AES, PCLMUL, FSGSBASE, RDRND, F16C,
|
|
|
22033d |
-FMA, SSE4A, FMA4, XOP, LWP, ABM, BMI, BMI2, LZCNT, RTM or 3DNow!@:
|
|
|
22033d |
+FMA, SSE4A, FMA4, XOP, LWP, ABM, BMI, BMI2, LZCNT, RTM, PKU or 3DNow!@:
|
|
|
22033d |
extended instruction sets.
|
|
|
22033d |
These extensions are also available as built-in functions: see
|
|
|
22033d |
@ref{X86 Built-in Functions}, for details of the functions enabled and
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/sse-12.c (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/sse-12.c (revision 231945)
|
|
|
22033d |
@@ -3,7 +3,7 @@
|
|
|
22033d |
popcntintrin.h and mm_malloc.h are usable
|
|
|
22033d |
with -O -std=c89 -pedantic-errors. */
|
|
|
22033d |
/* { dg-do compile } */
|
|
|
22033d |
-/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
|
|
|
22033d |
+/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
|
|
|
22033d |
|
|
|
22033d |
#include <x86intrin.h>
|
|
|
22033d |
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/sse-13.c (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/sse-13.c (revision 231945)
|
|
|
22033d |
@@ -1,5 +1,5 @@
|
|
|
22033d |
/* { dg-do compile } */
|
|
|
22033d |
-/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
|
|
|
22033d |
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
|
|
|
22033d |
|
|
|
22033d |
#include <mm_malloc.h>
|
|
|
22033d |
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/sse-22.c (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/sse-22.c (revision 231945)
|
|
|
22033d |
@@ -268,7 +268,7 @@ test_2 (_mm_clmulepi64_si128, __m128i, _
|
|
|
22033d |
|
|
|
22033d |
/* x86intrin.h (FMA4/XOP/LWP/BMI/BMI2/TBM/LZCNT/FMA). */
|
|
|
22033d |
#ifdef DIFFERENT_PRAGMAS
|
|
|
22033d |
-#pragma GCC target ("fma4,xop,lwp,bmi,bmi2,tbm,lzcnt,fma,rdseed,prfchw,adx,fxsr,xsaveopt")
|
|
|
22033d |
+#pragma GCC target ("fma4,xop,lwp,bmi,bmi2,tbm,lzcnt,fma,rdseed,prfchw,adx,fxsr,xsaveopt,pku")
|
|
|
22033d |
#endif
|
|
|
22033d |
#include <x86intrin.h>
|
|
|
22033d |
/* xopintrin.h */
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/sse-23.c (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/sse-23.c (revision 231945)
|
|
|
22033d |
@@ -183,7 +183,7 @@
|
|
|
22033d |
/* rtmintrin.h */
|
|
|
22033d |
#define __builtin_ia32_xabort(M) __builtin_ia32_xabort(1)
|
|
|
22033d |
|
|
|
22033d |
-#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c,fma,rtm,rdseed,prfchw,adx,fxsr,xsaveopt")
|
|
|
22033d |
+#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c,fma,rtm,rdseed,prfchw,adx,fxsr,xsaveopt,pku")
|
|
|
22033d |
#include <wmmintrin.h>
|
|
|
22033d |
#include <smmintrin.h>
|
|
|
22033d |
#include <mm3dnow.h>
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/rdpku-1.c (revision 0)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/rdpku-1.c (revision 231945)
|
|
|
22033d |
@@ -0,0 +1,11 @@
|
|
|
22033d |
+/* { dg-do compile } */
|
|
|
22033d |
+/* { dg-options "-mpku -O2" } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "rdpkru\n" } } */
|
|
|
22033d |
+
|
|
|
22033d |
+#include <x86intrin.h>
|
|
|
22033d |
+
|
|
|
22033d |
+unsigned extern
|
|
|
22033d |
+rdpku_test (void)
|
|
|
22033d |
+{
|
|
|
22033d |
+ return _rdpkru_u32 ();
|
|
|
22033d |
+}
|
|
|
22033d |
--- gcc/testsuite/gcc.target/i386/wrpku-1.c (revision 0)
|
|
|
22033d |
+++ gcc/testsuite/gcc.target/i386/wrpku-1.c (revision 231945)
|
|
|
22033d |
@@ -0,0 +1,11 @@
|
|
|
22033d |
+/* { dg-do compile } */
|
|
|
22033d |
+/* { dg-options "-mpku -O2" } */
|
|
|
22033d |
+/* { dg-final { scan-assembler "wrpkru\n" } } */
|
|
|
22033d |
+
|
|
|
22033d |
+#include <x86intrin.h>
|
|
|
22033d |
+
|
|
|
22033d |
+void extern
|
|
|
22033d |
+wrpku_test (unsigned int key)
|
|
|
22033d |
+{
|
|
|
22033d |
+ _wrpkru (key);
|
|
|
22033d |
+}
|
|
|
22033d |
--- gcc/testsuite/g++.dg/other/i386-2.C (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/g++.dg/other/i386-2.C (revision 231945)
|
|
|
22033d |
@@ -1,9 +1,9 @@
|
|
|
22033d |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
|
|
|
22033d |
-/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
|
|
|
22033d |
+/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
|
|
|
22033d |
|
|
|
22033d |
/* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h,
|
|
|
22033d |
xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h,
|
|
|
22033d |
- popcntintrin.h, fmaintrin.h and mm_malloc.h.h are usable with
|
|
|
22033d |
+ popcntintrin.h, fmaintrin.h, pkuintrin.h and mm_malloc.h.h are usable with
|
|
|
22033d |
-O -pedantic-errors. */
|
|
|
22033d |
|
|
|
22033d |
#include <x86intrin.h>
|
|
|
22033d |
--- gcc/testsuite/g++.dg/other/i386-3.C (revision 231943)
|
|
|
22033d |
+++ gcc/testsuite/g++.dg/other/i386-3.C (revision 231945)
|
|
|
22033d |
@@ -1,9 +1,9 @@
|
|
|
22033d |
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
|
|
|
22033d |
-/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt" } */
|
|
|
22033d |
+/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c -mfma -mrtm -mrdseed -mprfchw -madx -mfxsr -mxsaveopt -mpku" } */
|
|
|
22033d |
|
|
|
22033d |
/* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h,
|
|
|
22033d |
xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h,
|
|
|
22033d |
- popcntintrin.h, fmaintrin.h and mm_malloc.h are usable with
|
|
|
22033d |
+ popcntintrin.h, fmaintrin.h, pkuintrin.h and mm_malloc.h are usable with
|
|
|
22033d |
-O -fkeep-inline-functions. */
|
|
|
22033d |
|
|
|
22033d |
#include <x86intrin.h>
|