2015-07-30 06:32:47 +08:00
|
|
|
//===-- XCoreMachineFunctionInfo.cpp - XCore machine function info --------===//
|
2011-12-20 10:50:00 +08: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 22:20:41 +08:00
|
|
|
#include "XCoreInstrInfo.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
2014-01-06 22:20:41 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
2011-12-20 10:50:00 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void XCoreFunctionInfo::anchor() { }
|
2013-12-02 19:05:28 +08:00
|
|
|
|
|
|
|
bool XCoreFunctionInfo::isLargeFrame(const MachineFunction &MF) const {
|
|
|
|
if (CachedEStackSize == -1) {
|
2016-07-29 02:40:00 +08:00
|
|
|
CachedEStackSize = MF.getFrameInfo().estimateStackSize(MF);
|
2013-12-02 19:05:28 +08:00
|
|
|
}
|
|
|
|
// 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 22:20:41 +08:00
|
|
|
|
|
|
|
int XCoreFunctionInfo::createLRSpillSlot(MachineFunction &MF) {
|
|
|
|
if (LRSpillSlotSet) {
|
|
|
|
return LRSpillSlot;
|
|
|
|
}
|
2017-04-25 02:55:33 +08:00
|
|
|
const TargetRegisterClass &RC = XCore::GRRegsRegClass;
|
|
|
|
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
|
2016-07-29 02:40:00 +08:00
|
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
2017-12-16 06:22:58 +08:00
|
|
|
if (! MF.getFunction().isVarArg()) {
|
2014-01-06 22:20:41 +08:00
|
|
|
// A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
|
2017-04-25 02:55:33 +08:00
|
|
|
LRSpillSlot = MFI.CreateFixedObject(TRI.getSpillSize(RC), 0, true);
|
2014-01-06 22:20:41 +08:00
|
|
|
} else {
|
2017-04-25 02:55:33 +08:00
|
|
|
LRSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
|
|
|
|
TRI.getSpillAlignment(RC), true);
|
2014-01-06 22:20:41 +08:00
|
|
|
}
|
|
|
|
LRSpillSlotSet = true;
|
|
|
|
return LRSpillSlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
int XCoreFunctionInfo::createFPSpillSlot(MachineFunction &MF) {
|
|
|
|
if (FPSpillSlotSet) {
|
|
|
|
return FPSpillSlot;
|
|
|
|
}
|
2017-04-25 02:55:33 +08:00
|
|
|
const TargetRegisterClass &RC = XCore::GRRegsRegClass;
|
|
|
|
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
|
2016-07-29 02:40:00 +08:00
|
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
2017-04-25 02:55:33 +08:00
|
|
|
FPSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
|
|
|
|
TRI.getSpillAlignment(RC), true);
|
2014-01-06 22:20:41 +08:00
|
|
|
FPSpillSlotSet = true;
|
|
|
|
return FPSpillSlot;
|
|
|
|
}
|
|
|
|
|
2014-02-18 19:21:48 +08:00
|
|
|
const int* XCoreFunctionInfo::createEHSpillSlot(MachineFunction &MF) {
|
|
|
|
if (EHSpillSlotSet) {
|
|
|
|
return EHSpillSlot;
|
|
|
|
}
|
2017-04-25 02:55:33 +08:00
|
|
|
const TargetRegisterClass &RC = XCore::GRRegsRegClass;
|
|
|
|
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
|
2016-07-29 02:40:00 +08:00
|
|
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
2017-04-25 02:55:33 +08:00
|
|
|
unsigned Size = TRI.getSpillSize(RC);
|
|
|
|
unsigned Align = TRI.getSpillAlignment(RC);
|
|
|
|
EHSpillSlot[0] = MFI.CreateStackObject(Size, Align, true);
|
|
|
|
EHSpillSlot[1] = MFI.CreateStackObject(Size, Align, true);
|
2014-02-18 19:21:48 +08:00
|
|
|
EHSpillSlotSet = true;
|
|
|
|
return EHSpillSlot;
|
|
|
|
}
|
|
|
|
|