You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
Analysis
AsmParser
BinaryFormat
Bitcode
CodeGen
DebugInfo
Demangle
ExecutionEngine
FuzzMutate
Fuzzer
IR
IRReader
LTO
LineEditor
Linker
MC
Object
ObjectYAML
Option
Passes
ProfileData
Support
TableGen
Target
AArch64
AMDGPU
ARC
ARM
AVR
BPF
Hexagon
Lanai
MSP430
Mips
AsmParser
Disassembler
InstPrinter
MCTargetDesc
TargetInfo
CMakeLists.txt
LLVMBuild.txt
MSA.txt
MicroMips32r6InstrFormats.td
MicroMips32r6InstrInfo.td
MicroMipsDSPInstrFormats.td
MicroMipsDSPInstrInfo.td
MicroMipsInstrFPU.td
MicroMipsInstrFormats.td
MicroMipsInstrInfo.td
MicroMipsSizeReduction.cpp
Mips.h
Mips.td
Mips16FrameLowering.cpp
Mips16FrameLowering.h
Mips16HardFloat.cpp
Mips16HardFloatInfo.cpp
Mips16HardFloatInfo.h
Mips16ISelDAGToDAG.cpp
Mips16ISelDAGToDAG.h
Mips16ISelLowering.cpp
Mips16ISelLowering.h
Mips16InstrFormats.td
Mips16InstrInfo.cpp
Mips16InstrInfo.h
Mips16InstrInfo.td
Mips16RegisterInfo.cpp
Mips16RegisterInfo.h
Mips32r6InstrFormats.td
Mips32r6InstrInfo.td
Mips64InstrInfo.td
Mips64r6InstrInfo.td
MipsAnalyzeImmediate.cpp
MipsAnalyzeImmediate.h
MipsAsmPrinter.cpp
MipsAsmPrinter.h
MipsCCState.cpp
MipsCCState.h
MipsCallingConv.td
MipsCondMov.td
MipsConstantIslandPass.cpp
MipsDSPInstrFormats.td
MipsDSPInstrInfo.td
MipsDelaySlotFiller.cpp
MipsEVAInstrFormats.td
MipsEVAInstrInfo.td
MipsFastISel.cpp
MipsFrameLowering.cpp
MipsFrameLowering.h
MipsHazardSchedule.cpp
MipsISelDAGToDAG.cpp
MipsISelDAGToDAG.h
MipsISelLowering.cpp.REMOVED.git-id
MipsISelLowering.h
MipsInstrFPU.td
MipsInstrFormats.td
MipsInstrInfo.cpp
MipsInstrInfo.h
MipsInstrInfo.td.REMOVED.git-id
MipsLongBranch.cpp
MipsMCInstLower.cpp
MipsMCInstLower.h
MipsMSAInstrFormats.td
MipsMSAInstrInfo.td.REMOVED.git-id
MipsMTInstrFormats.td
MipsMTInstrInfo.td
MipsMachineFunction.cpp
MipsMachineFunction.h
MipsModuleISelDAGToDAG.cpp
MipsOptimizePICCall.cpp
MipsOptionRecord.h
MipsOs16.cpp
MipsRegisterInfo.cpp
MipsRegisterInfo.h
MipsRegisterInfo.td
MipsSEFrameLowering.cpp
MipsSEFrameLowering.h
MipsSEISelDAGToDAG.cpp
MipsSEISelDAGToDAG.h
MipsSEISelLowering.cpp.REMOVED.git-id
MipsSEISelLowering.h
MipsSEInstrInfo.cpp
MipsSEInstrInfo.h
MipsSERegisterInfo.cpp
MipsSERegisterInfo.h
MipsSchedule.td
MipsScheduleGeneric.td
MipsScheduleP5600.td
MipsSubtarget.cpp
MipsSubtarget.h
MipsTargetMachine.cpp
MipsTargetMachine.h
MipsTargetObjectFile.cpp
MipsTargetObjectFile.h
MipsTargetStreamer.h
Relocation.txt
NVPTX
Nios2
PowerPC
RISCV
Sparc
SystemZ
WebAssembly
X86
XCore
CMakeLists.txt
LLVMBuild.txt
README.txt
Target.cpp
TargetIntrinsicInfo.cpp
TargetLoweringObjectFile.cpp
TargetMachine.cpp
TargetMachineC.cpp
Testing
ToolDrivers
Transforms
WindowsManifest
XRay
CMakeLists.txt
LLVMBuild.txt
projects
resources
runtimes
scripts
test
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
version.txt.in
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
153 lines
5.7 KiB
C++
153 lines
5.7 KiB
C++
![]() |
//===-- MipsFrameLowering.cpp - Mips Frame Information --------------------===//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
//
|
||
|
// This file contains the Mips implementation of TargetFrameLowering class.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
#include "MipsFrameLowering.h"
|
||
|
#include "MCTargetDesc/MipsBaseInfo.h"
|
||
|
#include "MipsInstrInfo.h"
|
||
|
#include "MipsMachineFunction.h"
|
||
|
#include "MipsTargetMachine.h"
|
||
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||
|
#include "llvm/IR/DataLayout.h"
|
||
|
#include "llvm/IR/Function.h"
|
||
|
#include "llvm/Target/TargetOptions.h"
|
||
|
|
||
|
using namespace llvm;
|
||
|
|
||
|
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
//
|
||
|
// Stack Frame Processing methods
|
||
|
// +----------------------------+
|
||
|
//
|
||
|
// The stack is allocated decrementing the stack pointer on
|
||
|
// the first instruction of a function prologue. Once decremented,
|
||
|
// all stack references are done thought a positive offset
|
||
|
// from the stack/frame pointer, so the stack is considering
|
||
|
// to grow up! Otherwise terrible hacks would have to be made
|
||
|
// to get this stack ABI compliant :)
|
||
|
//
|
||
|
// The stack frame required by the ABI (after call):
|
||
|
// Offset
|
||
|
//
|
||
|
// 0 ----------
|
||
|
// 4 Args to pass
|
||
|
// . saved $GP (used in PIC)
|
||
|
// . Alloca allocations
|
||
|
// . Local Area
|
||
|
// . CPU "Callee Saved" Registers
|
||
|
// . saved FP
|
||
|
// . saved RA
|
||
|
// . FPU "Callee Saved" Registers
|
||
|
// StackSize -----------
|
||
|
//
|
||
|
// Offset - offset from sp after stack allocation on function prologue
|
||
|
//
|
||
|
// The sp is the stack pointer subtracted/added from the stack size
|
||
|
// at the Prologue/Epilogue
|
||
|
//
|
||
|
// References to the previous stack (to obtain arguments) are done
|
||
|
// with offsets that exceeds the stack size: (stacksize+(4*(num_arg-1))
|
||
|
//
|
||
|
// Examples:
|
||
|
// - reference to the actual stack frame
|
||
|
// for any local area var there is smt like : FI >= 0, StackOffset: 4
|
||
|
// sw REGX, 4(SP)
|
||
|
//
|
||
|
// - reference to previous stack frame
|
||
|
// suppose there's a load to the 5th arguments : FI < 0, StackOffset: 16.
|
||
|
// The emitted instruction will be something like:
|
||
|
// lw REGX, 16+StackSize(SP)
|
||
|
//
|
||
|
// Since the total stack size is unknown on LowerFormalArguments, all
|
||
|
// stack references (ObjectOffset) created to reference the function
|
||
|
// arguments, are negative numbers. This way, on eliminateFrameIndex it's
|
||
|
// possible to detect those references and the offsets are adjusted to
|
||
|
// their real location.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
const MipsFrameLowering *MipsFrameLowering::create(const MipsSubtarget &ST) {
|
||
|
if (ST.inMips16Mode())
|
||
|
return llvm::createMips16FrameLowering(ST);
|
||
|
|
||
|
return llvm::createMipsSEFrameLowering(ST);
|
||
|
}
|
||
|
|
||
|
// hasFP - Return true if the specified function should have a dedicated frame
|
||
|
// pointer register. This is true if the function has variable sized allocas,
|
||
|
// if it needs dynamic stack realignment, if frame pointer elimination is
|
||
|
// disabled, or if the frame address is taken.
|
||
|
bool MipsFrameLowering::hasFP(const MachineFunction &MF) const {
|
||
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
||
|
const TargetRegisterInfo *TRI = STI.getRegisterInfo();
|
||
|
|
||
|
return MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
||
|
MFI.hasVarSizedObjects() || MFI.isFrameAddressTaken() ||
|
||
|
TRI->needsStackRealignment(MF);
|
||
|
}
|
||
|
|
||
|
bool MipsFrameLowering::hasBP(const MachineFunction &MF) const {
|
||
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
||
|
const TargetRegisterInfo *TRI = STI.getRegisterInfo();
|
||
|
|
||
|
return MFI.hasVarSizedObjects() && TRI->needsStackRealignment(MF);
|
||
|
}
|
||
|
|
||
|
// Estimate the size of the stack, including the incoming arguments. We need to
|
||
|
// account for register spills, local objects, reserved call frame and incoming
|
||
|
// arguments. This is required to determine the largest possible positive offset
|
||
|
// from $sp so that it can be determined if an emergency spill slot for stack
|
||
|
// addresses is required.
|
||
|
uint64_t MipsFrameLowering::estimateStackSize(const MachineFunction &MF) const {
|
||
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
||
|
const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
|
||
|
|
||
|
int64_t Size = 0;
|
||
|
|
||
|
// Iterate over fixed sized objects which are incoming arguments.
|
||
|
for (int I = MFI.getObjectIndexBegin(); I != 0; ++I)
|
||
|
if (MFI.getObjectOffset(I) > 0)
|
||
|
Size += MFI.getObjectSize(I);
|
||
|
|
||
|
// Conservatively assume all callee-saved registers will be saved.
|
||
|
for (const MCPhysReg *R = TRI.getCalleeSavedRegs(&MF); *R; ++R) {
|
||
|
unsigned RegSize = TRI.getSpillSize(*TRI.getMinimalPhysRegClass(*R));
|
||
|
Size = alignTo(Size + RegSize, RegSize);
|
||
|
}
|
||
|
|
||
|
// Get the size of the rest of the frame objects and any possible reserved
|
||
|
// call frame, accounting for alignment.
|
||
|
return Size + MFI.estimateStackSize(MF);
|
||
|
}
|
||
|
|
||
|
// Eliminate ADJCALLSTACKDOWN, ADJCALLSTACKUP pseudo instructions
|
||
|
MachineBasicBlock::iterator MipsFrameLowering::
|
||
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||
|
MachineBasicBlock::iterator I) const {
|
||
|
unsigned SP = STI.getABI().IsN64() ? Mips::SP_64 : Mips::SP;
|
||
|
|
||
|
if (!hasReservedCallFrame(MF)) {
|
||
|
int64_t Amount = I->getOperand(0).getImm();
|
||
|
if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
|
||
|
Amount = -Amount;
|
||
|
|
||
|
STI.getInstrInfo()->adjustStackPtr(SP, Amount, MBB, I);
|
||
|
}
|
||
|
|
||
|
return MBB.erase(I);
|
||
|
}
|