1//===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9//
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
14#define LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
15
16#include "Sparc.h"
17#include "llvm/CodeGen/TargetFrameLowering.h"
18#include "llvm/Support/TypeSize.h"
19
20namespace llvm {
21
22class SparcSubtarget;
23class SparcFrameLowering : public TargetFrameLowering {
24 const SparcSubtarget &STI;
25
26public:
27 explicit SparcFrameLowering(const SparcSubtarget &ST);
28
29 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
30 /// the function.
31 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
32 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
33
34 MachineBasicBlock::iterator
35 eliminateCallFramePseudoInstr(MachineFunction &MF,
36 MachineBasicBlock &MBB,
37 MachineBasicBlock::iterator I) const override;
38
39 bool hasReservedCallFrame(const MachineFunction &MF) const override;
40 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
41 RegScavenger *RS = nullptr) const override;
42
43 StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
44 Register &FrameReg) const override;
45
46 /// targetHandlesStackFrameRounding - Returns true if the target is
47 /// responsible for rounding up the stack frame (probably at emitPrologue
48 /// time).
49 bool targetHandlesStackFrameRounding() const override { return true; }
50
51 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
52 RegScavenger *RS) const override;
53
54 void
55 processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF,
56 RegScavenger *RS) const override;
57
58protected:
59 bool hasFPImpl(const MachineFunction &MF) const override;
60
61private:
62 // Remap input registers to output registers for leaf procedure.
63 void remapRegsForLeafProc(MachineFunction &MF) const;
64
65 // Returns true if MF is a leaf procedure.
66 bool isLeafProc(MachineFunction &MF) const;
67
68
69 // Emits code for adjusting SP in function prologue/epilogue.
70 void emitSPAdjustment(MachineFunction &MF, MachineBasicBlock &MBB,
71 MachineBasicBlock::iterator MBBI, const DebugLoc &dl,
72 int NumBytes, unsigned ADDrr, unsigned ADDri) const;
73};
74
75} // End llvm namespace
76
77#endif
78