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 LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H
14 #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_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;
26 const unsigned ReturnSaveOffset;
27 const unsigned TOCSaveOffset;
28 const unsigned FramePointerSaveOffset;
29 const unsigned LinkageSize;
30 const unsigned BasePointerSaveOffset;
33 PPCFrameLowering(const PPCSubtarget &STI);
35 unsigned determineFrameLayout(MachineFunction &MF,
37 bool UseEstimate = false) const;
39 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
41 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
42 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
44 bool hasFP(const MachineFunction &MF) const override;
45 bool needsFP(const MachineFunction &MF) const;
46 void replaceFPWithRealFP(MachineFunction &MF) const;
48 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
49 RegScavenger *RS = nullptr) const override;
50 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
51 RegScavenger *RS = nullptr) const override;
52 void addScavengingSpillSlot(MachineFunction &MF, RegScavenger *RS) const;
54 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
55 MachineBasicBlock::iterator MI,
56 const std::vector<CalleeSavedInfo> &CSI,
57 const TargetRegisterInfo *TRI) const override;
59 void eliminateCallFramePseudoInstr(MachineFunction &MF,
60 MachineBasicBlock &MBB,
61 MachineBasicBlock::iterator I) const override;
63 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
64 MachineBasicBlock::iterator MI,
65 const std::vector<CalleeSavedInfo> &CSI,
66 const TargetRegisterInfo *TRI) const override;
68 /// targetHandlesStackFrameRounding - Returns true if the target is
69 /// responsible for rounding up the stack frame (probably at emitPrologue
71 bool targetHandlesStackFrameRounding() const override { return true; }
73 /// getReturnSaveOffset - Return the previous frame offset to save the
75 unsigned getReturnSaveOffset() const { return ReturnSaveOffset; }
77 /// getTOCSaveOffset - Return the previous frame offset to save the
78 /// TOC register -- 64-bit SVR4 ABI only.
79 unsigned getTOCSaveOffset() const { return TOCSaveOffset; }
81 /// getFramePointerSaveOffset - Return the previous frame offset to save the
83 unsigned getFramePointerSaveOffset() const { return FramePointerSaveOffset; }
85 /// getBasePointerSaveOffset - Return the previous frame offset to save the
87 unsigned getBasePointerSaveOffset() const { return BasePointerSaveOffset; }
89 /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
91 unsigned getLinkageSize() const { return LinkageSize; }
94 getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
96 } // End llvm namespace