xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/VE/VEFrameLowering.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1480093f4SDimitry Andric //===-- VEFrameLowering.h - Define frame lowering for VE --*- C++ -*-===//
2480093f4SDimitry Andric //
3480093f4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4480093f4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5480093f4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6480093f4SDimitry Andric //
7480093f4SDimitry Andric //===----------------------------------------------------------------------===//
8480093f4SDimitry Andric //
9480093f4SDimitry Andric // This class implements VE-specific bits of TargetFrameLowering class.
10480093f4SDimitry Andric //
11480093f4SDimitry Andric //===----------------------------------------------------------------------===//
12480093f4SDimitry Andric 
13480093f4SDimitry Andric #ifndef LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H
14480093f4SDimitry Andric #define LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H
15480093f4SDimitry Andric 
16480093f4SDimitry Andric #include "VE.h"
17480093f4SDimitry Andric #include "llvm/CodeGen/TargetFrameLowering.h"
18e8d8bef9SDimitry Andric #include "llvm/Support/TypeSize.h"
19480093f4SDimitry Andric 
20480093f4SDimitry Andric namespace llvm {
21480093f4SDimitry Andric 
22480093f4SDimitry Andric class VESubtarget;
23480093f4SDimitry Andric class VEFrameLowering : public TargetFrameLowering {
24480093f4SDimitry Andric public:
25480093f4SDimitry Andric   explicit VEFrameLowering(const VESubtarget &ST);
26480093f4SDimitry Andric 
27480093f4SDimitry Andric   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
28480093f4SDimitry Andric   /// the function.
29480093f4SDimitry Andric   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
30480093f4SDimitry Andric   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31480093f4SDimitry Andric   void emitPrologueInsns(MachineFunction &MF, MachineBasicBlock &MBB,
325ffd83dbSDimitry Andric                          MachineBasicBlock::iterator MBBI, uint64_t NumBytes,
33480093f4SDimitry Andric                          bool RequireFPUpdate) const;
34480093f4SDimitry Andric   void emitEpilogueInsns(MachineFunction &MF, MachineBasicBlock &MBB,
355ffd83dbSDimitry Andric                          MachineBasicBlock::iterator MBBI, uint64_t NumBytes,
36480093f4SDimitry Andric                          bool RequireFPUpdate) const;
37480093f4SDimitry Andric 
38480093f4SDimitry Andric   MachineBasicBlock::iterator
39480093f4SDimitry Andric   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
40480093f4SDimitry Andric                                 MachineBasicBlock::iterator I) const override;
41480093f4SDimitry Andric 
42480093f4SDimitry Andric   bool hasFP(const MachineFunction &MF) const override;
43e8d8bef9SDimitry Andric   bool hasBP(const MachineFunction &MF) const;
44e8d8bef9SDimitry Andric   bool hasGOT(const MachineFunction &MF) const;
45e8d8bef9SDimitry Andric 
465ffd83dbSDimitry Andric   // VE reserves argument space always for call sites in the function
475ffd83dbSDimitry Andric   // immediately on entry of the current function.
hasReservedCallFrame(const MachineFunction & MF)485ffd83dbSDimitry Andric   bool hasReservedCallFrame(const MachineFunction &MF) const override {
495ffd83dbSDimitry Andric     return true;
505ffd83dbSDimitry Andric   }
51480093f4SDimitry Andric   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
52480093f4SDimitry Andric                             RegScavenger *RS = nullptr) const override;
53480093f4SDimitry Andric 
54e8d8bef9SDimitry Andric   StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
555ffd83dbSDimitry Andric                                      Register &FrameReg) const override;
56480093f4SDimitry Andric 
57480093f4SDimitry Andric   const SpillSlot *
getCalleeSavedSpillSlots(unsigned & NumEntries)58480093f4SDimitry Andric   getCalleeSavedSpillSlots(unsigned &NumEntries) const override {
59480093f4SDimitry Andric     static const SpillSlot Offsets[] = {
60480093f4SDimitry Andric         {VE::SX17, 40},  {VE::SX18, 48},  {VE::SX19, 56},  {VE::SX20, 64},
61480093f4SDimitry Andric         {VE::SX21, 72},  {VE::SX22, 80},  {VE::SX23, 88},  {VE::SX24, 96},
62480093f4SDimitry Andric         {VE::SX25, 104}, {VE::SX26, 112}, {VE::SX27, 120}, {VE::SX28, 128},
63480093f4SDimitry Andric         {VE::SX29, 136}, {VE::SX30, 144}, {VE::SX31, 152}, {VE::SX32, 160},
64480093f4SDimitry Andric         {VE::SX33, 168}};
65*bdd1243dSDimitry Andric     NumEntries = std::size(Offsets);
66480093f4SDimitry Andric     return Offsets;
67480093f4SDimitry Andric   }
68480093f4SDimitry Andric 
695ffd83dbSDimitry Andric protected:
705ffd83dbSDimitry Andric   const VESubtarget &STI;
71480093f4SDimitry Andric 
72480093f4SDimitry Andric private:
73480093f4SDimitry Andric   // Returns true if MF is a leaf procedure.
74480093f4SDimitry Andric   bool isLeafProc(MachineFunction &MF) const;
75480093f4SDimitry Andric 
76480093f4SDimitry Andric   // Emits code for adjusting SP in function prologue/epilogue.
77480093f4SDimitry Andric   void emitSPAdjustment(MachineFunction &MF, MachineBasicBlock &MBB,
785ffd83dbSDimitry Andric                         MachineBasicBlock::iterator MBBI, int64_t NumBytes,
795ffd83dbSDimitry Andric                         MaybeAlign MayAlign = MaybeAlign()) const;
80480093f4SDimitry Andric 
81480093f4SDimitry Andric   // Emits code for extending SP in function prologue/epilogue.
82480093f4SDimitry Andric   void emitSPExtend(MachineFunction &MF, MachineBasicBlock &MBB,
835ffd83dbSDimitry Andric                     MachineBasicBlock::iterator MBBI) const;
84480093f4SDimitry Andric };
85480093f4SDimitry Andric 
86480093f4SDimitry Andric } // namespace llvm
87480093f4SDimitry Andric 
88480093f4SDimitry Andric #endif
89