Skip to content

Commit 2d47b81

Browse files
committed
address comment
1 parent 34a5cbf commit 2d47b81

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

llvm/include/llvm/MC/MCSubtargetInfo.h

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "llvm/ADT/ArrayRef.h"
1717
#include "llvm/ADT/STLExtras.h"
18-
#include "llvm/ADT/StringMap.h"
1918
#include "llvm/ADT/StringRef.h"
2019
#include "llvm/MC/MCInstrItineraries.h"
2120
#include "llvm/MC/MCSchedule.h"
@@ -33,55 +32,43 @@ class MCInst;
3332
//===----------------------------------------------------------------------===//
3433

3534
/// Used to provide key value pairs for feature and CPU bit flags.
36-
struct BasicSubtargetFeatureKV {
37-
const char *Key; ///< K-V key string
38-
unsigned Value; ///< K-V integer value
39-
FeatureBitArray Implies; ///< K-V bit mask
35+
struct SubtargetFeatureKV {
36+
const char *Key; ///< K-V key string
37+
const char *Desc; ///< Help descriptor
38+
unsigned Value; ///< K-V integer value
39+
FeatureBitArray Implies; ///< K-V bit mask
4040

4141
/// Compare routine for std::lower_bound
4242
bool operator<(StringRef S) const {
4343
return StringRef(Key) < S;
4444
}
4545

4646
/// Compare routine for std::is_sorted.
47-
bool operator<(const BasicSubtargetFeatureKV &Other) const {
47+
bool operator<(const SubtargetFeatureKV &Other) const {
4848
return StringRef(Key) < StringRef(Other.Key);
4949
}
50-
constexpr BasicSubtargetFeatureKV(const char *Key, unsigned Value,
51-
FeatureBitArray Implies)
52-
: Key(Key), Value(Value), Implies(Implies) {}
53-
};
54-
55-
struct SubtargetFeatureKV : BasicSubtargetFeatureKV {
56-
const char *Desc; ///< Help descriptor
57-
SubtargetFeatureKV(const char *Key, const char *Desc, unsigned Value,
58-
FeatureBitArray Implies)
59-
: BasicSubtargetFeatureKV(Key, Value, Implies), Desc(Desc) {}
6050
};
6151

6252
//===----------------------------------------------------------------------===//
6353

6454
/// Used to provide key value pairs for feature and CPU bit flags.
65-
struct BasicSubtargetSubTypeKV {
66-
const char *Key; ///< K-V key string
67-
FeatureBitArray Implies; ///< K-V bit mask
55+
struct SubtargetSubTypeKV {
56+
const char *Key; ///< K-V key string
57+
FeatureBitArray Implies; ///< K-V bit mask
58+
FeatureBitArray TuneImplies; ///< K-V bit mask
59+
const MCSchedModel *SchedModel;
6860

6961
/// Compare routine for std::lower_bound
7062
bool operator<(StringRef S) const {
7163
return StringRef(Key) < S;
7264
}
7365

7466
/// Compare routine for std::is_sorted.
75-
bool operator<(const BasicSubtargetSubTypeKV &Other) const {
67+
bool operator<(const SubtargetSubTypeKV &Other) const {
7668
return StringRef(Key) < StringRef(Other.Key);
7769
}
7870
};
7971

80-
struct SubtargetSubTypeKV : BasicSubtargetSubTypeKV {
81-
FeatureBitArray TuneImplies; ///< K-V bit mask
82-
const MCSchedModel *SchedModel;
83-
};
84-
8572
//===----------------------------------------------------------------------===//
8673
///
8774
/// Generic base class for all target subtargets.

llvm/include/llvm/TargetParser/TargetParser.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#ifndef LLVM_TARGETPARSER_TARGETPARSER_H
1515
#define LLVM_TARGETPARSER_TARGETPARSER_H
1616

17+
#include "SubtargetFeature.h"
18+
#include "llvm/ADT/ArrayRef.h"
1719
#include "llvm/ADT/StringMap.h"
1820
#include "llvm/ADT/StringRef.h"
19-
#include "llvm/MC/MCSubtargetInfo.h"
2021

2122
namespace llvm {
2223

@@ -191,6 +192,26 @@ insertWaveSizeFeature(StringRef GPU, const Triple &T,
191192

192193
} // namespace AMDGPU
193194

195+
struct BasicSubtargetFeatureKV {
196+
const char *Key; ///< K-V key string
197+
unsigned Value; ///< K-V integer value
198+
FeatureBitArray Implies; ///< K-V bit mask
199+
};
200+
201+
/// Used to provide key value pairs for feature and CPU bit flags.
202+
struct BasicSubtargetSubTypeKV {
203+
const char *Key; ///< K-V key string
204+
FeatureBitArray Implies; ///< K-V bit mask
205+
206+
/// Compare routine for std::lower_bound
207+
bool operator<(StringRef S) const { return StringRef(Key) < S; }
208+
209+
/// Compare routine for std::is_sorted.
210+
bool operator<(const BasicSubtargetSubTypeKV &Other) const {
211+
return StringRef(Key) < StringRef(Other.Key);
212+
}
213+
};
214+
194215
std::optional<llvm::StringMap<bool>>
195216
getCPUDefaultTargetFeatures(StringRef CPU,
196217
ArrayRef<BasicSubtargetSubTypeKV> ProcDesc,

llvm/lib/MC/MCSubtargetInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ static const T *Find(StringRef S, ArrayRef<T> A) {
3333
}
3434

3535
/// For each feature that is (transitively) implied by this feature, set it.
36-
template <typename FeatureKVType>
37-
static void SetImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies,
38-
ArrayRef<FeatureKVType> FeatureTable) {
36+
static
37+
void SetImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies,
38+
ArrayRef<SubtargetFeatureKV> FeatureTable) {
3939
// OR the Implies bits in outside the loop. This allows the Implies for CPUs
4040
// which might imply features not in FeatureTable to use this.
4141
Bits |= Implies;
42-
for (const FeatureKVType &FE : FeatureTable)
42+
for (const SubtargetFeatureKV &FE : FeatureTable)
4343
if (Implies.test(FE.Value))
4444
SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
4545
}

0 commit comments

Comments
 (0)