Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.7 KiB

  1. //===-- llvm/MC/SubtargetFeature.h - CPU characteristics --------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines and manages user or tool specified CPU characteristics.
  11. // The intent is to be able to package specific features that should or should
  12. // not be used on a specific target processor. A tool, such as llc, could, as
  13. // as example, gather chip info from the command line, a long with features
  14. // that should be used on that chip.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_MC_SUBTARGETFEATURE_H
  18. #define LLVM_MC_SUBTARGETFEATURE_H
  19. #include "llvm/ADT/Triple.h"
  20. #include "llvm/Support/DataTypes.h"
  21. #include <vector>
  22. namespace llvm {
  23. class raw_ostream;
  24. class StringRef;
  25. //===----------------------------------------------------------------------===//
  26. ///
  27. /// SubtargetFeatureKV - Used to provide key value pairs for feature and
  28. /// CPU bit flags.
  29. //
  30. struct SubtargetFeatureKV {
  31. const char *Key; // K-V key string
  32. const char *Desc; // Help descriptor
  33. uint64_t Value; // K-V integer value
  34. uint64_t Implies; // K-V bit mask
  35. // Compare routine for std binary search
  36. bool operator<(const SubtargetFeatureKV &S) const {
  37. return strcmp(Key, S.Key) < 0;
  38. }
  39. };
  40. //===----------------------------------------------------------------------===//
  41. ///
  42. /// SubtargetInfoKV - Used to provide key value pairs for CPU and arbitrary
  43. /// pointers.
  44. //
  45. struct SubtargetInfoKV {
  46. const char *Key; // K-V key string
  47. const void *Value; // K-V pointer value
  48. // Compare routine for std binary search
  49. bool operator<(const SubtargetInfoKV &S) const {
  50. return strcmp(Key, S.Key) < 0;
  51. }
  52. };
  53. //===----------------------------------------------------------------------===//
  54. ///
  55. /// SubtargetFeatures - Manages the enabling and disabling of subtarget
  56. /// specific features. Features are encoded as a string of the form
  57. /// "+attr1,+attr2,-attr3,...,+attrN"
  58. /// A comma separates each feature from the next (all lowercase.)
  59. /// Each of the remaining features is prefixed with + or - indicating whether
  60. /// that feature should be enabled or disabled contrary to the cpu
  61. /// specification.
  62. ///
  63. class SubtargetFeatures {
  64. std::vector<std::string> Features; // Subtarget features as a vector
  65. public:
  66. explicit SubtargetFeatures(const StringRef Initial = "");
  67. /// Features string accessors.
  68. std::string getString() const;
  69. /// Adding Features.
  70. void AddFeature(const StringRef String, bool IsEnabled = true);
  71. /// ToggleFeature - Toggle a feature and returns the newly updated feature
  72. /// bits.
  73. uint64_t ToggleFeature(uint64_t Bits, const StringRef String,
  74. const SubtargetFeatureKV *FeatureTable,
  75. size_t FeatureTableSize);
  76. /// Get feature bits of a CPU.
  77. uint64_t getFeatureBits(const StringRef CPU,
  78. const SubtargetFeatureKV *CPUTable,
  79. size_t CPUTableSize,
  80. const SubtargetFeatureKV *FeatureTable,
  81. size_t FeatureTableSize);
  82. /// Print feature string.
  83. void print(raw_ostream &OS) const;
  84. // Dump feature info.
  85. void dump() const;
  86. /// Retrieve a formatted string of the default features for the specified
  87. /// target triple.
  88. void getDefaultSubtargetFeatures(const Triple& Triple);
  89. };
  90. } // End namespace llvm
  91. #endif