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
18namespace llvm {
19
20class MachineFunction;
21class LLVMTargetMachine;
22
23/// This analysis create MachineFunction for given Function.
24/// To release the MachineFunction, users should invalidate it explicitly.
25class MachineFunctionAnalysis
26 : public AnalysisInfoMixin<MachineFunctionAnalysis> {
27 friend AnalysisInfoMixin<MachineFunctionAnalysis>;
28
29 static AnalysisKey Key;
30
31 const LLVMTargetMachine *TM;
32
33public:
34 class Result {
35 std::unique_ptr<MachineFunction> MF;
36
37 public:
38 Result(std::unique_ptr<MachineFunction> MF) : MF(std::move(MF)) {}
39 MachineFunction &getMF() { return *MF; };
40 bool invalidate(Function &, const PreservedAnalyses &PA,
41 FunctionAnalysisManager::Invalidator &);
42 };
43
44 MachineFunctionAnalysis(const LLVMTargetMachine *TM) : TM(TM){};
45 Result run(Function &F, FunctionAnalysisManager &FAM);
46};
47
48} // namespace llvm
49
50#endif // LLVM_CODEGEN_MachineFunctionAnalysis
51