diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 | 
| commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
| tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp | |
| parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp | 41 | 
1 files changed, 40 insertions, 1 deletions
| diff --git a/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp index 1c13796e84b6..8f61feb6506d 100644 --- a/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp +++ b/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp @@ -11,10 +11,13 @@  //===----------------------------------------------------------------------===//  #include "CSKYTargetMachine.h" +#include "CSKY.h" +#include "CSKYSubtarget.h"  #include "TargetInfo/CSKYTargetInfo.h"  #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"  #include "llvm/CodeGen/TargetPassConfig.h" -#include "llvm/Support/TargetRegistry.h" +#include "llvm/CodeGen/TargetSubtargetInfo.h" +#include "llvm/MC/TargetRegistry.h"  using namespace llvm; @@ -50,6 +53,34 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT,    initAsmInfo();  } +const CSKYSubtarget * +CSKYTargetMachine::getSubtargetImpl(const Function &F) const { +  Attribute CPUAttr = F.getFnAttribute("target-cpu"); +  Attribute TuneAttr = F.getFnAttribute("tune-cpu"); +  Attribute FSAttr = F.getFnAttribute("target-features"); + +  std::string CPU = +      CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU; +  std::string TuneCPU = +      TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU; +  std::string FS = +      FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS; + +  std::string Key = CPU + TuneCPU + FS; +  auto &I = SubtargetMap[Key]; +  if (!I) { +    // This needs to be done before we create a new subtarget since any +    // creation will depend on the TM and the code generation flags on the +    // function that reside in TargetOptions. +    resetTargetOptions(F); +    I = std::make_unique<CSKYSubtarget>(TargetTriple, CPU, TuneCPU, FS, *this); +    if (I->useHardFloat() && !I->hasAnyFloatExt()) +      errs() << "Hard-float can't be used with current CPU," +                " set to Soft-float\n"; +  } +  return I.get(); +} +  namespace {  class CSKYPassConfig : public TargetPassConfig {  public: @@ -59,6 +90,8 @@ public:    CSKYTargetMachine &getCSKYTargetMachine() const {      return getTM<CSKYTargetMachine>();    } + +  bool addInstSelector() override;  };  } // namespace @@ -66,3 +99,9 @@ public:  TargetPassConfig *CSKYTargetMachine::createPassConfig(PassManagerBase &PM) {    return new CSKYPassConfig(*this, PM);  } + +bool CSKYPassConfig::addInstSelector() { +  addPass(createCSKYISelDag(getCSKYTargetMachine())); + +  return false; +} | 
