InlineSizeEstimatorAnalysis.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- InlineSizeEstimatorAnalysis.h - ML size estimator --------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. #ifndef LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H
  15. #define LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H
  16. #include "llvm/IR/PassManager.h"
  17. namespace llvm {
  18. class Function;
  19. class TFModelEvaluator;
  20. class InlineSizeEstimatorAnalysis
  21. : public AnalysisInfoMixin<InlineSizeEstimatorAnalysis> {
  22. public:
  23. InlineSizeEstimatorAnalysis();
  24. InlineSizeEstimatorAnalysis(InlineSizeEstimatorAnalysis &&);
  25. ~InlineSizeEstimatorAnalysis();
  26. static AnalysisKey Key;
  27. using Result = std::optional<size_t>;
  28. Result run(const Function &F, FunctionAnalysisManager &FAM);
  29. static bool isEvaluatorRequested();
  30. private:
  31. std::unique_ptr<TFModelEvaluator> Evaluator;
  32. };
  33. class InlineSizeEstimatorAnalysisPrinterPass
  34. : public PassInfoMixin<InlineSizeEstimatorAnalysisPrinterPass> {
  35. raw_ostream &OS;
  36. public:
  37. explicit InlineSizeEstimatorAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
  38. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  39. };
  40. } // namespace llvm
  41. #endif // LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H
  42. #ifdef __GNUC__
  43. #pragma GCC diagnostic pop
  44. #endif