LLVM  8.0.1
XCoreMachineFunctionInfo.cpp
Go to the documentation of this file.
1 //===-- XCoreMachineFunctionInfo.cpp - XCore machine function info --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "XCoreInstrInfo.h"
13 #include "llvm/IR/Function.h"
14 
15 using namespace llvm;
16 
17 void XCoreFunctionInfo::anchor() { }
18 
20  if (CachedEStackSize == -1) {
21  CachedEStackSize = MF.getFrameInfo().estimateStackSize(MF);
22  }
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!
27  //
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;
33 }
34 
36  if (LRSpillSlotSet) {
37  return LRSpillSlot;
38  }
39  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
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);
45  } else {
46  LRSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
47  TRI.getSpillAlignment(RC), true);
48  }
49  LRSpillSlotSet = true;
50  return LRSpillSlot;
51 }
52 
54  if (FPSpillSlotSet) {
55  return FPSpillSlot;
56  }
57  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
59  MachineFrameInfo &MFI = MF.getFrameInfo();
60  FPSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
61  TRI.getSpillAlignment(RC), true);
62  FPSpillSlotSet = true;
63  return FPSpillSlot;
64 }
65 
67  if (EHSpillSlotSet) {
68  return EHSpillSlot;
69  }
70  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
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;
78  return EHSpillSlot;
79 }
80 
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.h:177
int createLRSpillSlot(MachineFunction &MF)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned const TargetRegisterInfo * TRI
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
int createFPSpillSlot(MachineFunction &MF)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
const int * createEHSpillSlot(MachineFunction &MF)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
uint32_t Size
Definition: Profile.cpp:47
bool isLargeFrame(const MachineFunction &MF) const