Commit Graph

1543 Commits

Author SHA1 Message Date
Dan Gohman
dabfc55c6e Bump version to 0.2.0 2018-02-27 15:58:25 -08:00
Dan Gohman
2addcfd642 Make publish-all.sh print the git commit line too, for convenience. 2018-02-27 15:54:29 -08:00
Dan Gohman
42a0c2e44b Enable backup files when setting version numbers with sed. 2018-02-27 15:44:36 -08:00
Dan Gohman
111c97df6d Quote shell variables in more places. 2018-02-27 15:43:13 -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
6a962e8b2c Add links to the docs.rs API documentation. 2018-02-27 15:26:06 -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
234d097f65 Change println!("") to println!().
https://rust-lang-nursery.github.io/rust-clippy/v0.0.186/index.html#print_with_newline
2018-02-26 15:25:37 -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
2a26b70854 Update URLs. 2018-02-23 16:16:44 -08:00
Jakob Stoklund Olesen
ec746c3359 Add a publish-all.sh script.
Set identical version numbers on all cretonne-* crates and print "cargo
publish" commands.

Update all crates to version 0.1.0.
2018-02-23 12:51:14 -08:00
Benjamin Bouvier
f02c8fd1ff Fixes #244: Prints the generated code size and wasm bytecode size in wasm command; 2018-02-23 08:46:09 -08:00
Dan Gohman
c7655c4928 Add minimal README.md files to published crates.
This will put descriptions on the packages' crates.io pages.
2018-02-21 20:50:03 -08:00
Dan Gohman
8e6e976e68 Add .swx to .gitignore to hide vim files from cargo watch. 2018-02-21 19:04:35 -08:00
Dan Gohman
c3c31e5cdc Add an empty .rustfmt.toml.
The existence of this file signals to some editors that this repository
wishes to be formatted with rustfmt.
2018-02-21 15:14:03 -08:00
Dan Gohman
a55a582d4e Suppress printing of placeholder external functions.
With the change to the parser to preserve indices, it now inserts
placeholders to pad out index spaces as needed. Placeholder functions
use reserved signature indices, so skip them when writing them out,
to avoid writing them out as "sig4294967295".
2018-02-21 13:10:58 -08:00
Dan Gohman
20500913ad Change tabs to spaces, for consistency with rustfmt.
This code is in a macro, which is presumably why rustfmt itself doesn't
reformat it.
2018-02-21 12:32:26 -08:00
Jakob Stoklund Olesen
043d80f7e1 Make the bitset module private.
This is just an implementation detail.
2018-02-21 12:14:50 -08:00
Jakob Stoklund Olesen
eae8261b07 Make the regalloc module private.
Cretonne clients don't need to know how the register allocator works.

Export the RegDiversions type from the binemit module instead. It is
used by the "test binemit" driver.
2018-02-21 12:11:50 -08:00
Jakob Stoklund Olesen
2f58c371bc Make specific ISA sub-modules private.
We don't want ISA-specific details exposed in the public Cretonne APIs.
2018-02-21 12:06:58 -08:00
Jakob Stoklund Olesen
8d388b2218 Fix stack pointer offsets for outgoing arguments.
StackSlotKind::OutgoingArg stack slots have an offset that is relative
to our own stack pointer, while all other stack slot kinds have offsets
that are relative to the caller's stack pointer.

Make sure we generate the right sp-relative offsets for outgoing
arguments too.
2018-02-21 10:34:41 -08:00
Dan Gohman
69cc6c8af3 Clean up more comments referring to "source numbers". 2018-02-20 17:27:46 -08:00
Dan Gohman
10dcfcacdb Remove support for entity variables in filecheck.
Now that the parser doesn't renumber indices, there's no need for entity
variables like $v0.
2018-02-20 17:27:46 -08:00
Dan Gohman
a5b00b173e Don't renumber entities in the parser.
This makes it easier to debug testcases:
 - the entity numbers in a .cton file match the entity numbers used
   within Cretonne.
 - serializing and deserializing doesn't cause indices to change.

One disadvantage is that if a .cton file uses sparse entity numbers,
deserializing to the in-memory form doesn't compact it. However, the
text format is not intended to be performance-critical, so this isn't
expected to be a big burden.
2018-02-20 17:27:46 -08:00
Jakob Stoklund Olesen
c846ec1626 Catch NaN explicitly in expand_fcvt_to_uint().
When the input is a NaN, we need to generate a different trap code, so
use the new trapff instruction to generate such a trap after the first
floating point comparison.
2018-02-20 14:44:57 -08:00
Jakob Stoklund Olesen
b9b1d0fcd5 Add a trapff instruction.
This is the floating point equivalent of trapif: Trap when a given
condition is in the floating-point flags.

