This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, microblaze, gas, opcodes] Add support for mbar and sleep insns


This patch is based on a patch from Kishore <kkatna@xilinx.com>
to add mbar opcode.

mbar ensures outstanding memory access on memory interfaces are completed
before any subsequent instructions are executed.

Added mnemonic 'sleep' instruction for 'mbar 16'

Include mbar and sleep in allinsn.{s,d} for microblaze testsuite.



binutils/opcodes/Changelog

 2012-11-08  David Holsgrove  <david.holsgrove@xilinx.com>

          * microblaze-opc.h: Define new instruction type INST_TYPE_IMM5,
            update OPCODE_MASK_H13S,
            add OPCODE_MASK_HN, define MIN_IMM5 / MAX_IMM5,
            and increase MAX_OPCODES.
            (op_code_struct):  add mbar and sleep
          * microblaze-opcm.h (microblaze_instr): add mbar
            Define IMM_MBAR and IMM5_MBAR_MASK
          * microblaze-dis.c: Add get_field_imm5_mbar
            (print_insn_microblaze): Add support for INST_TYPE_IMM5 and
            INST_TYPE_NONE

binutils/gas/Changelog

 2012-11-08  David Holsgrove  <david.holsgrove@xilinx.com>

          * config/tc-microblaze.c (md_assemble): Add support for
            INST_TYPE_IMM5

binutils/gas/testsuite/Changelog

 2012-11-08  David Holsgrove  <david.holsgrove@xilinx.com>

          * gas/microblaze/allinsn.s: Add mbar and sleep
          * gas/microblaze/allinsn.d: Likewise

From 637e5b28569a8d5a814e4aa5f9f70a26be5552e0 Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Date: Wed, 2 Nov 2011 23:04:44 +0100
Subject: [PATCH] opcodes/ * config/tc-microblaze.c: Add support for mbar and sleep insns

This patch is based on a patch from Kishore <kkatna@xilinx.com>
to add mbar opcode.

mbar ensures outstanding memory access on memory interfaces are completed
before any subsequent instructions are executed.

Added mnemonic 'sleep' instruction for 'mbar 16'

Include mbar and sleep in gas/testsuite coverage for microblaze

Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
---
 gas/config/tc-microblaze.c             |   18 ++++++++++++++++++
 gas/testsuite/gas/microblaze/allinsn.d |    6 ++++++
 gas/testsuite/gas/microblaze/allinsn.s |    8 ++++++++
 opcodes/microblaze-dis.c               |   16 ++++++++++++++++
 opcodes/microblaze-opc.h               |   16 +++++++++++++---
 opcodes/microblaze-opcm.h              |    6 +++++-
 6 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index 04dfa1e..b71383b 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -1605,6 +1605,24 @@ md_assemble (char * str)
       output = frag_more (isize);
       break;
 
+    case INST_TYPE_IMM5:
+      if (strcmp(op_end, ""))
+        op_end = parse_imm (op_end + 1, & exp, MIN_IMM5, MAX_IMM5);
+      else
+        as_fatal(_("Error in statement syntax"));
+      if (exp.X_op != O_constant) {
+        as_warn(_("Symbol used as immediate for mbar instruction"));
+      } else {
+        output = frag_more (isize);
+        immed = exp.X_add_number;
+      }
+      if (immed != (immed % 32)) {
+        as_warn(_("Immediate value for mbar > 32. using <value %% 32>"));
+        immed = immed % 32;
+      }
+      inst |= (immed << IMM_MBAR);
+      break;
+
     default:
       as_fatal (_("unimplemented opcode \"%s\""), name);
     }
diff --git a/gas/testsuite/gas/microblaze/allinsn.d b/gas/testsuite/gas/microblaze/allinsn.d
index c7854f1..ec14020 100644
--- a/gas/testsuite/gas/microblaze/allinsn.d
+++ b/gas/testsuite/gas/microblaze/allinsn.d
@@ -25,3 +25,9 @@ Disassembly of section .text:
 
 00000018 <clz>:
   18:	900000e0 	clz	r0, r0
+
+0000001c <mbar>:
+  1c:	b8420004 	mbar	2
+
+00000020 <sleep>:
+  20:	ba020004 	sleep
diff --git a/gas/testsuite/gas/microblaze/allinsn.s b/gas/testsuite/gas/microblaze/allinsn.s
index 0e4271d..582da17 100644
--- a/gas/testsuite/gas/microblaze/allinsn.s
+++ b/gas/testsuite/gas/microblaze/allinsn.s
@@ -28,4 +28,12 @@ swr:
     .global clz
 clz:
     clz r0,r0
+    .text
+    .global mbar
+mbar:
+    mbar 2
+    .text
+    .global sleep
+sleep:
+    sleep
 
diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
index bdbf831..e204e36 100644
--- a/opcodes/microblaze-dis.c
+++ b/opcodes/microblaze-dis.c
@@ -65,6 +65,15 @@ get_field_imm5 (long instr)
 }
 
 static char *
+get_field_imm5_mbar (long instr)
+{
+  char tmpstr[25];
+
+  sprintf(tmpstr, "%d", (short)((instr & IMM5_MBAR_MASK) >> IMM_MBAR));
+  return(strdup(tmpstr));
+}
+
+static char *
 get_field_rfsl (long instr)
 {
   char tmpstr[25];
@@ -374,6 +383,13 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
 	case INST_TYPE_RD_IMM15:
 	  print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_imm15 (inst));
 	  break;
