LLVM 22.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
12using namespace llvm;
13
14void ARMFunctionInfo::anchor() {}
15
18
22
24 const yaml::ARMFunctionInfo &YamlMFI) {
25 LRSpilled = YamlMFI.LRSpilled;
26}
27
29 const ARMSubtarget *Subtarget) {
30 if (!Subtarget->isMClass() || !Subtarget->hasV7Ops())
31 return false;
32
33 return F.hasFnAttribute("branch-target-enforcement");
34}
35
36// The pair returns values for the ARMFunctionInfo members
37// SignReturnAddress and SignReturnAddressAll respectively.
38static std::pair<bool, bool> GetSignReturnAddress(const Function &F) {
39 if (!F.hasFnAttribute("sign-return-address")) {
40 return {false, false};
41 }
42
43 StringRef Scope = F.getFnAttribute("sign-return-address").getValueAsString();
44 if (Scope == "none")
45 return {false, false};
46
47 if (Scope == "all")
48 return {true, true};
49
50 assert(Scope == "non-leaf");
51 return {true, false};
52}
53
55 const ARMSubtarget *Subtarget)
56 : isThumb(Subtarget->isThumb()), hasThumb2(Subtarget->hasThumb2()),
57 IsCmseNSEntry(F.hasFnAttribute("cmse_nonsecure_entry")),
58 IsCmseNSCall(F.hasFnAttribute("cmse_nonsecure_call")),
59 BranchTargetEnforcement(GetBranchTargetEnforcement(F, Subtarget)) {
60 if (Subtarget->isMClass() && Subtarget->hasV7Ops())
61 std::tie(SignReturnAddress, SignReturnAddressAll) = GetSignReturnAddress(F);
62}
63
67 &Src2DstMBB) const {
68 return DestMF.cloneInfo<ARMFunctionInfo>(*this);
69}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static std::pair< bool, bool > GetSignReturnAddress(const Function &F)
static bool isLRSpilled(const MachineFunction &MF)
static bool GetBranchTargetEnforcement(const Function &F, const ARMSubtarget *Subtarget)
#define F(x, y, z)
Definition MD5.cpp:55
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
Ty * cloneInfo(const Ty &Old)
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
void mappingImpl(yaml::IO &YamlIO) override
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:62