1 //=- LoongArchFrameLowering.h - TargetFrameLowering for LoongArch -*- C++ -*--//
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
7 //===----------------------------------------------------------------------===//
9 // This class implements LoongArch-specific bits of TargetFrameLowering class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
16 #include "llvm/CodeGen/TargetFrameLowering.h"
19 class LoongArchSubtarget
;
21 class LoongArchFrameLowering
: public TargetFrameLowering
{
22 const LoongArchSubtarget
&STI
;
25 explicit LoongArchFrameLowering(const LoongArchSubtarget
&STI
)
26 : TargetFrameLowering(StackGrowsDown
,
27 /*StackAlignment=*/Align(16),
28 /*LocalAreaOffset=*/0),
31 void emitPrologue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
32 void emitEpilogue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
34 void determineCalleeSaves(MachineFunction
&MF
, BitVector
&SavedRegs
,
35 RegScavenger
*RS
) const override
;
37 void processFunctionBeforeFrameFinalized(MachineFunction
&MF
,
38 RegScavenger
*RS
) const override
;
40 bool hasReservedCallFrame(const MachineFunction
&MF
) const override
;
41 MachineBasicBlock::iterator
42 eliminateCallFramePseudoInstr(MachineFunction
&MF
, MachineBasicBlock
&MBB
,
43 MachineBasicBlock::iterator MI
) const override
;
44 bool spillCalleeSavedRegisters(MachineBasicBlock
&MBB
,
45 MachineBasicBlock::iterator MI
,
46 ArrayRef
<CalleeSavedInfo
> CSI
,
47 const TargetRegisterInfo
*TRI
) const override
;
49 StackOffset
getFrameIndexReference(const MachineFunction
&MF
, int FI
,
50 Register
&FrameReg
) const override
;
52 bool hasFP(const MachineFunction
&MF
) const override
;
53 bool hasBP(const MachineFunction
&MF
) const;
55 uint64_t getFirstSPAdjustAmount(const MachineFunction
&MF
) const;
57 bool enableShrinkWrapping(const MachineFunction
&MF
) const override
;
60 void determineFrameLayout(MachineFunction
&MF
) const;
61 void adjustReg(MachineBasicBlock
&MBB
, MachineBasicBlock::iterator MBBI
,
62 const DebugLoc
&DL
, Register DestReg
, Register SrcReg
,
63 int64_t Val
, MachineInstr::MIFlag Flag
) const;
65 } // end namespace llvm
66 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H