opcodes/loongarch: print unrecognized insn words with the .word directive
authorWANG Xuerui <git@xen0n.name>
Thu, 29 Jun 2023 16:35:03 +0000 (00:35 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Fri, 30 Jun 2023 02:18:02 +0000 (10:18 +0800)
For better round-trip fidelity and readability in general.

gas/ChangeLog:

* testsuite/gas/loongarch/uleb128.d: Update test case.
* testsuite/gas/loongarch/raw-insn.d: New test.
* testsuite/gas/loongarch/raw-insn.s: Likewise.

opcodes/ChangeLog:

* loongarch-dis.c (disassemble_one): Print ".word" if !opc.

Signed-off-by: WANG Xuerui <git@xen0n.name>
gas/testsuite/gas/loongarch/raw-insn.d [new file with mode: 0644]
gas/testsuite/gas/loongarch/raw-insn.s [new file with mode: 0644]
gas/testsuite/gas/loongarch/uleb128.d
opcodes/loongarch-dis.c

diff --git a/gas/testsuite/gas/loongarch/raw-insn.d b/gas/testsuite/gas/loongarch/raw-insn.d
new file mode 100644 (file)
index 0000000..64980e4
--- /dev/null
@@ -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 (file)
index 0000000..528b152
--- /dev/null
@@ -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
index df66587b692b7faf77d2b14d4fa918176739d006..ad67ded9e7d320de9e7b9dbcbb5f393d7e2610f7 100644 (file)
@@ -8,29 +8,29 @@
 Disassembly of section .data:
 
 00000000.* <L1-0x5>:
-[      ]+0:[   ]+80030201[     ]+0x80030201
+[      ]+0:[   ]+80030201[     ]+\.word[       ]+0x80030201
 [      ]+3:[   ]+R_LARCH_ADD_ULEB128[  ]+L2
 [      ]+3:[   ]+R_LARCH_SUB_ULEB128[  ]+L1
 [      ]+\.\.\.
 
 0000000000000005[      ]+<L1>:
 [      ]+\.\.\.
-[      ]+81:[  ]+ff040000[     ]+0xff040000
+[      ]+81:[  ]+ff040000[     ]+\.word[       ]+0xff040000
 [      ]+85:[  ]+cacop[        ]+0x1f,[        ]+\$t3,[        ]+1
 
 0000000000000086[      ]+<L2>:
-[      ]+86:[  ]+07060005[     ]+0x07060005
-[      ]+8a:[  ]+0x00008080
+[      ]+86:[  ]+07060005[     ]+\.word[       ]+0x07060005
+[      ]+8a:[  ]+\.word[       ]+0x00008080
 [      ]+8a:[  ]+R_LARCH_ADD_ULEB128[  ]+L4
 [      ]+8a:[  ]+R_LARCH_SUB_ULEB128[  ]+L3
 
 000000000000008d[      ]+<L3>:
 [      ]+\.\.\.
-[      ]+4089:[        ]+ff080000[     ]+0xff080000
-[      ]+408d:[        ]+0x09ffffff
+[      ]+4089:[        ]+ff080000[     ]+\.word[       ]+0xff080000
+[      ]+408d:[        ]+\.word[       ]+0x09ffffff
 
 0000000000004090[      ]+<L4>:
-[      ]+4090:[        ]+09090909[     ]+0x09090909
-[      ]+4094:[        ]+09090909[     ]+0x09090909
-[      ]+4098:[        ]+09090909[     ]+0x09090909
-[      ]+409c:[        ]+09090909[     ]+0x09090909
+[      ]+4090:[        ]+09090909[     ]+\.word[       ]+0x09090909
+[      ]+4094:[        ]+09090909[     ]+\.word[       ]+0x09090909
+[      ]+4098:[        ]+09090909[     ]+\.word[       ]+0x09090909
+[      ]+409c:[        ]+09090909[     ]+\.word[       ]+0x09090909
index c45c4fc617ca898b33cdd10ead040dad0bc58407..8d72519be9f51041c972a6a556c64281cd7404bb 100644 (file)
@@ -259,6 +259,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;
     }