mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 08:48:12 +00:00
[x86] Introduce the pconfig intrinsic
Reviewers: craig.topper, zvi Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D46431 llvm-svn: 331740
This commit is contained in:
parent
2b5e96004b
commit
b0f310d51d
@ -2674,6 +2674,8 @@ def mpku : Flag<["-"], "mpku">, Group<m_x86_Features_Group>;
|
||||
def mno_pku : Flag<["-"], "mno-pku">, Group<m_x86_Features_Group>;
|
||||
def mpclmul : Flag<["-"], "mpclmul">, Group<m_x86_Features_Group>;
|
||||
def mno_pclmul : Flag<["-"], "mno-pclmul">, Group<m_x86_Features_Group>;
|
||||
def mpconfig : Flag<["-"], "mpconfig">, Group<m_x86_Features_Group>;
|
||||
def mno_pconfig : Flag<["-"], "mno-pconfig">, Group<m_x86_Features_Group>;
|
||||
def mpopcnt : Flag<["-"], "mpopcnt">, Group<m_x86_Features_Group>;
|
||||
def mno_popcnt : Flag<["-"], "mno-popcnt">, Group<m_x86_Features_Group>;
|
||||
def mprefetchwt1 : Flag<["-"], "mprefetchwt1">, Group<m_x86_Features_Group>;
|
||||
|
@ -154,6 +154,7 @@ bool X86TargetInfo::initFeatureMap(
|
||||
break;
|
||||
|
||||
case CK_IcelakeServer:
|
||||
setFeatureEnabledImpl(Features, "pconfig", true);
|
||||
setFeatureEnabledImpl(Features, "wbnoinvd", true);
|
||||
LLVM_FALLTHROUGH;
|
||||
case CK_IcelakeClient:
|
||||
@ -827,6 +828,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
|
||||
HasMOVDIRI = true;
|
||||
} else if (Feature == "+movdir64b") {
|
||||
HasMOVDIR64B = true;
|
||||
} else if (Feature == "+pconfig") {
|
||||
HasPCONFIG = true;
|
||||
}
|
||||
|
||||
X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature)
|
||||
@ -1187,6 +1190,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||
Builder.defineMacro("__MOVDIRI__");
|
||||
if (HasMOVDIR64B)
|
||||
Builder.defineMacro("__MOVDIR64B__");
|
||||
if (HasPCONFIG)
|
||||
Builder.defineMacro("__PCONFIG__");
|
||||
|
||||
// Each case falls through to the previous one here.
|
||||
switch (SSELevel) {
|
||||
@ -1316,6 +1321,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
|
||||
.Case("mpx", true)
|
||||
.Case("mwaitx", true)
|
||||
.Case("pclmul", true)
|
||||
.Case("pconfig", true)
|
||||
.Case("pku", true)
|
||||
.Case("popcnt", true)
|
||||
.Case("prefetchwt1", true)
|
||||
@ -1394,6 +1400,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
|
||||
.Case("mpx", HasMPX)
|
||||
.Case("mwaitx", HasMWAITX)
|
||||
.Case("pclmul", HasPCLMUL)
|
||||
.Case("pconfig", HasPCONFIG)
|
||||
.Case("pku", HasPKU)
|
||||
.Case("popcnt", HasPOPCNT)
|
||||
.Case("prefetchwt1", HasPREFETCHWT1)
|
||||
|
@ -92,6 +92,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
|
||||
bool HasMWAITX = false;
|
||||
bool HasCLZERO = false;
|
||||
bool HasCLDEMOTE = false;
|
||||
bool HasPCONFIG = false;
|
||||
bool HasPKU = false;
|
||||
bool HasCLFLUSHOPT = false;
|
||||
bool HasCLWB = false;
|
||||
|
@ -73,6 +73,7 @@ set(files
|
||||
opencl-c.h
|
||||
pkuintrin.h
|
||||
pmmintrin.h
|
||||
pconfigintrin.h
|
||||
popcntintrin.h
|
||||
prfchwintrin.h
|
||||
rdseedintrin.h
|
||||
|
@ -194,6 +194,7 @@
|
||||
/* Features in %edx for leaf 7 sub-leaf 0 */
|
||||
#define bit_AVX5124VNNIW 0x00000004
|
||||
#define bit_AVX5124FMAPS 0x00000008
|
||||
#define bit_PCONFIG 0x00040000
|
||||
#define bit_IBT 0x00100000
|
||||
|
||||
/* Features in %eax for leaf 13 sub-leaf 1 */
|
||||
|
@ -67,6 +67,7 @@ module _Builtin_intrinsics [system] [extern_c] {
|
||||
textual header "cldemoteintrin.h"
|
||||
textual header "waitpkgintrin.h"
|
||||
textual header "movdirintrin.h"
|
||||
textual header "pconfigintrin.h"
|
||||
|
||||
explicit module mm_malloc {
|
||||
requires !freestanding
|
||||
|
50
clang/lib/Headers/pconfigintrin.h
Normal file
50
clang/lib/Headers/pconfigintrin.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*===---- pconfigintrin.h - X86 platform configuration ---------------------===
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*===-----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#ifndef __X86INTRIN_H
|
||||
#error "Never use <pconfigintrin.h> directly; include <x86intrin.h> instead."
|
||||
#endif
|
||||
|
||||
#ifndef __PCONFIGINTRIN_H
|
||||
#define __PCONFIGINTRIN_H
|
||||
|
||||
#define __PCONFIG_KEY_PROGRAM 0x00000001
|
||||
|
||||
/* Define the default attributes for the functions in this file. */
|
||||
#define __DEFAULT_FN_ATTRS \
|
||||
__attribute__((__always_inline__, __nodebug__, __target__("pconfig")))
|
||||
|
||||
static __inline unsigned int __DEFAULT_FN_ATTRS
|
||||
_pconfig_u32(unsigned int __leaf, __SIZE_TYPE__ __d[])
|
||||
{
|
||||
unsigned int __result;
|
||||
__asm__ ("pconfig"
|
||||
: "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
|
||||
: "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2])
|
||||
: "cc");
|
||||
return __result;
|
||||
}
|
||||
|
||||
#undef __DEFAULT_FN_ATTRS
|
||||
|
||||
#endif
|
@ -105,4 +105,8 @@
|
||||
#include <movdirintrin.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__)
|
||||
#include <pconfigintrin.h>
|
||||
#endif
|
||||
|
||||
#endif /* __X86INTRIN_H */
|
||||
|
@ -159,3 +159,8 @@
|
||||
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s
|
||||
// MOVDIR64B: "-target-feature" "+movdir64b"
|
||||
// NO-MOVDIR64B: "-target-feature" "-movdir64b"
|
||||
|
||||
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PCONFIG %s
|
||||
// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-PCONFIG %s
|
||||
// PCONFIG: "-target-feature" "+pconfig"
|
||||
// NO-PCONFIG: "-target-feature" "-pconfig"
|
||||
|
12
clang/test/Headers/pconfigintin.c
Normal file
12
clang/test/Headers/pconfigintin.c
Normal file
@ -0,0 +1,12 @@
|
||||
// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-64
|
||||
// RUN: %clang_cc1 %s -ffreestanding -triple i386 -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-32
|
||||
|
||||
#include <x86intrin.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
uint32_t test_pconfig(uint32_t leaf, size_t data[3]) {
|
||||
// CHECK-64: call { i32, i64, i64, i64 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
|
||||
// CHECK-32: call { i32, i32, i32, i32 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
|
||||
return _pconfig_u32(leaf, data);
|
||||
}
|
@ -1204,6 +1204,7 @@
|
||||
// CHECK_ICX_M32: #define __MMX__ 1
|
||||
// CHECK_ICX_M32: #define __MPX__ 1
|
||||
// CHECK_ICX_M32: #define __PCLMUL__ 1
|
||||
// CHECK_ICX_M32: #define __PCONFIG__ 1
|
||||
// CHECK_ICX_M32: #define __PKU__ 1
|
||||
// CHECK_ICX_M32: #define __POPCNT__ 1
|
||||
// CHECK_ICX_M32: #define __PRFCHW__ 1
|
||||
@ -1261,6 +1262,7 @@
|
||||
// CHECK_ICX_M64: #define __MMX__ 1
|
||||
// CHECK_ICX_M64: #define __MPX__ 1
|
||||
// CHECK_ICX_M64: #define __PCLMUL__ 1
|
||||
// CHECK_ICX_M64: #define __PCONFIG__ 1
|
||||
// CHECK_ICX_M64: #define __PKU__ 1
|
||||
// CHECK_ICX_M64: #define __POPCNT__ 1
|
||||
// CHECK_ICX_M64: #define __PRFCHW__ 1
|
||||
|
Loading…
Reference in New Issue
Block a user