2018-01-11 03:41:03 +08:00
|
|
|
//=- RISCVMachineFunctionInfo.h - RISCV machine function info -----*- 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
|
2018-01-11 03:41:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares RISCV-specific per-machine-function information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
|
|
|
|
|
2020-02-12 05:23:03 +08:00
|
|
|
#include "RISCVSubtarget.h"
|
2018-04-12 13:34:25 +08:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2018-01-11 03:41:03 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo
|
|
|
|
/// and contains private RISCV-specific information for each MachineFunction.
|
|
|
|
class RISCVMachineFunctionInfo : public MachineFunctionInfo {
|
2018-04-12 13:34:25 +08:00
|
|
|
private:
|
2018-01-11 03:41:03 +08:00
|
|
|
/// FrameIndex for start of varargs area
|
|
|
|
int VarArgsFrameIndex = 0;
|
|
|
|
/// Size of the save area used for varargs
|
|
|
|
int VarArgsSaveSize = 0;
|
2018-04-12 13:34:25 +08:00
|
|
|
/// FrameIndex used for transferring values between 64-bit FPRs and a pair
|
|
|
|
/// of 32-bit GPRs via the stack.
|
|
|
|
int MoveF64FrameIndex = -1;
|
2020-02-12 05:23:03 +08:00
|
|
|
/// Size of any opaque stack adjustment due to save/restore libcalls.
|
|
|
|
unsigned LibCallStackSize = 0;
|
2018-01-11 03:41:03 +08:00
|
|
|
|
|
|
|
public:
|
2020-07-01 03:41:03 +08:00
|
|
|
RISCVMachineFunctionInfo(const MachineFunction &MF) {}
|
2018-01-11 03:41:03 +08:00
|
|
|
|
|
|
|
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
|
|
|
|
void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
|
|
|
|
|
|
|
|
unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
|
|
|
|
void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
|
2018-04-12 13:34:25 +08:00
|
|
|
|
2020-07-01 03:41:03 +08:00
|
|
|
int getMoveF64FrameIndex(MachineFunction &MF) {
|
2018-04-12 13:34:25 +08:00
|
|
|
if (MoveF64FrameIndex == -1)
|
2020-07-01 15:28:11 +08:00
|
|
|
MoveF64FrameIndex =
|
|
|
|
MF.getFrameInfo().CreateStackObject(8, Align(8), false);
|
2018-04-12 13:34:25 +08:00
|
|
|
return MoveF64FrameIndex;
|
|
|
|
}
|
2020-02-12 05:23:03 +08:00
|
|
|
|
|
|
|
unsigned getLibCallStackSize() const { return LibCallStackSize; }
|
|
|
|
void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; }
|
|
|
|
|
2020-07-01 03:41:03 +08:00
|
|
|
bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
|
2020-02-12 05:23:03 +08:00
|
|
|
// We cannot use fixed locations for the callee saved spill slots if the
|
|
|
|
// function uses a varargs save area.
|
|
|
|
return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
|
|
|
|
VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall();
|
|
|
|
}
|
2018-01-11 03:41:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
|