1 //===-- SystemZFrameLowering.h - Frame lowering for SystemZ -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SYSTEMZFRAMELOWERING_H
11 #define SYSTEMZFRAMELOWERING_H
13 #include "SystemZSubtarget.h"
14 #include "llvm/ADT/IndexedMap.h"
15 #include "llvm/Target/TargetFrameLowering.h"
18 class SystemZTargetMachine;
19 class SystemZSubtarget;
21 class SystemZFrameLowering : public TargetFrameLowering {
22 IndexedMap<unsigned> RegSpillOffsets;
25 const SystemZTargetMachine &TM;
26 const SystemZSubtarget &STI;
29 SystemZFrameLowering(const SystemZTargetMachine &tm,
30 const SystemZSubtarget &sti);
32 // Override FrameLowering.
34 processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
35 RegScavenger *RS) const LLVM_OVERRIDE;
37 spillCalleeSavedRegisters(MachineBasicBlock &MBB,
38 MachineBasicBlock::iterator MBBI,
39 const std::vector<CalleeSavedInfo> &CSI,
40 const TargetRegisterInfo *TRI) const
43 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
44 MachineBasicBlock::iterator MBBII,
45 const std::vector<CalleeSavedInfo> &CSI,
46 const TargetRegisterInfo *TRI) const
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
57 eliminateCallFramePseudoInstr(MachineFunction &MF,
58 MachineBasicBlock &MBB,
59 MachineBasicBlock::iterator MI) const
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;
72 // Return the number of bytes in the callee-allocated part of the frame.
73 uint64_t getAllocatedStackSize(const MachineFunction &MF) const;
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;
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;
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];
91 } // end namespace llvm