From 5eaada1e124bc4cc58e687b9b4b06a264380012a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 8 Feb 2017 05:45:46 +0000 Subject: [PATCH] [X86] Add test for clflushopt intrinsic and only enable it to be selected if the feature flag is set. llvm-svn: 294407 --- lib/Target/X86/X86InstrInfo.td | 2 ++ lib/Target/X86/X86Subtarget.h | 1 + test/CodeGen/X86/clflushopt.ll | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 test/CodeGen/X86/clflushopt.ll diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 7087fe9dcd8..7bdf2bd41b1 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -862,6 +862,7 @@ def HasMWAITX : Predicate<"Subtarget->hasMWAITX()">; def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">; def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">; def HasMPX : Predicate<"Subtarget->hasMPX()">; +def HasCLFLUSHOPT : Predicate<"Subtarget->hasCLFLUSHOPT()">; def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">; def Not64BitMode : Predicate<"!Subtarget->is64Bit()">, AssemblerPredicate<"!Mode64Bit", "Not 64-bit mode">; @@ -2529,6 +2530,7 @@ let Predicates = [HasTBM] in { // Memory Instructions // +let Predicates = [HasCLFLUSHOPT] in def CLFLUSHOPT : I<0xAE, MRM7m, (outs), (ins i8mem:$src), "clflushopt\t$src", [(int_x86_clflushopt addr:$src)]>, PD; def CLWB : I<0xAE, MRM6m, (outs), (ins i8mem:$src), "clwb\t$src", []>, PD; diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index f9ae5a4fc2d..633c7adda2f 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -487,6 +487,7 @@ public: bool hasVLX() const { return HasVLX; } bool hasPKU() const { return HasPKU; } bool hasMPX() const { return HasMPX; } + bool hasCLFLUSHOPT() const { return HasCLFLUSHOPT; } bool isXRaySupported() const override { return is64Bit(); } diff --git a/test/CodeGen/X86/clflushopt.ll b/test/CodeGen/X86/clflushopt.ll new file mode 100644 index 00000000000..ee416eb96c5 --- /dev/null +++ b/test/CodeGen/X86/clflushopt.ll @@ -0,0 +1,13 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=i686-apple-darwin -mattr=clflushopt | FileCheck %s + +define void @clflushopt(i8* %p) nounwind { +; CHECK-LABEL: clflushopt: +; CHECK: ## BB#0: +; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax +; CHECK-NEXT: clflushopt (%eax) +; CHECK-NEXT: retl + tail call void @llvm.x86.clflushopt(i8* %p) + ret void +} +declare void @llvm.x86.clflushopt(i8*) nounwind