@@ -230,7 +230,7 @@ class DecoderEmitter {
230
230
// Emit the decoder state machine table. Returns a mask of MCD decoder ops
231
231
// that were emitted.
232
232
unsigned emitTable (formatted_raw_ostream &OS, DecoderTable &Table,
233
- unsigned BitWidth, StringRef Namespace ,
233
+ StringRef Namespace, unsigned HwModeID, unsigned BitWidth ,
234
234
ArrayRef<unsigned > EncodingIDs) const ;
235
235
void emitInstrLenTable (formatted_raw_ostream &OS,
236
236
ArrayRef<unsigned > InstrLen) const ;
@@ -805,8 +805,8 @@ unsigned Filter::usefulness() const {
805
805
// Emit the decoder state machine table. Returns a mask of MCD decoder ops
806
806
// that were emitted.
807
807
unsigned DecoderEmitter::emitTable (formatted_raw_ostream &OS,
808
- DecoderTable &Table, unsigned BitWidth ,
809
- StringRef Namespace ,
808
+ DecoderTable &Table, StringRef Namespace ,
809
+ unsigned HwModeID, unsigned BitWidth ,
810
810
ArrayRef<unsigned > EncodingIDs) const {
811
811
// We'll need to be able to map from a decoded opcode into the corresponding
812
812
// EncodingID for this specific combination of BitWidth and Namespace. This
@@ -818,8 +818,10 @@ unsigned DecoderEmitter::emitTable(formatted_raw_ostream &OS,
818
818
OpcodeToEncodingID[Target.getInstrIntValue (InstDef)] = EncodingID;
819
819
}
820
820
821
- OS << " static const uint8_t DecoderTable" << Namespace << BitWidth
822
- << " [] = {\n " ;
821
+ OS << " static const uint8_t DecoderTable" << Namespace;
822
+ if (HwModeID != DefaultMode)
823
+ OS << ' _' << Target.getHwModes ().getModeName (HwModeID);
824
+ OS << BitWidth << " [] = {\n " ;
823
825
824
826
// Emit ULEB128 encoded value to OS, returning the number of bytes emitted.
825
827
auto emitULEB128 = [](DecoderTable::const_iterator &I,
@@ -2501,8 +2503,9 @@ namespace {
2501
2503
NumberedAlias,
2502
2504
&Target.getInstruction (NumberedAlias->getValueAsDef (" AliasOf" )));
2503
2505
2504
- // Map of (namespace, size) tuple to encoding IDs.
2505
- std::map<std::pair<std::string, unsigned >, std::vector<unsigned >> EncMap;
2506
+ // Map of (namespace, hwmode, size) tuple to encoding IDs.
2507
+ std::map<std::tuple<StringRef, unsigned , unsigned >, std::vector<unsigned >>
2508
+ EncMap;
2506
2509
std::map<unsigned , std::vector<OperandInfo>> Operands;
2507
2510
std::vector<unsigned > InstrLen;
2508
2511
bool IsVarLenInst = Target.hasVariableLengthEncodings ();
@@ -2537,27 +2540,22 @@ namespace {
2537
2540
MaxInstLen = std::max (MaxInstLen, Len);
2538
2541
InstrLen[NEI] = Len;
2539
2542
}
2540
- std::string DecoderNamespace =
2541
- EncodingDef->getValueAsString (" DecoderNamespace" ).str ();
2542
- // DecoderTables with DefaultMode should not have any suffix.
2543
- if (NumberedEncoding.HwModeID != DefaultMode) {
2544
- StringRef HwModeName = HWM.getModeName (NumberedEncoding.HwModeID );
2545
- DecoderNamespace += (" _" + HwModeName).str ();
2546
- }
2547
- EncMap[{DecoderNamespace, Size}].push_back (NEI);
2543
+ StringRef DecoderNamespace =
2544
+ EncodingDef->getValueAsString (" DecoderNamespace" );
2545
+ EncMap[{DecoderNamespace, NumberedEncoding.HwModeID , Size}].push_back (
2546
+ NEI);
2548
2547
} else {
2549
2548
NumEncodingsOmitted++;
2550
2549
}
2551
2550
}
2552
2551
2553
2552
DecoderTableInfo TableInfo;
2554
2553
unsigned OpcodeMask = 0 ;
2555
- for (const auto &[NSAndByteSize, EncodingIDs] : EncMap) {
2556
- const std::string &DecoderNamespace = NSAndByteSize.first ;
2557
- const unsigned BitWidth = 8 * NSAndByteSize.second ;
2558
- // Emit the decoder for this namespace+width combination.
2559
- FilterChooser FC (NumberedEncodings, EncodingIDs, Operands,
2560
- IsVarLenInst ? MaxInstLen : BitWidth, this );
2554
+ for (const auto &[Key, EncodingIDs] : EncMap) {
2555
+ auto [DecoderNamespace, HwModeID, Size] = Key;
2556
+ const unsigned BitWidth = IsVarLenInst ? MaxInstLen : 8 * Size;
2557
+ // Emit the decoder for this (namespace, hwmode, width) combination.
2558
+ FilterChooser FC (NumberedEncodings, EncodingIDs, Operands, BitWidth, this );
2561
2559
2562
2560
// The decode table is cleared for each top level decoder function. The
2563
2561
// predicates and decoders themselves, however, are shared across all
@@ -2573,8 +2571,8 @@ namespace {
2573
2571
TableInfo.Table .push_back (MCD::OPC_Fail);
2574
2572
2575
2573
// Print the table to the output stream.
2576
- OpcodeMask |= emitTable (OS, TableInfo.Table , FC. getBitWidth () ,
2577
- DecoderNamespace , EncodingIDs);
2574
+ OpcodeMask |= emitTable (OS, TableInfo.Table , DecoderNamespace, HwModeID ,
2575
+ BitWidth , EncodingIDs);
2578
2576
}
2579
2577
2580
2578
// For variable instruction, we emit a instruction length table
0 commit comments