blob: 08321e05a37866f21544f67d8f1de4ec0d69c991 [file] [log] [blame]
Ulrich Weigand1d09d562013-05-06 16:15:19 +00001//===-- 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
17namespace llvm {
18class SystemZTargetMachine;
19class SystemZSubtarget;
20
21class SystemZFrameLowering : public TargetFrameLowering {
22 IndexedMap<unsigned> RegSpillOffsets;
23
24protected:
25 const SystemZTargetMachine &TM;
26 const SystemZSubtarget &STI;
27
28public:
29 SystemZFrameLowering(const SystemZTargetMachine &tm,
30 const SystemZSubtarget &sti);
31
Richard Sandiford52c28b02013-07-03 09:11:00 +000032 // Override TargetFrameLowering.
33 virtual const SpillSlot *getCalleeSavedSpillSlots(unsigned &NumEntries) const
34 LLVM_OVERRIDE;
Ulrich Weigand1d09d562013-05-06 16:15:19 +000035 virtual void
36 processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
37 RegScavenger *RS) const LLVM_OVERRIDE;
38 virtual bool
39 spillCalleeSavedRegisters(MachineBasicBlock &MBB,
40 MachineBasicBlock::iterator MBBI,
41 const std::vector<CalleeSavedInfo> &CSI,
42 const TargetRegisterInfo *TRI) const
43 LLVM_OVERRIDE;
44 virtual bool
45 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MBBII,
47 const std::vector<CalleeSavedInfo> &CSI,
48 const TargetRegisterInfo *TRI) const
49 LLVM_OVERRIDE;
50 virtual void emitPrologue(MachineFunction &MF) const LLVM_OVERRIDE;
51 virtual void emitEpilogue(MachineFunction &MF,
52 MachineBasicBlock &MBB) const LLVM_OVERRIDE;
53 virtual bool hasFP(const MachineFunction &MF) const LLVM_OVERRIDE;
54 virtual int getFrameIndexOffset(const MachineFunction &MF,
55 int FI) const LLVM_OVERRIDE;
56 virtual bool hasReservedCallFrame(const MachineFunction &MF) const
57 LLVM_OVERRIDE;
58 virtual void
59 eliminateCallFramePseudoInstr(MachineFunction &MF,
60 MachineBasicBlock &MBB,
61 MachineBasicBlock::iterator MI) const
62 LLVM_OVERRIDE;
63
Ulrich Weigand1d09d562013-05-06 16:15:19 +000064 // Return the number of bytes in the callee-allocated part of the frame.
65 uint64_t getAllocatedStackSize(const MachineFunction &MF) const;
66
67 // Return the number of frame bytes that should be reserved for
68 // an emergency spill slot, for use by the register scaveneger.
69 // Return 0 if register scaveging won't be needed.
70 unsigned getEmergencySpillSlotSize(const MachineFunction &MF) const;
71
72 // Return the offset from the frame pointer of the emergency spill slot,
73 // which always fits within a 12-bit unsigned displacement field.
74 // Only valid if getEmergencySpillSlotSize(MF) returns nonzero.
75 unsigned getEmergencySpillSlotOffset(const MachineFunction &MF) const;
76
77 // Return the byte offset from the incoming stack pointer of Reg's
78 // ABI-defined save slot. Return 0 if no slot is defined for Reg.
79 unsigned getRegSpillOffset(unsigned Reg) const {
80 return RegSpillOffsets[Reg];
81 }
82};
83} // end namespace llvm
84
85#endif