Path: blob/main/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVFrameLowering.h
35266 views
//===-- RISCVFrameLowering.h - Define frame lowering for RISC-V -*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This class implements RISC-V specific bits of TargetFrameLowering class.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H13#define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H1415#include "llvm/CodeGen/TargetFrameLowering.h"16#include "llvm/Support/TypeSize.h"1718namespace llvm {19class RISCVSubtarget;2021class RISCVFrameLowering : public TargetFrameLowering {22public:23explicit RISCVFrameLowering(const RISCVSubtarget &STI);2425void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;26void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;2728uint64_t getStackSizeWithRVVPadding(const MachineFunction &MF) const;2930StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,31Register &FrameReg) const override;3233void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,34RegScavenger *RS) const override;3536void processFunctionBeforeFrameFinalized(MachineFunction &MF,37RegScavenger *RS) const override;3839bool hasFP(const MachineFunction &MF) const override;4041bool hasBP(const MachineFunction &MF) const;4243bool hasReservedCallFrame(const MachineFunction &MF) const override;44MachineBasicBlock::iterator45eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,46MachineBasicBlock::iterator MI) const override;4748bool assignCalleeSavedSpillSlots(MachineFunction &MF,49const TargetRegisterInfo *TRI,50std::vector<CalleeSavedInfo> &CSI,51unsigned &MinCSFrameIndex,52unsigned &MaxCSFrameIndex) const override;53bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,54MachineBasicBlock::iterator MI,55ArrayRef<CalleeSavedInfo> CSI,56const TargetRegisterInfo *TRI) const override;57bool58restoreCalleeSavedRegisters(MachineBasicBlock &MBB,59MachineBasicBlock::iterator MI,60MutableArrayRef<CalleeSavedInfo> CSI,61const TargetRegisterInfo *TRI) const override;6263// Get the first stack adjustment amount for SplitSPAdjust.64// Return 0 if we don't want to split the SP adjustment in prologue and65// epilogue.66uint64_t getFirstSPAdjustAmount(const MachineFunction &MF) const;6768bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;69bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;7071bool enableShrinkWrapping(const MachineFunction &MF) const override;7273bool isSupportedStackID(TargetStackID::Value ID) const override;74TargetStackID::Value getStackIDForScalableVectors() const override;7576bool isStackIdSafeForLocalArea(unsigned StackId) const override {77// We don't support putting RISC-V Vector objects into the pre-allocated78// local frame block at the moment.79return StackId != TargetStackID::ScalableVector;80}8182protected:83const RISCVSubtarget &STI;8485private:86void determineFrameLayout(MachineFunction &MF) const;87void adjustStackForRVV(MachineFunction &MF, MachineBasicBlock &MBB,88MachineBasicBlock::iterator MBBI, const DebugLoc &DL,89int64_t Amount, MachineInstr::MIFlag Flag) const;90void emitCalleeSavedRVVPrologCFI(MachineBasicBlock &MBB,91MachineBasicBlock::iterator MI,92bool HasFP) const;93std::pair<int64_t, Align>94assignRVVStackObjectOffsets(MachineFunction &MF) const;95};96} // namespace llvm97#endif9899100