Add procs for wasm32

This commit is contained in:
gingerBill
2021-10-31 19:00:01 +00:00
parent fca7142a3c
commit 5f51337a01
4 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
//+build wasm32
package runtime
@(link_name="__ashlti3")
__ashlti3 :: proc "c" (a: i64, b: i32) -> i64 {
return a
}

View File

@@ -2011,6 +2011,9 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
str_lit("gnu_h2f_ieee"),
str_lit("gnu_f2h_ieee"),
str_lit("extendhfsf2"),
// WASM Specific
str_lit("__ashlti3"),
};
for (isize i = 0; i < gb_count_of(required_runtime_entities); i++) {
force_add_dependency_entity(c, c->info.runtime_package->scope, required_runtime_entities[i]);

View File

@@ -1053,6 +1053,11 @@ namespace lbAbiWasm32 {
}
lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) {
if (!is_return && type == LLVMIntTypeInContext(c, 128)) {
LLVMTypeRef cast_type = LLVMVectorType(LLVMInt64TypeInContext(c), 2);
return lb_arg_type_direct(type, cast_type, nullptr, nullptr);
}
if (!is_return && lb_sizeof(type) > 8) {
return lb_arg_type_indirect(type, nullptr);
}

View File

@@ -388,6 +388,12 @@ void lb_run_remove_unused_function_pass(LLVMModuleRef mod) {
name == "memcpy") {
continue;
}
if (is_arch_wasm()) {
if (name == "__ashlti3") {
LLVMSetLinkage(curr_func, LLVMExternalLinkage);
continue;
}
}
LLVMLinkage linkage = LLVMGetLinkage(curr_func);