mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
[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
This commit is contained in:
parent
3002bdfd7c
commit
432f7965f4
@ -34,10 +34,10 @@ def InstB : TestInstruction {
|
||||
}
|
||||
|
||||
// CHECK: /* 0 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
|
||||
// CHECK-NEXT: /* 7 */ MCD::OPC_CheckField, 2, 2, 0, 5, 0, // Skip to: 18
|
||||
// CHECK-NEXT: /* 13 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, skip to: 18
|
||||
// CHECK-NEXT: /* 18 */ MCD::OPC_Decode, {{[0-9]+}}, 1, // Opcode: InstA
|
||||
// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 16, 0, 0, // Skip to: 24
|
||||
// CHECK-NEXT: /* 8 */ MCD::OPC_CheckField, 2, 2, 0, 6, 0, 0, // Skip to: 21
|
||||
// CHECK-NEXT: /* 15 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, skip to: 21
|
||||
// CHECK-NEXT: /* 21 */ MCD::OPC_Decode, {{[0-9]+}}, 1, // Opcode: InstA
|
||||
// CHECK-NEXT: /* 24 */ MCD::OPC_Fail,
|
||||
|
||||
// CHECK: if (DecodeInstB(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
|
||||
|
@ -31,14 +31,14 @@ def InstB : TestInstruction {
|
||||
}
|
||||
|
||||
// CHECK: /* 0 */ MCD::OPC_ExtractField, 2, 1, // Inst{2} ...
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 29, 0, // Skip to: 36
|
||||
// CHECK-NEXT: /* 7 */ MCD::OPC_ExtractField, 5, 3, // Inst{7-5} ...
|
||||
// CHECK-NEXT: /* 10 */ MCD::OPC_FilterValue, 0, 22, 0, // Skip to: 36
|
||||
// CHECK-NEXT: /* 14 */ MCD::OPC_CheckField, 0, 2, 3, 5, 0, // Skip to: 25
|
||||
// CHECK-NEXT: /* 20 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, skip to: 25
|
||||
// CHECK-NEXT: /* 25 */ MCD::OPC_CheckField, 3, 2, 0, 5, 0, // Skip to: 36
|
||||
// CHECK-NEXT: /* 31 */ MCD::OPC_TryDecode, {{[0-9]+}}, 1, 0, 0, // Opcode: InstA, skip to: 36
|
||||
// CHECK-NEXT: /* 36 */ MCD::OPC_Fail,
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 34, 0, 0, // Skip to: 42
|
||||
// CHECK-NEXT: /* 8 */ MCD::OPC_ExtractField, 5, 3, // Inst{7-5} ...
|
||||
// CHECK-NEXT: /* 11 */ MCD::OPC_FilterValue, 0, 26, 0, 0, // Skip to: 42
|
||||
// CHECK-NEXT: /* 16 */ MCD::OPC_CheckField, 0, 2, 3, 6, 0, 0, // Skip to: 29
|
||||
// CHECK-NEXT: /* 23 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, skip to: 29
|
||||
// CHECK-NEXT: /* 29 */ MCD::OPC_CheckField, 3, 2, 0, 6, 0, 0, // Skip to: 42
|
||||
// CHECK-NEXT: /* 36 */ MCD::OPC_TryDecode, {{[0-9]+}}, 1, 0, 0, 0, // Opcode: InstA, skip to: 42
|
||||
// CHECK-NEXT: /* 42 */ MCD::OPC_Fail,
|
||||
|
||||
// CHECK: if (DecodeInstB(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
|
||||
// CHECK: if (DecodeInstA(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
|
||||
|
@ -35,10 +35,10 @@ def InstB : TestInstruction {
|
||||
}
|
||||
|
||||
// CHECK: /* 0 */ MCD::OPC_ExtractField, 4, 4, // Inst{7-4} ...
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
|
||||
// CHECK-NEXT: /* 7 */ MCD::OPC_CheckField, 2, 2, 0, 5, 0, // Skip to: 18
|
||||
// CHECK-NEXT: /* 13 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, skip to: 18
|
||||
// CHECK-NEXT: /* 18 */ MCD::OPC_Decode, {{[0-9]+}}, 1, // Opcode: InstA
|
||||
// CHECK-NEXT: /* 21 */ MCD::OPC_Fail,
|
||||
// CHECK-NEXT: /* 3 */ MCD::OPC_FilterValue, 0, 16, 0, 0, // Skip to: 24
|
||||
// CHECK-NEXT: /* 8 */ MCD::OPC_CheckField, 2, 2, 0, 6, 0, 0, // Skip to: 21
|
||||
// CHECK-NEXT: /* 15 */ MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, 0, // Opcode: InstB, skip to: 21
|
||||
// CHECK-NEXT: /* 21 */ MCD::OPC_Decode, {{[0-9]+}}, 1, // Opcode: InstA
|
||||
// CHECK-NEXT: /* 24 */ MCD::OPC_Fail,
|
||||
|
||||
// CHECK: if (DecodeInstBOp(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user