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.
This commit is contained in:
@@ -1677,6 +1677,7 @@ fn define_simd(
|
||||
let uload32x2 = shared.by_name("uload32x2");
|
||||
let uload32x2_complex = shared.by_name("uload32x2_complex");
|
||||
let snarrow = shared.by_name("snarrow");
|
||||
let unarrow = shared.by_name("unarrow");
|
||||
let ushr_imm = shared.by_name("ushr_imm");
|
||||
let usub_sat = shared.by_name("usub_sat");
|
||||
let vconst = shared.by_name("vconst");
|
||||
@@ -1904,6 +1905,13 @@ fn define_simd(
|
||||
let snarrow = snarrow.bind(vector(*ty, sse_vector_size));
|
||||
e.enc_both_inferred(snarrow, rec_fa.opcodes(*opcodes));
|
||||
}
|
||||
for (ty, opcodes, isap) in &[
|
||||
(I16, &PACKUSWB[..], None),
|
||||
(I32, &PACKUSDW[..], Some(use_sse41_simd)),
|
||||
] {
|
||||
let unarrow = unarrow.bind(vector(*ty, sse_vector_size));
|
||||
e.enc_both_inferred_maybe_isap(unarrow, rec_fa.opcodes(*opcodes), *isap);
|
||||
}
|
||||
|
||||
// SIMD bitcast all 128-bit vectors to each other (for legalizing splat.x16x8).
|
||||
for from_type in ValueType::all_lane_types().filter(allowed_simd_type) {
|
||||
|
||||
@@ -314,7 +314,7 @@ pub static PABSD: [u8; 4] = [0x66, 0x0f, 0x38, 0x1e];
|
||||
/// xmm1 (SSSE3).
|
||||
pub static PABSW: [u8; 4] = [0x66, 0x0f, 0x38, 0x1d];
|
||||
|
||||
/// Converts 8 packed signed word integers from xmm1 and from xxm2/m128 into 16 packed signed byte
|
||||
/// Converts 8 packed signed word integers from xmm1 and from xmm2/m128 into 16 packed signed byte
|
||||
/// integers in xmm1 using signed saturation (SSE2).
|
||||
pub static PACKSSWB: [u8; 3] = [0x66, 0x0f, 0x63];
|
||||
|
||||
@@ -322,6 +322,14 @@ pub static PACKSSWB: [u8; 3] = [0x66, 0x0f, 0x63];
|
||||
/// word integers in xmm1 using signed saturation (SSE2).
|
||||
pub static PACKSSDW: [u8; 3] = [0x66, 0x0f, 0x6b];
|
||||
|
||||
/// Converts 8 packed signed word integers from xmm1 and from xmm2/m128 into 16 packed unsigned byte
|
||||
/// integers in xmm1 using unsigned saturation (SSE2).
|
||||
pub static PACKUSWB: [u8; 3] = [0x66, 0x0f, 0x67];
|
||||
|
||||
/// Converts 4 packed signed doubleword integers from xmm1 and from xmm2/m128 into 8 unpacked signed
|
||||
/// word integers in xmm1 using unsigned saturation (SSE4.1).
|
||||
pub static PACKUSDW: [u8; 4] = [0x66, 0x0f, 0x38, 0x2b];
|
||||
|
||||
/// Add packed byte integers from xmm2/m128 and xmm1 (SSE2).
|
||||
pub static PADDB: [u8; 3] = [0x66, 0x0f, 0xfc];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user