109467b48Spatrick //===-- VEFrameLowering.h - Define frame lowering for VE --*- C++ -*-===// 209467b48Spatrick // 309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information. 509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 609467b48Spatrick // 709467b48Spatrick //===----------------------------------------------------------------------===// 809467b48Spatrick // 909467b48Spatrick // This class implements VE-specific bits of TargetFrameLowering class. 1009467b48Spatrick // 1109467b48Spatrick //===----------------------------------------------------------------------===// 1209467b48Spatrick 1309467b48Spatrick #ifndef LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H 1409467b48Spatrick #define LLVM_LIB_TARGET_VE_VEFRAMELOWERING_H 1509467b48Spatrick 1609467b48Spatrick #include "VE.h" 1709467b48Spatrick #include "llvm/CodeGen/TargetFrameLowering.h" 1873471bf0Spatrick #include "llvm/Support/TypeSize.h" 1909467b48Spatrick 2009467b48Spatrick namespace llvm { 2109467b48Spatrick 2209467b48Spatrick class VESubtarget; 2309467b48Spatrick class VEFrameLowering : public TargetFrameLowering { 2409467b48Spatrick public: 2509467b48Spatrick explicit VEFrameLowering(const VESubtarget &ST); 2609467b48Spatrick 2709467b48Spatrick /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 2809467b48Spatrick /// the function. 2909467b48Spatrick void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 3009467b48Spatrick void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 3109467b48Spatrick void emitPrologueInsns(MachineFunction &MF, MachineBasicBlock &MBB, 32097a140dSpatrick MachineBasicBlock::iterator MBBI, uint64_t NumBytes, 3309467b48Spatrick bool RequireFPUpdate) const; 3409467b48Spatrick void emitEpilogueInsns(MachineFunction &MF, MachineBasicBlock &MBB, 35097a140dSpatrick MachineBasicBlock::iterator MBBI, uint64_t NumBytes, 3609467b48Spatrick bool RequireFPUpdate) const; 3709467b48Spatrick 3809467b48Spatrick MachineBasicBlock::iterator 3909467b48Spatrick eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, 4009467b48Spatrick MachineBasicBlock::iterator I) const override; 4109467b48Spatrick 4209467b48Spatrick bool hasFP(const MachineFunction &MF) const override; 4373471bf0Spatrick bool hasBP(const MachineFunction &MF) const; 4473471bf0Spatrick bool hasGOT(const MachineFunction &MF) const; 4573471bf0Spatrick 46097a140dSpatrick // VE reserves argument space always for call sites in the function 47097a140dSpatrick // immediately on entry of the current function. hasReservedCallFrame(const MachineFunction & MF)48097a140dSpatrick bool hasReservedCallFrame(const MachineFunction &MF) const override { 49097a140dSpatrick return true; 50097a140dSpatrick } 5109467b48Spatrick void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, 5209467b48Spatrick RegScavenger *RS = nullptr) const override; 5309467b48Spatrick 5473471bf0Spatrick StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, 55097a140dSpatrick Register &FrameReg) const override; 5609467b48Spatrick 5709467b48Spatrick const SpillSlot * getCalleeSavedSpillSlots(unsigned & NumEntries)5809467b48Spatrick getCalleeSavedSpillSlots(unsigned &NumEntries) const override { 5909467b48Spatrick static const SpillSlot Offsets[] = { 6009467b48Spatrick {VE::SX17, 40}, {VE::SX18, 48}, {VE::SX19, 56}, {VE::SX20, 64}, 6109467b48Spatrick {VE::SX21, 72}, {VE::SX22, 80}, {VE::SX23, 88}, {VE::SX24, 96}, 6209467b48Spatrick {VE::SX25, 104}, {VE::SX26, 112}, {VE::SX27, 120}, {VE::SX28, 128}, 6309467b48Spatrick {VE::SX29, 136}, {VE::SX30, 144}, {VE::SX31, 152}, {VE::SX32, 160}, 6409467b48Spatrick {VE::SX33, 168}}; 65*d415bd75Srobert NumEntries = std::size(Offsets); 6609467b48Spatrick return Offsets; 6709467b48Spatrick } 6809467b48Spatrick 69097a140dSpatrick protected: 70097a140dSpatrick const VESubtarget &STI; 7109467b48Spatrick 7209467b48Spatrick private: 7309467b48Spatrick // Returns true if MF is a leaf procedure. 7409467b48Spatrick bool isLeafProc(MachineFunction &MF) const; 7509467b48Spatrick 7609467b48Spatrick // Emits code for adjusting SP in function prologue/epilogue. 7709467b48Spatrick void emitSPAdjustment(MachineFunction &MF, MachineBasicBlock &MBB, 78097a140dSpatrick MachineBasicBlock::iterator MBBI, int64_t NumBytes, 79097a140dSpatrick MaybeAlign MayAlign = MaybeAlign()) const; 8009467b48Spatrick 8109467b48Spatrick // Emits code for extending SP in function prologue/epilogue. 8209467b48Spatrick void emitSPExtend(MachineFunction &MF, MachineBasicBlock &MBB, 83097a140dSpatrick MachineBasicBlock::iterator MBBI) const; 8409467b48Spatrick }; 8509467b48Spatrick 8609467b48Spatrick } // namespace llvm 8709467b48Spatrick 8809467b48Spatrick #endif 89