From: "Philippe Mathieu-Daudé via" <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org
Cc: "Aurelien Jarno" <aurelien@aurel32.net>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
"Pavel Dovgalyuk" <pavel.dovgalyuk@ispras.ru>,
"Pavel Dovgalyuk" <Pavel.Dovgalyuk@ispras.ru>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PULL 03/12] target/mips: implement Octeon-specific arithmetic instructions
Date: Tue, 12 Jul 2022 22:53:38 +0200 [thread overview]
Message-ID: <20220712205347.58372-4-f4bug@amsat.org> (raw)
In-Reply-To: <20220712205347.58372-1-f4bug@amsat.org>
From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
This patch implements several Octeon-specific instructions:
- BADDU
- DMUL
- EXTS/EXTS32
- CINS/CINS32
- POP/DPOP
- SEQ/SEQI
- SNE/SNEI
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <165572673245.167724.17377788816335619000.stgit@pasha-ThinkPad-X280>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
target/mips/tcg/octeon.decode | 26 +++++
target/mips/tcg/octeon_translate.c | 155 +++++++++++++++++++++++++++++
2 files changed, 181 insertions(+)
diff --git a/target/mips/tcg/octeon.decode b/target/mips/tcg/octeon.decode
index 8062715578..8929ad088e 100644
--- a/target/mips/tcg/octeon.decode
+++ b/target/mips/tcg/octeon.decode
@@ -13,3 +13,29 @@
%bbit_p 28:1 16:5
BBIT 11 set:1 . 10 rs:5 ..... offset:16 p=%bbit_p
+
+# Arithmetic
+# BADDU rd, rs, rt
+# DMUL rd, rs, rt
+# EXTS rt, rs, p, lenm1
+# EXTS32 rt, rs, p, lenm1
+# CINS rt, rs, p, lenm1
+# CINS32 rt, rs, p, lenm1
+# DPOP rd, rs
+# POP rd, rs
+# SEQ rd, rs, rt
+# SEQI rt, rs, immediate
+# SNE rd, rs, rt
+# SNEI rt, rs, immediate
+
+@r3 ...... rs:5 rt:5 rd:5 ..... ......
+%bitfield_p 0:1 6:5
+@bitfield ...... rs:5 rt:5 lenm1:5 ..... ..... . p=%bitfield_p
+
+BADDU 011100 ..... ..... ..... 00000 101000 @r3
+DMUL 011100 ..... ..... ..... 00000 000011 @r3
+EXTS 011100 ..... ..... ..... ..... 11101 . @bitfield
+CINS 011100 ..... ..... ..... ..... 11001 . @bitfield
+POP 011100 rs:5 00000 rd:5 00000 10110 dw:1
+SEQNE 011100 rs:5 rt:5 rd:5 00000 10101 ne:1
+SEQNEI 011100 rs:5 rt:5 imm:s10 10111 ne:1
diff --git a/target/mips/tcg/octeon_translate.c b/target/mips/tcg/octeon_translate.c
index 1558f74a8e..6a207d2e7e 100644
--- a/target/mips/tcg/octeon_translate.c
+++ b/target/mips/tcg/octeon_translate.c
@@ -44,3 +44,158 @@ static bool trans_BBIT(DisasContext *ctx, arg_BBIT *a)
tcg_temp_free(t0);
return true;
}
+
+static bool trans_BADDU(DisasContext *ctx, arg_BADDU *a)
+{
+ TCGv t0, t1;
+
+ if (a->rt == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ t1 = tcg_temp_new();
+ gen_load_gpr(t0, a->rs);
+ gen_load_gpr(t1, a->rt);
+
+ tcg_gen_add_tl(t0, t0, t1);
+ tcg_gen_andi_i64(cpu_gpr[a->rd], t0, 0xff);
+
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+
+ return true;
+}
+
+static bool trans_DMUL(DisasContext *ctx, arg_DMUL *a)
+{
+ TCGv t0, t1;
+
+ if (a->rt == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ t1 = tcg_temp_new();
+ gen_load_gpr(t0, a->rs);
+ gen_load_gpr(t1, a->rt);
+
+ tcg_gen_mul_i64(cpu_gpr[a->rd], t0, t1);
+
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+
+ return true;
+}
+
+static bool trans_EXTS(DisasContext *ctx, arg_EXTS *a)
+{
+ TCGv t0;
+
+ if (a->rt == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ gen_load_gpr(t0, a->rs);
+ tcg_gen_sextract_tl(t0, t0, a->p, a->lenm1 + 1);
+ gen_store_gpr(t0, a->rt);
+ tcg_temp_free(t0);
+
+ return true;
+}
+
+static bool trans_CINS(DisasContext *ctx, arg_CINS *a)
+{
+ TCGv t0;
+
+ if (a->rt == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ gen_load_gpr(t0, a->rs);
+ tcg_gen_deposit_z_tl(t0, t0, a->p, a->lenm1 + 1);
+ gen_store_gpr(t0, a->rt);
+ tcg_temp_free(t0);
+
+ return true;
+}
+
+static bool trans_POP(DisasContext *ctx, arg_POP *a)
+{
+ TCGv t0;
+
+ if (a->rd == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ gen_load_gpr(t0, a->rs);
+ if (!a->dw) {
+ tcg_gen_andi_i64(t0, t0, 0xffffffff);
+ }
+ tcg_gen_ctpop_tl(t0, t0);
+ gen_store_gpr(t0, a->rd);
+ tcg_temp_free(t0);
+
+ return true;
+}
+
+static bool trans_SEQNE(DisasContext *ctx, arg_SEQNE *a)
+{
+ TCGv t0, t1;
+
+ if (a->rd == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+ t1 = tcg_temp_new();
+
+ gen_load_gpr(t0, a->rs);
+ gen_load_gpr(t1, a->rt);
+
+ if (a->ne) {
+ tcg_gen_setcond_tl(TCG_COND_NE, cpu_gpr[a->rd], t1, t0);
+ } else {
+ tcg_gen_setcond_tl(TCG_COND_EQ, cpu_gpr[a->rd], t1, t0);
+ }
+
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+
+ return true;
+}
+
+static bool trans_SEQNEI(DisasContext *ctx, arg_SEQNEI *a)
+{
+ TCGv t0;
+
+ if (a->rt == 0) {
+ /* nop */
+ return true;
+ }
+
+ t0 = tcg_temp_new();
+
+ gen_load_gpr(t0, a->rs);
+
+ /* Sign-extend to 64 bit value */
+ target_ulong imm = a->imm;
+ if (a->ne) {
+ tcg_gen_setcondi_tl(TCG_COND_NE, cpu_gpr[a->rt], t0, imm);
+ } else {
+ tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_gpr[a->rt], t0, imm);
+ }
+
+ tcg_temp_free(t0);
+
+ return true;
+}
--
2.36.1
next prev parent reply other threads:[~2022-07-12 20:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 20:53 [PULL 00/12] MIPS patches for 2022-07-12 Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 01/12] target/mips: introduce decodetree structure for Cavium Octeon extension Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 02/12] target/mips: implement Octeon-specific BBIT instructions Philippe Mathieu-Daudé via
2022-07-12 20:53 ` Philippe Mathieu-Daudé via [this message]
2022-07-12 20:53 ` [PULL 04/12] target/mips: introduce Cavium Octeon CPU model Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 05/12] target/mips: Create report_fault for semihosting Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 06/12] target/mips: Drop link syscall from semihosting Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 07/12] target/mips: Use semihosting/syscalls.h Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 08/12] target/mips: Avoid qemu_semihosting_log_out for UHI_plog Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 09/12] target/mips: Use error_report for UHI_assert Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 10/12] semihosting: Remove qemu_semihosting_log_out Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 11/12] target/mips: Simplify UHI_argnlen and UHI_argn Philippe Mathieu-Daudé via
2022-07-12 20:53 ` [PULL 12/12] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING Philippe Mathieu-Daudé via
2022-07-14 8:30 ` [PULL 00/12] MIPS patches for 2022-07-12 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=20220712205347.58372-4-f4bug@amsat.org \
--to=qemu-devel@nongnu.org \
--cc=aleksandar.rikalo@syrmia.com \
--cc=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=f4bug@amsat.org \
--cc=jiaxun.yang@flygoat.com \
--cc=pavel.dovgalyuk@ispras.ru \
--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).