2012-02-18 12:03:15 +00:00
|
|
|
//===-- XCoreMachineFuctionInfo.cpp - XCore machine function info ---------===//
|
2011-12-20 02:50:00 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "XCoreMachineFunctionInfo.h"
|
2014-01-06 14:20:41 +00:00
|
|
|
#include "XCoreInstrInfo.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
2011-12-20 02:50:00 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void XCoreFunctionInfo::anchor() { }
|
2013-12-02 11:05:28 +00:00
|
|
|
|
|
|
|
bool XCoreFunctionInfo::isLargeFrame(const MachineFunction &MF) const {
|
|
|
|
if (CachedEStackSize == -1) {
|
|
|
|
CachedEStackSize = MF.getFrameInfo()->estimateStackSize(MF);
|
|
|
|
}
|
|
|
|
// isLargeFrame() is used when deciding if spill slots should be added to
|
|
|
|
// allow eliminateFrameIndex() to scavenge registers.
|
|
|
|
// This is only required when there is no FP and offsets are greater than
|
|
|
|
// ~256KB (~64Kwords). Thus only for code run on the emulator!
|
|
|
|
//
|
|
|
|
// The arbitrary value of 0xf000 allows frames of up to ~240KB before spill
|
|
|
|
// slots are added for the use of eliminateFrameIndex() register scavenging.
|
|
|
|
// For frames less than 240KB, it is assumed that there will be less than
|
|
|
|
// 16KB of function arguments.
|
|
|
|
return CachedEStackSize > 0xf000;
|
|
|
|
}
|
2014-01-06 14:20:41 +00:00
|
|
|
|
|
|
|
int XCoreFunctionInfo::createLRSpillSlot(MachineFunction &MF) {
|
|
|
|
if (LRSpillSlotSet) {
|
|
|
|
return LRSpillSlot;
|
|
|
|
}
|
|
|
|
const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
|
|
|
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
|
|
|
if (! MF.getFunction()->isVarArg()) {
|
|
|
|
// A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
|
|
|
|
LRSpillSlot = MFI->CreateFixedObject(RC->getSize(), 0, true);
|
|
|
|
} else {
|
|
|
|
LRSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
|
|
|
|
}
|
|
|
|
LRSpillSlotSet = true;
|
|
|
|
return LRSpillSlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
int XCoreFunctionInfo::createFPSpillSlot(MachineFunction &MF) {
|
|
|
|
if (FPSpillSlotSet) {
|
|
|
|
return FPSpillSlot;
|
|
|
|
}
|
|
|
|
const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
|
|
|
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
|
|
|
FPSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
|
|
|
|
FPSpillSlotSet = true;
|
|
|
|
return FPSpillSlot;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:21:48 +00:00
|
|
|
const int* XCoreFunctionInfo::createEHSpillSlot(MachineFunction &MF) {
|
|
|
|
if (EHSpillSlotSet) {
|
|
|
|
return EHSpillSlot;
|
|
|
|
}
|
|
|
|
const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
|
|
|
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
|
|
|
EHSpillSlot[0] = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
|
|
|
|
EHSpillSlot[1] = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
|
|
|
|
EHSpillSlotSet = true;
|
|
|
|
return EHSpillSlot;
|
|
|
|
}
|
|
|
|
|