1//==- MSP430FrameLowering.h - Define frame lowering for MSP430 --*- 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//
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_MSP430_MSP430FRAMELOWERING_H
14#define LLVM_LIB_TARGET_MSP430_MSP430FRAMELOWERING_H
15
16#include "MSP430.h"
17#include "llvm/CodeGen/TargetFrameLowering.h"
18
19namespace llvm {
20
21class MSP430Subtarget;
22class MSP430InstrInfo;
23class MSP430RegisterInfo;
24
25class MSP430FrameLowering : public TargetFrameLowering {
26protected:
27 bool hasFPImpl(const MachineFunction &MF) const override;
28
29public:
30 MSP430FrameLowering(const MSP430Subtarget &STI);
31
32 const MSP430Subtarget &STI;
33 const MSP430InstrInfo &TII;
34 const MSP430RegisterInfo *TRI;
35
36 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
37 /// the function.
38 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
39 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
40
41 MachineBasicBlock::iterator
42 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
43 MachineBasicBlock::iterator I) const override;
44
45 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MI,
47 ArrayRef<CalleeSavedInfo> CSI,
48 const TargetRegisterInfo *TRI) const override;
49 bool
50 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
51 MachineBasicBlock::iterator MI,
52 MutableArrayRef<CalleeSavedInfo> CSI,
53 const TargetRegisterInfo *TRI) const override;
54
55 bool hasReservedCallFrame(const MachineFunction &MF) const override;
56 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
57 RegScavenger *RS = nullptr) const override;
58
59 /// Wraps up getting a CFI index and building a MachineInstr for it.
60 void BuildCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
61 const DebugLoc &DL, const MCCFIInstruction &CFIInst,
62 MachineInstr::MIFlag Flag = MachineInstr::NoFlags) const;
63
64 void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
65 MachineBasicBlock::iterator MBBI,
66 const DebugLoc &DL, bool IsPrologue) const;
67};
68
69} // End llvm namespace
70
71#endif
72