Path: blob/main/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64FrameLowering.h
35269 views
//==-- AArch64FrameLowering.h - TargetFrameLowering for AArch64 --*- C++ -*-==//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8//9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H13#define LLVM_LIB_TARGET_AARCH64_AARCH64FRAMELOWERING_H1415#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"16#include "llvm/CodeGen/TargetFrameLowering.h"17#include "llvm/Support/TypeSize.h"1819namespace llvm {2021class AArch64FrameLowering : public TargetFrameLowering {22public:23explicit AArch64FrameLowering()24: TargetFrameLowering(StackGrowsDown, Align(16), 0, Align(16),25true /*StackRealignable*/) {}2627void resetCFIToInitialState(MachineBasicBlock &MBB) const override;2829MachineBasicBlock::iterator30eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,31MachineBasicBlock::iterator I) const override;3233/// emitProlog/emitEpilog - These methods insert prolog and epilog code into34/// the function.35void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;36void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;3738bool enableCFIFixup(MachineFunction &MF) const override;3940bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;4142StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,43Register &FrameReg) const override;44StackOffset getFrameIndexReferenceFromSP(const MachineFunction &MF,45int FI) const override;46StackOffset resolveFrameIndexReference(const MachineFunction &MF, int FI,47Register &FrameReg, bool PreferFP,48bool ForSimm) const;49StackOffset resolveFrameOffsetReference(const MachineFunction &MF,50int64_t ObjectOffset, bool isFixed,51bool isSVE, Register &FrameReg,52bool PreferFP, bool ForSimm) const;53bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,54MachineBasicBlock::iterator MI,55ArrayRef<CalleeSavedInfo> CSI,56const TargetRegisterInfo *TRI) const override;5758bool59restoreCalleeSavedRegisters(MachineBasicBlock &MBB,60MachineBasicBlock::iterator MI,61MutableArrayRef<CalleeSavedInfo> CSI,62const TargetRegisterInfo *TRI) const override;6364/// Can this function use the red zone for local allocations.65bool canUseRedZone(const MachineFunction &MF) const;6667bool hasFP(const MachineFunction &MF) const override;68bool hasReservedCallFrame(const MachineFunction &MF) const override;6970bool assignCalleeSavedSpillSlots(MachineFunction &MF,71const TargetRegisterInfo *TRI,72std::vector<CalleeSavedInfo> &CSI,73unsigned &MinCSFrameIndex,74unsigned &MaxCSFrameIndex) const override;7576void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,77RegScavenger *RS) const override;7879/// Returns true if the target will correctly handle shrink wrapping.80bool enableShrinkWrapping(const MachineFunction &MF) const override {81return true;82}8384bool enableStackSlotScavenging(const MachineFunction &MF) const override;85TargetStackID::Value getStackIDForScalableVectors() const override;8687void processFunctionBeforeFrameFinalized(MachineFunction &MF,88RegScavenger *RS) const override;8990void91processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF,92RegScavenger *RS) const override;9394unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override;9596unsigned getWinEHFuncletFrameSize(const MachineFunction &MF) const;9798StackOffset99getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI,100Register &FrameReg,101bool IgnoreSPUpdates) const override;102StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF,103int FI) const override;104int getSEHFrameIndexOffset(const MachineFunction &MF, int FI) const;105106bool isSupportedStackID(TargetStackID::Value ID) const override {107switch (ID) {108default:109return false;110case TargetStackID::Default:111case TargetStackID::ScalableVector:112case TargetStackID::NoAlloc:113return true;114}115}116117bool isStackIdSafeForLocalArea(unsigned StackId) const override {118// We don't support putting SVE objects into the pre-allocated local119// frame block at the moment.120return StackId != TargetStackID::ScalableVector;121}122123void124orderFrameObjects(const MachineFunction &MF,125SmallVectorImpl<int> &ObjectsToAllocate) const override;126127private:128/// Returns true if a homogeneous prolog or epilog code can be emitted129/// for the size optimization. If so, HOM_Prolog/HOM_Epilog pseudo130/// instructions are emitted in place. When Exit block is given, this check is131/// for epilog.132bool homogeneousPrologEpilog(MachineFunction &MF,133MachineBasicBlock *Exit = nullptr) const;134135/// Returns true if CSRs should be paired.136bool producePairRegisters(MachineFunction &MF) const;137138bool shouldCombineCSRLocalStackBump(MachineFunction &MF,139uint64_t StackBumpBytes) const;140141int64_t estimateSVEStackObjectOffsets(MachineFrameInfo &MF) const;142int64_t assignSVEStackObjectOffsets(MachineFrameInfo &MF,143int &MinCSFrameIndex,144int &MaxCSFrameIndex) const;145bool shouldCombineCSRLocalStackBumpInEpilogue(MachineBasicBlock &MBB,146unsigned StackBumpBytes) const;147void emitCalleeSavedGPRLocations(MachineBasicBlock &MBB,148MachineBasicBlock::iterator MBBI) const;149void emitCalleeSavedSVELocations(MachineBasicBlock &MBB,150MachineBasicBlock::iterator MBBI) const;151void emitCalleeSavedGPRRestores(MachineBasicBlock &MBB,152MachineBasicBlock::iterator MBBI) const;153void emitCalleeSavedSVERestores(MachineBasicBlock &MBB,154MachineBasicBlock::iterator MBBI) const;155void allocateStackSpace(MachineBasicBlock &MBB,156MachineBasicBlock::iterator MBBI,157int64_t RealignmentPadding, StackOffset AllocSize,158bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFI,159StackOffset InitialOffset, bool FollowupAllocs) const;160/// Make a determination whether a Hazard slot is used and create it if161/// needed.162void determineStackHazardSlot(MachineFunction &MF,163BitVector &SavedRegs) const;164165/// Emit target zero call-used regs.166void emitZeroCallUsedRegs(BitVector RegsToZero,167MachineBasicBlock &MBB) const override;168169/// Replace a StackProbe stub (if any) with the actual probe code inline170void inlineStackProbe(MachineFunction &MF,171MachineBasicBlock &PrologueMBB) const override;172173void inlineStackProbeFixed(MachineBasicBlock::iterator MBBI,174Register ScratchReg, int64_t FrameSize,175StackOffset CFAOffset) const;176177MachineBasicBlock::iterator178inlineStackProbeLoopExactMultiple(MachineBasicBlock::iterator MBBI,179int64_t NegProbeSize,180Register TargetReg) const;181182void emitRemarks(const MachineFunction &MF,183MachineOptimizationRemarkEmitter *ORE) const override;184};185186} // End llvm namespace187188#endif189190191