Commit Graph

2883 Commits

Author SHA1 Message Date
Benjamin Bouvier
079ccf1f6e Remove unused results warnings; 2019-06-24 11:42:26 +02:00
Benjamin Bouvier
d7d48d5cc6 Add the dyn keyword before trait objects; 2019-06-24 11:42:26 +02:00
Lars T Hansen
eee824b6bd Merge pull request #797 from lars-t-hansen/memsink_rodata_fix
Fix a calculation error for rodata_size in memsink
2019-06-21 08:29:13 -07:00
Lars T Hansen
36870c41c8 Fix a calculation error for rodata_size in memsink 2019-06-18 07:14:32 -07:00
Lars T Hansen
3b8ab2b5e2 Merge pull request #790 from lars-t-hansen/reloc_jt_fixes
Handle Reloc::X86PCRelRodata4 in sundry reloc_jt
2019-06-09 08:32:51 +02:00
Lars T Hansen
ec5dc3384e Handle Reloc::X86PCRelRodata4 in sundry reloc_jt 2019-06-07 14:37:58 +02:00
julian-seward1
5fb347b7bc Merge pull request #784 from julian-seward1/issue779
Only create copy_nop instructions for types for which an encoding exi…
2019-06-05 15:05:56 +02:00
Julian Seward
b1488decc4 Only create copy_nop instructions for types for which an encoding exists. Issue #779.
PR #773 detects, at reload time, `copy` instructions that copy a value from stack
slot back to the same stack slot.  It replaces them with `copy_nop` instructions
that have a null encoding (hence producing no code).

For x86_64, `copy_nop` encodings for the types I64, I32, F64 and F32 are
provided.  Unfortunately the code that detects the redundant copy doesn't
check the type of the copied value, hence leaving itself open to the danger of
creating a `copy_nop` instruction cannot be encoded (which is different from
saying it has a null encoding).

This patch:

* Expands the x86_64 set of `copy_nop` encodings to: I64 I32 I16 I8 F64 and F32

* Adds encodings for the same for x86_32, rv64 and rv32.

* In `visit_inst()` in `reload.rs`, checks the type of the copied value accordingly.

* Adds comments explaining the above.
2019-06-05 13:06:22 +02:00
Dan Gohman
23055196fc Bump the minimum required Rust version to 1.34.
1.34 was [released] on April 11, so it satisfies the stable Rust
[policy].

Notably, this version includes the new `try_from` features.

[released]: https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html
[policy]: https://github.com/CraneStation/cranelift/blob/master/CONTRIBUTING.md#rustc-version-support
2019-06-03 12:40:58 +02:00
Dan Gohman
da1baf7481 Use try_from instead of the cast crate.
Now that `try_from` is in stable Rust, we can use it here.
2019-06-03 12:40:58 +02:00
Lars T Hansen
fbaffa2c04 Merge pull request #774 from lars-t-hansen/jump_tables
Generalize information about compiled code
2019-06-01 12:24:41 +02:00
Lars T Hansen
420850adf0 Record information about sections of emitted code+data.
The result of the emitter is a vector of bytes holding machine code,
jump tables, and (in the future) other read-only data.  Some clients,
notably Firefox's Wasm compiler, needs to separate the machine code
from the data in order to insert more code directly after the code
generated by Cranelift.

To make such separation possible, we record more information about the
emitted bytes: the sizes of each of the sections of code, jump tables,
and read-only data, as well as the locations within the code that
reference (PC-relatively) the jump tables and read-only data.
2019-05-31 08:39:57 +02:00
Benjamin Bouvier
70f79d23bf [meta] Make Builders build() instead of finish(); 2019-05-29 14:05:01 +02:00
Benjamin Bouvier
d9277f249b [meta] Introduce the InstructionGroupBuilder;
This follows the rest of the code base data structures, where we have a
mutable data structure builder; once the data structure is constructed,
it's immutable.

This also makes the definition of instructions easier, and it paves the
way for defining immediate variants.
2019-05-29 14:05:01 +02:00
Benjamin Bouvier
feb90e376a [meta] Make Instruction name/doc Strings so they can be automatically generated; 2019-05-29 14:05:01 +02:00
Benjamin Bouvier
22a6823496 [meta] Rename cdsl/inst to cdsl/instructions; 2019-05-29 14:05:01 +02:00
iximeow
6059936113 remove rex-prefixed recipes for e9 and eb jumps
while not incorrect, the prefix has no additional semantics on these
  instructions other than taking an extra byte for the jump
2019-05-29 11:32:44 +02:00
Takanori Ishibashi
f427a2b923 Fix url in comments 2019-05-28 13:29:45 +02:00
Julian Seward
03368895fe Cranelift: Redundant stack-slot-to-stack-slot copy removal. PR#773.
This is also https://bugzilla.mozilla.org/show_bug.cgi?id=1552737.

Cranelift currently has a tendency to create redundant copies (self-copies) of
values from a stack slot back to the same stack slot.  This generates a
pointless load and store and an unnecessary register use.  The copies are
created by `visit_inst` in regalloc/reload.rs.  They appear to occur mostly,
but not exclusively, at loop heads.  It's unclear why this happens.

This patch adds a special case to `visit_inst` to find such copies.  They are
converted into a new instruction, `copy_nop`, which takes and produces the
same SSA names, so as not to break any of the SSA invariants, but which has a
zero-length encoding, hence removing the copy at emission time.

`copy_nop`s source and destination operands must be stack slots and of course
the *same* stack slot.  The verifier has been enhanced to check this, since
misuse of `copy_nop` will likely lead to hard-to-find incorrect-code bugs.

