Skip to content

Commit 3576d8c

Browse files
committed
Translate Wasm's widen instructions to Cranelift's [u|s]widen_[low|high]
1 parent f0b083c commit 3576d8c

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

cranelift/wasm/src/code_translator.rs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,17 +1582,39 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
15821582
let (a, b) = pop2_with_bitcast(state, I32X4, builder);
15831583
state.push1(builder.ins().unarrow(a, b))
15841584
}
1585-
Operator::I16x8WidenLowI8x16S { .. }
1586-
| Operator::I16x8WidenHighI8x16S { .. }
1587-
| Operator::I16x8WidenLowI8x16U { .. }
1588-
| Operator::I16x8WidenHighI8x16U { .. }
1589-
| Operator::I32x4WidenLowI16x8S { .. }
1590-
| Operator::I32x4WidenHighI16x8S { .. }
1591-
| Operator::I32x4WidenLowI16x8U { .. }
1592-
| Operator::I32x4WidenHighI16x8U { .. }
1593-
| Operator::I8x16Bitmask
1594-
| Operator::I16x8Bitmask
1595-
| Operator::I32x4Bitmask => {
1585+
Operator::I16x8WidenLowI8x16S => {
1586+
let a = pop1_with_bitcast(state, I8X16, builder);
1587+
state.push1(builder.ins().swiden_low(a))
1588+
}
1589+
Operator::I16x8WidenHighI8x16S => {
1590+
let a = pop1_with_bitcast(state, I8X16, builder);
1591+
state.push1(builder.ins().swiden_high(a))
1592+
}
1593+
Operator::I16x8WidenLowI8x16U => {
1594+
let a = pop1_with_bitcast(state, I8X16, builder);
1595+
state.push1(builder.ins().uwiden_low(a))
1596+
}
1597+
Operator::I16x8WidenHighI8x16U => {
1598+
let a = pop1_with_bitcast(state, I8X16, builder);
1599+
state.push1(builder.ins().uwiden_high(a))
1600+
}
1601+
Operator::I32x4WidenLowI16x8S => {
1602+
let a = pop1_with_bitcast(state, I16X8, builder);
1603+
state.push1(builder.ins().swiden_low(a))
1604+
}
1605+
Operator::I32x4WidenHighI16x8S => {
1606+
let a = pop1_with_bitcast(state, I16X8, builder);
1607+
state.push1(builder.ins().swiden_high(a))
1608+
}
1609+
Operator::I32x4WidenLowI16x8U => {
1610+
let a = pop1_with_bitcast(state, I16X8, builder);
1611+
state.push1(builder.ins().uwiden_low(a))
1612+
}
1613+
Operator::I32x4WidenHighI16x8U => {
1614+
let a = pop1_with_bitcast(state, I16X8, builder);
1615+
state.push1(builder.ins().uwiden_high(a))
1616+
}
1617+
Operator::I8x16Bitmask | Operator::I16x8Bitmask | Operator::I32x4Bitmask => {
15961618
return Err(wasm_unsupported!("proposed SIMD operator {:?}", op));
15971619
}
15981620

0 commit comments

Comments
 (0)