Skip to content

Commit 3ed446e

Browse files
committed
Remove InstructionEncoding from DecodeNode
We only need encoding name and instruction opcode.
1 parent d7b6fcf commit 3ed446e

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,8 @@ DecoderTreeBuilder::convertSingleton(unsigned EncodingID,
12311231
}
12321232

12331233
unsigned DecoderIndex = Ctx.getDecoderIndex(getDecoderString(Encoding));
1234-
N->addChild(std::make_unique<DecodeNode>(Encoding, DecoderIndex));
1234+
N->addChild(std::make_unique<DecodeNode>(
1235+
Encoding.getName(), Encoding.getInstruction()->EnumVal, DecoderIndex));
12351236

12361237
return N;
12371238
}

llvm/utils/TableGen/DecoderTableEmitter.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "DecoderTableEmitter.h"
10-
#include "Common/CodeGenInstruction.h"
11-
#include "Common/InstructionEncoding.h"
10+
#include "llvm/ADT/StringExtras.h"
1211
#include "llvm/Support/Format.h"
1312
#include "llvm/Support/LEB128.h"
1413

@@ -77,10 +76,8 @@ DecoderTableEmitter::computeNodeSize(const DecoderTreeNode *Node) const {
7776
}
7877
case DecoderTreeNode::Decode: {
7978
const auto *N = static_cast<const DecodeNode *>(Node);
80-
unsigned InstOpcode = N->getEncoding().getInstruction()->EnumVal;
81-
unsigned DecoderIndex = N->getDecoderIndex();
82-
return OpcodeSize + getULEB128Size(InstOpcode) +
83-
getULEB128Size(DecoderIndex);
79+
return OpcodeSize + getULEB128Size(N->getInstOpcode()) +
80+
getULEB128Size(N->getDecoderIndex());
8481
}
8582
}
8683
llvm_unreachable("Unknown node kind");
@@ -267,15 +264,15 @@ void DecoderTableEmitter::emitSoftFailNode(const SoftFailNode *N,
267264
}
268265

269266
void DecoderTableEmitter::emitDecodeNode(const DecodeNode *N, indent Indent) {
270-
const InstructionEncoding &Encoding = N->getEncoding();
271-
unsigned InstOpcode = Encoding.getInstruction()->EnumVal;
267+
StringRef EncodingName = N->getEncodingName();
268+
unsigned InstOpcode = N->getInstOpcode();
272269
unsigned DecoderIndex = N->getDecoderIndex();
273270

274271
emitOpcode("OPC_Decode");
275272
emitULEB128(InstOpcode);
276273
emitULEB128(DecoderIndex);
277274

278-
emitComment(Indent) << "decode to " << Encoding.getName() << " using decoder "
275+
emitComment(Indent) << "decode to " << EncodingName << " using decoder "
279276
<< DecoderIndex << '\n';
280277
}
281278

llvm/utils/TableGen/DecoderTree.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,18 @@ class SoftFailNode : public DecoderTreeNode {
189189
};
190190

191191
class DecodeNode : public DecoderTreeNode {
192-
const InstructionEncoding &Encoding;
192+
StringRef EncodingName;
193+
unsigned InstOpcode;
193194
unsigned DecoderIndex;
194195

195196
public:
196-
DecodeNode(const InstructionEncoding &Encoding, unsigned DecoderIndex)
197-
: DecoderTreeNode(Decode), Encoding(Encoding),
198-
DecoderIndex(DecoderIndex) {}
197+
DecodeNode(StringRef EncodingName, unsigned InstOpcode, unsigned DecoderIndex)
198+
: DecoderTreeNode(Decode), EncodingName(EncodingName),
199+
InstOpcode(InstOpcode), DecoderIndex(DecoderIndex) {}
199200

200-
const InstructionEncoding &getEncoding() const { return Encoding; }
201+
StringRef getEncodingName() const { return EncodingName; }
202+
203+
unsigned getInstOpcode() const { return InstOpcode; }
201204

202205
unsigned getDecoderIndex() const { return DecoderIndex; }
203206
};

0 commit comments

Comments
 (0)