Commit Graph

250 Commits

Author SHA1 Message Date
Dan Gohman
b476f823d4 Update to target_lexicon 0.2.0. 2018-11-07 16:01:15 -08:00
Lachlan Sneff
3409af7c07 Add early-stage optimization crate (#556)
* Add simple constant folding and folding tests
2018-11-07 15:59:29 -08:00
Dan Gohman
bdcc06eb15 When lowering br_table to branches, delete the old jump tables.
This prevents codegen from emitting unused readonly data.
2018-11-07 11:49:51 +01:00
Dan Gohman
997424a4c5 Add more comments explaining ghost instructions. 2018-11-07 11:03:23 +01:00
Dan Gohman
26da67b394 Add a verifier check that ghost instructions don't have encodings. 2018-11-07 11:03:23 +01:00
Dan Gohman
88bbbca6cd Make regalloc visit fallthrough_return instructions.
Add an explicit "is_ghost" property to selected instructions, and use
that to determine whether reload and coloring should visit instructions.
This allows them to visit fallthrough_return instructions and insert
fills and register moves as needed.
2018-11-07 11:03:23 +01:00
Dan Gohman
681cb5e20a Assert that the non-fixed inputs to return match the function's signature. 2018-11-07 10:51:19 +01:00
Dan Gohman
05c0b3bdd1 Insert copies to support a value being used as multiple return values.
When one value is used multiple times for separate return values, we
need to copy it to produce a new value, so that each value can be
allocated a different register.
2018-11-07 10:51:19 +01:00
Benjamin Bouvier
bcbb2d01cc [build] Stop using Python code to generate the register files; 2018-11-06 13:12:17 -08:00
Benjamin Bouvier
b7f2acf0ea [build] Implement registers code generation in the Rust meta crate; 2018-11-06 13:12:17 -08:00
Benjamin Bouvier
4f2d7dd54f [build] Move Isa enum to the meta library; 2018-11-06 13:12:17 -08:00
Benjamin Bouvier
17e88ed1c5 [build] Use the Rust-generated types files in place of the Python one; 2018-11-06 13:12:17 -08:00
Dan Gohman
a5cad9a748 Fix a typo in a comment. 2018-11-02 13:56:38 -07:00
Dan Gohman
d4f8eb7453 Introduce a TargetFrontendConfig type. (#570)
* Introduce a `TargetFrontendConfig` type.

`TargetFrontendConfig` is information specific to the target which is
provided to frontends to allow them to produce Cranelift IR for the
target. Currently this includes the pointer size and the default calling
convention.

The default calling convention is now inferred from the target, rather
than being a setting. cranelift-native is now just a provider of target
information, rather than also being a provider of settings, which gives
it a clearer role.

And instead of having cranelift-frontend routines require the whole
`TargetIsa`, just require the `TargetFrontendConfig`, and add a way to
get the `TargetFrontendConfig` from a `Module`.

Fixes #529.
Fixes #555.
2018-11-02 13:51:42 -07:00
Joe Howarth
7094d9f470 Prefix verifier errors with ; (#585)
* Prefix verifier errors with ;

extract arrow drawing code into helper
print ; at beginning of line followed by arrow and error body
2018-11-02 13:47:39 -07:00
Dan Gohman
9471c06da4 Update to use newer Rust features.
This re-introduces several cleanups that we previously deferred for not
supporting Rust 1.25.
2018-10-31 12:54:16 -07:00
Dan Gohman
0b769f5020 Use Display rather than having an explicit name() function for types.
This is more idiomatic Rust.
2018-10-30 11:45:35 +01:00
theJosher
d2b3ff6183 Errors reported by mypy 0.641 #558 2018-10-29 19:53:43 -07:00
Dan Gohman
f1db50aa76 Fix constant-offset folding to use the correct operand for stores. 2018-10-29 16:18:12 +01:00
Dan Gieschen Knutson
a19c6088f0 use iterative rather than recursive method for following aliases (#573)
* use iterative rather than recursive method for following aliases

* this avoids consuming stack via plain recursive calls
2018-10-28 20:26:44 -07:00
Dan Gohman
1b21d3a90e Fix the path to cdsl/types.py in a comment. 2018-10-26 11:22:43 -07:00
Dan Gohman
a2fcb32245 Escape backslashes in Python comments.
The latest version of flake8 diagnoses these as invalid escape
sequences, so properly escape them.
2018-10-24 10:00:42 -07:00
Boris-Chengbiao Zhou
b288c6001a Fix all clippy warnings (#564)
* Fix all clippy warnings

* Revert usage of inclusive ranges

* Remove redundant function argument

* Revert use of unavailable pointer methods

* Introduce ContiguousCaseRange
2018-10-22 21:52:35 -07:00
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