Skip to contentSkip to conversation

MIPS: Add microMIPS MSA support.

PATCH Superseded Steven J. Hill 2 participants 2 messages Apr 11, 2014 – Apr 13, 2014 MIPS

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Add microMIPS MSA support.

From: "Steven J. Hill" <[email protected]>

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

---
 arch/mips/include/asm/asmmacro.h | 35 +++++++++++++++++++++++++++++++++++
 arch/mips/include/asm/msa.h      | 18 ++++++++++++++----
 2 files changed, 49 insertions(+), 4 deletions(-)
arch/mips/include/asm/asmmacro.h +35 -0
index b464b8b..30d1ac3 100644
@@ -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
arch/mips/include/asm/msa.h +14 -4
index a2aba6c..fd76b3b 100644
@@ -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 */
Signature · 1 line
1.8.3.2
#1 lore raw

Hi Stephen,

arch/mips/include/asm/asmmacro.h line 281

Quoted 12 lines · Steven J. Hill
arch/mips/include/asm/asmmacro.h +5 -0
@@ -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)").

Quoted 5 lines
arch/mips/include/asm/msa.h +0 -0
index a2aba6c..fd76b3b 100644

arch/mips/include/asm/msa.h static inline void write_msa_##name(unsigned int val) \ · line 105

Quoted 10 lines
arch/mips/include/asm/msa.h +7 -0
@@ -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 -- [email protected]

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