LLVM 20.0.0git
|
#include "AArch64InstrInfo.h"
#include "AArch64Subtarget.h"
#include "MCTargetDesc/AArch64InstPrinter.h"
#include "Utils/AArch64BaseInfo.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <sstream>
Go to the source code of this file.
Macros | |
#define | AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME "AArch64 homogeneous prolog/epilog lowering pass" |
Enumerations | |
enum | FrameHelperType { Prolog , PrologFrame , Epilog , EpilogTail } |
Functions | |
INITIALIZE_PASS (AArch64LowerHomogeneousPrologEpilog, "aarch64-lower-homogeneous-prolog-epilog", AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME, false, false) bool AArch64LowerHomogeneousPrologEpilog | |
static std::string | getFrameHelperName (SmallVectorImpl< unsigned > &Regs, FrameHelperType Type, unsigned FpOffset) |
Return a frame helper name with the given CSRs and the helper type. | |
static MachineFunction & | createFrameHelperMachineFunction (Module *M, MachineModuleInfo *MMI, StringRef Name) |
Create a Function for the unique frame helper with the given name. | |
static void | emitStore (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator Pos, const TargetInstrInfo &TII, unsigned Reg1, unsigned Reg2, int Offset, bool IsPreDec) |
Emit a store-pair instruction for frame-setup. | |
static void | emitLoad (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator Pos, const TargetInstrInfo &TII, unsigned Reg1, unsigned Reg2, int Offset, bool IsPostDec) |
Emit a load-pair instruction for frame-destroy. | |
static Function * | getOrCreateFrameHelper (Module *M, MachineModuleInfo *MMI, SmallVectorImpl< unsigned > &Regs, FrameHelperType Type, unsigned FpOffset=0) |
Return a unique function if a helper can be formed with the given Regs and frame type. | |
static bool | shouldUseFrameHelper (MachineBasicBlock &MBB, MachineBasicBlock::iterator &NextMBBI, SmallVectorImpl< unsigned > &Regs, FrameHelperType Type) |
This function checks if a frame helper should be used for HOM_Prolog/HOM_Epilog pseudo instruction expansion. | |
Variables | |
cl::opt< int > | FrameHelperSizeThreshold ("frame-helper-size-threshold", cl::init(2), cl::Hidden, cl::desc("The minimum number of instructions that are outlined in a frame " "helper (default = 2)")) |
#define AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME "AArch64 homogeneous prolog/epilog lowering pass" |
Definition at line 35 of file AArch64LowerHomogeneousPrologEpilog.cpp.
enum FrameHelperType |
Enumerator | |
---|---|
Prolog | |
PrologFrame | |
Epilog | |
EpilogTail |
Definition at line 127 of file AArch64LowerHomogeneousPrologEpilog.cpp.
|
static |
Create a Function for the unique frame helper with the given name.
Return a newly created MachineFunction with an empty MachineBasicBlock.
Definition at line 161 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References assert(), llvm::MachineFunction::begin(), llvm::CallingConv::C, llvm::Function::Create(), llvm::BasicBlock::Create(), llvm::MachineFunction::CreateMachineBasicBlock(), llvm::IRBuilderBase::CreateRetVoid(), F, llvm::MachineRegisterInfo::freezeReservedRegs(), llvm::MachineModuleInfo::getOrCreateMachineFunction(), llvm::MachineFunction::getProperties(), llvm::MachineFunction::getRegInfo(), llvm::Type::getVoidTy(), llvm::MachineFunction::insert(), llvm::GlobalValue::LinkOnceODRLinkage, MBB, Name, llvm::MachineFunctionProperties::reset(), and llvm::MachineFunctionProperties::set().
Referenced by getOrCreateFrameHelper().
|
static |
Emit a load-pair instruction for frame-destroy.
If Reg2 is AArch64::NoRegister, emit LDR instead.
Definition at line 244 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), assert(), llvm::BuildMI(), contains(), llvm::MachineInstr::FrameDestroy, llvm::getDefRegState(), llvm::AArch64InstrInfo::getMemOpInfo(), MBB, llvm::Offset, llvm::MachineInstrBuilder::setMIFlag(), Success, and TII.
Referenced by getOrCreateFrameHelper().
|
static |
Emit a store-pair instruction for frame-setup.
If Reg2 is AArch64::NoRegister, emit STR instead.
Definition at line 203 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), assert(), llvm::BuildMI(), contains(), llvm::MachineInstr::FrameSetup, llvm::AArch64InstrInfo::getMemOpInfo(), MBB, llvm::Offset, llvm::MachineInstrBuilder::setMIFlag(), Success, and TII.
Referenced by getOrCreateFrameHelper().
|
static |
Return a frame helper name with the given CSRs and the helper type.
For instance, a prolog helper that saves x19 and x20 is named as OUTLINED_FUNCTION_PROLOG_x19x20.
Definition at line 132 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References Epilog, EpilogTail, llvm::AArch64InstPrinter::getRegisterName(), Prolog, and PrologFrame.
Referenced by getOrCreateFrameHelper().
|
static |
Return a unique function if a helper can be formed with the given Regs and frame type.
1) _OUTLINED_FUNCTION_PROLOG_x30x29x19x20x21x22: stp x22, x21, [sp, #-32]! ; x29/x30 has been stored at the caller stp x20, x19, [sp, #16] ret
2) _OUTLINED_FUNCTION_PROLOG_FRAME32_x30x29x19x20x21x22: stp x22, x21, [sp, #-32]! ; x29/x30 has been stored at the caller stp x20, x19, [sp, #16] add fp, sp, #32 ret
3) _OUTLINED_FUNCTION_EPILOG_x30x29x19x20x21x22: mov x16, x30 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] ldp x22, x21, [sp], #48 ret x16
4) _OUTLINED_FUNCTION_EPILOG_TAIL_x30x29x19x20x21x22: ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] ldp x22, x21, [sp], #48 ret
M | module |
MMI | machine module info |
Regs | callee save regs that the helper will handle |
Type | frame helper type |
Definition at line 313 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::MachineInstrBuilder::addUse(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::MachineFunction::begin(), llvm::BuildMI(), createFrameHelperMachineFunction(), emitLoad(), emitStore(), llvm::MachineBasicBlock::end(), Epilog, EpilogTail, F, llvm::find(), llvm::MachineInstr::FrameSetup, getFrameHelperName(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getSubtarget(), I, MBB, Name, Prolog, PrologFrame, llvm::MachineInstrBuilder::setMIFlag(), llvm::SmallVectorBase< Size_T >::size(), Size, and TII.
INITIALIZE_PASS | ( | AArch64LowerHomogeneousPrologEpilog | , |
"aarch64-lower-homogeneous-prolog-epilog" | , | ||
AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME | , | ||
false | , | ||
false | |||
) |
Definition at line 100 of file AArch64LowerHomogeneousPrologEpilog.cpp.
|
static |
This function checks if a frame helper should be used for HOM_Prolog/HOM_Epilog pseudo instruction expansion.
MBB | machine basic block |
NextMBBI | next instruction following HOM_Prolog/HOM_Epilog |
Regs | callee save registers that are saved or restored. |
Type | frame helper type |
Definition at line 395 of file AArch64LowerHomogeneousPrologEpilog.cpp.
References assert(), llvm::MachineBasicBlock::end(), Epilog, EpilogTail, FrameHelperSizeThreshold, llvm::MachineBasicBlock::getParent(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::is_contained(), MBB, Prolog, PrologFrame, llvm::SmallVectorBase< Size_T >::size(), llvm::MachineBasicBlock::successors(), and TRI.
cl::opt< int > FrameHelperSizeThreshold("frame-helper-size-threshold", cl::init(2), cl::Hidden, cl::desc("The minimum number of instructions that are outlined in a frame " "helper (default = 2)")) | ( | "frame-helper-size-threshold" | , |
cl::init(2) | , | ||
cl::Hidden | , | ||
cl::desc("The minimum number of instructions that are outlined in a frame " "helper (default = 2)") | |||
) |
Referenced by shouldUseFrameHelper().