1//===-- VEFrameLowering.h - Define frame lowering for VE --*- 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// This class implements VE-specific bits of TargetFrameLowering class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H
14#define LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H
15
16#include "VE.h"
17#include "llvm/CodeGen/TargetFrameLowering.h"
18#include "llvm/Support/TypeSize.h"
19
20namespace llvm {
21
22class VESubtarget;
23class VEFrameLowering : public TargetFrameLowering {
24public:
25 explicit VEFrameLowering(const VESubtarget &ST);
26
27 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
28 /// the function.
29 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
30 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31 void emitPrologueInsns(MachineFunction &MF, MachineBasicBlock &MBB,
32 MachineBasicBlock::iterator MBBI, uint64_t NumBytes,
33 bool RequireFPUpdate) const;
34 void emitEpilogueInsns(MachineFunction &MF, MachineBasicBlock &MBB,
35 MachineBasicBlock::iterator MBBI, uint64_t NumBytes,
36 bool RequireFPUpdate) const;
37
38 MachineBasicBlock::iterator
39 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
40 MachineBasicBlock::iterator I) const override;
41
42 bool hasFP(const MachineFunction &MF) const override;
43 bool hasBP(const MachineFunction &MF) const;
44 bool hasGOT(const MachineFunction &MF) const;
45
46 // VE reserves argument space always for call sites in the function
47 // immediately on entry of the current function.
48 bool hasReservedCallFrame(const MachineFunction &MF) const override {
49 return true;
50 }
51 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
52 RegScavenger *RS = nullptr) const override;
53
54 StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
55 Register &FrameReg) const override;
56
57 const SpillSlot *
58 getCalleeSavedSpillSlots(unsigned &NumEntries) const override {
59 static const SpillSlot Offsets[] = {
60 {.Reg: VE::SX17, .Offset: 40}, {.Reg: VE::SX18, .Offset: 48}, {.Reg: VE::SX19, .Offset: 56}, {.Reg: VE::SX20, .Offset: 64},
61 {.Reg: VE::SX21, .Offset: 72}, {.Reg: VE::SX22, .Offset: 80}, {.Reg: VE::SX23, .Offset: 88}, {.Reg: VE::SX24, .Offset: 96},
62 {.Reg: VE::SX25, .Offset: 104}, {.Reg: VE::SX26, .Offset: 112}, {.Reg: VE::SX27, .Offset: 120}, {.Reg: VE::SX28, .Offset: 128},
63 {.Reg: VE::SX29, .Offset: 136}, {.Reg: VE::SX30, .Offset: 144}, {.Reg: VE::SX31, .Offset: 152}, {.Reg: VE::SX32, .Offset: 160},
64 {.Reg: VE::SX33, .Offset: 168}};
65 NumEntries = std::size(Offsets);
66 return Offsets;
67 }
68
69protected:
70 const VESubtarget &STI;
71
72private:
73 // Returns true if MF is a leaf procedure.
74 bool isLeafProc(MachineFunction &MF) const;
75
76 // Emits code for adjusting SP in function prologue/epilogue.
77 void emitSPAdjustment(MachineFunction &MF, MachineBasicBlock &MBB,
78 MachineBasicBlock::iterator MBBI, int64_t NumBytes,
79 MaybeAlign MayAlign = MaybeAlign()) const;
80
81 // Emits code for extending SP in function prologue/epilogue.
82 void emitSPExtend(MachineFunction &MF, MachineBasicBlock &MBB,
83 MachineBasicBlock::iterator MBBI) const;
84};
85
86} // namespace llvm
87
88#endif
89