| Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 1 | //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class implements RISCV-specific bits of TargetFrameLowering class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H |
| 15 | #define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H |
| 16 | |
| David Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/TargetFrameLowering.h" |
| Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
| 20 | class RISCVSubtarget; |
| 21 | |
| 22 | class RISCVFrameLowering : public TargetFrameLowering { |
| 23 | public: |
| 24 | explicit RISCVFrameLowering(const RISCVSubtarget &STI) |
| 25 | : TargetFrameLowering(StackGrowsDown, |
| 26 | /*StackAlignment=*/16, |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 27 | /*LocalAreaOffset=*/0), |
| 28 | STI(STI) {} |
| Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 29 | |
| 30 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 31 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 32 | |
| Alex Bradbury | 660bcce | 2017-12-11 11:53:54 +0000 | [diff] [blame] | 33 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
| 34 | unsigned &FrameReg) const override; |
| 35 | |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 36 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 37 | RegScavenger *RS) const override; |
| 38 | |
| Alex Bradbury | 0715d35 | 2018-01-11 11:17:19 +0000 | [diff] [blame^] | 39 | void processFunctionBeforeFrameFinalized(MachineFunction &MF, |
| 40 | RegScavenger *RS) const override; |
| 41 | |
| Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 42 | bool hasFP(const MachineFunction &MF) const override; |
| Alex Bradbury | a337675 | 2017-11-08 13:41:21 +0000 | [diff] [blame] | 43 | |
| 44 | MachineBasicBlock::iterator |
| 45 | eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, |
| 46 | MachineBasicBlock::iterator MI) const override { |
| 47 | return MBB.erase(MI); |
| 48 | } |
| Alex Bradbury | b014e3d | 2017-12-11 12:34:11 +0000 | [diff] [blame] | 49 | |
| 50 | protected: |
| 51 | const RISCVSubtarget &STI; |
| 52 | |
| 53 | private: |
| 54 | void determineFrameLayout(MachineFunction &MF) const; |
| 55 | void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, |
| 56 | const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, |
| 57 | int64_t Val, MachineInstr::MIFlag Flag) const; |
| Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 58 | }; |
| 59 | } |
| 60 | #endif |