[llvm] [LLVM][MC] Add support to cull inactive decoders in decoder emitter (PR #154865)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 26 09:26:12 PDT 2025
================
@@ -2528,45 +2535,80 @@ namespace {
)";
// Do extra bookkeeping for variable-length encodings.
- std::vector<unsigned> InstrLen;
bool IsVarLenInst = Target.hasVariableLengthEncodings();
unsigned MaxInstLen = 0;
if (IsVarLenInst) {
- InstrLen.resize(Target.getInstructions().size(), 0);
+ std::vector<unsigned> InstrLen(Target.getInstructions().size(), 0);
for (const InstructionEncoding &Encoding : Encodings) {
MaxInstLen = std::max(MaxInstLen, Encoding.getBitWidth());
InstrLen[Target.getInstrIntValue(Encoding.getInstruction()->TheDef)] =
Encoding.getBitWidth();
}
+
+ // For variable instruction, we emit a instruction length table to let the
+ // decoder know how long the instructions are. You can see example usage in
+ // M68k's disassembler.
+ emitInstrLenTable(OS, InstrLen);
}
- // Map of (namespace, hwmode, size) tuple to encoding IDs.
- std::map<std::tuple<StringRef, unsigned, unsigned>, std::vector<unsigned>>
+ // Map of (bitwidth, namespace, hwmode) tuple to encoding IDs.
+ std::map<std::tuple<unsigned, StringRef, unsigned>, std::vector<unsigned>>
----------------
jurahul wrote:
Done,
https://github.com/llvm/llvm-project/pull/154865
More information about the llvm-commits
mailing list