diff --git a/core/runtime/procs_wasm32.odin b/core/runtime/procs_wasm32.odin new file mode 100644 index 000000000..dbc0dfcb7 --- /dev/null +++ b/core/runtime/procs_wasm32.odin @@ -0,0 +1,7 @@ +//+build wasm32 +package runtime + +@(link_name="__ashlti3") +__ashlti3 :: proc "c" (a: i64, b: i32) -> i64 { + return a +} \ No newline at end of file diff --git a/src/checker.cpp b/src/checker.cpp index 8db9e1bd6..f0f463816 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -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]); diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index ad8a45df7..9c7ced91e 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -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); } diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp index 8ddd3360d..75a377e5b 100644 --- a/src/llvm_backend_opt.cpp +++ b/src/llvm_backend_opt.cpp @@ -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);