]> granicus.if.org Git - clang/commitdiff
[X86] Introduce wbinvd intrinsic
authorGabor Buella <gabor.buella@intel.com>
Thu, 12 Apr 2018 18:42:02 +0000 (18:42 +0000)
committerGabor Buella <gabor.buella@intel.com>
Thu, 12 Apr 2018 18:42:02 +0000 (18:42 +0000)
A previously missing intrinsic for an old instruction.

Reviewers: craig.topper, echristo

Reviewed By: craig.topper

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

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

include/clang/Basic/BuiltinsX86.def
lib/Headers/ia32intrin.h
test/CodeGen/builtin-wbinvd.c [new file with mode: 0644]

index 6fa7e68be785ed62430bd1d748f00cb63513d65c..b4c3e2887be65c674a07dae8169f1734f4652b98 100644 (file)
@@ -679,7 +679,8 @@ TARGET_BUILTIN(__builtin_ia32_clflushopt, "vvC*", "", "clflushopt")
 //CLWB
 TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
 
-//WBNOINVD
+//WB[NO]INVD
+TARGET_BUILTIN(__builtin_ia32_wbinvd, "v", "", "")
 TARGET_BUILTIN(__builtin_ia32_wbnoinvd, "v", "", "wbnoinvd")
 
 // ADX
index 4928300103adc639cbc9976b36687a028431941d..38f51e5073bcd8f99bc1023a31498de08de12cb5 100644 (file)
@@ -70,4 +70,9 @@ __rdtscp(unsigned int *__A) {
 
 #define _rdpmc(A) __rdpmc(A)
 
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+_wbinvd(void) {
+  return __builtin_ia32_wbinvd();
+}
+
 #endif /* __IA32INTRIN_H */
diff --git a/test/CodeGen/builtin-wbinvd.c b/test/CodeGen/builtin-wbinvd.c
new file mode 100644 (file)
index 0000000..fe5ad58
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include <x86intrin.h>
+
+void test_wbinvd(void) {
+  //CHECK-LABEL: @test_wbinvd
+  //CHECK: call void @llvm.x86.wbinvd()
+  _wbinvd();
+}