blob: 8e6001da05db21224a763228886a9445d88f751f [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===//
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Korobeynikovf7183ed2010-11-15 00:06:54 +00006//
7//===----------------------------------------------------------------------===//
8//
9//
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
14#define LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000015
16#include "Sparc.h"
David Blaikie1be62f02017-11-03 22:32:11 +000017#include "llvm/CodeGen/TargetFrameLowering.h"
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000018
19namespace llvm {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000020
Eric Christopher55414d42014-06-26 22:33:50 +000021class SparcSubtarget;
Anton Korobeynikov2f931282011-01-10 12:39:04 +000022class SparcFrameLowering : public TargetFrameLowering {
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000023public:
Eric Christopher55414d42014-06-26 22:33:50 +000024 explicit SparcFrameLowering(const SparcSubtarget &ST);
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000025
26 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
27 /// the function.
Quentin Colombet61b305e2015-05-05 17:38:16 +000028 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Craig Topperb0c941b2014-04-29 07:57:13 +000029 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
Anton Korobeynikov0eecf5d2010-11-18 21:19:35 +000030
Hans Wennborge1a2e902016-03-31 18:33:38 +000031 MachineBasicBlock::iterator
Craig Topperb0c941b2014-04-29 07:57:13 +000032 eliminateCallFramePseudoInstr(MachineFunction &MF,
33 MachineBasicBlock &MBB,
34 MachineBasicBlock::iterator I) const override;
Eli Bendersky8da87162013-02-21 20:05:00 +000035
Craig Topperb0c941b2014-04-29 07:57:13 +000036 bool hasReservedCallFrame(const MachineFunction &MF) const override;
37 bool hasFP(const MachineFunction &MF) const override;
Matthias Braun02564862015-07-14 17:17:13 +000038 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
39 RegScavenger *RS = nullptr) const override;
Venkatraman Govindarajuca0fe2f52013-05-29 04:46:31 +000040
James Y Knight667395f2015-08-21 04:17:56 +000041 int getFrameIndexReference(const MachineFunction &MF, int FI,
42 unsigned &FrameReg) const override;
James Y Knight36022862015-08-26 17:57:51 +000043
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 Govindarajuca0fe2f52013-05-29 04:46:31 +000049private:
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000050 // Remap input registers to output registers for leaf procedure.
Venkatraman Govindarajuca0fe2f52013-05-29 04:46:31 +000051 void remapRegsForLeafProc(MachineFunction &MF) const;
52
Venkatraman Govindarajua54533ed2013-06-04 18:33:25 +000053 // Returns true if MF is a leaf procedure.
Venkatraman Govindarajuca0fe2f52013-05-29 04:46:31 +000054 bool isLeafProc(MachineFunction &MF) const;
Venkatraman Govindaraju11168682013-11-24 20:23:25 +000055
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 Korobeynikovf7183ed2010-11-15 00:06:54 +000063};
64
Alexander Kornienkof00654e2015-06-23 09:49:53 +000065} // End llvm namespace
Anton Korobeynikovf7183ed2010-11-15 00:06:54 +000066
67#endif