Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 1 | //===- Thumb1FrameLowering.h - Thumb1-specific frame info stuff ---*- C++ -*-=// |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 9 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H |
| 11 | #define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 12 | |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 13 | #include "ARMFrameLowering.h" |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 14 | |
| 15 | namespace llvm { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 16 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 17 | class ARMSubtarget; |
| 18 | class MachineFunction; |
| 19 | |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 20 | class Thumb1FrameLowering : public ARMFrameLowering { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 21 | public: |
Eric Christopher | 45fb7b6 | 2014-06-26 19:29:59 +0000 | [diff] [blame] | 22 | explicit Thumb1FrameLowering(const ARMSubtarget &sti); |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 23 | |
| 24 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 25 | /// the function. |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 26 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 27 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Anton Korobeynikov | 0eecf5d | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 28 | |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 29 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 30 | MachineBasicBlock::iterator MI, |
| 31 | const std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 32 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 33 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 34 | MachineBasicBlock::iterator MI, |
Krzysztof Parzyszek | bea30c6 | 2017-08-10 16:17:32 +0000 | [diff] [blame] | 35 | std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 36 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 37 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 38 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 39 | |
Hans Wennborg | e1a2e90 | 2016-03-31 18:33:38 +0000 | [diff] [blame] | 40 | MachineBasicBlock::iterator |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 41 | eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 42 | MachineBasicBlock &MBB, |
| 43 | MachineBasicBlock::iterator MI) const override; |
Quentin Colombet | 48b7720 | 2015-07-22 16:34:37 +0000 | [diff] [blame] | 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 | |
Weiming Zhao | 48c033e | 2016-01-08 18:37:43 +0000 | [diff] [blame] | 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 | |
Quentin Colombet | 48b7720 | 2015-07-22 16:34:37 +0000 | [diff] [blame] | 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; |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 87 | } // end namespace llvm |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 88 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 89 | #endif // LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H |