| ... | ... | @@ -5766,7 +5766,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 5766 | 5766 | buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf))); |
| 5767 | 5767 | return irb->codegen->invalid_instruction; |
| 5768 | 5768 | } |
| 5769 | | bit_offset_start = bigint_as_unsigned(node->data.pointer_type.bit_offset_start); |
| 5769 | bit_offset_start = bigint_as_u32(node->data.pointer_type.bit_offset_start); |
| 5770 | 5770 | } |
| 5771 | 5771 | |
| 5772 | 5772 | uint32_t host_int_bytes = 0; |
| ... | ... | @@ -5778,7 +5778,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 5778 | 5778 | buf_sprintf("value %s too large for u32 byte count", buf_ptr(val_buf))); |
| 5779 | 5779 | return irb->codegen->invalid_instruction; |
| 5780 | 5780 | } |
| 5781 | | host_int_bytes = bigint_as_unsigned(node->data.pointer_type.host_int_bytes); |
| 5781 | host_int_bytes = bigint_as_u32(node->data.pointer_type.host_int_bytes); |
| 5782 | 5782 | } |
| 5783 | 5783 | |
| 5784 | 5784 | if (host_int_bytes != 0 && bit_offset_start >= host_int_bytes * 8) { |
| ... | ... | @@ -11550,7 +11550,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 11550 | 11550 | return ira->codegen->invalid_instruction; |
| 11551 | 11551 | } |
| 11552 | 11552 | |
| 11553 | | size_t index = bigint_as_unsigned(&val->data.x_bigint); |
| 11553 | size_t index = bigint_as_usize(&val->data.x_bigint); |
| 11554 | 11554 | result->value.data.x_err_set = ira->codegen->errors_by_index.at(index); |
| 11555 | 11555 | return result; |
| 11556 | 11556 | } else { |
| ... | ... | @@ -12520,7 +12520,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, uint32_t *out |
| 12520 | 12520 | if (!const_val) |
| 12521 | 12521 | return false; |
| 12522 | 12522 | |
| 12523 | | uint32_t align_bytes = bigint_as_unsigned(&const_val->data.x_bigint); |
| 12523 | uint32_t align_bytes = bigint_as_u32(&const_val->data.x_bigint); |
| 12524 | 12524 | if (align_bytes == 0) { |
| 12525 | 12525 | ir_add_error(ira, value, buf_sprintf("alignment must be >= 1")); |
| 12526 | 12526 | return false; |
| ... | ... | @@ -12547,7 +12547,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i |
| 12547 | 12547 | if (!const_val) |
| 12548 | 12548 | return false; |
| 12549 | 12549 | |
| 12550 | | *out = bigint_as_unsigned(&const_val->data.x_bigint); |
| 12550 | *out = bigint_as_u64(&const_val->data.x_bigint); |
| 12551 | 12551 | return true; |
| 12552 | 12552 | } |
| 12553 | 12553 | |
| ... | ... | @@ -12595,7 +12595,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 12595 | 12595 | if (!const_val) |
| 12596 | 12596 | return false; |
| 12597 | 12597 | |
| 12598 | | *out = (AtomicOrder)bigint_as_unsigned(&const_val->data.x_enum_tag); |
| 12598 | *out = (AtomicOrder)bigint_as_u32(&const_val->data.x_enum_tag); |
| 12599 | 12599 | return true; |
| 12600 | 12600 | } |
| 12601 | 12601 | |
| ... | ... | @@ -12615,7 +12615,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 12615 | 12615 | if (!const_val) |
| 12616 | 12616 | return false; |
| 12617 | 12617 | |
| 12618 | | *out = (AtomicRmwOp)bigint_as_unsigned(&const_val->data.x_enum_tag); |
| 12618 | *out = (AtomicRmwOp)bigint_as_u32(&const_val->data.x_enum_tag); |
| 12619 | 12619 | return true; |
| 12620 | 12620 | } |
| 12621 | 12621 | |
| ... | ... | @@ -12635,7 +12635,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 12635 | 12635 | if (!const_val) |
| 12636 | 12636 | return false; |
| 12637 | 12637 | |
| 12638 | | *out = (GlobalLinkageId)bigint_as_unsigned(&const_val->data.x_enum_tag); |
| 12638 | *out = (GlobalLinkageId)bigint_as_u32(&const_val->data.x_enum_tag); |
| 12639 | 12639 | return true; |
| 12640 | 12640 | } |
| 12641 | 12641 | |
| ... | ... | @@ -12655,7 +12655,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 12655 | 12655 | if (!const_val) |
| 12656 | 12656 | return false; |
| 12657 | 12657 | |
| 12658 | | *out = (FloatMode)bigint_as_unsigned(&const_val->data.x_enum_tag); |
| 12658 | *out = (FloatMode)bigint_as_u32(&const_val->data.x_enum_tag); |
| 12659 | 12659 | return true; |
| 12660 | 12660 | } |
| 12661 | 12661 | |
| ... | ... | @@ -12684,7 +12684,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 12684 | 12684 | return array_val->data.x_array.data.s_buf; |
| 12685 | 12685 | } |
| 12686 | 12686 | expand_undef_array(ira->codegen, array_val); |
| 12687 | | size_t len = bigint_as_unsigned(&len_field->data.x_bigint); |
| 12687 | size_t len = bigint_as_usize(&len_field->data.x_bigint); |
| 12688 | 12688 | Buf *result = buf_alloc(); |
| 12689 | 12689 | buf_resize(result, len); |
| 12690 | 12690 | for (size_t i = 0; i < len; i += 1) { |
| ... | ... | @@ -12694,7 +12694,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 12694 | 12694 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); |
| 12695 | 12695 | return nullptr; |
| 12696 | 12696 | } |
| 12697 | | uint64_t big_c = bigint_as_unsigned(&char_val->data.x_bigint); |
| 12697 | uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); |
| 12698 | 12698 | assert(big_c <= UINT8_MAX); |
| 12699 | 12699 | uint8_t c = (uint8_t)big_c; |
| 12700 | 12700 | buf_ptr(result)[i] = c; |
| ... | ... | @@ -13829,7 +13829,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 13829 | 13829 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 13830 | 13830 | op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 13831 | 13831 | ConstExprValue *len_val = &op1_val->data.x_struct.fields[slice_len_index]; |
| 13832 | | op1_array_end = op1_array_index + bigint_as_unsigned(&len_val->data.x_bigint); |
| 13832 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 13833 | 13833 | } else { |
| 13834 | 13834 | ir_add_error(ira, op1, |
| 13835 | 13835 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op1->value.type->name))); |
| ... | ... | @@ -13862,7 +13862,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 13862 | 13862 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 13863 | 13863 | op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 13864 | 13864 | ConstExprValue *len_val = &op2_val->data.x_struct.fields[slice_len_index]; |
| 13865 | | op2_array_end = op2_array_index + bigint_as_unsigned(&len_val->data.x_bigint); |
| 13865 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 13866 | 13866 | } else { |
| 13867 | 13867 | ir_add_error(ira, op2, |
| 13868 | 13868 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name))); |
| ... | ... | @@ -16734,7 +16734,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 16734 | 16734 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); |
| 16735 | 16735 | uint64_t ptr_align = get_ptr_align(ira->codegen, return_type); |
| 16736 | 16736 | if (instr_is_comptime(casted_elem_index)) { |
| 16737 | | uint64_t index = bigint_as_unsigned(&casted_elem_index->value.data.x_bigint); |
| 16737 | uint64_t index = bigint_as_u64(&casted_elem_index->value.data.x_bigint); |
| 16738 | 16738 | if (array_type->id == ZigTypeIdArray) { |
| 16739 | 16739 | uint64_t array_len = array_type->data.array.len; |
| 16740 | 16740 | if (index >= array_len) { |
| ... | ... | @@ -16896,7 +16896,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 16896 | 16896 | ConstExprValue *len_field = &array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 16897 | 16897 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 16898 | 16898 | ConstExprValue *out_val = &result->value; |
| 16899 | | uint64_t slice_len = bigint_as_unsigned(&len_field->data.x_bigint); |
| 16899 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 16900 | 16900 | if (index >= slice_len) { |
| 16901 | 16901 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, |
| 16902 | 16902 | buf_sprintf("index %" ZIG_PRI_u64 " outside slice of size %" ZIG_PRI_u64, |
| ... | ... | @@ -21181,7 +21181,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 21181 | 21181 | |
| 21182 | 21182 | ConstExprValue *len_val = &val->data.x_struct.fields[slice_len_index]; |
| 21183 | 21183 | if (value_is_comptime(len_val)) { |
| 21184 | | known_len = bigint_as_unsigned(&len_val->data.x_bigint); |
| 21184 | known_len = bigint_as_u64(&len_val->data.x_bigint); |
| 21185 | 21185 | have_known_len = true; |
| 21186 | 21186 | } |
| 21187 | 21187 | } |
| ... | ... | @@ -21527,7 +21527,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 21527 | 21527 | zig_panic("TODO memset on null ptr"); |
| 21528 | 21528 | } |
| 21529 | 21529 | |
| 21530 | | size_t count = bigint_as_unsigned(&casted_count->value.data.x_bigint); |
| 21530 | size_t count = bigint_as_usize(&casted_count->value.data.x_bigint); |
| 21531 | 21531 | size_t end = start + count; |
| 21532 | 21532 | if (end > bound_end) { |
| 21533 | 21533 | ir_add_error(ira, count_value, buf_sprintf("out of bounds pointer access")); |
| ... | ... | @@ -21612,7 +21612,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 21612 | 21612 | casted_count->value.special == ConstValSpecialStatic && |
| 21613 | 21613 | casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) |
| 21614 | 21614 | { |
| 21615 | | size_t count = bigint_as_unsigned(&casted_count->value.data.x_bigint); |
| 21615 | size_t count = bigint_as_usize(&casted_count->value.data.x_bigint); |
| 21616 | 21616 | |
| 21617 | 21617 | ConstExprValue *dest_ptr_val = &casted_dest_ptr->value; |
| 21618 | 21618 | ConstExprValue *dest_elements; |
| ... | ... | @@ -21897,7 +21897,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 21897 | 21897 | case ConstPtrSpecialBaseArray: |
| 21898 | 21898 | array_val = parent_ptr->data.x_ptr.data.base_array.array_val; |
| 21899 | 21899 | abs_offset = parent_ptr->data.x_ptr.data.base_array.elem_index; |
| 21900 | | rel_end = bigint_as_unsigned(&len_val->data.x_bigint); |
| 21900 | rel_end = bigint_as_usize(&len_val->data.x_bigint); |
| 21901 | 21901 | break; |
| 21902 | 21902 | case ConstPtrSpecialBaseStruct: |
| 21903 | 21903 | zig_panic("TODO slice const inner struct"); |
| ... | ... | @@ -21910,7 +21910,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 21910 | 21910 | case ConstPtrSpecialHardCodedAddr: |
| 21911 | 21911 | array_val = nullptr; |
| 21912 | 21912 | abs_offset = 0; |
| 21913 | | rel_end = bigint_as_unsigned(&len_val->data.x_bigint); |
| 21913 | rel_end = bigint_as_usize(&len_val->data.x_bigint); |
| 21914 | 21914 | break; |
| 21915 | 21915 | case ConstPtrSpecialFunction: |
| 21916 | 21916 | zig_panic("TODO slice of slice cast from function"); |
| ... | ... | @@ -21921,7 +21921,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 21921 | 21921 | zig_unreachable(); |
| 21922 | 21922 | } |
| 21923 | 21923 | |
| 21924 | | uint64_t start_scalar = bigint_as_unsigned(&casted_start->value.data.x_bigint); |
| 21924 | uint64_t start_scalar = bigint_as_u64(&casted_start->value.data.x_bigint); |
| 21925 | 21925 | if (!ptr_is_undef && start_scalar > rel_end) { |
| 21926 | 21926 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds slice")); |
| 21927 | 21927 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -21929,7 +21929,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 21929 | 21929 | |
| 21930 | 21930 | uint64_t end_scalar; |
| 21931 | 21931 | if (end) { |
| 21932 | | end_scalar = bigint_as_unsigned(&end->value.data.x_bigint); |
| 21932 | end_scalar = bigint_as_u64(&end->value.data.x_bigint); |
| 21933 | 21933 | } else { |
| 21934 | 21934 | end_scalar = rel_end; |
| 21935 | 21935 | } |
| ... | ... | @@ -23500,7 +23500,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 23500 | 23500 | BigInt bn; |
| 23501 | 23501 | bigint_read_twos_complement(&bn, buf, codegen->builtin_types.entry_usize->data.integral.bit_count, |
| 23502 | 23502 | codegen->is_big_endian, false); |
| 23503 | | val->data.x_ptr.data.hard_coded_addr.addr = bigint_as_unsigned(&bn); |
| 23503 | val->data.x_ptr.data.hard_coded_addr.addr = bigint_as_usize(&bn); |
| 23504 | 23504 | return ErrorNone; |
| 23505 | 23505 | } |
| 23506 | 23506 | case ZigTypeIdArray: |
| ... | ... | @@ -23693,7 +23693,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 23693 | 23693 | if (!val) |
| 23694 | 23694 | return ira->codegen->invalid_instruction; |
| 23695 | 23695 | |
| 23696 | | uint64_t addr = bigint_as_unsigned(&val->data.x_bigint); |
| 23696 | uint64_t addr = bigint_as_u64(&val->data.x_bigint); |
| 23697 | 23697 | if (!ptr_allows_addr_zero(ptr_type) && addr == 0) { |
| 23698 | 23698 | ir_add_error(ira, source_instr, |
| 23699 | 23699 | buf_sprintf("pointer type '%s' does not allow address zero", buf_ptr(&ptr_type->name))); |