1//==-- ARMTargetFrameLowering.h - Define frame lowering for ARM --*- 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//
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
15#define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
16
17#include "llvm/Target/TargetFrameLowering.h"
18
19namespace llvm {
20  class ARMSubtarget;
21
22class ARMFrameLowering : public TargetFrameLowering {
23protected:
24  const ARMSubtarget &STI;
25
26public:
27  explicit ARMFrameLowering(const ARMSubtarget &sti);
28
29  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
30  /// the function.
31  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
33
34  bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
35                                 MachineBasicBlock::iterator MI,
36                                 const std::vector<CalleeSavedInfo> &CSI,
37                                 const TargetRegisterInfo *TRI) const override;
38
39  bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
40                                  MachineBasicBlock::iterator MI,
41                                  const std::vector<CalleeSavedInfo> &CSI,
42                                  const TargetRegisterInfo *TRI) const override;
43
44  bool noFramePointerElim(const MachineFunction &MF) const override;
45
46  bool hasFP(const MachineFunction &MF) const override;
47  bool hasReservedCallFrame(const MachineFunction &MF) const override;
48  bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
49  int getFrameIndexReference(const MachineFunction &MF, int FI,
50                             unsigned &FrameReg) const override;
51  int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
52                                 unsigned &FrameReg, int SPAdj) const;
53
54  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
55                            RegScavenger *RS) const override;
56
57  void adjustForSegmentedStacks(MachineFunction &MF,
58                                MachineBasicBlock &MBB) const override;
59
60  /// Returns true if the target will correctly handle shrink wrapping.
61  bool enableShrinkWrapping(const MachineFunction &MF) const override {
62    return true;
63  }
64
65 private:
66  void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
67                    const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc,
68                    unsigned StrOpc, bool NoGap,
69                    bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs,
70                    unsigned MIFlags = 0) const;
71  void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
72                   const std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc,
73                   unsigned LdrOpc, bool isVarArg, bool NoGap,
74                   bool(*Func)(unsigned, bool),
75                   unsigned NumAlignedDPRCS2Regs) const;
76
77  MachineBasicBlock::iterator
78  eliminateCallFramePseudoInstr(MachineFunction &MF,
79                                MachineBasicBlock &MBB,
80                                MachineBasicBlock::iterator MI) const override;
81};
82
83} // End llvm namespace
84
85#endif
86