/src/keystone/llvm/include/llvm/MC/MCSubtargetInfo.h
Line | Count | Source |
1 | | //==-- llvm/MC/MCSubtargetInfo.h - Subtarget Information ---------*- 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 describes the subtarget options of a Target machine. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_MC_MCSUBTARGETINFO_H |
15 | | #define LLVM_MC_MCSUBTARGETINFO_H |
16 | | |
17 | | #include "llvm/MC/MCInstrItineraries.h" |
18 | | #include "llvm/MC/MCSchedule.h" |
19 | | #include "llvm/MC/SubtargetFeature.h" |
20 | | #include <string> |
21 | | |
22 | | namespace llvm_ks { |
23 | | |
24 | | class StringRef; |
25 | | |
26 | | //===----------------------------------------------------------------------===// |
27 | | /// |
28 | | /// MCSubtargetInfo - Generic base class for all target subtargets. |
29 | | /// |
30 | | class MCSubtargetInfo { |
31 | | Triple TargetTriple; // Target triple |
32 | | std::string CPU; // CPU being targeted. |
33 | | ArrayRef<SubtargetFeatureKV> ProcFeatures; // Processor feature list |
34 | | ArrayRef<SubtargetFeatureKV> ProcDesc; // Processor descriptions |
35 | | |
36 | | FeatureBitset FeatureBits; // Feature bits for current CPU + FS |
37 | | |
38 | | // Scheduler machine model |
39 | | const SubtargetInfoKV *ProcSchedModels; |
40 | | const MCSchedModel *CPUSchedModel; |
41 | | |
42 | | MCSubtargetInfo() = delete; |
43 | | MCSubtargetInfo &operator=(MCSubtargetInfo &&) = delete; |
44 | | MCSubtargetInfo &operator=(const MCSubtargetInfo &) = delete; |
45 | | |
46 | | public: |
47 | 248k | MCSubtargetInfo(const MCSubtargetInfo &) = default; |
48 | | MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS, |
49 | | ArrayRef<SubtargetFeatureKV> PF, |
50 | | ArrayRef<SubtargetFeatureKV> PD, |
51 | | const SubtargetInfoKV *ProcSched); |
52 | | |
53 | | /// getTargetTriple - Return the target triple string. |
54 | 1.35M | const Triple &getTargetTriple() const { return TargetTriple; } |
55 | | |
56 | | /// getCPU - Return the CPU string. |
57 | 37.0k | StringRef getCPU() const { |
58 | 37.0k | return CPU; |
59 | 37.0k | } |
60 | | |
61 | | /// getFeatureBits - Return the feature bits. |
62 | | /// |
63 | 9.42M | const FeatureBitset& getFeatureBits() const { |
64 | 9.42M | return FeatureBits; |
65 | 9.42M | } |
66 | | |
67 | | /// setFeatureBits - Set the feature bits. |
68 | | /// |
69 | 3.08k | void setFeatureBits(const FeatureBitset &FeatureBits_) { |
70 | 3.08k | FeatureBits = FeatureBits_; |
71 | 3.08k | } |
72 | | |
73 | 108k | bool hasFeature(unsigned Feature) const { |
74 | 108k | return FeatureBits[Feature]; |
75 | 108k | } |
76 | | |
77 | | protected: |
78 | | /// Initialize the scheduling model and feature bits. |
79 | | /// |
80 | | /// FIXME: Find a way to stick this in the constructor, since it should only |
81 | | /// be called during initialization. |
82 | | void InitMCProcessorInfo(StringRef CPU, StringRef FS); |
83 | | |
84 | | public: |
85 | | /// Set the features to the default for the given CPU with an appended feature |
86 | | /// string. |
87 | | void setDefaultFeatures(StringRef CPU, StringRef FS); |
88 | | |
89 | | /// ToggleFeature - Toggle a feature and returns the re-computed feature |
90 | | /// bits. This version does not change the implied bits. |
91 | | FeatureBitset ToggleFeature(uint64_t FB); |
92 | | |
93 | | /// ToggleFeature - Toggle a feature and returns the re-computed feature |
94 | | /// bits. This version does not change the implied bits. |
95 | | FeatureBitset ToggleFeature(const FeatureBitset& FB); |
96 | | |
97 | | /// ToggleFeature - Toggle a set of features and returns the re-computed |
98 | | /// feature bits. This version will also change all implied bits. |
99 | | FeatureBitset ToggleFeature(StringRef FS); |
100 | | |
101 | | /// Apply a feature flag and return the re-computed feature bits, including |
102 | | /// all feature bits implied by the flag. |
103 | | FeatureBitset ApplyFeatureFlag(StringRef FS); |
104 | | |
105 | | /// getSchedModelForCPU - Get the machine model of a CPU. |
106 | | const MCSchedModel &getSchedModelForCPU(StringRef CPU) const; |
107 | | |
108 | | /// Get the machine model for this subtarget's CPU. |
109 | 32.5k | const MCSchedModel &getSchedModel() const { return *CPUSchedModel; } |
110 | | |
111 | | /// Check whether the CPU string is valid. |
112 | 29.4k | bool isCPUStringValid(StringRef CPU) const { |
113 | 29.4k | auto Found = std::lower_bound(ProcDesc.begin(), ProcDesc.end(), CPU); |
114 | 29.4k | return Found != ProcDesc.end() && StringRef(Found->Key) == CPU; |
115 | 29.4k | } |
116 | | }; |
117 | | |
118 | | } // End llvm namespace |
119 | | |
120 | | #endif |