From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: agraf@suse.de, thuth@redhat.com, lvivier@redhat.com,
benh@kernel.crashing.org, qemu-devel@nongnu.org,
qemu-ppc@nongnu.org,
Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 11/64] target-ppc: add cmpeqb instruction
Date: Wed, 7 Sep 2016 20:28:50 +1000 [thread overview]
Message-ID: <1473244183-31510-12-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1473244183-31510-1-git-send-email-david@gibson.dropbear.id.au>
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Search a byte in the stream of 8bytes provided in the register
Suggested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
target-ppc/helper.h | 1 +
target-ppc/int_helper.c | 22 ++++++++++++++++++++++
target-ppc/translate.c | 12 ++++++++++++
3 files changed, 35 insertions(+)
diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 9c79808..9e4bb7b 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -44,6 +44,7 @@ DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl)
DEF_HELPER_FLAGS_2(cmpb, TCG_CALL_NO_RWG_SE, tl, tl, tl)
DEF_HELPER_3(sraw, tl, env, tl, tl)
#if defined(TARGET_PPC64)
+DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl)
DEF_HELPER_FLAGS_1(cntlzd, TCG_CALL_NO_RWG_SE, tl, tl)
DEF_HELPER_FLAGS_1(cnttzd, TCG_CALL_NO_RWG_SE, tl, tl)
DEF_HELPER_FLAGS_1(popcntd, TCG_CALL_NO_RWG_SE, tl, tl)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 02b6df3..15947ad 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -151,6 +151,28 @@ target_ulong helper_cnttzw(target_ulong t)
}
#if defined(TARGET_PPC64)
+/* if x = 0xab, returns 0xababababababababa */
+#define pattern(x) (((x) & 0xff) * (~(target_ulong)0 / 0xff))
+
+/* substract 1 from each byte, and with inverse, check if MSB is set at each
+ * byte.
+ * i.e. ((0x00 - 0x01) & ~(0x00)) & 0x80
+ * (0xFF & 0xFF) & 0x80 = 0x80 (zero found)
+ */
+#define haszero(v) (((v) - pattern(0x01)) & ~(v) & pattern(0x80))
+
+/* When you XOR the pattern and there is a match, that byte will be zero */
+#define hasvalue(x, n) (haszero((x) ^ pattern(n)))
+
+uint32_t helper_cmpeqb(target_ulong ra, target_ulong rb)
+{
+ return hasvalue(rb, ra) ? 1 << CRF_GT : 0;
+}
+
+#undef pattern
+#undef haszero
+#undef hasvalue
+
target_ulong helper_cntlzd(target_ulong t)
{
return clz64(t);
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index b248453..dd2ce58 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -855,6 +855,15 @@ static void gen_cmprb(DisasContext *ctx)
tcg_temp_free_i32(src2hi);
}
+#if defined(TARGET_PPC64)
+/* cmpeqb */
+static void gen_cmpeqb(DisasContext *ctx)
+{
+ gen_helper_cmpeqb(cpu_crf[crfD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
+ cpu_gpr[rB(ctx->opcode)]);
+}
+#endif
+
/* isel (PowerPC 2.03 specification) */
static void gen_isel(DisasContext *ctx)
{
@@ -10045,6 +10054,9 @@ GEN_HANDLER(cmp, 0x1F, 0x00, 0x00, 0x00400000, PPC_INTEGER),
GEN_HANDLER(cmpi, 0x0B, 0xFF, 0xFF, 0x00400000, PPC_INTEGER),
GEN_HANDLER(cmpl, 0x1F, 0x00, 0x01, 0x00400000, PPC_INTEGER),
GEN_HANDLER(cmpli, 0x0A, 0xFF, 0xFF, 0x00400000, PPC_INTEGER),
+#if defined(TARGET_PPC64)
+GEN_HANDLER_E(cmpeqb, 0x1F, 0x00, 0x07, 0x00600000, PPC_NONE, PPC2_ISA300),
+#endif
GEN_HANDLER_E(cmpb, 0x1F, 0x1C, 0x0F, 0x00000001, PPC_NONE, PPC2_ISA205),
GEN_HANDLER_E(cmprb, 0x1F, 0x00, 0x06, 0x00400001, PPC_NONE, PPC2_ISA300),
GEN_HANDLER(isel, 0x1F, 0x0F, 0xFF, 0x00000001, PPC_ISEL),
--
2.7.4
next prev parent reply other threads:[~2016-09-07 10:28 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-07 10:28 [Qemu-devel] [PULL 00/64] ppc-for-2.8 queue 20160907 David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 01/64] xics_kvm: drop extra checking of kernel_xics_fd David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 02/64] hw/ppc: include fdt helper routine in a common file David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 03/64] target-ppc: Introduce Power9 family David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 04/64] target-ppc: Introduce POWER ISA 3.0 flag David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 05/64] target-ppc: adding addpcis instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 06/64] target-ppc: add cmprb instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 07/64] target-ppc: add modulo word operations David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 08/64] target-ppc: add modulo dword operations David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 09/64] target-ppc: add cnttzd[.] instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 10/64] target-ppc: add cnttzw[.] instruction David Gibson
2016-09-07 10:28 ` David Gibson [this message]
2016-09-07 10:28 ` [Qemu-devel] [PULL 12/64] target-ppc: add setb instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 13/64] target-ppc: add maddld instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 14/64] target-ppc: add maddhd and maddhdu instruction David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 15/64] target-ppc: introduce opc4 for Expanded Opcode David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 16/64] ppc: Provide basic raise_exception_* functions David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 17/64] ppc: Move classic fp ops out of translate.c David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 18/64] ppc: Move embedded spe " David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 19/64] ppc: Move DFP " David Gibson
2016-09-07 10:28 ` [Qemu-devel] [PULL 20/64] ppc: Move VMX " David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 21/64] ppc: Move VSX " David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 22/64] ppc: Rename fload_invalid_op_excp to float_invalid_op_excp David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 23/64] ppc: Make float_invalid_op_excp() pass the return address David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 24/64] ppc: Make float_check_status() " David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 25/64] ppc: Don't update the NIP in floating point generated code David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 26/64] ppc: FP exceptions are always precise David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 27/64] ppc: Don't update NIP in lswi/lswx/stswi/stswx David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 28/64] ppc: Don't update NIP in lmw/stmw/icbi David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 29/64] ppc: Make tlb_fill() use new exception helper David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 30/64] ppc: Fix source NIP on SLB related interrupts David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 31/64] ppc: Don't update NIP in DCR access routines David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 32/64] ppc: Don't update NIP in facility unavailable interrupts David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 33/64] ppc: Don't update NIP BookE 2.06 tlbwe David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 34/64] ppc: Don't update NIP on conditional trap instructions David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 35/64] ppc: Don't update NIP if not taking alignment exceptions David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 36/64] ppc: Don't update NIP in dcbz and lscbx David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 37/64] ppc: Make alignment exceptions suck less David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 38/64] ppc: Handle unconditional (always/never) traps at translation time David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 39/64] ppc: Speed up dcbz David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 40/64] ppc: Fix CFAR updates David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 41/64] ppc: Don't set access_type on all load/stores on hash64 David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 42/64] ppc: Use a helper to generate "LE unsupported" alignment interrupts David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 43/64] ppc: load/store multiple and string insns don't do LE David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 44/64] target-ppc: implement branch-less divw[o][.] David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 45/64] target-ppc: implement branch-less divd[o][.] David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 46/64] target-ppc: add dtstsfi[q] instructions David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 47/64] target-ppc: add vabsdu[b, h, w] instructions David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 48/64] target-ppc: add vcmpnez[b, h, w][.] instructions David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 49/64] target-ppc: add vslv instruction David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 50/64] target-ppc: add vsrv instruction David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 51/64] target-ppc: add extswsli[.] instruction David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 52/64] ppc: Rename #include'd .c files to .inc.c David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 53/64] hw/ppc: use error_report instead of fprintf David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 54/64] hw/ppc: add a ppc_create_page_sizes_prop() helper routine David Gibson
2016-09-14 13:59 ` Alex Bennée
2016-09-14 14:33 ` Cédric Le Goater
2016-09-14 14:40 ` Cédric Le Goater
2016-09-07 10:29 ` [Qemu-devel] [PULL 55/64] ppc: Fix macio ESCC legacy mapping David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 56/64] ppc: Fix catching some segfaults in user mode David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 57/64] ppc: Stop dumping state on all exceptions in linux-user David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 58/64] ppc: Don't generate dead code on unconditional branches David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 59/64] ppc: Improve flags for helpers loading/writing the time facilities David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 60/64] ppc: Improve the exception helpers flags David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 61/64] ppc: Improve a few more helper flags David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 62/64] spapr: implement H_CHANGE_LOGICAL_LAN_MAC h_call David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 63/64] tests: Resort check-qtest entries in Makefile.include David Gibson
2016-09-07 10:29 ` [Qemu-devel] [PULL 64/64] tests: Check serial output of firmware boot of some machines David Gibson
2016-09-07 12:02 ` [Qemu-devel] [PULL 00/64] ppc-for-2.8 queue 20160907 no-reply
2016-09-08 11:07 ` Peter Maydell
2016-09-14 14:00 ` Alex Bennée
2016-09-14 14:21 ` Paolo Bonzini
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=1473244183-31510-12-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=lvivier@redhat.com \
--cc=nikunj@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=thuth@redhat.com \
/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).