1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[X86] Add SERIALIZE instruction.

Summary: For more details about this instruction, please refer to the latest ISE document: https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference

Reviewers: craig.topper, RKSimon, LuoYuanke

Reviewed By: craig.topper

Subscribers: mgorny, hiraditya, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77193
This commit is contained in:
WangTianQing 2020-04-02 16:15:34 +08:00 committed by Xiang1 Zhang
parent 0aa096f1ca
commit 9f322059fe
12 changed files with 70 additions and 0 deletions

View File

@ -4930,3 +4930,11 @@ let TargetPrefix = "x86" in {
def int_x86_enqcmds : GCCBuiltin<"__builtin_ia32_enqcmds">,
Intrinsic<[llvm_i8_ty], [llvm_ptr_ty, llvm_ptr_ty], []>;
}
//===----------------------------------------------------------------------===//
// SERIALIZE - Serialize instruction fetch and execution
let TargetPrefix = "x86" in {
def int_x86_serialize : GCCBuiltin<"__builtin_ia32_serialize">,
Intrinsic<[], [], []>;
}

View File

@ -1477,6 +1477,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) {
Features["movdir64b"] = HasLeaf7 && ((ECX >> 28) & 1);
Features["enqcmd"] = HasLeaf7 && ((ECX >> 29) & 1);
Features["serialize"] = HasLeaf7 && ((EDX >> 14) & 1);
// There are two CPUID leafs which information associated with the pconfig
// instruction:
// EAX=0x7, ECX=0x0 indicates the availability of the instruction (via the 18th

View File

@ -273,6 +273,8 @@ def FeatureWAITPKG : SubtargetFeature<"waitpkg", "HasWAITPKG", "true",
"Wait and pause enhancements">;
def FeatureENQCMD : SubtargetFeature<"enqcmd", "HasENQCMD", "true",
"Has ENQCMD instructions">;
def FeatureSERIALIZE : SubtargetFeature<"serialize", "HasSERIALIZE", "true",
"Has serialize instruction">;
// On some processors, instructions that implicitly take two memory operands are
// slow. In practice, this means that CALL, PUSH, and POP with memory operands
// should be avoided in favor of a MOV + register CALL/PUSH/POP.

View File

@ -955,6 +955,7 @@ def HasCmpxchg8b : Predicate<"Subtarget->hasCmpxchg8b()">;
def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">;
def HasPCONFIG : Predicate<"Subtarget->hasPCONFIG()">;
def HasENQCMD : Predicate<"Subtarget->hasENQCMD()">;
def HasSERIALIZE : Predicate<"Subtarget->hasSERIALIZE()">;
def Not64BitMode : Predicate<"!Subtarget->is64Bit()">,
AssemblerPredicate<(all_of (not Mode64Bit)), "Not 64-bit mode">;
def In64BitMode : Predicate<"Subtarget->is64Bit()">,
@ -2861,6 +2862,13 @@ let SchedRW = [WriteLoad] in {
def : InstAlias<"clzero\t{%eax|eax}", (CLZERO32r)>, Requires<[Not64BitMode]>;
def : InstAlias<"clzero\t{%rax|rax}", (CLZERO64r)>, Requires<[In64BitMode]>;
//===----------------------------------------------------------------------===//
// SERIALIZE Instruction
//
def SERIALIZE : I<0x01, MRM_E8, (outs), (ins), "serialize",
[(int_x86_serialize)]>, PS,
Requires<[HasSERIALIZE]>;
//===----------------------------------------------------------------------===//
// Pattern fragments to auto generate TBM instructions.
//===----------------------------------------------------------------------===//

View File

@ -397,6 +397,9 @@ protected:
/// Processor supports PCONFIG instruction
bool HasPCONFIG = false;
/// Processor supports SERIALIZE instruction
bool HasSERIALIZE = false;
/// Processor has a single uop BEXTR implementation.
bool HasFastBEXTR = false;
@ -706,6 +709,7 @@ public:
bool threewayBranchProfitable() const { return ThreewayBranchProfitable; }
bool hasINVPCID() const { return HasINVPCID; }
bool hasENQCMD() const { return HasENQCMD; }
bool hasSERIALIZE() const { return HasSERIALIZE; }
bool useRetpolineIndirectCalls() const { return UseRetpolineIndirectCalls; }
bool useRetpolineIndirectBranches() const {
return UseRetpolineIndirectBranches;

View File

@ -0,0 +1,26 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86_64
; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+serialize | FileCheck %s --check-prefix=X86
; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+serialize | FileCheck %s --check-prefix=X32
define void @test_serialize() {
; X86_64-LABEL: test_serialize:
; X86_64: # %bb.0: # %entry
; X86_64-NEXT: serialize
; X86_64-NEXT: retq
;
; X86-LABEL: test_serialize:
; X86: # %bb.0: # %entry
; X86-NEXT: serialize
; X86-NEXT: retl
;
; X32-LABEL: test_serialize:
; X32: # %bb.0: # %entry
; X32-NEXT: serialize
; X32-NEXT: retq
entry:
call void @llvm.x86.serialize()
ret void
}
declare void @llvm.x86.serialize()

View File

@ -836,3 +836,6 @@
# CHECK: enqcmds (%edi), %edi
0x67,0xf3,0x0f,0x38,0xf8,0x3f
# CHECK: serialize
0x0f 0x01 0xe8

View File

@ -943,3 +943,6 @@
# CHECK: enqcmds 8128(%bx,%di), %ax
0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f
# CHECK: serialize
0x0f 0x01 0xe8

View File

@ -691,3 +691,6 @@
# CHECK: enqcmds 485498096, %rax
0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c
# CHECK: serialize
0x0f 0x01 0xe8

View File

@ -1029,3 +1029,7 @@ enqcmd (%edi), %edi
// CHECK: enqcmds (%edi), %edi
// CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x3f]
enqcmds (%edi), %edi
// CHECK: serialize
// CHECK: encoding: [0x0f,0x01,0xe8]
serialize

View File

@ -10876,3 +10876,7 @@ enqcmds (%bx,%di), %di
// CHECK: enqcmds 8128(%bx,%di), %ax
// CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
enqcmds 8128(%bx,%di), %ax
// CHECK: serialize
// CHECK: encoding: [0x0f,0x01,0xe8]
serialize

View File

@ -1877,3 +1877,7 @@ enqcmds -8192(%rdx), %rbx
// CHECK: enqcmds 485498096, %rax
// CHECK: encoding: [0xf3,0x0f,0x38,0xf8,0x04,0x25,0xf0,0x1c,0xf0,0x1c]
enqcmds 485498096, %rax
// CHECK: serialize
// CHECK: encoding: [0x0f,0x01,0xe8]
serialize