Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 1 | //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 6 | // |
| 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 Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/TargetFrameLowering.h" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | class RISCVSubtarget; |
| 20 | |
| 21 | class RISCVFrameLowering : public TargetFrameLowering { |
| 22 | public: |
| 23 | explicit RISCVFrameLowering(const RISCVSubtarget &STI) |
| 24 | : TargetFrameLowering(StackGrowsDown, |
| 25 | /*StackAlignment=*/16, |
Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 26 | /*LocalAreaOffset=*/0), |
| 27 | STI(STI) {} |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 28 | |
| 29 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 30 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 31 | |
Alex Bradbury | 660bcce | 2017-12-11 11:53:54 +0000 | [diff] [blame] | 32 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
| 33 | unsigned &FrameReg) const override; |
| 34 | |
Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 35 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 36 | RegScavenger *RS) const override; |
| 37 | |
Alex Bradbury | 0715d35 | 2018-01-11 11:17:19 +0000 | [diff] [blame] | 38 | void processFunctionBeforeFrameFinalized(MachineFunction &MF, |
| 39 | RegScavenger *RS) const override; |
| 40 | |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 41 | bool hasFP(const MachineFunction &MF) const override; |
Alex Bradbury | a337675 | 2017-11-08 13:41:21 +0000 | [diff] [blame] | 42 | |
Shiva Chen | cbd498a | 2018-03-20 01:39:17 +0000 | [diff] [blame] | 43 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
Alex Bradbury | a337675 | 2017-11-08 13:41:21 +0000 | [diff] [blame] | 44 | MachineBasicBlock::iterator |
| 45 | eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, |
Shiva Chen | cbd498a | 2018-03-20 01:39:17 +0000 | [diff] [blame] | 46 | MachineBasicBlock::iterator MI) const override; |
Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 47 | |
| 48 | protected: |
| 49 | const RISCVSubtarget &STI; |
| 50 | |
| 51 | private: |
| 52 | void determineFrameLayout(MachineFunction &MF) const; |
| 53 | void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, |
Luis Marques | fa06e95 | 2019-08-16 14:27:50 +0000 | [diff] [blame] | 54 | const DebugLoc &DL, Register DestReg, Register SrcReg, |
Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 55 | int64_t Val, MachineInstr::MIFlag Flag) const; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 56 | }; |
| 57 | } |
| 58 | #endif |