Fix types of SIMD or, xor, and

The operands of these bitwise instructions could have different types and still be valid Wasm (i.e. `v128`). Because of this, we must tell Cranelift to cast both operands to the same type--the default type, in this case. This undoes the work merged in https://github.com/bytecodealliance/cranelift/pull/1233.
This commit is contained in:
Andrew Brown
2020-03-09 11:25:29 -07:00
parent ebaf95e507
commit a2d388b593

View File

@@ -864,15 +864,15 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let (arg1, arg2) = state.pop2(); let (arg1, arg2) = state.pop2();
state.push1(builder.ins().iadd(arg1, arg2)); state.push1(builder.ins().iadd(arg1, arg2));
} }
Operator::I32And | Operator::I64And | Operator::V128And => { Operator::I32And | Operator::I64And => {
let (arg1, arg2) = state.pop2(); let (arg1, arg2) = state.pop2();
state.push1(builder.ins().band(arg1, arg2)); state.push1(builder.ins().band(arg1, arg2));
} }
Operator::I32Or | Operator::I64Or | Operator::V128Or => { Operator::I32Or | Operator::I64Or => {
let (arg1, arg2) = state.pop2(); let (arg1, arg2) = state.pop2();
state.push1(builder.ins().bor(arg1, arg2)); state.push1(builder.ins().bor(arg1, arg2));
} }
Operator::I32Xor | Operator::I64Xor | Operator::V128Xor => { Operator::I32Xor | Operator::I64Xor => {
let (arg1, arg2) = state.pop2(); let (arg1, arg2) = state.pop2();
state.push1(builder.ins().bxor(arg1, arg2)); state.push1(builder.ins().bxor(arg1, arg2));
} }
@@ -1331,6 +1331,18 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let (a, b) = pop2_with_bitcast(state, type_of(op), builder); let (a, b) = pop2_with_bitcast(state, type_of(op), builder);
state.push1(builder.ins().imul(a, b)) state.push1(builder.ins().imul(a, b))
} }
Operator::V128Or => {
let (a, b) = pop2_with_bitcast(state, type_of(op), builder);
state.push1(builder.ins().bor(a, b))
}
Operator::V128Xor => {
let (a, b) = pop2_with_bitcast(state, type_of(op), builder);
state.push1(builder.ins().bxor(a, b))
}
Operator::V128And => {
let (a, b) = pop2_with_bitcast(state, type_of(op), builder);
state.push1(builder.ins().band(a, b))
}
Operator::V128AndNot => { Operator::V128AndNot => {
let (a, b) = pop2_with_bitcast(state, type_of(op), builder); let (a, b) = pop2_with_bitcast(state, type_of(op), builder);
state.push1(builder.ins().band_not(a, b)) state.push1(builder.ins().band_not(a, b))