Commit Graph

7124 Commits

Author SHA1 Message Date
Nick Fitzgerald
43d2799fa2 clif-util: add the souper-to-peepmatic subcommand (#2200)
This adds a subcommand to the `clif-util` CLI for exposing the Souper->Peepmatic
translation machinery that was introduced in #2192.
2020-09-14 15:19:54 -05:00
Nick Fitzgerald
cb306fd514 Merge pull request #2192 from fitzgen/souper-to-peepmatic
Convert Souper optimizations to Peepmatic DSL
2020-09-11 14:54:36 -07:00
Nick Fitzgerald
39600437d9 peepmatic-souper: Clean up souper-to-peepmatic name conversion 2020-09-11 14:20:40 -07:00
Nick Fitzgerald
fa6db181a2 Canonicalize commutative instructions to _imm form during Souper->Peepmatic 2020-09-11 14:17:19 -07:00
Johnnie Birch
07d0d32b69 Adds i64x2.mul for the new backend targeting x64 2020-09-11 13:17:42 -07:00
Chris Fallin
91da85b6bd Merge pull request #2195 from bnjbvr/x64-refactor
machinst x64: two optimizations
2020-09-11 11:21:30 -07:00
Joey Gouly
22369cfa0d arm64: Combine mul + add into madd
Copyright (c) 2020, Arm Limited.
2020-09-11 18:06:19 +01:00
Benjamin Bouvier
3849dc18b1 machinst x64: revamp integer immediate emission;
In particular:

- try to optimize the integer emission into a 32-bit emission, when the
high bits are all zero, and stop relying on the caller of `imm_r` to
ensure this.
- rename `Inst::imm_r`/`Inst::Imm_R` to `Inst::imm`/`Inst::Imm`.
- generate a sign-extending mov 32-bit immediate to 64-bits, whenever
possible.
- fix a few places where the previous commit did introduce the
generation of zero-constants with xor, when calling `put_input_to_reg`,
thus clobbering the flags before they were read.
2020-09-11 18:13:30 +02:00
Benjamin Bouvier
d9052d0a9c machinst x64: generate copies of constants during lowering; 2020-09-11 17:41:44 +02:00
Benjamin Bouvier
cace32746f machinst x64: pattern-match addresses that are base+cst index; 2020-09-11 17:41:44 +02:00
Nick Fitzgerald
79d452ae7c Merge pull request #2194 from bnjbvr/wasm-multivalue-truncate-after-if
wasm: Remove duplicated parameters when popping an If
2020-09-11 08:34:26 -07:00
Benjamin Bouvier
518b7a7e23 wasm: Remove duplicated parameters when popping an If
Parameters are duplicated when pushing an If block, so they're available
to the Else block without an extra heap allocation. However, when
truncating the stack after popping the If control frame, the stack size
at entry doesn't account for the duplicated parameters. That is
intentional: the Else block uses this value to know what's the stack
size when it is entered, so there's nothing to change there.

This patch makes the wasm translation truncates the value stack to the
right size after an If block, by taking those duplicated parameters into
account.
2020-09-11 13:12:48 +02:00
Nick Fitzgerald
091de9449a Convert Souper optimizations into Peepmatic DSL
Conversion from Souper into Peepmatic is implemented with a straightforward,
top-down recursive traversal of the optimization's left- and right-hand side
expression DAGs. Most Souper instructions have a corresponding Peepmatic
instruction. If we run into an instruction where that isn't the case, we skip
that Souper optimization and move on to the next one.

Note that Souper fully supports DAGs, for example:

```text
%0 = var
%1 = add 1, %0
%2 = add %1, %1       ;; Two edges to `%1` makes this a DAG.
```

On the other hand, Peepmatic only currently supports trees, so shared
subexpressions are duplicated:

```text
(iadd (iadd 1 $x)
      (iadd 1 $x))    ;; The shared subexpression is duplicated.
```

This does not affect correctness.
2020-09-10 16:06:30 -07:00
Nick Fitzgerald
443965b95d Create a crate for converting Souper optimizations into Peepmatic DSL
This crate is currently empty but is hooked up to our CI, the cargo workspace,
our publish script, etc.
2020-09-10 16:06:30 -07:00
Chris Fallin
ae6693a638 Merge pull request #2193 from cfallin/min-rust-1.43
Update minimum Rust version in CI to 1.43.0.
2020-09-10 16:05:57 -07:00
Chris Fallin
3775276050 Update minimum Rust version in CI to 1.43.0.
Firefox currently requires vendored Rust code (including Cranelift) to
compile on Rust 1.43.0, according to this line:

https://searchfox.org/mozilla-central/rev/eb9d5c97927aea75f0c8e38bbc5b5d288099e687/python/mozboot/mozboot/util.py#16

Whenever that version is updated, we can bump this CI check's Rust
version accordingly.
2020-09-10 15:29:07 -07:00
Chris Fallin
170a8112c2 Merge pull request #2191 from bnjbvr/x64-fix-multivalue-store
machinst x64: fix gen_store_base_offset for multi-value returns
2020-09-10 09:00:26 -07:00
Benjamin Bouvier
a1bdf11602 machinst x64: fix gen_store_base_offset for multi-value returns;
The previous method assumed that this could be used only for I64 values,
but this is actually used for multi-value returns, which can have any
type.
2020-09-10 11:17:41 +02:00
Chris Fallin
bd3ba0a774 Merge pull request #2189 from bnjbvr/x64-refactor-sub
machinst x64: a few small refactorings/renamings
2020-09-09 12:40:59 -07:00
Alex Crichton
b189321d61 Actually add instantiate-maybe-invalid fuzz target (#2190)
Forgot to add it to the manifest so it didn't actually get built!
2020-09-09 12:09:04 -05:00
Benjamin Bouvier
b4a2dd37a4 machinst x64: rename input_to_reg to put_input_to_reg;
Eventually, we should be able to unify this function's implementation
with the aarch64 one; but the latter does much more, and this would
require abstractions brought up in another pending PR#2142.
2020-09-09 18:03:59 +02:00
Benjamin Bouvier
cb96d16ac7 machinst x64: inline helper used only once; 2020-09-09 18:03:59 +02:00
Benjamin Bouvier
7a833f442a machinst: common up some instruction data helpers; 2020-09-09 18:03:59 +02:00
Benjamin Bouvier
a835c247c0 machinst: make get_output_reg target independent; 2020-09-09 18:03:59 +02:00
Benjamin Bouvier
6a3c4fb54e machinst x64: rename output_to_reg to get_output_reg; 2020-09-09 18:03:59 +02:00
Benjamin Bouvier
9620ce6bdf machinst x64: mask shift count too; 2020-09-09 18:03:59 +02:00
Benjamin Bouvier
9c328cc64b machinst x64: Remove unfinished comment; 2020-09-09 18:03:59 +02:00
Chris Fallin
d52797a257 Merge pull request #2188 from akirilov-arm/doom3
AArch64: Add various missing SIMD bits
2020-09-09 08:33:41 -07:00
Anton Kirilov
f612e8e7b2 AArch64: Add various missing SIMD bits
In addition, improve the code for stack pointer manipulation.

Copyright (c) 2020, Arm Limited.
2020-09-09 13:37:50 +01:00
Chris Fallin
074a0afa83 Merge pull request #2142 from cfallin/machinst-abi-x64
x64 new backend: port ABI implementation to shared infrastructure with AArch64.
2020-09-08 18:35:02 -07:00
Chris Fallin
e8f772c1ac x64 new backend: port ABI implementation to shared infrastructure with AArch64.
Previously, in #2128, we factored out a common "vanilla 64-bit ABI"
implementation from the AArch64 ABI code, with the idea that this should
be largely compatible with x64. This PR alters the new x64 backend to
make use of the shared infrastructure, removing the duplication that
existed previously. The generated code is nearly (not exactly) the same;
the only difference relates to how the clobber-save region is padded in
the prologue.

This also changes some register allocations in the aarch64 code because
call support in the shared ABI infra now passes a temp vreg in, rather
than requiring use of a fixed, non-allocable temp; tests have been
updated, and the runtime behavior is unchanged.
2020-09-08 17:59:01 -07:00
Nick Fitzgerald
3a602994e6 Merge pull request #2185 from alexcrichton/fuzz-maybe-invalid
Expand modules instantiated in instantiate-wasm-smith
2020-09-08 17:05:46 -07:00
Alex Crichton
38428e1fbb Expand modules instantiated in instantiate-wasm-smith
This commit uses the new `MaybeInvalidModule` type in `wasm-smith` to
try to explore more points in the fuzz target space in the
`instantiate-maybe-invalid` fuzz target. The goal here is to use the raw
fuzz input as the body of a function to stress the validator/decoder a
bit more, and try to get inputs we might not otherwise generate.
2020-09-08 14:29:27 -07:00
Chris Fallin
3d6c4d312f Merge pull request #2187 from akirilov-arm/ALUOp3
AArch64: Introduce an enum for ternary integer operations
2020-09-08 12:57:59 -07:00
Chris Fallin
e913bcb26a Merge pull request #2179 from jgouly/mvn
arm64: Don't always materialise a 64-bit constant
2020-09-08 09:17:08 -07:00
bjorn3
9428480230 Merge SignExtendAlAh and SignExtendRaxRdx 2020-09-08 15:00:24 +02:00
bjorn3
3dcda164dc Fix nits 2020-09-08 15:00:24 +02:00
bjorn3
9999913a31 Fix sign extension
Co-authored-by: Max Graey <maxgraey@gmail.com>
2020-09-08 15:00:24 +02:00
bjorn3
067255ef45 x64: Implement rotl and rotr for small integers 2020-09-08 15:00:24 +02:00
bjorn3
4251a950ba x64: Implement ishl, ushr and sshr for small integers 2020-09-08 15:00:24 +02:00
bjorn3
cc35f1e9bb x64: Misc small integer fixes 2020-09-08 15:00:24 +02:00
bjorn3
ce033f2a0c x64: Fix udiv and sdiv for 8bit integers 2020-09-08 15:00:24 +02:00
bjorn3
74642b166f x64: Implement ineg and bnot 2020-09-08 15:00:24 +02:00
bjorn3
f1fdd5764a Limit jump tables to 32bit in Switch
This is the maximum size supported by the x64 backend
2020-09-08 15:00:24 +02:00
Anton Kirilov
e92f949663 AArch64: Introduce an enum for ternary integer operations
This commit performs a small cleanup in the AArch64 backend - after
the MAdd and MSub variants have been extracted, the ALUOp enum is
used purely for binary integer operations.

Also, Inst::Mov has been renamed to Inst::Mov64 for consistency.

Copyright (c) 2020, Arm Limited.
2020-09-08 13:22:22 +01:00
Johnnie Birch
a64af55cda Adds x64 packed negation for the new backend 2020-09-07 11:56:05 -07:00
bjorn3
ba9908dd0f Don't substract 1 from end_addr in line program writing (#2174)
* Don't substract 1 from end_addr in line program writing

Fixes #2173

* add testcase for end_sequence having offset past retq (#1)

* Update tests/all/debug/translate.rs

Co-authored-by: Gabor Greif <ggreif@gmail.com>

Co-authored-by: Gabor Greif <ggreif@gmail.com>
2020-09-07 08:41:44 -05:00
Pat Hickey
48fab12142 Merge pull request #2160 from bytecodealliance/pch/wasi_common_array_writer
wasi-common: factor out common string array writer code
2020-09-03 18:01:04 -07:00
Pat Hickey
776f12ae3c tests: exercise array getters 2020-09-03 16:41:10 -07:00
Pat Hickey
580c236dee wiggle: implement array get/get_range in terms of ptr/add/as_array
hard to get it wrong when you use the safe primitives i already made!
2020-09-03 16:40:45 -07:00