]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/lib/Target/SystemZ/SystemZFrameLowering.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / lib / Target / SystemZ / SystemZFrameLowering.h
1 //===-- SystemZFrameLowering.h - Frame lowering for SystemZ -----*- 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 #ifndef SYSTEMZFRAMELOWERING_H
11 #define SYSTEMZFRAMELOWERING_H
12
13 #include "SystemZSubtarget.h"
14 #include "llvm/ADT/IndexedMap.h"
15 #include "llvm/Target/TargetFrameLowering.h"
16
17 namespace llvm {
18 class SystemZTargetMachine;
19 class SystemZSubtarget;
20
21 class SystemZFrameLowering : public TargetFrameLowering {
22   IndexedMap<unsigned> RegSpillOffsets;
23
24 protected:
25   const SystemZTargetMachine &TM;
26   const SystemZSubtarget &STI;
27
28 public:
29   SystemZFrameLowering(const SystemZTargetMachine &tm,
30                        const SystemZSubtarget &sti);
31
32   // Override FrameLowering.
33   virtual void
34     processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
35                                          RegScavenger *RS) const LLVM_OVERRIDE;
36   virtual bool
37     spillCalleeSavedRegisters(MachineBasicBlock &MBB,
38                               MachineBasicBlock::iterator MBBI,
39                               const std::vector<CalleeSavedInfo> &CSI,
40                               const TargetRegisterInfo *TRI) const
41     LLVM_OVERRIDE;
42   virtual bool
43     restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
44                                 MachineBasicBlock::iterator MBBII,
45                                 const std::vector<CalleeSavedInfo> &CSI,
46                                 const TargetRegisterInfo *TRI) const
47     LLVM_OVERRIDE;
48   virtual void emitPrologue(MachineFunction &MF) const LLVM_OVERRIDE;
49   virtual void emitEpilogue(MachineFunction &MF,
50                             MachineBasicBlock &MBB) const LLVM_OVERRIDE;
51   virtual bool hasFP(const MachineFunction &MF) const LLVM_OVERRIDE;
52   virtual int getFrameIndexOffset(const MachineFunction &MF,
53                                   int FI) const LLVM_OVERRIDE;
54   virtual bool hasReservedCallFrame(const MachineFunction &MF) const
55     LLVM_OVERRIDE;
56   virtual void
57   eliminateCallFramePseudoInstr(MachineFunction &MF,
58                                 MachineBasicBlock &MBB,
59                                 MachineBasicBlock::iterator MI) const
60     LLVM_OVERRIDE;
61
62   // The target-independent code automatically allocates save slots for
63   // call-saved GPRs.  However, we don't need those slots for SystemZ,
64   // because the ABI sets aside GPR save slots in the caller-allocated part
65   // of the frame.  Since the target-independent code puts this unneeded
66   // area at the top of the callee-allocated part of frame, we choose not
67   // to allocate it and adjust the offsets accordingly.  Return the
68   // size of this unallocated area.
69   // FIXME: seems a bit hackish.
70   uint64_t getUnallocatedTopBytes(const MachineFunction &MF) const;
71
72   // Return the number of bytes in the callee-allocated part of the frame.
73   uint64_t getAllocatedStackSize(const MachineFunction &MF) const;
74
75   // Return the number of frame bytes that should be reserved for
76   // an emergency spill slot, for use by the register scaveneger.
77   // Return 0 if register scaveging won't be needed.
78   unsigned getEmergencySpillSlotSize(const MachineFunction &MF) const;
79
80   // Return the offset from the frame pointer of the emergency spill slot,
81   // which always fits within a 12-bit unsigned displacement field.
82   // Only valid if getEmergencySpillSlotSize(MF) returns nonzero.
83   unsigned getEmergencySpillSlotOffset(const MachineFunction &MF) const;
84
85   // Return the byte offset from the incoming stack pointer of Reg's
86   // ABI-defined save slot.  Return 0 if no slot is defined for Reg.
87   unsigned getRegSpillOffset(unsigned Reg) const {
88     return RegSpillOffsets[Reg];
89   }
90 };
91 } // end namespace llvm
92
93 #endif