From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 03/38] target/sparc: Rewrite gen_edge
Date: Wed, 5 Jun 2024 10:22:18 -0700 [thread overview]
Message-ID: <20240605172253.356302-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240605172253.356302-1-richard.henderson@linaro.org>
Drop the tables and compute the left and right edges directly.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/translate.c | 98 +++++++++++++++-------------------------
1 file changed, 37 insertions(+), 61 deletions(-)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index dca072888a..00c2a11353 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -3519,11 +3519,10 @@ static bool trans_SDIVX(DisasContext *dc, arg_r_r_ri *a)
}
static bool gen_edge(DisasContext *dc, arg_r_r_r *a,
- int width, bool cc, bool left)
+ int width, bool cc, bool little_endian)
{
- TCGv dst, s1, s2, lo1, lo2;
- uint64_t amask, tabl, tabr;
- int shift, imask, omask;
+ TCGv dst, s1, s2, l, r, t, m;
+ uint64_t amask = address_mask_i(dc, -8);
dst = gen_dest_gpr(dc, a->rd);
s1 = gen_load_gpr(dc, a->rs1);
@@ -3533,75 +3532,52 @@ static bool gen_edge(DisasContext *dc, arg_r_r_r *a,
gen_op_subcc(cpu_cc_N, s1, s2);
}
- /*
- * Theory of operation: there are two tables, left and right (not to
- * be confused with the left and right versions of the opcode). These
- * are indexed by the low 3 bits of the inputs. To make things "easy",
- * these tables are loaded into two constants, TABL and TABR below.
- * The operation index = (input & imask) << shift calculates the index
- * into the constant, while val = (table >> index) & omask calculates
- * the value we're looking for.
- */
+ l = tcg_temp_new();
+ r = tcg_temp_new();
+ t = tcg_temp_new();
+
switch (width) {
case 8:
- imask = 0x7;
- shift = 3;
- omask = 0xff;
- if (left) {
- tabl = 0x80c0e0f0f8fcfeffULL;
- tabr = 0xff7f3f1f0f070301ULL;
- } else {
- tabl = 0x0103070f1f3f7fffULL;
- tabr = 0xfffefcf8f0e0c080ULL;
- }
+ tcg_gen_andi_tl(l, s1, 7);
+ tcg_gen_andi_tl(r, s2, 7);
+ tcg_gen_xori_tl(r, r, 7);
+ m = tcg_constant_tl(0xff);
break;
case 16:
- imask = 0x6;
- shift = 1;
- omask = 0xf;
- if (left) {
- tabl = 0x8cef;
- tabr = 0xf731;
- } else {
- tabl = 0x137f;
- tabr = 0xfec8;
- }
+ tcg_gen_extract_tl(l, s1, 1, 2);
+ tcg_gen_extract_tl(r, s2, 1, 2);
+ tcg_gen_xori_tl(r, r, 3);
+ m = tcg_constant_tl(0xf);
break;
case 32:
- imask = 0x4;
- shift = 0;
- omask = 0x3;
- if (left) {
- tabl = (2 << 2) | 3;
- tabr = (3 << 2) | 1;
- } else {
- tabl = (1 << 2) | 3;
- tabr = (3 << 2) | 2;
- }
+ tcg_gen_extract_tl(l, s1, 2, 1);
+ tcg_gen_extract_tl(r, s2, 2, 1);
+ tcg_gen_xori_tl(r, r, 1);
+ m = tcg_constant_tl(0x3);
break;
default:
abort();
}
- lo1 = tcg_temp_new();
- lo2 = tcg_temp_new();
- tcg_gen_andi_tl(lo1, s1, imask);
- tcg_gen_andi_tl(lo2, s2, imask);
- tcg_gen_shli_tl(lo1, lo1, shift);
- tcg_gen_shli_tl(lo2, lo2, shift);
+ /* Compute Left Edge */
+ if (little_endian) {
+ tcg_gen_shl_tl(l, m, l);
+ tcg_gen_and_tl(l, l, m);
+ } else {
+ tcg_gen_shr_tl(l, m, l);
+ }
+ /* Compute Right Edge */
+ if (little_endian) {
+ tcg_gen_shr_tl(r, m, r);
+ } else {
+ tcg_gen_shl_tl(r, m, r);
+ tcg_gen_and_tl(r, r, m);
+ }
- tcg_gen_shr_tl(lo1, tcg_constant_tl(tabl), lo1);
- tcg_gen_shr_tl(lo2, tcg_constant_tl(tabr), lo2);
- tcg_gen_andi_tl(lo1, lo1, omask);
- tcg_gen_andi_tl(lo2, lo2, omask);
-
- amask = address_mask_i(dc, -8);
- tcg_gen_andi_tl(s1, s1, amask);
- tcg_gen_andi_tl(s2, s2, amask);
-
- /* Compute dst = (s1 == s2 ? lo1 : lo1 & lo2). */
- tcg_gen_and_tl(lo2, lo2, lo1);
- tcg_gen_movcond_tl(TCG_COND_EQ, dst, s1, s2, lo1, lo2);
+ /* Compute dst = (s1 == s2 under amask ? l : l & r) */
+ tcg_gen_xor_tl(t, s1, s2);
+ tcg_gen_and_tl(r, r, l);
+ tcg_gen_movcond_tl(TCG_COND_TSTEQ, dst, t, tcg_constant_tl(amask), r, l);
gen_store_gpr(dc, a->rd, dst);
return advance_pc(dc);
--
2.34.1
next prev parent reply other threads:[~2024-06-05 17:24 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 17:22 [PULL 00/38] sparc + linux-user patch queue Richard Henderson
2024-06-05 17:22 ` [PULL 01/38] linux-user: Add ioctl for BLKBSZSET Richard Henderson
2024-06-05 17:22 ` [PULL 02/38] target/sparc: Fix ARRAY8 Richard Henderson
2024-06-05 17:22 ` Richard Henderson [this message]
2024-06-05 17:22 ` [PULL 04/38] target/sparc: Fix do_dc Richard Henderson
2024-06-05 17:22 ` [PULL 05/38] target/sparc: Fix helper_fmul8ulx16 Richard Henderson
2024-06-05 17:22 ` [PULL 06/38] target/sparc: Perform DFPREG/QFPREG in decodetree Richard Henderson
2024-06-05 17:22 ` [PULL 07/38] target/sparc: Remove gen_dest_fpr_D Richard Henderson
2024-06-05 17:22 ` [PULL 08/38] target/sparc: Remove cpu_fpr[] Richard Henderson
2024-06-05 17:22 ` [PULL 09/38] target/sparc: Use gvec for VIS1 parallel add/sub Richard Henderson
2024-06-05 17:22 ` [PULL 10/38] target/sparc: Implement FMAf extension Richard Henderson
2024-06-05 17:22 ` [PULL 11/38] target/sparc: Add feature bits for VIS 3 Richard Henderson
2024-06-05 17:22 ` [PULL 12/38] target/sparc: Implement ADDXC, ADDXCcc Richard Henderson
2024-06-05 17:22 ` [PULL 13/38] target/sparc: Implement CMASK instructions Richard Henderson
2024-06-05 17:22 ` [PULL 14/38] target/sparc: Implement FCHKSM16 Richard Henderson
2024-06-05 17:22 ` [PULL 15/38] target/sparc: Implement FHADD, FHSUB, FNHADD, FNADD, FNMUL Richard Henderson
2024-06-05 17:22 ` [PULL 16/38] target/sparc: Implement FLCMP Richard Henderson
2024-06-05 17:22 ` [PULL 17/38] target/sparc: Implement FMEAN16 Richard Henderson
2024-06-05 17:22 ` [PULL 18/38] target/sparc: Implement FPADD64, FPSUB64 Richard Henderson
2024-06-05 17:22 ` [PULL 19/38] target/sparc: Implement FPADDS, FPSUBS Richard Henderson
2024-06-05 17:22 ` [PULL 20/38] target/sparc: Implement FPCMPEQ8, FPCMPNE8, FPCMPULE8, FPCMPUGT8 Richard Henderson
2024-06-05 17:22 ` [PULL 21/38] target/sparc: Implement FSLL, FSRL, FSRA, FSLAS Richard Henderson
2024-06-05 17:22 ` [PULL 22/38] target/sparc: Implement LDXEFSR Richard Henderson
2024-06-05 17:22 ` [PULL 23/38] target/sparc: Implement LZCNT Richard Henderson
2024-06-05 17:22 ` [PULL 24/38] target/sparc: Implement MOVsTOw, MOVdTOx, MOVwTOs, MOVxTOd Richard Henderson
2024-06-05 17:22 ` [PULL 25/38] target/sparc: Implement PDISTN Richard Henderson
2024-06-05 17:22 ` [PULL 26/38] target/sparc: Implement UMULXHI Richard Henderson
2024-06-05 17:22 ` [PULL 27/38] target/sparc: Implement XMULX Richard Henderson
2024-06-05 17:22 ` [PULL 28/38] target/sparc: Enable VIS3 feature bit Richard Henderson
2024-06-05 17:22 ` [PULL 29/38] target/sparc: Implement IMA extension Richard Henderson
2024-06-05 17:22 ` [PULL 30/38] target/sparc: Add feature bit for VIS4 Richard Henderson
2024-06-05 17:22 ` [PULL 31/38] target/sparc: Implement FALIGNDATAi Richard Henderson
2024-06-05 17:22 ` [PULL 32/38] target/sparc: Implement 8-bit FPADD, FPADDS, and FPADDUS Richard Henderson
2024-06-05 17:22 ` [PULL 33/38] target/sparc: Implement VIS4 comparisons Richard Henderson
2024-06-05 17:22 ` [PULL 34/38] target/sparc: Implement FPMIN, FPMAX Richard Henderson
2024-06-05 17:22 ` [PULL 35/38] target/sparc: Implement SUBXC, SUBXCcc Richard Henderson
2024-06-05 17:22 ` [PULL 36/38] target/sparc: Implement MWAIT Richard Henderson
2024-06-05 17:22 ` [PULL 37/38] target/sparc: Implement monitor ASIs Richard Henderson
2024-06-05 17:22 ` [PULL 38/38] target/sparc: Enable VIS4 feature bit Richard Henderson
2024-06-05 18:49 ` [PULL 00/38] sparc + linux-user patch queue 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=20240605172253.356302-4-richard.henderson@linaro.org \
--to=richard.henderson@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).