Commit Graph

138 Commits

Author SHA1 Message Date
Benjamin Bouvier
d5b80b2803 [meta] Generate full documentation for instructions in InstBuilder; 2019-07-11 11:48:45 +02:00
Benjamin Bouvier
84a6795873 [meta] Riscv: add back stacknull encodings for copy_nop; 2019-07-10 17:51:09 +02:00
Dan Gohman
59f6c81e4f Bump version to 0.34.0 2019-07-09 12:31:58 -07:00
Benjamin Bouvier
41a3d88b37 Fixes #837: Use an u64 comparison instead of a usize comparison in meta; 2019-07-09 18:15:30 +02:00
Sean Stangl
237d48477a Fix an outdated comment referring to FunctionLayout instead of Layout 2019-07-09 18:05:36 +02:00
Nicolas B. Pierron
3ac7466cab Legalize br_table to a BB-like format. 2019-07-09 16:48:54 +02:00
Nicolas B. Pierron
1963c223b1 Legalize trapz/trapnz to a BB-like format. 2019-07-09 16:02:49 +02:00
Benjamin Bouvier
f11fc34066 Build fix: add crates::predicates to the Riscv enc_tables file; 2019-07-09 11:31:21 +02:00
Benjamin Bouvier
56f6908020 [meta] Legalization: Don't generate a variable for replaced instructions;
(since they're unused)
2019-07-09 10:56:50 +02:00
Benjamin Bouvier
cd4c28ad97 [meta] Legalization: Unprefix some module paths to make code neater; 2019-07-09 10:56:50 +02:00
Benjamin Bouvier
15d8b95e72 [meta] Legalization: remove spurious Option wrapping for type variables; 2019-07-09 10:56:50 +02:00
Benjamin Bouvier
f1222dce10 [meta] Legalization: emit typeof type variables for results in all the cases; 2019-07-09 10:56:50 +02:00
Benjamin Bouvier
3545363006 Add ir::Types::lane_of as an alias of lane_type to be used in typevar constraints; 2019-07-09 10:56:50 +02:00
Benjamin Bouvier
4fef03f5f8 [meta] Legalization: remove spurious assert;
This assert was added when porting legalization from Python to Rust and
doesn't hold when we have derived type variables.
2019-07-09 10:56:50 +02:00
Benjamin Bouvier
563525b090 [meta] Remove mentions to Python in comments of the non-meta crate; 2019-07-05 17:50:17 +02:00
Benjamin Bouvier
f29a26de14 [meta] Remove the Python DSL
KILL THE SNAKE WITH FIRE.
2019-07-05 17:50:17 +02:00
Benjamin Bouvier
88307f693a [meta] Generate the encodings files; 2019-07-05 17:50:17 +02:00
Benjamin Bouvier
f574ab8703 [meta] Generate the binemits files;
Co-authored-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2019-07-05 17:50:17 +02:00
Benjamin Bouvier
fd03677292 [meta] Recipes and encodings descriptions for x86; 2019-07-05 11:38:51 +02:00
Benjamin Bouvier
ca277422bb [meta] Recipes and encodings descriptions for RiscV; 2019-07-05 11:38:51 +02:00
Benjamin Bouvier
21aaf0c89f [meta] Add cdsl facilities for encodings and recipes;
Co-authored-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2019-07-05 11:38:51 +02:00
Benjamin Bouvier
4a6b88193e [meta] Map global TransformGroup to local TransformGroup indices; 2019-07-04 16:38:28 +02:00
Benjamin Bouvier
1e42aac41a [meta] Add new instruction predicates and the InstructionPredicateMap;
The latter helps deduplicating predicates during encodings and recipes
construction.
2019-07-04 16:38:28 +02:00
Dan Gohman
a3e459269e Bump version to 0.33.0 2019-07-03 10:40:58 -07:00
Benjamin Bouvier
e34a4759cd [meta] Fix typo in x86 setting name use_lzcnt; 2019-07-03 18:39:28 +02:00
Benjamin Bouvier
ec5678ab7a [meta] Add the ability to bind any type to an instruction; 2019-07-03 18:39:28 +02:00
Benjamin Bouvier
9dcc185264 [meta] Add a MapWithDefault trait;
This traits augments HashMap so they have a `get_or_default` method that
can be used to avoid boilerplate around usage of `entry.or_default`.
2019-07-03 18:39:28 +02:00
Benjamin Bouvier
18fb87cd9c [meta] Refactor instruction predicates to distinguish format and type checks;
Also add the instruction format name in format predicates, since they're
going to be used when generating encodings.
2019-07-03 18:39:28 +02:00
Benjamin Bouvier
f1d1d1e960 [meta] Uniquely number every instruction in the Rust crate; 2019-07-03 18:39:28 +02:00
Nicolas B. Pierron
460fdaa34d Add verification pass to migrate from EBB to BB. 2019-07-03 13:57:14 +02:00
Dan Gohman
b35227b417 Bump version to 0.32.0 2019-07-02 12:27:39 -07:00
Dan Gohman
4b924d34b6 Bump version to 0.31.0 2019-06-28 11:37:39 -07:00
Benjamin Bouvier
83336290c2 Mark the jump_table_entry Instruction as loading; 2019-06-27 17:38:20 +02:00
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
36870c41c8 Fix a calculation error for rodata_size in memsink 2019-06-18 07:14:32 -07: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
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
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