LLVM  14.0.0git
RISCVMachineFunctionInfo.h
Go to the documentation of this file.
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"
19 
20 namespace llvm {
21 
22 /// RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo
23 /// and contains private RISCV-specific information for each MachineFunction.
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  /// Padding required to keep RVV stack aligned within the main stack.
38  uint64_t RVVPadding = 0;
39  /// Size of stack frame to save callee saved registers
40  unsigned CalleeSavedStackSize = 0;
41 
42 public:
44 
45  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
46  void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
47 
48  unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
49  void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
50 
52  if (MoveF64FrameIndex == -1)
53  MoveF64FrameIndex =
54  MF.getFrameInfo().CreateStackObject(8, Align(8), false);
55  return MoveF64FrameIndex;
56  }
57 
58  unsigned getLibCallStackSize() const { return LibCallStackSize; }
59  void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; }
60 
61  bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
62  // We cannot use fixed locations for the callee saved spill slots if the
63  // function uses a varargs save area, or is an interrupt handler.
64  return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
65  VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall() &&
66  !MF.getFunction().hasFnAttribute("interrupt");
67  }
68 
69  uint64_t getRVVStackSize() const { return RVVStackSize; }
70  void setRVVStackSize(uint64_t Size) { RVVStackSize = Size; }
71 
72  uint64_t getRVVPadding() const { return RVVPadding; }
73  void setRVVPadding(uint64_t Padding) { RVVPadding = Padding; }
74 
75  unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
76  void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
77 };
78 
79 } // end namespace llvm
80 
81 #endif // LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::RISCVMachineFunctionInfo::setRVVStackSize
void setRVVStackSize(uint64_t Size)
Definition: RISCVMachineFunctionInfo.h:70
llvm::RISCVMachineFunctionInfo::setLibCallStackSize
void setLibCallStackSize(unsigned Size)
Definition: RISCVMachineFunctionInfo.h:59
llvm::RISCVMachineFunctionInfo::getLibCallStackSize
unsigned getLibCallStackSize() const
Definition: RISCVMachineFunctionInfo.h:58
llvm::RISCVMachineFunctionInfo::getCalleeSavedStackSize
unsigned getCalleeSavedStackSize() const
Definition: RISCVMachineFunctionInfo.h:75
llvm::RISCVMachineFunctionInfo::setRVVPadding
void setRVVPadding(uint64_t Padding)
Definition: RISCVMachineFunctionInfo.h:73
llvm::RISCVMachineFunctionInfo::getMoveF64FrameIndex
int getMoveF64FrameIndex(MachineFunction &MF)
Definition: RISCVMachineFunctionInfo.h:51
llvm::RISCVMachineFunctionInfo::getRVVStackSize
uint64_t getRVVStackSize() const
Definition: RISCVMachineFunctionInfo.h:69
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:626
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:626
llvm::RISCVMachineFunctionInfo::getVarArgsSaveSize
unsigned getVarArgsSaveSize() const
Definition: RISCVMachineFunctionInfo.h:48
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
llvm::RISCVMachineFunctionInfo
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
Definition: RISCVMachineFunctionInfo.h:24
llvm::RISCVMachineFunctionInfo::useSaveRestoreLibCalls
bool useSaveRestoreLibCalls(const MachineFunction &MF) const
Definition: RISCVMachineFunctionInfo.h:61
llvm::RISCVSubtarget
Definition: RISCVSubtarget.h:35
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:642
llvm::RISCVMachineFunctionInfo::setCalleeSavedStackSize
void setCalleeSavedStackSize(unsigned Size)
Definition: RISCVMachineFunctionInfo.h:76
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::MachineFrameInfo::CreateStackObject
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
Definition: MachineFrameInfo.cpp:51
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:592
MachineFrameInfo.h
llvm::RISCVMachineFunctionInfo::getVarArgsFrameIndex
int getVarArgsFrameIndex() const
Definition: RISCVMachineFunctionInfo.h:45
llvm::RISCVMachineFunctionInfo::setVarArgsFrameIndex
void setVarArgsFrameIndex(int Index)
Definition: RISCVMachineFunctionInfo.h:46
RISCVSubtarget.h
llvm::RISCVMachineFunctionInfo::RISCVMachineFunctionInfo
RISCVMachineFunctionInfo(const MachineFunction &MF)
Definition: RISCVMachineFunctionInfo.h:43
llvm::MachineFrameInfo::hasTailCall
bool hasTailCall() const
Returns true if the function contains a tail call.
Definition: MachineFrameInfo.h:606
MachineFunction.h
llvm::MachineFunctionInfo
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Definition: MachineFunction.h:95
llvm::RISCVMachineFunctionInfo::getRVVPadding
uint64_t getRVVPadding() const
Definition: RISCVMachineFunctionInfo.h:72
llvm::RISCVMachineFunctionInfo::setVarArgsSaveSize
void setVarArgsSaveSize(int Size)
Definition: RISCVMachineFunctionInfo.h:49