bugfix with clz not being correct for u64
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 26 Sep 2022 19:19:22 +0000 (14:19 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 26 Sep 2022 19:19:22 +0000 (14:19 -0500)
compiler/src/checker.c
interpreter/src/vm/vm.c
shared/lib/linux_x86_64/lib/libovmwasm.so

index 80014d8b0c8667a917d5383524dfdc5e4cfe7118..b81cbbe962a9ab113921724a30ae964c9dca5559 100644 (file)
@@ -248,6 +248,10 @@ CheckStatus check_for(AstFor* fornode) {
         error_loc = fornode->token->pos;
     }
 
+    // @HACK This should be built elsewhere...
+    builtin_range_type_type = type_build_from_ast(context.ast_alloc, builtin_range_type);
+    if (builtin_range_type_type == NULL) YIELD(fornode->token->pos, "Waiting for 'range' structure to be built.");
+
     fornode->loop_type = For_Loop_Invalid;
     if (types_are_compatible(iter_type, &basic_types[Basic_Kind_I32])) {
         if (fornode->by_pointer) {
index 551c6caa023b3248c7b40b17cf1c3dd553b8c736..3a85c538e4dbd8ee52dea5e50273bed758d83876 100644 (file)
@@ -865,17 +865,17 @@ ovm_value_t ovm_run_code(ovm_engine_t *engine, ovm_state_t *state, ovm_program_t
             OVM_OP(OVMI_CLZ, OVM_TYPE_I8 , __builtin_clz, u8)
             OVM_OP(OVMI_CLZ, OVM_TYPE_I16, __builtin_clz, u16)
             OVM_OP(OVMI_CLZ, OVM_TYPE_I32, __builtin_clz, u32)
-            OVM_OP(OVMI_CLZ, OVM_TYPE_I64, __builtin_clz, u64)
+            OVM_OP(OVMI_CLZ, OVM_TYPE_I64, __builtin_clzll, u64)
 
             OVM_OP(OVMI_CTZ, OVM_TYPE_I8 , __builtin_ctz, u8)
             OVM_OP(OVMI_CTZ, OVM_TYPE_I16, __builtin_ctz, u16)
             OVM_OP(OVMI_CTZ, OVM_TYPE_I32, __builtin_ctz, u32)
-            OVM_OP(OVMI_CTZ, OVM_TYPE_I64, __builtin_ctz, u64)
+            OVM_OP(OVMI_CTZ, OVM_TYPE_I64, __builtin_ctzll, u64)
 
             OVM_OP(OVMI_POPCNT, OVM_TYPE_I8 , __builtin_popcount, u8)
             OVM_OP(OVMI_POPCNT, OVM_TYPE_I16, __builtin_popcount, u16)
             OVM_OP(OVMI_POPCNT, OVM_TYPE_I32, __builtin_popcount, u32)
-            OVM_OP(OVMI_POPCNT, OVM_TYPE_I64, __builtin_popcount, u64)
+            OVM_OP(OVMI_POPCNT, OVM_TYPE_I64, __builtin_popcountll, u64)
 
             OVM_OP(OVMI_ABS,     OVM_TYPE_F32, __ovm_abs, f32);
             OVM_OP(OVMI_NEG,     OVM_TYPE_F32, -, f32);
index 9779da0dd8a3fc5bea34bb81f6d24b8b580aa11b..bb90f89b5692c7b6157ae1f5a4033bd68fad1106 100755 (executable)
Binary files a/shared/lib/linux_x86_64/lib/libovmwasm.so and b/shared/lib/linux_x86_64/lib/libovmwasm.so differ