LLVM  17.0.0git
LoongArchFrameLowering.h
Go to the documentation of this file.
1 //=- LoongArchFrameLowering.h - TargetFrameLowering for LoongArch -*- C++ -*--//
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 // This class implements LoongArch-specific bits of TargetFrameLowering class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
15 
17 
18 namespace llvm {
19 class LoongArchSubtarget;
20 
22  const LoongArchSubtarget &STI;
23 
24 public:
27  /*StackAlignment=*/Align(16),
28  /*LocalAreaOffset=*/0),
29  STI(STI) {}
30 
31  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
33 
34  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
35  RegScavenger *RS) const override;
36 
38  RegScavenger *RS) const override;
39 
40  bool hasReservedCallFrame(const MachineFunction &MF) const override;
43  MachineBasicBlock::iterator MI) const override;
47  const TargetRegisterInfo *TRI) const override;
48 
50  Register &FrameReg) const override;
51 
52  bool hasFP(const MachineFunction &MF) const override;
53  bool hasBP(const MachineFunction &MF) const;
54 
56  bool IsPrologue = false) const;
57 
58 private:
59  void determineFrameLayout(MachineFunction &MF) const;
61  const DebugLoc &DL, Register DestReg, Register SrcReg,
62  int64_t Val, MachineInstr::MIFlag Flag) const;
63 };
64 } // end namespace llvm
65 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:109
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
TargetFrameLowering.h
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::LoongArchFrameLowering::getFrameIndexReference
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
Definition: LoongArchFrameLowering.cpp:477
llvm::LoongArchFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition: LoongArchFrameLowering.cpp:179
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:236
llvm::LoongArchFrameLowering::processFunctionBeforeFrameFinalized
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: LoongArchFrameLowering.cpp:141
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::LoongArchFrameLowering
Definition: LoongArchFrameLowering.h:21
llvm::LoongArchFrameLowering::getFirstSPAdjustAmount
uint64_t getFirstSPAdjustAmount(const MachineFunction &MF, bool IsPrologue=false) const
Definition: LoongArchFrameLowering.cpp:376
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:148
llvm::BitVector
Definition: BitVector.h:75
llvm::LoongArchFrameLowering::determineCalleeSaves
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition: LoongArchFrameLowering.cpp:400
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::LoongArchFrameLowering::spillCalleeSavedRegisters
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
Definition: LoongArchFrameLowering.cpp:453
uint64_t
llvm::LoongArchSubtarget
Definition: LoongArchSubtarget.h:32
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::LoongArchFrameLowering::LoongArchFrameLowering
LoongArchFrameLowering(const LoongArchSubtarget &STI)
Definition: LoongArchFrameLowering.h:25
llvm::LoongArchFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: LoongArchFrameLowering.cpp:418
llvm::LoongArchFrameLowering::hasBP
bool hasBP(const MachineFunction &MF) const
Definition: LoongArchFrameLowering.cpp:43
llvm::MachineInstr::MIFlag
MIFlag
Definition: MachineInstr.h:82
llvm::MachineFunction
Definition: MachineFunction.h:258
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:33
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm::StackOffset
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:36
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::LoongArchFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: LoongArchFrameLowering.cpp:322
llvm::LoongArchFrameLowering::eliminateCallFramePseudoInstr
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Definition: LoongArchFrameLowering.cpp:425
llvm::TargetFrameLowering::StackGrowsDown
@ StackGrowsDown
Definition: TargetFrameLowering.h:47
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::LoongArchFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition: LoongArchFrameLowering.cpp:34