+        /* For mbar insn.  */
+        case INST_TYPE_IMM5:
+          print_func (stream, "\t%s", get_field_imm5_mbar (inst));
+          break;
+        /* For mbar 16 or sleep insn.  */
+        case INST_TYPE_NONE:
+          break;
 	/* For tuqula instruction */
 	case INST_TYPE_RD:
 	  print_func (stream, "\t%s", get_field_rd (inst));
diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
index 132b951..0447fc5 100644
--- a/opcodes/microblaze-opc.h
+++ b/opcodes/microblaze-opc.h
@@ -56,6 +56,9 @@
 /* New insn type for t*put.  */
 #define INST_TYPE_RFSL  19
 
+/* For mbar.  */
+#define INST_TYPE_IMM5 20
+
 #define INST_TYPE_NONE 25
 
 
@@ -76,8 +79,8 @@
 #define OPCODE_MASK_H2  0xFC1F0000  /* High 6 and bits 20-16.  */
 #define OPCODE_MASK_H12 0xFFFF0000  /* High 16.  */
 #define OPCODE_MASK_H4  0xFC0007FF  /* High 6 and low 11 bits.  */
-#define OPCODE_MASK_H13S 0xFFE0EFF0 /* High 11 and 15:1 bits and last 
-				       nibble of last byte for spr.  */
+#define OPCODE_MASK_H13S 0xFFE0E7F0 /* High 11 16:18 21:27 bits, 19:20 bits
+                                       and last nibble of last byte for spr.  */
 #define OPCODE_MASK_H23S 0xFC1FC000 /* High 6, 20-16 and 15:1 bits and last 
 				       nibble of last byte for spr.  */
 #define OPCODE_MASK_H34 0xFC00FFFF  /* High 6 and low 16 bits.  */
@@ -92,11 +95,13 @@
 
 /* New Mask for msrset, msrclr insns.  */
 #define OPCODE_MASK_H23N  0xFC1F8000 /* High 6 and bits 11 - 16.  */
+/* Mask for mbar insn.  */
+#define OPCODE_MASK_HN 0xFF020004 /* High 16 bits and bits 14, 29.  */
 
 #define DELAY_SLOT 1
 #define NO_DELAY_SLOT 0
 
-#define MAX_OPCODES 285
+#define MAX_OPCODES 287
 
 struct op_code_struct
 {
@@ -395,6 +400,8 @@ struct op_code_struct
   {"necaputd",  INST_TYPE_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x4C000760, OPCODE_MASK_H34C, necaputd,  anyware_inst },
   {"tnecaputd", INST_TYPE_R2,    INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x4C0007E0, OPCODE_MASK_H34C, tnecaputd, anyware_inst },
   {"clz",       INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E0, OPCODE_MASK_H34,  clz,       special_inst },
+  {"mbar",      INST_TYPE_IMM5,  INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8020004, OPCODE_MASK_HN,   mbar,      special_inst },
+  {"sleep",     INST_TYPE_NONE,  INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBA020004, OPCODE_MASK_HN,   invalid_inst, special_inst }, /* translates to mbar 16.  */
   {"", 0, 0, 0, 0, 0, 0, 0, 0},
 };
 
@@ -412,5 +419,8 @@ char pvr_register_prefix[] = "rpvr";
 #define MIN_IMM15 ((int) 0x0000)
 #define MAX_IMM15 ((int) 0x7fff)
 
+#define MIN_IMM5  ((int) 0x00000000)
+#define MAX_IMM5  ((int) 0x0000001f)
+
 #endif /* MICROBLAZE_OPC */
 
diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
index 661d836..7b8d20b 100644
--- a/opcodes/microblaze-opcm.h
+++ b/opcodes/microblaze-opcm.h
@@ -31,7 +31,7 @@ enum microblaze_instr
   idiv, idivu, bsll, bsra, bsrl, get, put, nget, nput, cget, cput,
   ncget, ncput, muli, bslli, bsrai, bsrli, mului, or, and, xor,
   andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16, 
-  wic, wdc, wdcclear, wdcflush, mts, mfs, br, brd,
+  wic, wdc, wdcclear, wdcflush, mts, mfs, mbar, br, brd,
   brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
   bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
   imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
@@ -121,6 +121,7 @@ enum microblaze_instr_type
 #define RA_LOW  16 /* Low bit for RA.  */
 #define RB_LOW  11 /* Low bit for RB.  */
 #define IMM_LOW  0 /* Low bit for immediate.  */
+#define IMM_MBAR 21 /* low bit for mbar instruction.  */
 
 #define RD_MASK 0x03E00000
 #define RA_MASK 0x001F0000
@@ -130,6 +131,9 @@ enum microblaze_instr_type
 /* Imm mask for barrel shifts.  */
 #define IMM5_MASK 0x0000001F
 
+/* Imm mask for mbar.  */
+#define IMM5_MBAR_MASK 0x03E00000
+
 /* FSL imm mask for get, put instructions.  */
 #define  RFSL_MASK 0x000000F
 
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]