MIPS: microMIPS: Add instruction utility macros.
authorSteven J. Hill <[email protected]>
Tue, 5 Feb 2013 22:52:03 +0000 (16:52 -0600)
committerSteven J. Hill <[email protected]>
Wed, 1 May 2013 21:32:47 +0000 (16:32 -0500)
Add two new macros for microMIPS. One checks if an exception was
taken in either microMIPS or classic MIPS mode. The other checks
if a microMIPS instruction is 16-bit or 32-bit in length.

[[email protected]: Removed unnecessary parenthesis as noted by
Sergei Shtylyov <[email protected]>]

Signed-off-by: Steven J. Hill <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Sergei Shtylyov <[email protected]>
Patchwork: https://patchwork.linux-mips.org/patch/4924/
Signed-off-by: Ralf Baechle <[email protected]>
(cherry picked from commit 49df26472338b935fd5781bf94a77a88b148a716)

arch/mips/include/asm/mipsregs.h

index 0da44d422f5b0242380bfc0dde4973b547c1900e..f64e17fa3e96503e639b17f235b1a62fbe4844be 100644 (file)
 
 #ifndef __ASSEMBLY__
 
+/*
+ * Macros for handling the ISA mode bit for microMIPS.
+ */
+#define get_isa16_mode(x)              ((x) & 0x1)
+#define msk_isa16_mode(x)              ((x) & ~0x1)
+#define set_isa16_mode(x)              do { (x) |= 0x1; } while(0)
+
+/*
+ * microMIPS instructions can be 16-bit or 32-bit in length. This
+ * returns a 1 if the instruction is 16-bit and a 0 if 32-bit.
+ */
+static inline int mm_insn_16bit(u16 insn)
+{
+       u16 opcode = (insn >> 10) & 0x7;
+
+       return (opcode >= 1 && opcode <= 3) ? 1 : 0;
+}
+
 /*
  * Functions to access the R10000 performance counters.         These are basically
  * mfc0 and mtc0 instructions from and to coprocessor register with a 5-bit