AArch64FrameLowering.h revision 355940
1//==-- AArch64FrameLowering.h - TargetFrameLowering for AArch64 --*- C++ -*-==// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H 14#define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H 15 16#include "llvm/CodeGen/TargetFrameLowering.h" 17 18namespace llvm { 19 20class AArch64FrameLowering : public TargetFrameLowering { 21public: 22 explicit AArch64FrameLowering() 23 : TargetFrameLowering(StackGrowsDown, 16, 0, 16, 24 true /*StackRealignable*/) {} 25 26 void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, 27 MachineBasicBlock::iterator MBBI) const; 28 29 MachineBasicBlock::iterator 30 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, 31 MachineBasicBlock::iterator I) const override; 32 33 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 34 /// the function. 35 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 36 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 37 38 bool canUseAsPrologue(const MachineBasicBlock &MBB) const override; 39 40 int getFrameIndexReference(const MachineFunction &MF, int FI, 41 unsigned &FrameReg) const override; 42 int resolveFrameIndexReference(const MachineFunction &MF, int FI, 43 unsigned &FrameReg, bool PreferFP, 44 bool ForSimm) const; 45 int resolveFrameOffsetReference(const MachineFunction &MF, int ObjectOffset, 46 bool isFixed, unsigned &FrameReg, 47 bool PreferFP, bool ForSimm) const; 48 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 49 MachineBasicBlock::iterator MI, 50 const std::vector<CalleeSavedInfo> &CSI, 51 const TargetRegisterInfo *TRI) const override; 52 53 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 54 MachineBasicBlock::iterator MI, 55 std::vector<CalleeSavedInfo> &CSI, 56 const TargetRegisterInfo *TRI) const override; 57 58 /// Can this function use the red zone for local allocations. 59 bool canUseRedZone(const MachineFunction &MF) const; 60 61 bool hasFP(const MachineFunction &MF) const override; 62 bool hasReservedCallFrame(const MachineFunction &MF) const override; 63 64 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, 65 RegScavenger *RS) const override; 66 67 /// Returns true if the target will correctly handle shrink wrapping. 68 bool enableShrinkWrapping(const MachineFunction &MF) const override { 69 return true; 70 } 71 72 bool enableStackSlotScavenging(const MachineFunction &MF) const override; 73 74 void processFunctionBeforeFrameFinalized(MachineFunction &MF, 75 RegScavenger *RS) const override; 76 77 unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override; 78 79 unsigned getWinEHFuncletFrameSize(const MachineFunction &MF) const; 80 81 int getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, 82 unsigned &FrameReg, 83 bool IgnoreSPUpdates) const override; 84 int getNonLocalFrameIndexReference(const MachineFunction &MF, 85 int FI) const override; 86 int getSEHFrameIndexOffset(const MachineFunction &MF, int FI) const; 87 88private: 89 bool shouldCombineCSRLocalStackBump(MachineFunction &MF, 90 unsigned StackBumpBytes) const; 91}; 92 93} // End llvm namespace 94 95#endif 96