From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@amazon.com
Subject: [Qemu-devel] [PULL 14/14] tcg-aarch64: Introduce tcg_out_insn_3405
Date: Fri, 14 Mar 2014 13:09:51 -0700 [thread overview]
Message-ID: <1394827791-6518-15-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1394827791-6518-1-git-send-email-rth@twiddle.net>
Cleaning up the implementation of tcg_out_movi at the same time.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Tested-by: Claudio Fontana <claudio.fontana@huawei.com>
---
tcg/aarch64/tcg-target.c | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c
index 23bbe95..661a5af 100644
--- a/tcg/aarch64/tcg-target.c
+++ b/tcg/aarch64/tcg-target.c
@@ -289,6 +289,11 @@ typedef enum {
I3404_ORRI = 0x32000000,
I3404_EORI = 0x52000000,
+ /* Move wide immediate instructions. */
+ I3405_MOVN = 0x12800000,
+ I3405_MOVZ = 0x52800000,
+ I3405_MOVK = 0x72800000,
+
/* Add/subtract shifted register instructions (without a shift). */
I3502_ADD = 0x0b000000,
I3502_ADDS = 0x2b000000,
@@ -443,6 +448,15 @@ static void tcg_out_insn_3403(TCGContext *s, AArch64Insn insn, TCGType ext,
| rn << 5 | rd);
}
+/* This function is used for the Move (wide immediate) instruction group.
+ Note that SHIFT is a full shift count, not the 2 bit HW field. */
+static void tcg_out_insn_3405(TCGContext *s, AArch64Insn insn, TCGType ext,
+ TCGReg rd, uint16_t half, unsigned shift)
+{
+ assert((shift & ~0x30) == 0);
+ tcg_out32(s, insn | ext << 31 | shift << (21 - 4) | half << 5 | rd);
+}
+
/* This function is for both 3.5.2 (Add/Subtract shifted register), for
the rare occasion when we actually want to supply a shift amount. */
static inline void tcg_out_insn_3502S(TCGContext *s, AArch64Insn insn,
@@ -513,38 +527,30 @@ static void tcg_out_movr_sp(TCGContext *s, TCGType ext, TCGReg rd, TCGReg rn)
tcg_out_insn(s, 3401, ADDI, ext, rd, rn, 0);
}
-static inline void tcg_out_movi_aux(TCGContext *s,
- TCGReg rd, uint64_t value)
+static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
+ tcg_target_long value)
{
- uint32_t half, base, shift, movk = 0;
- /* construct halfwords of the immediate with MOVZ/MOVK with LSL */
- /* using MOVZ 0x52800000 | extended reg.. */
- base = (value > 0xffffffff) ? 0xd2800000 : 0x52800000;
+ AArch64Insn insn;
+
+ if (type == TCG_TYPE_I32) {
+ value = (uint32_t)value;
+ }
+
/* count trailing zeros in 16 bit steps, mapping 64 to 0. Emit the
first MOVZ with the half-word immediate skipping the zeros, with a shift
- (LSL) equal to this number. Then morph all next instructions into MOVKs.
+ (LSL) equal to this number. Then all next instructions use MOVKs.
Zero the processed half-word in the value, continue until empty.
We build the final result 16bits at a time with up to 4 instructions,
but do not emit instructions for 16bit zero holes. */
+ insn = I3405_MOVZ;
do {
- shift = ctz64(value) & (63 & -16);
- half = (value >> shift) & 0xffff;
- tcg_out32(s, base | movk | shift << 17 | half << 5 | rd);
- movk = 0x20000000; /* morph next MOVZs into MOVKs */
+ unsigned shift = ctz64(value) & (63 & -16);
+ tcg_out_insn_3405(s, insn, shift >= 32, rd, value >> shift, shift);
value &= ~(0xffffUL << shift);
+ insn = I3405_MOVK;
} while (value);
}
-static inline void tcg_out_movi(TCGContext *s, TCGType type,
- TCGReg rd, tcg_target_long value)
-{
- if (type == TCG_TYPE_I64) {
- tcg_out_movi_aux(s, rd, value);
- } else {
- tcg_out_movi_aux(s, rd, value & 0xffffffff);
- }
-}
-
static inline void tcg_out_ldst_r(TCGContext *s,
enum aarch64_ldst_op_data op_data,
enum aarch64_ldst_op_type op_type,
--
1.8.5.3
next prev parent reply other threads:[~2014-03-14 20:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 20:09 [Qemu-devel] [PULL 00/14] tcg/aarch64 improvements, part 2 Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 01/14] tcg-aarch64: Introduce tcg_out_insn Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 02/14] tcg-aarch64: Convert shift insns to tcg_out_insn Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 03/14] tcg-aarch64: Introduce tcg_out_insn_3401 Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 04/14] tcg-aarch64: Implement mov with tcg_out_insn Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 05/14] tcg-aarch64: Handle constant operands to add, sub, and compare Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 06/14] tcg-aarch64: Handle constant operands to and, or, xor Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 07/14] tcg-aarch64: Support andc, orc, eqv, not, neg Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 08/14] tcg-aarch64: Support movcond Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 09/14] tcg-aarch64: Use tcg_out_insn for setcond Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 10/14] tcg-aarch64: Support deposit Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 11/14] tcg-aarch64: Support add2, sub2 Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 12/14] tcg-aarch64: Support muluh, mulsh Richard Henderson
2014-03-14 20:09 ` [Qemu-devel] [PULL 13/14] tcg-aarch64: Support div, rem Richard Henderson
2014-03-14 20:09 ` Richard Henderson [this message]
2014-03-15 18:24 ` [Qemu-devel] [PULL 00/14] tcg/aarch64 improvements, part 2 Peter Maydell
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=1394827791-6518-15-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=aliguori@amazon.com \
--cc=peter.maydell@linaro.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).