mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-20 12:16:30 +00:00
remove panic and unimplemented in llvm-backend and runtime-core
This commit is contained in:
@ -1176,7 +1176,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
BasicTypeEnum::FloatType(float_ty) => {
|
BasicTypeEnum::FloatType(float_ty) => {
|
||||||
float_ty.const_float(0.0).as_basic_value_enum()
|
float_ty.const_float(0.0).as_basic_value_enum()
|
||||||
}
|
}
|
||||||
_ => unimplemented!(),
|
_ => {
|
||||||
|
return Err(CodegenError {
|
||||||
|
message: "Operator::End phi type unimplemented".to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
state.push1(placeholder_value);
|
state.push1(placeholder_value);
|
||||||
phi.as_instruction().erase_from_basic_block();
|
phi.as_instruction().erase_from_basic_block();
|
||||||
@ -1741,7 +1745,12 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
_ => value,
|
_ => value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => unimplemented!("multi-value returns"),
|
_ => {
|
||||||
|
return Err(CodegenError {
|
||||||
|
message: "Operator::CallIndirect multi-value returns unimplemented"
|
||||||
|
.to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6853,7 +6862,9 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
state.push1(result.try_as_basic_value().left().unwrap());
|
state.push1(result.try_as_basic_value().left().unwrap());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
unimplemented!("{:?}", op);
|
return Err(CodegenError {
|
||||||
|
message: format!("Operator {:?} unimplemented", op),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6876,7 +6887,11 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
|||||||
"return",
|
"return",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
_ => unimplemented!("multi-value returns not yet implemented"),
|
_ => {
|
||||||
|
return Err(CodegenError {
|
||||||
|
message: "multi-value returns not yet implemented".to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -7051,7 +7066,10 @@ impl ModuleCodeGenerator<LLVMFunctionCodeGenerator, LLVMBackend, CodegenError>
|
|||||||
self.context.as_ref().unwrap(),
|
self.context.as_ref().unwrap(),
|
||||||
self.builder.as_ref().unwrap(),
|
self.builder.as_ref().unwrap(),
|
||||||
self.intrinsics.as_ref().unwrap(),
|
self.intrinsics.as_ref().unwrap(),
|
||||||
);
|
)
|
||||||
|
.map_err(|e| CodegenError {
|
||||||
|
message: format!("trampolines generation error: {:?}", e),
|
||||||
|
})?;
|
||||||
|
|
||||||
if let Some(path) = unsafe { &crate::GLOBAL_OPTIONS.pre_opt_ir } {
|
if let Some(path) = unsafe { &crate::GLOBAL_OPTIONS.pre_opt_ir } {
|
||||||
self.module.print_to_file(path).unwrap();
|
self.module.print_to_file(path).unwrap();
|
||||||
|
@ -20,7 +20,7 @@ pub fn generate_trampolines(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
builder: &Builder,
|
builder: &Builder,
|
||||||
intrinsics: &Intrinsics,
|
intrinsics: &Intrinsics,
|
||||||
) {
|
) -> Result<(), String> {
|
||||||
for (sig_index, sig) in info.signatures.iter() {
|
for (sig_index, sig) in info.signatures.iter() {
|
||||||
let func_type = signatures[sig_index];
|
let func_type = signatures[sig_index];
|
||||||
|
|
||||||
@ -42,8 +42,9 @@ pub fn generate_trampolines(
|
|||||||
Some(Linkage::External),
|
Some(Linkage::External),
|
||||||
);
|
);
|
||||||
|
|
||||||
generate_trampoline(trampoline_func, sig, context, builder, intrinsics);
|
generate_trampoline(trampoline_func, sig, context, builder, intrinsics)?;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_trampoline(
|
fn generate_trampoline(
|
||||||
@ -52,7 +53,7 @@ fn generate_trampoline(
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
builder: &Builder,
|
builder: &Builder,
|
||||||
intrinsics: &Intrinsics,
|
intrinsics: &Intrinsics,
|
||||||
) {
|
) -> Result<(), String> {
|
||||||
let entry_block = context.append_basic_block(&trampoline_func, "entry");
|
let entry_block = context.append_basic_block(&trampoline_func, "entry");
|
||||||
builder.position_at_end(&entry_block);
|
builder.position_at_end(&entry_block);
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ fn generate_trampoline(
|
|||||||
args_ptr.into_pointer_value(),
|
args_ptr.into_pointer_value(),
|
||||||
returns_ptr.into_pointer_value(),
|
returns_ptr.into_pointer_value(),
|
||||||
),
|
),
|
||||||
_ => unimplemented!(),
|
_ => return Err("trampoline function unimplemented".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let cast_ptr_ty = |wasmer_ty| match wasmer_ty {
|
let cast_ptr_ty = |wasmer_ty| match wasmer_ty {
|
||||||
@ -108,8 +109,11 @@ fn generate_trampoline(
|
|||||||
call_site.try_as_basic_value().left().unwrap(),
|
call_site.try_as_basic_value().left().unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => unimplemented!("multi-value returns"),
|
_ => {
|
||||||
|
return Err("trampoline function multi-value returns".to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.build_return(None);
|
builder.build_return(None);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -392,14 +392,19 @@ pub fn read_module<
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn wp_type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
|
pub fn wp_type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
|
||||||
Ok(match ty {
|
match ty {
|
||||||
WpType::I32 => Type::I32,
|
WpType::I32 => Ok(Type::I32),
|
||||||
WpType::I64 => Type::I64,
|
WpType::I64 => Ok(Type::I64),
|
||||||
WpType::F32 => Type::F32,
|
WpType::F32 => Ok(Type::F32),
|
||||||
WpType::F64 => Type::F64,
|
WpType::F64 => Ok(Type::F64),
|
||||||
WpType::V128 => Type::V128,
|
WpType::V128 => Ok(Type::V128),
|
||||||
_ => panic!("broken invariant, invalid type"),
|
_ => {
|
||||||
})
|
return Err(BinaryReaderError {
|
||||||
|
message: "broken invariant, invalid type",
|
||||||
|
offset: -1isize as usize,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_to_wp_type(ty: Type) -> WpType {
|
pub fn type_to_wp_type(ty: Type) -> WpType {
|
||||||
|
Reference in New Issue
Block a user