LLVM 22.0.0git
AArch64LowerHomogeneousPrologEpilog.cpp File Reference

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 MachineFunctioncreateFrameHelperMachineFunction (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 FunctiongetOrCreateFrameHelper (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

static 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)"))

Macro Definition Documentation

◆ AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME

#define AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME    "AArch64 homogeneous prolog/epilog lowering pass"

Definition at line 32 of file AArch64LowerHomogeneousPrologEpilog.cpp.

Referenced by INITIALIZE_PASS().

Enumeration Type Documentation

◆ FrameHelperType

Enumerator
Prolog 
PrologFrame 
Epilog 
EpilogTail 

Definition at line 121 of file AArch64LowerHomogeneousPrologEpilog.cpp.

Function Documentation

◆ createFrameHelperMachineFunction()

◆ emitLoad()

◆ emitStore()

◆ getFrameHelperName()

std::string getFrameHelperName ( SmallVectorImpl< unsigned > & Regs,
FrameHelperType Type,
unsigned FpOffset )
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 126 of file AArch64LowerHomogeneousPrologEpilog.cpp.

References Epilog, EpilogTail, llvm::AArch64InstPrinter::getRegisterName(), Prolog, PrologFrame, and Reg.

Referenced by getOrCreateFrameHelper().

◆ getOrCreateFrameHelper()

Function * getOrCreateFrameHelper ( Module * M,
MachineModuleInfo * MMI,
SmallVectorImpl< unsigned > & Regs,
FrameHelperType Type,
unsigned FpOffset = 0 )
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

Parameters
Mmodule
MMImachine module info
Regscallee save regs that the helper will handle
Typeframe helper type
Returns
a helper function

Definition at line 303 of file AArch64LowerHomogeneousPrologEpilog.cpp.

References llvm::MachineInstrBuilder::addDef(), llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), llvm::MachineInstrBuilder::addUse(), assert(), llvm::MachineFunction::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::BuildMI(), createFrameHelperMachineFunction(), emitLoad(), emitStore(), Epilog, EpilogTail, F, llvm::find(), llvm::MachineInstr::FrameSetup, getFrameHelperName(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineFunction::getSubtarget(), I, MBB, Prolog, PrologFrame, llvm::MachineInstrBuilder::setMIFlag(), Size, llvm::SmallVectorTemplateCommon< T, typename >::size(), and TII.

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( AArch64LowerHomogeneousPrologEpilog ,
"aarch64-lower-homogeneous-prolog-epilog" ,
AARCH64_LOWER_HOMOGENEOUS_PROLOG_EPILOG_NAME ,
false ,
false  )

◆ shouldUseFrameHelper()

bool shouldUseFrameHelper ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator & NextMBBI,
SmallVectorImpl< unsigned > & Regs,
FrameHelperType Type )
static

This function checks if a frame helper should be used for HOM_Prolog/HOM_Epilog pseudo instruction expansion.

Parameters
MBBmachine basic block
NextMBBInext instruction following HOM_Prolog/HOM_Epilog
Regscallee save registers that are saved or restored.
Typeframe helper type
Returns
True if a use of helper is qualified.

Definition at line 385 of file AArch64LowerHomogeneousPrologEpilog.cpp.

References assert(), Epilog, EpilogTail, FrameHelperSizeThreshold, llvm::is_contained(), MBB, Prolog, PrologFrame, llvm::SmallVectorTemplateCommon< T, typename >::size(), and TRI.

Variable Documentation

◆ FrameHelperSizeThreshold

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)")  )
static

Referenced by shouldUseFrameHelper().