feat(asm): add LoongArch encoder with ELF and GOOBJ emission

Assisted-by: DeepSeek V4 Pro
This commit is contained in:
2026-08-13 11:24:44 +02:00
parent 2d1176e045
commit 31ee8e7941
24 changed files with 4777 additions and 149 deletions
+11 -4
View File
@@ -33,7 +33,9 @@ gasm profile show basic-block structure of functions
> profiling) in v0.25.0; Phase 4 (interactive debugger — ptrace-based,
> breakpoints, watchpoints, stepping, vector register display, named buffer
> allocation) in v0.27.0; RISC-V encoder (RV64IMAFDC + RVC, ELF emission,
> ground-truth, GOOBJ) in v0.28.0–v0.29.0. See [Roadmap](#roadmap).
> ground-truth, GOOBJ) in v0.28.0–v0.29.0; LoongArch encoder (the full
> instruction set with the MOV expansions, ELF and GOOBJ emission, and
> ground-truth verification) after v0.29.0. See [Roadmap](#roadmap).
## Architecture support
@@ -269,8 +271,13 @@ portable Go implementation every kernel is derived from.
- **RISC-V encoding — done.** RV64IMAFDC instruction set, RVC compression,
MOV pseudo-instruction, SB/global symbols (AUIPC pairs), ELF64 and GOOBJ
emission, and ground-truth verification against `go tool asm`.
- **Remaining:** arm64 and loong64 encoding, plus the same encode-and-verify
treatment for each (instruction tables already generated from the toolchain).
- **LoongArch encoding — done.** The LoongArch64 instruction set with the
MOV pseudo-instruction and its immediate-constant expansions, FP/SP frame
handling, SB/global symbol references (pcalau12i pairs), ELF64 and GOOBJ
emission, and ground-truth verification against `go tool asm` — the emitted
GOOBJ links into a real `go build` for `GOARCH=loong64`.
- **Remaining:** arm64 encoding, plus the same encode-and-verify treatment
(instruction tables already generated from the toolchain).
## Principles
@@ -303,7 +310,7 @@ portable Go implementation every kernel is derived from.
| `arch` | amd64, arm64, riscv64 and loong64 register files and instruction tables. |
| `lint` | Conservative static checks. |
| `format` | A canonical formatter — `gofmt` for assembly. |
| `asm` | The standalone assembler: amd64 and RISC-V encoders, linker, object-file emitters (ELF, GOOBJ). |
| `asm` | The standalone assembler: amd64, RISC-V and LoongArch encoders, linker, object-file emitters (ELF, GOOBJ). |
| `verify` | JIT execution substrate for dynamic analysis, combined ABI+fuzz differential testing (Phase 3). |
| `debug` | Interactive ptrace debugger with GPR/YMM register display and named buffer allocation (Phase 4). |
| `lsp` | Language Server Protocol server. |