xref: /freebsd/contrib/llvm-project/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- llvm/CodeGen/MachineFunctionAnalysis.h -------------------*- 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 the MachineFunctionAnalysis class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONANALYSIS
14 #define LLVM_CODEGEN_MACHINEFUNCTIONANALYSIS
15 
16 #include "llvm/IR/PassManager.h"
17 #include "llvm/Support/Compiler.h"
18 
19 namespace llvm {
20 
21 class MachineFunction;
22 class TargetMachine;
23 
24 /// This analysis create MachineFunction for given Function.
25 /// To release the MachineFunction, users should invalidate it explicitly.
26 class MachineFunctionAnalysis
27     : public AnalysisInfoMixin<MachineFunctionAnalysis> {
28   friend AnalysisInfoMixin<MachineFunctionAnalysis>;
29 
30   LLVM_ABI static AnalysisKey Key;
31 
32   const TargetMachine *TM;
33 
34 public:
35   class Result {
36     std::unique_ptr<MachineFunction> MF;
37 
38   public:
Result(std::unique_ptr<MachineFunction> MF)39     Result(std::unique_ptr<MachineFunction> MF) : MF(std::move(MF)) {}
getMF()40     MachineFunction &getMF() { return *MF; };
41     LLVM_ABI bool invalidate(Function &, const PreservedAnalyses &PA,
42                              FunctionAnalysisManager::Invalidator &);
43   };
44 
MachineFunctionAnalysis(const TargetMachine * TM)45   MachineFunctionAnalysis(const TargetMachine *TM) : TM(TM) {};
46   LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM);
47 };
48 
49 } // namespace llvm
50 
51 #endif // LLVM_CODEGEN_MachineFunctionAnalysis
52