LLVM 22.0.0git
Macros | Functions | Variables
RISCVFrameLowering.cpp File Reference
#include "RISCVFrameLowering.h"
#include "MCTargetDesc/RISCVBaseInfo.h"
#include "RISCVMachineFunctionInfo.h"
#include "RISCVSubtarget.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/CFIInstBuilder.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/LEB128.h"
#include <algorithm>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "riscv-frame"
 

Functions

static Align getABIStackAlignment (RISCVABI::ABI ABI)
 
static bool needsDwarfCFI (const MachineFunction &MF)
 Returns true if DWARF CFI instructions ("frame moves") should be emitted.
 
static void emitSCSPrologue (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL)
 
static void emitSCSEpilogue (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL)
 
static void emitSiFiveCLICStackSwap (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL)
 
static void createSiFivePreemptibleInterruptFrameEntries (MachineFunction &MF, RISCVMachineFunctionInfo &RVFI)
 
static void emitSiFiveCLICPreemptibleSaves (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL)
 
static void emitSiFiveCLICPreemptibleRestores (MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL)
 
static int getLibCallID (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static const chargetSpillLibCallName (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static const chargetRestoreLibCallName (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static unsigned getNumPushPopRegs (const std::vector< CalleeSavedInfo > &CSI)
 
static SmallVector< CalleeSavedInfo, 8 > getUnmanagedCSI (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static SmallVector< CalleeSavedInfo, 8 > getRVVCalleeSavedInfo (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static SmallVector< CalleeSavedInfo, 8 > getPushOrLibCallsSavedInfo (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static SmallVector< CalleeSavedInfo, 8 > getQCISavedInfo (const MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI)
 
static void appendScalableVectorExpression (const TargetRegisterInfo &TRI, SmallVectorImpl< char > &Expr, int FixedOffset, int ScalableOffset, llvm::raw_string_ostream &Comment)
 
static MCCFIInstruction createDefCFAExpression (const TargetRegisterInfo &TRI, Register Reg, uint64_t FixedOffset, uint64_t ScalableOffset)
 
static MCCFIInstruction createDefCFAOffset (const TargetRegisterInfo &TRI, Register Reg, uint64_t FixedOffset, uint64_t ScalableOffset)
 
static bool isPush (unsigned Opcode)
 
static bool isPop (unsigned Opcode)
 
static unsigned getPushOpcode (RISCVMachineFunctionInfo::PushPopKind Kind, bool UpdateFP)
 
static unsigned getPopOpcode (RISCVMachineFunctionInfo::PushPopKind Kind)
 
static MCRegister getRVVBaseRegister (const RISCVRegisterInfo &TRI, const Register &Reg)
 
static unsigned getScavSlotsNumForRVV (MachineFunction &MF)
 
static bool hasRVVFrameObject (const MachineFunction &MF)
 
static unsigned estimateFunctionSizeInBytes (const MachineFunction &MF, const RISCVInstrInfo &TII)
 
static unsigned getCalleeSavedRVVNumRegs (const Register &BaseReg)
 
static void emitStackProbeInline (MachineBasicBlock::iterator MBBI, DebugLoc DL, Register TargetReg, bool IsRVV)
 

Variables

static constexpr MCPhysReg FPReg = RISCV::X8
 
static constexpr MCPhysReg SPReg = RISCV::X2
 
static constexpr MCPhysReg RAReg = RISCV::X1
 
static const MCPhysReg FixedCSRFIMap []
 
static constexpr uint64_t QCIInterruptPushAmount = 96
 
static const std::pair< MCPhysReg, int8_t > FixedCSRFIQCIInterruptMap []
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "riscv-frame"

Definition at line 31 of file RISCVFrameLowering.cpp.

Function Documentation

◆ appendScalableVectorExpression()

static void appendScalableVectorExpression ( const TargetRegisterInfo TRI,
SmallVectorImpl< char > &  Expr,
int  FixedOffset,
int  ScalableOffset,
llvm::raw_string_ostream Comment 
)
static

◆ createDefCFAExpression()

static MCCFIInstruction createDefCFAExpression ( const TargetRegisterInfo TRI,
Register  Reg,
uint64_t  FixedOffset,
uint64_t  ScalableOffset 
)
static

◆ createDefCFAOffset()

static MCCFIInstruction createDefCFAOffset ( const TargetRegisterInfo TRI,
Register  Reg,
uint64_t  FixedOffset,
uint64_t  ScalableOffset 
)
static

◆ createSiFivePreemptibleInterruptFrameEntries()

static void createSiFivePreemptibleInterruptFrameEntries ( MachineFunction MF,
RISCVMachineFunctionInfo RVFI 
)
static

◆ emitSCSEpilogue()

static void emitSCSEpilogue ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
const DebugLoc DL 
)
static

◆ emitSCSPrologue()

static void emitSCSPrologue ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
const DebugLoc DL 
)
static

◆ emitSiFiveCLICPreemptibleRestores()

static void emitSiFiveCLICPreemptibleRestores ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL 
)
static

◆ emitSiFiveCLICPreemptibleSaves()

static void emitSiFiveCLICPreemptibleSaves ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL 
)
static

◆ emitSiFiveCLICStackSwap()

static void emitSiFiveCLICStackSwap ( MachineFunction MF,
MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI,
const DebugLoc DL 
)
static

◆ emitStackProbeInline()

static void emitStackProbeInline ( MachineBasicBlock::iterator  MBBI,
DebugLoc  DL,
Register  TargetReg,
bool  IsRVV 
)
static

◆ estimateFunctionSizeInBytes()

static unsigned estimateFunctionSizeInBytes ( const MachineFunction MF,
const RISCVInstrInfo TII 
)
static

Definition at line 1750 of file RISCVFrameLowering.cpp.

References llvm::MachineFunction::getSubtarget(), MBB, MI, and TII.

◆ getABIStackAlignment()

static Align getABIStackAlignment ( RISCVABI::ABI  ABI)
static

Definition at line 35 of file RISCVFrameLowering.cpp.

References llvm::RISCVABI::ABI_ILP32E, and llvm::RISCVABI::ABI_LP64E.

◆ getCalleeSavedRVVNumRegs()

static unsigned getCalleeSavedRVVNumRegs ( const Register BaseReg)
static

Definition at line 2177 of file RISCVFrameLowering.cpp.

◆ getLibCallID()

static int getLibCallID ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getNumPushPopRegs()

static unsigned getNumPushPopRegs ( const std::vector< CalleeSavedInfo > &  CSI)
static

◆ getPopOpcode()

static unsigned getPopOpcode ( RISCVMachineFunctionInfo::PushPopKind  Kind)
static

◆ getPushOpcode()

static unsigned getPushOpcode ( RISCVMachineFunctionInfo::PushPopKind  Kind,
bool  UpdateFP 
)
static

◆ getPushOrLibCallsSavedInfo()

static SmallVector< CalleeSavedInfo, 8 > getPushOrLibCallsSavedInfo ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getQCISavedInfo()

static SmallVector< CalleeSavedInfo, 8 > getQCISavedInfo ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getRestoreLibCallName()

static const char * getRestoreLibCallName ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getRVVBaseRegister()

static MCRegister getRVVBaseRegister ( const RISCVRegisterInfo TRI,
const Register Reg 
)
static

Definition at line 1547 of file RISCVFrameLowering.cpp.

References TRI.

Referenced by llvm::RISCVFrameLowering::determineCalleeSaves().

◆ getRVVCalleeSavedInfo()

static SmallVector< CalleeSavedInfo, 8 > getRVVCalleeSavedInfo ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getScavSlotsNumForRVV()

static unsigned getScavSlotsNumForRVV ( MachineFunction MF)
static

◆ getSpillLibCallName()

static const char * getSpillLibCallName ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ getUnmanagedCSI()

static SmallVector< CalleeSavedInfo, 8 > getUnmanagedCSI ( const MachineFunction MF,
const std::vector< CalleeSavedInfo > &  CSI 
)
static

◆ hasRVVFrameObject()

static bool hasRVVFrameObject ( const MachineFunction MF)
static

◆ isPop()

static bool isPop ( unsigned  Opcode)
static

◆ isPush()

static bool isPush ( unsigned  Opcode)
static

Definition at line 856 of file RISCVFrameLowering.cpp.

Referenced by llvm::RISCVFrameLowering::emitPrologue().

◆ needsDwarfCFI()

static bool needsDwarfCFI ( const MachineFunction MF)
static

Variable Documentation

◆ FixedCSRFIMap

const MCPhysReg FixedCSRFIMap[]
static
Initial value:
= {
RAReg, FPReg, RISCV::X9,
RISCV::X18, RISCV::X19, RISCV::X20,
RISCV::X21, RISCV::X22, RISCV::X23,
RISCV::X24, RISCV::X25, RISCV::X26,
RISCV::X27}
static constexpr MCPhysReg FPReg
static constexpr MCPhysReg RAReg

Definition at line 63 of file RISCVFrameLowering.cpp.

Referenced by llvm::RISCVFrameLowering::assignCalleeSavedSpillSlots(), getNumPushPopRegs(), getPushOrLibCallsSavedInfo(), llvm::RISCVFrameLowering::restoreCalleeSavedRegisters(), and llvm::RISCVFrameLowering::spillCalleeSavedRegisters().

◆ FixedCSRFIQCIInterruptMap

const std::pair<MCPhysReg, int8_t> FixedCSRFIQCIInterruptMap[]
static
Initial value:
= {
{ FPReg, -2},
{ RAReg, -4},
{ RISCV::X5, -6},
{ RISCV::X6, -7},
{ RISCV::X7, -8},
{ RISCV::X10, -9},
{ RISCV::X11, -10},
{ RISCV::X12, -11},
{ RISCV::X13, -12},
{ RISCV::X14, -13},
{ RISCV::X15, -14},
{ RISCV::X16, -15},
{ RISCV::X17, -16},
{ RISCV::X28, -17},
{ RISCV::X29, -18},
{ RISCV::X30, -19},
{ RISCV::X31, -20},
}

Definition at line 74 of file RISCVFrameLowering.cpp.

Referenced by llvm::RISCVFrameLowering::assignCalleeSavedSpillSlots(), getPushOrLibCallsSavedInfo(), getQCISavedInfo(), and llvm::RISCVFrameLowering::spillCalleeSavedRegisters().

◆ FPReg

constexpr MCPhysReg FPReg = RISCV::X8
staticconstexpr

◆ QCIInterruptPushAmount

constexpr uint64_t QCIInterruptPushAmount = 96
staticconstexpr

◆ RAReg

constexpr MCPhysReg RAReg = RISCV::X1
staticconstexpr

◆ SPReg

constexpr MCPhysReg SPReg = RISCV::X2
staticconstexpr

Definition at line 54 of file RISCVFrameLowering.cpp.

Referenced by llvm::X86FrameLowering::adjustForHiPEPrologue(), llvm::RISCVFrameLowering::allocateStack(), llvm::AMDGPURegisterBankInfo::applyMappingDynStackAlloc(), createDefCFAExpression(), llvm::SIFrameLowering::eliminateCallFramePseudoInstr(), llvm::CSKYFrameLowering::eliminateCallFramePseudoInstr(), llvm::LoongArchFrameLowering::eliminateCallFramePseudoInstr(), llvm::RISCVFrameLowering::eliminateCallFramePseudoInstr(), llvm::RISCVTargetLowering::emitDynamicProbedAlloc(), llvm::SIFrameLowering::emitEntryFunctionPrologue(), llvm::CSKYFrameLowering::emitEpilogue(), llvm::LoongArchFrameLowering::emitEpilogue(), llvm::PPCFrameLowering::emitEpilogue(), llvm::RISCVFrameLowering::emitEpilogue(), llvm::SystemZXPLINKFrameLowering::emitEpilogue(), llvm::WebAssemblyFrameLowering::emitEpilogue(), llvm::PPCTargetLowering::emitProbedAlloca(), llvm::CSKYFrameLowering::emitPrologue(), llvm::LoongArchFrameLowering::emitPrologue(), llvm::PPCFrameLowering::emitPrologue(), llvm::RISCVFrameLowering::emitPrologue(), llvm::WebAssemblyFrameLowering::emitPrologue(), emitSiFiveCLICStackSwap(), emitStackProbeInline(), llvm::LegalizerHelper::getDynStackAllocTargetPtr(), llvm::RISCVFrameLowering::getFrameIndexReference(), M68kOutgoingArgHandler::getStackAddress(), llvm::PPCFrameLowering::inlineStackProbe(), llvm::PPCInstrInfo::isTOCSaveMI(), llvm::SITargetLowering::LowerDYNAMIC_STACKALLOC(), llvm::LanaiTargetLowering::LowerDYNAMIC_STACKALLOC(), LowerDYNAMIC_STACKALLOC(), and llvm::LegalizerHelper::lowerDynStackAlloc().