Skip to content

Commit 23423c0

Browse files
committed
[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.
1 parent e4e281e commit 23423c0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/utils/TableGen/FixedLenDecoderEmitter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ class FilterChooser {
427427
// disassembler should return SoftFail instead of Success.
428428
//
429429
// This is used for marking UNPREDICTABLE instructions in the ARM world.
430-
BitsInit *SFBits =
431-
AllInstructions[Opcode].EncodingDef->getValueAsBitsInit("SoftFail");
432-
430+
const RecordVal *RV =
431+
AllInstructions[Opcode].EncodingDef->getValue("SoftFail");
432+
const BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue()) : nullptr;
433433
for (unsigned i = 0; i < BitWidth; ++i) {
434434
if (SFBits && bitFromBits(*SFBits, i) == BIT_TRUE)
435435
Insn.push_back(BIT_UNSET);
@@ -1309,8 +1309,9 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo,
13091309

13101310
void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo,
13111311
unsigned Opc) const {
1312-
BitsInit *SFBits =
1313-
AllInstructions[Opc].EncodingDef->getValueAsBitsInit("SoftFail");
1312+
const RecordVal *RV = AllInstructions[Opc].EncodingDef->getValue("SoftFail");
1313+
BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue()) : nullptr;
1314+
13141315
if (!SFBits) return;
13151316
BitsInit *InstBits =
13161317
AllInstructions[Opc].EncodingDef->getValueAsBitsInit("Inst");

0 commit comments

Comments
 (0)