LLVM  12.0.0git
Go to the documentation of this file.
1 //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- 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 RISCV-specific bits of TargetFrameLowering class.
10 //
11 //===----------------------------------------------------------------------===//
18 namespace llvm {
19 class RISCVSubtarget;
22 public:
25  /*StackAlignment=*/Align(16),
26  /*LocalAreaOffset=*/0),
27  STI(STI) {}
29  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
30  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32  int getFrameIndexReference(const MachineFunction &MF, int FI,
33  Register &FrameReg) const override;
35  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
36  RegScavenger *RS) const override;
39  RegScavenger *RS) const override;
41  bool hasFP(const MachineFunction &MF) const override;
43  bool hasBP(const MachineFunction &MF) const;
45  bool hasReservedCallFrame(const MachineFunction &MF) const override;
48  MachineBasicBlock::iterator MI) const override;
52  const TargetRegisterInfo *TRI) const override;
53  bool
57  const TargetRegisterInfo *TRI) const override;
59  // Get the first stack adjustment amount for SplitSPAdjust.
60  // Return 0 if we don't want to to split the SP adjustment in prologue and
61  // epilogue.
62  uint64_t getFirstSPAdjustAmount(const MachineFunction &MF) const;
64  bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;
65  bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;
67 protected:
70 private:
71  void determineFrameLayout(MachineFunction &MF) const;
73  const DebugLoc &DL, Register DestReg, Register SrcReg,
74  int64_t Val, MachineInstr::MIFlag Flag) const;
75 };
76 }
77 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a prologue for the target.
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...
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...
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:33
int 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...
MachineBasicBlock & MBB
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:138
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
bool hasBP(const MachineFunction &MF) const
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:298
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
RISCVFrameLowering(const RISCVSubtarget &STI)
uint64_t getFirstSPAdjustAmount(const MachineFunction &MF) const
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Information about stack frame layout on the target.
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a epilogue for the target.
const RISCVSubtarget & STI
IRTranslator LLVM IR MI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL