2017-10-20 05:37:38 +08:00
|
|
|
//===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2017-10-20 05:37:38 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This class implements RISCV-specific bits of TargetFrameLowering class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H
|
|
|
|
|
2017-11-04 06:32:11 +08:00
|
|
|
#include "llvm/CodeGen/TargetFrameLowering.h"
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class RISCVSubtarget;
|
|
|
|
|
|
|
|
class RISCVFrameLowering : public TargetFrameLowering {
|
|
|
|
public:
|
|
|
|
explicit RISCVFrameLowering(const RISCVSubtarget &STI)
|
|
|
|
: TargetFrameLowering(StackGrowsDown,
|
|
|
|
/*StackAlignment=*/16,
|
2017-12-11 20:34:11 +08:00
|
|
|
/*LocalAreaOffset=*/0),
|
|
|
|
STI(STI) {}
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
|
|
|
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
|
|
|
|
2017-12-11 19:53:54 +08:00
|
|
|
int getFrameIndexReference(const MachineFunction &MF, int FI,
|
|
|
|
unsigned &FrameReg) const override;
|
|
|
|
|
2017-12-11 20:34:11 +08:00
|
|
|
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
|
|
|
|
RegScavenger *RS) const override;
|
|
|
|
|
2018-01-11 19:17:19 +08:00
|
|
|
void processFunctionBeforeFrameFinalized(MachineFunction &MF,
|
|
|
|
RegScavenger *RS) const override;
|
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
bool hasFP(const MachineFunction &MF) const override;
|
2017-11-08 21:41:21 +08:00
|
|
|
|
2018-03-20 09:39:17 +08:00
|
|
|
bool hasReservedCallFrame(const MachineFunction &MF) const override;
|
2017-11-08 21:41:21 +08:00
|
|
|
MachineBasicBlock::iterator
|
|
|
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
2018-03-20 09:39:17 +08:00
|
|
|
MachineBasicBlock::iterator MI) const override;
|
2017-12-11 20:34:11 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const RISCVSubtarget &STI;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void determineFrameLayout(MachineFunction &MF) const;
|
|
|
|
void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
|
|
|
|
const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
|
|
|
|
int64_t Val, MachineInstr::MIFlag Flag) const;
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|