]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/RISCV/RISCVFrameLowering.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / RISCV / RISCVFrameLowering.h
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
17 #include "llvm/CodeGen/TargetFrameLowering.h"
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,
27                             /*LocalAreaOffset=*/0),
28         STI(STI) {}
29
30   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32
33   int getFrameIndexReference(const MachineFunction &MF, int FI,
34                              unsigned &FrameReg) const override;
35
36   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
37                             RegScavenger *RS) const override;
38
39   void processFunctionBeforeFrameFinalized(MachineFunction &MF,
40                                            RegScavenger *RS) const override;
41
42   bool hasFP(const MachineFunction &MF) const override;
43
44   bool hasReservedCallFrame(const MachineFunction &MF) const override;
45   MachineBasicBlock::iterator
46   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
47                                 MachineBasicBlock::iterator MI) const override;
48
49 protected:
50   const RISCVSubtarget &STI;
51
52 private:
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;
57 };
58 }
59 #endif