LLVM  15.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"
20 
21 namespace llvm {
22 
23 class RISCVMachineFunctionInfo;
24 
25 namespace yaml {
29 
30  RISCVMachineFunctionInfo() = default;
32 
33  void mappingImpl(yaml::IO &YamlIO) override;
34  ~RISCVMachineFunctionInfo() = default;
35 };
36 
38  static void mapping(IO &YamlIO, RISCVMachineFunctionInfo &MFI) {
39  YamlIO.mapOptional("varArgsFrameIndex", MFI.VarArgsFrameIndex);
40  YamlIO.mapOptional("varArgsSaveSize", MFI.VarArgsSaveSize);
41  }
42 };
43 } // end namespace yaml
44 
45 /// RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo
46 /// and contains private RISCV-specific information for each MachineFunction.
48 private:
49  /// FrameIndex for start of varargs area
50  int VarArgsFrameIndex = 0;
51  /// Size of the save area used for varargs
52  int VarArgsSaveSize = 0;
53  /// FrameIndex used for transferring values between 64-bit FPRs and a pair
54  /// of 32-bit GPRs via the stack.
55  int MoveF64FrameIndex = -1;
56  /// Size of any opaque stack adjustment due to save/restore libcalls.
57  unsigned LibCallStackSize = 0;
58  /// Size of RVV stack.
59  uint64_t RVVStackSize = 0;
60  /// Padding required to keep RVV stack aligned within the main stack.
61  uint64_t RVVPadding = 0;
62  /// Size of stack frame to save callee saved registers
63  unsigned CalleeSavedStackSize = 0;
64 
65 public:
67 
68  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
69  void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
70 
71  unsigned getVarArgsSaveSize() const { return VarArgsSaveSize; }
72  void setVarArgsSaveSize(int Size) { VarArgsSaveSize = Size; }
73 
75  if (MoveF64FrameIndex == -1)
76  MoveF64FrameIndex =
77  MF.getFrameInfo().CreateStackObject(8, Align(8), false);
78  return MoveF64FrameIndex;
79  }
80 
81  unsigned getLibCallStackSize() const { return LibCallStackSize; }
82  void setLibCallStackSize(unsigned Size) { LibCallStackSize = Size; }
83 
84  bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
85  // We cannot use fixed locations for the callee saved spill slots if the
86  // function uses a varargs save area, or is an interrupt handler.
87  return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
88  VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall() &&
89  !MF.getFunction().hasFnAttribute("interrupt");
90  }
91 
92  uint64_t getRVVStackSize() const { return RVVStackSize; }
93  void setRVVStackSize(uint64_t Size) { RVVStackSize = Size; }
94 
95  uint64_t getRVVPadding() const { return RVVPadding; }
96  void setRVVPadding(uint64_t Padding) { RVVPadding = Padding; }
97 
98  unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
99  void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
100 
102 };
103 
104 } // end namespace llvm
105 
106 #endif // LLVM_LIB_TARGET_RISCV_RISCVMACHINEFUNCTIONINFO_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::RISCVMachineFunctionInfo::setRVVStackSize
void setRVVStackSize(uint64_t Size)
Definition: RISCVMachineFunctionInfo.h:93
llvm::yaml::MachineFunctionInfo
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
Definition: MIRYamlMapping.h:676
llvm::RISCVMachineFunctionInfo::setLibCallStackSize
void setLibCallStackSize(unsigned Size)
Definition: RISCVMachineFunctionInfo.h:82
YamlIO
IO & YamlIO
Definition: ELFYAML.cpp:1224
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:51
llvm::RISCVMachineFunctionInfo::getLibCallStackSize
unsigned getLibCallStackSize() const
Definition: RISCVMachineFunctionInfo.h:81
llvm::RISCVMachineFunctionInfo::getCalleeSavedStackSize
unsigned getCalleeSavedStackSize() const
Definition: RISCVMachineFunctionInfo.h:98
MIRYamlMapping.h
llvm::RISCVMachineFunctionInfo::setRVVPadding
void setRVVPadding(uint64_t Padding)
Definition: RISCVMachineFunctionInfo.h:96
llvm::yaml::RISCVMachineFunctionInfo::VarArgsFrameIndex
int VarArgsFrameIndex
Definition: RISCVMachineFunctionInfo.h:27
llvm::RISCVMachineFunctionInfo::getMoveF64FrameIndex
int getMoveF64FrameIndex(MachineFunction &MF)
Definition: RISCVMachineFunctionInfo.h:74
llvm::RISCVMachineFunctionInfo::getRVVStackSize
uint64_t getRVVStackSize() const
Definition: RISCVMachineFunctionInfo.h:92
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::yaml::RISCVMachineFunctionInfo::RISCVMachineFunctionInfo
RISCVMachineFunctionInfo()=default
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:640
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:625
llvm::yaml::RISCVMachineFunctionInfo::VarArgsSaveSize
int VarArgsSaveSize
Definition: RISCVMachineFunctionInfo.h:28
llvm::RISCVMachineFunctionInfo::getVarArgsSaveSize
unsigned getVarArgsSaveSize() const
Definition: RISCVMachineFunctionInfo.h:71
uint64_t
llvm::RISCVMachineFunctionInfo
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
Definition: RISCVMachineFunctionInfo.h:47
llvm::RISCVMachineFunctionInfo::useSaveRestoreLibCalls
bool useSaveRestoreLibCalls(const MachineFunction &MF) const
Definition: RISCVMachineFunctionInfo.h:84
llvm::RISCVSubtarget
Definition: RISCVSubtarget.h:35
llvm::yaml::MappingTraits< RISCVMachineFunctionInfo >::mapping
static void mapping(IO &YamlIO, RISCVMachineFunctionInfo &MFI)
Definition: RISCVMachineFunctionInfo.h:38
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:656
llvm::yaml::RISCVMachineFunctionInfo::~RISCVMachineFunctionInfo
~RISCVMachineFunctionInfo()=default
llvm::RISCVMachineFunctionInfo::setCalleeSavedStackSize
void setCalleeSavedStackSize(unsigned Size)
Definition: RISCVMachineFunctionInfo.h:99
llvm::MachineFunction
Definition: MachineFunction.h:241
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:606
MachineFrameInfo.h
llvm::yaml::RISCVMachineFunctionInfo
Definition: RISCVMachineFunctionInfo.h:26
llvm::RISCVMachineFunctionInfo::getVarArgsFrameIndex
int getVarArgsFrameIndex() const
Definition: RISCVMachineFunctionInfo.h:68
llvm::RISCVMachineFunctionInfo::setVarArgsFrameIndex
void setVarArgsFrameIndex(int Index)
Definition: RISCVMachineFunctionInfo.h:69
RISCVSubtarget.h
llvm::yaml::RISCVMachineFunctionInfo::mappingImpl
void mappingImpl(yaml::IO &YamlIO) override
Definition: RISCVMachineFunctionInfo.cpp:22
llvm::RISCVMachineFunctionInfo::initializeBaseYamlFields
void initializeBaseYamlFields(const yaml::RISCVMachineFunctionInfo &YamlMFI)
Definition: RISCVMachineFunctionInfo.cpp:26
llvm::RISCVMachineFunctionInfo::RISCVMachineFunctionInfo
RISCVMachineFunctionInfo(const MachineFunction &MF)
Definition: RISCVMachineFunctionInfo.h:66
llvm::MachineFrameInfo::hasTailCall
bool hasTailCall() const
Returns true if the function contains a tail call.
Definition: MachineFrameInfo.h:630
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:95
llvm::RISCVMachineFunctionInfo::setVarArgsSaveSize
void setVarArgsSaveSize(int Size)
Definition: RISCVMachineFunctionInfo.h:72