1 //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class implements RISCV-specific bits of TargetFrameLowering class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
15 #define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
17 #include "llvm/CodeGen/TargetFrameLowering.h"
22 class RISCVFrameLowering : public TargetFrameLowering {
24 explicit RISCVFrameLowering(const RISCVSubtarget &STI)
25 : TargetFrameLowering(StackGrowsDown,
26 /*StackAlignment=*/16,
27 /*LocalAreaOffset=*/0),
30 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
33 int getFrameIndexReference(const MachineFunction &MF, int FI,
34 unsigned &FrameReg) const override;
36 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
37 RegScavenger *RS) const override;
39 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
40 RegScavenger *RS) const override;
42 bool hasFP(const MachineFunction &MF) const override;
44 bool hasReservedCallFrame(const MachineFunction &MF) const override;
45 MachineBasicBlock::iterator
46 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
47 MachineBasicBlock::iterator MI) const override;
50 const RISCVSubtarget &STI;
53 void determineFrameLayout(MachineFunction &MF) const;
54 void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
55 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
56 int64_t Val, MachineInstr::MIFlag Flag) const;