1 //=- LoongArchFrameLowering.h - TargetFrameLowering for LoongArch -*- 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 LoongArch-specific bits of TargetFrameLowering class. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H 14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H 15 16 #include "llvm/CodeGen/TargetFrameLowering.h" 17 18 namespace llvm { 19 class LoongArchSubtarget; 20 21 class LoongArchFrameLowering : public TargetFrameLowering { 22 const LoongArchSubtarget &STI; 23 24 public: 25 explicit LoongArchFrameLowering(const LoongArchSubtarget &STI) 26 : TargetFrameLowering(StackGrowsDown, 27 /*StackAlignment=*/Align(16), 28 /*LocalAreaOffset=*/0), 29 STI(STI) {} 30 31 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 32 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 33 34 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, 35 RegScavenger *RS) const override; 36 37 MachineBasicBlock::iterator 38 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, 39 MachineBasicBlock::iterator MI) const override { 40 return MBB.erase(MI); 41 } 42 43 StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, 44 Register &FrameReg) const override; 45 46 bool hasFP(const MachineFunction &MF) const override; 47 bool hasBP(const MachineFunction &MF) const; 48 49 private: 50 void determineFrameLayout(MachineFunction &MF) const; 51 void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, 52 const DebugLoc &DL, Register DestReg, Register SrcReg, 53 int64_t Val, MachineInstr::MIFlag Flag) const; 54 }; 55 } // end namespace llvm 56 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H 57