Explorar el Código

Add procs for wasm32

gingerBill hace 3 años
padre
commit
5f51337a01
Se han modificado 4 ficheros con 21 adiciones y 0 borrados
  1. 7 0
      core/runtime/procs_wasm32.odin
  2. 3 0
      src/checker.cpp
  3. 5 0
      src/llvm_abi.cpp
  4. 6 0
      src/llvm_backend_opt.cpp

+ 7 - 0
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
+}

+ 3 - 0
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]);

+ 5 - 0
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);
 		}

+ 6 - 0
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);