github.com/goplus/plan9asm
Plan 9 assembly parser and LLVM IR translator, extracted as an independent module.
github.com/goplus/plan9asm: parser + lowering library.cmd/plan9asm: package/file oriented helper (list,transpile), moved fromllgo-stdlib-opt/chore/plan9asm.cmd/plan9asmll: stdlib-oriented converter/test tool (.s -> .ll, optionalllccompile).
- Library parser/lowering targets:
amd64,arm64. - Tool targets (
cmd/plan9asmll -all-targets):darwin/amd64,darwin/arm64linux/amd64,linux/arm64,linux/386windows/amd64,windows/arm64,windows/386
386currently reuses the x86 lowering path fromamd64backend logic.arm64does not includearm(32-bit). They are separate architectures.
TranslateModulebuilds an in-memoryllvm.Module(github.com/goplus/llvm).Translatekeeps compatibility and returns textual IR from that module.- Root module dependency stays small (
goplus/llvm). golang.org/x/tools/go/packagesis used only incmd/plan9asmllsubmodule.cmd/plan9asmdoes not depend onllgo/internal/buildorllgo/internal/packages.
go test ./...Some tests require local LLVM/Clang tools (llc, clang) and skip when unavailable.
Show flags:
go run -C cmd/plan9asmll . -hList selected asm files only:
go run -C cmd/plan9asmll . -patterns=std -goos=linux -goarch=386 -list-onlyConvert one target (.s -> .ll):
go run -C cmd/plan9asmll . \
-patterns=std \
-goos=linux -goarch=amd64 \
-out _out/plan9asmll/linux-amd64 \
-report /tmp/plan9asmll-linux-amd64.jsonConvert and compile (.ll -> .o) via llc:
go run -C cmd/plan9asmll . \
-all-targets \
-patterns=std \
-compile \
-out _out/plan9asmll/all-targets \
-report /tmp/plan9asmll-all-targets.jsonRun only x86 (386) targets:
go run -C cmd/plan9asmll . \
-patterns=std \
-targets=linux/386,windows/386 \
-compile \
-out _out/plan9asmll/x86 \
-report /tmp/plan9asmll-x86.json- Every asm file is printed with explicit status (
OKorFAIL). - On failure, tool prints:
- the primary reason line,
- unsupported opcode set (if detected),
- per-hit location as file line number + source line.
-keep-going=true(default) continues through all files and summarizes at the end.
- The stdlib asm corpus depends on your local Go toolchain version (
go tool dist list,GOROOTcontent). - If
-compileis enabled,llcmust be discoverable inPATHor set via-llc. - Design notes and migration details are in
doc/llvm-module-migration.md.
List packages/files containing .s:
go run -C cmd/plan9asm . list -goos=linux -goarch=amd64 stdtranspile package mode uses positional patterns (go build/test style) and supports multiple patterns.
Transpile package selected .s files:
go run -C cmd/plan9asm . transpile \
-dir _out/plan9asm/runtime-linux-amd64 \
-goos=linux -goarch=amd64 \
runtimeTranspile one .s file:
go run -C cmd/plan9asm . transpile \
-i /path/to/file.s \
-o /tmp/file.ll \
-goos=linux -goarch=amd64