OSDN Git Service

[X86] Introduce LLVM wbinvd intrinsic
authorGabor Buella <gabor.buella@intel.com>
Thu, 12 Apr 2018 18:38:18 +0000 (18:38 +0000)
committerGabor Buella <gabor.buella@intel.com>
Thu, 12 Apr 2018 18:38:18 +0000 (18:38 +0000)
A previously missing intrinsic for an old instruction.

Reviewers: craig.topper, echristo

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D45312

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329936 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/IntrinsicsX86.td
lib/Target/X86/X86InstrSystem.td
test/CodeGen/X86/wbinvd-intrinsic.ll [new file with mode: 0644]

index 53285b1..3cbd053 100644 (file)
@@ -6403,10 +6403,14 @@ let TargetPrefix = "x86" in {
 }
 
 //===----------------------------------------------------------------------===//
-// Cache line write back intrinsics
+// Cache write back intrinsics
 
-// Write back no-invalidate
 let TargetPrefix = "x86" in {
+  // Write back and invalidate
+  def int_x86_wbinvd : GCCBuiltin<"__builtin_ia32_wbinvd">,
+      Intrinsic<[], [], []>;
+
+  // Write back no-invalidate
   def int_x86_wbnoinvd : GCCBuiltin<"__builtin_ia32_wbnoinvd">,
       Intrinsic<[], [], []>;
 }
index ecd871c..8e8d5b6 100644 (file)
@@ -442,7 +442,7 @@ let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
 // Cache instructions
 let SchedRW = [WriteSystem] in {
 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
-def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
+def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
 
 // wbnoinvd is like wbinvd, except without invalidation
 // encoding: like wbinvd + an 0xF3 prefix
diff --git a/test/CodeGen/X86/wbinvd-intrinsic.ll b/test/CodeGen/X86/wbinvd-intrinsic.ll
new file mode 100644 (file)
index 0000000..0bf28de
--- /dev/null
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=i686
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=x86_64
+
+define void @test_wbinvd() {
+; i686-LABEL: test_wbinvd:
+; i686:       # %bb.0:
+; i686-NEXT:    wbinvd
+; i686-NEXT:    retl
+;
+; x86_64-LABEL: test_wbinvd:
+; x86_64:       # %bb.0:
+; x86_64-NEXT:    wbinvd
+; x86_64-NEXT:    retq
+  call void @llvm.x86.wbinvd()
+  ret void
+}
+
+declare void @llvm.x86.wbinvd()