diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp b/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp new file mode 100644 index 000000000000..7182d55ca3cf --- /dev/null +++ b/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchFrameLowering.cpp @@ -0,0 +1,55 @@ +//===-- LoongArchFrameLowering.cpp - LoongArch Frame Information -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the LoongArch implementation of TargetFrameLowering class. +// +//===----------------------------------------------------------------------===// + +#include "LoongArchFrameLowering.h" +#include "LoongArchSubtarget.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/IR/DiagnosticInfo.h" +#include "llvm/MC/MCDwarf.h" + +using namespace llvm; + +#define DEBUG_TYPE "loongarch-frame-lowering" + +// Return true if the specified function should have a dedicated frame +// pointer register. This is true if frame pointer elimination is +// disabled, if it needs dynamic stack realignment, if the function has +// variable sized allocas, or if the frame address is taken. +bool LoongArchFrameLowering::hasFP(const MachineFunction &MF) const { + const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo(); + + const MachineFrameInfo &MFI = MF.getFrameInfo(); + return MF.getTarget().Options.DisableFramePointerElim(MF) || + RegInfo->hasStackRealignment(MF) || MFI.hasVarSizedObjects() || + MFI.isFrameAddressTaken(); +} + +bool LoongArchFrameLowering::hasBP(const MachineFunction &MF) const { + const MachineFrameInfo &MFI = MF.getFrameInfo(); + const TargetRegisterInfo *TRI = STI.getRegisterInfo(); + + return MFI.hasVarSizedObjects() && TRI->hasStackRealignment(MF); +} + +void LoongArchFrameLowering::emitPrologue(MachineFunction &MF, + MachineBasicBlock &MBB) const { + // TODO: Implement this when we have function calls +} + +void LoongArchFrameLowering::emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { + // TODO: Implement this when we have function calls +} |