49#define DEBUG_TYPE "mips"
96 Ret +=
"-i8:8:32-i16:16:32-i64:64";
101 if (ABI.IsN64() || ABI.IsN32())
102 Ret +=
"-n32:64-S128";
110 std::optional<Reloc::Model> RM) {
124 std::optional<Reloc::Model> RM,
125 std::optional<CodeModel::Model> CM,
134 DefaultSubtarget(TT, CPU, FS, isLittle, *this,
std::nullopt),
135 NoMips16Subtarget(TT, CPU, FS.empty() ?
"-mips16" : FS.str() +
",-mips16",
136 isLittle, *this,
std::nullopt),
137 Mips16Subtarget(TT, CPU, FS.empty() ?
"+mips16" : FS.str() +
",+mips16",
138 isLittle, *this,
std::nullopt) {
139 Subtarget = &DefaultSubtarget;
148void MipsebTargetMachine::anchor() {}
153 std::optional<Reloc::Model> RM,
154 std::optional<CodeModel::Model> CM,
158void MipselTargetMachine::anchor() {}
163 std::optional<Reloc::Model> RM,
164 std::optional<CodeModel::Model> CM,
170 Attribute CPUAttr =
F.getFnAttribute(
"target-cpu");
171 Attribute FSAttr =
F.getFnAttribute(
"target-features");
177 bool hasMips16Attr =
F.getFnAttribute(
"mips16").isValid();
178 bool hasNoMips16Attr =
F.getFnAttribute(
"nomips16").isValid();
180 bool HasMicroMipsAttr =
F.getFnAttribute(
"micromips").isValid();
181 bool HasNoMicroMipsAttr =
F.getFnAttribute(
"nomicromips").isValid();
186 bool softFloat =
F.getFnAttribute(
"use-soft-float").getValueAsBool();
189 FS += FS.empty() ?
"+mips16" :
",+mips16";
190 else if (hasNoMips16Attr)
191 FS += FS.empty() ?
"-mips16" :
",-mips16";
192 if (HasMicroMipsAttr)
193 FS += FS.empty() ?
"+micromips" :
",+micromips";
194 else if (HasNoMicroMipsAttr)
195 FS += FS.empty() ?
"-micromips" :
",-micromips";
197 FS += FS.empty() ?
"+soft-float" :
",+soft-float";
199 auto &
I = SubtargetMap[CPU + FS];
205 I = std::make_unique<MipsSubtarget>(
207 MaybeAlign(
F.getParent()->getOverrideStackAlignment()));
229 EnableTailMerge = !getMipsSubtarget().enableLongBranchPass();
233 return getTM<MipsTargetMachine>();
237 return *getMipsTargetMachine().getSubtargetImpl();
240 void addIRPasses()
override;
241 bool addInstSelector()
override;
242 void addPreEmitPass()
override;
243 void addPreRegAlloc()
override;
244 bool addIRTranslator()
override;
245 void addPreLegalizeMachineIR()
override;
246 bool addLegalizeMachineIR()
override;
247 void addPreRegBankSelect()
override;
248 bool addRegBankSelect()
override;
249 bool addGlobalInstructionSelect()
override;
251 std::unique_ptr<CSEConfigBase> getCSEConfig()
const override;
257 return new MipsPassConfig(*
this, PM);
260std::unique_ptr<CSEConfigBase> MipsPassConfig::getCSEConfig()
const {
264void MipsPassConfig::addIRPasses() {
267 if (getMipsSubtarget().os16())
269 if (getMipsSubtarget().inMips16HardFloat())
274bool MipsPassConfig::addInstSelector() {
281void MipsPassConfig::addPreRegAlloc() {
300 return MipsFunctionInfo::create<MipsFunctionInfo>(
Allocator,
F,
STI);
305void MipsPassConfig::addPreEmitPass() {
335bool MipsPassConfig::addIRTranslator() {
340void MipsPassConfig::addPreLegalizeMachineIR() {
344bool MipsPassConfig::addLegalizeMachineIR() {
349void MipsPassConfig::addPreRegBankSelect() {
354bool MipsPassConfig::addRegBankSelect() {
359bool 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.
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.
This pass is responsible for selecting generic machine instructions to target-specific instructions.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
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,...