LLVM  9.0.0svn
XCoreMachineFunctionInfo.cpp
Go to the documentation of this file.
1 //===-- XCoreMachineFunctionInfo.cpp - XCore machine function info --------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #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;
40  MachineFrameInfo &MFI = MF.getFrameInfo();
41  if (! MF.getFunction().isVarArg()) {
42  // A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
43  LRSpillSlot = MFI.CreateFixedObject(TRI.getSpillSize(RC), 0, true);
44  } else {
45  LRSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
46  TRI.getSpillAlignment(RC), true);
47  }
48  LRSpillSlotSet = true;
49  return LRSpillSlot;
50 }
51 
53  if (FPSpillSlotSet) {
54  return FPSpillSlot;
55  }
56  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
58  MachineFrameInfo &MFI = MF.getFrameInfo();
59  FPSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
60  TRI.getSpillAlignment(RC), true);
61  FPSpillSlotSet = true;
62  return FPSpillSlot;
63 }
64 
66  if (EHSpillSlotSet) {
67  return EHSpillSlot;
68  }
69  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
71  MachineFrameInfo &MFI = MF.getFrameInfo();
72  unsigned Size = TRI.getSpillSize(RC);
73  unsigned Align = TRI.getSpillAlignment(RC);
74  EHSpillSlot[0] = MFI.CreateStackObject(Size, Align, true);
75  EHSpillSlot[1] = MFI.CreateStackObject(Size, Align, true);
76  EHSpillSlotSet = true;
77  return EHSpillSlot;
78 }
79 
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Definition: Function.h:176
int createLRSpillSlot(MachineFunction &MF)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:46
bool isLargeFrame(const MachineFunction &MF) const