@@ -230,7 +230,7 @@ class DecoderEmitter {
230230 // Emit the decoder state machine table. Returns a mask of MCD decoder ops
231231 // that were emitted.
232232 unsigned emitTable (formatted_raw_ostream &OS, DecoderTable &Table,
233- unsigned BitWidth, StringRef Namespace ,
233+ StringRef Namespace, unsigned HwModeID, unsigned BitWidth ,
234234 ArrayRef<unsigned > EncodingIDs) const ;
235235 void emitInstrLenTable (formatted_raw_ostream &OS,
236236 ArrayRef<unsigned > InstrLen) const ;
@@ -805,8 +805,8 @@ unsigned Filter::usefulness() const {
805805// Emit the decoder state machine table. Returns a mask of MCD decoder ops
806806// that were emitted.
807807unsigned DecoderEmitter::emitTable (formatted_raw_ostream &OS,
808- DecoderTable &Table, unsigned BitWidth ,
809- StringRef Namespace ,
808+ DecoderTable &Table, StringRef Namespace ,
809+ unsigned HwModeID, unsigned BitWidth ,
810810 ArrayRef<unsigned > EncodingIDs) const {
811811 // We'll need to be able to map from a decoded opcode into the corresponding
812812 // EncodingID for this specific combination of BitWidth and Namespace. This
@@ -818,8 +818,10 @@ unsigned DecoderEmitter::emitTable(formatted_raw_ostream &OS,
818818 OpcodeToEncodingID[Target.getInstrIntValue (InstDef)] = EncodingID;
819819 }
820820
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 " ;
823825
824826 // Emit ULEB128 encoded value to OS, returning the number of bytes emitted.
825827 auto emitULEB128 = [](DecoderTable::const_iterator &I,
@@ -2501,8 +2503,9 @@ namespace {
25012503 NumberedAlias,
25022504 &Target.getInstruction (NumberedAlias->getValueAsDef (" AliasOf" )));
25032505
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;
25062509 std::map<unsigned , std::vector<OperandInfo>> Operands;
25072510 std::vector<unsigned > InstrLen;
25082511 bool IsVarLenInst = Target.hasVariableLengthEncodings ();
@@ -2537,27 +2540,22 @@ namespace {
25372540 MaxInstLen = std::max (MaxInstLen, Len);
25382541 InstrLen[NEI] = Len;
25392542 }
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);
25482547 } else {
25492548 NumEncodingsOmitted++;
25502549 }
25512550 }
25522551
25532552 DecoderTableInfo TableInfo;
25542553 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 );
25612559
25622560 // The decode table is cleared for each top level decoder function. The
25632561 // predicates and decoders themselves, however, are shared across all
@@ -2573,8 +2571,8 @@ namespace {
25732571 TableInfo.Table .push_back (MCD::OPC_Fail);
25742572
25752573 // 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);
25782576 }
25792577
25802578 // For variable instruction, we emit a instruction length table
0 commit comments