Implement the wasm sign-extension-ops proposal.
https://github.com/WebAssembly/sign-extension-ops/
This commit is contained in:
@@ -634,12 +634,35 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
let val = state.pop1();
|
let val = state.pop1();
|
||||||
state.push1(builder.ins().bitcast(I64, val));
|
state.push1(builder.ins().bitcast(I64, val));
|
||||||
}
|
}
|
||||||
Operator::I32Extend8S |
|
Operator::I32Extend8S => {
|
||||||
Operator::I32Extend16S |
|
let val = state.pop1();
|
||||||
Operator::I64Extend8S |
|
state.push1(builder.ins().ireduce(I8, val));
|
||||||
Operator::I64Extend16S |
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().sextend(I32, val));
|
||||||
|
}
|
||||||
|
Operator::I32Extend16S => {
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().ireduce(I16, val));
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().sextend(I32, val));
|
||||||
|
}
|
||||||
|
Operator::I64Extend8S => {
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().ireduce(I8, val));
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().sextend(I64, val));
|
||||||
|
}
|
||||||
|
Operator::I64Extend16S => {
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().ireduce(I8, val));
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().sextend(I64, val));
|
||||||
|
}
|
||||||
Operator::I64Extend32S => {
|
Operator::I64Extend32S => {
|
||||||
panic!("proposed sign-extend operators not yet supported");
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().ireduce(I32, val));
|
||||||
|
let val = state.pop1();
|
||||||
|
state.push1(builder.ins().sextend(I64, val));
|
||||||
}
|
}
|
||||||
/****************************** Binary Operators ************************************/
|
/****************************** Binary Operators ************************************/
|
||||||
Operator::I32Add | Operator::I64Add => {
|
Operator::I32Add | Operator::I64Add => {
|
||||||
|
|||||||
Reference in New Issue
Block a user