From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
richard.henderson@linaro.org,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [RISU PATCH v3 10/22] risugen: add reg_plus_imm_pl and reg_plus_imm_vl address helpers
Date: Wed, 13 Jun 2018 13:55:49 +0100 [thread overview]
Message-ID: <20180613125601.14371-11-alex.bennee@linaro.org> (raw)
In-Reply-To: <20180613125601.14371-1-alex.bennee@linaro.org>
From: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
risugen_arm.pm | 126 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
diff --git a/risugen_arm.pm b/risugen_arm.pm
index 485e94e..696bf5f 100644
--- a/risugen_arm.pm
+++ b/risugen_arm.pm
@@ -306,6 +306,52 @@ sub write_mov_ri($$)
}
}
+sub write_addpl_rri($$$)
+{
+ my ($rd, $rn, $imm) = @_;
+ die "write_addpl: invalid operation for this arch.\n" if (!$is_aarch64);
+
+ insn32(0x04605000 | ($rn << 16) | (($imm & 0x3f) << 5) | $rd);
+}
+
+sub write_addvl_rri($$$)
+{
+ my ($rd, $rn, $imm) = @_;
+ die "write_addvl: invalid operation for this arch.\n" if (!$is_aarch64);
+
+ insn32(0x04205000 | ($rn << 16) | (($imm & 0x3f) << 5) | $rd);
+}
+
+sub write_rdvl_ri($$)
+{
+ my ($rd, $imm) = @_;
+ die "write_rdvl: invalid operation for this arch.\n" if (!$is_aarch64);
+
+ insn32(0x04bf5000 | (($imm & 0x3f) << 5) | $rd);
+}
+
+sub write_madd_rrrr($$$$)
+{
+ my ($rd, $rn, $rm, $ra) = @_;
+ die "write_madd: invalid operation for this arch.\n" if (!$is_aarch64);
+
+ insn32(0x9b000000 | ($rm << 16) | ($ra << 10) | ($rn << 5) | $rd);
+}
+
+sub write_msub_rrrr($$$$)
+{
+ my ($rd, $rn, $rm, $ra) = @_;
+ die "write_msub: invalid operation for this arch.\n" if (!$is_aarch64);
+
+ insn32(0x9b008000 | ($rm << 16) | ($ra << 10) | ($rn << 5) | $rd);
+}
+
+sub write_mul_rrr($$$)
+{
+ my ($rd, $rn, $rm) = @_;
+ write_madd_rrrr($rd, $rn, $rm, 31);
+}
+
# write random fp value of passed precision (1=single, 2=double, 4=quad)
sub write_random_fpreg_var($)
{
@@ -767,6 +813,86 @@ sub reg_plus_imm($$@)
return $base;
}
+sub reg_plus_imm_pl($$@)
+{
+ # Handle reg + immediate addressing mode
+ my ($base, $imm, @trashed) = @_;
+ if ($imm == 0) {
+ return reg($base, @trashed);
+ }
+ write_get_offset();
+
+ # Now r0 is the address we want to do the access to,
+ # so set the basereg by doing the inverse of the
+ # addressing mode calculation, ie base = r0 - imm
+ #
+ # Note that addpl has a 6-bit immediate, but ldr has a 9-bit
+ # immediate, so we need to be able to support larger immediates.
+
+ if (-$imm >= -32 && -$imm <= 31) {
+ write_addpl_rri($base, 0, -$imm);
+ } else {
+ # We borrow r1 and r2 as a temporaries (not a problem
+ # as long as we don't leave anything in a register
+ # which depends on the location of the memory block)
+ write_mov_ri(1, 0);
+ write_mov_ri(2, $imm);
+ write_addpl_rri(1, 1, 1);
+ write_msub_rrrr($base, 1, 2, 0);
+ }
+ if (grep $_ == $base, @trashed) {
+ return -1;
+ }
+ return $base;
+}
+
+sub reg_plus_imm_vl($$@)
+{
+ # The usual address formulation is
+ # elements = VL DIV esize
+ # mbytes = msize DIV 8
+ # addr = base + imm * elements * mbytes
+ # Here we compute
+ # scale = log2(esize / msize)
+ # base + (imm * VL) >> scale
+ my ($base, $imm, $scale, @trashed) = @_;
+ if ($imm == 0) {
+ return reg($base, @trashed);
+ }
+ write_get_offset();
+
+ # Now r0 is the address we want to do the access to,
+ # so set the basereg by doing the inverse of the
+ # addressing mode calculation, ie base = r0 - imm
+ #
+ # Note that rdvl/addvl have a 6-bit immediate, but ldr has a 9-bit
+ # immediate, so we need to be able to support larger immediates.
+
+ use integer;
+ my $mul = 1 << $scale;
+ my $imm_div = $imm / $mul;
+
+ if ($imm == $imm_div * $mul && -$imm_div >= -32 && -$imm_div <= 31) {
+ write_addvl_rri($base, 0, -$imm_div);
+ } elsif ($imm >= -32 && $imm <= 31) {
+ write_rdvl_ri(1, $imm);
+ write_sub_rrrs($base, 0, 1, $SHIFT_ASR, $scale);
+ } else {
+ write_rdvl_ri(1, 1);
+ write_mov_ri(2, $imm);
+ if ($scale == 0) {
+ write_msub_rrrr($base, 1, 2, 0);
+ } else {
+ write_mul_rrr(1, 1, 2);
+ write_sub_rrrs($base, 0, 1, $SHIFT_ASR, $scale);
+ }
+ }
+ if (grep $_ == $base, @trashed) {
+ return -1;
+ }
+ return $base;
+}
+
sub reg_minus_imm($$@)
{
my ($base, $imm, @trashed) = @_;
--
2.17.1
next prev parent reply other threads:[~2018-06-13 12:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 12:55 [Qemu-devel] [RISU PATCH v3 00/22] SVE support and various misc fixes Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 01/22] risu_reginfo_aarch64: include signal.h for FPSIMD_MAGIC Alex Bennée
2018-06-14 5:40 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 02/22] comms: include header for writev Alex Bennée
2018-06-14 5:41 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 03/22] build-all-arches: expand the range of docker images Alex Bennée
2018-06-14 5:42 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 04/22] build-all-arches: do a distclean $(SRC) configured Alex Bennée
2018-06-14 5:43 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 05/22] risu: add zlib indication to help text Alex Bennée
2018-06-14 5:47 ` Richard Henderson
2018-06-14 8:34 ` Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 06/22] Makefile: include risu_reginfo_$(ARCH) in HDRS Alex Bennée
2018-06-14 5:50 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 07/22] risugen: add --sve support Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 08/22] risugen: Initialize sve predicates with random data Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 09/22] risugen: use fewer insns for aarch64 immediate load Alex Bennée
2018-06-13 12:55 ` Alex Bennée [this message]
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 11/22] risugen: add dtype_msz address helper Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 12/22] contrib/generate_all.sh: allow passing of arguments to risugen Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 13/22] risu: move optional args to each architecture Alex Bennée
2018-06-14 20:20 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 14/22] risu: add process_arch_opt Alex Bennée
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 15/22] risu_reginfo_aarch64: drop stray ; Alex Bennée
2018-06-14 20:23 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 16/22] risu_reginfo_aarch64: unionify VFP regs Alex Bennée
2018-06-14 20:24 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 17/22] risu_reginfo: introduce reginfo_size() Alex Bennée
2018-06-14 20:25 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 18/22] risu_reginfo_aarch64: left justify regnums and drop masks Alex Bennée
2018-06-14 20:26 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 19/22] risu_reginfo_aarch64: add support for copying SVE register state Alex Bennée
2018-06-14 20:33 ` Richard Henderson
2018-06-13 12:55 ` [Qemu-devel] [RISU PATCH v3 20/22] risu_reginfo_aarch64: add SVE support to reginfo_dump_mismatch Alex Bennée
2018-06-14 20:42 ` Richard Henderson
2018-06-13 12:56 ` [Qemu-devel] [RISU PATCH v3 21/22] risu_reginfo_aarch64: limit SVE_VQ_MAX to current architecture Alex Bennée
2018-06-13 12:56 ` [Qemu-devel] [RISU PATCH v3 22/22] risu_reginfo_aarch64: handle variable VQ Alex Bennée
2018-06-14 20:50 ` 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=20180613125601.14371-11-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).