Commit Graph

1293 Commits

Author SHA1 Message Date
Dan Gohman
56c7d85727 More minor code simplifications. 2018-03-09 15:08:54 -08:00
Dan Gohman
55d0efcb14 Pass the wasmparser::Operator by value, simplifying the code. 2018-03-09 15:08:54 -08:00
Dan Gohman
8df9fe6c87 Fix obsolete paths in comments. 2018-03-09 15:08:54 -08:00
Dan Gohman
b5f428b6f2 Bump version to 0.3.3 2018-03-08 02:50:09 -08:00
Dan Gohman
40ec50d0b6 Don't relax a branch to have different input constraints.
When relaxing a branch, restrict the set of candidate encodings to those which
have the same input constraints as the original encoding choice. This prevents
situations where relaxation prefers a non-REX-prefixed encoding over a REX
prefixed one because the end of the instruction can be one byte closer to the
destination, in a situation where the encoding needs to be REX-prefixed
because of one of the operand registers.

This also makes the Context class perform encoding verification after
relaxation, to catch similar problems in the future.

Fixes #256.
2018-03-08 02:34:41 -08:00
Dan Gohman
6cf9bf36b8 Fix a typo in a comment. 2018-03-08 02:26:15 -08:00
Dan Gohman
ee0bce4106 Bump version to 0.3.2 2018-03-05 16:17:00 -08:00
Dan Gohman
136d6f5c4b Implement ireduce, sextend, and uextend between i8/i16 and i32/i64. 2018-03-05 15:13:59 -08:00
Dan Gohman
ae0801e23b Disable creation of .pyc files.
Cretonne's python scripts aren't run very often, so there's little
benefit in creating .pyc files. And the .pyc files cause trouble for
some vendoring scripts. So disable them.
2018-03-05 14:05:13 -08:00
Dan Gohman
d119524c90 Bump version to 0.3.1 2018-03-05 07:11:23 -08:00
Dan Gohman
bf480c341b Use https rather than http for several URLs. 2018-03-05 06:55:27 -08:00
Dan Gohman
6e94e70f30 Use an https URL rather than http.
Found by sphinx's linkcheck.
2018-03-05 06:55:27 -08:00
Dan Gohman
c59e9180de Tidy up whitespace. 2018-03-05 06:55:27 -08:00
Bruce Mitchener
d2d02565fb I64Extend16S should operate on 16 bits, not 8.
This showed up in clippy warnings as the code for this case was
the same as for `I64Extend8S`.
2018-03-05 06:53:13 -08:00
Dan Gohman
13b167770c Include emergency stack slots when laying out the stack.
Emergency stack slots are a new kind of stack slot added relatively
recently. They need to be allocated a stack offset just like explicit
and spill slots.

Also, make StackSlotData's offset field an Option, to catch problems
like this in the future. Previously the value 0 was used when offsets
weren't assigned yet, however that made it non-obvious when the field
meant "not assigned yet" and when it meant "assigned the value 0".
2018-03-04 21:34:49 -08:00
Dan Gohman
a301280d94 Change the stack alignment for 32-bit x86 to 16.
Spiderwasm on 32-bit x86 always uses a 16-byte-aligned stack pointer.

Change the setting for the "native" convention as well, for
compatibility with Linux and Darwin ABIs, and so that if a platform
has different ABI rules, the problem will be detected in code emitted by
Cretonne, rather than somewhere else.
2018-03-04 21:34:49 -08:00
Dan Gohman
aac006ed49 Avoid trivial numeric casts. 2018-03-04 21:34:49 -08:00
Dan Gohman
804b56d0f2 Document that "enable_float=false" isn't implemented yet. 2018-03-04 21:34:49 -08:00
Dan Gohman
505fe9277a Tidy up calls to analyze_branch. 2018-03-04 21:34:49 -08:00
Bruce Mitchener
125270e2b0 Fix some typos. 2018-03-04 21:33:04 -08:00
Dan Gohman
5dc449ec9e Rename "local variables" to "explicit stack slots".
The term "local variables" predated the SSA builder in the front-end
crate, which also provides a way to implement source-language local
variables. The name "explicit stack slot" makes it clear what this
construct is.
2018-02-28 14:04:28 -08:00
Dan Gohman
c93f29ad1e Remove more obsolete comments about entity number remapping. 2018-02-28 13:30:37 -08:00
Dan Gohman
b9f51d7850 Enable more compliler lints. 2018-02-28 13:18:07 -08:00
Dan Gohman
1cf9a8d669 Implement the wasm sign-extension-ops proposal.
https://github.com/WebAssembly/sign-extension-ops/
2018-02-28 12:02:14 -08:00
Dan Gohman
227baaadb8 Enable the simple_gvn and licm passes at OptLevel::Best. 2018-02-28 11:50:59 -08:00
Julian Seward
7054f25abb Adds support to transform integer div and rem by constants into cheaper equivalents.
Adds support for transforming integer division and remainder by constants
into sequences that do not involve division instructions.

* div/rem by constant powers of two are turned into right shifts, plus some
  fixups for the signed cases.

* div/rem by constant non-powers of two are turned into double length
  multiplies by a magic constant, plus some fixups involving shifts,
  addition and subtraction, that depends on the constant, the word size and
  the signedness involved.

