#include "PPCFrameLowering.h"
#include "MCTargetDesc/PPCPredicates.h"
#include "PPCInstrBuilder.h"
#include "PPCInstrInfo.h"
#include "PPCMachineFunctionInfo.h"
#include "PPCSubtarget.h"
#include "PPCTargetMachine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LivePhysRegs.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/CodeGen/RegisterScavenging.h"
#include "llvm/IR/Function.h"
#include "llvm/Target/TargetOptions.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumPESpillVSR, "Number of spills to vector in prologue");
STATISTIC(NumPEReloadVSR, "Number of reloads from vector in epilogue");
STATISTIC(NumPrologProbed, "Number of prologues probed");
static cl::opt<bool>
EnablePEVectorSpills("ppc-enable-pe-vector-spills",
cl::desc("Enable spills in prologue to vector registers."),
cl::init(false), cl::Hidden);
static unsigned computeReturnSaveOffset(const PPCSubtarget &STI) { … }
static unsigned computeTOCSaveOffset(const PPCSubtarget &STI) { … }
static unsigned computeFramePointerSaveOffset(const PPCSubtarget &STI) { … }
static unsigned computeLinkageSize(const PPCSubtarget &STI) { … }
static unsigned computeBasePointerSaveOffset(const PPCSubtarget &STI) { … }
static unsigned computeCRSaveOffset(const PPCSubtarget &STI) { … }
PPCFrameLowering::PPCFrameLowering(const PPCSubtarget &STI)
: … { … }
const PPCFrameLowering::SpillSlot *PPCFrameLowering::getCalleeSavedSpillSlots(
unsigned &NumEntries) const { … }
static bool spillsCR(const MachineFunction &MF) { … }
static bool hasSpills(const MachineFunction &MF) { … }
static bool hasNonRISpills(const MachineFunction &MF) { … }
static bool MustSaveLR(const MachineFunction &MF, unsigned LR) { … }
uint64_t
PPCFrameLowering::determineFrameLayoutAndUpdate(MachineFunction &MF,
bool UseEstimate) const { … }
uint64_t
PPCFrameLowering::determineFrameLayout(const MachineFunction &MF,
bool UseEstimate,
unsigned *NewMaxCallFrameSize) const { … }
bool PPCFrameLowering::hasFP(const MachineFunction &MF) const { … }
bool PPCFrameLowering::needsFP(const MachineFunction &MF) const { … }
void PPCFrameLowering::replaceFPWithRealFP(MachineFunction &MF) const { … }
bool
PPCFrameLowering::findScratchRegister(MachineBasicBlock *MBB,
bool UseAtEnd,
bool TwoUniqueRegsRequired,
Register *SR1,
Register *SR2) const { … }
bool
PPCFrameLowering::twoUniqueScratchRegsRequired(MachineBasicBlock *MBB) const { … }
bool PPCFrameLowering::canUseAsPrologue(const MachineBasicBlock &MBB) const { … }
bool PPCFrameLowering::canUseAsEpilogue(const MachineBasicBlock &MBB) const { … }
bool PPCFrameLowering::stackUpdateCanBeMoved(MachineFunction &MF) const { … }
void PPCFrameLowering::emitPrologue(MachineFunction &MF,
MachineBasicBlock &MBB) const { … }
void PPCFrameLowering::inlineStackProbe(MachineFunction &MF,
MachineBasicBlock &PrologMBB) const { … }
void PPCFrameLowering::emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const { … }
void PPCFrameLowering::createTailCallBranchInstr(MachineBasicBlock &MBB) const { … }
void PPCFrameLowering::determineCalleeSaves(MachineFunction &MF,
BitVector &SavedRegs,
RegScavenger *RS) const { … }
void PPCFrameLowering::processFunctionBeforeFrameFinalized(MachineFunction &MF,
RegScavenger *RS) const { … }
void
PPCFrameLowering::addScavengingSpillSlot(MachineFunction &MF,
RegScavenger *RS) const { … }
bool PPCFrameLowering::assignCalleeSavedSpillSlots(
MachineFunction &MF, const TargetRegisterInfo *TRI,
std::vector<CalleeSavedInfo> &CSI) const { … }
bool PPCFrameLowering::spillCalleeSavedRegisters(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
ArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const { … }
static void restoreCRs(bool is31, bool CR2Spilled, bool CR3Spilled,
bool CR4Spilled, MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
ArrayRef<CalleeSavedInfo> CSI, unsigned CSIIndex) { … }
MachineBasicBlock::iterator PPCFrameLowering::
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const { … }
static bool isCalleeSavedCR(unsigned Reg) { … }
bool PPCFrameLowering::restoreCalleeSavedRegisters(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
MutableArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const { … }
uint64_t PPCFrameLowering::getTOCSaveOffset() const { … }
uint64_t PPCFrameLowering::getFramePointerSaveOffset() const { … }
uint64_t PPCFrameLowering::getBasePointerSaveOffset() const { … }
bool PPCFrameLowering::enableShrinkWrapping(const MachineFunction &MF) const { … }
void PPCFrameLowering::updateCalleeSaves(const MachineFunction &MF,
BitVector &SavedRegs) const { … }
uint64_t PPCFrameLowering::getStackThreshold() const { … }