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