1 //===-- XCoreMachineFunctionInfo.cpp - XCore machine function info --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "XCoreMachineFunctionInfo.h"
11 #include "XCoreInstrInfo.h"
12 #include "llvm/CodeGen/TargetSubtargetInfo.h"
13 #include "llvm/IR/Function.h"
17 void XCoreFunctionInfo::anchor() { }
19 bool XCoreFunctionInfo::isLargeFrame(const MachineFunction
&MF
) const {
20 if (CachedEStackSize
== -1) {
21 CachedEStackSize
= MF
.getFrameInfo().estimateStackSize(MF
);
23 // isLargeFrame() is used when deciding if spill slots should be added to
24 // allow eliminateFrameIndex() to scavenge registers.
25 // This is only required when there is no FP and offsets are greater than
26 // ~256KB (~64Kwords). Thus only for code run on the emulator!
28 // The arbitrary value of 0xf000 allows frames of up to ~240KB before spill
29 // slots are added for the use of eliminateFrameIndex() register scavenging.
30 // For frames less than 240KB, it is assumed that there will be less than
31 // 16KB of function arguments.
32 return CachedEStackSize
> 0xf000;
35 int XCoreFunctionInfo::createLRSpillSlot(MachineFunction
&MF
) {
39 const TargetRegisterClass
&RC
= XCore::GRRegsRegClass
;
40 const TargetRegisterInfo
&TRI
= *MF
.getSubtarget().getRegisterInfo();
41 MachineFrameInfo
&MFI
= MF
.getFrameInfo();
42 if (! MF
.getFunction().isVarArg()) {
43 // A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
44 LRSpillSlot
= MFI
.CreateFixedObject(TRI
.getSpillSize(RC
), 0, true);
46 LRSpillSlot
= MFI
.CreateStackObject(TRI
.getSpillSize(RC
),
47 TRI
.getSpillAlignment(RC
), true);
49 LRSpillSlotSet
= true;
53 int XCoreFunctionInfo::createFPSpillSlot(MachineFunction
&MF
) {
57 const TargetRegisterClass
&RC
= XCore::GRRegsRegClass
;
58 const TargetRegisterInfo
&TRI
= *MF
.getSubtarget().getRegisterInfo();
59 MachineFrameInfo
&MFI
= MF
.getFrameInfo();
60 FPSpillSlot
= MFI
.CreateStackObject(TRI
.getSpillSize(RC
),
61 TRI
.getSpillAlignment(RC
), true);
62 FPSpillSlotSet
= true;
66 const int* XCoreFunctionInfo::createEHSpillSlot(MachineFunction
&MF
) {
70 const TargetRegisterClass
&RC
= XCore::GRRegsRegClass
;
71 const TargetRegisterInfo
&TRI
= *MF
.getSubtarget().getRegisterInfo();
72 MachineFrameInfo
&MFI
= MF
.getFrameInfo();
73 unsigned Size
= TRI
.getSpillSize(RC
);
74 unsigned Align
= TRI
.getSpillAlignment(RC
);
75 EHSpillSlot
[0] = MFI
.CreateStackObject(Size
, Align
, true);
76 EHSpillSlot
[1] = MFI
.CreateStackObject(Size
, Align
, true);
77 EHSpillSlotSet
= true;