LLVM  3.7.0
XCoreMachineFunctionInfo.cpp
Go to the documentation of this file.
1 //===-- XCoreMachineFuctionInfo.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"
12 #include "llvm/IR/Function.h"
13 
14 using namespace llvm;
15 
16 void XCoreFunctionInfo::anchor() { }
17 
19  if (CachedEStackSize == -1) {
20  CachedEStackSize = MF.getFrameInfo()->estimateStackSize(MF);
21  }
22  // isLargeFrame() is used when deciding if spill slots should be added to
23  // allow eliminateFrameIndex() to scavenge registers.
24  // This is only required when there is no FP and offsets are greater than
25  // ~256KB (~64Kwords). Thus only for code run on the emulator!
26  //
27  // The arbitrary value of 0xf000 allows frames of up to ~240KB before spill
28  // slots are added for the use of eliminateFrameIndex() register scavenging.
29  // For frames less than 240KB, it is assumed that there will be less than
30  // 16KB of function arguments.
31  return CachedEStackSize > 0xf000;
32 }
33 
35  if (LRSpillSlotSet) {
36  return LRSpillSlot;
37  }
38  const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
39  MachineFrameInfo *MFI = MF.getFrameInfo();
40  if (! MF.getFunction()->isVarArg()) {
41  // A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
42  LRSpillSlot = MFI->CreateFixedObject(RC->getSize(), 0, true);
43  } else {
44  LRSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
45  }
46  LRSpillSlotSet = true;
47  return LRSpillSlot;
48 }
49 
51  if (FPSpillSlotSet) {
52  return FPSpillSlot;
53  }
54  const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
55  MachineFrameInfo *MFI = MF.getFrameInfo();
56  FPSpillSlot = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
57  FPSpillSlotSet = true;
58  return FPSpillSlot;
59 }
60 
62  if (EHSpillSlotSet) {
63  return EHSpillSlot;
64  }
65  const TargetRegisterClass *RC = &XCore::GRRegsRegClass;
66  MachineFrameInfo *MFI = MF.getFrameInfo();
67  EHSpillSlot[0] = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
68  EHSpillSlot[1] = MFI->CreateStackObject(RC->getSize(), RC->getAlignment(), true);
69  EHSpillSlotSet = true;
70  return EHSpillSlot;
71 }
72 
int createLRSpillSlot(MachineFunction &MF)
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
unsigned getSize() const
getSize - Return the size of the register in bytes, which is also the size of a stack slot allocated ...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
int createFPSpillSlot(MachineFunction &MF)
unsigned getAlignment() const
getAlignment - Return the minimum required alignment for a register of this class.
const int * createEHSpillSlot(MachineFunction &MF)
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
bool isLargeFrame(const MachineFunction &MF) const
MachineFrameInfo * getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.cpp:229