Skip to content

Commit

Permalink
[TableGen] Fix a misuse of getValueAsBitsInit
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
0x59616e committed Mar 22, 2022
1 parent e4e281e commit 23423c0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 23423c0

Please sign in to comment.