blob: a4d6451ccf125d8b1096beeefc51b763eda6092c [file] [log] [blame]
Eugene Zelenko076468c2017-09-20 21:35:51 +00001//===- Thumb1FrameLowering.h - Thumb1-specific frame info stuff ---*- C++ -*-=//
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +00002//
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//===----------------------------------------------------------------------===//
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +00009
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
11#define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000012
Anton Korobeynikov2f931282011-01-10 12:39:04 +000013#include "ARMFrameLowering.h"
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000014
15namespace llvm {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000016
Eugene Zelenko076468c2017-09-20 21:35:51 +000017class ARMSubtarget;
18class MachineFunction;
19
Anton Korobeynikov2f931282011-01-10 12:39:04 +000020class Thumb1FrameLowering : public ARMFrameLowering {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000021public:
Eric Christopher45fb7b62014-06-26 19:29:59 +000022 explicit Thumb1FrameLowering(const ARMSubtarget &sti);
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000023
24 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
25 /// the function.
Quentin Colombet61b305e2015-05-05 17:38:16 +000026 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Craig Topper6bc27bf2014-03-10 02:09:33 +000027 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Anton Korobeynikov0eecf5d2010-11-18 21:19:35 +000028
Anton Korobeynikovd08fbd12010-11-27 23:05:03 +000029 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
30 MachineBasicBlock::iterator MI,
31 const std::vector<CalleeSavedInfo> &CSI,
Craig Topper6bc27bf2014-03-10 02:09:33 +000032 const TargetRegisterInfo *TRI) const override;
Anton Korobeynikovd08fbd12010-11-27 23:05:03 +000033 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
Craig Topper6bc27bf2014-03-10 02:09:33 +000034 MachineBasicBlock::iterator MI,
Krzysztof Parzyszekbea30c62017-08-10 16:17:32 +000035 std::vector<CalleeSavedInfo> &CSI,
Craig Topper6bc27bf2014-03-10 02:09:33 +000036 const TargetRegisterInfo *TRI) const override;
Anton Korobeynikovd08fbd12010-11-27 23:05:03 +000037
Craig Topper6bc27bf2014-03-10 02:09:33 +000038 bool hasReservedCallFrame(const MachineFunction &MF) const override;
Eli Bendersky8da87162013-02-21 20:05:00 +000039
Hans Wennborge1a2e902016-03-31 18:33:38 +000040 MachineBasicBlock::iterator
Craig Topper6bc27bf2014-03-10 02:09:33 +000041 eliminateCallFramePseudoInstr(MachineFunction &MF,
42 MachineBasicBlock &MBB,
43 MachineBasicBlock::iterator MI) const override;
Quentin Colombet48b77202015-07-22 16:34:37 +000044
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
Weiming Zhao48c033e2016-01-08 18:37:43 +000052 /// 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
Quentin Colombet48b77202015-07-22 16:34:37 +000057private:
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;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000085};
86
Eugene Zelenko076468c2017-09-20 21:35:51 +000087} // end namespace llvm
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000088
Eugene Zelenko076468c2017-09-20 21:35:51 +000089#endif // LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H