4536 Commits

Author SHA1 Message Date
T0b1
a9d0dd56fb fix 2023-05-23 13:38:01 +02:00
T0b1
0df60ce50f custom regalloc 2023-04-27 16:16:48 +02:00
T0b1
3742c97bf0 better vcode printing 2023-04-27 16:14:28 +02:00
Alex Crichton
edae6c0217 x64: Add non-SSE4.1 lowerings of pmov{s,z}x* (#6279)
* x64: Add non-SSE4.1 lowerings of `pmov{s,z}x*`

This commit adds lowerings for a suite of sign/zero extension
instructions which don't require SSE4.1. Like before these lowerings are
based on LLVM's output.

This commit also deletes special casees for `i16x8.extmul_{low,high}_*`
since the output of the special case is the same as the default lowering
of all the component instructions used within as well.

* Remove SSE4.1 specialization of `uwiden_high`

LLVM prefers the `punpckh*`-based lowerings and at least according to
`llvm-mca` these are slightly better cycle-wise too.
2023-04-27 02:15:34 +00:00
Dan Gohman
ec6755512f Remove maintenance badges from the Cargo.toml files. (#6286)
Several of these badges were out of date, with some crates in wide production
use marked as "experimental". Insted of trying to keep them up to date, just
remove them, since they are [no longer displayed on crates.io].

[no longer displayed on crates.io]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section
2023-04-26 01:33:09 +00:00
Afonso Bordado
62cbb5045e riscv64: Implement a few SIMD arithmetic ops (#6268)
* riscv64: Swap order of `VecAluRRR` source registers

These were accidentally reversed from what we declare in the isle emit helper

* riscv64: Add SIMD `isub`

* riscv64: Add SIMD `imul`

* riscv64: Add `{u,s}mulhi`

* riscv64: Add `b{and,or,xor}`

* cranelift: Move `imul.i8x16` runtest to separate file

Looks like x86 does not implement it

* riscv64: Better formatting for `VecAluOpRRR`

* cranelift: Enable x86 SIMD tests with `has_sse41=false`
2023-04-25 16:39:33 +00:00
Afonso Bordado
4337ccd4b7 riscv64: Support non 128bit vector sizes (#6266)
* riscv64: Add `Zvl` extensions

* riscv64: Allow lowering SIMD operations that fit in a vector register

* riscv64: Support non 128bit vector sizes

* riscv64: Add Zvl Presets

* riscv64: Precompute `min_vec_reg_size`
2023-04-25 14:50:00 +00:00
Afonso Bordado
5113739601 riscv64: Enable more instructions in the fuzzer (#6271)
These have been fixed in the past, and I've been forgeting to re-enable them.
2023-04-25 11:03:16 +00:00
Alex Crichton
d2bb4aa13b x64: Add non-SSE4.1 lowering for pmulld (#6259)
Adds a lowering for SSE2 for i32x4-based multiplication which only first
became available in SSE4.1
2023-04-24 17:24:19 +00:00
yuyang
c9a9c2c191 Specify a read parameter for ISLE's Lexer. (#6123)
* fix col

* fix test failure

* specify read method.

* modify isle lexer

* remove a fn
2023-04-24 16:11:34 +00:00
Afonso Bordado
c14838d9e6 riscv64: Delete CSR Instructions (#6267) 2023-04-23 15:41:00 +00:00
bjorn3
91d1d246cd Allow serializing all cranelift-module data structures (#6172)
* Remove ModuleCompiledFunction

The same information can be retrieved using

ctx.compiled_code().unwrap().code_info().total_size

In addition for Module implementations that don't immediately compile the
given function there is no correct value that can be returned.

* Don't give anonymous functions and data objects an internal name

This internal name can conflict if a module is serialized and then
deserialized into another module. It also wasn't used by any of the
Module implementations anyway.

* Allow serializing all cranelift-module data structures

This allows a Module implementation to serialize it's internal state and
deserialize it in another compilation session. For example to implement
LTO or to load the module into cranelift-interpreter.

* Use expect
2023-04-21 12:39:15 +00:00
Trevor Elliott
d9e27c5441 Bump regalloc2 to 0.7.0 (#6237)
* Bump RA2 to 0.7.0

* Certify the RA2 update

* Import the rustc-hash audit

* Updates for regalloc2

prtest:full

* Update tests
2023-04-21 00:47:58 +00:00
Remo Senekowitsch
1192697c7e refactor BlockLoweringOrder::new (#6255)
Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com>
Co-authored-by: Moritz Waser <mzrw.dev@pm.me>
2023-04-20 22:24:32 +00:00
Trevor Elliott
e6339b2725 s390x: Remove uses of copy_reg (#6253)
* Remove uses of `copy_reg` in s390x lowerings

* Update tests

* Add one copy back in for smulhi to avoid an inserted move
2023-04-20 22:05:55 +00:00
Alex Crichton
a2a38edd8a x64: Add non-SSE 4.1 lowerings for v{all,any}_true (#6232)
This commit adds lowerings to the x64 backend for two more CLIF
instructions that currently require SSE 4.1. These lowerings are
inspired by LLVM's lowerings and avoid the use of SSE 4.1 instructions.
2023-04-20 21:56:59 +00:00
Afonso Bordado
60e4a00413 riscv64: Initial SIMD Vector Implementation (#6240)
* riscv64: Remove unused code

* riscv64: Add vector types

* riscv64: Initial Vector ABI Load/Stores

* riscv64: Vector Loads/Stores

* riscv64: Fix `vsetvli` encoding error

* riscv64: Add SIMD `iadd` runtests

* riscv64: Rename `VecSew`

The SEW name is correct, but only for VType. We also use this type
in loads/stores as the Efective Element Width, so the name isn't
quite correct in that case.

* ci: Add V extension to RISC-V QEMU

* riscv64: Misc Cleanups

* riscv64: Check V extension in `load`/`store` for SIMD

* riscv64: Fix `sumop` doc comment

* cranelift: Fix comment typo

* riscv64: Add convert for VType and VecElementWidth

* riscv64: Remove VecElementWidth converter
2023-04-20 21:54:43 +00:00
Trevor Elliott
7ad2fe32c9 aarch64: Avoid a copy in the extract_vector lowering (#6252)
* Avoid a move in the aarch64 lowering of extract_vector

* Update tests
2023-04-20 18:24:12 +00:00
Trevor Elliott
b667f5fa5b Avoid introducing a move for struct return (#6245)
* Move sret_reg handling to Lower:new, from gen_arg_setup

* Update exp files

* Review feedback

* Review feedback
2023-04-20 18:13:40 +00:00
Dan Gohman
c59bb8db39 Update several dependencies. (#6171)
This updates to rustix 0.37.13, which contains some features we can use to
implement more features in wasi-common for the wasi-sockets API. This also
pulls in several other updates to avoid having multiple versions of rustix.

This does introduce multiple versions of windows-sys, as the errno and tokio
crates are currently using 0.45 while rustix and other dependencies have
updated to 0.48; PRs updating these are already in flight so this will
hopefully be resolved soon.

It also includes cap-std 1.0.14, which disables the use of `openat2` and
`statx` on Android, fixing a bug where some Android devices crash the
process when those syscalls are executed.
2023-04-20 14:03:49 +00:00
Trevor Elliott
f89ac63766 riscv64: Remove the gen_move2 helper (#6246)
* Remove gen_move2 from riscv64

* Update exp files
2023-04-19 21:04:30 +00:00
Alex Crichton
b6bb6a196a Add support for binary/octal literals to ISLE (#6234)
* Add support for binary/octal literals to ISLE

In a number of x64-changes recently some u8 immediates are interpreted
as four bit-packed 2-bit numbers and I have a tough time going between
hex and these bit-packed numbers. I've been writing `0xAA == 0b...` in
comments to indicate the intent but I figured it'd be a bit clearer if
the binary literal was accepted directly!

This is a minor update to the ISLE lexer to allow for binary `0b00...`
and octal `0o00...` literals in the same manner as hex literals. Some
comments in the x64 backend are then removed to use the binary literal
syntax directly.

* Update ISLE reference for octal/binary

* Update ISLE tests for octal/binary
2023-04-18 23:04:04 +00:00
Trevor Elliott
c17a3d89f7 cranelift: Remove EBB references from docs (#6235)
* Remove ebb references from compare-llvm.md

* Remove EBB references from ir.md

* Remove EBB references from testing.md

* Fix grammar

* Clean up discussion of conditionals terminating BBs

* Remove a reference to boolean types
2023-04-18 23:01:45 +00:00
Alexa VanHattum
a486aa37ad Update doc for which integer types are supported (#6233)
* Update doc for which integer types are supported

* Update ir.md
2023-04-18 20:02:31 +00:00
Alex Crichton
62f8928bee x64: Add non-SSE4.1 lowerings of ceil/trunc/floor/nearest (#6224)
* x64: Add non-SSE4.1 lowerings of ceil/trunc/floor/nearest

This commit adds lowerings that work with SSE2 for CLIF `ceil`, `trunc`,
`floor`, and `nearest` instructions over vectors. To get these working
`insertlane` for float vectors was also implemented for non-SSE4.1
instructions as well.

Note that the goal of these lowerings is not speed but rather "it
works", so the decompose-to-call-libcalls logic for vector is probably
horrendously slow but should at least be correct.

* Skip new tests on riscv64

* Update cranelift/codegen/src/isa/x64/inst.isle

Co-authored-by: Andrew Brown <andrew.brown@intel.com>

---------

Co-authored-by: Andrew Brown <andrew.brown@intel.com>
2023-04-18 17:23:18 +00:00
T0b1-iOS
387db16d28 Remove unsigned variants of DataValue (#6218)
* remove unsigned variants of DataValue

* make value operation names more in-line with cranelift IR
2023-04-18 14:08:29 +00:00
Alex Crichton
7ebff82861 Optimize sign extension via shifts (#6220)
* Optimize sign extension via shifts

This commit adds egraph optimization patterns for left-shifting a value
and then right-shifting it as a form of sign extending its lower bits.
This matches the behavior of the WebAssembly `i32.extend8_s`
instruction, for example. Note that the lowering of that WebAssembly
instruction does not use shifts, but historical versions of LLVM that
didn't support the instruction, or versions with the instruction
disabled, will use shifts instead.

A second rule for reduction-of-extend being the same as the original
value was added to keep an existing shift-related test passing as well.

* Add reference assemblies for new opts
2023-04-17 18:48:08 +00:00
Alex Crichton
9a4bd7c6df x64: Begin to lift SSE 4.1 requirement for SIMD support (#6216)
* x64: Change `use_sse41` to a constructor

This refactors the existing `use_sse41` extractor to instead be a
`constructor` to use with `if-let`.

* x64: Gate the `pblendw` instruction on SSE4.1 being enabled

This specialization of `shuffle` isn't a base case so adding an `if-let`
here should be sufficient for gating this instruction properly on
enabled CPU features.

* x64: Gate `pmuldq` lowerings on SSE 4.1

The specialized rules using these instructions can fall back to the
standard lowerings for non-SSE 4.1 instructions.
2023-04-17 16:09:58 +00:00
kevaundray
85118c8c26 Add clippy suggestions (#6203)
* add clippy suggestions

* revert &/ref change

* Update cranelift/isle/isle/src/parser.rs

Co-authored-by: Jamey Sharp <jamey@minilop.net>

---------

Co-authored-by: Jamey Sharp <jamey@minilop.net>
2023-04-17 15:53:34 +00:00
Alex Crichton
91de5de049 Update wasm-tools crates (#6215)
While bringing in no major updates for Wasmtime I've taken this
opportunity to list myself for `cargo vet` with wildcard audits of this
family of crates. That means I shouldn't need to further add any more
entries in the future for updating these crates and additionally any
other organizations using these audits will automatically be able to
have audits for version that I publish.

While here I also ran `cargo vet prune` which was able to remove a
number of our exemptions.
2023-04-15 00:07:32 +00:00
Afonso Bordado
9e1ff9726c egraphs: Add bmask bit pattern optimization rule (#6196)
* egraphs: Add a bmask bit pattern optimization

* egraphs: Add more `ineg` rules

* egraphs: Add sshr rule

* egraphs: Simplify bmask rule

* egraphs: Add comutative version of bmask rule

* egraphs: Add more testcases

* egraphs: Cleanup rule comments

* egraphs: Add more `ineg` optimizations
2023-04-14 18:50:48 +00:00
Alex Crichton
2d25db047f x64: Lower SIMD requirement to SSE4.1 from SSE4.2 (#6206)
Cranelift only has one instruction SIMD which depends on SSE4.2 so this
commit adds a lowering rule for `pcmpgtq` which doesn't use SSE4.2 and
enables lowering the baseline requirement for SIMD support from SSE4.2
to SSE4.1.

The `has_sse42` setting is no longer enabled by default for Cranelift.
Additionally `enable_simd` no longer requires `has_sse42` on x64.
Finally the fuzz-generator for Wasmtime codegen settings now enables
flipping the `has_sse42` setting instead of unconditionally setting it
to `true`.

The specific lowering for `pcmpgtq` is copied from LLVM's lowering of
this instruction.
2023-04-14 17:24:43 +00:00
T0b1-iOS
3956a6aa0f remove unsigned_add_overflow_condition (#6199) 2023-04-13 14:30:44 +00:00
Karl Meakin
91e36f3449 Clarify the representation of icmp output (#6202)
* Clarify the representation of `icmp` output

* Reformat

* "ie" => "i.e."

* Update `fcmp` documentation as well
2023-04-12 20:05:44 +00:00
Karl Meakin
42528d82b8 Add multi_lane precondition to bitselect => {u,s}{min,max} rewrite (#6201) 2023-04-12 19:04:30 +00:00
T0b1-iOS
f684a5fbee remove iadd_cout and isub_bout (#6198) 2023-04-11 23:39:32 +00:00
Karl Meakin
c0166f78f9 ISLE: simplify select/bitselect when both choices are the same (#6141) 2023-04-11 22:41:19 +00:00
Karl Meakin
b9a58148cf ISLE: split algebraic.isle into several files (#6140)
* ISLE: split algebraic.isle into several files

* delete `algebraic.clif`

* Add `README.md`

* Remove old `algebraic.clif` tests

---------

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
2023-04-11 21:39:18 +00:00
T0b1-iOS
569089e473 Add {u,s}{add,sub,mul}_overflow instructions (#5784)
* add `{u,s}{add,sub,mul}_overflow` with interpreter

* add `{u,s}{add,sub,mul}_overflow` for x64

* add `{u,s}{add,sub,mul}_overflow` for aarch64

* 128bit filetests for `{u,s}{add,sub,mul}_overflow`

* `{u,s}{add,sub,mul}_overflow` emit tests for x64

* `{u,s}{add,sub,mul}_overflow` emit tests for aarch64

* Initial review changes

* add `with_flags_extended` helper

* add `with_flags_chained` helper
2023-04-11 20:16:04 +00:00
Afonso Bordado
4c32dd7786 riscv64: Delete SelectIf instruction (#5888)
* riscv64: Delete `SelectIf` instruction

* riscv64: Fix typo in comment

Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>

* riscv64: Improve `bmask` codegen

* riscv64: Use `lower_bmask` in `select_spectre_guard`

* riscv64: Use `lower_bmask` to extend values in `select_spectre_guard`

Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>

---------

Co-authored-by: Trevor Elliott <awesomelyawesome@gmail.com>
2023-04-11 17:33:32 +00:00
Afonso Bordado
9acb649f17 cranelift-native: Detect RISC-V extensions using /proc/cpuinfo (#6192)
* cranelift-native: Move riscv to separate module

* cranelift-native: Read /proc/cpuinfo to parse RISC-V extensions

* ci: Add QEMU cpuinfo emulation patch

This patch emulates the /proc/cpuinfo interface for RISC-V. This
allows us to do feature detection for the RISC-V backend.

It has been queued for QEMU 8.1 so we should remove it as soon as
that is available.

* ci: Enable QEMU RISC-V extensions

* cranelift-native: Cleanup ISA string parsing

Co-Authored-By: Jamey Sharp <jsharp@fastly.com>

* cranelift-native: Rework `/proc/cpuinfo` parsing

Co-Authored-By: Jamey Sharp <jsharp@fastly.com>

---------

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
2023-04-11 17:31:42 +00:00
kevaundray
f2393b8f27 Removes debug assertion that was related to issue 796 (#6175)
* fix typo: behaviour -> behavior

* remove debug assertion since 796 has been merged

* Update data_value.rs
2023-04-11 16:52:11 +00:00
bjorn3
0478ead3f8 Handle signature() for more libcalls (#6174)
* Handle signature() for more libcalls

This is necessary to be able to call them in the interpreter. All the
remaining libcalls which signature() doesn't handle are never used in
clif ir. Only in code compiled by a backend.

* Fix libcall declarations in cranelift-frontend

* Add function signatures

* Use correct pointer type instead of I64
2023-04-11 16:50:41 +00:00
bjorn3
52440f0fc8 Remove ImmutableRegisterState and replace {get,set}_value in State with current_frame{,_mut} (#6179)
* Remove ImmutableRegisterState

It was introduced for an SCCP optimization pass, but a simplified
version of this will likely use the egraph infrastructure instead.

* Replace {get,set}_value in State with current_frame{,_mut}

The outer Interpreter needs this anyway and only offering one way to
get locals simplifies things.

* Update comment
2023-04-11 12:15:22 +00:00
bjorn3
96a60aa26b Make cranelift-interpreter non-generic over value (#6178)
* Make cranelift-interpreter non-generic over value

Fixes #5793

* Review suggestion

Co-authored-by: Jamey Sharp <jamey@minilop.net>

* Fix fuzz target

* Update doc comments

---------

Co-authored-by: Jamey Sharp <jamey@minilop.net>
2023-04-11 11:13:29 +00:00
kevaundray
4053ae9e08 Minir typo/Grammar fixes (#6187)
* fix typo

* add test to check that Option<EntityRef> is twice as large as EntityRef

* grammar

* grammar

* reverse snakecase -- Not sure if folks want this type of change
2023-04-10 19:39:25 +00:00
Alex Crichton
435b6894d7 x64: Clarify and shrink up ModRM/SIB encoding (#6181)
I noticed recently that for the `ImmRegRegShift` addressing mode
Cranelift will unconditionally emit at least a 1-byte immediate for the
offset to be added to the register addition computation, even when the
offset is zero. In this case though the instruction encoding can be
slightly more compact and remove a byte. This commit started off by
applying this optimization, which resulted in the `*.clif` test changes
in this commit.

Further reading this code, however, I personally found it quite hard to
follow what was happening with all the various branches and ModRM/SIB
bits. I reviewed these encodings in the x64 architecture manual and
attempted to improve the logic for encoding here. The new version in
this commit is intended to be functionally equivalent to the prior
version where dropping a zero-offset from the `ImmRegRegShift` variant
is the only change.
2023-04-10 19:37:19 +00:00
Chris Fallin
8f1a7773a3 Revert "ISLE: rewrite loose inequalities to strict inequalities and strict inequalities to equalities (#6130)" (#6193)
This reverts commit 57e42d0c46.

Fixes #6185.
2023-04-10 18:43:15 +00:00
bjorn3
b9fb31e9a7 Re-export cranelift-control from cranelift-codegen (#6173)
This makes it easier to keep the versions of both in sync and avoids
having to specify another dependency for a single type.
2023-04-10 16:49:43 +00:00
Jamey Sharp
ac2bd1f305 cranelift: Rename a filetest with the wrong extension (#6190)
This test was committed with a `.isle` extension instead of `.clif`, so
it wasn't actually running in the test suite. Fortunately, it still
passes.
2023-04-10 16:27:42 +00:00