target/arm: Pull handling of XScale insns out of disas_coproc_insn()

At the moment we check for XScale/iwMMXt insns inside
disas_coproc_insn(): for CPUs with ARM_FEATURE_XSCALE all copro insns
with cp 0 or 1 are handled specially. This works, but is an odd
place for this check, because disas_coproc_insn() is called from both
the Arm and Thumb decoders but the XScale case never applies for
Thumb (all the XScale CPUs were ARMv5, which has only Thumb1, not
Thumb2 with the 32-bit coprocessor insn encodings). It also makes it
awkward to convert the real copro access insns to decodetree.

Move the identification of XScale out to its own function
which is only called from disas_arm_insn().

Backports commit 7b4f933db865391a90a3b4518bb2050a83f2a873 from qemu
This commit is contained in:
Peter Maydell 2021-02-26 10:50:22 -05:00 committed by Lioncash
parent 9b7f4b72fc
commit 2944a75b98

View file

@ -4647,20 +4647,6 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn)
cpnum = (insn >> 8) & 0xf;
/* First check for coprocessor space used for XScale/iwMMXt insns */
if (arm_dc_feature(s, ARM_FEATURE_XSCALE) && (cpnum < 2)) {
if (extract32(s->c15_cpar, cpnum, 1) == 0) {
return 1;
}
if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) {
return disas_iwmmxt_insn(s, insn);
} else if (arm_dc_feature(s, ARM_FEATURE_XSCALE)) {
return disas_dsp_insn(s, insn);
}
return 1;
}
/* Otherwise treat as a generic register access */
is64 = (insn & (1 << 25)) == 0;
if (!is64 && ((insn & (1 << 4)) == 0)) {
/* cdp */
@ -4902,6 +4888,23 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn)
return 1;
}
/* Decode XScale DSP or iWMMXt insn (in the copro space, cp=0 or 1) */
static void disas_xscale_insn(DisasContext *s, uint32_t insn)
{
int cpnum = (insn >> 8) & 0xf;
if (extract32(s->c15_cpar, cpnum, 1) == 0) {
unallocated_encoding(s);
} else if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) {
if (disas_iwmmxt_insn(s, insn)) {
unallocated_encoding(s);
}
} else if (arm_dc_feature(s, ARM_FEATURE_XSCALE)) {
if (disas_dsp_insn(s, insn)) {
unallocated_encoding(s);
}
}
}
/* Store a 64-bit value to a register pair. Clobbers val. */
static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val)
@ -8535,15 +8538,26 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
case 0xc:
case 0xd:
case 0xe:
if (((insn >> 8) & 0xe) == 10) {
{
/* First check for coprocessor space used for XScale/iwMMXt insns */
int cpnum = (insn >> 8) & 0xf;
if (arm_dc_feature(s, ARM_FEATURE_XSCALE) && (cpnum < 2)) {
disas_xscale_insn(s, insn);
break;
}
if ((cpnum & 0xe) == 10) {
/* VFP, but failed disas_vfp. */
goto illegal_op;
}
if (disas_coproc_insn(s, insn)) {
/* Coprocessor. */
goto illegal_op;
}
break;
}
default:
illegal_op:
unallocated_encoding(s);