blob: 812f9830824de99a61909be5f6d357a7fc6cf485 [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
Craig Topper6bc27bf2014-03-10 02:09:33 +000044 void
45 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
56private:
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;
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000084};
85
Alexander Kornienkof00654e2015-06-23 09:49:53 +000086} // End llvm namespace
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000087
88#endif