linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH] [POWERPC] Emulate isel (Integer Select) instruction
Date: Mon, 19 Nov 2007 21:36:57 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0711192135460.24923@blarg.am.freescale.net> (raw)

isel (Integer Select) is a new user space instruction in the
PowerISA 2.04 spec.  Not all processors implement it so lets emulate
to ensure code built with isel will run everywhere.

---
 arch/powerpc/kernel/traps.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

In my git tree for 2.6.25.

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 59c464e..cad6484 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -622,6 +622,9 @@ static void parse_fpe(struct pt_regs *regs)
 #define INST_POPCNTB		0x7c0000f4
 #define INST_POPCNTB_MASK	0xfc0007fe

+#define INST_ISEL		0x7c00001e
+#define INST_ISEL_MASK		0xfc00003e
+
 static int emulate_string_inst(struct pt_regs *regs, u32 instword)
 {
 	u8 rT = (instword >> 21) & 0x1f;
@@ -707,6 +710,23 @@ static int emulate_popcntb_inst(struct pt_regs *regs, u32 instword)
 	return 0;
 }

+static int emulate_isel(struct pt_regs *regs, u32 instword)
+{
+	u8 rT = (instword >> 21) & 0x1f;
+	u8 rA = (instword >> 16) & 0x1f;
+	u8 rB = (instword >> 11) & 0x1f;
+	u8 BC = (instword >> 6) & 0x1f;
+	u8 bit;
+	unsigned long tmp;
+
+	tmp = (rA == 0) ? 0 : regs->gpr[rA];
+	bit = (regs->ccr >> (31 - BC)) & 0x1;
+
+	regs->gpr[rT] = bit ? tmp : regs->gpr[rB];
+
+	return 0;
+}
+
 static int emulate_instruction(struct pt_regs *regs)
 {
 	u32 instword;
@@ -749,6 +769,11 @@ static int emulate_instruction(struct pt_regs *regs)
 		return emulate_popcntb_inst(regs, instword);
 	}

+	/* Emulate isel (Integer Select) instruction */
+	if ((instword & INST_ISEL_MASK) == INST_ISEL) {
+		return emulate_isel(regs, instword);
+	}
+
 	return -EINVAL;
 }

-- 
1.5.3.4

             reply	other threads:[~2007-11-20  3:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-20  3:36 Kumar Gala [this message]
2007-11-20 17:54 ` [PATCH] [POWERPC] Emulate isel (Integer Select) instruction Scott Wood
2007-11-20 21:01   ` Kumar Gala
2007-11-21  9:12     ` Benjamin Herrenschmidt
2007-11-21 14:19       ` Kumar Gala
2007-11-21 13:09     ` Geert Uytterhoeven
2007-11-21 14:22       ` Kumar Gala
2007-11-21 14:33         ` Geert Uytterhoeven
2007-11-21 15:34           ` Kumar Gala
2007-11-21 16:50         ` Geert Uytterhoeven
2007-11-21 19:22           ` Kumar Gala
2007-11-21 21:31       ` Paul Mackerras
2007-11-21 21:36       ` Paul Mackerras
2007-11-21 21:41         ` Scott Wood
2007-11-21 21:48           ` Kim Phillips
2007-11-21 21:38       ` Paul Mackerras
2007-11-27 14:56       ` Geert Uytterhoeven
2007-11-27 15:23         ` Olof Johansson
2007-11-28 10:49           ` Geert Uytterhoeven
2007-11-29 15:13             ` Geert Uytterhoeven
2007-12-14  8:12               ` Olof Johansson
2007-12-14  8:08                 ` Kumar Gala
2007-12-14  8:17                   ` Olof Johansson
2007-12-14  8:16                 ` Olof Johansson

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=Pine.LNX.4.64.0711192135460.24923@blarg.am.freescale.net \
    --to=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.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).