SystemZFrameLowering.h revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
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
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
32  // Override TargetFrameLowering.
33  bool isFPCloseToIncomingSP() const override { return false; }
34  const SpillSlot *getCalleeSavedSpillSlots(unsigned &NumEntries) const
35    override;
36  void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
37                                            RegScavenger *RS) const override;
38  bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
39                                 MachineBasicBlock::iterator MBBI,
40                                 const std::vector<CalleeSavedInfo> &CSI,
41                                 const TargetRegisterInfo *TRI) const override;
42  bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
43                                   MachineBasicBlock::iterator MBBII,
44                                   const std::vector<CalleeSavedInfo> &CSI,
45                                   const TargetRegisterInfo *TRI) const
46    override;
47  void processFunctionBeforeFrameFinalized(MachineFunction &MF,
48                                           RegScavenger *RS) const override;
49  void emitPrologue(MachineFunction &MF) const override;
50  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
51  bool hasFP(const MachineFunction &MF) const override;
52  int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;
53  bool hasReservedCallFrame(const MachineFunction &MF) const override;
54  void eliminateCallFramePseudoInstr(MachineFunction &MF,
55                                     MachineBasicBlock &MBB,
56                                     MachineBasicBlock::iterator MI) const
57    override;
58
59  // Return the number of bytes in the callee-allocated part of the frame.
60  uint64_t getAllocatedStackSize(const MachineFunction &MF) const;
61
62  // Return the byte offset from the incoming stack pointer of Reg's
63  // ABI-defined save slot.  Return 0 if no slot is defined for Reg.
64  unsigned getRegSpillOffset(unsigned Reg) const {
65    return RegSpillOffsets[Reg];
66  }
67};
68} // end namespace llvm
69
70#endif
71