@@ -164,7 +164,6 @@ class Vocabulary {
164
164
friend class llvm ::IR2VecVocabAnalysis;
165
165
using VocabVector = std::vector<ir2vec::Embedding>;
166
166
VocabVector Vocab;
167
- bool Valid = false ;
168
167
169
168
public:
170
169
// Slot layout:
@@ -210,9 +209,9 @@ class Vocabulary {
210
209
static_cast <unsigned >(OperandKind::MaxOperandKind);
211
210
212
211
Vocabulary () = default ;
213
- LLVM_ABI Vocabulary (VocabVector &&Vocab);
212
+ LLVM_ABI Vocabulary (VocabVector &&Vocab) : Vocab(std::move(Vocab)) {}
214
213
215
- LLVM_ABI bool isValid () const ;
214
+ LLVM_ABI bool isValid () const { return Vocab. size () == NumCanonicalEntries; } ;
216
215
LLVM_ABI unsigned getDimension () const ;
217
216
// / Total number of entries (opcodes + canonicalized types + operand kinds)
218
217
static constexpr size_t getCanonicalSize () { return NumCanonicalEntries; }
@@ -243,22 +242,22 @@ class Vocabulary {
243
242
// / Const Iterator type aliases
244
243
using const_iterator = VocabVector::const_iterator;
245
244
const_iterator begin () const {
246
- assert (Valid && " IR2Vec Vocabulary is invalid" );
245
+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
247
246
return Vocab.begin ();
248
247
}
249
248
250
249
const_iterator cbegin () const {
251
- assert (Valid && " IR2Vec Vocabulary is invalid" );
250
+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
252
251
return Vocab.cbegin ();
253
252
}
254
253
255
254
const_iterator end () const {
256
- assert (Valid && " IR2Vec Vocabulary is invalid" );
255
+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
257
256
return Vocab.end ();
258
257
}
259
258
260
259
const_iterator cend () const {
261
- assert (Valid && " IR2Vec Vocabulary is invalid" );
260
+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
262
261
return Vocab.cend ();
263
262
}
264
263
0 commit comments