@@ -251,8 +251,7 @@ class DecoderEmitter {
251
251
//
252
252
// BIT_UNFILTERED is used as the init value for a filter position. It is used
253
253
// only for filter processings.
254
- class BitValue {
255
- public:
254
+ struct BitValue {
256
255
enum bit_value_t : uint8_t {
257
256
BIT_FALSE, // '0'
258
257
BIT_TRUE, // '1'
@@ -261,25 +260,37 @@ class BitValue {
261
260
};
262
261
263
262
BitValue (bit_value_t V) : V(V) {}
264
- BitValue (const Init *Init) {
265
- if (const BitInit *Bit = dyn_cast<BitInit>(Init))
263
+ explicit BitValue (const Init *Init) {
264
+ if (const auto *Bit = dyn_cast<BitInit>(Init))
266
265
V = Bit->getValue () ? BIT_TRUE : BIT_FALSE;
267
266
else
268
267
V = BIT_UNSET;
269
268
}
270
269
BitValue (const BitsInit &Bits, unsigned Idx) : BitValue(Bits.getBit(Idx)) {}
271
270
272
- bool isSet (void ) const { return V == BIT_TRUE || V == BIT_FALSE; }
273
- bool isUnset (void ) const { return V == BIT_UNSET; }
274
- std::optional<uint64_t > getValue (void ) const {
271
+ bool isSet () const { return V == BIT_TRUE || V == BIT_FALSE; }
272
+ bool isUnset () const { return V == BIT_UNSET; }
273
+ std::optional<uint64_t > getValue () const {
275
274
if (isSet ())
276
275
return static_cast <uint64_t >(V);
277
276
return std::nullopt;
278
277
}
279
278
bit_value_t getRawValue () const { return V; }
280
279
281
280
// For printing a bit value.
282
- operator StringRef () const { return StringRef (" 01_." ).slice (V, V + 1 ); }
281
+ operator StringRef () const {
282
+ switch (V) {
283
+ case BIT_FALSE:
284
+ return " 0" ;
285
+ case BIT_TRUE:
286
+ return " 1" ;
287
+ case BIT_UNSET:
288
+ return " _" ;
289
+ case BIT_UNFILTERED:
290
+ return " ." ;
291
+ }
292
+ llvm_unreachable (" Unknow bit value" );
293
+ }
283
294
284
295
bool operator ==(bit_value_t Other) const { return Other == V; }
285
296
bool operator !=(bit_value_t Other) const { return Other != V; }
@@ -318,7 +329,7 @@ static const BitsInit &getBitsField(const Record &Def, StringRef FieldName) {
318
329
else if (const BitInit *BI = dyn_cast<BitInit>(SI.Value ))
319
330
Bits.push_back (BI);
320
331
else
321
- Bits.insert (Bits. end (), SI.BitWidth , UnsetInit::get (Def.getRecords ()));
332
+ Bits.append ( SI.BitWidth , UnsetInit::get (Def.getRecords ()));
322
333
}
323
334
324
335
return *BitsInit::get (Def.getRecords (), Bits);
@@ -1430,16 +1441,13 @@ void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo,
1430
1441
if (B != BitValue::BIT_TRUE)
1431
1442
continue ;
1432
1443
1433
- switch (IB.getRawValue ()) {
1434
- case BitValue::BIT_FALSE:
1444
+ if (IB == BitValue::BIT_FALSE) {
1435
1445
// The bit is meant to be false, so emit a check to see if it is true.
1436
1446
PositiveMask.setBit (i);
1437
- break ;
1438
- case BitValue::BIT_TRUE:
1447
+ } else if (IB == BitValue::BIT_TRUE) {
1439
1448
// The bit is meant to be true, so emit a check to see if it is false.
1440
1449
NegativeMask.setBit (i);
1441
- break ;
1442
- default :
1450
+ } else {
1443
1451
// The bit is not set; this must be an error!
1444
1452
errs () << " SoftFail Conflict: bit SoftFail{" << i << " } in "
1445
1453
<< AllInstructions[Opc] << " is set but Inst{" << i
0 commit comments