@@ -226,6 +226,26 @@ struct DecoderTableInfo {
226
226
DecoderTable Table;
227
227
PredicateSet Predicates;
228
228
DecoderSet Decoders;
229
+
230
+ void insertPredicate (StringRef Predicate) {
231
+ Predicates.insert (CachedHashString (Predicate));
232
+ }
233
+
234
+ void insertDecoder (StringRef Decoder) {
235
+ Decoders.insert (CachedHashString (Decoder));
236
+ }
237
+
238
+ unsigned getPredicateIndex (StringRef Predicate) const {
239
+ auto I = find (Predicates, Predicate);
240
+ assert (I != Predicates.end ());
241
+ return std::distance (Predicates.begin (), I);
242
+ }
243
+
244
+ unsigned getDecoderIndex (StringRef Decoder) const {
245
+ auto I = find (Decoders, Decoder);
246
+ assert (I != Decoders.end ());
247
+ return std::distance (Decoders.begin (), I);
248
+ }
229
249
};
230
250
231
251
using NamespacesHwModesMap = std::map<StringRef, std::set<unsigned >>;
@@ -1087,13 +1107,8 @@ unsigned DecoderTableBuilder::getDecoderIndex(unsigned EncodingID) const {
1087
1107
// performance concern, we can implement a mangling of the predicate
1088
1108
// data easily enough with a map back to the actual string. That's
1089
1109
// overkill for now, though.
1090
-
1091
- // Make sure the predicate is in the table.
1092
- DecoderSet &Decoders = TableInfo.Decoders ;
1093
- Decoders.insert (CachedHashString (Decoder));
1094
- // Now figure out the index for when we write out the table.
1095
- DecoderSet::const_iterator P = find (Decoders, Decoder.str ());
1096
- return std::distance (Decoders.begin (), P);
1110
+ TableInfo.insertDecoder (Decoder);
1111
+ return TableInfo.getDecoderIndex (Decoder);
1097
1112
}
1098
1113
1099
1114
// Returns true if there was any predicate emitted.
@@ -1117,12 +1132,8 @@ unsigned DecoderTableBuilder::getPredicateIndex(StringRef Predicate) const {
1117
1132
// performance concern, we can implement a mangling of the predicate
1118
1133
// data easily enough with a map back to the actual string. That's
1119
1134
// overkill for now, though.
1120
-
1121
- // Make sure the predicate is in the table.
1122
- TableInfo.Predicates .insert (CachedHashString (Predicate));
1123
- // Now figure out the index for when we write out the table.
1124
- PredicateSet::const_iterator P = find (TableInfo.Predicates , Predicate);
1125
- return (unsigned )(P - TableInfo.Predicates .begin ());
1135
+ TableInfo.insertPredicate (Predicate);
1136
+ return TableInfo.getPredicateIndex (Predicate);
1126
1137
}
1127
1138
1128
1139
void DecoderTableBuilder::emitPredicateTableEntry (unsigned EncodingID) const {
0 commit comments