mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
The arith assembly is big enough, and the details that you have to keep in mind are complex enough and varied enough, that it is worth using a Go program to generate the assembly. That way, all the architectures can use the same algorithms, and porting to new architectures will be easier. This is the first of a sequence of CLs to introduce a new mini-compiler for generating the arith assembly, in math/big/internal/asmgen. This CL has the basics of the compiler as well as a couple simple architectures and the generator for addVV/subVV. It does not check in the generated assembly yet. That will happen in a followup CL after the other architectures and generators have been added. Change-Id: Ib704c60fd972fc5690ac04d8fae3712ee2c1a80a Reviewed-on: https://go-review.googlesource.com/c/go/+/664935 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
39 lines
861 B
Go
39 lines
861 B
Go
// Copyright 2025 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package asmgen
|
|
|
|
import (
|
|
"bytes"
|
|
"flag"
|
|
"internal/diff"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
var generateFlag = flag.Bool("generate", false, "generate files")
|
|
|
|
func Test(t *testing.T) {
|
|
t.Skip("assembly not yet installed")
|
|
for _, arch := range arches {
|
|
t.Run(arch.Name, func(t *testing.T) {
|
|
file, data := generate(arch)
|
|
old, err := os.ReadFile("../../" + file)
|
|
if err == nil && bytes.Equal(old, data) {
|
|
return
|
|
}
|
|
if *generateFlag {
|
|
if err := os.WriteFile("../../"+file, data, 0o666); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return
|
|
}
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Fatalf("generated assembly differs:\n%s\n", diff.Diff("../../"+file, old, "regenerated", data))
|
|
})
|
|
}
|
|
}
|