mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 00:00:49 +00:00
Reformat.
This commit is contained in:
parent
ea93b68165
commit
3e009c5971
@ -114,14 +114,22 @@ fn trunc_sat(
|
||||
let int_min_value = splat_vector(
|
||||
builder,
|
||||
intrinsics,
|
||||
ivec_ty.get_element_type().into_int_type().const_int(int_min_value, is_signed).as_basic_value_enum(),
|
||||
ivec_ty
|
||||
.get_element_type()
|
||||
.into_int_type()
|
||||
.const_int(int_min_value, is_signed)
|
||||
.as_basic_value_enum(),
|
||||
ivec_ty,
|
||||
"",
|
||||
);
|
||||
let int_max_value = splat_vector(
|
||||
builder,
|
||||
intrinsics,
|
||||
ivec_ty.get_element_type().into_int_type().const_int(int_max_value, is_signed).as_basic_value_enum(),
|
||||
ivec_ty
|
||||
.get_element_type()
|
||||
.into_int_type()
|
||||
.const_int(int_max_value, is_signed)
|
||||
.as_basic_value_enum(),
|
||||
ivec_ty,
|
||||
"",
|
||||
);
|
||||
@ -183,10 +191,15 @@ fn trunc_sat(
|
||||
"",
|
||||
);
|
||||
let nan_cmp = builder.build_float_compare(FloatPredicate::UNO, value, zero, "nan");
|
||||
let above_upper_bound_cmp = builder.build_float_compare(FloatPredicate::OGT, value, upper_bound, "above_upper_bound");
|
||||
let below_lower_bound_cmp = builder.build_float_compare(FloatPredicate::OLT, value, lower_bound, "below_lower_bound");
|
||||
let not_representable = builder
|
||||
.build_or(builder.build_or(nan_cmp, above_upper_bound_cmp, ""), below_lower_bound_cmp, "not_representable_as_int");
|
||||
let above_upper_bound_cmp =
|
||||
builder.build_float_compare(FloatPredicate::OGT, value, upper_bound, "above_upper_bound");
|
||||
let below_lower_bound_cmp =
|
||||
builder.build_float_compare(FloatPredicate::OLT, value, lower_bound, "below_lower_bound");
|
||||
let not_representable = builder.build_or(
|
||||
builder.build_or(nan_cmp, above_upper_bound_cmp, ""),
|
||||
below_lower_bound_cmp,
|
||||
"not_representable_as_int",
|
||||
);
|
||||
let value = builder
|
||||
.build_select(not_representable, zero, value, "safe_to_convert")
|
||||
.into_vector_value();
|
||||
@ -4120,10 +4133,24 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
let idx = builder
|
||||
.build_extract_element(v2, intrinsics.i32_ty.const_int(i, false), "idx")
|
||||
.into_int_value();
|
||||
let idx_out_of_range = builder.build_int_compare(IntPredicate::UGE, idx, lanes, "idx_out_of_range");
|
||||
let idx_clamped = builder.build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped").into_int_value();
|
||||
let elem = builder.build_extract_element(v1, idx_clamped, "elem").into_int_value();
|
||||
let elem_or_zero = builder.build_select(idx_out_of_range, intrinsics.i32_zero, elem, "elem_or_zero");
|
||||
let idx_out_of_range = builder.build_int_compare(
|
||||
IntPredicate::UGE,
|
||||
idx,
|
||||
lanes,
|
||||
"idx_out_of_range",
|
||||
);
|
||||
let idx_clamped = builder
|
||||
.build_select(idx_out_of_range, intrinsics.i32_zero, idx, "idx_clamped")
|
||||
.into_int_value();
|
||||
let elem = builder
|
||||
.build_extract_element(v1, idx_clamped, "elem")
|
||||
.into_int_value();
|
||||
let elem_or_zero = builder.build_select(
|
||||
idx_out_of_range,
|
||||
intrinsics.i32_zero,
|
||||
elem,
|
||||
"elem_or_zero",
|
||||
);
|
||||
res = builder.build_insert_element(
|
||||
res,
|
||||
elem_or_zero,
|
||||
|
@ -519,7 +519,12 @@ fn call_func_with_index(
|
||||
|
||||
let signature = &info.signatures[sig_index];
|
||||
let num_results = signature.returns().len();
|
||||
let num_results = num_results + signature.returns().iter().filter(|&&ty| ty == Type::V128).count();
|
||||
let num_results = num_results
|
||||
+ signature
|
||||
.returns()
|
||||
.iter()
|
||||
.filter(|&&ty| ty == Type::V128)
|
||||
.count();
|
||||
rets.reserve(num_results);
|
||||
|
||||
if !signature.check_param_value_types(args) {
|
||||
@ -548,17 +553,25 @@ fn call_func_with_index(
|
||||
let mut raw_args: SmallVec<[u64; 8]> = SmallVec::new();
|
||||
for v in args {
|
||||
match v {
|
||||
Value::I32(i) => { raw_args.push(*i as u64); }
|
||||
Value::I64(i) => { raw_args.push(*i as u64); }
|
||||
Value::F32(f) => { raw_args.push(f.to_bits() as u64); }
|
||||
Value::F64(f) => { raw_args.push(f.to_bits() as u64); }
|
||||
Value::I32(i) => {
|
||||
raw_args.push(*i as u64);
|
||||
}
|
||||
Value::I64(i) => {
|
||||
raw_args.push(*i as u64);
|
||||
}
|
||||
Value::F32(f) => {
|
||||
raw_args.push(f.to_bits() as u64);
|
||||
}
|
||||
Value::F64(f) => {
|
||||
raw_args.push(f.to_bits() as u64);
|
||||
}
|
||||
Value::V128(v) => {
|
||||
let bytes = v.to_le_bytes();
|
||||
let mut lo = [0u8; 8];
|
||||
lo.clone_from_slice(&bytes[0 .. 8]);
|
||||
lo.clone_from_slice(&bytes[0..8]);
|
||||
raw_args.push(u64::from_le_bytes(lo));
|
||||
let mut hi = [0u8; 8];
|
||||
hi.clone_from_slice(&bytes[8 .. 16]);
|
||||
hi.clone_from_slice(&bytes[8..16]);
|
||||
raw_args.push(u64::from_le_bytes(hi));
|
||||
}
|
||||
}
|
||||
@ -621,7 +634,10 @@ fn call_func_with_index(
|
||||
let mut bytes = [0u8; 16];
|
||||
let lo = result[0].to_le_bytes();
|
||||
let hi = result[1].to_le_bytes();
|
||||
for i in 0..8 { bytes[i] = lo[i]; bytes[i + 8] = hi[i]; }
|
||||
for i in 0..8 {
|
||||
bytes[i] = lo[i];
|
||||
bytes[i + 8] = hi[i];
|
||||
}
|
||||
rets.push(Value::V128(u128::from_le_bytes(bytes)));
|
||||
Ok(())
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs, io::Write};
|
||||
use wabt::script::{Action, Command, CommandKind, ModuleBinary, ScriptParser, Value};
|
||||
use wabt::{Features, wasm2wat_with_features};
|
||||
use wabt::{wasm2wat_with_features, Features};
|
||||
|
||||
static BANNER: &str = "// Rust test file autogenerated with cargo build (build/spectests.rs).
|
||||
// Please do NOT modify it by hand, as it will be reset on next build.\n";
|
||||
@ -309,8 +309,9 @@ impl WastTestGenerator {
|
||||
let source = fs::read(&path).unwrap();
|
||||
let mut features = wabt::Features::new();
|
||||
features.enable_simd();
|
||||
let script: ScriptParser = ScriptParser::from_source_and_name_with_features(&source, filename, features)
|
||||
.expect(&format!("Failed to parse script {}", &filename));
|
||||
let script: ScriptParser =
|
||||
ScriptParser::from_source_and_name_with_features(&source, filename, features)
|
||||
.expect(&format!("Failed to parse script {}", &filename));
|
||||
let buffer = String::new();
|
||||
WastTestGenerator {
|
||||
last_module: 0,
|
||||
@ -393,7 +394,8 @@ fn test_module_{}() {{
|
||||
let wasm_binary: Vec<u8> = module.clone().into_vec();
|
||||
let mut features = Features::new();
|
||||
features.enable_simd();
|
||||
let wast_string = wasm2wat_with_features(wasm_binary, features).expect("Can't convert back to wasm");
|
||||
let wast_string =
|
||||
wasm2wat_with_features(wasm_binary, features).expect("Can't convert back to wasm");
|
||||
let last_module = self.last_module;
|
||||
self.flush_module_calls(last_module);
|
||||
self.last_module = self.last_module + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user