1 //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===//
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
7 //===----------------------------------------------------------------------===//
9 // This class implements RISCV-specific bits of TargetFrameLowering class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
14 #define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
16 #include "llvm/CodeGen/TargetFrameLowering.h"
21 class RISCVFrameLowering
: public TargetFrameLowering
{
23 explicit RISCVFrameLowering(const RISCVSubtarget
&STI
)
24 : TargetFrameLowering(StackGrowsDown
,
25 /*StackAlignment=*/16,
26 /*LocalAreaOffset=*/0),
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 unsigned &FrameReg
) const override
;
35 void determineCalleeSaves(MachineFunction
&MF
, BitVector
&SavedRegs
,
36 RegScavenger
*RS
) const override
;
38 void processFunctionBeforeFrameFinalized(MachineFunction
&MF
,
39 RegScavenger
*RS
) const override
;
41 bool hasFP(const MachineFunction
&MF
) const override
;
43 bool hasReservedCallFrame(const MachineFunction
&MF
) const override
;
44 MachineBasicBlock::iterator
45 eliminateCallFramePseudoInstr(MachineFunction
&MF
, MachineBasicBlock
&MBB
,
46 MachineBasicBlock::iterator MI
) const override
;
48 // Get the first stack adjustment amount for SplitSPAdjust.
49 // Return 0 if we don't want to to split the SP adjustment in prologue and
51 uint64_t getFirstSPAdjustAmount(const MachineFunction
&MF
) const;
54 const RISCVSubtarget
&STI
;
57 void determineFrameLayout(MachineFunction
&MF
) const;
58 void adjustReg(MachineBasicBlock
&MBB
, MachineBasicBlock::iterator MBBI
,
59 const DebugLoc
&DL
, Register DestReg
, Register SrcReg
,
60 int64_t Val
, MachineInstr::MIFlag Flag
) const;