Skip to content

Commit d65719f

Browse files
committed
[TableGen] Use isUInt to simplify some asserts. NFC
1 parent 8370ac8 commit d65719f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static void resolveTableFixups(DecoderTable &Table, const FixupList &Fixups,
688688
uint32_t Delta = DestIdx - FixupIdx - 3;
689689
// Our NumToSkip entries are 24-bits. Make sure our table isn't too
690690
// big.
691-
assert(Delta < (1u << 24));
691+
assert(isUInt<24>(Delta));
692692
Table[FixupIdx] = (uint8_t)Delta;
693693
Table[FixupIdx + 1] = (uint8_t)(Delta >> 8);
694694
Table[FixupIdx + 2] = (uint8_t)(Delta >> 16);
@@ -698,7 +698,7 @@ static void resolveTableFixups(DecoderTable &Table, const FixupList &Fixups,
698698
// Emit table entries to decode instructions given a segment or segments
699699
// of bits.
700700
void Filter::emitTableEntry(DecoderTableInfo &TableInfo) const {
701-
assert((NumBits < (1u << 8)) && "NumBits overflowed uint8 table entry!");
701+
assert(isUInt<8>(NumBits) && "NumBits overflowed uint8 table entry!");
702702
TableInfo.Table.push_back(MCD::OPC_ExtractField);
703703

704704
SmallString<16> SBytes;
@@ -753,8 +753,7 @@ void Filter::emitTableEntry(DecoderTableInfo &TableInfo) const {
753753
// two as to account for the width of the NumToSkip field itself.
754754
if (PrevFilter) {
755755
uint32_t NumToSkip = Table.size() - PrevFilter - 3;
756-
assert(NumToSkip < (1u << 24) &&
757-
"disassembler decoding table too large!");
756+
assert(isUInt<24>(NumToSkip) && "disassembler decoding table too large!");
758757
Table[PrevFilter] = (uint8_t)NumToSkip;
759758
Table[PrevFilter + 1] = (uint8_t)(NumToSkip >> 8);
760759
Table[PrevFilter + 2] = (uint8_t)(NumToSkip >> 16);
@@ -1446,7 +1445,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
14461445
// Check any additional encoding fields needed.
14471446
for (unsigned I = Size; I != 0; --I) {
14481447
unsigned NumBits = EndBits[I - 1] - StartBits[I - 1] + 1;
1449-
assert((NumBits < (1u << 8)) && "NumBits overflowed uint8 table entry!");
1448+
assert(isUInt<8>(NumBits) && "NumBits overflowed uint8 table entry!");
14501449
TableInfo.Table.push_back(MCD::OPC_CheckField);
14511450
uint8_t Buffer[16], *P;
14521451
encodeULEB128(StartBits[I - 1], Buffer);

0 commit comments

Comments
 (0)