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: Mips16FrameLowering.cpp
//===- Mips16FrameLowering.cpp - Mips16 Frame Information -----------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file contains the Mips16 implementation of TargetFrameLowering class. // //===----------------------------------------------------------------------===// #include "Mips16FrameLowering.h" #include "MCTargetDesc/MipsBaseInfo.h" #include "Mips16InstrInfo.h" #include "MipsInstrInfo.h" #include "MipsRegisterInfo.h" #include "MipsSubtarget.h" #include "llvm/ADT/BitVector.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/IR/DebugLoc.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MachineLocation.h" #include "llvm/Support/MathExtras.h" #include "llvm/CodeGen/TargetFrameLowering.h" #include <cassert> #include <cstdint> #include <vector> using namespace llvm; Mips16FrameLowering::Mips16FrameLowering(const MipsSubtarget &STI) : MipsFrameLowering(STI, STI.getStackAlignment()) {} void Mips16FrameLowering::emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const { MachineFrameInfo &MFI = MF.getFrameInfo(); const Mips16InstrInfo &TII = *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo()); MachineBasicBlock::iterator MBBI = MBB.begin(); // Debug location must be unknown since the first debug location is used // to determine the end of the prologue. DebugLoc dl; uint64_t StackSize = MFI.getStackSize(); // No need to allocate space on the stack. if (StackSize == 0 && !MFI.adjustsStack()) return; MachineModuleInfo &MMI = MF.getMMI(); const MCRegisterInfo *MRI = MMI.getContext().getRegisterInfo(); // Adjust stack. TII.makeFrame(Mips::SP, StackSize, MBB, MBBI); // emit ".cfi_def_cfa_offset StackSize" unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::cfiDefCfaOffset(nullptr, StackSize)); BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex); const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo(); if (!CSI.empty()) { const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo(); for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(), E = CSI.end(); I != E; ++I) { int64_t Offset = MFI.getObjectOffset(I->getFrameIdx()); unsigned Reg = I->getReg(); unsigned DReg = MRI->getDwarfRegNum(Reg, true); unsigned CFIIndex = MF.addFrameInst( MCCFIInstruction::createOffset(nullptr, DReg, Offset)); BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION)) .addCFIIndex(CFIIndex); } } if (hasFP(MF)) BuildMI(MBB, MBBI, dl, TII.get(Mips::MoveR3216), Mips::S0) .addReg(Mips::SP).setMIFlag(MachineInstr::FrameSetup); } void Mips16FrameLowering::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { MachineBasicBlock::iterator MBBI = MBB.getFirstTerminator(); MachineFrameInfo &MFI = MF.getFrameInfo(); const Mips16InstrInfo &TII = *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo()); DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); uint64_t StackSize = MFI.getStackSize(); if (!StackSize) return; if (hasFP(MF)) BuildMI(MBB, MBBI, dl, TII.get(Mips::Move32R16), Mips::SP) .addReg(Mips::S0); // Adjust stack. // assumes stacksize multiple of 8 TII.restoreFrame(Mips::SP, StackSize, MBB, MBBI); } bool Mips16FrameLowering::spillCalleeSavedRegisters( MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const { MachineFunction *MF = MBB.getParent(); // // Registers RA, S0,S1 are the callee saved registers and they // will be saved with the "save" instruction // during emitPrologue // for (unsigned i = 0, e = CSI.size(); i != e; ++i) { // Add the callee-saved register as live-in. Do not add if the register is // RA and return address is taken, because it has already been added in // method MipsTargetLowering::lowerRETURNADDR. // It's killed at the spill, unless the register is RA and return address // is taken. unsigned Reg = CSI[i].getReg(); bool IsRAAndRetAddrIsTaken = (Reg == Mips::RA) && MF->getFrameInfo().isReturnAddressTaken(); if (!IsRAAndRetAddrIsTaken) MBB.addLiveIn(Reg); } return true; } bool Mips16FrameLowering::restoreCalleeSavedRegisters( MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const { // // Registers RA,S0,S1 are the callee saved registers and they will be restored // with the restore instruction during emitEpilogue. // We need to override this virtual function, otherwise llvm will try and // restore the registers on it's on from the stack. // return true; } bool Mips16FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const { const MachineFrameInfo &MFI = MF.getFrameInfo(); // Reserve call frame if the size of the maximum call frame fits into 15-bit // immediate field and there are no variable sized objects on the stack. return isInt<15>(MFI.getMaxCallFrameSize()) && !MFI.hasVarSizedObjects(); } void Mips16FrameLowering::determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const { TargetFrameLowering::determineCalleeSaves(MF, SavedRegs, RS); const Mips16InstrInfo &TII = *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo()); const MipsRegisterInfo &RI = TII.getRegisterInfo(); const BitVector Reserved = RI.getReservedRegs(MF); bool SaveS2 = Reserved[Mips::S2]; if (SaveS2) SavedRegs.set(Mips::S2); if (hasFP(MF)) SavedRegs.set(Mips::S0); } const MipsFrameLowering * llvm::createMips16FrameLowering(const MipsSubtarget &ST) { return new Mips16FrameLowering(ST); }
Upload File
Create Folder