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