Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===// |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +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 |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H |
| 14 | #define LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 15 | |
| 16 | #include "Sparc.h" |
David Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/TargetFrameLowering.h" |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 20 | |
Eric Christopher | 55414d4 | 2014-06-26 22:33:50 +0000 | [diff] [blame] | 21 | class SparcSubtarget; |
Anton Korobeynikov | 2f93128 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 22 | class SparcFrameLowering : public TargetFrameLowering { |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 23 | public: |
Eric Christopher | 55414d4 | 2014-06-26 22:33:50 +0000 | [diff] [blame] | 24 | explicit SparcFrameLowering(const SparcSubtarget &ST); |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 25 | |
| 26 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 27 | /// the function. |
Quentin Colombet | 61b305e | 2015-05-05 17:38:16 +0000 | [diff] [blame] | 28 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 29 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
Anton Korobeynikov | 0eecf5d | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 30 | |
Hans Wennborg | e1a2e90 | 2016-03-31 18:33:38 +0000 | [diff] [blame] | 31 | MachineBasicBlock::iterator |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 32 | eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 33 | MachineBasicBlock &MBB, |
| 34 | MachineBasicBlock::iterator I) const override; |
Eli Bendersky | 8da8716 | 2013-02-21 20:05:00 +0000 | [diff] [blame] | 35 | |
Craig Topper | b0c941b | 2014-04-29 07:57:13 +0000 | [diff] [blame] | 36 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
| 37 | bool hasFP(const MachineFunction &MF) const override; |
Matthias Braun | 0256486 | 2015-07-14 17:17:13 +0000 | [diff] [blame] | 38 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 39 | RegScavenger *RS = nullptr) const override; |
Venkatraman Govindaraju | ca0fe2f5 | 2013-05-29 04:46:31 +0000 | [diff] [blame] | 40 | |
James Y Knight | 667395f | 2015-08-21 04:17:56 +0000 | [diff] [blame] | 41 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
| 42 | unsigned &FrameReg) const override; |
James Y Knight | 3602286 | 2015-08-26 17:57:51 +0000 | [diff] [blame] | 43 | |
| 44 | /// targetHandlesStackFrameRounding - Returns true if the target is |
| 45 | /// responsible for rounding up the stack frame (probably at emitPrologue |
| 46 | /// time). |
| 47 | bool targetHandlesStackFrameRounding() const override { return true; } |
| 48 | |
Venkatraman Govindaraju | ca0fe2f5 | 2013-05-29 04:46:31 +0000 | [diff] [blame] | 49 | private: |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 50 | // Remap input registers to output registers for leaf procedure. |
Venkatraman Govindaraju | ca0fe2f5 | 2013-05-29 04:46:31 +0000 | [diff] [blame] | 51 | void remapRegsForLeafProc(MachineFunction &MF) const; |
| 52 | |
Venkatraman Govindaraju | a54533ed | 2013-06-04 18:33:25 +0000 | [diff] [blame] | 53 | // Returns true if MF is a leaf procedure. |
Venkatraman Govindaraju | ca0fe2f5 | 2013-05-29 04:46:31 +0000 | [diff] [blame] | 54 | bool isLeafProc(MachineFunction &MF) const; |
Venkatraman Govindaraju | 1116868 | 2013-11-24 20:23:25 +0000 | [diff] [blame] | 55 | |
| 56 | |
| 57 | // Emits code for adjusting SP in function prologue/epilogue. |
| 58 | void emitSPAdjustment(MachineFunction &MF, |
| 59 | MachineBasicBlock &MBB, |
| 60 | MachineBasicBlock::iterator MBBI, |
| 61 | int NumBytes, unsigned ADDrr, unsigned ADDri) const; |
| 62 | |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 65 | } // End llvm namespace |
Anton Korobeynikov | f7183ed | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 66 | |
| 67 | #endif |