docs: add BSD-3-Clause headers to generated files and update CI docs

This commit is contained in:
2026-08-07 22:43:40 +02:00
parent cde7d0f96a
commit 2a27a3a52b
10 changed files with 104 additions and 27 deletions
+9 -2
View File
@@ -68,8 +68,15 @@ See [AGENTS.md](AGENTS.md) for the full style guide. Key points:
## CI ## CI
There is no CI pipeline in this repository. The Definition of Done CI runs on every push to `development` and on pull requests:
(`just build` + `just test` + `just fmt`) is enforced locally.
- **Test** (`test.yml`) — `gofmt` check, `go vet`, `go test -race` and the
80 % coverage gate.
- **Release** (`release.yml`) — cross-compiles release binaries for
linux/{amd64,arm64,riscv64,loong64} on version tags and publishes them.
The Definition of Done (`just build` + `just test` + `just fmt`) must still
pass locally before pushing.
## AI-Assisted Contributions ## AI-Assisted Contributions
+8 -2
View File
@@ -86,7 +86,10 @@ func filterCommon(names []string) []string {
func writeCommon(names []string) error { func writeCommon(names []string) error {
var b strings.Builder var b strings.Builder
b.WriteString("// Code generated by gasm-devkit _gen; DO NOT EDIT.\n") b.WriteString("// Code generated by gasm-devkit _gen; DO NOT EDIT.\n")
b.WriteString("// Source: cmd/internal/obj/util.go from the Go toolchain.\n\n") b.WriteString("// Source: cmd/internal/obj/util.go from the Go toolchain.\n")
b.WriteString("//\n")
b.WriteString("// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)\n")
b.WriteString("// SPDX-License-Identifier: BSD-3-Clause\n\n")
b.WriteString("package arch\n\n") b.WriteString("package arch\n\n")
b.WriteString("// commonGeneratedInstrs is the set of opcodes shared by every architecture\n") b.WriteString("// commonGeneratedInstrs is the set of opcodes shared by every architecture\n")
b.WriteString("// (RET, JMP, NOP, CALL, TEXT, FUNCDATA, PCDATA, …).\n") b.WriteString("// (RET, JMP, NOP, CALL, TEXT, FUNCDATA, PCDATA, …).\n")
@@ -154,7 +157,10 @@ func stringLit(elt ast.Expr) string {
func writeGen(arch, sub string, names []string) error { func writeGen(arch, sub string, names []string) error {
var b strings.Builder var b strings.Builder
b.WriteString("// Code generated by gasm-devkit _gen; DO NOT EDIT.\n") b.WriteString("// Code generated by gasm-devkit _gen; DO NOT EDIT.\n")
b.WriteString("// Source: cmd/internal/obj/" + sub + "/anames.go from the Go toolchain.\n\n") b.WriteString("// Source: cmd/internal/obj/" + sub + "/anames.go from the Go toolchain.\n")
b.WriteString("//\n")
b.WriteString("// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)\n")
b.WriteString("// SPDX-License-Identifier: BSD-3-Clause\n\n")
b.WriteString("package arch\n\n") b.WriteString("package arch\n\n")
b.WriteString("// " + arch + "GeneratedInstrs is the complete set of " + arch + b.WriteString("// " + arch + "GeneratedInstrs is the complete set of " + arch +
" mnemonics accepted by\n// Go's Plan 9 assembler.\n") " mnemonics accepted by\n// Go's Plan 9 assembler.\n")
+3
View File
@@ -1,5 +1,8 @@
// Code generated by gasm-devkit _gen; DO NOT EDIT. // Code generated by gasm-devkit _gen; DO NOT EDIT.
// Source: cmd/internal/obj/x86/anames.go from the Go toolchain. // Source: cmd/internal/obj/x86/anames.go from the Go toolchain.
//
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package arch package arch
+3
View File
@@ -1,5 +1,8 @@
// Code generated by gasm-devkit _gen; DO NOT EDIT. // Code generated by gasm-devkit _gen; DO NOT EDIT.
// Source: cmd/internal/obj/arm64/anames.go from the Go toolchain. // Source: cmd/internal/obj/arm64/anames.go from the Go toolchain.
//
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package arch package arch
+3
View File
@@ -1,5 +1,8 @@
// Code generated by gasm-devkit _gen; DO NOT EDIT. // Code generated by gasm-devkit _gen; DO NOT EDIT.
// Source: cmd/internal/obj/util.go from the Go toolchain. // Source: cmd/internal/obj/util.go from the Go toolchain.
//
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package arch package arch
+3
View File
@@ -1,5 +1,8 @@
// Code generated by gasm-devkit _gen; DO NOT EDIT. // Code generated by gasm-devkit _gen; DO NOT EDIT.
// Source: cmd/internal/obj/loong64/anames.go from the Go toolchain. // Source: cmd/internal/obj/loong64/anames.go from the Go toolchain.
//
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package arch package arch
+3
View File
@@ -1,5 +1,8 @@
// Code generated by gasm-devkit _gen; DO NOT EDIT. // Code generated by gasm-devkit _gen; DO NOT EDIT.
// Source: cmd/internal/obj/riscv/anames.go from the Go toolchain. // Source: cmd/internal/obj/riscv/anames.go from the Go toolchain.
//
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package arch package arch
+23
View File
@@ -0,0 +1,23 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package asm
import (
"fmt"
"sourcedock.dev/petrbalvin/gasm-devkit/ast"
)
// assembleARM64 is a stub. The arm64 (AArch64) instruction encoder is not yet
// implemented — the instruction tables, register files and operand-count
// metadata are in place (package arch), and the lexer, parser, formatter and
// linter already handle arm64 source files.
func assembleARM64(t *ast.Text) ([]byte, map[string]int, []Reloc, error) {
return nil, nil, nil, fmt.Errorf("arm64 instruction encoding is not yet implemented")
}
// AssembleFileARM64 is a stub, returning the same error as assembleARM64.
func AssembleFileARM64(f *ast.File) (*Image, error) {
return nil, fmt.Errorf("arm64 instruction encoding is not yet implemented")
}
+23
View File
@@ -0,0 +1,23 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
package asm
import (
"fmt"
"sourcedock.dev/petrbalvin/gasm-devkit/ast"
)
// assembleLOONG64 is a stub. The loong64 (LoongArch) instruction encoder is
// not yet implemented — the instruction tables, register files and operand-count
// metadata are in place (package arch), and the lexer, parser, formatter and
// linter already handle loong64 source files.
func assembleLOONG64(t *ast.Text) ([]byte, map[string]int, []Reloc, error) {
return nil, nil, nil, fmt.Errorf("loong64 instruction encoding is not yet implemented")
}
// AssembleFileLOONG64 is a stub, returning the same error as assembleLOONG64.
func AssembleFileLOONG64(f *ast.File) (*Image, error) {
return nil, fmt.Errorf("loong64 instruction encoding is not yet implemented")
}
+26 -23
View File
@@ -396,10 +396,10 @@ hover, document symbols, diagnostics and semantic-token highlighting.
func cmdAsm(args []string) int { func cmdAsm(args []string) int {
fs := newCommand("asm", "gasm asm [--format raw|elf|goobj] [-p pkg] [-o out] <file>", ` fs := newCommand("asm", "gasm asm [--format raw|elf|goobj] [-p pkg] [-o out] <file>", `
Assemble FILE (amd64 or riscv64) without the Go toolchain: every TEXT function is Assemble FILE without the Go toolchain: every TEXT function is encoded to
encoded to machine code — scalar, VEX/AVX2 and EVEX/AVX-512 instructions, machine code and printed as a hex dump. Supported architectures: amd64
FP/SP frame mapping, local labels and file-local static symbols (GLOBL/DATA) (including VEX/AVX2 and EVEX/AVX-512) and riscv64 (RV64IMAFDC + RVC);
resolved RIP-relative — and printed as a hex dump. arm64 and loong64 encoding is not yet implemented.
With -o the output is written to a file instead. The --format flag selects With -o the output is written to a file instead. The --format flag selects
what is written: raw (the default) concatenates the functions and the data what is written: raw (the default) concatenates the functions and the data
@@ -419,10 +419,6 @@ requires -p, the package path, and the installed Go toolchain).
} }
path := fs.Arg(0) path := fs.Arg(0)
targetArch := arch.FromFilename(path) targetArch := arch.FromFilename(path)
if targetArch != arch.AMD64 && targetArch != arch.RISCV {
fmt.Fprintln(os.Stderr, "gasm asm: only amd64 and riscv64 are supported")
return 1
}
src, err := readSource(path) src, err := readSource(path)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "gasm:", err) fmt.Fprintln(os.Stderr, "gasm:", err)
@@ -436,12 +432,7 @@ requires -p, the package path, and the installed Go toolchain).
return 1 return 1
} }
var img *asm.Image img, err := assembleFile(path, targetArch, f)
if targetArch == arch.RISCV {
img, err = asm.AssembleFileRISCV(f)
} else {
img, err = asm.AssembleFile(f)
}
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
return 1 return 1
@@ -565,12 +556,12 @@ e.g. --map wideCopyAVX2=wideCopyAVX512 pairs the two regardless of suffix.
} }
// Assemble both files. // Assemble both files.
img1, err := assembleFile(path1) img1, err := assemblePath(path1)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "gasm diff: %s: %v\n", path1, err) fmt.Fprintf(os.Stderr, "gasm diff: %s: %v\n", path1, err)
return 1 return 1
} }
img2, err := assembleFile(path2) img2, err := assemblePath(path2)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "gasm diff: %s: %v\n", path2, err) fmt.Fprintf(os.Stderr, "gasm diff: %s: %v\n", path2, err)
return 1 return 1
@@ -629,8 +620,24 @@ e.g. --map wideCopyAVX2=wideCopyAVX512 pairs the two regardless of suffix.
return 1 return 1
} }
// assembleFile assembles a file and returns the image. // assembleFile assembles a parsed file for the given architecture and returns the image.
func assembleFile(path string) (*asm.Image, error) { func assembleFile(path string, targetArch arch.Arch, f *ast.File) (*asm.Image, error) {
switch targetArch {
case arch.AMD64:
return asm.AssembleFile(f)
case arch.RISCV:
return asm.AssembleFileRISCV(f)
case arch.ARM64:
return asm.AssembleFileARM64(f)
case arch.LOONG64:
return asm.AssembleFileLOONG64(f)
default:
return nil, fmt.Errorf("unsupported architecture %q", targetArch)
}
}
// assemblePath reads, parses and assembles a file (used by cmdDiff).
func assemblePath(path string) (*asm.Image, error) {
src, err := readSource(path) src, err := readSource(path)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -642,11 +649,7 @@ func assembleFile(path string) (*asm.Image, error) {
if len(errs) > 0 { if len(errs) > 0 {
return nil, fmt.Errorf("parse errors") return nil, fmt.Errorf("parse errors")
} }
targetArch := arch.FromFilename(path) return assembleFile(path, arch.FromFilename(path), f)
if targetArch == arch.RISCV {
return asm.AssembleFileRISCV(f)
}
return asm.AssembleFile(f)
} }
// printByteDiff shows the first few byte differences between two code blocks. // printByteDiff shows the first few byte differences between two code blocks.