LLVM 20.0.0git
ARMMachineFunctionInfo.cpp
Go to the documentation of this file.
1//===-- ARMMachineFunctionInfo.cpp - ARM machine function info ------------===//
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
10#include "ARMSubtarget.h"
11#include "llvm/IR/Module.h"
12
13using namespace llvm;
14
15void ARMFunctionInfo::anchor() {}
16
18 : LRSpilled(MFI.isLRSpilled()) {}
19
22}
23
25 const yaml::ARMFunctionInfo &YamlMFI) {
26 LRSpilled = YamlMFI.LRSpilled;
27}
28
30 const ARMSubtarget *Subtarget) {
31 if (!Subtarget->isMClass() || !Subtarget->hasV7Ops())
32 return false;
33
34 return F.hasFnAttribute("branch-target-enforcement");
35}
36
37// The pair returns values for the ARMFunctionInfo members
38// SignReturnAddress and SignReturnAddressAll respectively.
39static std::pair<bool, bool> GetSignReturnAddress(const Function &F) {
40 if (!F.hasFnAttribute("sign-return-address")) {
41 return {false, false};
42 }
43
44 StringRef Scope = F.getFnAttribute("sign-return-address").getValueAsString();
45 if (Scope == "none")
46 return {false, false};
47
48 if (Scope == "all")
49 return {true, true};
50
51 assert(Scope == "non-leaf");
52 return {true, false};
53}
54
56 const ARMSubtarget *Subtarget)
57 : isThumb(Subtarget->isThumb()), hasThumb2(Subtarget->hasThumb2()),
58 IsCmseNSEntry(F.hasFnAttribute("cmse_nonsecure_entry")),
59 IsCmseNSCall(F.hasFnAttribute("cmse_nonsecure_call")),
60 BranchTargetEnforcement(GetBranchTargetEnforcement(F, Subtarget)) {
61 if (Subtarget->isMClass() && Subtarget->hasV7Ops())
62 std::tie(SignReturnAddress, SignReturnAddressAll) = GetSignReturnAddress(F);
63}
64
68 &Src2DstMBB) const {
69 return DestMF.cloneInfo<ARMFunctionInfo>(*this);
70}
static std::pair< bool, bool > GetSignReturnAddress(const Function &F)
static bool isLRSpilled(const MachineFunction &MF)
static bool isThumb(const MCSubtargetInfo &STI)
static bool GetBranchTargetEnforcement(const Function &F, const ARMSubtarget *Subtarget)
IO & YamlIO
Definition: ELFYAML.cpp:1308
#define F(x, y, z)
Definition: MD5.cpp:55
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
void initializeBaseYamlFields(const yaml::ARMFunctionInfo &YamlMFI)
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
bool isMClass() const
Definition: ARMSubtarget.h:366
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Ty * cloneInfo(const Ty &Old)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
void mappingImpl(yaml::IO &YamlIO) override