Home | History | Annotate | Download | only in PowerPC
      1 //===-- PPCFrameLowering.h - Define frame lowering for PowerPC --*- 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 //
     11 //===----------------------------------------------------------------------===//
     12 
     13 #ifndef LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H
     14 #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H
     15 
     16 #include "PPC.h"
     17 #include "llvm/ADT/STLExtras.h"
     18 #include "llvm/Target/TargetFrameLowering.h"
     19 #include "llvm/Target/TargetMachine.h"
     20 
     21 namespace llvm {
     22 class PPCSubtarget;
     23 
     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;
     31 
     32 public:
     33   PPCFrameLowering(const PPCSubtarget &STI);
     34 
     35   unsigned determineFrameLayout(MachineFunction &MF,
     36                                 bool UpdateMF = true,
     37                                 bool UseEstimate = false) const;
     38 
     39   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
     40   /// the function.
     41   void emitPrologue(MachineFunction &MF) const override;
     42   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
     43 
     44   bool hasFP(const MachineFunction &MF) const override;
     45   bool needsFP(const MachineFunction &MF) const;
     46   void replaceFPWithRealFP(MachineFunction &MF) const;
     47 
     48   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
     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;
     53 
     54   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
     55                                  MachineBasicBlock::iterator MI,
     56                                  const std::vector<CalleeSavedInfo> &CSI,
     57                                  const TargetRegisterInfo *TRI) const override;
     58 
     59   void eliminateCallFramePseudoInstr(MachineFunction &MF,
     60                                   MachineBasicBlock &MBB,
     61                                   MachineBasicBlock::iterator I) const override;
     62 
     63   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
     64                                   MachineBasicBlock::iterator MI,
     65                                   const std::vector<CalleeSavedInfo> &CSI,
     66                                   const TargetRegisterInfo *TRI) const override;
     67 
     68   /// targetHandlesStackFrameRounding - Returns true if the target is
     69   /// responsible for rounding up the stack frame (probably at emitPrologue
     70   /// time).
     71   bool targetHandlesStackFrameRounding() const override { return true; }
     72 
     73   /// getReturnSaveOffset - Return the previous frame offset to save the
     74   /// return address.
     75   unsigned getReturnSaveOffset() const { return ReturnSaveOffset; }
     76 
     77   /// getTOCSaveOffset - Return the previous frame offset to save the
     78   /// TOC register -- 64-bit SVR4 ABI only.
     79   unsigned getTOCSaveOffset() const { return TOCSaveOffset; }
     80 
     81   /// getFramePointerSaveOffset - Return the previous frame offset to save the
     82   /// frame pointer.
     83   unsigned getFramePointerSaveOffset() const { return FramePointerSaveOffset; }
     84 
     85   /// getBasePointerSaveOffset - Return the previous frame offset to save the
     86   /// base pointer.
     87   unsigned getBasePointerSaveOffset() const { return BasePointerSaveOffset; }
     88 
     89   /// getLinkageSize - Return the size of the PowerPC ABI linkage area.
     90   ///
     91   unsigned getLinkageSize() const { return LinkageSize; }
     92 
     93   const SpillSlot *
     94   getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
     95 };
     96 } // End llvm namespace
     97 
     98 #endif
     99