1 //===-- CSKYFrameLowering.h - Define frame lowering for CSKY -*- 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 CSKY-specific bits of TargetFrameLowering class.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H
14 #define LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H
16 #include "llvm/CodeGen/TargetFrameLowering.h"
21 class CSKYFrameLowering
: public TargetFrameLowering
{
22 const CSKYSubtarget
&STI
;
24 void determineFrameLayout(MachineFunction
&MF
) const;
25 void adjustReg(MachineBasicBlock
&MBB
, MachineBasicBlock::iterator MBBI
,
26 const DebugLoc
&DL
, Register DestReg
, Register SrcReg
,
27 int64_t Val
, MachineInstr::MIFlag Flag
) const;
30 explicit CSKYFrameLowering(const CSKYSubtarget
&STI
)
31 : TargetFrameLowering(StackGrowsDown
,
32 /*StackAlignment=*/Align(4),
33 /*LocalAreaOffset=*/0),
36 void emitPrologue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
37 void emitEpilogue(MachineFunction
&MF
, MachineBasicBlock
&MBB
) const override
;
39 StackOffset
getFrameIndexReference(const MachineFunction
&MF
, int FI
,
40 Register
&FrameReg
) const override
;
42 void determineCalleeSaves(MachineFunction
&MF
, BitVector
&SavedRegs
,
43 RegScavenger
*RS
) const override
;
45 bool assignCalleeSavedSpillSlots(
46 MachineFunction
&MF
, const TargetRegisterInfo
*TRI
,
47 std::vector
<CalleeSavedInfo
> &CSI
) const override
{
49 std::reverse(CSI
.begin(), CSI
.end());
54 bool spillCalleeSavedRegisters(MachineBasicBlock
&MBB
,
55 MachineBasicBlock::iterator MI
,
56 ArrayRef
<CalleeSavedInfo
> CSI
,
57 const TargetRegisterInfo
*TRI
) const override
;
59 restoreCalleeSavedRegisters(MachineBasicBlock
&MBB
,
60 MachineBasicBlock::iterator MI
,
61 MutableArrayRef
<CalleeSavedInfo
> CSI
,
62 const TargetRegisterInfo
*TRI
) const override
;
64 bool hasBP(const MachineFunction
&MF
) const;
66 bool hasReservedCallFrame(const MachineFunction
&MF
) const override
;
68 MachineBasicBlock::iterator
69 eliminateCallFramePseudoInstr(MachineFunction
&MF
, MachineBasicBlock
&MBB
,
70 MachineBasicBlock::iterator MI
) const override
;
73 bool hasFPImpl(const MachineFunction
&MF
) const override
;