LLVM 20.0.0git
InlineOrder.h
Go to the documentation of this file.
1//===- InlineOrder.h - Inlining order abstraction -*- 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#ifndef LLVM_ANALYSIS_INLINEORDER_H
10#define LLVM_ANALYSIS_INLINEORDER_H
11
13#include <utility>
14
15namespace llvm {
16class CallBase;
17template <typename Fn> class function_ref;
18
19template <typename T> class InlineOrder {
20public:
21 virtual ~InlineOrder() = default;
22
23 virtual size_t size() = 0;
24
25 virtual void push(const T &Elt) = 0;
26
27 virtual T pop() = 0;
28
29 virtual void erase_if(function_ref<bool(T)> Pred) = 0;
30
31 bool empty() { return !size(); }
32};
33
34std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
35getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
36 ModuleAnalysisManager &MAM, Module &M);
37
38std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
39getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
40 ModuleAnalysisManager &MAM, Module &M);
41
42/// Used for dynamically loading instances of InlineOrder as plugins
43///
44/// Plugins must implement an InlineOrderFactory, for an example refer to:
45/// llvm/unittests/Analysis/InlineOrderPlugin/InlineOrderPlugin.cpp
46///
47/// If a PluginInlineOrderAnalysis has been registered with the
48/// current ModuleAnalysisManager, llvm::getInlineOrder returns an
49/// InlineOrder created by the PluginInlineOrderAnalysis' Factory.
50///
52 : public AnalysisInfoMixin<PluginInlineOrderAnalysis> {
53public:
55
56 typedef std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>> (
58 const InlineParams &Params,
60
61 PluginInlineOrderAnalysis(InlineOrderFactory Factory) : Factory(Factory) {
62 assert(Factory != nullptr &&
63 "The plugin inline order factory should not be a null pointer.");
64 }
65
66 struct Result {
68 };
69
70 Result run(Module &, ModuleAnalysisManager &) { return {Factory}; }
71 Result getResult() { return {Factory}; }
72
73private:
74 InlineOrderFactory Factory;
75};
76
77} // namespace llvm
78#endif // LLVM_ANALYSIS_INLINEORDER_H
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
virtual T pop()=0
virtual size_t size()=0
virtual void erase_if(function_ref< bool(T)> Pred)=0
virtual ~InlineOrder()=default
virtual void push(const T &Elt)=0
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Used for dynamically loading instances of InlineOrder as plugins.
Definition: InlineOrder.h:52
PluginInlineOrderAnalysis(InlineOrderFactory Factory)
Definition: InlineOrder.h:61
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > >(* InlineOrderFactory)(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
Definition: InlineOrder.h:57
Result run(Module &, ModuleAnalysisManager &)
Definition: InlineOrder.h:70
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:546
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > > getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > > getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition: MIRParser.h:38
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
Thresholds to tune inline cost analysis.
Definition: InlineCost.h:205