2018-01-10 20:41:03 +01:00
|
|
|
//=- RISCVMachineFunctionInfo.h - RISCV machine function info -----*- C++ -*-=//
|
|
|
|
//
|
2019-01-19 09:50:56 +01: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-10 20:41:03 +01: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-11 22:23:03 +01:00
|
|
|
#include "RISCVSubtarget.h"
|
2018-04-12 07:34:25 +02:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2018-01-10 20:41:03 +01: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 07:34:25 +02:00
|
|
|
private:
|
2018-01-10 20:41:03 +01:00
|
|
|
/// FrameIndex for start of varargs area
|
|
|
|
int VarArgsFrameIndex = 0;
|
|
|
|
/// Size of the save area used for varargs
|
|
|
|
int VarArgsSaveSize = 0;
|
2018-04-12 07:34:25 +02: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-11 22:23:03 +01:00
|
|
|
/// Size of any opaque stack adjustment due to save/restore libcalls.
|
|
|
|
unsigned LibCallStackSize = 0;
|
2021-01-08 03:18:26 +01:00
|
|
|
/// Size of RVV stack.
|
|
|
|
uint64_t RVVStackSize = 0;
|
2021-03-18 11:26:33 +01:00
|
|
|
/// Padding required to keep RVV stack aligned within the main stack.
|
|
|
|
uint64_t RVVPadding = 0;
|
2021-02-20 07:02:56 +01:00
|
|
|
/// Size of stack frame to save callee saved registers
|
|
|
|
unsigned CalleeSavedStackSize = 0;
|
2018-01-10 20:41:03 +01:00
|
|
|
|
|
|
|
public:
|
2020-06-30 21:41:03 +02:00
|
|
|
RISCVMachineFunctionInfo(const MachineFunction &MF) {}
|
2018-01-10 20:41:03 +01: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 07:34:25 +02:00
|
|
|
|
2020-06-30 21:41:03 +02:00
|
|
|
int getMoveF64FrameIndex(MachineFunction &MF) {
|
2018-04-12 07:34:25 +02:00
|
|
|
if (MoveF64FrameIndex == -1)
|
2020-07-01 09:28:11 +02:00
|
|
|
MoveF64FrameIndex =
|
|
|
|
MF.getFrameInfo().CreateStackObject(8, Align(8), false);
|
2018-04-12 07:34:25 +02:00
|
|
|
return MoveF64FrameIndex;
|
|
|
|
}
|
2020-02-11 22:23:03 +01:00
|
|
|
|
|
|
|
unsigned getLibCallStackSize() const { return LibCallStackSize; }
|
|
|
|
void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; }
|
|
|
|
|
2020-06-30 21:41:03 +02:00
|
|
|
bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
|
2020-02-11 22:23:03 +01:00
|
|
|
// We cannot use fixed locations for the callee saved spill slots if the
|
2021-04-16 06:50:51 +02:00
|
|
|
// function uses a varargs save area, or is an interrupt handler.
|
2020-02-11 22:23:03 +01:00
|
|
|
return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
|
2021-04-16 06:50:51 +02:00
|
|
|
VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall() &&
|
|
|
|
!MF.getFunction().hasFnAttribute("interrupt");
|
2020-02-11 22:23:03 +01:00
|
|
|
}
|
2021-01-08 03:18:26 +01:00
|
|
|
|
|
|
|
uint64_t getRVVStackSize() const { return RVVStackSize; }
|
|
|
|
void setRVVStackSize(uint64_t Size) { RVVStackSize = Size; }
|
2021-02-20 07:02:56 +01:00
|
|
|
|
2021-03-18 11:26:33 +01:00
|
|
|
uint64_t getRVVPadding() const { return RVVPadding; }
|
|
|
|
void setRVVPadding(uint64_t Padding) { RVVPadding = Padding; }
|
|
|
|
|
2021-02-20 07:02:56 +01:00
|
|
|
unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
|
|
|
|
void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
|
2018-01-10 20:41:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
|