Commit Graph

227 Commits

Author SHA1 Message Date
Lachlan Sneff
586a8835e9 Add a readonly flag for loads (#562)
* Add readonly MemFlag

* Add readonly flag verifier check

* Make global loads readonly

* Fix gvn to consider readonly loads
2018-10-22 21:50:09 -07:00
Benjamin Bouvier
3ec21459c5 Remove verify! macro that's used only once; 2018-10-19 16:10:05 -07:00
Dan Gohman
54ab1ea533 Optimize load/store with an iadd_imm operand.
Fold the immediate into the load/store offset when possible.
2018-10-19 10:58:55 -07:00
Benjamin Bouvier
9d6821d6d9 Fix #335: Introduce variable size recipes and remove GPR_SAFE reg classes (#552)
* Rename size to base_size and introduce a compute_size function;

* Add infra to inspect in/outs registers when computing the size of an instruction;

* Remove the GPR_SAFE_DEREF and GPR_ZERO_DEREF_SAFE register classes on x86 (fixes #335);
2018-10-15 15:43:38 -07:00
Dan Gohman
7f90414ae1 Update no_std support. 2018-10-05 17:18:40 -07:00
Dan Gohman
17a9631981 Use more Self keywords instead of repeating the type name. 2018-10-05 16:40:50 -07:00
Dan Gohman
9a1e966156 Fix an unused import warning. 2018-10-05 13:46:38 -07:00
Dan Gohman
652e526bb6 Put TargetIsa's emit_inst under a "testing_hooks" feature. (#531)
* Put TargetIsa's emit_inst under a "testing_hooks" feature.

In practice, TargetIsa's emit_inst pulls in its own instantiation
of the target-specifi `emit_inst` functions, which can be quite
large, and LTO doesn't eliminate them because they're held live
by TargetIsa's vtable.

Fortunately, this function is only used by tests, so we can put
it behind a feature flag.

Fixes #530.

* Add comments for `emit_inst` to clarify its purpose.
2018-10-05 09:12:47 -07:00
Dan Gohman
bf041e3ae2 Move return_at_end out of Settings and into the wasm FuncEnvironment. (#547)
* Move `return_at_end` out of Settings and into the wasm FuncEnvironment.

The `return_at_end` flag supports users that want to append a custom
epilogue to Cranelift-produced functions. It arranges for functions to
always return via a single return statement at the end, and users are
expected to remove this return to append their code.

This patch makes two changes:
 - First, introduce a `fallthrough_return` instruction and use that
   instead of adding a `return` at the end. That's simpler than having
   users remove the `return` themselves.

 - Second, move this setting out of the Settings and into the wasm
   FuncEnvironment. This flag isn't something the code generator uses,
   it's something that the wasm translator uses. The code generator
   needs to preserve the property, however we can give the
   `fallthrough_return` instruction properties to ensure this as needed,
   such as marking it non-cloneable.
2018-10-05 06:43:22 -07:00
Dan Gohman
20eea311a3 Miscellaenous code cleanups. 2018-10-04 13:14:29 -07:00
Dan Gohman
1098eafb45 Remove the concept of non-dense jump tables.
WebAssembly doesn't have non-dense jump tables, and higher-level users
are better served by the facilities in lib/frontend/src/switch.rs for
working with non-dense switches.

This eliminates the concept of "absent" jump table entries, which
were represented as "0" in the text format.

Also, jump table contents are now enclosed in `[` and `]`, so that
we can unambiguously display empty jump tables. Previously, empty jump
tables were displayed as if they had a single absent entry.
2018-10-04 12:46:40 -07:00
Dan Gohman
2eb9ae45aa Tidy up some comments. 2018-10-04 10:43:11 -07:00
bjorn3
b2a28d69e6 Add encodings for i8 and i16 copy, spill, fill, ireduce.i8.i16 (#534)
* Add encodings for i8 and i16 copy, spill, fill, ireduce.i8.i16

Also adds legalization for srem, irsub_imm, {u,s}extend.i16.i8

Fixes #477 cc #466

* Legalize popcnt, clz and ctz for i8 and i16

* Fix bug in call_memset
2018-10-03 14:43:59 -07:00
Dan Gohman
17859a87ff Fix a typo in a comment. 2018-10-03 13:09:37 -07:00
Tyler McMullen
79cea5e18b Implement jump tables (#453)
* Add 'jump_table_entry' and 'indirect_jump' instructions.

* Update CodeSink to keep track of code size. Pretty up clif-util's disassembly output.

* Only disassemble the machine portion of output. Pretty print the read-only data after it.

* Update switch frontend code to use new br_table instruction w/ default.
2018-10-03 10:04:21 -07:00
Benjamin Bouvier
de1d82b4ba Make SettingsError easier to diagnose; 2018-10-03 06:36:03 -07:00
Benjamin Bouvier
8b296e4874 Fixes #504: Implement Display/Fail for SetError and LookupError; 2018-10-03 06:36:03 -07:00
Benjamin Bouvier
0b3d3ac880 Remove logging levels restrictions (#538)
* Fixes #537: Remove release mode logging levels restrictions;

* Add information about log's logging levels in the README;
2018-10-02 10:45:23 -07:00
Dan Gohman
b94cf6c65b Rename test modules to "tests" for consistency.
The majority of the test modules were already named "tests", and that's
what the example in the Rust book uses, so switch to that for all test
modules, for consistency.
2018-09-28 14:50:01 -07:00
Dan Gohman
aa5ba71c97 Clarify the meaning of the symbol_value instruction. 2018-09-27 11:43:41 -07:00
Muhammad Mominul Huque
d266b1a42d Rename EntityMap to SecondaryMap (#528)
* Rename `EntityMap` to `SecondaryMap`
2018-09-26 12:03:44 -07:00
Dan Gohman
95e904da75 Merge branch 'master' into master 2018-09-25 16:12:26 -07:00
bjorn3
2eec1469a8 Legalize some more i8/i16 intructions (#524)
* Legalize some more i8/i16 intructions
2018-09-25 16:10:23 -07:00
Bruce Mitchener
81d6731e76 clippy: Remove explicit return statements. 2018-09-24 09:40:32 -07:00
Aaron Power
09f2b78b14 Added FunctionBuilder::{call_memcpy, call_memset, call_memmove} 2018-09-23 11:25:39 +01:00
Aaron Power
c187e7a345 Replaced LibCall's fmt::Display implementation 2018-09-22 21:43:31 -07:00
Dan Gohman
ab99720959 Bump version to 0.22.0 2018-09-21 21:39:41 -07:00
Dan Gohman
d514cec065 Avoid unneeded '&'s in let patterns. 2018-09-19 20:11:37 -07:00
Dan Gohman
53a0c6c67f Update to the rustfmt in rust 1.29, which is now stable. 2018-09-13 12:59:25 -07:00
Maddy
52e6b07058 Update the reload pass to replace copies with fill/spill instructions. 2018-09-12 14:15:45 -07:00
Dan Gohman
b4c7451ae5 Bump version to 0.21.1 2018-09-10 10:00:45 -07:00
Dan Gohman
608e74d8cb Document that b8 etc. are intended for use as SIMD elements. 2018-09-05 14:23:03 -07:00
Dan Gohman
e8878ba504 Bump version to 0.21.0 2018-09-04 22:04:22 -07:00
Dan Gohman
112e4a6083 Add a use std::vec::Vec; to fix the no_std build. 2018-09-04 21:57:32 -07:00
Dan Gohman
d4b8622393 Rename the VOID type to INVALID and clean up obsolete comments.
The VOID type isn't used for anything resembling what "void" means in C,
so rename it to INVALID to avoid confusion.
2018-09-04 21:46:22 -07:00
Dan Gohman
18900df4d5 Clean up obsolete comments. 2018-09-04 21:22:50 -07:00
Dan Gohman
ca9da7702e Reorganize the global value kinds. (#490)
* Reorganize the global value kinds.

This:
 - renames "deref" global values to "load" and gives it a offset that works
   like the "load" instructions' does
 - adds an explicit "iadd_imm" global value kind, which replaces the
   builtin iadd in "vmctx" and "deref" global values.
 - also renames "globalsym" to "symbol"
2018-09-04 21:09:04 -07:00
Aaron Power
17bb62c16c Added bitrev instruction for 32 and 64 bit integers (#486) 2018-09-04 16:23:50 -07:00
Kaz Wesley
7e571f4a49 Print value aliases at referrent definition (#492)
* Print value aliases at referrent definition

Closes #488.
2018-09-04 15:02:46 -07:00
Dan Gohman
c836a96e30 Bump cranelift-entity version to 0.20.1. 2018-08-28 20:19:09 -07:00
Dan Gohman
7fa0a38793 Bump version to 0.20.0 2018-08-28 16:37:52 -07:00
Dan Gohman
c23bfdaa91 Minor code simplification. 2018-08-28 16:24:10 -07:00
Dan Gohman
8e2d01a675 Add an index_type field to Table.
This parallels the `index_type` field in `Heap`.
2018-08-28 14:28:43 -07:00
Dan Gohman
eb439c9a68 Fix legalization of heap_addrs with 32-bit indices. (#480)
This makes several changes:
 - It adds an index_type to heap declarations, allowing heaps to specify the
   type for indexing. This also anticipates 64-bit heap support.

 - It adds a memory_type to deref global values, allowing deref globals to
   have types other than pointers. This is used to allow the bound variable
   in dynamic heaps to have type i32, to match the index type in heaps
   with i32 index type.

 - And, it fixes heap legalization to do the bounds check in the heap's
   index type.
2018-08-28 13:37:33 -07:00
Dan Gohman
6af407144c Remove Signature's argument_bytes field.
It's not currently used. If we do need such information, it would be
better to compute it on demand.
2018-08-28 13:19:59 -07:00
Grégoire Geis
0e67255f52 Fix error not reported if at least one other error expected. (#485)
* fix error not reported if at least one other error expected.

* Fixed unused extern crate error if wasm feature is not enabled.

* No longer reporting deref cycles multiple times.

* Fix filetest type_check.clif.

* Switched comparison order for perf.

* Fixed isa/riscv/verify-encoding.clif filetest.
2018-08-28 10:33:46 -07:00
Grégoire Geis
8e74a4f8fc Pretty printing preamble errors. (#472)
* Pretty printing preamble errors.
2018-08-27 09:38:44 -07:00
Dan Gohman
2c9b7fd73a Add "no-std" category to crates supporting no-std.
And add "wasm" category to cranelift-wasm.
2018-08-22 12:51:54 -07:00
Dan Gohman
ad170c7412 Update to log 0.4.4. 2018-08-17 12:04:01 -07:00
Dan Gohman
3d89a8645b Fix rustfmt errors. 2018-08-16 15:26:53 -07:00