LLVM 20.0.0git
Macros | Enumerations | Functions | Variables
AArch64LowerHomogeneousPrologEpilog.cpp File Reference
#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 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

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 35 of file AArch64LowerHomogeneousPrologEpilog.cpp.

Enumeration Type Documentation

◆ FrameHelperType

Enumerator
Prolog 
PrologFrame 
Epilog 
EpilogTail 

Definition at line 127 of file AArch64LowerHomogeneousPrologEpilog.cpp.

Function Documentation

◆ createFrameHelperMachineFunction()

static MachineFunction & createFrameHelperMachineFunction ( Module M,
MachineModuleInfo MMI,
StringRef  Name 
)
static

◆ emitLoad()

static void emitLoad ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  Pos,
const TargetInstrInfo TII,
unsigned  Reg1,
unsigned  Reg2,
int  Offset,
bool  IsPostDec 
)
static

◆ emitStore()

static void emitStore ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  Pos,
const TargetInstrInfo TII,
unsigned  Reg1,
unsigned  Reg2,
int  Offset,
bool  IsPreDec 
)
static

◆ getFrameHelperName()

static 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 132 of file AArch64LowerHomogeneousPrologEpilog.cpp.

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

Referenced by getOrCreateFrameHelper().

◆ getOrCreateFrameHelper()

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

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

Definition at line 100 of file AArch64LowerHomogeneousPrologEpilog.cpp.

◆ shouldUseFrameHelper()

static 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 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.

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

Referenced by shouldUseFrameHelper().