003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Target/Mips
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Target
/
Mips
/
📁
..
📁
AsmParser
📁
Disassembler
📁
MCTargetDesc
📄
MSA.txt
(3.64 KB)
📄
MicroMips32r6InstrFormats.td
(20.42 KB)
📄
MicroMips32r6InstrInfo.td
(86.7 KB)
📄
MicroMipsDSPInstrFormats.td
(6.55 KB)
📄
MicroMipsDSPInstrInfo.td
(33.92 KB)
📄
MicroMipsInstrFPU.td
(20.28 KB)
📄
MicroMipsInstrFormats.td
(19.75 KB)
📄
MicroMipsInstrInfo.td
(63.12 KB)
📄
MicroMipsSizeReduction.cpp
(26.44 KB)
📄
Mips.h
(1.85 KB)
📄
Mips.td
(13.99 KB)
📄
Mips16FrameLowering.cpp
(6.34 KB)
📄
Mips16FrameLowering.h
(1.73 KB)
📄
Mips16HardFloat.cpp
(15.87 KB)
📄
Mips16HardFloatInfo.cpp
(1.45 KB)
📄
Mips16HardFloatInfo.h
(1.33 KB)
📄
Mips16ISelDAGToDAG.cpp
(7.33 KB)
📄
Mips16ISelDAGToDAG.h
(1.8 KB)
📄
Mips16ISelLowering.cpp
(29.05 KB)
📄
Mips16ISelLowering.h
(3.29 KB)
📄
Mips16InstrFormats.td
(16.29 KB)
📄
Mips16InstrInfo.cpp
(17.93 KB)
📄
Mips16InstrInfo.h
(5.33 KB)
📄
Mips16InstrInfo.td
(51.26 KB)
📄
Mips16RegisterInfo.cpp
(4.81 KB)
📄
Mips16RegisterInfo.h
(1.56 KB)
📄
Mips32r6InstrFormats.td
(14.85 KB)
📄
Mips32r6InstrInfo.td
(47.55 KB)
📄
Mips64InstrInfo.td
(58.62 KB)
📄
Mips64r6InstrInfo.td
(15.93 KB)
📄
MipsAnalyzeImmediate.cpp
(4.62 KB)
📄
MipsAnalyzeImmediate.h
(2.24 KB)
📄
MipsAsmPrinter.cpp
(43.89 KB)
📄
MipsAsmPrinter.h
(6.04 KB)
📄
MipsBranchExpansion.cpp
(29.72 KB)
📄
MipsCCState.cpp
(6.71 KB)
📄
MipsCCState.h
(6.14 KB)
📄
MipsCallLowering.cpp
(23.62 KB)
📄
MipsCallLowering.h
(3.35 KB)
📄
MipsCallingConv.td
(17.55 KB)
📄
MipsCondMov.td
(14.56 KB)
📄
MipsConstantIslandPass.cpp
(62.17 KB)
📄
MipsDSPInstrFormats.td
(7.39 KB)
📄
MipsDSPInstrInfo.td
(68.68 KB)
📄
MipsDelaySlotFiller.cpp
(32.55 KB)
📄
MipsEVAInstrFormats.td
(2.51 KB)
📄
MipsEVAInstrInfo.td
(8.52 KB)
📄
MipsExpandPseudo.cpp
(30.1 KB)
📄
MipsFastISel.cpp
(66.8 KB)
📄
MipsFrameLowering.cpp
(5.75 KB)
📄
MipsFrameLowering.h
(1.74 KB)
📄
MipsISelDAGToDAG.cpp
(10.22 KB)
📄
MipsISelDAGToDAG.h
(6.13 KB)
📄
MipsISelLowering.cpp
(192.31 KB)
📄
MipsISelLowering.h
(27.02 KB)
📄
MipsInstrFPU.td
(44.82 KB)
📄
MipsInstrFormats.td
(19.73 KB)
📄
MipsInstrInfo.cpp
(28.1 KB)
📄
MipsInstrInfo.h
(7.87 KB)
📄
MipsInstrInfo.td
(138.02 KB)
📄
MipsInstructionSelector.cpp
(34.44 KB)
📄
MipsLegalizerInfo.cpp
(21.07 KB)
📄
MipsLegalizerInfo.h
(1.19 KB)
📄
MipsMCInstLower.cpp
(9.68 KB)
📄
MipsMCInstLower.h
(1.77 KB)
📄
MipsMSAInstrFormats.td
(9.18 KB)
📄
MipsMSAInstrInfo.td
(182.92 KB)
📄
MipsMTInstrFormats.td
(2.44 KB)
📄
MipsMTInstrInfo.td
(7.59 KB)
📄
MipsMachineFunction.cpp
(7.22 KB)
📄
MipsMachineFunction.h
(4.37 KB)
📄
MipsModuleISelDAGToDAG.cpp
(1.67 KB)
📄
MipsOptimizePICCall.cpp
(9.78 KB)
📄
MipsOptionRecord.h
(2.9 KB)
📄
MipsOs16.cpp
(4.18 KB)
📄
MipsPfmCounters.td
(706 B)
📄
MipsPreLegalizerCombiner.cpp
(3.93 KB)
📄
MipsRegisterBankInfo.cpp
(26.01 KB)
📄
MipsRegisterBankInfo.h
(9.13 KB)
📄
MipsRegisterBanks.td
(573 B)
📄
MipsRegisterInfo.cpp
(10.41 KB)
📄
MipsRegisterInfo.h
(2.82 KB)
📄
MipsRegisterInfo.td
(23.18 KB)
📄
MipsSEFrameLowering.cpp
(34.47 KB)
📄
MipsSEFrameLowering.h
(1.88 KB)
📄
MipsSEISelDAGToDAG.cpp
(49.41 KB)
📄
MipsSEISelDAGToDAG.h
(5.92 KB)
📄
MipsSEISelLowering.cpp
(140.76 KB)
📄
MipsSEISelLowering.h
(6.25 KB)
📄
MipsSEInstrInfo.cpp
(34.71 KB)
📄
MipsSEInstrInfo.h
(5.34 KB)
📄
MipsSERegisterInfo.cpp
(8.44 KB)
📄
MipsSERegisterInfo.h
(1.2 KB)
📄
MipsSchedule.td
(38.24 KB)
📄
MipsScheduleGeneric.td
(71.71 KB)
📄
MipsScheduleP5600.td
(27.85 KB)
📄
MipsSubtarget.cpp
(10.72 KB)
📄
MipsSubtarget.h
(13.43 KB)
📄
MipsTargetMachine.cpp
(12.66 KB)
📄
MipsTargetMachine.h
(3.08 KB)
📄
MipsTargetObjectFile.cpp
(7.39 KB)
📄
MipsTargetObjectFile.h
(2.02 KB)
📄
MipsTargetStreamer.h
(14.58 KB)
📄
Relocation.txt
(3.91 KB)
📁
TargetInfo
Editing: MipsTargetMachine.cpp
//===-- MipsTargetMachine.cpp - Define TargetMachine for Mips -------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Implements the info about Mips target spec. // //===----------------------------------------------------------------------===// #include "MipsTargetMachine.h" #include "MCTargetDesc/MipsABIInfo.h" #include "MCTargetDesc/MipsMCTargetDesc.h" #include "Mips.h" #include "Mips16ISelDAGToDAG.h" #include "MipsSEISelDAGToDAG.h" #include "MipsSubtarget.h" #include "MipsTargetObjectFile.h" #include "TargetInfo/MipsTargetInfo.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/BasicTTIImpl.h" #include "llvm/CodeGen/GlobalISel/IRTranslator.h" #include "llvm/CodeGen/GlobalISel/InstructionSelect.h" #include "llvm/CodeGen/GlobalISel/Legalizer.h" #include "llvm/CodeGen/GlobalISel/RegBankSelect.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Function.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Debug.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetOptions.h" #include <string> using namespace llvm; #define DEBUG_TYPE "mips" extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget() { // Register the target. RegisterTargetMachine<MipsebTargetMachine> X(getTheMipsTarget()); RegisterTargetMachine<MipselTargetMachine> Y(getTheMipselTarget()); RegisterTargetMachine<MipsebTargetMachine> A(getTheMips64Target()); RegisterTargetMachine<MipselTargetMachine> B(getTheMips64elTarget()); PassRegistry *PR = PassRegistry::getPassRegistry(); initializeGlobalISel(*PR); initializeMipsDelaySlotFillerPass(*PR); initializeMipsBranchExpansionPass(*PR); initializeMicroMipsSizeReducePass(*PR); initializeMipsPreLegalizerCombinerPass(*PR); } static std::string computeDataLayout(const Triple &TT, StringRef CPU, const TargetOptions &Options, bool isLittle) { std::string Ret; MipsABIInfo ABI = MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions); // There are both little and big endian mips. if (isLittle) Ret += "e"; else Ret += "E"; if (ABI.IsO32()) Ret += "-m:m"; else Ret += "-m:e"; // Pointers are 32 bit on some ABIs. if (!ABI.IsN64()) Ret += "-p:32:32"; // 8 and 16 bit integers only need to have natural alignment, but try to // align them to 32 bits. 64 bit integers have natural alignment. Ret += "-i8:8:32-i16:16:32-i64:64"; // 32 bit registers are always available and the stack is at least 64 bit // aligned. On N64 64 bit registers are also available and the stack is // 128 bit aligned. if (ABI.IsN64() || ABI.IsN32()) Ret += "-n32:64-S128"; else Ret += "-n32-S64"; return Ret; } static Reloc::Model getEffectiveRelocModel(bool JIT, Optional<Reloc::Model> RM) { if (!RM.hasValue() || JIT) return Reloc::Static; return *RM; } // On function prologue, the stack is created by decrementing // its pointer. Once decremented, all references are done with positive // offset from the stack/frame pointer, using StackGrowsUp enables // an easier handling. // Using CodeModel::Large enables different CALL behavior. MipsTargetMachine::MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT, bool isLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT, CPU, FS, Options, getEffectiveRelocModel(JIT, RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), isLittle(isLittle), TLOF(std::make_unique<MipsTargetObjectFile>()), ABI(MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions)), Subtarget(nullptr), DefaultSubtarget(TT, CPU, FS, isLittle, *this, MaybeAlign(Options.StackAlignmentOverride)), NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16", isLittle, *this, MaybeAlign(Options.StackAlignmentOverride)), Mips16Subtarget(TT, CPU, FS.empty() ? "+mips16" : FS.str() + ",+mips16", isLittle, *this, MaybeAlign(Options.StackAlignmentOverride)) { Subtarget = &DefaultSubtarget; initAsmInfo(); // Mips supports the debug entry values. setSupportsDebugEntryValues(true); } MipsTargetMachine::~MipsTargetMachine() = default; void MipsebTargetMachine::anchor() {} MipsebTargetMachine::MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} void MipselTargetMachine::anchor() {} MipselTargetMachine::MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} const MipsSubtarget * MipsTargetMachine::getSubtargetImpl(const Function &F) const { Attribute CPUAttr = F.getFnAttribute("target-cpu"); Attribute FSAttr = F.getFnAttribute("target-features"); std::string CPU = !CPUAttr.hasAttribute(Attribute::None) ? CPUAttr.getValueAsString().str() : TargetCPU; std::string FS = !FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString().str() : TargetFS; bool hasMips16Attr = !F.getFnAttribute("mips16").hasAttribute(Attribute::None); bool hasNoMips16Attr = !F.getFnAttribute("nomips16").hasAttribute(Attribute::None); bool HasMicroMipsAttr = !F.getFnAttribute("micromips").hasAttribute(Attribute::None); bool HasNoMicroMipsAttr = !F.getFnAttribute("nomicromips").hasAttribute(Attribute::None); // FIXME: This is related to the code below to reset the target options, // we need to know whether or not the soft float flag is set on the // function, so we can enable it as a subtarget feature. bool softFloat = F.hasFnAttribute("use-soft-float") && F.getFnAttribute("use-soft-float").getValueAsString() == "true"; if (hasMips16Attr) FS += FS.empty() ? "+mips16" : ",+mips16"; else if (hasNoMips16Attr) FS += FS.empty() ? "-mips16" : ",-mips16"; if (HasMicroMipsAttr) FS += FS.empty() ? "+micromips" : ",+micromips"; else if (HasNoMicroMipsAttr) FS += FS.empty() ? "-micromips" : ",-micromips"; if (softFloat) FS += FS.empty() ? "+soft-float" : ",+soft-float"; auto &I = SubtargetMap[CPU + FS]; 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<MipsSubtarget>( TargetTriple, CPU, FS, isLittle, *this, MaybeAlign(Options.StackAlignmentOverride)); } return I.get(); } void MipsTargetMachine::resetSubtarget(MachineFunction *MF) { LLVM_DEBUG(dbgs() << "resetSubtarget\n"); Subtarget = &MF->getSubtarget<MipsSubtarget>(); } namespace { /// Mips Code Generator Pass Configuration Options. class MipsPassConfig : public TargetPassConfig { public: MipsPassConfig(MipsTargetMachine &TM, PassManagerBase &PM) : TargetPassConfig(TM, PM) { // The current implementation of long branch pass requires a scratch // register ($at) to be available before branch instructions. Tail merging // can break this requirement, so disable it when long branch pass is // enabled. EnableTailMerge = !getMipsSubtarget().enableLongBranchPass(); } MipsTargetMachine &getMipsTargetMachine() const { return getTM<MipsTargetMachine>(); } const MipsSubtarget &getMipsSubtarget() const { return *getMipsTargetMachine().getSubtargetImpl(); } void addIRPasses() override; bool addInstSelector() override; void addPreEmitPass() override; void addPreRegAlloc() override; bool addIRTranslator() override; void addPreLegalizeMachineIR() override; bool addLegalizeMachineIR() override; bool addRegBankSelect() override; bool addGlobalInstructionSelect() override; std::unique_ptr<CSEConfigBase> getCSEConfig() const override; }; } // end anonymous namespace TargetPassConfig *MipsTargetMachine::createPassConfig(PassManagerBase &PM) { return new MipsPassConfig(*this, PM); } std::unique_ptr<CSEConfigBase> MipsPassConfig::getCSEConfig() const { return getStandardCSEConfigForOpt(TM->getOptLevel()); } void MipsPassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); addPass(createAtomicExpandPass()); if (getMipsSubtarget().os16()) addPass(createMipsOs16Pass()); if (getMipsSubtarget().inMips16HardFloat()) addPass(createMips16HardFloatPass()); } // Install an instruction selector pass using // the ISelDag to gen Mips code. bool MipsPassConfig::addInstSelector() { addPass(createMipsModuleISelDagPass()); addPass(createMips16ISelDag(getMipsTargetMachine(), getOptLevel())); addPass(createMipsSEISelDag(getMipsTargetMachine(), getOptLevel())); return false; } void MipsPassConfig::addPreRegAlloc() { addPass(createMipsOptimizePICCallPass()); } TargetTransformInfo MipsTargetMachine::getTargetTransformInfo(const Function &F) { if (Subtarget->allowMixed16_32()) { LLVM_DEBUG(errs() << "No Target Transform Info Pass Added\n"); // FIXME: This is no longer necessary as the TTI returned is per-function. return TargetTransformInfo(F.getParent()->getDataLayout()); } LLVM_DEBUG(errs() << "Target Transform Info Pass Added\n"); return TargetTransformInfo(BasicTTIImpl(this, F)); } // Implemented by targets that want to run passes immediately before // machine code is emitted. return true if -print-machineinstrs should // print out the code after the passes. void MipsPassConfig::addPreEmitPass() { // Expand pseudo instructions that are sensitive to register allocation. addPass(createMipsExpandPseudoPass()); // The microMIPS size reduction pass performs instruction reselection for // instructions which can be remapped to a 16 bit instruction. addPass(createMicroMipsSizeReducePass()); // The delay slot filler pass can potientially create forbidden slot hazards // for MIPSR6 and therefore it should go before MipsBranchExpansion pass. addPass(createMipsDelaySlotFillerPass()); // This pass expands branches and takes care about the forbidden slot hazards. // Expanding branches may potentially create forbidden slot hazards for // MIPSR6, and fixing such hazard may potentially break a branch by extending // its offset out of range. That's why this pass combine these two tasks, and // runs them alternately until one of them finishes without any changes. Only // then we can be sure that all branches are expanded properly and no hazards // exists. // Any new pass should go before this pass. addPass(createMipsBranchExpansion()); addPass(createMipsConstantIslandPass()); } bool MipsPassConfig::addIRTranslator() { addPass(new IRTranslator()); return false; } void MipsPassConfig::addPreLegalizeMachineIR() { addPass(createMipsPreLegalizeCombiner()); } bool MipsPassConfig::addLegalizeMachineIR() { addPass(new Legalizer()); return false; } bool MipsPassConfig::addRegBankSelect() { addPass(new RegBankSelect()); return false; } bool MipsPassConfig::addGlobalInstructionSelect() { addPass(new InstructionSelect()); return false; }
Upload File
Create Folder