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
+7
View File
@@ -32,6 +32,12 @@ func GroundTruthRISCV(path string) (map[string][]byte, error) {
return groundTruthArch(path, "riscv64")
}
// GroundTruthLOONG64 assembles the given .s file with the Go toolchain in
// LoongArch cross-assembly mode (GOARCH=loong64).
func GroundTruthLOONG64(path string) (map[string][]byte, error) {
return groundTruthArch(path, "loong64")
}
func groundTruthArch(path, goarch string) (map[string][]byte, error) {
goroot := runtime.GOROOT()
asmBin := filepath.Join(goroot, "pkg", "tool", runtime.GOOS+"_"+runtime.GOARCH, "asm")
@@ -51,6 +57,7 @@ func groundTruthArch(path, goarch string) (map[string][]byte, error) {
pkg := strings.TrimSuffix(base, ".s")
pkg = strings.TrimSuffix(pkg, "_amd64")
pkg = strings.TrimSuffix(pkg, "_riscv64")
pkg = strings.TrimSuffix(pkg, "_loong64")
cmd := exec.Command(asmBin, "-I", includeDir, "-p", pkg, "-o", objPath, path)
if goarch != "" {