LLVM  9.0.0svn
Thumb1FrameLowering.h
Go to the documentation of this file.
1 //===- Thumb1FrameLowering.h - Thumb1-specific frame info stuff ---*- 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 #ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
10 #define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
11 
12 #include "ARMFrameLowering.h"
13 
14 namespace llvm {
15 
16 class ARMSubtarget;
17 class MachineFunction;
18 
20 public:
21  explicit Thumb1FrameLowering(const ARMSubtarget &sti);
22 
23  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
24  /// the function.
25  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
26  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
27 
30  const std::vector<CalleeSavedInfo> &CSI,
31  const TargetRegisterInfo *TRI) const override;
34  std::vector<CalleeSavedInfo> &CSI,
35  const TargetRegisterInfo *TRI) const override;
36 
37  bool hasReservedCallFrame(const MachineFunction &MF) const override;
38 
41  MachineBasicBlock &MBB,
42  MachineBasicBlock::iterator MI) const override;
43 
44  /// Check whether or not the given \p MBB can be used as a epilogue
45  /// for the target.
46  /// The epilogue will be inserted before the first terminator of that block.
47  /// This method is used by the shrink-wrapping pass to decide if
48  /// \p MBB will be correctly handled by the target.
49  bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;
50 
51  /// Disable shrink wrap as tBfar/BL will be used to adjust for long jumps.
52  bool enableShrinkWrapping(const MachineFunction &MF) const override {
53  return false;
54  }
55 
56 private:
57  /// Check if the frame lowering of \p MF needs a special fixup
58  /// code sequence for the epilogue.
59  /// Unlike T2 and ARM mode, the T1 pop instruction cannot restore
60  /// to LR, and we can't pop the value directly to the PC when
61  /// we need to update the SP after popping the value. So instead
62  /// we have to emit:
63  /// POP {r3}
64  /// ADD sp, #offset
65  /// BX r3
66  /// If this would clobber a return value, then generate this sequence instead:
67  /// MOV ip, r3
68  /// POP {r3}
69  /// ADD sp, #offset
70  /// MOV lr, r3
71  /// MOV r3, ip
72  /// BX lr
73  bool needPopSpecialFixUp(const MachineFunction &MF) const;
74 
75  /// Emit the special fixup code sequence for the epilogue.
76  /// \see needPopSpecialFixUp for more details.
77  /// \p DoIt, tells this method whether or not to actually insert
78  /// the code sequence in \p MBB. I.e., when \p DoIt is false,
79  /// \p MBB is left untouched.
80  /// \returns For \p DoIt == true: True when the emission succeeded
81  /// false otherwise. For \p DoIt == false: True when the emission
82  /// would have been possible, false otherwise.
83  bool emitPopSpecialFixUp(MachineBasicBlock &MBB, bool DoIt) const;
84 };
85 
86 } // end namespace llvm
87 
88 #endif // LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
unsigned const TargetRegisterInfo * TRI
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Thumb1FrameLowering(const ARMSubtarget &sti)
bool enableShrinkWrapping(const MachineFunction &MF) const override
Disable shrink wrap as tBfar/BL will be used to adjust for long jumps.
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a epilogue for the target.
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
IRTranslator LLVM IR MI
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...