Commit Graph

1642 Commits

Author SHA1 Message Date
Dan Gohman
7cce4be96a Fix an incorrect index in "cton-util wasm -s". 2018-03-27 21:11:24 -07:00
Dan Gohman
0b5bb313cb Mark CondCode's functions #[must_use].
It's easy to forget whether they mutate the value in place or return a
new value. Marking them #[must_use] will catch cases where they are used
incorrectly.
2018-03-27 14:16:55 -07:00
Dan Gohman
79f02e42dd Use movss/movsd rather than movd/movq for floating-point loads and stores.
While there may be CPUs that have a domain crossing penalty here,
this also helps the generated code look more like the code produced
by other compilers.
2018-03-27 11:53:59 -07:00
Dan Gohman
3b0a9b9ecf Remove an unused argument. 2018-03-27 11:53:10 -07:00
Dan Gohman
a661a8a9bb Factor out common ways to call encode from a dfg or func. 2018-03-27 11:53:03 -07:00
Dan Gohman
ffe89cdc0a Rename %eflags to %rflags.
EFLAGS is a subregister of RFLAGS. For consistency with GPRs where we
use the 64-bit names to refer to the registers, use the 64-bit name for
RFLAGS as well.
2018-03-27 11:52:57 -07:00
Dan Gohman
14faef7374 Derive Debug for LiveValue. 2018-03-26 21:21:54 -07:00
Dan Gohman
685cde98a4 Mark loads from globals aligned and notrap.
Mark loads from globals generated by cton_wasm or by legalization as
`aligned` and `notrap`, since memory for these globals should be
allocated by the runtime environment for that purpose. This reduces
the number of potentially trapping instructions, which can reduce
the amount of metadata required by embedding environments.
2018-03-26 21:21:54 -07:00
Dan Gohman
bcd3309c15 Mention `reserved_reg` being unimplemented in the docs too. 2018-03-26 21:21:54 -07:00
Pat Hickey
80d2c5d9bf Implement shift-immediate encodings for x86 (#283)
* add x86 encodings for shift-immediate instructions

implements encodings for ishl_imm, sshr_imm, and ushr_imm. uses 8-bit immediates.

added tests for the encodings to intel/binary64.cton. Canonical versions
come from llvm-mc.

* translate test to use shift-immediates

* shift immediate encodings: use enc_i32_i64

and note why the regular shift encodings cant use it above

* add additional encoding tests for shift immediates

this covers 32 bit mode, and 64 bit operations in 64 bit mode.
2018-03-26 16:48:20 -07:00
Dan Gohman
51eea8b89d Add some comments noting unimplemented features.
While use of these features will trigger an `unimplemented!()`, it is
nice to let users know in advance about features which aren't yet
implemented.
2018-03-23 12:46:23 -07:00
Dan Gohman
aa73de8ca1 Make code that tests for specific opcode families more consistent. 2018-03-23 11:38:11 -07:00
Dan Gohman
9602b78320 Disable the LICM pass for now.
There appear to be underlying problems with the way Cretonne handles value
aliases, which are causing problems for LICM. Disable LICM until we have
a chance to fix the underlying issues.

Fixes #275.
2018-03-22 16:55:18 -07:00
Dan Gohman
af8ac8f8ca Avoid calling analyze_branch() when the BranchInfo is not needed.
It's faster to just call `opcode().is_branch()`.
2018-03-22 13:18:25 -07:00
Dan Gohman
3ec7918ba1 Tidy up a redundant import. 2018-03-22 13:18:25 -07:00
Dan Gohman
e787357520 Wrap build.py's contents in a main function.
This prevents its local variables from becoming global variables.
2018-03-22 13:18:25 -07:00
Pat Hickey
03ee007624 Use clippy (#276)
* cton-util: fix some clippy unnecessary pass-by-value warnings

* clippy: ignore too many arguments / cyclomatic complexity in module

since these functions are taking args coming from the command line, i
dont think this is actually a valid lint, morally the arguments are all
from one structure

* cton-util: take care of remaining clippy warnings

* cton-reader: fix all non-suspicious clippy warnings

* cton-reader: disable clippy at site of suspicious lint

* cton-frontend: disable clippy at the site of an invalid lint

* cton-frontend: fix clippy warnings, or ignore benign ones

* clippy: ignore the camelcase word WebAssembly in docs

* cton-wasm: fix clippy complaints or ignore benign ones

* cton-wasm tests: fix clippy complaints

* cretonne: starting point turns off all clippy warnings

* cretonne: clippy fixes, or lower allow() to source of problem

* cretonne: more clippy fixes

* cretonne: fix or disable needless_lifetimes lint

this linter is buggy when the declared lifetime is used for another type
constraint.

* cretonne: fix clippy complaint about Pass::NoPass

* rustfmt

* fix prev minor api changes clippy suggested

* add clippy to test-all

* cton-filetests: clippy fixes

* simplify clippy reporting in test-all

* cretonne: document clippy allows better

* cretonne: fix some more clippy lints

* cretonne: fix clippy lints (mostly doc comments)

* cretonne: allow all needless_lifetimes clippy warnings

remove overrides at the false positives

* rustfmt
2018-03-22 13:10:41 -07:00
Dan Gohman
2b3df1a506 Add use declarations for std features.
Merge the `use` parts of the `no_std` branch. This reduces the diffs
between master and the `no_std` branch, making it easier to maintain.

Most of these changes are derived from patches by @lachlansneff in
https://github.com/Cretonne/cretonne/tree/no_std.
2018-03-20 14:07:05 -07:00
Dan Gohman
da4cf27780 Update to filecheck 0.3.0. 2018-03-20 13:28:35 -07:00
Dan Gohman
ca4582ae82 Rename the recipes for x86 spill/fill instructions.
Both "sp" and "fi" have multiple meanings in this context, so use slightly
longer but less ambiguous names.
2018-03-20 13:28:35 -07:00
Dan Gohman
f6b8cf86a5 Factor out br_if translation into helper functions. 2018-03-20 13:28:32 -07:00
Dan Gohman
c333a52e3e Factor out fcmp and icmp translation into helper functions. 2018-03-20 13:27:45 -07:00
Dan Gohman
2d1f9f874c Bump version to 0.4.1 2018-03-18 14:56:30 -07:00
Dan Gohman
d99b43e4b7 Add a hook to the wasm FuncEnvironment for emitting loop headers.
This will allow wasm implementations that wish to insert code into
every loop, for example to insert an interrupt check or a safepoint.
do so without relying on asynchronous signals.
2018-03-18 14:54:05 -07:00
Dan Gohman
492fa1283c Define an "interrupt" trap code.
This is a trap code for interrupting the running code, to allow
timeouts and safepoints to be implemented. It is resumable.
2018-03-18 14:54:05 -07:00
Dan Gohman
832d9d9a0d Minor code simplification. 2018-03-18 14:54:05 -07:00
Sergey Pepyakin
c161b0d103 Fix check-rustfmt.sh for macOS (#273)
There are two cases:

1. It seems that grep on macOS exits as soon as it finds the first match. This makes cargo unhappy and it prints message like "failed printing to stdout: Broken pipe (os error 32)". The solution is to fully consume the output from cargo. I choose to use tee for this task.

2. When in a strict mode, bash complains that $1 is not defined (when it's actually not defined in case of omitting --install). The solution is to apply bash substitution magic: when $1 is undefined or set to null substitute it with empty string.
2018-03-18 13:53:02 -07:00
Afnan Enayet
9a49bc2ec9 Rename I32 -> X86_32 and I64 -> X86_64 (#271)
* Rename `I32` -> `X86_32` and `I64` -> `X86_64`

* Format file to pass flake8 tests

* Fix comment so lines are under 80 char limit

* Remove trailing whitespace from comment

* Renamed `enc_i64` to `enc_x86_64` as per suggestion from PR
2018-03-18 13:50:51 -07:00
Dan Gohman
921cea2845 Bump version to 0.4.0 2018-03-16 16:12:56 -07:00
Dan Gohman
5e21ac1a30 Use whitespace more consistently in Cargo.toml files. 2018-03-16 16:01:15 -07:00
Dan Gohman
a4c51d66a8 Remove uses of println! in tests.
In this case, it's a little nicer to just use more assertions,
which will print their line number indicating how far the test
got, when they fail.

And this allows the tests to be run in no_std configurations.
2018-03-15 22:45:09 -07:00
Dan Gohman
06fe3b654f Avoid match expressions with reference patterns.
https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
2018-03-15 22:44:54 -07:00
Dan Gohman
99f7cb5b8d Use debug_assert_ne rather than debug_assert with a !=.
https://github.com/rust-lang-nursery/rust-clippy/wiki#should_assert_eq
2018-03-15 22:44:33 -07:00
Dan Gohman
e6db8e278c Rename one more "local" to "explicit_slot". 2018-03-15 22:32:47 -07:00
Dan Gohman
5e5fcefdfd Add Travis builds with Rust nightly.
See [here](https://docs.travis-ci.com/user/languages/rust/) for details.
2018-03-15 21:37:31 -07:00
Dan Gohman
e2f3079d8b Tidy up redundant commands in test-all.sh. 2018-03-15 21:37:08 -07:00
Dan Gohman
4dbafb45c7 Update to num_cpus 1.8, and other updates. 2018-03-15 21:09:59 -07:00
Dan Gohman
e889b88d04 Split filecheck out into its own repo. 2018-03-15 15:35:48 -07:00
Dan Gohman
965b93bd2a Move the filetest harness into its own crate.
This allows us to run the tests via a library call rather than just
as a command execution. And, it's a step toward a broader goal, which
is to keep the code in the top-level src directory minimal, with
important functionality exposed as crates.
2018-03-15 15:35:48 -07:00
Dan Gohman
00af7a28f3 Run the filetests as part of "cargo test".
Refactor the filetests harness so that it can be run as part of
`cargo test`. And begin reorganizing the test harness code in preparation
for moving it out of the src directory.
 - Test subcommand files are now named `test_*.rs`.
 - cton-util subcommand files now just export their `run` and nothing else.
 - src/filetest/mod.rs now also just exports `run` and nothing else.
 - Tests are now run in release mode (with debug assertions enabled).
2018-03-15 13:38:21 -07:00
Dan Gohman
b2acd457d5 Use OrderedDict rather than explicit sorting.
This reduces churn in the generated files, making it easier to inspect
changes.
2018-03-15 10:35:06 -07:00
Dan Gohman
c842b9aaa1 Code cleanup: import OrderedDict rather than collections.OrderedDict 2018-03-15 10:13:26 -07:00
Dan Gohman
bb82bac3af Tweak the Gitter URLs. 2018-03-14 12:40:20 -07:00
Dan Gohman
48fc161b8b Add a badge for a Gitter chat room.
I don't know how much interest there will be in Gitter, but if
there is some, I'm interested in trying it out.
2018-03-14 11:26:02 -07:00
Dan Gohman
272d03d8fc Add a utility for generating Rust 'match' expressions.
This makes it a little simpler to generate 'match' statements, and
it performs deduplication of identical arms. And it means I don't
have to think about as many strings like '{} {{ {}.. }} => {}'
when I'm trying to think about how instructions work :-).
2018-03-14 10:51:09 -07:00
Dan Gohman
d9712f5d7d Elaborate on some comments in generated source files.
Recipe names are fairly obscure, so the more context we can give
when using them the better.
2018-03-14 10:51:09 -07:00
Dan Gohman
cc8d6400f4 Rename builder.rs to inst_builder.rs.
This reflects its purpose, to define the `InstBuilder` trait.
2018-03-14 10:51:09 -07:00
Dan Gohman
3afe85ff17 Auto-generate InstructionData.
The meta description has all the information to generate the `InstructionData`
enum, so generate it rather than having a manually-maintained copy.
2018-03-14 10:51:09 -07:00
Afnan Enayet
9128290fb4 Rename ILBuilder to FunctionBuilderContext (#268)
* Rename `ILBuilder` to `FunctionBuilderContext` and update corresponding
code

* Refactor usages of ILBuilder to become FunctionBuilderContext,
update variable names to reflect this change

* Reformat to ensure that lines stay under 100 char limit

* Apply corrections from `rustfmt` to pass tests

* Rename variables to be more consistent with refactor of ILBuilder
2018-03-14 10:48:06 -07:00
Dan Gohman
44ca27beec Update to wasmparser 0.15.1. 2018-03-13 09:34:20 -07:00