77 lines · c
1//===-- CSKYFrameLowering.h - Define frame lowering for CSKY -*- 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-exception6//7//===----------------------------------------------------------------------===//8//9// This class implements CSKY-specific bits of TargetFrameLowering class.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H14#define LLVM_LIB_TARGET_CSKY_CSKYFRAMELOWERING_H15 16#include "llvm/CodeGen/TargetFrameLowering.h"17 18namespace llvm {19class CSKYSubtarget;20 21class CSKYFrameLowering : public TargetFrameLowering {22 const CSKYSubtarget &STI;23 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;28 29public:30 explicit CSKYFrameLowering(const CSKYSubtarget &STI)31 : TargetFrameLowering(StackGrowsDown,32 /*StackAlignment=*/Align(4),33 /*LocalAreaOffset=*/0),34 STI(STI) {}35 36 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;37 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;38 39 StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,40 Register &FrameReg) const override;41 42 void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,43 RegScavenger *RS) const override;44 45 bool assignCalleeSavedSpillSlots(46 MachineFunction &MF, const TargetRegisterInfo *TRI,47 std::vector<CalleeSavedInfo> &CSI) const override {48 49 std::reverse(CSI.begin(), CSI.end());50 51 return false;52 }53 54 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,55 MachineBasicBlock::iterator MI,56 ArrayRef<CalleeSavedInfo> CSI,57 const TargetRegisterInfo *TRI) const override;58 bool59 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,60 MachineBasicBlock::iterator MI,61 MutableArrayRef<CalleeSavedInfo> CSI,62 const TargetRegisterInfo *TRI) const override;63 64 bool hasBP(const MachineFunction &MF) const;65 66 bool hasReservedCallFrame(const MachineFunction &MF) const override;67 68 MachineBasicBlock::iterator69 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,70 MachineBasicBlock::iterator MI) const override;71 72protected:73 bool hasFPImpl(const MachineFunction &MF) const override;74};75} // namespace llvm76#endif77