Define Intel encodings comparable to the trapif encodings.
2018-02-20 14:35:41 -08:00
Jakob Stoklund Olesen
1e56d44465 Remember the positive numbers in expand_fcvt_to_sint.
We can get an INT_MIN result when converting a positive number that is
too large to fit in an integer too.
2018-02-20 14:01:13 -08:00
Dan Gohman
21215529fe Simplify the code in make_inst_results_reusing; NFC. 2018-02-20 12:15:23 -08:00
Jakob Stoklund Olesen
ad896d9790 Add more legalization patterns for *_imm instructions.
When the imediate value is out of range for the legal encodings, convert
these instructions to an iconst followed by their register counterparts.
2018-02-20 10:47:46 -08:00
Jakob Stoklund Olesen
a6ab90f205 Legalize irsub_imm. 2018-02-16 15:50:36 -08:00
Jakob Stoklund Olesen
a9e799debb Add an avoid_div_traps setting.
This enables code generation that never causes a SIGFPE signal to be
raised from a division instruction. Instead, division and remainder
calculations are protected by explicit traps.
2018-02-16 13:10:29 -08:00
Pat Hickey
ed24320eda gen_settings: dont try to display a Preset descriptor in Flags (#241)
* gen_settings: dont try to display a Preset descriptor in Flags

Trying to display a preset doesnt make sense, and before this commit it
does not display anything meaningful - the printout just says e.g.
"haswell =\n".

The offset byte a preset descriptor isnt a valid offset into the
flag bytes, it is actually an offset into the PRESETS table. It will
cause a panic when the offset is out of bounds for the flag bytes,
which happens in the intel isa as of this commit.

* intel settings: test that display impl doesnt panic
2018-02-14 11:51:40 -08:00
Dan Gohman
42e1616b82 Update to wasmparser 0.14.1. 2018-02-13 20:14:54 -08:00
Jakob Stoklund Olesen
3ccc3f4f9b Add a stack_check instruction.
This instruction loads a stack limit from a global variable and compares
it to the stack pointer, trapping if the stack has grown beyond the
limit.

Also add a expand_flags transform group containing legalization patterns
for ISAs with CPU flags.

Fixes #234.
2018-02-13 10:48:06 -08:00
Jakob Stoklund Olesen
a73fcb2691 Pass an ISA argument to legalization functions.
This lets them look at the ISA flags.
2018-02-13 10:42:00 -08:00
Jakob Stoklund Olesen
60e70da0e6 Add Intel encodings for ifcmp_imm.
The instruction set has variants with 8-bit and 32-bit signed immediate
operands.

Add a TODO to use a TEST instruction for the special case ifcmp_imm x, 0.
2018-02-13 10:38:46 -08:00
Jakob Stoklund Olesen
788a78caf4 Add Intel encodings for ifcmp_sp.
Also generate an Into<RegUnit> implementation for the RU enums.
2018-02-09 14:32:29 -08:00
Jakob Stoklund Olesen
73c4c356c9 Add an ifcmp_sp instruction.
This will be used to implement the stack_check macro.
2018-02-09 13:59:49 -08:00
Jakob Stoklund Olesen
69f70fc61d Add Intel encodings for trapif.
This is implemented as a macro with a conditional jump over a ud2. This
way, we don't have to split up EBBs at every conditional trap.
2018-02-08 15:15:15 -08:00
Jakob Stoklund Olesen
11c721934c Add a trapif instruction.
This is a conditional trap controlled by integer CPU flags.
Compare to brif.
2018-02-08 14:40:46 -08:00
Jakob Stoklund Olesen
3eeef1c752 Add some missing instructions to the language reference. 2018-02-06 09:55:53 -08:00
Julian Seward
6f8a54b6a5 Adds support for legalizing CLZ, CTZ and POPCOUNT on baseline x86_64 targets.
Changes:

* Adds a new generic instruction, SELECTIF, that does value selection (a la
  conditional move) similarly to existing SELECT, except that it is
  controlled by condition code input and flags-register inputs.

* Adds a new Intel x86_64 variant, 'baseline', that supports SSE2 and
  nothing else.

* Adds new Intel x86_64 instructions BSR and BSF.

* Implements generic CLZ, CTZ and POPCOUNT on x86_64 'baseline' targets
  using the new BSR, BSF and SELECTIF instructions.

* Implements SELECTIF on x86_64 targets using conditional-moves.

* new test filetests/isa/intel/baseline_clz_ctz_popcount.cton
  (for legalization)

* new test filetests/isa/intel/baseline_clz_ctz_popcount_encoding.cton
  (for encoding)

* Allow lib/cretonne/meta/gen_legalizer.py to generate non-snake-caseified
  Rust without rustc complaining.

Fixes #238.
2018-02-06 09:43:00 -08:00
Jakob Stoklund Olesen
e3714ddd10 Add a func.inst_offsets() iterator.
This Function method can be used after the final code layout has been
computed. It returns all the instructions in an EBB along with their
encoded size and offset from the beginning of the function.

This is useful for extracting additional metadata about trapping
instructions and other things that may be needed by a VM.
2018-02-01 17:19:05 -08:00
Jakob Stoklund Olesen
429027e2f2 Stack alignment is 16 bytes on x86_64.
Make sure that the stack frame size is always a multiple of 16 as
specified by the x86_64 ABI.

Heads up @pchickey
2018-01-31 16:19:35 -08:00
Tyler McMullen
ff16583c59 Remove RSP from deref safe register class as well. 2018-01-29 14:18:08 -08:00
Pat Hickey
099b959d57 TargetIsa implies a Display of shared and isa-specific flags 2018-01-29 13:53:08 -08:00
Tyler McMullen
21f0fc39ad Further restrict Intel register classes to prevent incorrect encoding of R12 derefs. 2018-01-29 13:42:11 -08:00
Jakob Stoklund Olesen
584a33bca7 Give better error messages in "test binemit".
When an instruction can't be encoded, provide a bit more help:

- Detect missing register assignments for input and output operands.
- List encodings that where considered and rejected.
2018-01-29 09:16:33 -08:00