[PATCH v4 6/6] opcodes/loongarch: print unrecognized insn words with the .word directive
WANG Xuerui
i.swmail@xen0n.name
Wed Feb 15 18:03:03 GMT 2023
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
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;
}
--
2.39.1
More information about the Binutils
mailing list