diff options
Diffstat (limited to 'lib/Target/Sparc')
| -rw-r--r-- | lib/Target/Sparc/Sparc.td | 6 | ||||
| -rw-r--r-- | lib/Target/Sparc/SparcISelLowering.cpp | 13 | ||||
| -rw-r--r-- | lib/Target/Sparc/SparcInstrInfo.td | 3 | ||||
| -rw-r--r-- | lib/Target/Sparc/SparcSubtarget.cpp | 1 | ||||
| -rw-r--r-- | lib/Target/Sparc/SparcSubtarget.h | 2 | 
5 files changed, 24 insertions, 1 deletions
| diff --git a/lib/Target/Sparc/Sparc.td b/lib/Target/Sparc/Sparc.td index 11004c5a952fc..91cab00b2b651 100644 --- a/lib/Target/Sparc/Sparc.td +++ b/lib/Target/Sparc/Sparc.td @@ -20,6 +20,10 @@ include "llvm/Target/Target.td"  // SPARC Subtarget features.  // +def FeatureSoftMulDiv +  : SubtargetFeature<"soft-mul-div", "UseSoftMulDiv", "true", +                     "Use software emulation for integer multiply and divide">; +  def FeatureV9    : SubtargetFeature<"v9", "IsV9", "true",                       "Enable SPARC-V9 instructions">; @@ -75,7 +79,7 @@ class Proc<string Name, list<SubtargetFeature> Features>   : Processor<Name, NoItineraries, Features>;  def : Proc<"generic",         []>; -def : Proc<"v7",              []>; +def : Proc<"v7",              [FeatureSoftMulDiv]>;  def : Proc<"v8",              []>;  def : Proc<"supersparc",      []>;  def : Proc<"sparclite",       []>; diff --git a/lib/Target/Sparc/SparcISelLowering.cpp b/lib/Target/Sparc/SparcISelLowering.cpp index 9e7e3c6b705a9..6767a59a97571 100644 --- a/lib/Target/Sparc/SparcISelLowering.cpp +++ b/lib/Target/Sparc/SparcISelLowering.cpp @@ -1689,6 +1689,19 @@ SparcTargetLowering::SparcTargetLowering(const TargetMachine &TM,    setOperationAction(ISD::MULHS,     MVT::i32, Expand);    setOperationAction(ISD::MUL,       MVT::i32, Expand); +  if (Subtarget->useSoftMulDiv()) { +    // .umul works for both signed and unsigned +    setOperationAction(ISD::SMUL_LOHI, MVT::i32, Expand); +    setOperationAction(ISD::UMUL_LOHI, MVT::i32, Expand); +    setLibcallName(RTLIB::MUL_I32, ".umul"); + +    setOperationAction(ISD::SDIV, MVT::i32, Expand); +    setLibcallName(RTLIB::SDIV_I32, ".div"); + +    setOperationAction(ISD::UDIV, MVT::i32, Expand); +    setLibcallName(RTLIB::UDIV_I32, ".udiv"); +  } +    if (Subtarget->is64Bit()) {      setOperationAction(ISD::UMUL_LOHI, MVT::i64, Expand);      setOperationAction(ISD::SMUL_LOHI, MVT::i64, Expand); diff --git a/lib/Target/Sparc/SparcInstrInfo.td b/lib/Target/Sparc/SparcInstrInfo.td index ae45c8be67524..3194ad4aeb6b1 100644 --- a/lib/Target/Sparc/SparcInstrInfo.td +++ b/lib/Target/Sparc/SparcInstrInfo.td @@ -27,6 +27,9 @@ def Is32Bit : Predicate<"!Subtarget->is64Bit()">;  // True when generating 64-bit code. This also implies HasV9.  def Is64Bit : Predicate<"Subtarget->is64Bit()">; +def UseSoftMulDiv : Predicate<"Subtarget->useSoftMulDiv()">, +              AssemblerPredicate<"FeatureSoftMulDiv">; +  // HasV9 - This predicate is true when the target processor supports V9  // instructions.  Note that the machine may be running in 32-bit mode.  def HasV9   : Predicate<"Subtarget->isV9()">, diff --git a/lib/Target/Sparc/SparcSubtarget.cpp b/lib/Target/Sparc/SparcSubtarget.cpp index 43ddef3cc96e9..daac56add87ce 100644 --- a/lib/Target/Sparc/SparcSubtarget.cpp +++ b/lib/Target/Sparc/SparcSubtarget.cpp @@ -28,6 +28,7 @@ void SparcSubtarget::anchor() { }  SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,                                                                  StringRef FS) { +  UseSoftMulDiv = false;    IsV9 = false;    IsLeon = false;    V8DeprecatedInsts = false; diff --git a/lib/Target/Sparc/SparcSubtarget.h b/lib/Target/Sparc/SparcSubtarget.h index fa42da425ff2d..d18139984b87f 100644 --- a/lib/Target/Sparc/SparcSubtarget.h +++ b/lib/Target/Sparc/SparcSubtarget.h @@ -32,6 +32,7 @@ class StringRef;  class SparcSubtarget : public SparcGenSubtargetInfo {    Triple TargetTriple;    virtual void anchor(); +  bool UseSoftMulDiv;    bool IsV9;    bool IsLeon;    bool V8DeprecatedInsts; @@ -76,6 +77,7 @@ public:    bool enableMachineScheduler() const override; +  bool useSoftMulDiv() const { return UseSoftMulDiv; }    bool isV9() const { return IsV9; }    bool isLeon() const { return IsLeon; }    bool isVIS() const { return IsVIS; } | 
