[v5,6/6] opcodes/loongarch: print unrecognized insn words with the .word directive

Message ID 20230628115103.3440262-7-i.swmail@xen0n.name
State Unresolved
Headers
Series LoongArch: colored disassembly and readability tweaks |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

WANG Xuerui June 28, 2023, 11:51 a.m. UTC
  From: WANG Xuerui <git@xen0n.name>

For better round-trip fidelity and readability in general.
---
 gas/testsuite/gas/loongarch/raw-insn.d | 11 +++++++++++
 gas/testsuite/gas/loongarch/raw-insn.s |  7 +++++++
 opcodes/loongarch-dis.c                |  1 +
 3 files changed, 19 insertions(+)
 create mode 100644 gas/testsuite/gas/loongarch/raw-insn.d
 create mode 100644 gas/testsuite/gas/loongarch/raw-insn.s
  

Patch

diff --git a/gas/testsuite/gas/loongarch/raw-insn.d b/gas/testsuite/gas/loongarch/raw-insn.d
new file mode 100644
index 00000000000..64980e47f7b
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/raw-insn.d
@@ -0,0 +1,11 @@ 
+#as:
+#objdump: -dr
+
+.*:[ 	]+file format .*
+
+
+Disassembly of section .text:
+
+0+000 <target>:
+[ 	]+0:[ 	]+00000000[ 	]+.word[ 	]+0x00000000
+[ 	]+4:[ 	]+feedf00d[ 	]+.word[ 	]+0xfeedf00d
diff --git a/gas/testsuite/gas/loongarch/raw-insn.s b/gas/testsuite/gas/loongarch/raw-insn.s
new file mode 100644
index 00000000000..528b15263ae
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/raw-insn.s
@@ -0,0 +1,7 @@ 
+target:
+	.word 0
+	# Given how the LoongArch encoding space is apparently centrally-
+	# managed and sequentially allocated in chunks of prefixes, it is
+	# highly unlikely this would become a valid LoongArch instruction in
+	# the foreseeable future.
+	.word 0xfeedf00d
diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c
index 10614a5a704..c87ea569791 100644
--- a/opcodes/loongarch-dis.c
+++ b/opcodes/loongarch-dis.c
@@ -250,6 +250,7 @@  disassemble_one (insn_t insn, struct disassemble_info *info)
   if (!opc)
     {
       info->insn_type = dis_noninsn;
+      info->fprintf_styled_func (info->stream, dis_style_assembler_directive, ".word\t\t");
       info->fprintf_styled_func (info->stream, dis_style_immediate, "0x%08x", insn);
       return;
     }