Commit Graph

465 Commits

Author SHA1 Message Date
Michael McLoughlin
6acd6a048d tests: test functions with random signatures (#216)
Adds a test for function signature memory layout by generating functions with
random signatures. This confirms that the size and offsets computed by
`gotypes` agree with `asmdecl`.

Updates #191 #195
2021-10-30 18:22:24 -07:00
Michael McLoughlin
bcbebd5674 build: global Function() and SignatureExpr() (#215)
Exposes a few functions on Context that are not available globally. This
oversight suggests that #33 or #133 would be reasonable. `Signature()` is
currently excluded because it causes a conflict for users who have
dot-imported both `build` and `gotypes`. For example:

18af27c3ce/build/base64/decode_asm.go (L13-L14)
a88a5ae268/asm/asm.go (L6-L7)
2021-10-30 15:05:19 -07:00
Michael McLoughlin
4f7179b08e gotypes,tests: test case for issue #195 (#214)
Adds test cases for the bug in #195, similar to #212.

Updates #195
Updates #191
2021-10-30 13:47:55 -07:00
Michael McLoughlin
7de02518a2 gotypes: fix argument size for signatures without return types (#212)
This fixes a bug in argument size calculation in the case where the function
has no return values. Previously it was padding the argument struct to max
alignment, but this only happens if there are return values following.

Updates #191
2021-10-30 13:32:25 -07:00
Michael McLoughlin
e70c62b254 all: upgrade direct dependencies (#213) 2021-10-30 12:07:23 -07:00
Michael McLoughlin
1d235fb56e buildtags: Format only go:build lines for go 1.18+ (#211)
```
$ ./tmp/testgo161718.sh ./buildtags/ ./printer/
+ go1.16.8 test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
+ go1.17.2 test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
+ gotip test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
```

Updates #183
2021-10-30 00:10:16 -07:00
Michael McLoughlin
c48d61faf6 script: switch to go install for tools (#210) 2021-10-29 01:26:54 -07:00
Michael McLoughlin
9c70781236 all: go 1.17 (#197)
Bump CI Go versions to 1.16 and 1.17.
Update build tags with `go:build` equivalents.
Upgrade asmfmt tool for new `go:build` support.

Updates #183
2021-10-29 01:18:34 -07:00
Michael McLoughlin
79bee1a316 printer: constraints formatting (#209)
Uses `buildtag.Format` to format constraints in the assembly and stub file
printers. This will ensure `// + build` and `//go:build` syntax are used
consistent with the current Go version.

Updates #183
2021-10-29 01:08:02 -07:00
Michael McLoughlin
55d98ccf77 buildtags: go:build support (#208)
Implements formatting of constraints according to the current Go version
supported syntax. This is achieved by delegating to go/format and extracting
out the resulting comments.

Also provides functions to query for constraint syntax support, which are
mainly intended for writing version-dependent tests.

Updates #183
2021-10-29 00:43:49 -07:00
Michael McLoughlin
a5480393fc script: pin golangci-lint install script (#205) 2021-10-27 23:18:45 -07:00
Michael McLoughlin
9a44e522f4 script: switch to install.sh from golangci-lint repo (#203)
The goreleaser script has been deprecated:

goreleaser/godownloader#207
2021-10-27 23:07:44 -07:00
Michael McLoughlin
9c815a0581 tests/thirdparty: fix phoreproject-bls (#204)
This started failing under Go 1.17.2 due to a missing go mod tidy in the
root of the respository.
2021-10-27 23:03:23 -07:00
Michael McLoughlin
5e686673b2 tests/thirdparty: add segmentio/asm (#201)
Adds third-party test for https://github.com/segmentio/asm.

Fixes #200
2021-09-15 23:49:08 -07:00
Michael McLoughlin
8ff8e3b751 tests/thirdparty: fix and run as github workflow (#198)
As part of fixing failing third-party tests, this PR significantly
rearchitects their specification and execution.

Third-party tests are now specified in a much more flexible format allowing
more customization on a per-package level. In addition, third-party tests are
now used to auto-generate a Github Actions workflow to perform the tests in
parallel. This not only gives faster feedback on PRs, but will also allow us
to more quickly narrow down on which packages are failing. An additional
workflow also confirms that local execution of third-party tests is consistent
with the Github Actions version. This workflow only runs when tests/thirdparty
itself is changed.
2021-09-15 23:25:51 -07:00
Michael McLoughlin
b935256fa5 ci: upgrade codecov action (#196)
Upgrades codecov-action in order to fix codecov errors CI, for example:

https://github.com/mmcloughlin/avo/runs/3389170262?check_suite_focus=true#step:10:11

See codecov/codecov-action#322.
2021-08-21 14:56:26 -07:00
Michael McLoughlin
3a219c8d3a ci: github actions hardening (#190)
Restrict permissions of github token. Pin action versions.

Following advice in briansmith/untrusted#50.
2021-04-27 21:42:09 -07:00
Michael McLoughlin
ec9535c905 doc: link to Filippo's live stream in README (#187)
Link to Filippo's live stream of rewriting the filippo.io/edwards25519 assembly with avo.

Reformat the "learn more" links in a list.
2021-04-21 22:03:43 -07:00
Michael McLoughlin
6bad393fdc ci: bump to go 1.16 (#166)
Required updates to the thirdparty test suite due to modules changes in go toolchain.
2021-04-19 14:34:35 -07:00
Klaus Post
f798093d69 tests/thirdparty: update/add packages, fix modules (#186)
Update github.com/klauspost/compress version.

Add github.com/klauspost/reedsolomon and github.com/minio/md5-simd.

Add `-mod=mod` to commands due to golang/go#44129.
2021-04-19 12:38:24 -07:00
Michael McLoughlin
c32f24fb1e pass: de-prioritize base pointer in register allocation (#184)
Updates #156
2021-04-18 19:22:09 -07:00
Michael McLoughlin
f295bde84c pass: ensure frame pointer register is saved (#174)
Currently `avo` uses `BP` as a standard general-purpose register. However, `BP` is used for the frame pointer and should be callee-save. Under some circumstances, the Go assembler will do this automatically, but not always. At the moment `avo` can produce code that clobbers the `BP` register. Since Go 1.16 this code will also fail a new `go vet` check.

This PR provides a (currently sub-optimal) fix for the issue. It introduces an `EnsureBasePointerCalleeSaved` pass which will check if the base pointer is written to by a function, and if so will artificially ensure that the function has a non-zero frame size. This will trigger the Go assembler to automatically save and restore the BP register.

In addition, we update the `asmdecl` tool to `asmvet`, which includes the `framepointer` vet check.

Updates #156
2021-04-18 18:37:56 -07:00
Jeremy Larkin
4592e16ebb operand: allow signed immediates to be matched by IsIMMX (#182)
Many of the instruction functions correctly match the size of immediate values, but they only accept unsigned immediates. This PR fixes the operand check functions for intermediate types to also accept the signed variants.

Fixes #181
2021-04-16 15:12:12 -07:00
Michael McLoughlin
3622eb09b9 pass: support priority in register allocator (#180)
Updates #156
2021-04-11 23:32:52 -07:00
Michael McLoughlin
060ad41ef0 ci: codecov informational mode (#179) 2021-04-11 22:54:05 -07:00
Michael McLoughlin
e9f28cafb8 attr: flag test methods (#177)
Adds a method to the Attribute type to test for each flag in the textflag.h header.
2021-04-11 13:25:13 -07:00
Michael McLoughlin
c5faaae583 attr: generate code from textflag.h (#176) 2021-04-10 23:45:40 -07:00
Michael McLoughlin
e5c9b4e5a6 script: use tools.mod for bootstrap (#175)
Replaces gobin with the preferred tools.mod solution for pinning tool dependencies.

Updates #166
2021-04-10 21:10:42 -07:00
Michael McLoughlin
3f5da8f6e4 all: upgrade direct dependencies (#172) 2021-04-06 23:24:52 -07:00
Michael McLoughlin
8f3c4ea0bf examples: cpu feature checks (#171)
Add necessary feature checks to the dot and geohash examples to prevent illegal instruction errors.

Fixes #170 #153
2021-04-06 22:24:58 -07:00
Josh Bleecher Snyder
599bdd1269 internal/cmd/avogen: write output file even when gofmt fails (#165)
This makes it easier to debug avogen: when you emit invalid syntax, you can inspect the generated file to determine what went wrong, instead of having only gofmt's error to work with.
2021-01-03 19:29:11 -08:00
Michael McLoughlin
039ef47f4f doc: mention #assembly slack channel (#161) 2020-12-16 15:13:06 -08:00
Michael McLoughlin
45c8ae10fd ci: switch to env files (#160)
Switch to env files following the deprecation of set-env and add-path commands.

https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
2020-11-29 17:27:00 -08:00
Michael McLoughlin
5d2f697d26 all: upgrade dependencies (#159)
Upgrade dependencies with:

go get -u ./...
go mod tidy
2020-11-04 23:48:41 -08:00
Michael McLoughlin
fea6accff2 ci: upgrade to go 1.15 (#158) 2020-11-04 23:04:25 -08:00
Luke Champine
443f81d771 build: expose Instruction method on global context (#155) 2020-08-03 14:51:36 -07:00
Michael McLoughlin
4439b6b2c0 build: -pkg flag to specify package name (#150)
Allows override in the case where package name is incorrectly deduced from directory name.

Fixes #68
Fixes #147
2020-05-23 12:07:32 -07:00
Michael McLoughlin
fa88270b07 script: pin tool dependencies
An update to gofumpt caused the lint job to start failing:

https://github.com/mmcloughlin/avo/runs/638734114?check_suite_focus=true#step:7:688

The underlying issue is that the "join parameters" rule added to gofumpt
disagrees with output from go/types. It's possible to fix, but I don't
think it's important enough to deal with right now. Instead I'll pin the
gofumpt dependency to a version before that rule was added.

Pinning tool dependencies is a good idea anyway.
2020-05-03 22:38:06 -07:00
Michael McLoughlin
f891fe8d97 ci: test on go 1.14 (#138)
Add go 1.14 to CI testing. Upgrade golang.org/x/tools dependency to resolve golang/go#37617.
2020-04-25 01:27:57 -07:00
Michael McLoughlin
6df701fe67 tests/thirdparty: lukechampine/us/merkle/blake2b (#140)
Fixes #139
2020-03-02 20:22:53 -08:00
Michael McLoughlin
1859174b62 tests/thirdparty: blake3 (#137)
Adds blake3 to suite of third party tests.

Closes #136
2020-02-26 18:15:39 -08:00
Michael McLoughlin
fb157e1de8 doc: point at go.dev 2020-02-01 15:50:37 -05:00
Michael McLoughlin
d51141dc8f tests/thirdparty: add klauspost/compress/s2 (#131)
Adds @klauspost's S2 implementation to the third party test suite.

The full klauspost/compress tests are slow but we only care about the S2 sub-package. Therefore this PR also adds the option to only run a subset of the package tests, controlled by a "test" parameter in the JSON configuration.

Closes #130
2020-01-28 23:27:12 -05:00
Michael McLoughlin
e089a6c93c tests/fixedbugs: regression test for issue 100 (#129)
Adds a regression test based on klauspost/compress#186. This necessitated some related changes:

* Mark "RET" as a terminal instruction
* printer refactor to maintain compatibility with asmfmt
* Tweaks to other regression tests to ensure they are run correctly in CI

Updates #100 #65 #8
2020-01-27 21:05:33 -08:00
Michael McLoughlin
5a144d9b53 doc: link to gophercon talk 2020-01-27 13:35:45 -08:00
Michael McLoughlin
f40d602170 reg,pass: refactor allocation of aliased registers (#121)
Issue #100 demonstrated that register allocation for aliased registers is
fundamentally broken. The root of the issue is that currently accesses to the
same virtual register with different masks are treated as different registers.
This PR takes a different approach:

* Liveness analysis is masked: we now properly consider which parts of a register are live
* Register allocation produces a mapping from virtual to physical ID, and aliasing is applied later

In addition, a new pass ZeroExtend32BitOutputs accounts for the fact that 32-bit writes in 64-bit mode should actually be treated as 64-bit writes (the result is zero-extended).

Closes #100
2020-01-22 22:50:40 -08:00
Michael McLoughlin
126469f13d pass: VerifyMemOperands (#127)
Introduces a pass to verify memory operands. This is added to a new
Verify pass, that in future could do much more.

Updates #125
2020-01-22 19:59:02 -08:00
Michael McLoughlin
ff7a160610 pass: allow consecutive labels (#123)
Fixes #122
2020-01-19 22:06:52 -08:00
Michael McLoughlin
cde7e9483b pass,printer: display required ISA features (#120)
Fixes #119
2020-01-19 16:45:09 -08:00
Klaus Post
b0ac74488c pass: "instruction should follow a label" info (#115)
Add the label in question to the error message.
2020-01-13 10:52:16 -08:00