All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Add microMIPS MSA support.
@ 2014-04-11 14:58 Steven J. Hill
  2014-04-13  8:13 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Steven J. Hill @ 2014-04-11 14:58 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

From: "Steven J. Hill" <Steven.Hill@imgtec.com>

This patch adds support for the microMIPS implementation
of the MSA instructions.

Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com>
Reviewed-by: Paul Burton <Paul.Burton@imgtec.com>
---
 arch/mips/include/asm/asmmacro.h | 35 +++++++++++++++++++++++++++++++++++
 arch/mips/include/asm/msa.h      | 18 ++++++++++++++----
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
index b464b8b..30d1ac3 100644
--- a/arch/mips/include/asm/asmmacro.h
+++ b/arch/mips/include/asm/asmmacro.h
@@ -273,7 +273,12 @@
 	.macro	cfcmsa	rd, cs
 	.set	push
 	.set	noat
+#ifdef CONFIG_CPU_MICROMIPS
+	.insn
+	.word	0x587e0056 | (\cs << 11)
+#else
 	.word	0x787e0059 | (\cs << 11)
+#endif
 	move	\rd, $1
 	.set	pop
 	.endm
@@ -282,7 +287,11 @@
 	.set	push
 	.set	noat
 	move	$1, \rs
+#ifdef CONFIG_CPU_MICROMIPS
+	.word	0x583e0816 | (\cd << 6)
+#else
 	.word	0x783e0819 | (\cd << 6)
+#endif
 	.set	pop
 	.endm
 
@@ -290,7 +299,11 @@
 	.set	push
 	.set	noat
 	add	$1, \base, \off
+#ifdef CONFIG_CPU_MICROMIPS
+	.word	0x5800083f | (\wd << 6)
+#else
 	.word	0x78000823 | (\wd << 6)
+#endif
 	.set	pop
 	.endm
 
@@ -298,14 +311,23 @@
 	.set	push
 	.set	noat
 	add	$1, \base, \off
+#ifdef CONFIG_CPU_MICROMIPS
+	.word	0x5800083f | (\wd << 6)
+#else
 	.word	0x78000827 | (\wd << 6)
+#endif
 	.set	pop
 	.endm
 
 	.macro	copy_u_w	rd, ws, n
 	.set	push
 	.set	noat
+#ifdef CONFIG_CPU_MICROMIPS
+	.insn
+	.word	0x58f00056 | (\n << 16) | (\ws << 11)
+#else
 	.word	0x78f00059 | (\n << 16) | (\ws << 11)
+#endif
 	/* move triggers an assembler bug... */
 	or	\rd, $1, zero
 	.set	pop
@@ -314,7 +336,12 @@
 	.macro	copy_u_d	rd, ws, n
 	.set	push
 	.set	noat
+#ifdef CONFIG_CPU_MICROMIPS
+	.insn
+	.word	0x58f80056 | (\n << 16) | (\ws << 11)
+#else
 	.word	0x78f80059 | (\n << 16) | (\ws << 11)
+#endif
 	/* move triggers an assembler bug... */
 	or	\rd, $1, zero
 	.set	pop
@@ -325,7 +352,11 @@
 	.set	noat
 	/* move triggers an assembler bug... */
 	or	$1, \rs, zero
+#ifdef CONFIG_CPU_MICROMIPS
+	.word	0x59300816 | (\n << 16) | (\wd << 6)
+#else
 	.word	0x79300819 | (\n << 16) | (\wd << 6)
+#endif
 	.set	pop
 	.endm
 
@@ -334,7 +365,11 @@
 	.set	noat
 	/* move triggers an assembler bug... */
 	or	$1, \rs, zero
+#ifdef CONFIG_CPU_MICROMIPS
+	.word	0x59380816 | (\n << 16) | (\wd << 6)
+#else
 	.word	0x79380819 | (\n << 16) | (\wd << 6)
+#endif
 	.set	pop
 	.endm
 #endif
