Add PREFETCHW codegen support

- Add 'PRFCHW' feature defined in AVX2 ISA extension



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178040 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Liao 2013-03-26 17:47:11 +00:00
parent 30ebb962b6
commit 675eb3b9ac
6 changed files with 24 additions and 5 deletions

View File

@ -122,6 +122,8 @@ def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
"Support RTM instructions">; "Support RTM instructions">;
def FeatureADX : SubtargetFeature<"adx", "HasADX", "true", def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
"Support ADX instructions">; "Support ADX instructions">;
def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
"Support PRFCHW instructions">;
def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true", def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
"Use LEA for adjusting the stack pointer">; "Use LEA for adjusting the stack pointer">;
def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb", def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb",

View File

@ -84,13 +84,16 @@ defm PI2FD : I3DNow_conv_rm_int<0x0D, "pi2fd">;
defm PMULHRW : I3DNow_binop_rm_int<0xB7, "pmulhrw">; defm PMULHRW : I3DNow_binop_rm_int<0xB7, "pmulhrw">;
def FEMMS : I3DNow<0x0E, RawFrm, (outs), (ins), "femms", [(int_x86_mmx_femms)]>; def FEMMS : I3DNow<0x0E, RawFrm, (outs), (ins), "femms",
[(int_x86_mmx_femms)]>;
def PREFETCH : I3DNow<0x0D, MRM0m, (outs), (ins i32mem:$addr), def PREFETCH : I3DNow<0x0D, MRM0m, (outs), (ins i8mem:$addr),
"prefetch\t$addr", []>; "prefetch\t$addr",
[(prefetch addr:$addr, (i32 0), imm, (i32 1))]>;
def PREFETCHW : I3DNow<0x0D, MRM1m, (outs), (ins i16mem:$addr), def PREFETCHW : I<0x0D, MRM1m, (outs), (ins i8mem:$addr), "prefetchw\t$addr",
"prefetchw\t$addr", []>; [(prefetch addr:$addr, (i32 1), (i32 3), (i32 1))]>, TB,
Requires<[HasPrefetchW]>;
// "3DNowA" instructions // "3DNowA" instructions
defm PF2IW : I3DNow_conv_rm_int<0x1C, "pf2iw", "a">; defm PF2IW : I3DNow_conv_rm_int<0x1C, "pf2iw", "a">;

View File

@ -604,6 +604,8 @@ def HasBMI : Predicate<"Subtarget->hasBMI()">;
def HasBMI2 : Predicate<"Subtarget->hasBMI2()">; def HasBMI2 : Predicate<"Subtarget->hasBMI2()">;
def HasRTM : Predicate<"Subtarget->hasRTM()">; def HasRTM : Predicate<"Subtarget->hasRTM()">;
def HasADX : Predicate<"Subtarget->hasADX()">; def HasADX : Predicate<"Subtarget->hasADX()">;
def HasPRFCHW : Predicate<"Subtarget->hasPRFCHW()">;
def HasPrefetchW : Predicate<"Subtarget->has3DNow() || Subtarget->hasPRFCHW()">;
def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">; def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">; def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">; def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">;

View File

@ -283,6 +283,10 @@ void X86Subtarget::AutoDetectSubtargetFeatures() {
HasLZCNT = true; HasLZCNT = true;
ToggleFeature(X86::FeatureLZCNT); ToggleFeature(X86::FeatureLZCNT);
} }
if (IsIntel && ((ECX >> 8) & 0x1)) {
HasPRFCHW = true;
ToggleFeature(X86::FeaturePRFCHW);
}
if (IsAMD) { if (IsAMD) {
if ((ECX >> 6) & 0x1) { if ((ECX >> 6) & 0x1) {
HasSSE4A = true; HasSSE4A = true;
@ -440,6 +444,7 @@ void X86Subtarget::initializeEnvironment() {
HasBMI2 = false; HasBMI2 = false;
HasRTM = false; HasRTM = false;
HasADX = false; HasADX = false;
HasPRFCHW = false;
IsBTMemSlow = false; IsBTMemSlow = false;
IsUAMemFast = false; IsUAMemFast = false;
HasVectorUAMem = false; HasVectorUAMem = false;

View File

@ -124,6 +124,9 @@ protected:
/// HasADX - Processor has ADX instructions. /// HasADX - Processor has ADX instructions.
bool HasADX; bool HasADX;
/// HasPRFCHW - Processor has PRFCHW instructions.
bool HasPRFCHW;
/// IsBTMemSlow - True if BT (bit test) of memory instructions are slow. /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow.
bool IsBTMemSlow; bool IsBTMemSlow;
@ -254,6 +257,7 @@ public:
bool hasBMI2() const { return HasBMI2; } bool hasBMI2() const { return HasBMI2; }
bool hasRTM() const { return HasRTM; } bool hasRTM() const { return HasRTM; }
bool hasADX() const { return HasADX; } bool hasADX() const { return HasADX; }
bool hasPRFCHW() const { return HasPRFCHW; }
bool isBTMemSlow() const { return IsBTMemSlow; } bool isBTMemSlow() const { return IsBTMemSlow; }
bool isUnalignedMemAccessFast() const { return IsUAMemFast; } bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
bool hasVectorUAMem() const { return HasVectorUAMem; } bool hasVectorUAMem() const { return HasVectorUAMem; }

View File

@ -1,5 +1,6 @@
; RUN: llc < %s -march=x86 -mattr=+sse | FileCheck %s ; RUN: llc < %s -march=x86 -mattr=+sse | FileCheck %s
; RUN: llc < %s -march=x86 -mattr=+avx | FileCheck %s ; RUN: llc < %s -march=x86 -mattr=+avx | FileCheck %s
; RUN: llc < %s -march=x86 -mattr=+prfchw | FileCheck %s -check-prefix=PRFCHW
; rdar://10538297 ; rdar://10538297
@ -9,10 +10,12 @@ entry:
; CHECK: prefetcht1 ; CHECK: prefetcht1
; CHECK: prefetcht0 ; CHECK: prefetcht0
; CHECK: prefetchnta ; CHECK: prefetchnta
; PRFCHW: prefetchw
tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 1, i32 1 ) tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 1, i32 1 )
tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 2, i32 1 ) tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 2, i32 1 )
tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 3, i32 1 ) tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 3, i32 1 )
tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 0, i32 1 ) tail call void @llvm.prefetch( i8* %ptr, i32 0, i32 0, i32 1 )
tail call void @llvm.prefetch( i8* %ptr, i32 1, i32 3, i32 1 )
ret void ret void
} }