Commit Graph

41 Commits

Author SHA1 Message Date
Andrew Brown
c9e8889d47 Update clippy annotation to use latest version (#2375) 2020-11-09 09:24:59 -06:00
Nick Fitzgerald
010e5b9aa8 Make filetest errors report full context (#2207)
* clif-util: do not convert `anyhow::Error`s into strings into `anyhow::Error`s

* filetests: Use the debug formatting of `anyhow::Error`s

This provides the full error context, not just the source error's message.
2020-09-18 13:33:38 -05:00
Nick Fitzgerald
ed38348b22 clif-util: Switch to using structopt for CLI arguments 2020-09-15 09:39:43 -07:00
Nick Fitzgerald
31cbbd1d20 clif-util: Use anyhow::Error for errors instead of String
Also does the same for `cranelift-filetests`.
2020-09-14 18:29:00 -07:00
Nick Fitzgerald
3a6dd832c0 Harvest left-hand side superoptimization candidates.
Given a clif function, harvest all its integer subexpressions, so that they can
be fed into [Souper](https://github.com/google/souper) as candidates for
superoptimization. For some of these candidates, Souper will successfully
synthesize a right-hand side that is equivalent but has lower cost than the
left-hand side. Then, we can combine these left- and right-hand sides into a
complete optimization, and add it to our peephole passes.

To harvest the expression that produced a given value `x`, we do a post-order
traversal of the dataflow graph starting from `x`. As we do this traversal, we
maintain a map from clif values to their translated Souper values. We stop
traversing when we reach anything that can't be translated into Souper IR: a
memory load, a float-to-int conversion, a block parameter, etc. For values
produced by these instructions, we create a Souper `var`, which is an input
variable to the optimization. For instructions that have a direct mapping into
Souper IR, we get the Souper version of each of its operands and then create the
Souper version of the instruction itself. It should now be clear why we do a
post-order traversal: we need an instruction's translated operands in order to
translate the instruction itself. Once this instruction is translated, we update
the clif-to-souper map with this new translation so that any other instruction
that uses this result as an operand has access to the translated value. When the
traversal is complete we return the translation of `x` as the root of left-hand
side candidate.
2020-09-14 16:27:47 -07:00
Nick Fitzgerald
43d2799fa2 clif-util: add the souper-to-peepmatic subcommand (#2200)
This adds a subcommand to the `clif-util` CLI for exposing the Souper->Peepmatic
translation machinery that was introduced in #2192.
2020-09-14 15:19:54 -05:00
penguin-wwy
e535005c74 Remove unused argument for clif-util compile commandline 2020-08-31 10:43:30 +02:00
Andrew Brown
ef122a72d2 clif-util: add option for controlling terminal colors
On @fitzgen's suggestion, this change adds a `--color` option for controlling whether the `clif-util` output prints with ANSI color escape sequences. Only `clif-util wasm ...` currently uses this new option. The option has three variants:
 - `--color auto`, the default, prints colors if the terminal supports them
 - `--color always` prints colors always
 - `--color never` never prints colors
2020-08-03 14:14:12 -07:00
Nick Fitzgerald
d5bdce99c7 Remove executable bit from Rust source files 2020-06-01 15:09:51 -07:00
Andrew Brown
b65bd1c8a2 Add an interpret command to clif-util 2020-05-07 16:51:09 -07:00
Alex Crichton
3a13f79b66 Try to reduce CI times with a Rust *.wat parser (#1332)
This commit moves the cranelift tests and tools from the `wabt` crate on
crates.io (which compiles the wabt C++ codebase) to the `wat` crate on
crates.io which is a Rust parser for the `*.wat` format. This was
motivated by me noticing that release builds on Windows are ~5 minutes
longer than Linux builds, and local timing graphs showed that `wabt-sys`
was by far the longest build step in the build process.

This commit changes the `clif-util` binary where the `--enable-simd`
flag is no longer respected with the text format as input, since the
`wat` crate has no feature gating. This was already sort of not
respected, though, since `--enable-simd` wasn't consulted for binary
inputs which `clif-util` supports as well. If this isn't ok though then
it should be ok to close this PR!
2020-01-10 14:32:16 -08:00
Yury Delendik
2c51341888 Add wasm reference/pointers translation. (#1073) 2019-12-06 17:46:03 -06:00
Nick Fitzgerald
b3cf7f911b clif-util: Make the -t flag work with the wasm subcommand (#1105)
* clif-util: Make the `-t` flag work with the `wasm` subcommand

The presence of the flag was checked in the code, so it was essentially already
supported, but it was not properly configured when constructing
the CLI arguments parser.

* clif-util: also enable the `-c` flag for the `wasm` subcommand

Similar to the parent commit, this functionality is already supported, just a
mix up of the CLI parser construction made it not show up.
2019-10-02 15:41:43 -07:00
Nick Fitzgerald
10be3e4ba8 cranelift-wasm: support multi-value Wasm (#1049)
This commit introduces initial support for multi-value Wasm. Wasm blocks and
calls can now take and return an arbitrary number of values.

The encoding for multi-value blocks means that we need to keep the contents of
the "Types" section around when translating function bodies. To do this, we
introduce a `WasmTypesMap` type that maps the type indices to their parameters
and returns, construct it when parsing the "Types" section, and shepherd it
through a bunch of functions and methods when translating function bodies.
2019-10-02 12:40:35 -07:00
Andrew Brown
2b49b51306 Add flags to allow wasm SIMD instructions (#910)
Add `--enable-simd` flag to `clif-util wasm`
2019-08-27 10:52:06 +02:00
Benjamin Bouvier
67a995f107 [clif-util] Use a simple cfg guard instead of cfg_if for the wasm module; 2019-08-26 17:19:32 +02:00
Andrew Brown
ff3c44385c Add test run to cranelift-filetests to allow executing CLIF (#890)
* Add ability to run CLIF IR using `clif-util run [-v] {file}` and add `test run` to cranelift-filetests to allow executing CLIF

This re-factors the compile/execute parts to a FunctionRunner that is shared between cranelift-filetests and clif-util. CLIF can be now be run using `clif-util run` as well as during `clif-util test` for files with a `test run` header. As before, only functions suffixed with a `run` comment are executed. The `run: fn(...) == ...` expression syntax is left for a subsequent change.
2019-08-21 18:03:09 +02:00
bjorn3
e6e274a3aa Add bugpoint command
Add the command `cargo run --release bugpoint crash.clif 2>/dev/null` to reduce test cases.
2019-08-08 11:40:41 +02:00
Yury Delendik
8f95c51730 Reconstruct locations of the original source variable 2019-05-09 00:35:44 -07:00
Lars T Hansen
141ccb9e9d Add a --disasm option to clif-util wasm and compile (#713)
- Both the `wasm` and `compile` commands get this new subcommand, and it defaults to false.  This means that test runs with `wasm` can request disassembly (the main reason I am doing this) while test runs with `compile` now must request it, this changes current behavior.
- Switch to using context.compile_and_emit directly, and make the reloc and trap printers just accumulate output, not print it.  This allows us to factor the printing code into the disasm module.
2019-03-27 12:57:13 +01:00
Muhammad Mominul Huque
effe6c04e4 Update to Rust 2018 edition (#632)
* initial cargo fix run

* Upgrade cranelift-entity crate

* Upgrade bforest crate

* Upgrade the codegen crate

* Upgrade the faerie crate

* Upgrade the filetests crate

* Upgrade the codegen-meta crate

* Upgrade the frontend crate

* Upgrade the cranelift-module crate

* Upgrade the cranelift-native crate

* Upgrade the cranelift-preopt crate

* Upgrade the cranelift-reader crate

* Upgrade the cranelift-serde crate

* Upgrade the cranelift-simplejit crate

* Upgrade the cranelift or cranelift-umbrella crate

* Upgrade the cranelift-wasm crate

* Upgrade cranelift-tools crate

* Use new import style on remaining files

* run format-all.sh

* run test-all.sh, update Readme and travis ci configuration
fixed an AssertionError also

* Remove deprecated functions
2018-12-26 09:49:05 -08:00
Dan Gohman
5d7ece3d15 Fix clippy warning namespaces. 2018-12-06 20:50:38 -05:00
Dan Gohman
5adab629f2 Update to the rustfmt in rust 1.31, which is now stable. 2018-12-06 16:15:48 -05:00
Dan Gohman
f8754c2cf8 Fix warnings when the "wasm" feature is disabled. 2018-11-28 16:36:59 -08:00
Zach Reizner
f028c53479 Fix incorrect wasm subcommand 'about' text. 2018-11-27 12:05:46 +01:00
Boris-Chengbiao Zhou
b288c6001a Fix all clippy warnings (#564)
* Fix all clippy warnings

* Revert usage of inclusive ranges

* Remove redundant function argument

* Revert use of unavailable pointer methods

* Introduce ContiguousCaseRange
2018-10-22 21:52:35 -07:00
Benjamin Bouvier
af0a239539 Revive the -T aka --time-passes argument to report run times on the CLI; 2018-10-15 16:19:10 -07:00
Bruce Mitchener
c8a65a721c clippy: Remove useless format call. 2018-09-24 09:40:32 -07:00
Bruce Mitchener
e07e159bda filetests: run_passes can take &str, not &String. 2018-09-24 09:40:32 -07:00
Dan Gohman
53a0c6c67f Update to the rustfmt in rust 1.29, which is now stable. 2018-09-13 12:59:25 -07:00
Nick Fitzgerald
ea85018ccf clif-util: fix clif-util pass subcommand arguments
Because of the way that the `pass` subcommand orders its arguments, the
positional "single-file" input cannot be optional with a default value, because
it is followed by required positional arguments. If it were optional, that would
result in argument ambiguity where `clap` cannot tell if the optional positional
argument is supplied, or if the given argument is the next required positional
argument.

Before this commit:

```
$ cargo run --bin clif-util -- pass ./filetests/dce/basic.clif dce
   Compiling cranelift-tools v0.21.0 (file:///Users/fitzgen/src/cranelift)
    Finished dev [unoptimized + debuginfo] target(s) in 4.38s
     Running `target/debug/clif-util pass ./filetests/dce/basic.clif dce`
thread 'main' panicked at 'Found positional argument which is not required with a lower index than a required positional argument: "single-file" index 1', /Users/fitzgen/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.32.0/src/app/parser.rs:612:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```

After this commit:

```
$ cargo run --bin clif-util -- pass ./filetests/dce/basic.clif dce
   Compiling cranelift-filetests v0.21.0 (file:///Users/fitzgen/src/cranelift/lib/filetests)
   Compiling cranelift-tools v0.21.0 (file:///Users/fitzgen/src/cranelift)
    Finished dev [unoptimized + debuginfo] target(s) in 5.96s
     Running `target/debug/clif-util pass ./filetests/dce/basic.clif dce`
1 tests
```
2018-09-11 10:16:14 -07:00
Nick Fitzgerald
90756a8a01 clif-util: Default to reading input files from stdin
Fixes #495
2018-09-06 17:35:26 -07:00
Caroline Cullen
59b83912ba Adds pass command to clif-util. (#487)
* Adds pass command to clif-util.
2018-09-04 16:31:24 -07:00
Grégoire Geis
0e67255f52 Fix error not reported if at least one other error expected. (#485)
* fix error not reported if at least one other error expected.

* Fixed unused extern crate error if wasm feature is not enabled.

* No longer reporting deref cycles multiple times.

* Fix filetest type_check.clif.

* Switched comparison order for perf.

* Fixed isa/riscv/verify-encoding.clif filetest.
2018-08-28 10:33:46 -07:00
Caroline Cullen
0f93ef5cee Changing from docopt to clap for the clif-util #434 (#463)
* Changing from docopt to clap for the clif-util

* Updates to cargo file.

* Remove filecheck subcommand.
2018-08-22 11:25:55 -07:00
Grégoire Geis
e2badb0ad6 Improvements to error reporting (#470)
* Fixed error reporting.

* Fixed compile time error when wasm feature is disabled.

* Fixed valid instructions not being printed in print_function_error.

* Fixed errors print_function_error not writing valid instructions after end.

* Made multiple checks non-fatal.

* verify_global_values is no longer fatal.

* Slightly better formatting of errors in pretty_verifier_error.
2018-08-16 11:34:52 -07:00
Dan Gohman
3b56b2f4fb Fix rustfmt errors. 2018-08-13 12:52:09 -07:00
Dan Gohman
cc4bf1c7fb Deny unstable_features in "std" builds. 2018-08-13 12:51:49 -07:00
Benjamin Bouvier
a044f58cea Fixes #404: Use log.rs and a file-per-thread logger instead of the dbg! macro; 2018-08-13 12:51:14 -07:00
Maddy
f5d46cabe7 Use types to distinguish between wasm function body indices and wasm function indices. 2018-08-09 19:52:21 -07:00
Dan Gohman
f4dbd38a4c Rename Cretonne to Cranelift! 2018-07-13 09:15:16 -07:00