Commit Graph

2765 Commits

Author SHA1 Message Date
Andrew Brown
fe25abeb0d Add x86 encodings for vector copy, copy_nop, fill_nop 2019-09-19 12:04:14 -07:00
Andrew Brown
766cf8ddfd Add x86 implemention for SIMD iadd 2019-09-19 12:04:14 -07:00
Andrew Brown
cd426cb7bc Rename Uimm128 to V128Imm 2019-09-19 12:04:14 -07:00
Andrew Brown
6cbc6e8bfb Handle use of SIMD vector globals and locals 2019-09-19 12:04:14 -07:00
Andrew Brown
7e6913e362 Add x86 encodings for vector store, load, fill, spill, and regmove 2019-09-19 12:04:14 -07:00
Andrew Brown
ddd1680e76 Add V128 -> I8X16 type conversions 2019-09-19 12:04:14 -07:00
Andrew Brown
13ac951004 Allow global initialization of SIMD vectors 2019-09-19 12:04:14 -07:00
Wander Lairson Costa
1e74d01111 Check for types::INVALID in the function signature, resolves #493 (#1046) 2019-09-19 11:26:17 -07:00
Andrew Brown
20c67f243e Add boolean shuffle test 2019-09-19 10:53:40 -07:00
Andrew Brown
e72434e58f Add boolean encodings for x86
Includes and, or, xor, not, and regmove; TODO re-factor PerCpuModeEncodings to avoid code duplication
2019-09-19 10:53:40 -07:00
Andrew Brown
af1499ce99 Add x86 implementation of shuffle 2019-09-19 10:53:40 -07:00
julian-seward1
9e088e4164 Reorganise optimisation level settings, and make the insn shrink pass optional (#1044)
This patch:

* removes the "default" opt level, on the basis that it has no definition and
  is referred to nowhere in the compiler.

* renames the "fastest" level to "none".  The resulting set of transformations
  is unchanged.

* renames the "best" level to "speed_and_size".  The resulting set of
  transformations is unchanged.

* adds a new level, "speed".  This is the same as "speed_and_size" except that
  it omits transformations aimed only at reducing code size.  Currently it
  omits only the insn shrinking pass.
2019-09-19 18:51:25 +02:00
Joshua Nelson
59139c6c46 Add more documentation for entities, fixes #1038 (#1041)
Also fixes broken links to point to docs.rs; see
https://github.com/CraneStation/cranelift/pull/1041#issuecomment-532356880,
there doesn't currently seem to be a way to link to a type in a
dependent crate.
2019-09-18 16:48:57 -07:00
Joshua Nelson
e252e0f5b7 fix broken link in cranelift-object 2019-09-18 08:33:17 -07:00
Erin Power
3c6795decf Fixed broken pipe race condition in ensure_installed 2019-09-18 11:11:30 +02:00
AnthonyMikh
c0274eca24 Simplify and rename Stackmap::from_vec (#1032)
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2019-09-18 10:11:32 +02:00
bjorn3
add6a4f269 Correctly zero extend operand of fcvt_from_uint for 8ints and 16bit ints (#997)
Fixes #996
2019-09-18 10:06:15 +02:00
bookmoons
156938facf Continuous fuzzing with Fuzzit (#1042)
Enables automated fuzzing on Fuzzit. Runs fuzz regression tests
every push and PR. Runs full fuzzing every push. Fuzzit emails
if it finds crashes.

Uses the existing fuzz targets:
* translate-module - Fuzz valid WebAssembly modules.
* reader-parse - Fuzz IR text format parsing.
2019-09-18 14:35:30 +09:00
Andrew Brown
9b852fde09 Add verifier check to ensure each SIMD lane index is within bounds, fixes #1016 2019-09-17 09:29:36 -07:00
Wander Lairson Costa
863ac809d9 [codegen] Check for downcasting in bitcast instruction
Bitcasting to a smaller size is invalid.

closes #854
2019-09-17 17:07:07 +02:00
Erin Power
5426e42a27 Revert "Remove FunctionBuilderContext from API, and change FunctionBuilder API"
This reverts commit 39e638af99dbe6537bc935bfb1a74669b62877b3.
2019-09-17 08:58:46 +02:00
Till Schneidereit
8d62d5f724 Revert "Continuous fuzzing (#944)" (#1036)
This reverts commit 374fd238b06860a1e6e3f8bb9eb598afe91b90fe.
2019-09-17 15:06:37 +09:00
bookmoons
f8d0e6ecab Continuous fuzzing (#944)
Enables automated fuzzing on Fuzzit. Runs fuzz regression tests
every push and PR. Runs full fuzzing every push. Fuzzit emails
if it finds crashes.

Uses the existing fuzz targets:
* translate-module - Fuzz valid WebAssembly modules.
* reader-parse - Fuzz IR text format parsing.
2019-09-17 14:12:31 +09:00
Andy Wortman
99380fad1a Use 'xor r, r' to set registers to 0 instead of mov (#766) 2019-09-16 16:35:55 +02:00
julian-seward1
b95508c51a legalizer/split.rs: split_ebb_params: avoid pointless Vec allocations. (#1025)
This function is responsible for 2.2% of all heap allocation (calls) in CL.
This change avoids all of them in the (presumably) common case where none of
the parameters require splitting.  It also slightly reduces the compiler's
instruction count.
2019-09-16 15:01:07 +02:00
Wander Lairson Costa
a51606bfeb [frontend] Add message for pristine assertion violation
After we add any instruction to an EBB, we can't add EBB parameters
anymore. There is an assertion in `append_ebb_param` to detect this
error, but the backtrace generated doesn't give any hint what happened.

We add an error message to the assertion so the user can understand what
is wrong.

fixes #1003
2019-09-16 14:55:19 +02:00
Rett Berg
4aef679243 fix reflink in CONTRIBUTING.md 2019-09-16 10:45:51 +02:00
Ujjwal Sharma
3418fb6e18 [codegen] reintroduce support for carry and borrow instructions in RI… (#1005)
Reintroduce support for iadd carry variants and isub borrow variants for
RISC ISAs which had been removed in
https://github.com/CraneStation/cranelift/pull/961 and
https://github.com/CraneStation/cranelift/pull/962 because of the lack
of a proper flags register in RISC architectures.
2019-09-13 17:27:49 +02:00
Andrew Brown
cadd0ac655 Remove unused import when cross-compiling, fixes #1022 2019-09-12 09:28:39 -07:00
julian-seward1
92a01c816d Minor speedup tuning for SecondaryMap (#1020)
The `SecondaryMap` abstraction -- basically, resize-on-demand arrays with a
default value -- is very hot in Cranelift.  This small patch is the result of
many profiling runs.  It makes two changes:

* `fn index_mut` is changed to be `#[inline(always)]`, based on profile data.

* `fn index` and `fn index_mut` call `self.elems.resize()` directly, rather
  than via `self.resize()`.  The point of this is not to improve performance.
  Rather, it ensures that the public functions for `SecondaryMap` do not call
  each other.  When public interface functions call each other, it becomes
  difficult to interpret profiling results, because it's harder to see what
  fraction of costs for `SecondaryMap` as a whole come from outside the
  module, and what fraction is the result of "internal" calls to the external
  interface.

The overall result, for wasm_lua_binarytrees, is a 1.4% reduction in
instruction count for the compiler, and a 2.2% reduction in loads/stores.
2019-09-12 11:09:35 +02:00
Nicolas B. Pierron
e8dc9ad8c9 Fix x86/br-i128 test case to use basic blocks. 2019-09-11 20:24:48 +02:00
Wander Lairson Costa
35c6d869f5 Replace region::protect by make_exec in cranelift-filetests 2019-09-10 18:53:02 -07:00
Nicolas B. Pierron
abb157315b Basic Blocks: Fix frontend::sample_function test case. (#1007) 2019-09-10 15:02:11 -06:00
Benjamin Bouvier
cad2074587 [codegen] Don't simplify an operation if it would result in unnecessary legalization;
Converting something like iadd.i64 on a 32-bits architecture into a
iadd_imm.i64 will result in the instruction being legalized back to an
iadd.i64 later on, creating unnecessary churn.

This commit implements avoid doing so, and changes the target ISA to a
64-bits platform for tests than ran into this, as well as making sure
this won't happen on 32-bits platforms.
2019-09-10 19:50:34 +02:00
Benjamin Bouvier
3aa76b558c Legalize i64.const by breaking it into two i32.const, on 32-bits platforms; 2019-09-10 19:50:34 +02:00
Andrew Brown
6f1ed94e82 Fix documentation 2019-09-10 10:45:12 -07:00
Andrew Brown
295b2ef614 Avoid extra register movement when lowering an x86 insertlane to a float vector 2019-09-10 10:45:12 -07:00
Andrew Brown
3dfc68afb1 Avoid extra register movement when lowering the x86 scalar_to_vector of a float value 2019-09-10 10:45:12 -07:00
Andrew Brown
00bedca274 Avoid extra register movement when lowering the x86 extractlane of a float vector
This commit is based on the assumption that floats are already stored in XMM registers in x86. When extracting a lane, cranelift was moving the float to a regular register and back to an XMM register; this change avoids this by shuffling the float value to the lowest bits of the XMM register. It also assumes that the upper bits can be left as is (instead of zeroing them out).
2019-09-10 10:45:12 -07:00
Andrew Brown
f1363168a9 Translate the sign-extended and zero-extended versions of extract_lane 2019-09-10 10:45:12 -07:00
Andrew Brown
ebc783e49b Use raw_bitcast when legalizing splat
raw_bitcast matches the intent of this legalization more clearly (to simply change the CLIF type without changing any bits) and the additional null encodings added are necessary for later instructions
2019-09-10 10:45:12 -07:00
Andrew Brown
8a6686ec45 Enable SSSE3 setting when detected on CPU 2019-09-10 10:45:12 -07:00
Andrew Brown
7f152611a4 Log compiled and legalized functions 2019-09-10 10:45:12 -07:00
Sean Stangl
4b085b9cf7 Avoid unnecessary reallocations in domtree::with_function() (#1011) 2019-09-10 08:18:06 -06:00
julian-seward1
63367d205c Fix #975 (Structure of cranelift-wasm/src/translation_utils.rs causes many pointless heap allocations) (#1010)
This patch restricts the `Err(..)` return from `blocktype_to_type` to be
`Err(..)` only in the case where it really is an error to continue.  The three
use points of `blocktype_to_type` are changed to check for an `Err(..)` rather
than silently ignoring it.  There are also cosmetic changes to `type_to_type`
and `tabletype_to_type`.

When compiling wasm_lua_binarytrees, this reduces the number of blocks
allocated by CL by 1.9%.  Instruction count falls by 0.1%.

Details:

* `type_to_type` and `tabletype_to_type`:

   - Added the function name in the failure message

   - No functional change for non-error cases

   - Push the `Ok(..)` to expression leaves, where it really applies.  This
     corrects the misleading impression that, in the case of an unsupported
     type, the function returns `Ok` wrapped around whatever
     `wasm_unsupported` returns.  It doesn't do that, but it certainly reads
     like that.  This assumes that the LLVM backend will do tail merging, so
     the generated code will be unchanged.

* `blocktype_to_type`:

  - Change return type from `WasmResult<ir::Type>` to `WasmResult<Option<ir::Type>>`

  - Manually inline the call to `type_to_type`, to make this function easier
    to read.

  - For the non-error case: map `TypeOrFuncType::Type(Type::EmptyBlockType)`
    to `Ok(None)` rather than `Err(..)`, since that's what all the call sites
    expect - For the error cases, add the function name in the failure
    messages

* cranelift-wasm/src/code_translator.rs

  - For the three uses of `blocktype_to_type`, use `?` to detect failures and
    drop out immediately, meaning that the code will no longer silently ignore
    errors.
2019-09-10 15:06:10 +02:00
Nicolas B. Pierron
81fa5e7696 Add equivalent safepoint test cases for basic blocks. 2019-09-10 14:53:13 +02:00
Ujjwal Sharma
345b2dc0cc [codegen] add new recipe "rout" (#1014)
* [codegen] add new recipe "rout"

Add a new recipe "rout" intended to be used by arithematic operations
that output flags, currently being used for `iadd_cout` and `isub_bout`.

Fixes: https://github.com/CraneStation/cranelift/issues/1009
2019-09-10 12:55:24 +02:00
data-pup
ac2ca6116b allow module environment to parse name section 2019-09-10 11:30:54 +02:00
Philip Craig
3293ca6b69 Add cranelift-object 2019-09-09 21:54:20 -07:00
Nicolas B. Pierron
90b0b86f5c Simplify isa_builder macro 2019-09-09 13:30:02 +02:00