Commit Graph

1806 Commits

Author SHA1 Message Date
Artur Jamro
9e884b4433 Add support for some serde serialization (#847)
* Add support for some serde serialization
2019-07-12 15:30:50 -07:00
Nicolas B. Pierron
8edc40cb49 BB-like manual legalization for x86 ISA 2019-07-12 14:20:26 +02:00
Mark McCaskey
f856b124fd Use Default trait for Position and DisplayFunctionAnnotations (#843) 2019-07-12 11:21:00 +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
cd4c28ad97 [meta] Legalization: Unprefix some module paths to make code neater; 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
563525b090 [meta] Remove mentions to Python in comments of the non-meta crate; 2019-07-05 17:50:17 +02:00
Benjamin Bouvier
88307f693a [meta] Generate the encodings files; 2019-07-05 17:50:17 +02:00
Nicolas B. Pierron
460fdaa34d Add verification pass to migrate from EBB to BB. 2019-07-03 13:57:14 +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
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
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
edd2bf12fd Export ValueLocRange and DisplayFunctionAnnotations::default() 2019-05-15 09:18:45 +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
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
efdb7d86b3 Fixes #607: Use a wrapping multiply when computing div/rem magic numbers; (#757) 2019-04-30 11:46:54 +02:00
Benjamin Bouvier
95e6fc9efc Avoid inserting checks during div/rem legalization when the input is a constant immediate; 2019-04-25 16:58:41 +02:00
Benjamin Bouvier
6acf9be540 Refactor simple-preopt to make it slightly simpler to read;
- don't use camel case but snake casing;
- longer variable names;
- more whitespace;
- add/wrap comments;
2019-04-24 14:14:44 +02:00
Benjamin Bouvier
274415d5ee Fixes #738: Check ebbs used in jump tables in the verifier; 2019-04-17 15:37:27 +02:00
Tyler McMullen
3b1583ebb7 Style changes in response to code review. 2019-04-17 13:15:41 +02:00
Tyler McMullen
4d427d7c71 Remove old commented out code 2019-04-17 13:15:41 +02:00
Tyler McMullen
5596b5fadc Address code review comments, simplifying some bits of branch_opt. 2019-04-17 13:15:41 +02:00
Tyler McMullen
402d0d9c83 Add comments to branch folding and reordering functions in simple_preopt. 2019-04-17 13:15:41 +02:00
Tyler McMullen
fd6940baaf Switch branch order opt from brif/brff to br_icmp, as that's what frontends should produce. 2019-04-17 13:15:41 +02:00
Tyler McMullen
571b87414f Switch ifcmp+brif folding to be icmp+brz folding, which is what frontends actually produce. 2019-04-17 13:15:41 +02:00
Tyler McMullen
67cc5aafec Refactoring of branch ordering and zero-check optimization based on PR feedback. 2019-04-17 13:15:41 +02:00
Tyler McMullen
947130be81 Add branch order optimization to simple_preopt to encourage fallthroughs. 2019-04-17 13:15:41 +02:00
Tyler McMullen
57f087c9da Add note to simple_preopt differentiating its use from the preopt crate. 2019-04-17 13:15:41 +02:00
Tyler McMullen
fc6876c68e Fold 'ifcmp_imm' + 'brif' where imm is zero and cond is 'eq' or 'ne', into 'brz' or 'brnz'. 2019-04-17 13:15:41 +02:00
Lars T Hansen
aa926e9097 Allow readonly nontrapping loads to be hoisted by licm (#727) 2019-04-09 11:40:23 +02:00
carolinecullen
0166d6507a Adding comment about copying RiscV abi file into ARM32. 2019-04-08 17:06:08 -07:00
carolinecullen
8ab7170a07 Updated comments. 2019-04-08 17:06:08 -07:00
carolinecullen
72bc035d70 Beginnings of arm32 backend. 2019-04-08 17:06:08 -07:00
Benjamin Bouvier
cd8a42e01f Fix #686: Allow code shrink in relaxation if the shrinking pass hasn't been run;
Also:
- make sure to apply diversions when determining offsets for code
relaxation.
- select the smallest encoding when selecting a relaxed branch
instruction.
2019-04-03 11:42:38 +02:00
Lars T Hansen
141ccb9e9d Add a --disasm option to clif-util wasm and compile (#713)
- Both the `wasm` and `compile` commands get this new subcommand, and it defaults to false.  This means that test runs with `wasm` can request disassembly (the main reason I am doing this) while test runs with `compile` now must request it, this changes current behavior.
- Switch to using context.compile_and_emit directly, and make the reloc and trap printers just accumulate output, not print it.  This allows us to factor the printing code into the disasm module.
2019-03-27 12:57:13 +01:00
Dan Gohman
6b854381bb Fix a documentation-comment warning. 2019-03-26 09:11:57 -07:00
Dan Gohman
975b7f2e8d Put a space between "//!" and "```". 2019-03-26 08:40:25 -07:00
Yury Delendik
5e12f4f2b8 Add missing use_srcloc in postopt and regalloc passes 2019-03-25 15:06:41 +01:00
Benjamin Bouvier
b7dfe8aaa6 Fix build warnings for cranelift-codegen tests; 2019-03-12 09:53:36 +01:00
Steffen Butzer
92b3987e54 windows/x64 call convention: only use XMM0 for float return values (#691) 2019-03-11 11:44:44 +01:00