@@ -486,10 +486,10 @@ class FilterChooser {
486
486
protected:
487
487
friend class Filter ;
488
488
489
- // Vector of codegen instructions to choose our filter.
490
- ArrayRef<EncodingAndInst> AllInstructions ;
489
+ // Vector of encodings to choose our filter.
490
+ ArrayRef<EncodingAndInst> Encodings ;
491
491
492
- // Vector of uid's for this filter chooser to work on.
492
+ // Vector of encoding IDs for this filter chooser to work on.
493
493
ArrayRef<unsigned > EncodingIDs;
494
494
495
495
// Lookup table for the operand decoding of instructions.
@@ -518,20 +518,22 @@ class FilterChooser {
518
518
};
519
519
520
520
public:
521
- FilterChooser (ArrayRef<EncodingAndInst> Insts, ArrayRef<unsigned > EncodingIDs,
521
+ FilterChooser (ArrayRef<EncodingAndInst> Encodings,
522
+ ArrayRef<unsigned > EncodingIDs,
522
523
const std::map<unsigned , std::vector<OperandInfo>> &Ops,
523
524
unsigned BW, const DecoderEmitter *E)
524
- : AllInstructions(Insts ), EncodingIDs(EncodingIDs), Operands(Ops),
525
+ : Encodings(Encodings ), EncodingIDs(EncodingIDs), Operands(Ops),
525
526
FilterBitValues (BW, BitValue::BIT_UNFILTERED), Parent(nullptr ),
526
527
BitWidth(BW), Emitter(E) {
527
528
doFilter ();
528
529
}
529
530
530
- FilterChooser (ArrayRef<EncodingAndInst> Insts, ArrayRef<unsigned > EncodingIDs,
531
+ FilterChooser (ArrayRef<EncodingAndInst> Encodings,
532
+ ArrayRef<unsigned > EncodingIDs,
531
533
const std::map<unsigned , std::vector<OperandInfo>> &Ops,
532
534
const std::vector<BitValue> &ParentFilterBitValues,
533
535
const FilterChooser &parent)
534
- : AllInstructions(Insts ), EncodingIDs(EncodingIDs), Operands(Ops),
536
+ : Encodings(Encodings ), EncodingIDs(EncodingIDs), Operands(Ops),
535
537
FilterBitValues(ParentFilterBitValues), Parent(&parent),
536
538
BitWidth(parent.BitWidth), Emitter(parent.Emitter) {
537
539
doFilter ();
@@ -544,8 +546,8 @@ class FilterChooser {
544
546
545
547
protected:
546
548
// Populates the insn given the uid.
547
- insn_t insnWithID (unsigned Opcode ) const {
548
- const Record *EncodingDef = AllInstructions[Opcode ].EncodingDef ;
549
+ insn_t insnWithID (unsigned EncodingID ) const {
550
+ const Record *EncodingDef = Encodings[EncodingID ].EncodingDef ;
549
551
const BitsInit &Bits = getBitsField (*EncodingDef, " Inst" );
550
552
insn_t Insn (std::max (BitWidth, Bits.getNumBits ()), BitValue::BIT_UNSET);
551
553
// We may have a SoftFail bitmask, which specifies a mask where an encoding
@@ -584,15 +586,17 @@ class FilterChooser {
584
586
585
587
// Emits code to check the Predicates member of an instruction are true.
586
588
// Returns true if predicate matches were emitted, false otherwise.
587
- bool emitPredicateMatch (raw_ostream &OS, unsigned Opc ) const ;
589
+ bool emitPredicateMatch (raw_ostream &OS, unsigned EncodingID ) const ;
588
590
bool emitPredicateMatchAux (const Init &Val, bool ParenIfBinOp,
589
591
raw_ostream &OS) const ;
590
592
591
- bool doesOpcodeNeedPredicate (unsigned Opc ) const ;
593
+ bool doesOpcodeNeedPredicate (unsigned EncodingID ) const ;
592
594
unsigned getPredicateIndex (DecoderTableInfo &TableInfo, StringRef P) const ;
593
- void emitPredicateTableEntry (DecoderTableInfo &TableInfo, unsigned Opc) const ;
595
+ void emitPredicateTableEntry (DecoderTableInfo &TableInfo,
596
+ unsigned EncodingID) const ;
594
597
595
- void emitSoftFailTableEntry (DecoderTableInfo &TableInfo, unsigned Opc) const ;
598
+ void emitSoftFailTableEntry (DecoderTableInfo &TableInfo,
599
+ unsigned EncodingID) const ;
596
600
597
601
// Emits table entries to decode the singleton.
598
602
void emitSingletonTableEntry (DecoderTableInfo &TableInfo,
@@ -605,9 +609,9 @@ class FilterChooser {
605
609
bool emitBinaryParser (raw_ostream &OS, indent Indent,
606
610
const OperandInfo &OpInfo) const ;
607
611
608
- bool emitDecoder (raw_ostream &OS, indent Indent, unsigned Opc ) const ;
612
+ bool emitDecoder (raw_ostream &OS, indent Indent, unsigned EncodingID ) const ;
609
613
std::pair<unsigned , bool > getDecoderIndex (DecoderSet &Decoders,
610
- unsigned Opc ) const ;
614
+ unsigned EncodingID ) const ;
611
615
612
616
// Assign a single filter and run with it.
613
617
void runSingleFilter (unsigned startBit, unsigned numBit);
@@ -694,9 +698,8 @@ void Filter::recurse() {
694
698
695
699
// Delegates to an inferior filter chooser for further processing on this
696
700
// group of instructions whose segment values are variable.
697
- VariableFC =
698
- std::make_unique<FilterChooser>(Owner.AllInstructions , VariableIDs,
699
- Owner.Operands , BitValueArray, Owner);
701
+ VariableFC = std::make_unique<FilterChooser>(
702
+ Owner.Encodings , VariableIDs, Owner.Operands , BitValueArray, Owner);
700
703
}
701
704
702
705
// No need to recurse for a singleton filtered instruction.
@@ -718,7 +721,7 @@ void Filter::recurse() {
718
721
// category of instructions.
719
722
FilterChooserMap.try_emplace (
720
723
FilterVal,
721
- std::make_unique<FilterChooser>(Owner.AllInstructions , EncodingIDs,
724
+ std::make_unique<FilterChooser>(Owner.Encodings , EncodingIDs,
722
725
Owner.Operands , BitValueArray, Owner));
723
726
}
724
727
}
@@ -1197,10 +1200,10 @@ bool FilterChooser::emitBinaryParser(raw_ostream &OS, indent Indent,
1197
1200
}
1198
1201
1199
1202
bool FilterChooser::emitDecoder (raw_ostream &OS, indent Indent,
1200
- unsigned Opc ) const {
1203
+ unsigned EncodingID ) const {
1201
1204
bool HasCompleteDecoder = true ;
1202
1205
1203
- for (const auto &Op : Operands.find (Opc )->second ) {
1206
+ for (const OperandInfo &Op : Operands.find (EncodingID )->second ) {
1204
1207
// If a custom instruction decoder was specified, use that.
1205
1208
if (Op.numFields () == 0 && !Op.Decoder .empty ()) {
1206
1209
HasCompleteDecoder = Op.HasCompleteDecoder ;
@@ -1216,15 +1219,16 @@ bool FilterChooser::emitDecoder(raw_ostream &OS, indent Indent,
1216
1219
return HasCompleteDecoder;
1217
1220
}
1218
1221
1219
- std::pair<unsigned , bool > FilterChooser::getDecoderIndex (DecoderSet &Decoders,
1220
- unsigned Opc) const {
1222
+ std::pair<unsigned , bool >
1223
+ FilterChooser::getDecoderIndex (DecoderSet &Decoders,
1224
+ unsigned EncodingID) const {
1221
1225
// Build up the predicate string.
1222
1226
SmallString<256 > Decoder;
1223
1227
// FIXME: emitDecoder() function can take a buffer directly rather than
1224
1228
// a stream.
1225
1229
raw_svector_ostream S (Decoder);
1226
1230
indent Indent (UseFnTableInDecodeToMCInst ? 2 : 4 );
1227
- bool HasCompleteDecoder = emitDecoder (S, Indent, Opc );
1231
+ bool HasCompleteDecoder = emitDecoder (S, Indent, EncodingID );
1228
1232
1229
1233
// Using the full decoder string as the key value here is a bit
1230
1234
// heavyweight, but is effective. If the string comparisons become a
@@ -1273,9 +1277,10 @@ bool FilterChooser::emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
1273
1277
return true ;
1274
1278
}
1275
1279
1276
- bool FilterChooser::emitPredicateMatch (raw_ostream &OS, unsigned Opc) const {
1280
+ bool FilterChooser::emitPredicateMatch (raw_ostream &OS,
1281
+ unsigned EncodingID) const {
1277
1282
const ListInit *Predicates =
1278
- AllInstructions[Opc ].EncodingDef ->getValueAsListInit (" Predicates" );
1283
+ Encodings[EncodingID ].EncodingDef ->getValueAsListInit (" Predicates" );
1279
1284
bool IsFirstEmission = true ;
1280
1285
for (unsigned i = 0 ; i < Predicates->size (); ++i) {
1281
1286
const Record *Pred = Predicates->getElementAsRecord (i);
@@ -1295,9 +1300,9 @@ bool FilterChooser::emitPredicateMatch(raw_ostream &OS, unsigned Opc) const {
1295
1300
return !Predicates->empty ();
1296
1301
}
1297
1302
1298
- bool FilterChooser::doesOpcodeNeedPredicate (unsigned Opc ) const {
1303
+ bool FilterChooser::doesOpcodeNeedPredicate (unsigned EncodingID ) const {
1299
1304
const ListInit *Predicates =
1300
- AllInstructions[Opc ].EncodingDef ->getValueAsListInit (" Predicates" );
1305
+ Encodings[EncodingID ].EncodingDef ->getValueAsListInit (" Predicates" );
1301
1306
for (unsigned i = 0 ; i < Predicates->size (); ++i) {
1302
1307
const Record *Pred = Predicates->getElementAsRecord (i);
1303
1308
if (!Pred->getValue (" AssemblerMatcherPredicate" ))
@@ -1325,16 +1330,16 @@ unsigned FilterChooser::getPredicateIndex(DecoderTableInfo &TableInfo,
1325
1330
}
1326
1331
1327
1332
void FilterChooser::emitPredicateTableEntry (DecoderTableInfo &TableInfo,
1328
- unsigned Opc ) const {
1329
- if (!doesOpcodeNeedPredicate (Opc ))
1333
+ unsigned EncodingID ) const {
1334
+ if (!doesOpcodeNeedPredicate (EncodingID ))
1330
1335
return ;
1331
1336
1332
1337
// Build up the predicate string.
1333
1338
SmallString<256 > Predicate;
1334
1339
// FIXME: emitPredicateMatch() functions can take a buffer directly rather
1335
1340
// than a stream.
1336
1341
raw_svector_ostream PS (Predicate);
1337
- emitPredicateMatch (PS, Opc );
1342
+ emitPredicateMatch (PS, EncodingID );
1338
1343
1339
1344
// Figure out the index into the predicate table for the predicate just
1340
1345
// computed.
@@ -1353,8 +1358,8 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo,
1353
1358
}
1354
1359
1355
1360
void FilterChooser::emitSoftFailTableEntry (DecoderTableInfo &TableInfo,
1356
- unsigned Opc ) const {
1357
- const Record *EncodingDef = AllInstructions[Opc ].EncodingDef ;
1361
+ unsigned EncodingID ) const {
1362
+ const Record *EncodingDef = Encodings[EncodingID ].EncodingDef ;
1358
1363
const RecordVal *RV = EncodingDef->getValue (" SoftFail" );
1359
1364
const BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue ()) : nullptr ;
1360
1365
@@ -1380,7 +1385,7 @@ void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo,
1380
1385
} else {
1381
1386
// The bit is not set; this must be an error!
1382
1387
errs () << " SoftFail Conflict: bit SoftFail{" << i << " } in "
1383
- << AllInstructions[Opc ] << " is set but Inst{" << i
1388
+ << Encodings[EncodingID ] << " is set but Inst{" << i
1384
1389
<< " } is unset!\n "
1385
1390
<< " - You can only mark a bit as SoftFail if it is fully defined"
1386
1391
<< " (1/0 - not '?') in Inst\n " ;
@@ -1453,7 +1458,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
1453
1458
: MCD::OPC_TryDecode);
1454
1459
TableInfo.Table .push_back (DecoderOp);
1455
1460
NumEncodingsSupported++;
1456
- const Record *InstDef = AllInstructions [EncodingID].Inst ->TheDef ;
1461
+ const Record *InstDef = Encodings [EncodingID].Inst ->TheDef ;
1457
1462
TableInfo.Table .insertULEB128 (Emitter->getTarget ().getInstrIntValue (InstDef));
1458
1463
TableInfo.Table .insertULEB128 (DIdx);
1459
1464
@@ -1748,7 +1753,7 @@ void FilterChooser::doFilter() {
1748
1753
1749
1754
// Dump encodings.
1750
1755
for (unsigned EncodingID : EncodingIDs) {
1751
- const EncodingAndInst &Enc = AllInstructions [EncodingID];
1756
+ const EncodingAndInst &Enc = Encodings [EncodingID];
1752
1757
errs () << Indent;
1753
1758
dumpBits (errs (), getBitsField (*Enc.EncodingDef , " Inst" ), BitWidth);
1754
1759
errs () << " " << Enc << ' \n ' ;
@@ -1919,7 +1924,7 @@ static void addOneOperandFields(const Record &EncodingDef, const BitsInit &Bits,
1919
1924
1920
1925
static unsigned
1921
1926
populateInstruction (const CodeGenTarget &Target, const Record &EncodingDef,
1922
- const CodeGenInstruction &CGI, unsigned Opc ,
1927
+ const CodeGenInstruction &CGI, unsigned EncodingID ,
1923
1928
std::map<unsigned , std::vector<OperandInfo>> &Operands,
1924
1929
bool IsVarLenInst) {
1925
1930
const Record &Def = *CGI.TheDef ;
@@ -1941,7 +1946,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
1941
1946
EncodingDef.getValueAsBit (" hasCompleteDecoder" );
1942
1947
InsnOperands.push_back (
1943
1948
OperandInfo (InstDecoder.str (), HasCompleteInstDecoder));
1944
- Operands[Opc ] = std::move (InsnOperands);
1949
+ Operands[EncodingID ] = std::move (InsnOperands);
1945
1950
return Bits.getNumBits ();
1946
1951
}
1947
1952
@@ -2063,7 +2068,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
2063
2068
InsnOperands.push_back (std::move (OpInfo));
2064
2069
}
2065
2070
}
2066
- Operands[Opc ] = std::move (InsnOperands);
2071
+ Operands[EncodingID ] = std::move (InsnOperands);
2067
2072
2068
2073
#if 0
2069
2074
LLVM_DEBUG({
0 commit comments