Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 1 | //===- ARMTargetFrameLowering.h - Define frame lowering for ARM -*- C++ -*-===// |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 9 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |
| 11 | #define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 12 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 13 | #include "llvm/CodeGen/MachineBasicBlock.h" |
David Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/TargetFrameLowering.h" |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 15 | #include <vector> |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 16 | |
| 17 | namespace llvm { |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 18 | |
| 19 | class ARMSubtarget; |
| 20 | class CalleeSavedInfo; |
| 21 | class MachineFunction; |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 22 | |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 23 | class ARMFrameLowering : public TargetFrameLowering { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 24 | protected: |
| 25 | const ARMSubtarget &STI; |
| 26 | |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 27 | public: |
Eric Christopher | 45fb7b6 | 2014-06-26 19:29:59 +0000 | [diff] [blame] | 28 | explicit ARMFrameLowering(const ARMSubtarget &sti); |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 29 | |
| 30 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 31 | /// the function. |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 32 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 33 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Anton Korobeynikov | 0eecf5d | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 34 | |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 35 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 36 | MachineBasicBlock::iterator MI, |
| 37 | const std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 38 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 39 | |
| 40 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 41 | MachineBasicBlock::iterator MI, |
Krzysztof Parzyszek | bea30c6 | 2017-08-10 16:17:32 +0000 | [diff] [blame] | 42 | std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 43 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 44 | |
Akira Hatanaka | ddf76aa | 2015-05-23 01:14:08 +0000 | [diff] [blame] | 45 | bool noFramePointerElim(const MachineFunction &MF) const override; |
| 46 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 47 | bool hasFP(const MachineFunction &MF) const override; |
| 48 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
| 49 | bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 50 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 51 | unsigned &FrameReg) const override; |
| 52 | int ResolveFrameIndexReference(const MachineFunction &MF, int FI, |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 53 | unsigned &FrameReg, int SPAdj) const; |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 54 | |
Matthias Braun | 0256486 | 2015-07-14 17:17:13 +0000 | [diff] [blame] | 55 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 56 | RegScavenger *RS) const override; |
Anton Korobeynikov | 7283b8d | 2010-11-27 23:05:25 +0000 | [diff] [blame] | 57 | |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 58 | void adjustForSegmentedStacks(MachineFunction &MF, |
| 59 | MachineBasicBlock &MBB) const override; |
Oliver Stannard | b14c625 | 2014-04-02 16:10:33 +0000 | [diff] [blame] | 60 | |
Quentin Colombet | 8cb95b8 | 2015-11-18 00:40:54 +0000 | [diff] [blame] | 61 | /// Returns true if the target will correctly handle shrink wrapping. |
| 62 | bool enableShrinkWrapping(const MachineFunction &MF) const override { |
| 63 | return true; |
| 64 | } |
| 65 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 66 | private: |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 67 | void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Jim Grosbach | 5fccad8 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 68 | const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc, |
| 69 | unsigned StrOpc, bool NoGap, |
Jakob Stoklund Olesen | 0965585 | 2011-12-23 00:36:18 +0000 | [diff] [blame] | 70 | bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs, |
Anton Korobeynikov | e7410dd | 2011-03-05 18:43:32 +0000 | [diff] [blame] | 71 | unsigned MIFlags = 0) const; |
Evan Cheng | 775ead3 | 2010-12-07 23:08:38 +0000 | [diff] [blame] | 72 | void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Krzysztof Parzyszek | bea30c6 | 2017-08-10 16:17:32 +0000 | [diff] [blame] | 73 | std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc, |
Jim Grosbach | 5fccad8 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 74 | unsigned LdrOpc, bool isVarArg, bool NoGap, |
Jakob Stoklund Olesen | 0965585 | 2011-12-23 00:36:18 +0000 | [diff] [blame] | 75 | bool(*Func)(unsigned, bool), |
| 76 | unsigned NumAlignedDPRCS2Regs) const; |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 77 | |
Hans Wennborg | e1a2e90 | 2016-03-31 18:33:38 +0000 | [diff] [blame] | 78 | MachineBasicBlock::iterator |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 79 | eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 80 | MachineBasicBlock &MBB, |
| 81 | MachineBasicBlock::iterator MI) const override; |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 84 | } // end namespace llvm |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 85 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 86 | #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |