LLVM 22.0.0git
MachineFunctionAnalysis.cpp
Go to the documentation of this file.
1//===- MachineFunctionAnalysis.cpp ----------------------------------------===//
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 contains the definitions of the MachineFunctionAnalysis
10// members.
11//
12//===----------------------------------------------------------------------===//
13
17#include "llvm/IR/Function.h"
19
20using namespace llvm;
21
22AnalysisKey MachineFunctionAnalysis::Key;
23
25 std::unique_ptr<MachineFunction> MF)
26 : MF(std::move(MF)) {}
27
29 Function &, const PreservedAnalyses &PA,
30 FunctionAnalysisManager::Invalidator &) {
31 // Unless it is invalidated explicitly, it should remain preserved.
32 auto PAC = PA.getChecker<MachineFunctionAnalysis>();
33 return !PAC.preservedWhenStateless();
34}
35
38 auto &Context = F.getContext();
39 const TargetSubtargetInfo &STI = *TM->getSubtargetImpl(F);
40 auto &MMI = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F)
41 .getCachedResult<MachineModuleAnalysis>(*F.getParent())
42 ->getMMI();
43 auto MF = std::make_unique<MachineFunction>(
44 F, *TM, STI, MMI.getContext(), Context.generateMachineFunctionNum(F));
45 MF->initTargetMachineFunctionInfo(STI);
46
47 // MRI callback for target specific initializations.
48 TM->registerMachineRegisterInfoCallback(*MF);
49
50 return Result(std::move(MF));
51}
52
#define F(x, y, z)
Definition MD5.cpp:55
FunctionAnalysisManager FAM
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Result(std::unique_ptr< MachineFunction > MF)
LLVM_ABI bool invalidate(Function &, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
This analysis create MachineFunction for given Function.
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM)
MachineFunctionAnalysis(const TargetMachine *TM)
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition Analysis.h:275
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1849
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:851
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29