Commit Graph

1012 Commits

Author SHA1 Message Date
Benjamin Bouvier
571061fe4c machinst x64: add support for rotations; 2020-07-16 18:21:06 +02:00
Benjamin Bouvier
22892466e7 machinst x64: fix implementation of *reduce;
They should just generate a plain move, since the high bits are then
ignored, and not an extended move.
2020-07-16 18:21:06 +02:00
MaxGraey
4564c396d2 Merge branch 'main' into peepmatic-bnot 2020-07-16 16:13:28 +03:00
MaxGraey
657aea5286 remove rule and tests 2020-07-16 14:56:11 +03:00
Andrew Brown
f0b083c6ad Legalize [u|s]widen_high for x86
Use `x86_palignr` and `[u|s]widen_low` for legalizing this instruction.
2020-07-15 11:32:08 -07:00
Andrew Brown
c8ddf8a34c Encode [u|s]widen_low for x86 2020-07-15 11:32:08 -07:00
Andrew Brown
fafef7db77 Add x86_palignr instructions
This instruction is necessary for implementing `[s|u]widen_high`.
2020-07-15 11:32:08 -07:00
Andrew Brown
0e5e8a62c8 Add DerivedFunction for doubling lane widths and halving the number of lanes (i.e. merging)
Certain operations (e.g. widening) will have operands with types like `NxM` but will return results with types like `(N*2)x(M/2)` (double the lane width, halve the number of lanes; maintain the same number of vector bits). This is equivalent to applying two `DerivedFunction`s to the type: `DerivedFunction::DoubleWidth` then `DerivedFunction::HalfVector`. Since there is no easy way to apply multiple `DerivedFunction`s (e.g. most of the logic is one-level deep, 1d5a678124/cranelift/codegen/meta/src/gen_inst.rs (L618-L621)), I added `DerivedFunction::MergeLanes` to do the necessary type conversion.
2020-07-15 11:32:08 -07:00
Chris Fallin
12a31c88d7 Merge pull request #2021 from akirilov-arm/VectorSize
AArch64: Introduce an enum to specify vector instruction operand sizes
2020-07-15 09:43:18 -07:00
MaxGraey
67b785d241 refactor: use different sections for this rule 2020-07-15 17:11:27 +03:00
Benjamin Bouvier
abf157bd69 machinst x64: Only use the feature flag to enable the x64 new backend;
Before this patch, running the x64 new backend would require both
compiling with --features experimental_x64 and running with
`use_new_backend`.

This patches changes this behavior so that the runtime flag is not
needed anymore: using the feature flag will enforce usage of the new
backend everywhere, making using and testing it much simpler:

    cargo run --features experimental_x64 ;; other CLI options/flags

This also gives a hint at what the meta language generation would look
like after switching to the new backend.

Compiling only with the x64 codegen flag gives a nice compile time speedup.
2020-07-15 13:11:28 +02:00
MaxGraey
5b38857e7f add bnot to peepmatic + transform rule 2020-07-15 13:46:25 +03:00
Anton Kirilov
95b0b05af2 AArch64: Introduce an enum to specify vector instruction operand sizes
Copyright (c) 2020, Arm Limited.
2020-07-14 21:37:44 +01:00
Anton Kirilov
400639245c AArch64: Remove show_freg_sized()
It provides the same functionality as show_vreg_scalar().

Copyright (c) 2020, Arm Limited.
2020-07-14 11:27:46 -07:00
Chris Fallin
4ba3ee3368 Merge pull request #2016 from jgouly/saturating-math
arm64: Implement saturating SIMD arithmetic
2020-07-14 11:24:10 -07:00
Joey Gouly
aa84a4173c arm64: Implement saturating SIMD arithmetic
Copyright (c) 2020, Arm Limited.
2020-07-14 18:19:11 +01:00
Chris Fallin
26529006e0 Address review comments. 2020-07-14 10:17:29 -07:00
Chris Fallin
08353fcc14 Reftypes part two: add support for stackmaps.
This commit adds support for generating stackmaps at safepoints to the
new backend framework and to the AArch64 backend in particular. It has
been tested to work with SpiderMonkey.
2020-07-14 10:17:27 -07:00
Chris Fallin
b93e8c296d Initial reftype support in aarch64, modulo safepoints.
This commit adds the inital support to allow reftypes to flow through
the program when targetting aarch64. It also adds a fix to the
`ModuleTranslationState` needed to send R32/R64 types over from the
SpiderMonkey embedding.

