xref: /aosp_15_r20/external/llvm/lib/Target/AArch64/AArch64FrameLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //==-- AArch64FrameLowering.h - TargetFrameLowering for AArch64 --*- C++ -*-==//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker //
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetFrameLowering.h"
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker namespace llvm {
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker class AArch64FrameLowering : public TargetFrameLowering {
22*9880d681SAndroid Build Coastguard Worker public:
AArch64FrameLowering()23*9880d681SAndroid Build Coastguard Worker   explicit AArch64FrameLowering()
24*9880d681SAndroid Build Coastguard Worker       : TargetFrameLowering(StackGrowsDown, 16, 0, 16,
25*9880d681SAndroid Build Coastguard Worker                             true /*StackRealignable*/) {}
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker   void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
28*9880d681SAndroid Build Coastguard Worker                                  MachineBasicBlock::iterator MBBI) const;
29*9880d681SAndroid Build Coastguard Worker 
30*9880d681SAndroid Build Coastguard Worker   MachineBasicBlock::iterator
31*9880d681SAndroid Build Coastguard Worker   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
32*9880d681SAndroid Build Coastguard Worker                                 MachineBasicBlock::iterator I) const override;
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
35*9880d681SAndroid Build Coastguard Worker   /// the function.
36*9880d681SAndroid Build Coastguard Worker   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
37*9880d681SAndroid Build Coastguard Worker   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
38*9880d681SAndroid Build Coastguard Worker 
39*9880d681SAndroid Build Coastguard Worker   bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;
40*9880d681SAndroid Build Coastguard Worker 
41*9880d681SAndroid Build Coastguard Worker   int getFrameIndexReference(const MachineFunction &MF, int FI,
42*9880d681SAndroid Build Coastguard Worker                              unsigned &FrameReg) const override;
43*9880d681SAndroid Build Coastguard Worker   int resolveFrameIndexReference(const MachineFunction &MF, int FI,
44*9880d681SAndroid Build Coastguard Worker                                  unsigned &FrameReg,
45*9880d681SAndroid Build Coastguard Worker                                  bool PreferFP = false) const;
46*9880d681SAndroid Build Coastguard Worker   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
47*9880d681SAndroid Build Coastguard Worker                                  MachineBasicBlock::iterator MI,
48*9880d681SAndroid Build Coastguard Worker                                  const std::vector<CalleeSavedInfo> &CSI,
49*9880d681SAndroid Build Coastguard Worker                                  const TargetRegisterInfo *TRI) const override;
50*9880d681SAndroid Build Coastguard Worker 
51*9880d681SAndroid Build Coastguard Worker   bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
52*9880d681SAndroid Build Coastguard Worker                                   MachineBasicBlock::iterator MI,
53*9880d681SAndroid Build Coastguard Worker                                   const std::vector<CalleeSavedInfo> &CSI,
54*9880d681SAndroid Build Coastguard Worker                                   const TargetRegisterInfo *TRI) const override;
55*9880d681SAndroid Build Coastguard Worker 
56*9880d681SAndroid Build Coastguard Worker   /// \brief Can this function use the red zone for local allocations.
57*9880d681SAndroid Build Coastguard Worker   bool canUseRedZone(const MachineFunction &MF) const;
58*9880d681SAndroid Build Coastguard Worker 
59*9880d681SAndroid Build Coastguard Worker   bool hasFP(const MachineFunction &MF) const override;
60*9880d681SAndroid Build Coastguard Worker   bool hasReservedCallFrame(const MachineFunction &MF) const override;
61*9880d681SAndroid Build Coastguard Worker 
62*9880d681SAndroid Build Coastguard Worker   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
63*9880d681SAndroid Build Coastguard Worker                             RegScavenger *RS) const override;
64*9880d681SAndroid Build Coastguard Worker 
65*9880d681SAndroid Build Coastguard Worker   /// Returns true if the target will correctly handle shrink wrapping.
enableShrinkWrapping(const MachineFunction & MF)66*9880d681SAndroid Build Coastguard Worker   bool enableShrinkWrapping(const MachineFunction &MF) const override {
67*9880d681SAndroid Build Coastguard Worker     return true;
68*9880d681SAndroid Build Coastguard Worker   }
69*9880d681SAndroid Build Coastguard Worker 
70*9880d681SAndroid Build Coastguard Worker   bool enableStackSlotScavenging(const MachineFunction &MF) const override;
71*9880d681SAndroid Build Coastguard Worker 
72*9880d681SAndroid Build Coastguard Worker private:
73*9880d681SAndroid Build Coastguard Worker   bool shouldCombineCSRLocalStackBump(MachineFunction &MF,
74*9880d681SAndroid Build Coastguard Worker                                       unsigned StackBumpBytes) const;
75*9880d681SAndroid Build Coastguard Worker };
76*9880d681SAndroid Build Coastguard Worker 
77*9880d681SAndroid Build Coastguard Worker } // End llvm namespace
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker #endif
80