x64: Add most remaining AVX lowerings (#5819)
* x64: Add most remaining AVX lowerings This commit goes through `inst.isle` and adds a corresponding AVX lowering for most SSE lowerings. I opted to skip instructions where the SSE lowering didn't read/modify a register, such as `roundps`. I think that AVX will benefit these instructions when there's load-merging since AVX doesn't require alignment, but I've deferred that work to a future PR. Otherwise though in this PR I think all (or almost all) of the 3-operand forms of AVX instructions are supported with their SSE counterparts. This should ideally improve codegen slightly by removing register pressure and the need for `movdqa` between registers. I've attempted to ensure that there's at least one codegen test for all the new instructions. As a side note, the recent capstone integration into `precise-output` tests helped me catch a number of encoding bugs much earlier than otherwise, so I've found that incredibly useful in tests! * Move `vpinsr*` instructions to their own variant Use true `XmmMem` and `GprMem` types in the instruction as well to get more type-level safety for what goes where. * Remove `Inst::produces_const` accessor Instead of conditionally defining regalloc and various other operations instead add dedicated `MInst` variants for operations which are intended to produce a constant to have more clear interactions with regalloc and printing and such. * Fix tests * Register traps in `MachBuffer` for load-folding ops This adds a missing `add_trap` to encoding of VEX instructions with memory operands to ensure that if they cause a segfault that there's appropriate metadata for Wasmtime to understand that the instruction could in fact trap. This fixes a fuzz test case found locally where v8 trapped and Wasmtime didn't catch the signal and crashed the fuzzer.
This commit is contained in:
@@ -4860,6 +4860,20 @@ fn test_x64_emit() {
|
||||
"roundpd $0, %xmm15, %xmm15",
|
||||
));
|
||||
|
||||
// ========================================================
|
||||
// XmmRmRImmVex
|
||||
insns.push((
|
||||
Inst::XmmVexPinsr {
|
||||
op: AvxOpcode::Vpinsrb,
|
||||
dst: Writable::from_reg(Xmm::new(xmm13).unwrap()),
|
||||
src1: Xmm::new(xmm14).unwrap(),
|
||||
src2: GprMem::new(RegMem::reg(r15)).unwrap(),
|
||||
imm: 2,
|
||||
},
|
||||
"C4430920EF02",
|
||||
"vpinsrb $2 %xmm14, %r15, %xmm13",
|
||||
));
|
||||
|
||||
// ========================================================
|
||||
// Pertaining to atomics.
|
||||
let am1: SyntheticAmode =
|
||||
@@ -5135,6 +5149,7 @@ fn test_x64_emit() {
|
||||
isa_flag_builder.enable("has_ssse3").unwrap();
|
||||
isa_flag_builder.enable("has_sse41").unwrap();
|
||||
isa_flag_builder.enable("has_fma").unwrap();
|
||||
isa_flag_builder.enable("has_avx").unwrap();
|
||||
isa_flag_builder.enable("has_avx512bitalg").unwrap();
|
||||
isa_flag_builder.enable("has_avx512dq").unwrap();
|
||||
isa_flag_builder.enable("has_avx512f").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user