diff options
author | Sander de Smalen <sander.desmalen@arm.com> | 2018-07-05 10:39:15 +0000 |
---|---|---|
committer | Sander de Smalen <sander.desmalen@arm.com> | 2018-07-05 10:39:15 +0000 |
commit | 13f9425e3a9afc8e8bfa6314de1a4a1d266d9a76 (patch) | |
tree | c322c3850ee5688def299353329b6a2b942c2de9 /llvm/utils | |
parent | 97e6afec2aaaf3e7e2ddebcaf4330acc4c75d518 (diff) | |
download | bcm5719-llvm-13f9425e3a9afc8e8bfa6314de1a4a1d266d9a76.tar.gz bcm5719-llvm-13f9425e3a9afc8e8bfa6314de1a4a1d266d9a76.zip |
[TableGen] Increase the number of supported decoder fix-ups.
The vast number of added instructions for SVE causes TableGen to fail with an assertion:
Assertion `Delta < 65536U && "disassembler decoding table too large!"'
This patch increases the number of supported decoder fix-ups.
Reviewers: dmgreen, stoklund, petpav01
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D48937
llvm-svn: 336334
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/TableGen/FixedLenDecoderEmitter.cpp | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index fcecc764d44..9628c47ac07 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -606,12 +606,13 @@ static void resolveTableFixups(DecoderTable &Table, const FixupList &Fixups, // NumToSkip entry itself, so subtract two from the displacement here // to account for that. uint32_t FixupIdx = *I; - uint32_t Delta = DestIdx - FixupIdx - 2; - // Our NumToSkip entries are 16-bits. Make sure our table isn't too + uint32_t Delta = DestIdx - FixupIdx - 3; + // Our NumToSkip entries are 24-bits. Make sure our table isn't too // big. - assert(Delta < 65536U && "disassembler decoding table too large!"); + assert(Delta < (1u << 24)); Table[FixupIdx] = (uint8_t)Delta; Table[FixupIdx + 1] = (uint8_t)(Delta >> 8); + Table[FixupIdx + 2] = (uint8_t)(Delta >> 16); } } @@ -646,7 +647,7 @@ void Filter::emitTableEntry(DecoderTableInfo &TableInfo) const { } else { Table.push_back(MCD::OPC_FilterValue); // Encode and emit the value to filter against. - uint8_t Buffer[8]; + uint8_t Buffer[16]; unsigned Len = encodeULEB128(Filter.first, Buffer); Table.insert(Table.end(), Buffer, Buffer + Len); // Reserve space for the NumToSkip entry. We'll backpatch the value @@ -654,6 +655,7 @@ void Filter::emitTableEntry(DecoderTableInfo &TableInfo) const { PrevFilter = Table.size(); Table.push_back(0); Table.push_back(0); + Table.push_back(0); } // We arrive at a category of instructions with the same segment value. @@ -666,10 +668,11 @@ void Filter::emitTableEntry(DecoderTableInfo &TableInfo) const { // of the filter itself to be able to skip forward when false. Subtract // two as to account for the width of the NumToSkip field itself. if (PrevFilter) { - uint32_t NumToSkip = Table.size() - PrevFilter - 2; - assert(NumToSkip < 65536U && "disassembler decoding table too large!"); + uint32_t NumToSkip = Table.size() - PrevFilter - 3; + assert(NumToSkip < (1u << 24) && "disassembler decoding table too large!"); Table[PrevFilter] = (uint8_t)NumToSkip; Table[PrevFilter + 1] = (uint8_t)(NumToSkip >> 8); + Table[PrevFilter + 2] = (uint8_t)(NumToSkip >> 16); } } @@ -745,13 +748,16 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, OS << (unsigned)*I++ << ", "; OS << (unsigned)*I++ << ", "; - // 16-bit numtoskip value. + // 24-bit numtoskip value. uint8_t Byte = *I++; uint32_t NumToSkip = Byte; OS << (unsigned)Byte << ", "; Byte = *I++; OS << (unsigned)Byte << ", "; NumToSkip |= Byte << 8; + Byte = *I++; + OS << utostr(Byte) << ", "; + NumToSkip |= Byte << 16; OS << "// Skip to: " << ((I - Table.begin()) + NumToSkip) << "\n"; break; } @@ -765,13 +771,16 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, for (; *I >= 128; ++I) OS << (unsigned)*I << ", "; OS << (unsigned)*I++ << ", "; - // 16-bit numtoskip value. + // 24-bit numtoskip value. uint8_t Byte = *I++; uint32_t NumToSkip = Byte; OS << (unsigned)Byte << ", "; Byte = *I++; OS << (unsigned)Byte << ", "; NumToSkip |= Byte << 8; + Byte = *I++; + OS << utostr(Byte) << ", "; + NumToSkip |= Byte << 16; OS << "// Skip to: " << ((I - Table.begin()) + NumToSkip) << "\n"; break; } @@ -782,13 +791,16 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, OS << (unsigned)*I << ", "; OS << (unsigned)*I++ << ", "; - // 16-bit numtoskip value. + // 24-bit numtoskip value. uint8_t Byte = *I++; uint32_t NumToSkip = Byte; OS << (unsigned)Byte << ", "; Byte = *I++; OS << (unsigned)Byte << ", "; NumToSkip |= Byte << 8; + Byte = *I++; + OS << utostr(Byte) << ", "; + NumToSkip |= Byte << 16; OS << "// Skip to: " << ((I - Table.begin()) + NumToSkip) << "\n"; break; } @@ -797,7 +809,7 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, bool IsTry = *I == MCD::OPC_TryDecode; ++I; // Extract the ULEB128 encoded Opcode to a buffer. - uint8_t Buffer[8], *p = Buffer; + uint8_t Buffer[16], *p = Buffer; while ((*p++ = *I++) >= 128) assert((p - Buffer) <= (ptrdiff_t)sizeof(Buffer) && "ULEB128 value too large!"); @@ -822,13 +834,16 @@ void FixedLenDecoderEmitter::emitTable(formatted_raw_ostream &OS, // Fallthrough for OPC_TryDecode. - // 16-bit numtoskip value. + // 24-bit numtoskip value. uint8_t Byte = *I++; uint32_t NumToSkip = Byte; OS << (unsigned)Byte << ", "; Byte = *I++; OS << (unsigned)Byte << ", "; NumToSkip |= Byte << 8; + Byte = *I++; + OS << utostr(Byte) << ", "; + NumToSkip |= Byte << 16; OS << "// Opcode: " << NumberedInstructions[Opc]->TheDef->getName() @@ -1226,6 +1241,7 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo, TableInfo.FixupStack.back().push_back(TableInfo.Table.size()); TableInfo.Table.push_back(0); TableInfo.Table.push_back(0); + TableInfo.Table.push_back(0); } void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo, @@ -1311,18 +1327,19 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo, TableInfo.Table.push_back(MCD::OPC_CheckField); TableInfo.Table.push_back(StartBits[I-1]); TableInfo.Table.push_back(NumBits); - uint8_t Buffer[8], *p; + uint8_t Buffer[16], *p; encodeULEB128(FieldVals[I-1], Buffer); for (p = Buffer; *p >= 128 ; ++p) TableInfo.Table.push_back(*p); TableInfo.Table.push_back(*p); // Push location for NumToSkip backpatching. TableInfo.FixupStack.back().push_back(TableInfo.Table.size()); - // The fixup is always 16-bits, so go ahead and allocate the space + // The fixup is always 24-bits, so go ahead and allocate the space // in the table so all our relative position calculations work OK even // before we fully resolve the real value here. TableInfo.Table.push_back(0); TableInfo.Table.push_back(0); + TableInfo.Table.push_back(0); } // Check for soft failure of the match. @@ -1342,7 +1359,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo, // can decode it. TableInfo.Table.push_back(HasCompleteDecoder ? MCD::OPC_Decode : MCD::OPC_TryDecode); - uint8_t Buffer[8], *p; + uint8_t Buffer[16], *p; encodeULEB128(Opc, Buffer); for (p = Buffer; *p >= 128 ; ++p) TableInfo.Table.push_back(*p); @@ -1362,6 +1379,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo, // Allocate the space for the fixup. TableInfo.Table.push_back(0); TableInfo.Table.push_back(0); + TableInfo.Table.push_back(0); } } @@ -2097,9 +2115,10 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) { << " unsigned Len;\n" << " InsnType Val = decodeULEB128(++Ptr, &Len);\n" << " Ptr += Len;\n" - << " // NumToSkip is a plain 16-bit integer.\n" + << " // NumToSkip is a plain 24-bit integer.\n" << " unsigned NumToSkip = *Ptr++;\n" << " NumToSkip |= (*Ptr++) << 8;\n" + << " NumToSkip |= (*Ptr++) << 16;\n" << "\n" << " // Perform the filter operation.\n" << " if (Val != CurFieldValue)\n" @@ -2120,9 +2139,10 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) { << " // Decode the field value.\n" << " uint32_t ExpectedValue = decodeULEB128(++Ptr, &Len);\n" << " Ptr += Len;\n" - << " // NumToSkip is a plain 16-bit integer.\n" + << " // NumToSkip is a plain 24-bit integer.\n" << " unsigned NumToSkip = *Ptr++;\n" << " NumToSkip |= (*Ptr++) << 8;\n" + << " NumToSkip |= (*Ptr++) << 16;\n" << "\n" << " // If the actual and expected values don't match, skip.\n" << " if (ExpectedValue != FieldValue)\n" @@ -2143,9 +2163,10 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) { << " // Decode the Predicate Index value.\n" << " unsigned PIdx = decodeULEB128(++Ptr, &Len);\n" << " Ptr += Len;\n" - << " // NumToSkip is a plain 16-bit integer.\n" + << " // NumToSkip is a plain 24-bit integer.\n" << " unsigned NumToSkip = *Ptr++;\n" << " NumToSkip |= (*Ptr++) << 8;\n" + << " NumToSkip |= (*Ptr++) << 16;\n" << " // Check the predicate.\n" << " bool Pred;\n" << " if (!(Pred = checkDecoderPredicate(PIdx, Bits)))\n" @@ -2185,9 +2206,10 @@ static void emitDecodeInstruction(formatted_raw_ostream &OS) { << " Ptr += Len;\n" << " unsigned DecodeIdx = decodeULEB128(Ptr, &Len);\n" << " Ptr += Len;\n" - << " // NumToSkip is a plain 16-bit integer.\n" + << " // NumToSkip is a plain 24-bit integer.\n" << " unsigned NumToSkip = *Ptr++;\n" << " NumToSkip |= (*Ptr++) << 8;\n" + << " NumToSkip |= (*Ptr++) << 16;\n" << "\n" << " // Perform the decode operation.\n" << " MCInst TmpMI;\n" |