LLVM 22.0.0git
AArch64PrologueEpilogue.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file contains the declaration of the AArch64PrologueEmitter class,
11/// which is is used to emit the prologue on AArch64.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64PROLOGUEEPILOGUE_H
16#define LLVM_LIB_TARGET_AARCH64_AARCH64PROLOGUEEPILOGUE_H
17
18#include "AArch64RegisterInfo.h"
21
22namespace llvm {
23
27
28/// A helper class for emitting the prologue. Substantial new functionality
29/// should be factored into a new method. Where possible "emit*" methods should
30/// be const, and any flags that change how the prologue is emitted should be
31/// set in the constructor.
33public:
35 const AArch64FrameLowering &AFL);
36
37 /// Emit the prologue.
38 void emitPrologue();
39
41 MF.setHasWinCFI(HasWinCFI);
42#ifndef NDEBUG
43 verifyPrologueClobbers();
44#endif
45 }
46
47private:
48 void emitShadowCallStackPrologue(MachineBasicBlock::iterator MBBI,
49 const DebugLoc &DL) const;
50
51 void emitSwiftAsyncContextFramePointer(MachineBasicBlock::iterator MBBI,
52 const DebugLoc &DL) const;
53
54 void emitEmptyStackFramePrologue(int64_t NumBytes,
56 const DebugLoc &DL) const;
57
58 void emitFramePointerSetup(MachineBasicBlock::iterator MBBI,
59 const DebugLoc &DL, unsigned FixedObject);
60
61 void emitDefineCFAWithFP(MachineBasicBlock::iterator MBBI,
62 unsigned FixedObject) const;
63
64 void emitWindowsStackProbe(MachineBasicBlock::iterator MBBI,
65 const DebugLoc &DL, int64_t &NumBytes,
66 int64_t RealignmentPadding) const;
67
68 void emitCalleeSavedGPRLocations(MachineBasicBlock::iterator MBBI) const;
69 void emitCalleeSavedSVELocations(MachineBasicBlock::iterator MBBI) const;
70
71 void determineLocalsStackSize(uint64_t StackSize, uint64_t PrologueSaveSize);
72
75
76 const Function &F;
77 const MachineFrameInfo &MFI;
78 const AArch64Subtarget &Subtarget;
79 const AArch64FrameLowering &AFL;
81
82#ifndef NDEBUG
83 mutable LivePhysRegs LiveRegs{RegInfo};
84 MachineBasicBlock::iterator PrologueEndI;
85
86 void collectBlockLiveins();
87 void verifyPrologueClobbers() const;
88#endif
89
90 // Prologue flags. These generally should not change outside of the
91 // constructor. Two exceptions are "CombineSPBump" which is set in
92 // determineLocalsStackSize, and "NeedsWinCFI" which is set in
93 // emitFramePointerSetup.
94 bool EmitCFI = false;
95 bool EmitAsyncCFI = false;
96 bool HasFP = false;
97 bool IsFunclet = false;
98 bool CombineSPBump = false;
99 bool HomPrologEpilog = false;
100 bool NeedsWinCFI = false;
101
102 // Note: "HasWinCFI" is mutable as it can change in any "emit" function.
103 mutable bool HasWinCFI = false;
104
105 const TargetInstrInfo *TII = nullptr;
106 AArch64FunctionInfo *AFI = nullptr;
107};
108
109} // namespace llvm
110
111#endif
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define F(x, y, z)
Definition MD5.cpp:55
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
AArch64PrologueEmitter(MachineFunction &MF, MachineBasicBlock &MBB, const AArch64FrameLowering &AFL)
A debug info location.
Definition DebugLoc.h:124
A set of physical registers with utility functions to track liveness when walking backward/forward th...
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
This is an optimization pass for GlobalISel generic memory operations.