[llvm] 23423c0 - [TableGen] Fix a misuse of getValueAsBitsInit
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 21 23:05:26 PDT 2022
Author: Sheng
Date: 2022-03-22T06:04:36Z
New Revision: 23423c0ea8d414e56081cb6a13bd8b2cc91513a9
URL: https://github.com/llvm/llvm-project/commit/23423c0ea8d414e56081cb6a13bd8b2cc91513a9
DIFF: https://github.com/llvm/llvm-project/commit/23423c0ea8d414e56081cb6a13bd8b2cc91513a9.diff
LOG: [TableGen] Fix a misuse of getValueAsBitsInit
`getValueAsBitsInit` will assert when the "SoftFail" isn't presented.
But given the 'if' statement below, we should've allowed this situation.
This patch fix this.
Added:
Modified:
llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
index d945da109b5cc..86591cb7bd523 100644
--- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -427,9 +427,9 @@ class FilterChooser {
// disassembler should return SoftFail instead of Success.
//
// This is used for marking UNPREDICTABLE instructions in the ARM world.
- BitsInit *SFBits =
- AllInstructions[Opcode].EncodingDef->getValueAsBitsInit("SoftFail");
-
+ const RecordVal *RV =
+ AllInstructions[Opcode].EncodingDef->getValue("SoftFail");
+ const BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue()) : nullptr;
for (unsigned i = 0; i < BitWidth; ++i) {
if (SFBits && bitFromBits(*SFBits, i) == BIT_TRUE)
Insn.push_back(BIT_UNSET);
@@ -1309,8 +1309,9 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo,
void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo,
unsigned Opc) const {
- BitsInit *SFBits =
- AllInstructions[Opc].EncodingDef->getValueAsBitsInit("SoftFail");
+ const RecordVal *RV = AllInstructions[Opc].EncodingDef->getValue("SoftFail");
+ BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue()) : nullptr;
+
if (!SFBits) return;
BitsInit *InstBits =
AllInstructions[Opc].EncodingDef->getValueAsBitsInit("Inst");
More information about the llvm-commits
mailing list