diff --git a/arch/mips/include/asm/msa.h b/arch/mips/include/asm/msa.h
index a2aba6c..fd76b3b 100644
--- a/arch/mips/include/asm/msa.h
+++ b/arch/mips/include/asm/msa.h
@@ -96,6 +96,13 @@ static inline void write_msa_##name(unsigned int val)		\
  * allow compilation with toolchains that do not support MSA. Once all
  * toolchains in use support MSA these can be removed.
  */
+#ifdef CONFIG_CPU_MICROMIPS
+#define CFCMSA_INSN	0x587e0056
+#define CTCMSA_INSN	0x583e0816
+#else
+#define CFCMSA_INSN	0x787e0059
+#define CTCMSA_INSN	0x783e0819
+#endif
 
 #define __BUILD_MSA_CTL_REG(name, cs)				\
 static inline unsigned int read_msa_##name(void)		\
@@ -104,10 +111,12 @@ static inline unsigned int read_msa_##name(void)		\
 	__asm__ __volatile__(					\
 	"	.set	push\n"					\
 	"	.set	noat\n"					\
-	"	.word	0x787e0059 | (" #cs " << 11)\n"		\
+	"	.insn\n"					\
+	"	.word	%1 | (" #cs " << 11)\n"			\
 	"	move	%0, $1\n"				\
 	"	.set	pop\n"					\
-	: "=r"(reg));						\
+	: "=r"(reg)						\
+	: "i"(CFCMSA_INSN));					\
 	return reg;						\
 }								\
 								\
@@ -117,9 +126,10 @@ static inline void write_msa_##name(unsigned int val)		\
 	"	.set	push\n"					\
 	"	.set	noat\n"					\
 	"	move	$1, %0\n"				\
-	"	.word	0x783e0819 | (" #cs " << 6)\n"		\
+	"	.insn\n"					\
+	"	.word	%1 | (" #cs " << 6)\n"			\
 	"	.set	pop\n"					\
-	: : "r"(val));						\
+	: : "r"(val), "i"(CTCMSA_INSN));			\
 }
 
 #endif /* !TOOLCHAIN_SUPPORTS_MSA */
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: Add microMIPS MSA support.
  2014-04-11 14:58 [PATCH] MIPS: Add microMIPS MSA support Steven J. Hill
@ 2014-04-13  8:13 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2014-04-13  8:13 UTC (permalink / raw)
  To: Steven J. Hill; +Cc: Linux MIPS Mailing List, Ralf Baechle

Hi Stephen,

On Fri, Apr 11, 2014 at 4:58 PM, Steven J. Hill <Steven.Hill@imgtec.com> wrote:
> --- a/arch/mips/include/asm/asmmacro.h
> +++ b/arch/mips/include/asm/asmmacro.h
> @@ -273,7 +273,12 @@
>         .macro  cfcmsa  rd, cs
>         .set    push
>         .set    noat
> +#ifdef CONFIG_CPU_MICROMIPS
> +       .insn
> +       .word   0x587e0056 | (\cs << 11)
> +#else
>         .word   0x787e0059 | (\cs << 11)
> +#endif

Personally, I would like it more if you would use the CFCMSA_INSN
macro in the code above. This allows to get rid of all but one #ifdef,
and avoids mistakes in the parameter parts (e.g. "| (\cs << 11)").

> diff --git a/arch/mips/include/asm/msa.h b/arch/mips/include/asm/msa.h
> index a2aba6c..fd76b3b 100644
> --- a/arch/mips/include/asm/msa.h
> +++ b/arch/mips/include/asm/msa.h
> @@ -96,6 +96,13 @@ static inline void write_msa_##name(unsigned int val)                \
>   * allow compilation with toolchains that do not support MSA. Once all
>   * toolchains in use support MSA these can be removed.
>   */
> +#ifdef CONFIG_CPU_MICROMIPS
> +#define CFCMSA_INSN    0x587e0056
> +#define CTCMSA_INSN    0x583e0816
> +#else
> +#define CFCMSA_INSN    0x787e0059
> +#define CTCMSA_INSN    0x783e0819
> +#endif

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-13  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 14:58 [PATCH] MIPS: Add microMIPS MSA support Steven J. Hill
2014-04-13  8:13 ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.