1 //===-- PPCFrameLowering.h - Define frame lowering for PowerPC --*- 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 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #ifndef POWERPC_FRAMEINFO_H
14 #define POWERPC_FRAMEINFO_H
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/Target/TargetFrameLowering.h"
19 #include "llvm/Target/TargetMachine.h"
24 class PPCFrameLowering: public TargetFrameLowering {
25 const PPCSubtarget &Subtarget;
28 PPCFrameLowering(const PPCSubtarget &STI);
30 unsigned determineFrameLayout(MachineFunction &MF,
32 bool UseEstimate = false) const;
34 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
36 void emitPrologue(MachineFunction &MF) const override;
37 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
39 bool hasFP(const MachineFunction &MF) const override;
40 bool needsFP(const MachineFunction &MF) const;
41 void replaceFPWithRealFP(MachineFunction &MF) const;
43 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
44 RegScavenger *RS = nullptr) const override;
45 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
46 RegScavenger *RS = nullptr) const override;
47 void addScavengingSpillSlot(MachineFunction &MF, RegScavenger *RS) const;
49 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
50 MachineBasicBlock::iterator MI,
51 const std::vector<CalleeSavedInfo> &CSI,
52 const TargetRegisterInfo *TRI) const override;
54 void eliminateCallFramePseudoInstr(MachineFunction &MF,
55 MachineBasicBlock &MBB,
56 MachineBasicBlock::iterator I) const override;
58 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
59 MachineBasicBlock::iterator MI,
60 const std::vector<CalleeSavedInfo> &CSI,
61 const TargetRegisterInfo *TRI) const override;
63 /// targetHandlesStackFrameRounding - Returns true if the target is
64 /// responsible for rounding up the stack frame (probably at emitPrologue
66 bool targetHandlesStackFrameRounding() const override { return true; }
68 /// getReturnSaveOffset - Return the previous frame offset to save the
70 static unsigned getReturnSaveOffset(bool isPPC64, bool isDarwinABI) {
72 return isPPC64 ? 16 : 8;
74 return isPPC64 ? 16 : 4;
77 /// getFramePointerSaveOffset - Return the previous frame offset to save the
79 static unsigned getFramePointerSaveOffset(bool isPPC64, bool isDarwinABI) {
80 // For the Darwin ABI:
81 // We cannot use the TOC save slot (offset +20) in the PowerPC linkage area
82 // for saving the frame pointer (if needed.) While the published ABI has
83 // not used this slot since at least MacOSX 10.2, there is older code
84 // around that does use it, and that needs to continue to work.
86 return isPPC64 ? -8U : -4U;
88 // SVR4 ABI: First slot in the general register save area.
89 return isPPC64 ? -8U : -4U;
92 /// getBasePointerSaveOffset - Return the previous frame offset to save the
94 static unsigned getBasePointerSaveOffset(bool isPPC64, bool isDarwinABI) {
96 return isPPC64 ? -16U : -8U;
98 // SVR4 ABI: First slot in the general register save area.
99 return isPPC64 ? -16U : -8U;
102 /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
104 static unsigned getLinkageSize(bool isPPC64, bool isDarwinABI) {
105 if (isDarwinABI || isPPC64)
106 return 6 * (isPPC64 ? 8 : 4);
112 /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
114 static unsigned getMinCallArgumentsSize(bool isPPC64, bool isDarwinABI);
116 getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
117 static unsigned getMinCallFrameSize(bool isPPC64, bool isDarwinABI);
119 } // End llvm namespace