diff options
author | Chris Dewhurst <chris.dewhurst@lero.ie> | 2016-10-10 08:53:06 +0000 |
---|---|---|
committer | Chris Dewhurst <chris.dewhurst@lero.ie> | 2016-10-10 08:53:06 +0000 |
commit | 850131213f1cb52653f7ff092cf48a23e04bab24 (patch) | |
tree | f4d8657b3f5abf7ae3e103919c20d069e3b09236 /llvm/lib/Target/Sparc | |
parent | 30cd7341d07a94b78864355c64103d41bdbde910 (diff) | |
download | bcm5719-llvm-850131213f1cb52653f7ff092cf48a23e04bab24.tar.gz bcm5719-llvm-850131213f1cb52653f7ff092cf48a23e04bab24.zip |
This pass, fixing an erratum in some LEON 2 processors ensures that the SDIV instruction is not issued, but replaced by SDIVcc instead, which does not exhibit the error. Unit test included.
Differential Review: https://reviews.llvm.org/D24660
llvm-svn: 283727
Diffstat (limited to 'llvm/lib/Target/Sparc')
-rwxr-xr-x | llvm/lib/Target/Sparc/LeonFeatures.td | 8 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/Sparc.td | 2 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcSubtarget.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcSubtarget.h | 2 |
5 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Target/Sparc/LeonFeatures.td b/llvm/lib/Target/Sparc/LeonFeatures.td index e2282abbbdb..27d739b5a85 100755 --- a/llvm/lib/Target/Sparc/LeonFeatures.td +++ b/llvm/lib/Target/Sparc/LeonFeatures.td @@ -37,6 +37,14 @@ def LeonCASA : SubtargetFeature< "Enable CASA instruction for LEON3 and LEON4 processors" >; + +def ReplaceSDIV : SubtargetFeature< + "replacesdiv", + "PerformSDIVReplace", + "true", + "AT697E erratum fix: Do not emit SDIV, emit SDIVCC instead" +>; + def InsertNOPLoad: SubtargetFeature< "insertnopload", "InsertNOPLoad", diff --git a/llvm/lib/Target/Sparc/Sparc.td b/llvm/lib/Target/Sparc/Sparc.td index bdbdc1c6c1a..11004c5a952 100644 --- a/llvm/lib/Target/Sparc/Sparc.td +++ b/llvm/lib/Target/Sparc/Sparc.td @@ -110,7 +110,7 @@ def : Processor<"leon2", LEON2Itineraries, // LEON 2 FT (AT697E) // TO DO: Place-holder: Processor specific features will be added *very* soon here. def : Processor<"at697e", LEON2Itineraries, - [FeatureLeon, InsertNOPLoad]>; + [FeatureLeon, ReplaceSDIV, InsertNOPLoad]>; // LEON 2 FT (AT697F) // TO DO: Place-holder: Processor specific features will be added *very* soon here. diff --git a/llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp index a16cd32484a..c36e75d1b07 100644 --- a/llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -360,6 +360,12 @@ void SparcDAGToDAGISel::Select(SDNode *N) { // FIXME: Handle div by immediate. unsigned Opcode = N->getOpcode() == ISD::SDIV ? SP::SDIVrr : SP::UDIVrr; + // SDIV is a hardware erratum on some LEON2 processors. Replace it with SDIVcc here. + if (((SparcTargetMachine&)TM).getSubtargetImpl()->performSDIVReplace() + && + Opcode == SP::SDIVrr) { + Opcode = SP::SDIVCCrr; + } CurDAG->SelectNodeTo(N, Opcode, MVT::i32, DivLHS, DivRHS, TopPart); return; } diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.cpp b/llvm/lib/Target/Sparc/SparcSubtarget.cpp index 97d4aef3378..75ea4c7c8f5 100644 --- a/llvm/lib/Target/Sparc/SparcSubtarget.cpp +++ b/llvm/lib/Target/Sparc/SparcSubtarget.cpp @@ -39,6 +39,7 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU, // Leon features HasLeonCasa = false; HasUmacSmac = false; + PerformSDIVReplace = false; InsertNOPLoad = false; FixFSMULD = false; ReplaceFMULS = false; diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.h b/llvm/lib/Target/Sparc/SparcSubtarget.h index 9122f54f7c8..25dc4291c44 100644 --- a/llvm/lib/Target/Sparc/SparcSubtarget.h +++ b/llvm/lib/Target/Sparc/SparcSubtarget.h @@ -48,6 +48,7 @@ class SparcSubtarget : public SparcGenSubtargetInfo { bool FixFSMULD; bool ReplaceFMULS; bool FixAllFDIVSQRT; + bool PerformSDIVReplace; SparcInstrInfo InstrInfo; SparcTargetLowering TLInfo; @@ -86,6 +87,7 @@ public: // Leon options bool hasUmacSmac() const { return HasUmacSmac; } + bool performSDIVReplace() const { return PerformSDIVReplace; } bool hasLeonCasa() const { return HasLeonCasa; } bool insertNOPLoad() const { return InsertNOPLoad; } bool fixFSMULD() const { return FixFSMULD; } |