[PATCH 1/7] opcodes: microblaze: tell bslli, bsrai and bsrli apart

Samuel Price thesamprice@gmail.com
Mon Nov 9 04:08:05 GMT 2026


OPCODE_MASK_H3B, the mask of the immediate barrel shifts, leaves out
bits 21:22 (0x600), the only bits that tell bslli, bsrai and bsrli
apart.  The bit_sequence of bslli and bsrai has bits outside the mask,
so the opcode lookup never matches them, and every immediate barrel
shift disassembles as bsrli.  The simulator and GDB decode through the
same table, so the simulator also runs bslli and bsrai as bsrli.  gas
does not read the mask, and its output does not change.

The mask came in with 2d1777b530d, first released in 2.42.  The new
value, 0xFC00FFE0, fixes bits 16:26, as QEMU's decoder does for these
three instructions.  OPCODE_MASK_H3B has no other users.

The new test gas/microblaze/bshift fails on its bslli and bsrai lines
without the opcodes change.

opcodes/
	* microblaze-opc.h (OPCODE_MASK_H3B): Include bits 21:22.

gas/
	* testsuite/gas/microblaze/bshift.exp: New file.
	* testsuite/gas/microblaze/bshift.s: New file.
	* testsuite/gas/microblaze/bshift.d: New test.

Signed-off-by: Sam Price <thesamprice@gmail.com>
Assisted-by: Claude (Anthropic)
---
 gas/testsuite/gas/microblaze/bshift.d   | 17 +++++++++++++++++
 gas/testsuite/gas/microblaze/bshift.exp | 21 +++++++++++++++++++++
 gas/testsuite/gas/microblaze/bshift.s   | 10 ++++++++++
 opcodes/microblaze-opc.h                |  3 +--
 4 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 gas/testsuite/gas/microblaze/bshift.d
 create mode 100644 gas/testsuite/gas/microblaze/bshift.exp
 create mode 100644 gas/testsuite/gas/microblaze/bshift.s

diff --git a/gas/testsuite/gas/microblaze/bshift.d b/gas/testsuite/gas/microblaze/bshift.d
new file mode 100644
index 00000000000..45b855c0786
--- /dev/null
+++ b/gas/testsuite/gas/microblaze/bshift.d
@@ -0,0 +1,17 @@
+#as:
+#objdump: -d
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+00000000 <.text>:
+   0:	64e4041f 	bslli	r7, r4, 31
+   4:	64e4021f 	bsrai	r7, r4, 31
+   8:	64e4001f 	bsrli	r7, r4, 31
+   c:	64e40403 	bslli	r7, r4, 3
+  10:	64e40203 	bsrai	r7, r4, 3
+  14:	64e40003 	bsrli	r7, r4, 3
+  18:	44e42c00 	bsll	r7, r4, r5
+  1c:	44e42a00 	bsra	r7, r4, r5
+  20:	44e42800 	bsrl	r7, r4, r5
diff --git a/gas/testsuite/gas/microblaze/bshift.exp b/gas/testsuite/gas/microblaze/bshift.exp
new file mode 100644
index 00000000000..259ba14b6f1
--- /dev/null
+++ b/gas/testsuite/gas/microblaze/bshift.exp
@@ -0,0 +1,21 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+# MicroBlaze test for barrel shift disassembly.
+
+if [istarget microblaze*-*-*] {
+    run_dump_test "bshift"
+}
diff --git a/gas/testsuite/gas/microblaze/bshift.s b/gas/testsuite/gas/microblaze/bshift.s
new file mode 100644
index 00000000000..235d3d6f312
--- /dev/null
+++ b/gas/testsuite/gas/microblaze/bshift.s
@@ -0,0 +1,10 @@
+    .text
+    bslli r7, r4, 31
+    bsrai r7, r4, 31
+    bsrli r7, r4, 31
+    bslli r7, r4, 3
+    bsrai r7, r4, 3
+    bsrli r7, r4, 3
+    bsll r7, r4, r5
+    bsra r7, r4, r5
+    bsrl r7, r4, r5
diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
index 849769dbadc..fde7b94e694 100644
--- a/opcodes/microblaze-opc.h
+++ b/opcodes/microblaze-opc.h
@@ -92,8 +92,7 @@
 #define OPCODE_MASK_H124  0xFFFF07FF /* High 16, and low 11 bits.  */
 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits.  */
 #define OPCODE_MASK_H3    0xFC000600 /* High 6 bits and bits 21, 22.  */
-#define OPCODE_MASK_H3B   0xFC00F9E0 /* High 6 bits and bits 16:20 and
-					bits 23:26. */
+#define OPCODE_MASK_H3B   0xFC00FFE0 /* High 6 bits and bits 16:26.  */
 #define OPCODE_MASK_H32   0xFC00FC00 /* High 6 bits and bit 16-21.  */
 #define OPCODE_MASK_H32B  0xFC00F820 /* High 6 bits and bits 16:20 and
 					bit 26 */
-- 
2.39.5 (Apple Git-154)



More information about the Binutils mailing list