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 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 8 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 9 | #ifndef LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |
| 10 | #define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 11 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 12 | #include "llvm/CodeGen/MachineBasicBlock.h" |
David Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 13 | #include "llvm/CodeGen/TargetFrameLowering.h" |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 14 | #include <vector> |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 15 | |
| 16 | namespace llvm { |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 17 | |
| 18 | class ARMSubtarget; |
| 19 | class CalleeSavedInfo; |
| 20 | class MachineFunction; |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 21 | |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 22 | class ARMFrameLowering : public TargetFrameLowering { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 23 | protected: |
| 24 | const ARMSubtarget &STI; |
| 25 | |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 26 | public: |
Eric Christopher | 45fb7b6 | 2014-06-26 19:29:59 +0000 | [diff] [blame] | 27 | explicit ARMFrameLowering(const ARMSubtarget &sti); |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 28 | |
| 29 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 30 | /// the function. |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 31 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 32 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Anton Korobeynikov | 0eecf5d | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 33 | |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 34 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 35 | MachineBasicBlock::iterator MI, |
| 36 | const std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 37 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 38 | |
| 39 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 40 | MachineBasicBlock::iterator MI, |
Krzysztof Parzyszek | bea30c6 | 2017-08-10 16:17:32 +0000 | [diff] [blame] | 41 | std::vector<CalleeSavedInfo> &CSI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 42 | const TargetRegisterInfo *TRI) const override; |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 43 | |
Francis Visoiu Mistrih | b7cef81 | 2019-01-14 10:55:55 +0000 | [diff] [blame] | 44 | bool keepFramePointer(const MachineFunction &MF) const override; |
Akira Hatanaka | ddf76aa | 2015-05-23 01:14:08 +0000 | [diff] [blame] | 45 | |
Tim Northover | e25e458 | 2018-04-07 10:57:03 +0000 | [diff] [blame] | 46 | bool enableCalleeSaveSkip(const MachineFunction &MF) const override; |
| 47 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 48 | bool hasFP(const MachineFunction &MF) const override; |
| 49 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
| 50 | bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 51 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 52 | unsigned &FrameReg) const override; |
| 53 | int ResolveFrameIndexReference(const MachineFunction &MF, int FI, |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 54 | unsigned &FrameReg, int SPAdj) const; |
Anton Korobeynikov | 4687778 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 55 | |
Sander de Smalen | d6a7da8 | 2019-10-29 12:49:34 +0000 | [diff] [blame] | 56 | void getCalleeSaves(const MachineFunction &MF, |
| 57 | BitVector &SavedRegs) const override; |
Matthias Braun | 0256486 | 2015-07-14 17:17:13 +0000 | [diff] [blame] | 58 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 59 | RegScavenger *RS) const override; |
Anton Korobeynikov | 7283b8d | 2010-11-27 23:05:25 +0000 | [diff] [blame] | 60 | |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 61 | void adjustForSegmentedStacks(MachineFunction &MF, |
| 62 | MachineBasicBlock &MBB) const override; |
Oliver Stannard | b14c625 | 2014-04-02 16:10:33 +0000 | [diff] [blame] | 63 | |
Quentin Colombet | 8cb95b8 | 2015-11-18 00:40:54 +0000 | [diff] [blame] | 64 | /// Returns true if the target will correctly handle shrink wrapping. |
| 65 | bool enableShrinkWrapping(const MachineFunction &MF) const override { |
| 66 | return true; |
| 67 | } |
Oliver Stannard | 4b7239e | 2019-08-02 10:23:17 +0000 | [diff] [blame] | 68 | bool isProfitableForNoCSROpt(const Function &F) const override { |
| 69 | // The no-CSR optimisation is bad for code size on ARM, because we can save |
| 70 | // many registers with a single PUSH/POP pair. |
| 71 | return false; |
| 72 | } |
Quentin Colombet | 8cb95b8 | 2015-11-18 00:40:54 +0000 | [diff] [blame] | 73 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 74 | private: |
Anton Korobeynikov | d08fbd1 | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 75 | void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Jim Grosbach | 5fccad8 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 76 | const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc, |
| 77 | unsigned StrOpc, bool NoGap, |
Jakob Stoklund Olesen | 0965585 | 2011-12-23 00:36:18 +0000 | [diff] [blame] | 78 | bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs, |
Anton Korobeynikov | e7410dd | 2011-03-05 18:43:32 +0000 | [diff] [blame] | 79 | unsigned MIFlags = 0) const; |
Evan Cheng | 775ead3 | 2010-12-07 23:08:38 +0000 | [diff] [blame] | 80 | void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Krzysztof Parzyszek | bea30c6 | 2017-08-10 16:17:32 +0000 | [diff] [blame] | 81 | std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc, |
Jim Grosbach | 5fccad8 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 82 | unsigned LdrOpc, bool isVarArg, bool NoGap, |
Jakob Stoklund Olesen | 0965585 | 2011-12-23 00:36:18 +0000 | [diff] [blame] | 83 | bool(*Func)(unsigned, bool), |
| 84 | unsigned NumAlignedDPRCS2Regs) const; |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 85 | |
Hans Wennborg | e1a2e90 | 2016-03-31 18:33:38 +0000 | [diff] [blame] | 86 | MachineBasicBlock::iterator |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 87 | eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 88 | MachineBasicBlock &MBB, |
| 89 | MachineBasicBlock::iterator MI) const override; |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 92 | } // end namespace llvm |
Rafael Espindola | bf8e751 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 93 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 94 | #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H |