diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-06-11 18:16:27 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-06-11 18:16:27 +0000 | 
| commit | 687a64222b4c87c825258d4dfeb1f0794e8cb300 (patch) | |
| tree | f15e528223c9e06e4ed874e21ad41c2eb169030b /lib/Target/AVR | |
| parent | 24eadf6f46cd3637ffe867648ce8eca7314115c6 (diff) | |
vendor/llvm/llvm-release_801-r366581vendor/llvm/llvm-release_80-r364487vendor/llvm/llvm-release_80-r363030vendor/llvm-80
Diffstat (limited to 'lib/Target/AVR')
| -rw-r--r-- | lib/Target/AVR/AVRISelLowering.cpp | 28 | ||||
| -rw-r--r-- | lib/Target/AVR/AVRISelLowering.h | 8 | ||||
| -rw-r--r-- | lib/Target/AVR/AVRSubtarget.cpp | 12 | ||||
| -rw-r--r-- | lib/Target/AVR/AVRSubtarget.h | 5 | 
4 files changed, 38 insertions, 15 deletions
diff --git a/lib/Target/AVR/AVRISelLowering.cpp b/lib/Target/AVR/AVRISelLowering.cpp index 57fc978b54bb6..5db7577823226 100644 --- a/lib/Target/AVR/AVRISelLowering.cpp +++ b/lib/Target/AVR/AVRISelLowering.cpp @@ -26,19 +26,21 @@  #include "AVR.h"  #include "AVRMachineFunctionInfo.h" +#include "AVRSubtarget.h"  #include "AVRTargetMachine.h"  #include "MCTargetDesc/AVRMCTargetDesc.h"  namespace llvm { -AVRTargetLowering::AVRTargetLowering(AVRTargetMachine &tm) -    : TargetLowering(tm) { +AVRTargetLowering::AVRTargetLowering(const AVRTargetMachine &TM, +                                     const AVRSubtarget &STI) +    : TargetLowering(TM), Subtarget(STI) {    // Set up the register classes.    addRegisterClass(MVT::i8, &AVR::GPR8RegClass);    addRegisterClass(MVT::i16, &AVR::DREGSRegClass);    // Compute derived properties from the register classes. -  computeRegisterProperties(tm.getSubtargetImpl()->getRegisterInfo()); +  computeRegisterProperties(Subtarget.getRegisterInfo());    setBooleanContents(ZeroOrOneBooleanContent);    setBooleanVectorContents(ZeroOrOneBooleanContent); @@ -163,6 +165,13 @@ AVRTargetLowering::AVRTargetLowering(AVRTargetMachine &tm)    setOperationAction(ISD::SMUL_LOHI, MVT::i16, Expand);    setOperationAction(ISD::UMUL_LOHI, MVT::i16, Expand); +  // Expand multiplications to libcalls when there is +  // no hardware MUL. +  if (!Subtarget.supportsMultiplication()) { +    setOperationAction(ISD::SMUL_LOHI, MVT::i8, Expand); +    setOperationAction(ISD::UMUL_LOHI, MVT::i8, Expand); +  } +    for (MVT VT : MVT::integer_valuetypes()) {      setOperationAction(ISD::MULHS, VT, Expand);      setOperationAction(ISD::MULHU, VT, Expand); @@ -1271,7 +1280,7 @@ SDValue AVRTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,    // Add a register mask operand representing the call-preserved registers.    const AVRTargetMachine &TM = (const AVRTargetMachine &)getTargetMachine(); -  const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo(); +  const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();    const uint32_t *Mask =        TRI->getCallPreservedMask(DAG.getMachineFunction(), CallConv);    assert(Mask && "Missing call preserved mask for calling convention"); @@ -1434,7 +1443,7 @@ MachineBasicBlock *AVRTargetLowering::insertShift(MachineInstr &MI,    MachineFunction *F = BB->getParent();    MachineRegisterInfo &RI = F->getRegInfo();    const AVRTargetMachine &TM = (const AVRTargetMachine &)getTargetMachine(); -  const TargetInstrInfo &TII = *TM.getSubtargetImpl()->getInstrInfo(); +  const TargetInstrInfo &TII = *Subtarget.getInstrInfo();    DebugLoc dl = MI.getDebugLoc();    switch (MI.getOpcode()) { @@ -1575,7 +1584,7 @@ static bool isCopyMulResult(MachineBasicBlock::iterator const &I) {  MachineBasicBlock *AVRTargetLowering::insertMul(MachineInstr &MI,                                                  MachineBasicBlock *BB) const {    const AVRTargetMachine &TM = (const AVRTargetMachine &)getTargetMachine(); -  const TargetInstrInfo &TII = *TM.getSubtargetImpl()->getInstrInfo(); +  const TargetInstrInfo &TII = *Subtarget.getInstrInfo();    MachineBasicBlock::iterator I(MI);    ++I; // in any case insert *after* the mul instruction    if (isCopyMulResult(I)) @@ -1838,9 +1847,6 @@ std::pair<unsigned, const TargetRegisterClass *>  AVRTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,                                                  StringRef Constraint,                                                  MVT VT) const { -  auto STI = static_cast<const AVRTargetMachine &>(this->getTargetMachine()) -                 .getSubtargetImpl(); -    // We only support i8 and i16.    //    //:FIXME: remove this assert for now since it gets sometimes executed @@ -1884,8 +1890,8 @@ AVRTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,      }    } -  return TargetLowering::getRegForInlineAsmConstraint(STI->getRegisterInfo(), -                                                      Constraint, VT); +  return TargetLowering::getRegForInlineAsmConstraint( +      Subtarget.getRegisterInfo(), Constraint, VT);  }  void AVRTargetLowering::LowerAsmOperandForConstraint(SDValue Op, diff --git a/lib/Target/AVR/AVRISelLowering.h b/lib/Target/AVR/AVRISelLowering.h index c90c65c81f700..7d77dd8fb0188 100644 --- a/lib/Target/AVR/AVRISelLowering.h +++ b/lib/Target/AVR/AVRISelLowering.h @@ -64,12 +64,14 @@ enum NodeType {  } // end of namespace AVRISD +class AVRSubtarget;  class AVRTargetMachine;  /// Performs target lowering for the AVR.  class AVRTargetLowering : public TargetLowering {  public: -  explicit AVRTargetLowering(AVRTargetMachine &TM); +  explicit AVRTargetLowering(const AVRTargetMachine &TM, +                             const AVRSubtarget &STI);  public:    MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override { @@ -164,6 +166,10 @@ private:                            const SDLoc &dl, SelectionDAG &DAG,                            SmallVectorImpl<SDValue> &InVals) const; +protected: + +  const AVRSubtarget &Subtarget; +  private:    MachineBasicBlock *insertShift(MachineInstr &MI, MachineBasicBlock *BB) const;    MachineBasicBlock *insertMul(MachineInstr &MI, MachineBasicBlock *BB) const; diff --git a/lib/Target/AVR/AVRSubtarget.cpp b/lib/Target/AVR/AVRSubtarget.cpp index 556d69ec52341..c7c566270f432 100644 --- a/lib/Target/AVR/AVRSubtarget.cpp +++ b/lib/Target/AVR/AVRSubtarget.cpp @@ -29,9 +29,9 @@  namespace llvm {  AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU, -                           const std::string &FS, AVRTargetMachine &TM) +                           const std::string &FS, const AVRTargetMachine &TM)      : AVRGenSubtargetInfo(TT, CPU, FS), InstrInfo(), FrameLowering(), -      TLInfo(TM), TSInfo(), +      TLInfo(TM, initializeSubtargetDependencies(CPU, FS, TM)), TSInfo(),        // Subtarget features        m_hasSRAM(false), m_hasJMPCALL(false), m_hasIJMPCALL(false), @@ -44,4 +44,12 @@ AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU,    ParseSubtargetFeatures(CPU, FS);  } +AVRSubtarget & +AVRSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS, +                                              const TargetMachine &TM) { +  // Parse features string. +  ParseSubtargetFeatures(CPU, FS); +  return *this; +} +  } // end of namespace llvm diff --git a/lib/Target/AVR/AVRSubtarget.h b/lib/Target/AVR/AVRSubtarget.h index fa26738da1900..ba036d5e40616 100644 --- a/lib/Target/AVR/AVRSubtarget.h +++ b/lib/Target/AVR/AVRSubtarget.h @@ -37,7 +37,7 @@ public:    //! \param FS  The feature string.    //! \param TM  The target machine.    AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, -               AVRTargetMachine &TM); +               const AVRTargetMachine &TM);    const AVRInstrInfo *getInstrInfo() const override { return &InstrInfo; }    const TargetFrameLowering *getFrameLowering() const override { return &FrameLowering; } @@ -49,6 +49,9 @@ public:    /// \note Definition of function is auto generated by `tblgen`.    void ParseSubtargetFeatures(StringRef CPU, StringRef FS); +  AVRSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS, +                                                const TargetMachine &TM); +    // Subtarget feature getters.    // See AVR.td for details.    bool hasSRAM() const { return m_hasSRAM; }  | 
