cranelift-filetest: Add support for Wasm-to-CLIF translation filetests (#5412)

This adds support for `.wat` tests in `cranelift-filetest`. The test runner
translates the WAT to Wasm and then uses `cranelift-wasm` to translate the Wasm
to CLIF.

These tests are always precise output tests. The test expectations can be
updated by running tests with the `CRANELIFT_TEST_BLESS=1` environment variable
set, similar to our compile precise output tests. The test's expected output is
contained in the last comment in the test file.

The tests allow for configuring the kinds of heaps used to implement Wasm linear
memory via TOML in a `;;!` comment at the start of the test.

To get ISA and Cranelift flags parsing available in the filetests crate, I had
to move the `parse_sets_and_triple` helper from the `cranelift-tools` binary
crate to the `cranelift-reader` crate, where I think it logically
fits.

Additionally, I had to make some more bits of `cranelift-wasm`'s dummy
environment `pub` so that I could properly wrap and compose it with the
environment used for the `.wat` tests. I don't think this is a big deal, but if
we eventually want to clean this stuff up, we can probably remove the dummy
environments completely, remove `translate_module`, and fold them into these new
test environments and test runner (since Wasmtime isn't using those things
anyways).
This commit is contained in:
Nick Fitzgerald
2022-12-12 11:31:29 -08:00
committed by GitHub
parent 7adf3cacc5
commit f2e1eaa847
19 changed files with 1069 additions and 104 deletions

View File

@@ -154,7 +154,7 @@ cranelift = { path = "cranelift/umbrella", version = "0.92.0" }
winch-codegen = { path = "winch/codegen", version = "=0.3.0" }
target-lexicon = { version = "0.12.3", default-features = false }
target-lexicon = { version = "0.12.3", default-features = false, features = ["std"] }
anyhow = "1.0.22"
wasmparser = "0.95.0"
wat = "1.0.52"