blob: 9324336c6ef74f624b38dd7a7063653aa3746e56 [file] [log] [blame]
Alex Bradbury89718422017-10-19 21:37:38 +00001//===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Alex Bradbury89718422017-10-19 21:37:38 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This class implements RISCV-specific bits of TargetFrameLowering class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
14#define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
15
David Blaikie1be62f02017-11-03 22:32:11 +000016#include "llvm/CodeGen/TargetFrameLowering.h"
Alex Bradbury89718422017-10-19 21:37:38 +000017
18namespace llvm {
19class RISCVSubtarget;
20
21class RISCVFrameLowering : public TargetFrameLowering {
22public:
23 explicit RISCVFrameLowering(const RISCVSubtarget &STI)
24 : TargetFrameLowering(StackGrowsDown,
25 /*StackAlignment=*/16,
Alex Bradburyb014e3d2017-12-11 12:34:11 +000026 /*LocalAreaOffset=*/0),
27 STI(STI) {}
Alex Bradbury89718422017-10-19 21:37:38 +000028
29 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
30 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31
Alex Bradbury660bcce2017-12-11 11:53:54 +000032 int getFrameIndexReference(const MachineFunction &MF, int FI,
33 unsigned &FrameReg) const override;
34
Alex Bradburyb014e3d2017-12-11 12:34:11 +000035 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
36 RegScavenger *RS) const override;
37
Alex Bradbury0715d352018-01-11 11:17:19 +000038 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
39 RegScavenger *RS) const override;
40
Alex Bradbury89718422017-10-19 21:37:38 +000041 bool hasFP(const MachineFunction &MF) const override;
Alex Bradburya3376752017-11-08 13:41:21 +000042
Shiva Chencbd498a2018-03-20 01:39:17 +000043 bool hasReservedCallFrame(const MachineFunction &MF) const override;
Alex Bradburya3376752017-11-08 13:41:21 +000044 MachineBasicBlock::iterator
45 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
Shiva Chencbd498a2018-03-20 01:39:17 +000046 MachineBasicBlock::iterator MI) const override;
Alex Bradburyb014e3d2017-12-11 12:34:11 +000047
48protected:
49 const RISCVSubtarget &STI;
50
51private:
52 void determineFrameLayout(MachineFunction &MF) const;
53 void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
Luis Marquesfa06e952019-08-16 14:27:50 +000054 const DebugLoc &DL, Register DestReg, Register SrcReg,
Alex Bradburyb014e3d2017-12-11 12:34:11 +000055 int64_t Val, MachineInstr::MIFlag Flag) const;
Alex Bradbury89718422017-10-19 21:37:38 +000056};
57}
58#endif