Skip to content

Commit ea3a3a8

Browse files
authored
[TableGen][Decoder] Cache DecoderNamespace in InstructionEncoding (NFC) (llvm#156059)
1 parent adbd432 commit ea3a3a8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ class InstructionEncoding {
157157
/// The name of this encoding (for debugging purposes).
158158
std::string Name;
159159

160+
/// The namespace in which this encoding exists.
161+
StringRef DecoderNamespace;
162+
160163
/// Known bits of this encoding. This is the value of the `Inst` field
161164
/// with any variable references replaced with '?'.
162165
KnownBits InstBits;
@@ -190,6 +193,9 @@ class InstructionEncoding {
190193
/// Returns the name of this encoding, for debugging purposes.
191194
StringRef getName() const { return Name; }
192195

196+
/// Returns the namespace in which this encoding exists.
197+
StringRef getDecoderNamespace() const { return DecoderNamespace; }
198+
193199
/// Returns the size of this encoding, in bits.
194200
unsigned getBitWidth() const { return InstBits.getBitWidth(); }
195201

@@ -2054,6 +2060,7 @@ InstructionEncoding::InstructionEncoding(const Record *EncodingDef,
20542060
Name = (EncodingDef->getName() + Twine(':')).str();
20552061
Name.append(InstDef->getName());
20562062

2063+
DecoderNamespace = EncodingDef->getValueAsString("DecoderNamespace");
20572064
DecoderMethod = EncodingDef->getValueAsString("DecoderMethod");
20582065
if (!DecoderMethod.empty())
20592066
HasCompleteDecoder = EncodingDef->getValueAsBit("hasCompleteDecoder");
@@ -2339,8 +2346,7 @@ void DecoderEmitter::handleHwModesUnrelatedEncodings(
23392346
break;
23402347
}
23412348
case SUPPRESSION_LEVEL1: {
2342-
const Record *InstDef = Encodings[EncodingID].getInstruction()->TheDef;
2343-
StringRef DecoderNamespace = InstDef->getValueAsString("DecoderNamespace");
2349+
StringRef DecoderNamespace = Encodings[EncodingID].getDecoderNamespace();
23442350
auto It = NamespacesWithHwModes.find(DecoderNamespace);
23452351
if (It != NamespacesWithHwModes.end()) {
23462352
for (unsigned HwModeID : It->second)
@@ -2513,8 +2519,7 @@ namespace {
25132519
const InstructionEncoding &Encoding = Encodings[EncodingID];
25142520
const Record *EncodingDef = Encoding.getRecord();
25152521
unsigned Size = EncodingDef->getValueAsInt("Size");
2516-
StringRef DecoderNamespace =
2517-
EncodingDef->getValueAsString("DecoderNamespace");
2522+
StringRef DecoderNamespace = Encoding.getDecoderNamespace();
25182523
EncMap[{DecoderNamespace, HwModeID, Size}].push_back(EncodingID);
25192524
}
25202525
}

0 commit comments

Comments
 (0)