This commit does not include any support for safepoints in aarch64
or the `MachInst` infrastructure; that is in the next commit.

This commit also makes a drive-by improvement to `Bint`, avoiding an
unneeded zero-extension op when the extended value comes directly from a
conditional-set (which produces a full-width 0 or 1).
2020-07-14 10:14:18 -07:00
Anton Kirilov
79dfac5514 Refactor the InstSize enum in the AArch64 backend
The main issue with the InstSize enum was that it was used both for
GPR and SIMD & FP operands, even though machine instructions do not
mix them in general (as in a destination register is either a GPR
or not). As a result it had methods such as sf_bit() that made
sense only for one type of operand.

Another issue was that the enum name was not reflecting its purpose
accurately - it was meant to represent an instruction operand size,
not an instruction size, which is fixed in A64 (always 4 bytes).

Now the enum is split into one for GPR operands and another for
scalar SIMD & FP operands.

Copyright (c) 2020, Arm Limited.
2020-07-14 15:04:35 +01:00
Alex Crichton
85ffc8f595 Switch CI back to nightly channel (#2014)
* Switch CI back to nightly channel

I think all upstream issues are now fixed so we should be good to switch
back to nightly from our previously pinned version.

* Fix doc warnings
2020-07-13 18:40:47 -05:00
Chris Fallin
4b6ebc0c27 Merge pull request #1999 from bnjbvr/fix-aarch64-ishl-by-zero
machinst aarch64: fix encoding generation of left-shift by 0
2020-07-13 09:25:21 -07:00
Chris Fallin
f4f5eed254 Merge pull request #1977 from jgouly/simd_shift
arm64: Implement SIMD shift instructions
2020-07-13 09:24:19 -07:00
Yury Delendik
b2551bb4d0 Make wasmtime_environ::Module serializable (#2005)
* Define WasmType/WasmFuncType in the Cranelift
* Make `Module` serializable
2020-07-10 15:56:43 -05:00
Benjamin Bouvier
f316bef763 machinst aarch64: fix encoding generation of left-shift by 0;
The ARM book says that the immr field should contain (-count % 64); the
existing code was approximating this with (64 - count), which is not
correct for a zero count.
2020-07-09 15:43:42 +02:00
Andrew Brown
c5a69cee9f Add x86 legalization for fcvt_to_uint_sat.i32x4
This converts an `f32x4` into an `i32x4` (unsigned) with rounding by using a long sequence of SSE4.1 compatible instructions.
2020-07-08 10:20:01 -07:00
Peter Huene
d6ae72abe6 Merge pull request #1983 from peterhuene/fix-unwind-info
Remove 'set frame pointer' unwind code from Windows x64 unwind.
2020-07-06 22:26:41 -07:00
Peter Huene
92864baa1f Fix module doc comment. 2020-07-06 19:02:52 -07:00
Peter Huene
b1c7c1401e Fix incorrect scaling for SaveXmm128Far.
The `SaveXmm128Far` unwind op should have a 32-bit unscaled value.

The value was accidentally scaled down by 16 while calculating whether or not
the `SaveXmm128` or `SaveXmm128Far` unwind op should be used.
2020-07-06 18:52:16 -07:00
Nick Fitzgerald
62530e4d23 Merge pull request #1975 from MaxGraey/more-peephole-opts
peepmatic: add reminder by a power of two rule
2020-07-06 16:32:16 -07:00
MaxGraey
305659427d changes according review 2020-07-07 01:55:18 +03:00
Peter Huene
3a33749404 Remove 'set frame pointer' unwind code from Windows x64 unwind.
This commit removes the "set frame pointer" unwind code and frame
pointer information from Windows x64 unwind information.

In Windows x64 unwind information, a "frame pointer" is actually the
*base address* of the static part of the local frame and would be at some
negative offset to RSP upon establishing the frame pointer.

Currently Cranelift uses a "traditional" notion of a frame pointer, one
that is the highest address in the local frame (i.e. pointing at the
previous frame pointer on the stack).

Windows x64 unwind doesn't describe such frame pointers and only needs
one described if the frame contains a dynamic stack allocation.

Fixes #1967.
2020-07-06 14:22:57 -07:00
MaxGraey
2048278d2a typo 2020-07-03 21:45:40 +03:00
Joey Gouly
3a67d25ed6 arm64: Implement SIMD shift instructions
Copyright (c) 2020, Arm Limited.
2020-07-03 16:47:43 +01:00
Benjamin Bouvier
9d5be00de4 Address review comments
- put the division in the synthetic instruction as well,
- put the branch table check in the inst's emission code,
- replace OneWayCondJmp by TrapIf vcode instruction,
- add comments describing code generated by the synthetic instructions
2020-07-03 14:33:52 +02:00
Benjamin Bouvier
2115e70acb machinst x64: implement enough to support branch tables; 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
f86ecdcb86 machinst x64: lower and implement div/idiv; ADD TESTS 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
da30527368 machinst x64: implement one way conditional jmp 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
9d1bcfb2e8 machinst x64: implement cmov 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
bd88065571 machinst x64: lower binary ALU operators; 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
faeed3c7a4 machinst x64: implement spills and reloads 2020-07-03 14:33:52 +02:00
Benjamin Bouvier
08efcbd9d5 machinst x64: use movss for f32 loads; 2020-07-03 11:19:32 +02:00
MaxGraey
d21ca7f2a3 fixed added fits-in-native-word contrain 2020-07-03 11:46:37 +03:00
MaxGraey
1fcb215895 trailing new line 2020-07-03 11:03:03 +03:00
MaxGraey
1033cf5748 use (isub 1 $C) instead (iadd -1 $C) 2020-07-03 11:01:35 +03:00
MaxGraey
d839d83f7e add reminder by a power of two peephole rule 2020-07-03 09:44:59 +03:00
Chris Fallin
b700646c93 Merge pull request #1962 from cfallin/aarch64-lowering-condbr
AArch64: avoid branches with explicit offsets at lowering stage.
2020-07-02 14:05:40 -07:00
Chris Fallin
9bc0f3eceb Merge pull request #1966 from jgouly/simd-arith
arm64: Implement basic SIMD arithmetic
2020-07-02 11:07:14 -07:00
Chris Fallin
b7ecad1d74 AArch64: avoid branches with explicit offsets at lowering stage.
In discussions with @bnjbvr, it came up that generating `OneWayCondBr`s
with explicit, hardcoded PC-offsets as part of lowered instruction
sequences is actually unsafe, because the register allocator *might*
insert a spill or reload into the middle of our sequence. We were
careful about this in some cases but somehow missed that it was a
general restriction. Conceptually, all inter-instruction references
should be via labels at the VCode level; explicit offsets are only ever
known at emission time, and resolved by the `MachBuffer`.

To allow for conditional trap checks without modifying the CFG (as seen
by regalloc) during lowering, this PR instead adds a `TrapIf`
pseudo-instruction that conditionally skips a single embedded trap
instruction. It lowers to the same `condbr label ; trap ; label: ...`
sequence, but without the hardcoded branch-target offset in the lowering
code.
2020-07-02 11:02:27 -07:00
Andrew Brown
057c93b64e Add unarrow instruction with x86 implementation
Adds a shared `unarrow` instruction in order to lower the Wasm SIMD specification's unsigned narrowing (see https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing). Additionally, this commit implements the instruction for x86 using PACKUSWB and PACKUSDW for the applicable encodings.
2020-07-02 09:35:45 -07:00