@@ -193,6 +193,9 @@
UNSPEC_BNDCU
UNSPEC_BNDCN
UNSPEC_MPX_FENCE
+
+ ;; For RDPKRU support
+ UNSPEC_PKU
])
(define_c_enum "unspecv" [
@@ -268,6 +271,9 @@
;; For CLZERO support
UNSPECV_CLZERO
+ ;; For WRPKRU support
+ UNSPECV_PKU
+
])
;; Constants to represent rounding modes in the ROUND instruction
@@ -19287,6 +19293,47 @@
[(set_attr "type" "imov")
(set_attr "mode" "<MODE>")])
+(define_expand "rdpkru"
+ [(set (match_operand:SI 2 "register_operand") (const_int 0))
+ (parallel [(set (match_operand:SI 0 "register_operand")
+ (unspec:SI [(match_dup 2)] UNSPEC_PKU))
+ (clobber (match_operand:SI 1 "register_operand"))])]
+ "TARGET_PKU"
+{
+ operands[1] = gen_reg_rtx (SImode);
+ operands[2] = gen_reg_rtx (SImode);
+})
+
+(define_insn "*rdpkru_2"
+ [(set (match_operand:SI 0 "register_operand" "=a")
+ (unspec:SI [(match_operand:SI 2 "register_operand" "c")] UNSPEC_PKU))
+ (clobber (match_operand:SI 1 "register_operand" "=d"))]
+ "TARGET_PKU"
+ "rdpkru"
+ [(set_attr "type" "other")])
+
+(define_expand "wrpkru"
+ [(set (match_operand:SI 1 "register_operand")
+ (const_int 0))
+ (set (match_operand:SI 2 "register_operand")
+ (const_int 0))
+ (unspec_volatile:SI [(match_operand:SI 0 "register_operand")
+ (match_dup 1)
+ (match_dup 2)] UNSPECV_PKU)]
+ "TARGET_PKU"
+{
+ operands[1] = gen_reg_rtx (SImode);
+ operands[2] = gen_reg_rtx (SImode);
+})
+
+(define_insn "*wrpkru_2"
+ [(unspec_volatile:SI [(match_operand:SI 0 "register_operand" "a")
+ (match_operand:SI 1 "register_operand" "c")
+ (match_operand:SI 2 "register_operand" "d")] UNSPECV_PKU)]
+ "TARGET_PKU"
+ "wrpkru"
+ [(set_attr "type" "other")])
+
(include "mmx.md")
(include "sse.md")
(include "sync.md")