1 //===- XCoreMachineFunctionInfo.h - XCore machine function info -*- C++ -*-===// 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 // 10 // This file declares XCore-specific per-machine-function information. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H 15 #define LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H 16 17 #include "llvm/CodeGen/MachineBasicBlock.h" 18 #include "llvm/CodeGen/MachineFrameInfo.h" 19 #include "llvm/CodeGen/MachineFunction.h" 20 #include <cassert> 21 #include <utility> 22 #include <vector> 23 24 namespace llvm { 25 26 /// XCoreFunctionInfo - This class is derived from MachineFunction private 27 /// XCore target-specific information for each MachineFunction. 28 class XCoreFunctionInfo : public MachineFunctionInfo { 29 bool LRSpillSlotSet = false; 30 int LRSpillSlot; 31 bool FPSpillSlotSet = false; 32 int FPSpillSlot; 33 bool EHSpillSlotSet = false; 34 int EHSpillSlot[2]; 35 unsigned ReturnStackOffset; 36 bool ReturnStackOffsetSet = false; 37 int VarArgsFrameIndex = 0; 38 mutable int CachedEStackSize = -1; 39 std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>> 40 SpillLabels; 41 42 virtual void anchor(); 43 44 public: 45 XCoreFunctionInfo() = default; 46 XCoreFunctionInfo(MachineFunction & MF)47 explicit XCoreFunctionInfo(MachineFunction &MF) {} 48 49 ~XCoreFunctionInfo() override = default; 50 setVarArgsFrameIndex(int off)51 void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; } getVarArgsFrameIndex()52 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 53 54 int createLRSpillSlot(MachineFunction &MF); hasLRSpillSlot()55 bool hasLRSpillSlot() { return LRSpillSlotSet; } getLRSpillSlot()56 int getLRSpillSlot() const { 57 assert(LRSpillSlotSet && "LR Spill slot not set"); 58 return LRSpillSlot; 59 } 60 61 int createFPSpillSlot(MachineFunction &MF); hasFPSpillSlot()62 bool hasFPSpillSlot() { return FPSpillSlotSet; } getFPSpillSlot()63 int getFPSpillSlot() const { 64 assert(FPSpillSlotSet && "FP Spill slot not set"); 65 return FPSpillSlot; 66 } 67 68 const int* createEHSpillSlot(MachineFunction &MF); hasEHSpillSlot()69 bool hasEHSpillSlot() { return EHSpillSlotSet; } getEHSpillSlot()70 const int* getEHSpillSlot() const { 71 assert(EHSpillSlotSet && "EH Spill slot not set"); 72 return EHSpillSlot; 73 } 74 setReturnStackOffset(unsigned value)75 void setReturnStackOffset(unsigned value) { 76 assert(!ReturnStackOffsetSet && "Return stack offset set twice"); 77 ReturnStackOffset = value; 78 ReturnStackOffsetSet = true; 79 } 80 getReturnStackOffset()81 unsigned getReturnStackOffset() const { 82 assert(ReturnStackOffsetSet && "Return stack offset not set"); 83 return ReturnStackOffset; 84 } 85 86 bool isLargeFrame(const MachineFunction &MF) const; 87 88 std::vector<std::pair<MachineBasicBlock::iterator, CalleeSavedInfo>> & getSpillLabels()89 getSpillLabels() { 90 return SpillLabels; 91 } 92 }; 93 94 } // end namespace llvm 95 96 #endif // LLVM_LIB_TARGET_XCORE_XCOREMACHINEFUNCTIONINFO_H 97