xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.h (revision 753f127f3ace09432b2baeffd71a308760641a62)
181ad6265SDimitry Andric //=- LoongArchFrameLowering.h - TargetFrameLowering for LoongArch -*- C++ -*--//
281ad6265SDimitry Andric //
381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric //
781ad6265SDimitry Andric //===----------------------------------------------------------------------===//
881ad6265SDimitry Andric //
981ad6265SDimitry Andric // This class implements LoongArch-specific bits of TargetFrameLowering class.
1081ad6265SDimitry Andric //
1181ad6265SDimitry Andric //===----------------------------------------------------------------------===//
1281ad6265SDimitry Andric 
1381ad6265SDimitry Andric #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
1481ad6265SDimitry Andric #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
1581ad6265SDimitry Andric 
1681ad6265SDimitry Andric #include "llvm/CodeGen/TargetFrameLowering.h"
1781ad6265SDimitry Andric 
1881ad6265SDimitry Andric namespace llvm {
1981ad6265SDimitry Andric class LoongArchSubtarget;
2081ad6265SDimitry Andric 
2181ad6265SDimitry Andric class LoongArchFrameLowering : public TargetFrameLowering {
2281ad6265SDimitry Andric   const LoongArchSubtarget &STI;
2381ad6265SDimitry Andric 
2481ad6265SDimitry Andric public:
2581ad6265SDimitry Andric   explicit LoongArchFrameLowering(const LoongArchSubtarget &STI)
2681ad6265SDimitry Andric       : TargetFrameLowering(StackGrowsDown,
2781ad6265SDimitry Andric                             /*StackAlignment=*/Align(16),
2881ad6265SDimitry Andric                             /*LocalAreaOffset=*/0),
2981ad6265SDimitry Andric         STI(STI) {}
3081ad6265SDimitry Andric 
3181ad6265SDimitry Andric   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
3281ad6265SDimitry Andric   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
3381ad6265SDimitry Andric 
34*753f127fSDimitry Andric   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
35*753f127fSDimitry Andric                             RegScavenger *RS) const override;
36*753f127fSDimitry Andric 
37*753f127fSDimitry Andric   MachineBasicBlock::iterator
38*753f127fSDimitry Andric   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
39*753f127fSDimitry Andric                                 MachineBasicBlock::iterator MI) const override {
40*753f127fSDimitry Andric     return MBB.erase(MI);
41*753f127fSDimitry Andric   }
42*753f127fSDimitry Andric 
43*753f127fSDimitry Andric   StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
44*753f127fSDimitry Andric                                      Register &FrameReg) const override;
45*753f127fSDimitry Andric 
4681ad6265SDimitry Andric   bool hasFP(const MachineFunction &MF) const override;
4781ad6265SDimitry Andric   bool hasBP(const MachineFunction &MF) const;
48*753f127fSDimitry Andric 
49*753f127fSDimitry Andric private:
50*753f127fSDimitry Andric   void determineFrameLayout(MachineFunction &MF) const;
51*753f127fSDimitry Andric   void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
52*753f127fSDimitry Andric                  const DebugLoc &DL, Register DestReg, Register SrcReg,
53*753f127fSDimitry Andric                  int64_t Val, MachineInstr::MIFlag Flag) const;
5481ad6265SDimitry Andric };
5581ad6265SDimitry Andric } // namespace llvm
5681ad6265SDimitry Andric #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
57