From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH 1/7] target/arm: Pull handling of XScale insns out of disas_coproc_insn()
Date: Mon, 3 Aug 2020 12:18:43 +0100 [thread overview]
Message-ID: <20200803111849.13368-2-peter.maydell@linaro.org> (raw)
In-Reply-To: <20200803111849.13368-1-peter.maydell@linaro.org>
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().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/translate.c | 44 ++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 15 deletions(-)
diff --git a/target/arm/translate.c b/target/arm/translate.c
index c39a929b938..a2765fc60b2 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -4551,20 +4551,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 */
@@ -4823,6 +4809,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)
@@ -8270,15 +8273,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);
--
2.20.1
next prev parent reply other threads:[~2020-08-03 11:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 11:18 [PATCH 0/7] target/arm: copro decode cleanup Peter Maydell
2020-08-03 11:18 ` Peter Maydell [this message]
2020-08-04 14:49 ` [PATCH 1/7] target/arm: Pull handling of XScale insns out of disas_coproc_insn() Richard Henderson
2020-08-03 11:18 ` [PATCH 2/7] target/arm: Separate decode from handling of coproc insns Peter Maydell
2020-08-04 14:53 ` Richard Henderson
2020-08-03 11:18 ` [PATCH 3/7] target/arm: Convert A32 coprocessor insns to decodetree Peter Maydell
2020-08-05 2:53 ` Richard Henderson
2020-08-03 11:18 ` [PATCH 4/7] target/arm: Tidy up disas_arm_insn() Peter Maydell
2020-08-05 2:57 ` Richard Henderson
2020-08-03 11:18 ` [PATCH 5/7] target/arm: Do M-profile NOCP checks early and via decodetree Peter Maydell
2020-08-05 3:04 ` Richard Henderson
2020-08-03 11:18 ` [PATCH 6/7] target/arm: Convert T32 coprocessor insns to decodetree Peter Maydell
2020-08-05 3:05 ` Richard Henderson
2020-08-03 11:18 ` [PATCH 7/7] target/arm: Remove ARCH macro Peter Maydell
2020-08-05 3:07 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200803111849.13368-2-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).