48#define DEBUG_TYPE "mips"
71static std::unique_ptr<TargetLoweringObjectFile>
73 if (TT.isOSBinFormatCOFF())
74 return std::make_unique<TargetLoweringObjectFileCOFF>();
75 return std::make_unique<MipsTargetObjectFile>(UseSmallSection);
90 std::optional<Reloc::Model>
RM,
91 std::optional<CodeModel::Model> CM,
97 CLOpts(
cl::LibraryOptionsContext::
get<MipsOptions>(
98 Options.MCOptions.LibraryOptions)),
100 IsJIT(JIT), DefaultSubtarget(TT, CPU, FS,
Options.MCOptions.getABIName(),
101 isLittle, *this,
std::nullopt),
102 TLOF(
createTLOF(TT, DefaultSubtarget.useSmallSection())) {
111void MipsebTargetMachine::anchor() {}
116 std::optional<Reloc::Model>
RM,
117 std::optional<CodeModel::Model> CM,
121void MipselTargetMachine::anchor() {}
126 std::optional<Reloc::Model>
RM,
127 std::optional<CodeModel::Model> CM,
131void NanoMipsTargetMachine::anchor() {}
136 std::optional<Reloc::Model>
RM,
137 std::optional<CodeModel::Model> CM,
144 const Module *M =
F.getParent();
145 if (
const MipsSubtarget *ST = LastSubtarget.lookup(FnAttrs, M))
148 SubtargetAttrs Attrs;
154 Attrs.NoMicroMips = FnAttrs.
getAttribute(
"nomicromips");
155 Attrs.SoftFloat = FnAttrs.
getAttribute(
"use-soft-float");
158 if (
const MipsSubtarget *ST = LastSubtarget.lookup(FnAttrs, M, Attrs))
162 Attrs.CPU.isValid() ? Attrs.CPU.getValueAsString().str() :
TargetCPU;
164 Attrs.FS.isValid() ? Attrs.FS.getValueAsString().str() :
TargetFS;
165 bool hasMips16Attr = Attrs.Mips16.isValid();
166 bool hasNoMips16Attr = Attrs.NoMips16.isValid();
168 bool HasMicroMipsAttr = Attrs.MicroMips.isValid();
169 bool HasNoMicroMipsAttr = Attrs.NoMicroMips.isValid();
174 bool softFloat = Attrs.SoftFloat.getValueAsBool();
179 FS += FS.empty() ?
"+mips16" :
",+mips16";
180 else if (hasNoMips16Attr)
181 FS += FS.empty() ?
"-mips16" :
",-mips16";
182 if (HasMicroMipsAttr)
183 FS += FS.empty() ?
"+micromips" :
",+micromips";
184 else if (HasNoMicroMipsAttr)
185 FS += FS.empty() ?
"-micromips" :
",-micromips";
187 FS += FS.empty() ?
"+soft-float" :
",+soft-float";
189 auto &
I = SubtargetMap[CPU + FS + Attrs.ABIName.str()];
191 I = std::make_unique<MipsSubtarget>(
193 MaybeAlign(
F.getParent()->getOverrideStackAlignment()));
195 LastSubtarget.set(FnAttrs, M, Attrs,
I.get());
209 EnableTailMerge =
false;
210 EnableLoopTermFold =
true;
217 void addIRPasses()
override;
218 bool addInstSelector()
override;
219 void addPreEmitPass()
override;
220 void addPreRegAlloc()
override;
221 bool addIRTranslator()
override;
222 void addPreLegalizeMachineIR()
override;
223 bool addLegalizeMachineIR()
override;
224 void addPreRegBankSelect()
override;
225 bool addRegBankSelect()
override;
226 bool addGlobalInstructionSelect()
override;
228 std::unique_ptr<CSEConfigBase> getCSEConfig()
const override;
234 return new MipsPassConfig(*
this, PM);
237std::unique_ptr<CSEConfigBase> MipsPassConfig::getCSEConfig()
const {
241void MipsPassConfig::addIRPasses() {
244 if (getMipsTargetMachine().getCLOpts().os16)
250bool MipsPassConfig::addInstSelector() {
256void MipsPassConfig::addPreRegAlloc() {
274void MipsPassConfig::addPreEmitPass() {
284 if (getMipsTargetMachine().getCLOpts().mfix4300)
304bool MipsPassConfig::addIRTranslator() {
309void MipsPassConfig::addPreLegalizeMachineIR() {
313bool MipsPassConfig::addLegalizeMachineIR() {
318void MipsPassConfig::addPreRegBankSelect() {
323bool MipsPassConfig::addRegBankSelect() {
328bool MipsPassConfig::addGlobalInstructionSelect() {
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
static Reloc::Model getEffectiveRelocModel()
This file contains the simple types necessary to represent the attributes associated with functions a...
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
#define LLVM_EXTERNAL_VISIBILITY
This file declares the IRTranslator pass.
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget()
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
Target-Independent Code Generator Pass Configuration Options pass.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
This pass is responsible for selecting generic machine instructions to target-specific instructions.
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT, bool isLittle)
const MipsOptions & getCLOpts() const
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
~MipsTargetMachine() override
const MipsSubtarget * getSubtargetImpl(const Function &F) const override
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
A Module instance is used to store all the information related to an LLVM module.
NanoMipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
Represent a constant reference to a string, i.e.
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
const Triple & getTargetTriple() const
StringRef getTargetABIName(const Module &M) const
Returns the effective target ABI name: the "target-abi" module flag if present, otherwise the -target...
std::unique_ptr< const MCSubtargetInfo > STI
Target-Independent Code Generator Pass Configuration Options.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Registers T with cl::parseCommandLineOptions.
This namespace contains all of the command line option processing machinery.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createMipsPostLegalizeCombinerLegacyPass(bool IsOptNone)
FunctionPass * createMipsBranchExpansionLegacyPass()
FunctionPass * createMipsSEISelDAGLegacyPass(MipsTargetMachine &TM, CodeGenOptLevel OptLevel)
Target & getTheMips64Target()
void initializeMipsAsmPrinterPass(PassRegistry &)
void initializeMicroMipsSizeReduceLegacyPass(PassRegistry &)
FunctionPass * createMipsPreLegalizeCombinerLegacyPass()
void initializeMipsDelaySlotFillerLegacyPass(PassRegistry &)
void initializeMipsDAGToDAGISelLegacyPass(PassRegistry &)
Target & getTheNanoMipsTarget()
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
FunctionPass * createMipsExpandPseudoLegacyPass()
createMipsExpandPseudoPass - returns an instance of the pseudo instruction expansion pass.
void initializeMipsPostLegalizerCombinerLegacyPass(PassRegistry &)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
ModulePass * createMipsOs16LegacyPass()
FunctionPass * createMips16ISelDAGLegacyPass(MipsTargetMachine &TM, CodeGenOptLevel OptLevel)
void initializeMipsMulMulBugFixLegacyPass(PassRegistry &)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FunctionPass * createMipsOptimizePICCallLegacyPass()
Return an OptimizeCall object.
FunctionPass * createMipsConstantIslandLegacyPass()
Returns a pass that converts branches to long branches.
void initializeMipsPreLegalizerCombinerLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Target & getTheMips64elTarget()
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
ModulePass * createMips16HardFloatLegacyPass()
Target & getTheMipselTarget()
FunctionPass * createMipsDelaySlotFillerLegacyPass()
createMipsDelaySlotFillerPass - Returns a pass that fills in delay slots in Mips MachineFunctions
FunctionPass * createMicroMipsSizeReduceLegacyPass()
Returns an instance of the MicroMips size reduction pass.
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Target & getTheMipsTarget()
void initializeMipsBranchExpansionLegacyPass(PassRegistry &)
FunctionPass * createMipsMulMulBugFixLegacyPass()
Implement std::hash so that hash_code can be used in STL containers.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static FuncInfoTy * create(BumpPtrAllocator &Allocator, const Function &F, const SubtargetTy *STI)
Factory function: default behavior is to call new using the supplied allocator.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
RegisterTargetMachine - Helper template for registering a target machine implementation,...