From 43494a30f072962db6192053318ba06bf6b9e431 Mon Sep 17 00:00:00 2001 From: petrbalvin Date: Wed, 7 Oct 2026 21:36:54 +0200 Subject: [PATCH] test(disasm): pin the toolchain's own ADDU16I.D rendering Assisted-by: GLM 5.3 Flash --- disasm/loong64_naming_test.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/disasm/loong64_naming_test.go b/disasm/loong64_naming_test.go index b5f148e..22440b3 100644 --- a/disasm/loong64_naming_test.go +++ b/disasm/loong64_naming_test.go @@ -88,14 +88,30 @@ func TestUnknownNaming(t *testing.T) { } } -// TestUnknownNamingBoundaries pins what stays untouched: the macro helper -// ADDU16I.D has no toolchain spelling (the assembler never takes it as -// input), so its "Unknown" render is the decoder's own and stays. +// TestUnknownNamingBoundaries pins what stays untouched: the ADDU16I.D +// render. The truth of the naming question, established against the live +// toolchain: the assembler spells the family ADDV16 (loong64enc1.s pins +// the rows and go tool asm refuses "ADDU16I.D" as input), while the +// toolchain's own disassembler names the encoding ADDU16I.D with the +// "Unknown" prefix x/arch gives the ops its Plan 9 map lacks, and `go tool +// objdump` prints exactly this text ("Unknown ADDU16I.D $16, R4" for the +// 0x10004084 the loong64enc1.s corpus carries). The render is therefore +// the toolchain's own on both counts, name and prefix, and stays. func TestUnknownNamingBoundaries(t *testing.T) { for _, tt := range []struct { code []byte text string }{ + // loong64enc1.s: ADDV16 $(-32768<<16), R4, R5 // 85000012. + {[]byte{0x85, 0x00, 0x00, 0x12}, "Unknown ADDU16I.D $-32768, R4, R5"}, + // loong64enc1.s: ADDV16 $(0<<16), R4, R5 // 85000010. + {[]byte{0x85, 0x00, 0x00, 0x10}, "Unknown ADDU16I.D $0, R4, R5"}, + // loong64enc1.s: ADDV16 $(8<<16), R4, R5 // 85200010. + {[]byte{0x85, 0x20, 0x00, 0x10}, "Unknown ADDU16I.D $8, R4, R5"}, + // loong64enc1.s: ADDV16 $(32767<<16), R4, R5 // 85fcff11. + {[]byte{0x85, 0xfc, 0xff, 0x11}, "Unknown ADDU16I.D $32767, R4, R5"}, + // loong64enc1.s: ADDV16 $(16<<16), R4 // 84400010; the destination- + // only form collapses in the renderer when rd equals rj. {[]byte{0x84, 0x40, 0x00, 0x10}, "Unknown ADDU16I.D $16, R4"}, {[]byte{0x85, 0x00, 0x17, 0x00}, "MOVW R4, R5"}, } {