Implement base Calling Convention functionality. Implement stack load/store register operations. Implement call lowering.
60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
//===- XtensaFrameLowering.cpp - Xtensa Frame Information -----------------===//
|
|
//
|
|
// 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 Xtensa implementation of TargetFrameLowering class.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "XtensaFrameLowering.h"
|
|
#include "XtensaInstrInfo.h"
|
|
#include "XtensaSubtarget.h"
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
#include "llvm/CodeGen/RegisterScavenging.h"
|
|
#include "llvm/IR/Function.h"
|
|
|
|
using namespace llvm;
|
|
|
|
XtensaFrameLowering::XtensaFrameLowering()
|
|
: TargetFrameLowering(TargetFrameLowering::StackGrowsDown, Align(4), 0,
|
|
Align(4)) {}
|
|
|
|
bool XtensaFrameLowering::hasFP(const MachineFunction &MF) const {
|
|
const MachineFrameInfo &MFI = MF.getFrameInfo();
|
|
return MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
|
MFI.hasVarSizedObjects();
|
|
}
|
|
|
|
void XtensaFrameLowering::emitPrologue(MachineFunction &MF,
|
|
MachineBasicBlock &MBB) const {}
|
|
|
|
void XtensaFrameLowering::emitEpilogue(MachineFunction &MF,
|
|
MachineBasicBlock &MBB) const {}
|
|
|
|
// Eliminate ADJCALLSTACKDOWN, ADJCALLSTACKUP pseudo instructions
|
|
MachineBasicBlock::iterator XtensaFrameLowering::eliminateCallFramePseudoInstr(
|
|
MachineFunction &MF, MachineBasicBlock &MBB,
|
|
MachineBasicBlock::iterator I) const {
|
|
const XtensaInstrInfo &TII =
|
|
*static_cast<const XtensaInstrInfo *>(MF.getSubtarget().getInstrInfo());
|
|
|
|
if (!hasReservedCallFrame(MF)) {
|
|
int64_t Amount = I->getOperand(0).getImm();
|
|
|
|
if (I->getOpcode() == Xtensa::ADJCALLSTACKDOWN)
|
|
Amount = -Amount;
|
|
|
|
unsigned SP = Xtensa::SP;
|
|
TII.adjustStackPtr(SP, Amount, MBB, I);
|
|
}
|
|
|
|
return MBB.erase(I);
|
|
}
|