Merge remote-tracking branch 'origin/master' into middleware

This commit is contained in:
losfair
2020-06-17 00:52:20 +08:00
143 changed files with 3449 additions and 2396 deletions

View File

@@ -112,7 +112,7 @@ impl Compiler for LLVMCompiler {
})
.collect::<PrimaryMap<LocalFunctionIndex, _>>();
Ok(Compilation::new(functions, module_custom_sections))
Ok(Compilation::new(functions, module_custom_sections, None))
}
fn compile_function_call_trampolines(

View File

@@ -63,7 +63,7 @@ pub fn func_type_to_llvm<'ctx>(
Type::I32 | Type::F32 => 32,
Type::I64 | Type::F64 => 64,
Type::V128 => 128,
Type::AnyRef => unimplemented!("anyref in the llvm backend"),
Type::ExternRef => unimplemented!("externref in the llvm backend"),
Type::FuncRef => unimplemented!("funcref in the llvm backend"),
})
.collect::<Vec<i32>>();
@@ -300,7 +300,7 @@ pub fn rets_from_call<'ctx>(
assert!(value.get_type() == intrinsics.i128_ty.as_basic_type_enum());
value
}
Type::AnyRef => unimplemented!("anyref in the llvm backend"),
Type::ExternRef => unimplemented!("externref in the llvm backend"),
Type::FuncRef => unimplemented!("funcref in the llvm backend"),
}
};
@@ -331,7 +331,7 @@ pub fn rets_from_call<'ctx>(
Type::I32 | Type::F32 => 32,
Type::I64 | Type::F64 => 64,
Type::V128 => 128,
Type::AnyRef => unimplemented!("anyref in the llvm backend"),
Type::ExternRef => unimplemented!("externref in the llvm backend"),
Type::FuncRef => unimplemented!("funcref in the llvm backend"),
})
.collect::<Vec<i32>>();

View File

