InlineModelFeatureMaps.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- InlineModelFeatureMaps.h - common model runner defs ------*- 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_INLINEMODELFEATUREMAPS_H
  15. #define LLVM_ANALYSIS_INLINEMODELFEATUREMAPS_H
  16. #include <array>
  17. #include <string>
  18. #include <vector>
  19. namespace llvm {
  20. // List of features. Each feature is defined through a triple:
  21. // - the name of an enum member, which will be the feature index
  22. // - a textual name, used for Tensorflow model binding (so it needs to match the
  23. // names used by the Tensorflow model)
  24. // - a documentation description. Currently, that is not used anywhere
  25. // programmatically, and serves as workaround to inability of inserting comments
  26. // in macros.
  27. #define INLINE_FEATURE_ITERATOR(M) \
  28. M(CalleeBasicBlockCount, "callee_basic_block_count", \
  29. "number of basic blocks of the callee") \
  30. M(CallSiteHeight, "callsite_height", \
  31. "position of the call site in the original call graph - measured from " \
  32. "the farthest SCC") \
  33. M(NodeCount, "node_count", \
  34. "total current number of defined functions in the module") \
  35. M(NrCtantParams, "nr_ctant_params", \
  36. "number of parameters in the call site that are constants") \
  37. M(CostEstimate, "cost_estimate", "total cost estimate (threshold - free)") \
  38. M(EdgeCount, "edge_count", \
  39. "number of module-internal users of the caller, +1 if the caller is " \
  40. "exposed externally") \
  41. M(CallerUsers, "caller_users", \
  42. "number of blocks reached from a conditional instruction, in the caller") \
  43. M(CallerConditionallyExecutedBlocks, "caller_conditionally_executed_blocks", \
  44. "number of blocks reached from a conditional instruction, in the caller") \
  45. M(CallerBasicBlockCount, "caller_basic_block_count", \
  46. "number of basic blocks in the caller") \
  47. M(CalleeConditionallyExecutedBlocks, "callee_conditionally_executed_blocks", \
  48. "number of blocks reached from a conditional instruction, in the callee") \
  49. M(CalleeUsers, "callee_users", \
  50. "number of blocks reached from a conditional instruction, in the callee")
  51. enum class FeatureIndex : size_t {
  52. #define POPULATE_INDICES(INDEX_NAME, NAME, COMMENT) INDEX_NAME,
  53. INLINE_FEATURE_ITERATOR(POPULATE_INDICES)
  54. #undef POPULATE_INDICES
  55. NumberOfFeatures
  56. };
  57. constexpr size_t NumberOfFeatures =
  58. static_cast<size_t>(FeatureIndex::NumberOfFeatures);
  59. extern const std::array<std::string, NumberOfFeatures> FeatureNameMap;
  60. extern const char *const DecisionName;
  61. extern const char *const DefaultDecisionName;
  62. extern const char *const RewardName;
  63. using InlineFeatures = std::vector<int64_t>;
  64. } // namespace llvm
  65. #endif // LLVM_ANALYSIS_INLINEMODELFEATUREMAPS_H
  66. #ifdef __GNUC__
  67. #pragma GCC diagnostic pop
  68. #endif