Skip to content

Commit

Permalink
[NFC][AArch64] Move AArch64 MSR/MRS into a new decoder namespace
Browse files Browse the repository at this point in the history
This removes the general forms of the AArch64 MSR and MRS instructions
from the same decoding table that contains many more specific
instructions that supersede them. They're now in a separate decoding
table of their own, called "Fallback", which is only consulted in the
event of the main decoder table failing to produce an answer.

This should avoid decoding conflicts on future specialized instructions
in the MSR space.

Patch written by Simon Tatham.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D91771
  • Loading branch information
pratlucas committed Dec 17, 2020
1 parent 29077ae commit b5bbb4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Expand Up @@ -1447,6 +1447,7 @@ class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg),
"mrs", "\t$Rt, $systemreg"> {
bits<16> systemreg;
let Inst{20-5} = systemreg;
let DecoderNamespace = "Fallback";
}

// FIXME: Some of these def NZCV, others don't. Best way to model that?
Expand All @@ -1456,6 +1457,7 @@ class MSRI : RtSystemI<0, (outs), (ins msr_sysreg_op:$systemreg, GPR64:$Rt),
"msr", "\t$systemreg, $Rt"> {
bits<16> systemreg;
let Inst{20-5} = systemreg;
let DecoderNamespace = "Fallback";
}

def SystemPStateFieldWithImm0_15Operand : AsmOperandClass {
Expand Down
12 changes: 10 additions & 2 deletions llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp
Expand Up @@ -267,8 +267,16 @@ DecodeStatus AArch64Disassembler::getInstruction(MCInst &MI, uint64_t &Size,
uint32_t Insn =
(Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | (Bytes[0] << 0);

// Calling the auto-generated decoder function.
return decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI);
const uint8_t *Tables[] = {DecoderTable32, DecoderTableFallback32};

for (auto Table : Tables) {
DecodeStatus Result =
decodeInstruction(Table, MI, Insn, Address, this, STI);
if (Result != MCDisassembler::Fail)
return Result;
}

return MCDisassembler::Fail;
}

static MCSymbolizer *
Expand Down

0 comments on commit b5bbb4b

Please sign in to comment.