LLVM 20.0.0git
RISCVMachineFunctionInfo.cpp
Go to the documentation of this file.
1//=- RISCVMachineFunctionInfo.cpp - RISC-V 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
14#include "llvm/IR/Module.h"
15
16using namespace llvm;
17
20 : VarArgsFrameIndex(MFI.getVarArgsFrameIndex()),
21 VarArgsSaveSize(MFI.getVarArgsSaveSize()) {}
22
24 BumpPtrAllocator &Allocator, MachineFunction &DestMF,
26 const {
27 return DestMF.cloneInfo<RISCVMachineFunctionInfo>(*this);
28}
29
31 const RISCVSubtarget *STI) {
32
33 // The default stack probe size is 4096 if the function has no
34 // stack-probe-size attribute. This is a safe default because it is the
35 // smallest possible guard page size.
36 uint64_t ProbeSize = 4096;
37 if (F.hasFnAttribute("stack-probe-size"))
38 ProbeSize = F.getFnAttributeAsParsedInteger("stack-probe-size");
39 else if (const auto *PS = mdconst::extract_or_null<ConstantInt>(
40 F.getParent()->getModuleFlag("stack-probe-size")))
41 ProbeSize = PS->getZExtValue();
42 assert(int64_t(ProbeSize) > 0 && "Invalid stack probe size");
43
44 // Round down to the stack alignment.
45 uint64_t StackAlign =
47 ProbeSize = std::max(StackAlign, alignDown(ProbeSize, StackAlign));
48 StringRef ProbeKind;
49 if (F.hasFnAttribute("probe-stack"))
50 ProbeKind = F.getFnAttribute("probe-stack").getValueAsString();
51 else if (const auto *PS = dyn_cast_or_null<MDString>(
52 F.getParent()->getModuleFlag("probe-stack")))
53 ProbeKind = PS->getString();
54 if (ProbeKind.size()) {
55 StackProbeSize = ProbeSize;
56 }
57}
58
61}
62
64 const yaml::RISCVMachineFunctionInfo &YamlMFI) {
67}
68
70 SExt32Registers.push_back(Reg);
71}
72
74 return is_contained(SExt32Registers, Reg);
75}
IO & YamlIO
Definition: ELFYAML.cpp:1312
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition: MD5.cpp:55
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Ty * cloneInfo(const Ty &Old)
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
void initializeBaseYamlFields(const yaml::RISCVMachineFunctionInfo &YamlMFI)
bool isSExt32Register(Register Reg) const
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
const RISCVFrameLowering * getFrameLowering() const override
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
Definition: MathExtras.h:555
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1903
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
void mappingImpl(yaml::IO &YamlIO) override