mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 21:58:20 +00:00
cargo clippy
This commit is contained in:
@@ -210,7 +210,7 @@ impl FuncTrampoline {
|
||||
fn generate_trampoline<'ctx>(
|
||||
trampoline_func: FunctionValue,
|
||||
func_sig: &FunctionType,
|
||||
func_attrs: &Vec<(Attribute, AttributeLoc)>,
|
||||
func_attrs: &[(Attribute, AttributeLoc)],
|
||||
context: &'ctx Context,
|
||||
intrinsics: &Intrinsics<'ctx>,
|
||||
) -> Result<(), CompileError> {
|
||||
@@ -318,9 +318,9 @@ fn generate_trampoline<'ctx>(
|
||||
let ptr = builder.build_pointer_cast(ptr, v.get_type().ptr_type(AddressSpace::Generic), "");
|
||||
builder.build_store(ptr, *v);
|
||||
if v.get_type() == intrinsics.i128_ty.as_basic_type_enum() {
|
||||
idx = idx + 1;
|
||||
idx += 1;
|
||||
}
|
||||
idx = idx + 1;
|
||||
idx += 1;
|
||||
});
|
||||
|
||||
builder.build_return(None);
|
||||
|
||||
@@ -227,17 +227,15 @@ pub fn args_to_call<'ctx>(
|
||||
None
|
||||
};
|
||||
|
||||
let values = std::iter::once(ctx_ptr.as_basic_value_enum()).chain(values.iter().map(|x| *x));
|
||||
let values = std::iter::once(ctx_ptr.as_basic_value_enum()).chain(values.iter().copied());
|
||||
|
||||
let values = if sret.is_some() {
|
||||
std::iter::once(sret.unwrap().as_basic_value_enum())
|
||||
if let Some(sret) = sret {
|
||||
std::iter::once(sret.as_basic_value_enum())
|
||||
.chain(values)
|
||||
.collect()
|
||||
} else {
|
||||
values.collect()
|
||||
};
|
||||
|
||||
values
|
||||
}
|
||||
}
|
||||
|
||||
// Given a CallSite, extract the returned values and return them in a Vec.
|
||||
@@ -315,7 +313,7 @@ pub fn rets_from_call<'ctx>(
|
||||
let (low, high) = split_i64(value);
|
||||
let low = casted(low.into(), func_sig.results()[0]);
|
||||
let high = casted(high.into(), func_sig.results()[1]);
|
||||
return vec![low.into(), high.into()];
|
||||
return vec![low, high];
|
||||
}
|
||||
if basic_value.get_type() == f32x2_ty {
|
||||
assert!(func_sig.results().len() == 2);
|
||||
@@ -341,35 +339,35 @@ pub fn rets_from_call<'ctx>(
|
||||
match func_sig_returns_bitwidths.as_slice() {
|
||||
[32, 64] | [64, 32] | [64, 64] => {
|
||||
assert!(func_sig.results().len() == 2);
|
||||
vec![rets[0].into(), rets[1].into()]
|
||||
vec![rets[0], rets[1]]
|
||||
}
|
||||
[32, 32, _]
|
||||
if rets[0].get_type() == intrinsics.f32_ty.vec_type(2).as_basic_type_enum() =>
|
||||
{
|
||||
assert!(func_sig.results().len() == 3);
|
||||
let (rets0, rets1) = extract_f32x2(rets[0].into_vector_value());
|
||||
vec![rets0.into(), rets1.into(), rets[1].into()]
|
||||
vec![rets0.into(), rets1.into(), rets[1]]
|
||||
}
|
||||
[32, 32, _] => {
|
||||
assert!(func_sig.results().len() == 3);
|
||||
let (low, high) = split_i64(rets[0].into_int_value());
|
||||
let low = casted(low.into(), func_sig.results()[0]);
|
||||
let high = casted(high.into(), func_sig.results()[1]);
|
||||
vec![low.into(), high.into(), rets[1].into()]
|
||||
vec![low, high, rets[1]]
|
||||
}
|
||||
[64, 32, 32]
|
||||
if rets[1].get_type() == intrinsics.f32_ty.vec_type(2).as_basic_type_enum() =>
|
||||
{
|
||||
assert!(func_sig.results().len() == 3);
|
||||
let (rets1, rets2) = extract_f32x2(rets[1].into_vector_value());
|
||||
vec![rets[0].into(), rets1.into(), rets2.into()]
|
||||
vec![rets[0], rets1.into(), rets2.into()]
|
||||
}
|
||||
[64, 32, 32] => {
|
||||
assert!(func_sig.results().len() == 3);
|
||||
let (rets1, rets2) = split_i64(rets[1].into_int_value());
|
||||
let rets1 = casted(rets1.into(), func_sig.results()[1]);
|
||||
let rets2 = casted(rets2.into(), func_sig.results()[2]);
|
||||
vec![rets[0].into(), rets1.into(), rets2.into()]
|
||||
vec![rets[0], rets1, rets2]
|
||||
}
|
||||
[32, 32, 32, 32] => {
|
||||
assert!(func_sig.results().len() == 4);
|
||||
@@ -395,7 +393,7 @@ pub fn rets_from_call<'ctx>(
|
||||
let high0 = casted(high0, func_sig.results()[1]);
|
||||
let low1 = casted(low1, func_sig.results()[2]);
|
||||
let high1 = casted(high1, func_sig.results()[3]);
|
||||
vec![low0.into(), high0.into(), low1.into(), high1.into()]
|
||||
vec![low0, high0, low1, high1]
|
||||
}
|
||||
_ => unreachable!("expected an sret for this type"),
|
||||
}
|
||||
@@ -430,7 +428,7 @@ pub fn rets_from_call<'ctx>(
|
||||
assert!(func_sig.results().len() == rets.len());
|
||||
rets
|
||||
} else {
|
||||
assert!(func_sig.results().len() == 0);
|
||||
assert!(func_sig.results().is_empty());
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ impl FuncTranslator {
|
||||
func_names: &SecondaryMap<FunctionIndex, String>,
|
||||
) -> Result<(CompiledFunction, CustomSections), CompileError> {
|
||||
// The function type, used for the callbacks.
|
||||
let function = CompiledFunctionKind::Local(local_func_index.clone());
|
||||
let function = CompiledFunctionKind::Local(*local_func_index);
|
||||
let func_index = wasm_module.func_index(*local_func_index);
|
||||
let func_name = &func_names[func_index];
|
||||
let module_name = match wasm_module.name.as_ref() {
|
||||
@@ -1155,13 +1155,12 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
self.intrinsics.i32_zero,
|
||||
"",
|
||||
);
|
||||
let vec = self.builder.build_insert_element(
|
||||
self.builder.build_insert_element(
|
||||
vec,
|
||||
second,
|
||||
self.intrinsics.i32_ty.const_int(1, false),
|
||||
"",
|
||||
);
|
||||
vec
|
||||
)
|
||||
};
|
||||
|
||||
let build_struct = |ty: StructType<'ctx>, values: &[BasicValueEnum<'ctx>]| {
|
||||
@@ -1325,7 +1324,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
);
|
||||
self.builder.build_return(Some(&struct_value));
|
||||
}
|
||||
results @ _ => {
|
||||
results => {
|
||||
let sret = self
|
||||
.function
|
||||
.get_first_param()
|
||||
@@ -1336,8 +1335,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
.get_element_type()
|
||||
.into_struct_type()
|
||||
.get_undef();
|
||||
let mut idx = 0;
|
||||
for (value, info) in results {
|
||||
for (idx, (value, info)) in results.iter().enumerate() {
|
||||
let one_value = self.apply_pending_canonicalization(*value, *info);
|
||||
let one_value = self.builder.build_bitcast(
|
||||
one_value,
|
||||
@@ -1349,7 +1347,6 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
|
||||
.build_insert_value(struct_value, one_value, idx as u32, "")
|
||||
.unwrap()
|
||||
.into_struct_value();
|
||||
idx = idx + 1;
|
||||
}
|
||||
self.builder.build_store(sret, struct_value);
|
||||
self.builder.build_return(None);
|
||||
|
||||
Reference in New Issue
Block a user