48#define DEBUG_TYPE "mips"
73 return std::make_unique<MipsTargetObjectFile>();
99 Ret +=
"-i8:8:32-i16:16:32-i64:64";
104 if (ABI.IsN64() || ABI.IsN32())
105 Ret +=
"-i128:128-n32:64-S128";
113 std::optional<Reloc::Model> RM) {
127 std::optional<Reloc::Model> RM,
128 std::optional<CodeModel::Model> CM,
135 isLittle(isLittle), TLOF(
createTLOF(getTargetTriple())),
138 DefaultSubtarget(TT, CPU, FS, isLittle, *this,
std::nullopt),
139 NoMips16Subtarget(TT, CPU, FS.empty() ?
"-mips16" : FS.str() +
",-mips16",
140 isLittle, *this,
std::nullopt),
141 Mips16Subtarget(TT, CPU, FS.empty() ?
"+mips16" : FS.str() +
",+mips16",
142 isLittle, *this,
std::nullopt) {
143 Subtarget = &DefaultSubtarget;
152void MipsebTargetMachine::anchor() {}
157 std::optional<Reloc::Model> RM,
158 std::optional<CodeModel::Model> CM,
162void MipselTargetMachine::anchor() {}
167 std::optional<Reloc::Model> RM,
168 std::optional<CodeModel::Model> CM,
174 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
175 Attribute FSAttr =
F.getFnAttribute(
"target-features");
181 bool hasMips16Attr =
F.getFnAttribute(
"mips16").isValid();
182 bool hasNoMips16Attr =
F.getFnAttribute(
"nomips16").isValid();
184 bool HasMicroMipsAttr =
F.getFnAttribute(
"micromips").isValid();
185 bool HasNoMicroMipsAttr =
F.getFnAttribute(
"nomicromips").isValid();
190 bool softFloat =
F.getFnAttribute(
"use-soft-float").getValueAsBool();
193 FS += FS.empty() ?
"+mips16" :
",+mips16";
194 else if (hasNoMips16Attr)
195 FS += FS.empty() ?
"-mips16" :
",-mips16";
196 if (HasMicroMipsAttr)
197 FS += FS.empty() ?
"+micromips" :
",+micromips";
198 else if (HasNoMicroMipsAttr)
199 FS += FS.empty() ?
"-micromips" :
",-micromips";
201 FS += FS.empty() ?
"+soft-float" :
",+soft-float";
203 auto &
I = SubtargetMap[CPU + FS];
209 I = std::make_unique<MipsSubtarget>(
211 MaybeAlign(
F.getParent()->getOverrideStackAlignment()));
233 EnableTailMerge = !getMipsSubtarget().enableLongBranchPass();
237 return getTM<MipsTargetMachine>();
241 return *getMipsTargetMachine().getSubtargetImpl();
244 void addIRPasses()
override;
245 bool addInstSelector()
override;
246 void addPreEmitPass()
override;
247 void addPreRegAlloc()
override;
248 bool addIRTranslator()
override;
249 void addPreLegalizeMachineIR()
override;
250 bool addLegalizeMachineIR()
override;
251 void addPreRegBankSelect()
override;
252 bool addRegBankSelect()
override;
253 bool addGlobalInstructionSelect()
override;
255 std::unique_ptr<CSEConfigBase> getCSEConfig()
const override;
261 return new MipsPassConfig(*
this, PM);
264std::unique_ptr<CSEConfigBase> MipsPassConfig::getCSEConfig()
const {
268void MipsPassConfig::addIRPasses() {
271 if (getMipsSubtarget().os16())
273 if (getMipsSubtarget().inMips16HardFloat())
278bool MipsPassConfig::addInstSelector() {
285void MipsPassConfig::addPreRegAlloc() {
304 return MipsFunctionInfo::create<MipsFunctionInfo>(
Allocator,
F,
STI);
309void MipsPassConfig::addPreEmitPass() {
339bool MipsPassConfig::addIRTranslator() {
344void MipsPassConfig::addPreLegalizeMachineIR() {
348bool MipsPassConfig::addLegalizeMachineIR() {
353void MipsPassConfig::addPreRegBankSelect() {
358bool MipsPassConfig::addRegBankSelect() {
363bool MipsPassConfig::addGlobalInstructionSelect() {
static ARMBaseTargetMachine::ARMABI computeTargetABI(const Triple &TT, StringRef CPU, const TargetOptions &Options)
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Provides analysis for continuously CSEing during GISel passes.
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file declares the IRTranslator pass.
static std::string computeDataLayout()
static Reloc::Model getEffectiveRelocModel(bool JIT, std::optional< Reloc::Model > RM)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget()
static cl::opt< bool > EnableMulMulFix("mfix4300", cl::init(false), cl::desc("Enable the VR4300 mulmul bug fix."), cl::Hidden)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
Target-Independent Code Generator Pass Configuration Options pass.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Allocate memory in an ever growing pool, as if by bump-pointer.
implements a set of functionality in the TargetMachine class for targets that make use of the indepen...
This pass is responsible for selecting generic machine instructions to target-specific instructions.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static MipsABIInfo computeTargetABI(const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
bool allowMixed16_32() const
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)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
~MipsTargetMachine() override
void resetSubtarget(MachineFunction *MF)
Reset the subtarget for the Mips target.
const MipsSubtarget * getSubtargetImpl() const
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)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static 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.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
std::unique_ptr< const MCSubtargetInfo > STI
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
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 ...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheMips64Target()
FunctionPass * createMipsConstantIslandPass()
Returns a pass that converts branches to long branches.
void initializeMipsPreLegalizerCombinerPass(PassRegistry &)
void initializeMipsBranchExpansionPass(PassRegistry &)
void initializeMipsDelaySlotFillerPass(PassRegistry &)
void initializeMipsMulMulBugFixPass(PassRegistry &)
FunctionPass * createMipsOptimizePICCallPass()
Return an OptimizeCall object.
void initializeMipsDAGToDAGISelLegacyPass(PassRegistry &)
std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
FunctionPass * createMipsModuleISelDagPass()
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createMipsPreLegalizeCombiner()
void initializeMipsPostLegalizerCombinerPass(PassRegistry &)
FunctionPass * createMicroMipsSizeReducePass()
Returns an instance of the MicroMips size reduction pass.
FunctionPass * createMipsSEISelDag(MipsTargetMachine &TM, CodeGenOptLevel OptLevel)
CodeGenOptLevel
Code generation optimization level.
FunctionPass * createMipsBranchExpansion()
Target & getTheMips64elTarget()
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
FunctionPass * createMipsMulMulBugPass()
void initializeMicroMipsSizeReducePass(PassRegistry &)
void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
Target & getTheMipselTarget()
FunctionPass * createMips16ISelDag(MipsTargetMachine &TM, CodeGenOptLevel OptLevel)
ModulePass * createMips16HardFloatPass()
FunctionPass * createMipsExpandPseudoPass()
createMipsExpandPseudoPass - returns an instance of the pseudo instruction expansion pass.
FunctionPass * createMipsDelaySlotFillerPass()
createMipsDelaySlotFillerPass - Returns a pass that fills in delay slots in Mips MachineFunctions
FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
Target & getTheMipsTarget()
ModulePass * createMipsOs16Pass()
FunctionPass * createMipsPostLegalizeCombiner(bool IsOptNone)
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...
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,...