From 4b6eb0e63c698094db5506763df44cc83c19f643 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 20 Mar 2022 12:40:34 +0100 Subject: Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks (cherry picked from commit 349cc55c9796c4596a5b9904cd3281af295f878f) --- .../llvm/lib/Target/CSKY/CSKYTargetMachine.cpp | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'contrib/llvm-project/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp') 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(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(); } + + 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; +} -- cgit v1.2.3