From 22bb8f5964256f220b9cfdeb48e58964580ed6d5 Mon Sep 17 00:00:00 2001 From: Asaf Badouh Date: Tue, 15 Dec 2015 13:35:29 +0000 Subject: [PATCH] [x86] adding PKU feature flag the feature flag is essential for RDPKRU and WRPKRU instruction more about the instruction can be found in the SDM rev 56, vol 2 from http://www.intel.com/sdm Differential Revision: http://reviews.llvm.org/D15491 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255644 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Host.cpp | 2 ++ lib/Target/X86/X86.td | 3 +++ lib/Target/X86/X86InstrInfo.td | 1 + lib/Target/X86/X86Subtarget.cpp | 1 + lib/Target/X86/X86Subtarget.h | 4 ++++ 5 files changed, 11 insertions(+) diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index d7c9947b02d..c0f9e0744b5 100644 --- a/lib/Support/Host.cpp +++ b/lib/Support/Host.cpp @@ -812,6 +812,8 @@ bool sys::getHostCPUFeatures(StringMap &Features) { Features["rdseed"] = HasLeaf7 && ((EBX >> 18) & 1); Features["adx"] = HasLeaf7 && ((EBX >> 19) & 1); Features["sha"] = HasLeaf7 && ((EBX >> 29) & 1); + // Enable protection keys + Features["pku"] = HasLeaf7 && ((ECX >> 4) & 1); // AVX512 is only supported if the OS supports the context save for it. Features["avx512f"] = HasLeaf7 && ((EBX >> 16) & 1) && HasAVX512Save; diff --git a/lib/Target/X86/X86.td b/lib/Target/X86/X86.td index 7fc4def15fe..d2055adc99d 100644 --- a/lib/Target/X86/X86.td +++ b/lib/Target/X86/X86.td @@ -134,6 +134,8 @@ def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true", def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true", "Enable AVX-512 Vector Length eXtensions", [FeatureAVX512]>; +def FeaturePKU : SubtargetFeature<"pku", "HasPKU", "true", + "Enable protection keys">; def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true", "Enable packed carry-less multiplication instructions", [FeatureSSE2]>; @@ -491,6 +493,7 @@ class SkylakeProc : ProcessorModelhasVLX()">, def NoVLX : Predicate<"!Subtarget->hasVLX()">; def NoVLX_Or_NoBWI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasBWI()">; def NoVLX_Or_NoDQI : Predicate<"!Subtarget->hasVLX() || !Subtarget->hasDQI()">; +def PKU : Predicate<"!Subtarget->hasPKU()">; def HasPOPCNT : Predicate<"Subtarget->hasPOPCNT()">; def HasAES : Predicate<"Subtarget->hasAES()">; diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index f90a0b0d04f..8ef08c960f0 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -270,6 +270,7 @@ void X86Subtarget::initializeEnvironment() { HasBWI = false; HasVLX = false; HasADX = false; + HasPKU = false; HasSHA = false; HasPRFCHW = false; HasRDSEED = false; diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 83bc640976a..13d1026dcaa 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -223,6 +223,9 @@ protected: /// Processor has AVX-512 Vector Length eXtenstions bool HasVLX; + /// Processor has PKU extenstions + bool HasPKU; + /// Processot supports MPX - Memory Protection Extensions bool HasMPX; @@ -398,6 +401,7 @@ public: bool hasDQI() const { return HasDQI; } bool hasBWI() const { return HasBWI; } bool hasVLX() const { return HasVLX; } + bool hasPKU() const { return HasPKU; } bool hasMPX() const { return HasMPX; } bool isAtom() const { return X86ProcFamily == IntelAtom; } -- 2.34.1