1 //=- RISCVMachineFunctionInfo.h - RISCV machine function info -----*- C++ -*-=// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares RISCV-specific per-machine-function information. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H 14 #define LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H 15 16 #include "RISCVSubtarget.h" 17 #include "llvm/CodeGen/MachineFrameInfo.h" 18 #include "llvm/CodeGen/MachineFunction.h" 19 20 namespace llvm { 21 22 /// RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo 23 /// and contains private RISCV-specific information for each MachineFunction. 24 class RISCVMachineFunctionInfo : public MachineFunctionInfo { 25 private: 26 /// FrameIndex for start of varargs area 27 int VarArgsFrameIndex = 0; 28 /// Size of the save area used for varargs 29 int VarArgsSaveSize = 0; 30 /// FrameIndex used for transferring values between 64-bit FPRs and a pair 31 /// of 32-bit GPRs via the stack. 32 int MoveF64FrameIndex = -1; 33 /// Size of any opaque stack adjustment due to save/restore libcalls. 34 unsigned LibCallStackSize = 0; 35 /// Size of RVV stack. 36 uint64_t RVVStackSize = 0; 37 38 public: 39 RISCVMachineFunctionInfo(const MachineFunction &MF) {} 40 41 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } 42 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } 43 44 unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; } 45 void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; } 46 47 int getMoveF64FrameIndex(MachineFunction &MF) { 48 if (MoveF64FrameIndex == -1) 49 MoveF64FrameIndex = 50 MF.getFrameInfo().CreateStackObject(8, Align(8), false); 51 return MoveF64FrameIndex; 52 } 53 54 unsigned getLibCallStackSize() const { return LibCallStackSize; } 55 void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; } 56 57 bool useSaveRestoreLibCalls(const MachineFunction &MF) const { 58 // We cannot use fixed locations for the callee saved spill slots if the 59 // function uses a varargs save area. 60 return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() && 61 VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall(); 62 } 63 64 uint64_t getRVVStackSize() const { return RVVStackSize; } 65 void setRVVStackSize(uint64_t Size) { RVVStackSize = Size; } 66 }; 67 68 } // end namespace llvm 69 70 #endif // LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H 71