[llvm] [RISCV][Disassembler] Use a table to store all the decoder tables and their associated features. NFC (PR #130883)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 11 20:31:10 PDT 2025
================
@@ -620,29 +620,19 @@ void RISCVDisassembler::addSPOperands(MCInst &MI) const {
MI.insert(MI.begin() + i, MCOperand::createReg(RISCV::X2));
}
-#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, \
- DESC, ADDITIONAL_OPERATION) \
- do { \
- if (FEATURE_CHECKS) { \
- LLVM_DEBUG(dbgs() << "Trying " << DESC << " table:\n"); \
- DecodeStatus Result = \
- decodeInstruction(DECODER_TABLE, MI, Insn, Address, this, STI); \
- if (Result != MCDisassembler::Fail) { \
- ADDITIONAL_OPERATION; \
- return Result; \
- } \
- } \
- } while (false)
-#define TRY_TO_DECODE_AND_ADD_SP(FEATURE_CHECKS, DECODER_TABLE, DESC) \
- TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
- addSPOperands(MI))
-#define TRY_TO_DECODE(FEATURE_CHECKS, DECODER_TABLE, DESC) \
- TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
- (void)nullptr)
-#define TRY_TO_DECODE_FEATURE(FEATURE, DECODER_TABLE, DESC) \
- TRY_TO_DECODE(STI.hasFeature(FEATURE), DECODER_TABLE, DESC)
-#define TRY_TO_DECODE_FEATURE_ANY(FEATURES, DECODER_TABLE, DESC) \
- TRY_TO_DECODE((STI.getFeatureBits() & (FEATURES)).any(), DECODER_TABLE, DESC)
+namespace {
+
+struct DecoderListEntry {
+ const uint8_t *Table;
+ FeatureBitset RequiredFeatures;
----------------
lenary wrote:
Let's give this a different name - usually when we have a bitmap with "required" in the name, it means you're comparing based on all the bits being set, whereas here we just want if any are set.
This also applies to `haveRequiredFeatures` below, which should use the same adjective that you choose instead of "required".
https://github.com/llvm/llvm-project/pull/130883
More information about the llvm-commits
mailing list