XCore target: Refactor LR handling
[oota-llvm.git] / lib / Target / XCore / XCoreMachineFunctionInfo.h
1 //===-- XCoreMachineFuctionInfo.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 XCOREMACHINEFUNCTIONINFO_H
15 #define XCOREMACHINEFUNCTIONINFO_H
16
17 #include "llvm/CodeGen/MachineFrameInfo.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include <vector>
20
21 namespace llvm {
22
23 // Forward declarations
24 class Function;
25
26 /// XCoreFunctionInfo - This class is derived from MachineFunction private
27 /// XCore target-specific information for each MachineFunction.
28 class XCoreFunctionInfo : public MachineFunctionInfo {
29   virtual void anchor();
30   bool LRSpillSlotSet;
31   int LRSpillSlot;
32   bool FPSpillSlotSet;
33   int FPSpillSlot;
34   int VarArgsFrameIndex;
35   mutable int CachedEStackSize;
36   std::vector<std::pair<MCSymbol*, CalleeSavedInfo> > SpillLabels;
37
38 public:
39   XCoreFunctionInfo() :
40     LRSpillSlotSet(false),
41     LRSpillSlot(0),
42     FPSpillSlotSet(false),
43     FPSpillSlot(0),
44     VarArgsFrameIndex(0),
45     CachedEStackSize(-1) {}
46   
47   explicit XCoreFunctionInfo(MachineFunction &MF) :
48     LRSpillSlotSet(false),
49     LRSpillSlot(0),
50     FPSpillSlotSet(false),
51     FPSpillSlot(0),
52     VarArgsFrameIndex(0),
53     CachedEStackSize(-1) {}
54   
55   ~XCoreFunctionInfo() {}
56   
57   void setVarArgsFrameIndex(int off) { VarArgsFrameIndex = off; }
58   int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
59
60   int createLRSpillSlot(MachineFunction &MF);
61   bool hasLRSpillSlot() { return LRSpillSlotSet; }
62   int getLRSpillSlot() const {
63     assert(LRSpillSlotSet && "LR Spill slot no set");
64     return LRSpillSlot;
65   }
66
67   int createFPSpillSlot(MachineFunction &MF);
68   bool hasFPSpillSlot() { return FPSpillSlotSet; }
69   int getFPSpillSlot() const {
70     assert(FPSpillSlotSet && "FP Spill slot no set");
71     return FPSpillSlot;
72   }
73
74   bool isLargeFrame(const MachineFunction &MF) const;
75
76   std::vector<std::pair<MCSymbol*, CalleeSavedInfo> > &getSpillLabels() {
77     return SpillLabels;
78   }
79 };
80 } // End llvm namespace
81
82 #endif // XCOREMACHINEFUNCTIONINFO_H