* The following cases are transformed: div and rem, signed or unsigned, 32
  or 64 bit.  The only un-transformed cases are: unsigned div and rem by
  zero, signed div and rem by zero or -1.

* This is all incorporated within a new transformation pass, "preopt", in
  lib/cretonne/src/preopt.rs.

* In preopt.rs, fn do_preopt() is the main driver.  It is designed to be
  extensible to transformations of other kinds of instructions.  Currently
  it merely uses a helper to identify div/rem transformation candidates and
  another helper to perform the transformation.

* In preopt.rs, fn get_div_info() pattern matches to find candidates, both
  cases where the second arg is an immediate, and cases where the second
  arg is an identifier bound to an immediate at its definition point.

* In preopt.rs, fn do_divrem_transformation() does the heavy lifting of the
  transformation proper.  It in turn uses magic{S,U}{32,64} to calculate the
  magic numbers required for the transformations.

* There are many test cases for the transformation proper:
    filetests/preopt/div_by_const_non_power_of_2.cton
    filetests/preopt/div_by_const_power_of_2.cton
    filetests/preopt/rem_by_const_non_power_of_2.cton
    filetests/preopt/rem_by_const_power_of_2.cton
    filetests/preopt/div_by_const_indirect.cton
  preopt.rs also contains a set of tests for magic number generation.

* The main (non-power-of-2) transformation requires instructions that return
  the high word of a double-length multiply.  For this, instructions umulhi
  and smulhi have been added to the core instruction set.  These will map
  directly to single instructions on most non-intel targets.

* intel does not have an instruction exactly like that.  For intel,
  instructions x86_umulx and x86_smulx have been added.  These map to real
  instructions and return both result words.  The intel legaliser will
  rewrite {s,u}mulhi into x86_{s,u}mulx uses that throw away the lower half
  word.  Tests:
    filetests/isa/intel/legalize-mulhi.cton (new file)
    filetests/isa/intel/binary64.cton (added x86_{s,u}mulx encoding tests)
2018-02-28 11:41:36 -08:00
Nathan Froyd
e4b30d3284 fix typo in build.rs 2018-02-28 11:37:37 -08:00
Dan Gohman
6fcbb20e10 Bump version to 0.3.0 2018-02-28 10:31:00 -08:00
Dan Gohman
ab9298eafa Make the fst recipe use the deref-safe register class as well. 2018-02-28 10:12:40 -08:00
Dan Gohman
9010e576dd Simply instruction result value handling in the parser.
Also, move the handling earlier so that they're checked before the rest
of the instruction is checked.
2018-02-28 10:10:42 -08:00
Dan Gohman
d71756f298 Delete an extraneous file. 2018-02-28 03:43:55 -08:00
Dan Gohman
60c6154b94 Add some crate keywords. 2018-02-28 03:38:48 -08:00
Dan Gohman
dabfc55c6e Bump version to 0.2.0 2018-02-27 15:58:25 -08:00
Dan Gohman
d394ae0902 Enable "set -euo pipefail" in all bash scripts.
This enables "set -e", "set -u", and "set -o pipefail", which
catch common errors.
2018-02-27 15:32:21 -08:00
Dan Gohman
af154655d7 Replace as casts with type-conversion functions.
https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_lossless
2018-02-26 15:25:46 -08:00
Dan Gohman
e943d932b9 Change match self to match *self to avoid adding & to all patterns in a match.
https://rust-lang-nursery.github.io/rust-clippy/v0.0.186/index.html#match_ref_pats
2018-02-26 15:25:39 -08:00
Dan Gohman
0e22c74085 Track wasm reachability explicitly.
Maintain an explicit "reachable" flag when decoding wasm. Push placeholder
frames on the control-flow stack instead of just maintaining a count of
the stack depth in unreachable code, so that we can whether If blocks
have Elses, and whether block exits are branched to, in all contexts.

Fixes #217.
2018-02-26 15:24:33 -08:00
Dan Gohman
81c126619b Ignore unknown custom wasm sections. 2018-02-26 15:24:25 -08:00
Dan Gohman
6c9cf2bacf Switch from error_core to failure. 2018-02-23 21:49:59 -08:00
Dan Gohman
e37f45667f Add an explicit std feature so that features are purely additive. 2018-02-23 21:49:55 -08:00
Dan Gohman
61db54c447 Add support for running tests in no_std mode. 2018-02-23 21:35:22 -08:00
Lachlan Sneff
023f8d7980 Fixed missing vec 2018-02-23 20:57:26 -08:00
Lachlan Sneff
4cdbf2f56e Removed unused prelude 2018-02-23 20:57:26 -08:00
Lachlan Sneff
ddfa88c8ba Removed extraneous newlines 2018-02-23 20:57:26 -08:00
Lachlan Sneff
2462a065ad Fixed formatting issues 2018-02-23 20:56:30 -08:00
Lachlan Sneff
5c85c1ba4a Fixed formatting issues 2018-02-23 20:56:30 -08:00
Lachlan Sneff
66a150e67a lib/wasm works with no_std 2018-02-23 20:56:30 -08:00
Lachlan Sneff
299e8a9737 lib/cretonne works with no_std 2018-02-23 20:56:30 -08:00
Lachlan Sneff
7375088c3e Most of the way to no_std support 2018-02-23 20:56:30 -08:00
Dan Gohman
2a26b70854 Update URLs. 2018-02-23 16:16:44 -08:00