@@ -2617,14 +2617,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let res = self.builder.build_int_mul(v1, v2, "");
self.state.push1(res);
}
Operator::I8x16Mul => {
let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
let (v1, _) = self.v128_into_i8x16(v1, i1);
let (v2, _) = self.v128_into_i8x16(v2, i2);
let res = self.builder.build_int_mul(v1, v2, "");
let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
self.state.push1(res);
}
// Operator::I8x16Mul => {
// let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
// let (v1, _) = self.v128_into_i8x16(v1, i1);
// let (v2, _) = self.v128_into_i8x16(v2, i2);
// let res = self.builder.build_int_mul(v1, v2, "");
// let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
// self.state.push1(res);
// }
Operator::I16x8Mul => {
let ((v1, i1), (v2, i2)) = self.state.pop2_extra()?;
let (v1, _) = self.v128_into_i16x8(v1, i1);
@@ -4964,36 +4964,36 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
);
self.state.push1(res);
}
Operator::I64x2TruncSatF64x2S => {
let (v, i) = self.state.pop1_extra()?;
let v = self.apply_pending_canonicalization(v, i);
let v = v.into_int_value();
let res = self.trunc_sat(
self.intrinsics.f64x2_ty,
self.intrinsics.i64x2_ty,
std::i64::MIN as u64,
std::i64::MAX as u64,
std::i64::MIN as u64,
std::i64::MAX as u64,
v,
);
self.state.push1(res);
}
Operator::I64x2TruncSatF64x2U => {
let (v, i) = self.state.pop1_extra()?;
let v = self.apply_pending_canonicalization(v, i);
let v = v.into_int_value();
let res = self.trunc_sat(
self.intrinsics.f64x2_ty,
self.intrinsics.i64x2_ty,
std::u64::MIN,
std::u64::MAX,
std::u64::MIN,
std::u64::MAX,
v,
);
self.state.push1(res);
}
// Operator::I64x2TruncSatF64x2S => {
// let (v, i) = self.state.pop1_extra()?;
// let v = self.apply_pending_canonicalization(v, i);
// let v = v.into_int_value();
// let res = self.trunc_sat(
// self.intrinsics.f64x2_ty,
// self.intrinsics.i64x2_ty,
// std::i64::MIN as u64,
// std::i64::MAX as u64,
// std::i64::MIN as u64,
// std::i64::MAX as u64,
// v,
// );
// self.state.push1(res);
// }
// Operator::I64x2TruncSatF64x2U => {
// let (v, i) = self.state.pop1_extra()?;
// let v = self.apply_pending_canonicalization(v, i);
// let v = v.into_int_value();
// let res = self.trunc_sat(
// self.intrinsics.f64x2_ty,
// self.intrinsics.i64x2_ty,
// std::u64::MIN,
// std::u64::MAX,
// std::u64::MIN,
// std::u64::MAX,
// v,
// );
// self.state.push1(res);
// }
Operator::I32TruncF32S => {
let v1 = self.state.pop1()?.into_float_value();
self.trap_if_not_representable_as_int(
@@ -5276,30 +5276,30 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
self.state.push1(res);
}
Operator::F64x2ConvertI64x2S => {
let v = self.state.pop1()?;
let v = self
.builder
.build_bitcast(v, self.intrinsics.i64x2_ty, "")
.into_vector_value();
let res = self
.builder
.build_signed_int_to_float(v, self.intrinsics.f64x2_ty, "");
let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
self.state.push1(res);
}
Operator::F64x2ConvertI64x2U => {
let v = self.state.pop1()?;
let v = self
.builder
.build_bitcast(v, self.intrinsics.i64x2_ty, "")
.into_vector_value();
let res = self
.builder
.build_unsigned_int_to_float(v, self.intrinsics.f64x2_ty, "");
let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
self.state.push1(res);
}
// Operator::F64x2ConvertI64x2S => {
// let v = self.state.pop1()?;
// let v = self
// .builder
// .build_bitcast(v, self.intrinsics.i64x2_ty, "")
// .into_vector_value();
// let res = self
// .builder
// .build_signed_int_to_float(v, self.intrinsics.f64x2_ty, "");
// let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
// self.state.push1(res);
// }
// Operator::F64x2ConvertI64x2U => {
// let v = self.state.pop1()?;
// let v = self
// .builder
// .build_bitcast(v, self.intrinsics.i64x2_ty, "")
// .into_vector_value();
// let res = self
// .builder
// .build_unsigned_int_to_float(v, self.intrinsics.f64x2_ty, "");
// let res = self.builder.build_bitcast(res, self.intrinsics.i128_ty, "");
// self.state.push1(res);
// }
Operator::I32ReinterpretF32 => {
let (v, i) = self.state.pop1_extra()?;
let v = self.apply_pending_canonicalization(v, i);
@@ -5880,10 +5880,8 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let res = self.builder.build_not(v, "");
self.state.push1(res);
}
Operator::I8x16AnyTrue
| Operator::I16x8AnyTrue
| Operator::I32x4AnyTrue
| Operator::I64x2AnyTrue => {
Operator::I8x16AnyTrue | Operator::I16x8AnyTrue | Operator::I32x4AnyTrue => {
// | Operator::I64x2AnyTrue
// Skip canonicalization, it never changes non-zero values to zero or vice versa.
let v = self.state.pop1()?.into_int_value();
let res = self.builder.build_int_compare(
@@ -5900,15 +5898,13 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
ExtraInfo::arithmetic_f32() | ExtraInfo::arithmetic_f64(),
);
}
Operator::I8x16AllTrue
| Operator::I16x8AllTrue
| Operator::I32x4AllTrue
| Operator::I64x2AllTrue => {
Operator::I8x16AllTrue | Operator::I16x8AllTrue | Operator::I32x4AllTrue => {
// | Operator::I64x2AllTrue
let vec_ty = match op {
Operator::I8x16AllTrue => self.intrinsics.i8x16_ty,
Operator::I16x8AllTrue => self.intrinsics.i16x8_ty,
Operator::I32x4AllTrue => self.intrinsics.i32x4_ty,
Operator::I64x2AllTrue => self.intrinsics.i64x2_ty,
// Operator::I64x2AllTrue => self.intrinsics.i64x2_ty,
_ => unreachable!(),
};
let (v, i) = self.state.pop1_extra()?;