mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[X86] AVX512: Add disassembler support for compressed displacement
There are two parts here. First is to modify tablegen to adjust the encoding type ENCODING_RM with the scaling factor. The second is to use the new encoding types to compute the correct displacement in the decoder. Fixes <rdar://problem/17608489> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213281 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -205,6 +205,7 @@ RecognizableInstr::RecognizableInstr(DisassemblerTables &tables,
|
||||
HasEVEX_B = Rec->getValueAsBit("hasEVEX_B");
|
||||
IsCodeGenOnly = Rec->getValueAsBit("isCodeGenOnly");
|
||||
ForceDisassemble = Rec->getValueAsBit("ForceDisassemble");
|
||||
CD8_Scale = byteFromRec(Rec, "CD8_Scale");
|
||||
|
||||
Name = Rec->getName();
|
||||
AsmString = Rec->getValueAsString("AsmString");
|
||||
@@ -441,6 +442,16 @@ InstructionContext RecognizableInstr::insnContext() const {
|
||||
return insnContext;
|
||||
}
|
||||
|
||||
void RecognizableInstr::adjustOperandEncoding(OperandEncoding &encoding) {
|
||||
// The scaling factor for AVX512 compressed displacement encoding is an
|
||||
// instruction attribute. Adjust the ModRM encoding type to include the
|
||||
// scale for compressed displacement.
|
||||
if (encoding != ENCODING_RM || CD8_Scale == 0)
|
||||
return;
|
||||
encoding = (OperandEncoding)(encoding + Log2_32(CD8_Scale));
|
||||
assert(encoding <= ENCODING_RM_CD64 && "Invalid CDisp scaling");
|
||||
}
|
||||
|
||||
void RecognizableInstr::handleOperand(bool optional, unsigned &operandIndex,
|
||||
unsigned &physicalOperandIndex,
|
||||
unsigned &numPhysicalOperands,
|
||||
@@ -464,8 +475,10 @@ void RecognizableInstr::handleOperand(bool optional, unsigned &operandIndex,
|
||||
|
||||
const std::string &typeName = (*Operands)[operandIndex].Rec->getName();
|
||||
|
||||
Spec->operands[operandIndex].encoding = encodingFromString(typeName,
|
||||
OpSize);
|
||||
OperandEncoding encoding = encodingFromString(typeName, OpSize);
|
||||
// Adjust the encoding type for an operand based on the instruction.
|
||||
adjustOperandEncoding(encoding);
|
||||
Spec->operands[operandIndex].encoding = encoding;
|
||||
Spec->operands[operandIndex].type = typeFromString(typeName,
|
||||
HasREX_WPrefix, OpSize);
|
||||
|
||||
|
Reference in New Issue
Block a user