1 //==-- AArch64FrameLowering.h - TargetFrameLowering for AArch64 --*- 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 
14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H
15 #define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H
16 
17 #include "llvm/CodeGen/TargetFrameLowering.h"
18 
19 namespace llvm {
20 
21 class AArch64FrameLowering : public TargetFrameLowering {
22 public:
AArch64FrameLowering()23   explicit AArch64FrameLowering()
24       : TargetFrameLowering(StackGrowsDown, 16, 0, 16,
25                             true /*StackRealignable*/) {}
26 
27   void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
28                                  MachineBasicBlock::iterator MBBI) const;
29 
30   MachineBasicBlock::iterator
31   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
32                                 MachineBasicBlock::iterator I) const override;
33 
34   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
35   /// the function.
36   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
37   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
38 
39   bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;
40 
41   int getFrameIndexReference(const MachineFunction &MF, int FI,
42                              unsigned &FrameReg) const override;
43   int resolveFrameIndexReference(const MachineFunction &MF, int FI,
44                                  unsigned &FrameReg,
45                                  bool PreferFP = false) const;
46   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
47                                  MachineBasicBlock::iterator MI,
48                                  const std::vector<CalleeSavedInfo> &CSI,
49                                  const TargetRegisterInfo *TRI) const override;
50 
51   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
52                                   MachineBasicBlock::iterator MI,
53                                   std::vector<CalleeSavedInfo> &CSI,
54                                   const TargetRegisterInfo *TRI) const override;
55 
56   /// Can this function use the red zone for local allocations.
57   bool canUseRedZone(const MachineFunction &MF) const;
58 
59   bool hasFP(const MachineFunction &MF) const override;
60   bool hasReservedCallFrame(const MachineFunction &MF) const override;
61 
62   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
63                             RegScavenger *RS) const override;
64 
65   /// Returns true if the target will correctly handle shrink wrapping.
enableShrinkWrapping(const MachineFunction & MF)66   bool enableShrinkWrapping(const MachineFunction &MF) const override {
67     return true;
68   }
69 
70   bool enableStackSlotScavenging(const MachineFunction &MF) const override;
71 
72   void processFunctionBeforeFrameFinalized(MachineFunction &MF,
73                                              RegScavenger *RS) const override;
74 
75   unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override;
76 
77   unsigned getWinEHFuncletFrameSize(const MachineFunction &MF) const;
78 
79   int getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI,
80                                      unsigned &FrameReg,
81                                      bool IgnoreSPUpdates) const override;
82 
83 private:
84   bool shouldCombineCSRLocalStackBump(MachineFunction &MF,
85                                       unsigned StackBumpBytes) const;
86 };
87 
88 } // End llvm namespace
89 
90 #endif
91