Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:13

0001 //===- InlineOrder.h - Inlining order abstraction -*- C++ ---*-------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 #ifndef LLVM_ANALYSIS_INLINEORDER_H
0010 #define LLVM_ANALYSIS_INLINEORDER_H
0011 
0012 #include "llvm/Analysis/InlineCost.h"
0013 #include <utility>
0014 
0015 namespace llvm {
0016 class CallBase;
0017 template <typename Fn> class function_ref;
0018 
0019 template <typename T> class InlineOrder {
0020 public:
0021   virtual ~InlineOrder() = default;
0022 
0023   virtual size_t size() = 0;
0024 
0025   virtual void push(const T &Elt) = 0;
0026 
0027   virtual T pop() = 0;
0028 
0029   virtual void erase_if(function_ref<bool(T)> Pred) = 0;
0030 
0031   bool empty() { return !size(); }
0032 };
0033 
0034 std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
0035 getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
0036                       ModuleAnalysisManager &MAM, Module &M);
0037 
0038 std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
0039 getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
0040                ModuleAnalysisManager &MAM, Module &M);
0041 
0042 /// Used for dynamically loading instances of InlineOrder as plugins
0043 ///
0044 /// Plugins must implement an InlineOrderFactory, for an example refer to:
0045 /// llvm/unittests/Analysis/InlineOrderPlugin/InlineOrderPlugin.cpp
0046 ///
0047 /// If a PluginInlineOrderAnalysis has been registered with the
0048 /// current ModuleAnalysisManager, llvm::getInlineOrder returns an
0049 /// InlineOrder created by the PluginInlineOrderAnalysis' Factory.
0050 ///
0051 class PluginInlineOrderAnalysis
0052     : public AnalysisInfoMixin<PluginInlineOrderAnalysis> {
0053 public:
0054   static AnalysisKey Key;
0055 
0056   typedef std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>> (
0057       *InlineOrderFactory)(FunctionAnalysisManager &FAM,
0058                            const InlineParams &Params,
0059                            ModuleAnalysisManager &MAM, Module &M);
0060 
0061   PluginInlineOrderAnalysis(InlineOrderFactory Factory) : Factory(Factory) {
0062     assert(Factory != nullptr &&
0063            "The plugin inline order factory should not be a null pointer.");
0064   }
0065 
0066   struct Result {
0067     InlineOrderFactory Factory;
0068   };
0069 
0070   Result run(Module &, ModuleAnalysisManager &) { return {Factory}; }
0071   Result getResult() { return {Factory}; }
0072 
0073 private:
0074   InlineOrderFactory Factory;
0075 };
0076 
0077 } // namespace llvm
0078 #endif // LLVM_ANALYSIS_INLINEORDER_H