1 | //===-- CSKYFrameLowering.h - Define frame lowering for CSKY -*- C++ -*--===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This class implements CSKY-specific bits of TargetFrameLowering class. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H |
14 | #define LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H |
15 | |
16 | #include "llvm/CodeGen/TargetFrameLowering.h" |
17 | |
18 | namespace llvm { |
19 | class CSKYSubtarget; |
20 | |
21 | class CSKYFrameLowering : public TargetFrameLowering { |
22 | const CSKYSubtarget &STI; |
23 | |
24 | void determineFrameLayout(MachineFunction &MF) const; |
25 | void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, |
26 | const DebugLoc &DL, Register DestReg, Register SrcReg, |
27 | int64_t Val, MachineInstr::MIFlag Flag) const; |
28 | |
29 | public: |
30 | explicit CSKYFrameLowering(const CSKYSubtarget &STI) |
31 | : TargetFrameLowering(StackGrowsDown, |
32 | /*StackAlignment=*/Align(4), |
33 | /*LocalAreaOffset=*/0), |
34 | STI(STI) {} |
35 | |
36 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
37 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
38 | |
39 | StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, |
40 | Register &FrameReg) const override; |
41 | |
42 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
43 | RegScavenger *RS) const override; |
44 | |
45 | bool assignCalleeSavedSpillSlots( |
46 | MachineFunction &MF, const TargetRegisterInfo *TRI, |
47 | std::vector<CalleeSavedInfo> &CSI) const override { |
48 | |
49 | std::reverse(first: CSI.begin(), last: CSI.end()); |
50 | |
51 | return false; |
52 | } |
53 | |
54 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
55 | MachineBasicBlock::iterator MI, |
56 | ArrayRef<CalleeSavedInfo> CSI, |
57 | const TargetRegisterInfo *TRI) const override; |
58 | bool |
59 | restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
60 | MachineBasicBlock::iterator MI, |
61 | MutableArrayRef<CalleeSavedInfo> CSI, |
62 | const TargetRegisterInfo *TRI) const override; |
63 | |
64 | bool hasFP(const MachineFunction &MF) const override; |
65 | bool hasBP(const MachineFunction &MF) const; |
66 | |
67 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
68 | |
69 | MachineBasicBlock::iterator |
70 | eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, |
71 | MachineBasicBlock::iterator MI) const override; |
72 | }; |
73 | } // namespace llvm |
74 | #endif |
75 | |