blob: 9de1ba1d7009aadaec6841a65b50396fd4faf174 [file] [log] [blame]
Anton Korobeynikov2f931282011-01-10 12:39:04 +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//===----------------------------------------------------------------------===//
9//
10//
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
15#define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000016
Anton Korobeynikov2f931282011-01-10 12:39:04 +000017#include "ARMFrameLowering.h"
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000018#include "Thumb1InstrInfo.h"
Eric Christopherae326492015-03-12 22:48:50 +000019#include "ThumbRegisterInfo.h"
Anton Korobeynikov2f931282011-01-10 12:39:04 +000020#include "llvm/Target/TargetFrameLowering.h"
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000021
22namespace llvm {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000023
Anton Korobeynikov2f931282011-01-10 12:39:04 +000024class Thumb1FrameLowering : public ARMFrameLowering {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000025public:
Eric Christopher45fb7b62014-06-26 19:29:59 +000026 explicit Thumb1FrameLowering(const ARMSubtarget &sti);
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000027
28 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
29 /// the function.
Quentin Colombet61b305e2015-05-05 17:38:16 +000030 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Craig Topper6bc27bf2014-03-10 02:09:33 +000031 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Anton Korobeynikov0eecf5d2010-11-18 21:19:35 +000032
Anton Korobeynikovd08fbd12010-11-27 23:05:03 +000033 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
34 MachineBasicBlock::iterator MI,
35 const 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 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
Craig Topper6bc27bf2014-03-10 02:09:33 +000038 MachineBasicBlock::iterator MI,
39 const std::vector<CalleeSavedInfo> &CSI,
40 const TargetRegisterInfo *TRI) const override;
Anton Korobeynikovd08fbd12010-11-27 23:05:03 +000041
Craig Topper6bc27bf2014-03-10 02:09:33 +000042 bool hasReservedCallFrame(const MachineFunction &MF) const override;
Eli Bendersky8da87162013-02-21 20:05:00 +000043
Hans Wennborge1a2e902016-03-31 18:33:38 +000044 MachineBasicBlock::iterator
Craig Topper6bc27bf2014-03-10 02:09:33 +000045 eliminateCallFramePseudoInstr(MachineFunction &MF,
46 MachineBasicBlock &MBB,
47 MachineBasicBlock::iterator MI) const override;
Quentin Colombet48b77202015-07-22 16:34:37 +000048
49 /// Check whether or not the given \p MBB can be used as a epilogue
50 /// for the target.
51 /// The epilogue will be inserted before the first terminator of that block.
52 /// This method is used by the shrink-wrapping pass to decide if
53 /// \p MBB will be correctly handled by the target.
54 bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;
55
Weiming Zhao48c033e2016-01-08 18:37:43 +000056 /// Disable shrink wrap as tBfar/BL will be used to adjust for long jumps.
57 bool enableShrinkWrapping(const MachineFunction &MF) const override {
58 return false;
59 }
60
Quentin Colombet48b77202015-07-22 16:34:37 +000061private:
62 /// Check if the frame lowering of \p MF needs a special fixup
63 /// code sequence for the epilogue.
64 /// Unlike T2 and ARM mode, the T1 pop instruction cannot restore
65 /// to LR, and we can't pop the value directly to the PC when
66 /// we need to update the SP after popping the value. So instead
67 /// we have to emit:
68 /// POP {r3}
69 /// ADD sp, #offset
70 /// BX r3
71 /// If this would clobber a return value, then generate this sequence instead:
72 /// MOV ip, r3
73 /// POP {r3}
74 /// ADD sp, #offset
75 /// MOV lr, r3
76 /// MOV r3, ip
77 /// BX lr
78 bool needPopSpecialFixUp(const MachineFunction &MF) const;
79
80 /// Emit the special fixup code sequence for the epilogue.
81 /// \see needPopSpecialFixUp for more details.
82 /// \p DoIt, tells this method whether or not to actually insert
83 /// the code sequence in \p MBB. I.e., when \p DoIt is false,
84 /// \p MBB is left untouched.
85 /// \returns For \p DoIt == true: True when the emission succeeded
86 /// false otherwise. For \p DoIt == false: True when the emission
87 /// would have been possible, false otherwise.
88 bool emitPopSpecialFixUp(MachineBasicBlock &MBB, bool DoIt) const;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000089};
90
Alexander Kornienkof00654e2015-06-23 09:49:53 +000091} // End llvm namespace
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000092
93#endif