authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-07-05 15:28:13-05:00
committergravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-07-05 15:28:13-05:00
log0e5fa87ac9695378683e770fbe0d577521860d35
tree216ae76ac1afd63acb08a27550f3ef22afdbe38d
parent9b0868776646934bdec84888dabebbb2b8d9924e

Better hashing, new asserts failing


7 files changed, 238 insertions(+), 219 deletions(-)

src/stage1/analyze.cpp+209-175
...@@ -5507,34 +5507,48 @@ bool handle_is_ptr(CodeGen *g, ZigType *type_entry) {...@@ -5507,34 +5507,48 @@ bool handle_is_ptr(CodeGen *g, ZigType *type_entry) {
5507 zig_unreachable();5507 zig_unreachable();
5508}5508}
55095509
5510static uint32_t hash_ptr(void *ptr) {5510static const uint32_t HASH_INIT = 0x811c9dc5U;
5511 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);5511
5512template<typename T>
5513static uint32_t hash_combine(uint32_t hash, const T *value, size_t count = 1) {
5514 // Simple FNV32 hash
5515 size_t len = sizeof(T) * count;
5516 const unsigned char *char_bytes = (const unsigned char*)value;
5517 for (size_t c = 0; c < len; ++c) {
5518 hash ^= char_bytes[c];
5519 hash *= 0x01000193U;
5520 }
5521 return hash;
5522}
5523
5524static uint32_t hash_combine_bigint(uint32_t hash, const BigInt *value) {
5525 return hash_combine(hash, bigint_ptr(value), value->digit_count);
5512}5526}
55135527
5514static uint32_t hash_size(size_t x) {5528static uint32_t hash_combine_buf(uint32_t hash, const Buf *buf) {
5515 return (uint32_t)(x % UINT32_MAX);5529 return hash_combine(hash, buf_ptr(buf), buf_len(buf));
5516}5530}
55175531
5518uint32_t fn_table_entry_hash(ZigFn* value) {5532uint32_t fn_table_entry_hash(ZigFn* value) {
5519 return ptr_hash(value);5533 return hash_combine(HASH_INIT, &value);
5520}5534}
55215535
5522bool fn_table_entry_eql(ZigFn *a, ZigFn *b) {5536bool fn_table_entry_eql(ZigFn *a, ZigFn *b) {
5523 return ptr_eq(a, b);5537 return a == b;
5524}5538}
55255539
5526uint32_t fn_type_id_hash(FnTypeId *id) {5540uint32_t fn_type_id_hash(FnTypeId *id) {
5527 uint32_t result = 0;5541 uint32_t hash = HASH_INIT;
5528 result += ((uint32_t)(id->cc)) * (uint32_t)3349388391;5542 hash = hash_combine(hash, &id->cc);
5529 result += id->is_var_args ? (uint32_t)1931444534 : 0;5543 hash = hash_combine(hash, &id->is_var_args);
5530 result += hash_ptr(id->return_type);5544 hash = hash_combine(hash, &id->return_type);
5531 result += id->alignment * 0xd3b3f3e2;5545 hash = hash_combine(hash, &id->alignment);
5532 for (size_t i = 0; i < id->param_count; i += 1) {5546 for (size_t i = 0; i < id->param_count; i += 1) {
5533 FnTypeParamInfo *info = &id->param_info[i];5547 FnTypeParamInfo *info = &id->param_info[i];
5534 result += info->is_noalias ? (uint32_t)892356923 : 0;5548 hash = hash_combine(hash, &info->is_noalias);
5535 result += hash_ptr(info->type);5549 hash = hash_combine(hash, &info->type);
5536 }5550 }
5537 return result;5551 return hash;
5538}5552}
55395553
5540bool fn_type_id_eql(FnTypeId *a, FnTypeId *b) {5554bool fn_type_id_eql(FnTypeId *a, FnTypeId *b) {
...@@ -5559,194 +5573,202 @@ bool fn_type_id_eql(FnTypeId *a, FnTypeId *b) {...@@ -5559,194 +5573,202 @@ bool fn_type_id_eql(FnTypeId *a, FnTypeId *b) {
5559 return true;5573 return true;
5560}5574}
55615575
5562static uint32_t hash_const_val_error_set(ZigValue *const_val) {5576static uint32_t hash_combine_const_val_error_set(uint32_t hash_val, ZigValue *const_val) {
5563 assert(const_val->data.x_err_set != nullptr);5577 assert(const_val->data.x_err_set != nullptr);
5564 return const_val->data.x_err_set->value ^ 2630160122;5578 return hash_combine(hash_val, &const_val->data.x_err_set->value);
5565}5579}
55665580
5567static uint32_t hash_const_val_ptr(ZigValue *const_val) {5581static uint32_t hash_combine_const_val_ptr(uint32_t hash_val, ZigValue *const_val) {
5568 uint32_t hash_val = 0;5582 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.special);
5569 switch (const_val->data.x_ptr.mut) {
5570 case ConstPtrMutRuntimeVar:
5571 hash_val += (uint32_t)3500721036;
5572 break;
5573 case ConstPtrMutComptimeConst:
5574 hash_val += (uint32_t)4214318515;
5575 break;
5576 case ConstPtrMutInfer:
5577 case ConstPtrMutComptimeVar:
5578 hash_val += (uint32_t)1103195694;
5579 break;
5580 }
5581 switch (const_val->data.x_ptr.special) {5583 switch (const_val->data.x_ptr.special) {
5582 case ConstPtrSpecialInvalid:5584 case ConstPtrSpecialInvalid:
5583 zig_unreachable();5585 zig_unreachable();
5584 case ConstPtrSpecialRef:5586 case ConstPtrSpecialRef:
5585 hash_val += (uint32_t)2478261866;5587 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.ref.pointee);
5586 hash_val += hash_ptr(const_val->data.x_ptr.data.ref.pointee);
5587 return hash_val;5588 return hash_val;
5588 case ConstPtrSpecialBaseArray:5589 case ConstPtrSpecialBaseArray:
5589 hash_val += (uint32_t)1764906839;5590 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_array.array_val);
5590 hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val);5591 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_array.elem_index);
5591 hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index);
5592 return hash_val;5592 return hash_val;
5593 case ConstPtrSpecialSubArray:5593 case ConstPtrSpecialSubArray:
5594 hash_val += (uint32_t)2643358777;5594 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_array.array_val);
5595 hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val);5595 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_array.elem_index);
5596 hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index);
5597 return hash_val;5596 return hash_val;
5598 case ConstPtrSpecialBaseStruct:5597 case ConstPtrSpecialBaseStruct:
5599 hash_val += (uint32_t)3518317043;5598 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_struct.struct_val);
5600 hash_val += hash_ptr(const_val->data.x_ptr.data.base_struct.struct_val);5599 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_struct.field_index);
5601 hash_val += hash_size(const_val->data.x_ptr.data.base_struct.field_index);
5602 return hash_val;5600 return hash_val;
5603 case ConstPtrSpecialBaseErrorUnionCode:5601 case ConstPtrSpecialBaseErrorUnionCode:
5604 hash_val += (uint32_t)2994743799;5602 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_err_union_code.err_union_val);
5605 hash_val += hash_ptr(const_val->data.x_ptr.data.base_err_union_code.err_union_val);
5606 return hash_val;5603 return hash_val;
5607 case ConstPtrSpecialBaseErrorUnionPayload:5604 case ConstPtrSpecialBaseErrorUnionPayload:
5608 hash_val += (uint32_t)3456080131;5605 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_err_union_payload.err_union_val);
5609 hash_val += hash_ptr(const_val->data.x_ptr.data.base_err_union_payload.err_union_val);
5610 return hash_val;5606 return hash_val;
5611 case ConstPtrSpecialBaseOptionalPayload:5607 case ConstPtrSpecialBaseOptionalPayload:
5612 hash_val += (uint32_t)3163140517;5608 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.base_optional_payload.optional_val);
5613 hash_val += hash_ptr(const_val->data.x_ptr.data.base_optional_payload.optional_val);
5614 return hash_val;5609 return hash_val;
5615 case ConstPtrSpecialHardCodedAddr:5610 case ConstPtrSpecialHardCodedAddr:
5616 hash_val += (uint32_t)4048518294;5611 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.hard_coded_addr.addr);
5617 hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr);
5618 return hash_val;
5619 case ConstPtrSpecialDiscard:
5620 hash_val += 2010123162;
5621 return hash_val;5612 return hash_val;
5622 case ConstPtrSpecialFunction:5613 case ConstPtrSpecialFunction:
5623 hash_val += (uint32_t)2590901619;5614 hash_val = hash_combine(hash_val, &const_val->data.x_ptr.data.fn.fn_entry);
5624 hash_val += hash_ptr(const_val->data.x_ptr.data.fn.fn_entry);
5625 return hash_val;5615 return hash_val;
5616 case ConstPtrSpecialDiscard:
5626 case ConstPtrSpecialNull:5617 case ConstPtrSpecialNull:
5627 hash_val += (uint32_t)1486246455;5618 // No fields to hash
5628 return hash_val;5619 return hash_val;
5629 }5620 }
5630 zig_unreachable();5621 zig_unreachable();
5631}5622}
56325623
5633static uint32_t hash_const_val(ZigValue *const_val) {5624static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val);
5625static uint32_t hash_combine_const_val_array(uint32_t hash_val, ZigValue *array, size_t len) {
5626 if (array->data.x_array.special == ConstArraySpecialUndef) {
5627 char undef_tag = 56;
5628 return hash_combine(hash_val, &undef_tag);
5629 } else if (array->data.x_array.special == ConstArraySpecialBuf) {
5630 // Hash in a way that is compatible with standard byte arrays
5631 // If any of these asserts fails, the if after this needs to be modified
5632 // to handle the new type in SpecialBuf.
5633 assert(array->type->data.array.child_type->id == ZigTypeIdInt);
5634 assert(array->type->data.array.child_type->data.integral.bit_count == 8);
5635 assert(array->type->data.array.child_type->data.integral.is_signed == false);
5636 const char *buf_pos = buf_ptr(array->data.x_array.data.s_buf);
5637 const char *buf_end = buf_pos + buf_len(array->data.x_array.data.s_buf);
5638 while (buf_pos < buf_end) {
5639 hash_val = hash_combine(hash_val, buf_pos);
5640 buf_pos++;
5641 }
5642 return hash_val;
5643 } else if (array->type->data.array.child_type->id == ZigTypeIdInt &&
5644 array->type->data.array.child_type->data.integral.bit_count == 8 &&
5645 array->type->data.array.child_type->data.integral.is_signed == false) {
5646 // If the type is u8, we hash it as if it's a ConstArraySpecialBuf,
5647 // to maintain compatibility.
5648 ZigValue *elems = array->data.x_array.data.s_none.elements;
5649 for (size_t i = 0; i < len; i += 1) {
5650 ZigValue *value = &elems[i];
5651 assert(value->type == array->type->data.array.child_type);
5652 // N.B. Using char here instead of uint8_t to match the const char*
5653 // returned by buf_ptr.
5654 const char byte_value = (char) bigint_as_u8(&value->data.x_bigint);
5655 hash_val = hash_combine(hash_val, &byte_value);
5656 }
5657 return hash_val;
5658 } else {
5659 ZigValue *elems = array->data.x_array.data.s_none.elements;
5660 for (size_t i = 0; i < len; i += 1) {
5661 hash_val = hash_combine_const_val(hash_val, &elems[i]);
5662 }
5663 return hash_val;
5664 }
5665}
5666static uint32_t hash_combine_const_val(uint32_t hash_val, ZigValue *const_val) {
5667 hash_val = hash_combine(hash_val, &const_val->special);
5668 if (const_val->special == ConstValSpecialUndef) {
5669 return hash_val;
5670 }
5671 // if (const_val->special == ConstValSpecialLazy ||
5672 // const_val->special == ConstValSpecialRuntime) {
5673 // // NO_COMMIT verify this is correct
5674 // return hash_combine(hash_val, &const_val);
5675 // }
5676 if (const_val->special != ConstValSpecialStatic) {
5677 printf("\nInvalid special: %d\n", const_val->special);
5678 }
5634 assert(const_val->special == ConstValSpecialStatic);5679 assert(const_val->special == ConstValSpecialStatic);
5680 hash_val = hash_combine(hash_val, &const_val->type->id);
5635 switch (const_val->type->id) {5681 switch (const_val->type->id) {
5636 case ZigTypeIdOpaque:5682 case ZigTypeIdOpaque:
5637 zig_unreachable();5683 zig_unreachable();
5638 case ZigTypeIdBool:5684 case ZigTypeIdBool:
5639 return const_val->data.x_bool ? (uint32_t)127863866 : (uint32_t)215080464;5685 return hash_combine(hash_val, &const_val->data.x_bool);
5640 case ZigTypeIdMetaType:5686 case ZigTypeIdMetaType:
5641 return hash_ptr(const_val->data.x_type);5687 return hash_combine(hash_val, &const_val->data.x_type);
5642 case ZigTypeIdVoid:
5643 return (uint32_t)4149439618;
5644 case ZigTypeIdInt:5688 case ZigTypeIdInt:
5645 case ZigTypeIdComptimeInt:5689 case ZigTypeIdComptimeInt:
5646 {5690 return hash_combine_bigint(hash_val, &const_val->data.x_bigint);
5647 uint32_t result = 1331471175;
5648 for (size_t i = 0; i < const_val->data.x_bigint.digit_count; i += 1) {
5649 uint64_t digit = bigint_ptr(&const_val->data.x_bigint)[i];
5650 result ^= ((uint32_t)(digit >> 32)) ^ (uint32_t)(result);
5651 }
5652 return result;
5653 }
5654 case ZigTypeIdEnumLiteral:5691 case ZigTypeIdEnumLiteral:
5655 return buf_hash(const_val->data.x_enum_literal) * (uint32_t)2691276464;5692 return hash_combine_buf(hash_val, const_val->data.x_enum_literal);
5656 case ZigTypeIdEnum:5693 case ZigTypeIdEnum:
5657 {5694 return hash_combine_bigint(hash_val, &const_val->data.x_enum_tag);
5658 uint32_t result = 31643936;
5659 for (size_t i = 0; i < const_val->data.x_enum_tag.digit_count; i += 1) {
5660 uint64_t digit = bigint_ptr(&const_val->data.x_enum_tag)[i];
5661 result ^= ((uint32_t)(digit >> 32)) ^ (uint32_t)(result);
5662 }
5663 return result;
5664 }
5665 case ZigTypeIdFloat:5695 case ZigTypeIdFloat:
5696 hash_val = hash_combine(hash_val, &const_val->type->data.floating.bit_count);
5666 switch (const_val->type->data.floating.bit_count) {5697 switch (const_val->type->data.floating.bit_count) {
5667 case 16:5698 case 16: return hash_combine(hash_val, &const_val->data.x_f16);
5668 {5699 case 32: return hash_combine(hash_val, &const_val->data.x_f32);
5669 uint16_t result;5700 case 64: return hash_combine(hash_val, &const_val->data.x_f64);
5670 static_assert(sizeof(result) == sizeof(const_val->data.x_f16), "");5701 case 128: return hash_combine(hash_val, &const_val->data.x_f128);
5671 memcpy(&result, &const_val->data.x_f16, sizeof(result));5702 default: zig_unreachable();
5672 return result * 65537u;
5673 }
5674 case 32:
5675 {
5676 uint32_t result;
5677 memcpy(&result, &const_val->data.x_f32, 4);
5678 return result ^ 4084870010;
5679 }
5680 case 64:
5681 {
5682 uint32_t ints[2];
5683 memcpy(&ints[0], &const_val->data.x_f64, 8);
5684 return ints[0] ^ ints[1] ^ 0x22ed43c6;
5685 }
5686 case 128:
5687 {
5688 uint32_t ints[4];
5689 memcpy(&ints[0], &const_val->data.x_f128, 16);
5690 return ints[0] ^ ints[1] ^ ints[2] ^ ints[3] ^ 0xb5ffef27;
5691 }
5692 default:
5693 zig_unreachable();
5694 }5703 }
5695 case ZigTypeIdComptimeFloat:5704 case ZigTypeIdComptimeFloat:
5696 {5705 return hash_combine(hash_val, &const_val->data.x_bigfloat.value);
5697 float128_t f128 = bigfloat_to_f128(&const_val->data.x_bigfloat);
5698 uint32_t ints[4];
5699 memcpy(&ints[0], &f128, 16);
5700 return ints[0] ^ ints[1] ^ ints[2] ^ ints[3] ^ 0xed8b3dfb;
5701 }
5702 case ZigTypeIdFn:5706 case ZigTypeIdFn:
5703 assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst);5707 assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst);
5704 assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction);5708 assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction);
5705 return 3677364617 ^ hash_ptr(const_val->data.x_ptr.data.fn.fn_entry);5709 return hash_combine(hash_val, &const_val->data.x_ptr.data.fn.fn_entry);
5706 case ZigTypeIdPointer:5710 case ZigTypeIdPointer:
5707 return hash_const_val_ptr(const_val);5711 return hash_combine_const_val_ptr(hash_val, const_val);
5712 case ZigTypeIdVoid:
5708 case ZigTypeIdUndefined:5713 case ZigTypeIdUndefined:
5709 return 162837799;
5710 case ZigTypeIdNull:5714 case ZigTypeIdNull:
5711 return 844854567;5715 return hash_val;
5712 case ZigTypeIdArray:5716 case ZigTypeIdArray:
5713 // TODO better hashing algorithm5717 return hash_combine_const_val_array(hash_val, const_val, const_val->type->data.array.len);
5714 return 1166190605;5718 case ZigTypeIdStruct: {
5715 case ZigTypeIdStruct:5719 size_t field_count = const_val->type->data.structure.src_field_count;
5716 // TODO better hashing algorithm5720 for (size_t i = 0; i < field_count; i += 1) {
5717 return 1532530855;5721 ZigValue *field = const_val->data.x_struct.fields[i];
5718 case ZigTypeIdUnion:5722 hash_val = hash_combine_const_val(hash_val, field);
5719 // TODO better hashing algorithm5723 }
5720 return 2709806591;5724 return hash_val;
5725 }
5726 case ZigTypeIdUnion: {
5727 ConstUnionValue *union_value = &const_val->data.x_union;
5728 hash_val = hash_combine_bigint(hash_val, &union_value->tag);
5729 return hash_combine_const_val(hash_val, union_value->payload);
5730 }
5721 case ZigTypeIdOptional:5731 case ZigTypeIdOptional:
5722 if (get_src_ptr_type(const_val->type) != nullptr) {5732 if (get_src_ptr_type(const_val->type) != nullptr) {
5723 return hash_const_val_ptr(const_val) * (uint32_t)1992916303;5733 char tag = 1;
5734 hash_val = hash_combine(hash_val, &tag);
5735 return hash_combine_const_val_ptr(hash_val, const_val);
5724 } else if (const_val->type->data.maybe.child_type->id == ZigTypeIdErrorSet) {5736 } else if (const_val->type->data.maybe.child_type->id == ZigTypeIdErrorSet) {
5725 return hash_const_val_error_set(const_val) * (uint32_t)3147031929;5737 char tag = 2;
5738 hash_val = hash_combine(hash_val, &tag);
5739 return hash_combine_const_val_error_set(hash_val, const_val);
5740 } else if (const_val->data.x_optional) {
5741 char tag = 3;
5742 hash_val = hash_combine(hash_val, &tag);
5743 return hash_combine_const_val(hash_val, const_val->data.x_optional);
5726 } else {5744 } else {
5727 if (const_val->data.x_optional) {5745 char tag = 4;
5728 return hash_const_val(const_val->data.x_optional) * (uint32_t)1992916303;5746 hash_val = hash_combine(hash_val, &tag);
5729 } else {5747 return hash_val;
5730 return 4016830364;
5731 }
5732 }5748 }
5733 case ZigTypeIdErrorUnion:5749 case ZigTypeIdErrorUnion: {
5734 // TODO better hashing algorithm5750 bool is_err = const_val->data.x_err_union.error_set->data.x_err_set != nullptr;
5735 return 3415065496;5751 hash_val = hash_combine(hash_val, &is_err);
5752 if (is_err) {
5753 hash_val = hash_combine_const_val(hash_val, const_val->data.x_err_union.error_set);
5754 } else {
5755 hash_val = hash_combine_const_val(hash_val, const_val->data.x_err_union.payload);
5756 }
5757 return hash_val;
5758 }
5736 case ZigTypeIdErrorSet:5759 case ZigTypeIdErrorSet:
5737 return hash_const_val_error_set(const_val);5760 return hash_combine_const_val_error_set(hash_val, const_val);
5738 case ZigTypeIdVector:5761 case ZigTypeIdVector:
5739 // TODO better hashing algorithm5762 return hash_combine_const_val_array(hash_val, const_val, const_val->type->data.vector.len);
5740 return 3647867726;
5741 case ZigTypeIdFnFrame:5763 case ZigTypeIdFnFrame:
5742 // TODO better hashing algorithm5764 // TODO better hashing algorithm
5743 return 675741936;5765 return hash_val;
5744 case ZigTypeIdAnyFrame:5766 case ZigTypeIdAnyFrame:
5745 // TODO better hashing algorithm5767 // TODO better hashing algorithm
5746 return 3747294894;5768 return hash_val;
5747 case ZigTypeIdBoundFn: {5769 case ZigTypeIdBoundFn: {
5748 assert(const_val->data.x_bound_fn.fn != nullptr);5770 assert(const_val->data.x_bound_fn.fn != nullptr);
5749 return 3677364617 ^ hash_ptr(const_val->data.x_bound_fn.fn);5771 return hash_combine(hash_val, &const_val->data.x_bound_fn.fn);
5750 }5772 }
5751 case ZigTypeIdInvalid:5773 case ZigTypeIdInvalid:
5752 case ZigTypeIdUnreachable:5774 case ZigTypeIdUnreachable:
...@@ -5754,15 +5776,18 @@ static uint32_t hash_const_val(ZigValue *const_val) {...@@ -5754,15 +5776,18 @@ static uint32_t hash_const_val(ZigValue *const_val) {
5754 }5776 }
5755 zig_unreachable();5777 zig_unreachable();
5756}5778}
5779static uint32_t hash_const_val(ZigValue *const_val) {
5780 return hash_combine_const_val(HASH_INIT, const_val);
5781}
57575782
5758uint32_t generic_fn_type_id_hash(GenericFnTypeId *id) {5783uint32_t generic_fn_type_id_hash(GenericFnTypeId *id) {
5759 uint32_t result = 0;5784 uint32_t result = HASH_INIT;
5760 result += hash_ptr(id->fn_entry);5785 result = hash_combine(result, &id->fn_entry);
5761 for (size_t i = 0; i < id->param_count; i += 1) {5786 for (size_t i = 0; i < id->param_count; i += 1) {
5762 ZigValue *generic_param = &id->params[i];5787 ZigValue *generic_param = &id->params[i];
5763 if (generic_param->special != ConstValSpecialRuntime) {5788 if (generic_param->special != ConstValSpecialRuntime) {
5764 result += hash_const_val(generic_param);5789 result = hash_combine_const_val(result, generic_param);
5765 result += hash_ptr(generic_param->type);5790 result = hash_combine(result, &generic_param->type);
5766 }5791 }
5767 }5792 }
5768 return result;5793 return result;
...@@ -5957,15 +5982,15 @@ bool fn_eval_cacheable(Scope *scope, ZigType *return_type) {...@@ -5957,15 +5982,15 @@ bool fn_eval_cacheable(Scope *scope, ZigType *return_type) {
5957}5982}
59585983
5959uint32_t fn_eval_hash(Scope* scope) {5984uint32_t fn_eval_hash(Scope* scope) {
5960 uint32_t result = 0;5985 uint32_t hash = HASH_INIT;
5961 while (scope) {5986 while (scope) {
5962 if (scope->id == ScopeIdVarDecl) {5987 if (scope->id == ScopeIdVarDecl) {
5963 ScopeVarDecl *var_scope = (ScopeVarDecl *)scope;5988 ScopeVarDecl *var_scope = (ScopeVarDecl *)scope;
5964 result += hash_const_val(var_scope->var->const_value);5989 hash = hash_combine_const_val(hash, var_scope->var->const_value);
5965 } else if (scope->id == ScopeIdFnDef) {5990 } else if (scope->id == ScopeIdFnDef) {
5966 ScopeFnDef *fn_scope = (ScopeFnDef *)scope;5991 ScopeFnDef *fn_scope = (ScopeFnDef *)scope;
5967 result += hash_ptr(fn_scope->fn_entry);5992 hash = hash_combine(hash, &fn_scope->fn_entry);
5968 return result;5993 return hash;
5969 } else {5994 } else {
5970 zig_unreachable();5995 zig_unreachable();
5971 }5996 }
...@@ -7260,6 +7285,8 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {...@@ -7260,6 +7285,8 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {
7260 case ZigTypeIdMetaType:7285 case ZigTypeIdMetaType:
7261 return a->data.x_type == b->data.x_type;7286 return a->data.x_type == b->data.x_type;
7262 case ZigTypeIdVoid:7287 case ZigTypeIdVoid:
7288 case ZigTypeIdUndefined:
7289 case ZigTypeIdNull:
7263 return true;7290 return true;
7264 case ZigTypeIdErrorSet:7291 case ZigTypeIdErrorSet:
7265 return a->data.x_err_set->value == b->data.x_err_set->value;7292 return a->data.x_err_set->value == b->data.x_err_set->value;
...@@ -7292,10 +7319,9 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {...@@ -7292,10 +7319,9 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {
7292 case ZigTypeIdVector:7319 case ZigTypeIdVector:
7293 assert(a->type->data.vector.len == b->type->data.vector.len);7320 assert(a->type->data.vector.len == b->type->data.vector.len);
7294 return const_values_equal_array(g, a, b, a->type->data.vector.len);7321 return const_values_equal_array(g, a, b, a->type->data.vector.len);
7295 case ZigTypeIdArray: {7322 case ZigTypeIdArray:
7296 assert(a->type->data.array.len == b->type->data.array.len);7323 assert(a->type->data.array.len == b->type->data.array.len);
7297 return const_values_equal_array(g, a, b, a->type->data.array.len);7324 return const_values_equal_array(g, a, b, a->type->data.array.len);
7298 }
7299 case ZigTypeIdStruct:7325 case ZigTypeIdStruct:
7300 for (size_t i = 0; i < a->type->data.structure.src_field_count; i += 1) {7326 for (size_t i = 0; i < a->type->data.structure.src_field_count; i += 1) {
7301 ZigValue *field_a = a->data.x_struct.fields[i];7327 ZigValue *field_a = a->data.x_struct.fields[i];
...@@ -7308,10 +7334,6 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {...@@ -7308,10 +7334,6 @@ bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {
7308 zig_panic("TODO: const_values_equal ZigTypeIdFnFrame");7334 zig_panic("TODO: const_values_equal ZigTypeIdFnFrame");
7309 case ZigTypeIdAnyFrame:7335 case ZigTypeIdAnyFrame:
7310 zig_panic("TODO: const_values_equal ZigTypeIdAnyFrame");7336 zig_panic("TODO: const_values_equal ZigTypeIdAnyFrame");
7311 case ZigTypeIdUndefined:
7312 zig_panic("TODO: const_values_equal ZigTypeIdUndefined");
7313 case ZigTypeIdNull:
7314 zig_panic("TODO: const_values_equal ZigTypeIdNull");
7315 case ZigTypeIdOptional:7337 case ZigTypeIdOptional:
7316 if (get_src_ptr_type(a->type) != nullptr)7338 if (get_src_ptr_type(a->type) != nullptr)
7317 return const_values_equal_ptr(a, b);7339 return const_values_equal_ptr(a, b);
...@@ -7719,6 +7741,7 @@ ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {...@@ -7719,6 +7741,7 @@ ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
7719}7741}
77207742
7721uint32_t type_id_hash(TypeId x) {7743uint32_t type_id_hash(TypeId x) {
7744 uint32_t hash = hash_combine(HASH_INIT, &x.id);
7722 switch (x.id) {7745 switch (x.id) {
7723 case ZigTypeIdInvalid:7746 case ZigTypeIdInvalid:
7724 case ZigTypeIdOpaque:7747 case ZigTypeIdOpaque:
...@@ -7743,27 +7766,38 @@ uint32_t type_id_hash(TypeId x) {...@@ -7743,27 +7766,38 @@ uint32_t type_id_hash(TypeId x) {
7743 case ZigTypeIdAnyFrame:7766 case ZigTypeIdAnyFrame:
7744 zig_unreachable();7767 zig_unreachable();
7745 case ZigTypeIdErrorUnion:7768 case ZigTypeIdErrorUnion:
7746 return hash_ptr(x.data.error_union.err_set_type) ^ hash_ptr(x.data.error_union.payload_type);7769 hash = hash_combine(hash, &x.data.error_union.err_set_type);
7770 hash = hash_combine(hash, &x.data.error_union.payload_type);
7771 return hash;
7747 case ZigTypeIdPointer:7772 case ZigTypeIdPointer:
7748 return hash_ptr(x.data.pointer.child_type) +7773 hash = hash_combine(hash, &x.data.pointer.child_type);
7749 (uint32_t)x.data.pointer.ptr_len * 1120226602u +7774 hash = hash_combine(hash, &x.data.pointer.ptr_len);
7750 (x.data.pointer.is_const ? (uint32_t)2749109194 : (uint32_t)4047371087) +7775 hash = hash_combine(hash, &x.data.pointer.is_const);
7751 (x.data.pointer.is_volatile ? (uint32_t)536730450 : (uint32_t)1685612214) +7776 hash = hash_combine(hash, &x.data.pointer.is_volatile);
7752 (x.data.pointer.allow_zero ? (uint32_t)3324284834 : (uint32_t)3584904923) +7777 hash = hash_combine(hash, &x.data.pointer.allow_zero);
7753 (((uint32_t)x.data.pointer.alignment) ^ (uint32_t)0x777fbe0e) +7778 hash = hash_combine(hash, &x.data.pointer.alignment);
7754 (((uint32_t)x.data.pointer.bit_offset_in_host) ^ (uint32_t)2639019452) +7779 hash = hash_combine(hash, &x.data.pointer.bit_offset_in_host);
7755 (((uint32_t)x.data.pointer.vector_index) ^ (uint32_t)0x19199716) +7780 hash = hash_combine(hash, &x.data.pointer.vector_index);
7756 (((uint32_t)x.data.pointer.host_int_bytes) ^ (uint32_t)529908881) *7781 hash = hash_combine(hash, &x.data.pointer.host_int_bytes);
7757 (x.data.pointer.sentinel ? hash_const_val(x.data.pointer.sentinel) : (uint32_t)2955491856);7782 if (x.data.pointer.sentinel != nullptr) {
7783 hash = hash_combine_const_val(hash, x.data.pointer.sentinel);
7784 }
7785 return hash;
7758 case ZigTypeIdArray:7786 case ZigTypeIdArray:
7759 return hash_ptr(x.data.array.child_type) *7787 hash = hash_combine(hash, &x.data.array.child_type);
7760 ((uint32_t)x.data.array.size ^ (uint32_t)2122979968) *7788 hash = hash_combine(hash, &x.data.array.size);
7761 (x.data.array.sentinel ? hash_const_val(x.data.array.sentinel) : (uint32_t)1927201585);7789 if (x.data.array.sentinel != nullptr) {
7790 hash = hash_combine_const_val(hash, x.data.array.sentinel);
7791 }
7792 return hash;
7762 case ZigTypeIdInt:7793 case ZigTypeIdInt:
7763 return (x.data.integer.is_signed ? (uint32_t)2652528194 : (uint32_t)163929201) +7794 hash = hash_combine(hash, &x.data.integer.is_signed);
7764 (((uint32_t)x.data.integer.bit_count) ^ (uint32_t)2998081557);7795 hash = hash_combine(hash, &x.data.integer.bit_count);
7796 return hash;
7765 case ZigTypeIdVector:7797 case ZigTypeIdVector:
7766 return hash_ptr(x.data.vector.elem_type) * (x.data.vector.len * 526582681);7798 hash = hash_combine(hash, &x.data.vector.elem_type);
7799 hash = hash_combine(hash, &x.data.vector.len);
7800 return hash;
7767 }7801 }
7768 zig_unreachable();7802 zig_unreachable();
7769}7803}
...@@ -8155,7 +8189,7 @@ ZigType *get_align_amt_type(CodeGen *g) {...@@ -8155,7 +8189,7 @@ ZigType *get_align_amt_type(CodeGen *g) {
8155}8189}
81568190
8157uint32_t type_ptr_hash(const ZigType *ptr) {8191uint32_t type_ptr_hash(const ZigType *ptr) {
8158 return hash_ptr((void*)ptr);8192 return hash_combine(HASH_INIT, &ptr);
8159}8193}
81608194
8161bool type_ptr_eql(const ZigType *a, const ZigType *b) {8195bool type_ptr_eql(const ZigType *a, const ZigType *b) {
...@@ -8163,7 +8197,7 @@ bool type_ptr_eql(const ZigType *a, const ZigType *b) {...@@ -8163,7 +8197,7 @@ bool type_ptr_eql(const ZigType *a, const ZigType *b) {
8163}8197}
81648198
8165uint32_t pkg_ptr_hash(const ZigPackage *ptr) {8199uint32_t pkg_ptr_hash(const ZigPackage *ptr) {
8166 return hash_ptr((void*)ptr);8200 return hash_combine(HASH_INIT, &ptr);
8167}8201}
81688202
8169bool pkg_ptr_eql(const ZigPackage *a, const ZigPackage *b) {8203bool pkg_ptr_eql(const ZigPackage *a, const ZigPackage *b) {
...@@ -8171,7 +8205,7 @@ bool pkg_ptr_eql(const ZigPackage *a, const ZigPackage *b) {...@@ -8171,7 +8205,7 @@ bool pkg_ptr_eql(const ZigPackage *a, const ZigPackage *b) {
8171}8205}
81728206
8173uint32_t tld_ptr_hash(const Tld *ptr) {8207uint32_t tld_ptr_hash(const Tld *ptr) {
8174 return hash_ptr((void*)ptr);8208 return hash_combine(HASH_INIT, &ptr);
8175}8209}
81768210
8177bool tld_ptr_eql(const Tld *a, const Tld *b) {8211bool tld_ptr_eql(const Tld *a, const Tld *b) {
...@@ -8179,7 +8213,7 @@ bool tld_ptr_eql(const Tld *a, const Tld *b) {...@@ -8179,7 +8213,7 @@ bool tld_ptr_eql(const Tld *a, const Tld *b) {
8179}8213}
81808214
8181uint32_t node_ptr_hash(const AstNode *ptr) {8215uint32_t node_ptr_hash(const AstNode *ptr) {
8182 return hash_ptr((void*)ptr);8216 return hash_combine(HASH_INIT, &ptr);
8183}8217}
81848218
8185bool node_ptr_eql(const AstNode *a, const AstNode *b) {8219bool node_ptr_eql(const AstNode *a, const AstNode *b) {
...@@ -8187,7 +8221,7 @@ bool node_ptr_eql(const AstNode *a, const AstNode *b) {...@@ -8187,7 +8221,7 @@ bool node_ptr_eql(const AstNode *a, const AstNode *b) {
8187}8221}
81888222
8189uint32_t fn_ptr_hash(const ZigFn *ptr) {8223uint32_t fn_ptr_hash(const ZigFn *ptr) {
8190 return hash_ptr((void*)ptr);8224 return hash_combine(HASH_INIT, &ptr);
8191}8225}
81928226
8193bool fn_ptr_eql(const ZigFn *a, const ZigFn *b) {8227bool fn_ptr_eql(const ZigFn *a, const ZigFn *b) {
...@@ -8195,7 +8229,7 @@ bool fn_ptr_eql(const ZigFn *a, const ZigFn *b) {...@@ -8195,7 +8229,7 @@ bool fn_ptr_eql(const ZigFn *a, const ZigFn *b) {
8195}8229}
81968230
8197uint32_t err_ptr_hash(const ErrorTableEntry *ptr) {8231uint32_t err_ptr_hash(const ErrorTableEntry *ptr) {
8198 return hash_ptr((void*)ptr);8232 return hash_combine(HASH_INIT, &ptr);
8199}8233}
82008234
8201bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {8235bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {
src/stage1/bigint.cpp+7
...@@ -1691,6 +1691,13 @@ uint32_t bigint_as_u32(const BigInt *bigint) {...@@ -1691,6 +1691,13 @@ uint32_t bigint_as_u32(const BigInt *bigint) {
1691 return value32;1691 return value32;
1692}1692}
16931693
1694uint8_t bigint_as_u8(const BigInt *bigint) {
1695 uint64_t value64 = bigint_as_unsigned(bigint);
1696 uint8_t value8 = (uint8_t)value64;
1697 assert (value64 == value8);
1698 return value8;
1699}
1700
1694size_t bigint_as_usize(const BigInt *bigint) {1701size_t bigint_as_usize(const BigInt *bigint) {
1695 uint64_t value64 = bigint_as_unsigned(bigint);1702 uint64_t value64 = bigint_as_unsigned(bigint);
1696 size_t valueUsize = (size_t)value64;1703 size_t valueUsize = (size_t)value64;
src/stage1/bigint.hpp+1
...@@ -39,6 +39,7 @@ void bigint_deinit(BigInt *bi);...@@ -39,6 +39,7 @@ void bigint_deinit(BigInt *bi);
39// panics if number won't fit39// panics if number won't fit
40uint64_t bigint_as_u64(const BigInt *bigint);40uint64_t bigint_as_u64(const BigInt *bigint);
41uint32_t bigint_as_u32(const BigInt *bigint);41uint32_t bigint_as_u32(const BigInt *bigint);
42uint8_t bigint_as_u8(const BigInt *bigint);
42size_t bigint_as_usize(const BigInt *bigint);43size_t bigint_as_usize(const BigInt *bigint);
4344
44int64_t bigint_as_signed(const BigInt *bigint);45int64_t bigint_as_signed(const BigInt *bigint);
src/stage1/buffer.hpp+1-1
...@@ -26,7 +26,7 @@ Buf *buf_sprintf(const char *format, ...)...@@ -26,7 +26,7 @@ Buf *buf_sprintf(const char *format, ...)
26 ATTRIBUTE_PRINTF(1, 2);26 ATTRIBUTE_PRINTF(1, 2);
27Buf *buf_vprintf(const char *format, va_list ap);27Buf *buf_vprintf(const char *format, va_list ap);
2828
29static inline size_t buf_len(Buf *buf) {29static inline size_t buf_len(const Buf *buf) {
30 assert(buf);30 assert(buf);
31 assert(buf->list.length);31 assert(buf->list.length);
32 return buf->list.length - 1;32 return buf->list.length - 1;
src/stage1/ir.cpp+20-13
...@@ -272,8 +272,8 @@ static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *r...@@ -272,8 +272,8 @@ static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *r
272static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field);272static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field);
273static void value_to_bigfloat(BigFloat *out, ZigValue *val);273static void value_to_bigfloat(BigFloat *out, ZigValue *val);
274274
275static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val);275static Error ir_resolve_lazy_recurse(IrAnalyze *ira, AstNode *source_node, ZigValue *val);
276static Error ir_resolve_lazy_recurse_array(AstNode *source_node, ZigValue *val, size_t len);276static Error ir_resolve_lazy_recurse_array(IrAnalyze *ira, AstNode *source_node, ZigValue *val, size_t len);
277277
278278
279static void ir_assert_impl(bool ok, IrInstGen *source_instruction, char const *file, unsigned int line) {279static void ir_assert_impl(bool ok, IrInstGen *source_instruction, char const *file, unsigned int line) {
...@@ -12945,7 +12945,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour...@@ -12945,7 +12945,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, Scope *scope, AstNode *sour
12945 for (size_t i = 0; i < generic_id->param_count; i += 1) {12945 for (size_t i = 0; i < generic_id->param_count; i += 1) {
12946 ZigValue *generic_param = &generic_id->params[i];12946 ZigValue *generic_param = &generic_id->params[i];
12947 if (generic_param->special != ConstValSpecialRuntime) {12947 if (generic_param->special != ConstValSpecialRuntime) {
12948 if ((err = ir_resolve_lazy_recurse(source_node, generic_param))) {12948 if ((err = ir_resolve_lazy_recurse(ira, source_node, generic_param))) {
12949 return ira->codegen->invalid_inst_gen;12949 return ira->codegen->invalid_inst_gen;
12950 }12950 }
12951 }12951 }
...@@ -25531,7 +25531,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {...@@ -25531,7 +25531,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
25531 zig_unreachable();25531 zig_unreachable();
25532}25532}
2553325533
25534static Error ir_resolve_lazy_recurse_array(AstNode *source_node, ZigValue *val, size_t len) {25534static Error ir_resolve_lazy_recurse_array(IrAnalyze *ira, AstNode *source_node, ZigValue *val, size_t len) {
25535 Error err;25535 Error err;
25536 switch (val->data.x_array.special) {25536 switch (val->data.x_array.special) {
25537 case ConstArraySpecialUndef:25537 case ConstArraySpecialUndef:
...@@ -25543,17 +25543,24 @@ static Error ir_resolve_lazy_recurse_array(AstNode *source_node, ZigValue *val,...@@ -25543,17 +25543,24 @@ static Error ir_resolve_lazy_recurse_array(AstNode *source_node, ZigValue *val,
25543 ZigValue *elems = val->data.x_array.data.s_none.elements;25543 ZigValue *elems = val->data.x_array.data.s_none.elements;
2554425544
25545 for (size_t i = 0; i < len; i += 1) {25545 for (size_t i = 0; i < len; i += 1) {
25546 if ((err = ir_resolve_lazy_recurse(source_node, &elems[i])))25546 if ((err = ir_resolve_lazy_recurse(ira, source_node, &elems[i])))
25547 return err;25547 return err;
25548 }25548 }
2554925549
25550 return ErrorNone;25550 return ErrorNone;
25551}25551}
2555225552
25553static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {25553static Error ir_resolve_lazy_recurse(IrAnalyze *ira, AstNode *source_node, ZigValue *val) {
25554 Error err;25554 Error err;
25555 if ((err = ir_resolve_lazy_raw(source_node, val))) 25555 if ((err = ir_resolve_lazy_raw(source_node, val)))
25556 return err;25556 return err;
25557 if (val->special == ConstValSpecialRuntime) {
25558 // This shouldn't be possible, it indicates an ICE.
25559 // NO_COMMIT
25560 ir_add_error_node(ira, source_node,
25561 buf_sprintf("This is a bug in the Zig compiler. Runtime value found in comptime known parameter."));
25562 return ErrorSemanticAnalyzeFail;
25563 }
25557 if (val->special != ConstValSpecialStatic)25564 if (val->special != ConstValSpecialStatic)
25558 return ErrorNone;25565 return ErrorNone;
25559 switch (val->type->id) {25566 switch (val->type->id) {
...@@ -25581,16 +25588,16 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {...@@ -25581,16 +25588,16 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {
25581 zig_panic("TODO: ir_resolve_lazy_recurse ZigTypeIdFnFrame");25588 zig_panic("TODO: ir_resolve_lazy_recurse ZigTypeIdFnFrame");
25582 case ZigTypeIdUnion: {25589 case ZigTypeIdUnion: {
25583 ConstUnionValue *union_val = &val->data.x_union;25590 ConstUnionValue *union_val = &val->data.x_union;
25584 return ir_resolve_lazy_recurse(source_node, union_val->payload);25591 return ir_resolve_lazy_recurse(ira, source_node, union_val->payload);
25585 }25592 }
25586 case ZigTypeIdVector:25593 case ZigTypeIdVector:
25587 return ir_resolve_lazy_recurse_array(source_node, val, val->type->data.vector.len);25594 return ir_resolve_lazy_recurse_array(ira, source_node, val, val->type->data.vector.len);
25588 case ZigTypeIdArray:25595 case ZigTypeIdArray:
25589 return ir_resolve_lazy_recurse_array(source_node, val, val->type->data.array.len);25596 return ir_resolve_lazy_recurse_array(ira, source_node, val, val->type->data.array.len);
25590 case ZigTypeIdStruct:25597 case ZigTypeIdStruct:
25591 for (size_t i = 0; i < val->type->data.structure.src_field_count; i += 1) {25598 for (size_t i = 0; i < val->type->data.structure.src_field_count; i += 1) {
25592 ZigValue *field = val->data.x_struct.fields[i];25599 ZigValue *field = val->data.x_struct.fields[i];
25593 if ((err = ir_resolve_lazy_recurse(source_node, field)))25600 if ((err = ir_resolve_lazy_recurse(ira, source_node, field)))
25594 return err;25601 return err;
25595 }25602 }
25596 return ErrorNone;25603 return ErrorNone;
...@@ -25600,13 +25607,13 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {...@@ -25600,13 +25607,13 @@ static Error ir_resolve_lazy_recurse(AstNode *source_node, ZigValue *val) {
25600 if (val->data.x_optional == nullptr)25607 if (val->data.x_optional == nullptr)
25601 return ErrorNone;25608 return ErrorNone;
2560225609
25603 return ir_resolve_lazy_recurse(source_node, val->data.x_optional);25610 return ir_resolve_lazy_recurse(ira, source_node, val->data.x_optional);
25604 case ZigTypeIdErrorUnion: {25611 case ZigTypeIdErrorUnion: {
25605 bool is_err = val->data.x_err_union.error_set->data.x_err_set != nullptr;25612 bool is_err = val->data.x_err_union.error_set->data.x_err_set != nullptr;
25606 if (is_err) {25613 if (is_err) {
25607 return ir_resolve_lazy_recurse(source_node, val->data.x_err_union.error_set);25614 return ir_resolve_lazy_recurse(ira, source_node, val->data.x_err_union.error_set);
25608 } else {25615 } else {
25609 return ir_resolve_lazy_recurse(source_node, val->data.x_err_union.payload);25616 return ir_resolve_lazy_recurse(ira, source_node, val->data.x_err_union.payload);
25610 }25617 }
25611 }25618 }
25612 }25619 }
src/stage1/util.cpp-23
...@@ -21,29 +21,6 @@ void zig_panic(const char *format, ...) {...@@ -21,29 +21,6 @@ void zig_panic(const char *format, ...) {
21 abort();21 abort();
22}22}
2323
24uint32_t int_hash(int i) {
25 return (uint32_t)(i % UINT32_MAX);
26}
27bool int_eq(int a, int b) {
28 return a == b;
29}
30
31uint32_t uint64_hash(uint64_t i) {
32 return (uint32_t)(i % UINT32_MAX);
33}
34
35bool uint64_eq(uint64_t a, uint64_t b) {
36 return a == b;
37}
38
39uint32_t ptr_hash(const void *ptr) {
40 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
41}
42
43bool ptr_eq(const void *a, const void *b) {
44 return a == b;
45}
46
47// Ported from std/mem.zig.24// Ported from std/mem.zig.
48bool SplitIterator_isSplitByte(SplitIterator *self, uint8_t byte) {25bool SplitIterator_isSplitByte(SplitIterator *self, uint8_t byte) {
49 for (size_t i = 0; i < self->split_bytes.len; i += 1) {26 for (size_t i = 0; i < self->split_bytes.len; i += 1) {
src/stage1/util.hpp-7
...@@ -129,13 +129,6 @@ static inline uint64_t round_to_next_power_of_2(uint64_t x) {...@@ -129,13 +129,6 @@ static inline uint64_t round_to_next_power_of_2(uint64_t x) {
129 return x + 1;129 return x + 1;
130}130}
131131
132uint32_t int_hash(int i);
133bool int_eq(int a, int b);
134uint32_t uint64_hash(uint64_t i);
135bool uint64_eq(uint64_t a, uint64_t b);
136uint32_t ptr_hash(const void *ptr);
137bool ptr_eq(const void *a, const void *b);
138
139static inline uint8_t log2_u64(uint64_t x) {132static inline uint8_t log2_u64(uint64_t x) {
140 return (63 - clzll(x));133 return (63 - clzll(x));
141}134}