Attempts were made to write a standalone .clif test case.  But these failed
because it appears the .clif parser accepts but ignores location hints that
are stack slots.  So it's impossible to write, in clif, the exact form of
`copy` instruction that triggers the transformation.
2019-05-27 13:55:48 +02:00
Benjamin Bouvier
6935033c9e [meta] Have bind() be a method of {Bound,}Instruction instead of a static method; 2019-05-23 14:31:00 +02:00
Benjamin Bouvier
724d1cd2a1 [meta] Rename ApplyTarget to InstSpec; 2019-05-23 14:31:00 +02:00
Benjamin Bouvier
a46b2d7173 [meta] Move ApplyTarget/bind to cdsl/inst; 2019-05-23 14:31:00 +02:00
Benjamin Bouvier
cbbb7a220e [meta] Move x86 registers generation to their own file; 2019-05-22 10:55:02 +02:00
Benjamin Bouvier
92109f664c [meta] Move x86 settings generation to their own file; 2019-05-22 10:55:02 +02:00
Nicolas B. Pierron
72b5487563 Add x86 encoding for rotr_imm and rotl_imm. 2019-05-20 11:56:56 +02:00
Benjamin Bouvier
97ebaa6f37 Add Rust implementation and address review comments of #742; 2019-05-20 11:52:43 +02:00
bjorn3
71a345e813 Legalize fcvt_from_u/sint.f32/f64.i8/i16 2019-05-20 11:52:43 +02:00
Julian Seward
91ec44acbf Add extensive test cases for integer division-by-constant magic number generation.
This adds test cases to ensure, to a reasonably high degree of certainty, that
the magic-number generators `magic_u32`, `magic_s32`, `magic_u64` and
`magic_s64` work correctly.  This is done by iterating through a large number
of `(n, d)` pairs, generating the magic numbers for `d`, interpreting the
magic numbers so as to perform the division, and comparing against the result
produced directly by the hardware.  The distribution of numbers is arranged so
that particular emphasis is given to corner cases -- the range ends and
midpoints -- but also so that there is at least some cover for values away
from those areas.  In total 50,148,000 tests are performed.
2019-05-17 12:33:07 +02:00
bjorn3
c27b0a0c3e Add note about needing to call func.dfg.collect_debug_info for set_val_label to have any effect 2019-05-15 09:26:16 +02:00
bjorn3
edd2bf12fd Export ValueLocRange and DisplayFunctionAnnotations::default() 2019-05-15 09:18:45 +02:00
Benjamin Bouvier
a0ddbf403c [wasm] Have the WasmError::User member be a String; 2019-05-14 18:34:16 +02:00
Yury Delendik
8f95c51730 Reconstruct locations of the original source variable 2019-05-09 00:35:44 -07:00
Benjamin Bouvier
d6059d4605 [meta] Use the Rust crate for settings generation; 2019-05-03 12:01:12 +02:00
Benjamin Bouvier
f335c5c56c [meta] Small fixes in the settings generation; 2019-05-03 12:01:12 +02:00
Benjamin Bouvier
390cfb37da [meta] Use named predicates for x86 settings in the Rust crate too;
And generate them using the same deterministic order that the Python
code uses.
2019-05-03 12:01:12 +02:00
Benjamin Bouvier
6a25354520 [meta-python] Use named predicates for x86 encodings instead of anonymous predicates;
And generate those in a deterministic order that the Rust crate can
reproduce easily.
2019-05-03 12:01:12 +02:00
Lars T Hansen
5cd0724fef Clarify that FixedTied constraints are not Tied (#756)
* Clarify that FixedTied constraints are not Tied
2019-05-02 14:33:54 +02:00
Benjamin Bouvier
18a5386c08 Remove and reorganize IntCC/FloatCC imports to avoid a build warning; 2019-05-02 10:08:53 +02:00
Benjamin Bouvier
dca168f350 [meta] Switch to the Rust crate to generate legalizations and remove Python code; 2019-05-02 10:08:53 +02:00
bjorn3
abf0048972 Merge data alignment 2019-04-30 14:06:34 +02:00
bjorn3
8216b83c65 Make alignment magic number constants 2019-04-30 14:06:34 +02:00
bjorn3
556d5d45e9 Rustfmt 2019-04-30 14:06:34 +02:00
bjorn3
cb6268118c Make it possible to define data alignment 2019-04-30 14:06:34 +02:00
Benjamin Bouvier
443e48aee1 [wasm] Raise an error instead of panicking for unhandled function local types; 2019-04-30 13:58:18 +02:00
Benjamin Bouvier
3ce5d2057d [wasm] Add the ability to provide a user-defined error; 2019-04-30 13:58:18 +02:00
Benjamin Bouvier
02e114cf3d [wasm] Make FuncEnvironment functions fallible (fixes #752); 2019-04-30 13:58:18 +02:00
Benjamin Bouvier
efdb7d86b3 Fixes #607: Use a wrapping multiply when computing div/rem magic numbers; (#757) 2019-04-30 11:46:54 +02:00
antoyo
79d6978e29 cranelift-simplejit: add a translation mechanism for LibCalls (#747) 2019-04-29 16:58:39 +02:00
Antoni Boucher
d8d573208b Remove unwrap() for branch folding 2019-04-28 16:32:01 -07:00
Antoni Boucher
4ee2747c5b Fix cranelift_preopt panic
Fix #611
2019-04-28 16:32:01 -07:00