authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-13 20:26:09-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-14 03:52:36-05:00
logf2f698a888afdc8709142912f8394376d28e16ea
treeec0077cb1fca066eb6a8ca678ca06b02b8fa22cb
parentb83ce08a3b51c58096ab0b2383212a2124794c82
signaturelock-open Commit is signed but in an unrecognized format.

rework comptime struct value layout, removing 1/2 hacks

in the implementation of anonymous struct literals

5 files changed, 277 insertions(+), 266 deletions(-)

src/all_types.hpp+1-1
......@@ -152,7 +152,7 @@ struct ConstParent {
152152};
153153
154154struct ConstStructValue {
155 ConstExprValue *fields;
155 ConstExprValue **fields;
156156};
157157
158158struct ConstUnionValue {
src/analyze.cpp+29-12
......@@ -1461,8 +1461,8 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **
14611461 if (type_is_invalid(result_val->type))
14621462 return false;
14631463
1464 ConstExprValue *ptr_field = &result_val->data.x_struct.fields[slice_ptr_index];
1465 ConstExprValue *len_field = &result_val->data.x_struct.fields[slice_len_index];
1464 ConstExprValue *ptr_field = result_val->data.x_struct.fields[slice_ptr_index];
1465 ConstExprValue *len_field = result_val->data.x_struct.fields[slice_len_index];
14661466
14671467 assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray);
14681468 ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val;
......@@ -5283,7 +5283,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
52835283 zig_unreachable();
52845284 case ZigTypeIdStruct:
52855285 for (uint32_t i = 0; i < value->type->data.structure.src_field_count; i += 1) {
5286 if (can_mutate_comptime_var_state(&value->data.x_struct.fields[i]))
5286 if (can_mutate_comptime_var_state(value->data.x_struct.fields[i]))
52875287 return true;
52885288 }
52895289 return false;
......@@ -5798,11 +5798,11 @@ void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *arr
57985798
57995799 const_val->special = ConstValSpecialStatic;
58005800 const_val->type = get_slice_type(g, ptr_type);
5801 const_val->data.x_struct.fields = create_const_vals(2);
5801 const_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
58025802
5803 init_const_ptr_array(g, &const_val->data.x_struct.fields[slice_ptr_index], array_val, start, is_const,
5803 init_const_ptr_array(g, const_val->data.x_struct.fields[slice_ptr_index], array_val, start, is_const,
58045804 PtrLenUnknown);
5805 init_const_usize(g, &const_val->data.x_struct.fields[slice_len_index], len);
5805 init_const_usize(g, const_val->data.x_struct.fields[slice_len_index], len);
58065806}
58075807
58085808ConstExprValue *create_const_slice(CodeGen *g, ConstExprValue *array_val, size_t start, size_t len, bool is_const) {
......@@ -5886,6 +5886,23 @@ ConstExprValue *create_const_vals(size_t count) {
58865886 return vals;
58875887}
58885888
5889ConstExprValue **alloc_const_vals_ptrs(size_t count) {
5890 return realloc_const_vals_ptrs(nullptr, 0, count);
5891}
5892
5893ConstExprValue **realloc_const_vals_ptrs(ConstExprValue **ptr, size_t old_count, size_t new_count) {
5894 assert(new_count >= old_count);
5895
5896 size_t new_item_count = new_count - old_count;
5897 ConstExprValue **result = reallocate(ptr, old_count, new_count, "ConstExprValue*");
5898 ConstExprValue *vals = create_const_vals(new_item_count);
5899 for (size_t i = old_count; i < new_count; i += 1) {
5900 result[i] = &vals[i - old_count];
5901 }
5902 return result;
5903}
5904
5905
58895906static ZigType *get_async_fn_type(CodeGen *g, ZigType *orig_fn_type) {
58905907 if (orig_fn_type->data.fn.fn_type_id.cc == CallingConventionAsync)
58915908 return orig_fn_type;
......@@ -6567,8 +6584,8 @@ bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) {
65676584 }
65686585 case ZigTypeIdStruct:
65696586 for (size_t i = 0; i < a->type->data.structure.src_field_count; i += 1) {
6570 ConstExprValue *field_a = &a->data.x_struct.fields[i];
6571 ConstExprValue *field_b = &b->data.x_struct.fields[i];
6587 ConstExprValue *field_a = a->data.x_struct.fields[i];
6588 ConstExprValue *field_b = b->data.x_struct.fields[i];
65726589 if (!const_values_equal(g, field_a, field_b))
65736590 return false;
65746591 }
......@@ -6876,10 +6893,10 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
68766893 case ZigTypeIdStruct:
68776894 {
68786895 if (is_slice(type_entry)) {
6879 ConstExprValue *len_val = &const_val->data.x_struct.fields[slice_len_index];
6896 ConstExprValue *len_val = const_val->data.x_struct.fields[slice_len_index];
68806897 size_t len = bigint_as_usize(&len_val->data.x_bigint);
68816898
6882 ConstExprValue *ptr_val = &const_val->data.x_struct.fields[slice_ptr_index];
6899 ConstExprValue *ptr_val = const_val->data.x_struct.fields[slice_ptr_index];
68836900 if (ptr_val->special == ConstValSpecialUndef) {
68846901 assert(len == 0);
68856902 buf_appendf(buf, "((%s)(undefined))[0..0]", buf_ptr(&type_entry->name));
......@@ -7156,9 +7173,9 @@ static void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
71567173
71577174 const_val->special = ConstValSpecialStatic;
71587175 size_t field_count = wanted_type->data.structure.src_field_count;
7159 const_val->data.x_struct.fields = create_const_vals(field_count);
7176 const_val->data.x_struct.fields = alloc_const_vals_ptrs(field_count);
71607177 for (size_t i = 0; i < field_count; i += 1) {
7161 ConstExprValue *field_val = &const_val->data.x_struct.fields[i];
7178 ConstExprValue *field_val = const_val->data.x_struct.fields[i];
71627179 field_val->type = resolve_struct_field_type(g, &wanted_type->data.structure.fields[i]);
71637180 assert(field_val->type);
71647181 init_const_undefined(g, field_val);
src/analyze.hpp+2
......@@ -177,6 +177,8 @@ void init_const_arg_tuple(CodeGen *g, ConstExprValue *const_val, size_t arg_inde
177177ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_index_end);
178178
179179ConstExprValue *create_const_vals(size_t count);
180ConstExprValue **alloc_const_vals_ptrs(size_t count);
181ConstExprValue **realloc_const_vals_ptrs(ConstExprValue **ptr, size_t old_count, size_t new_count);
180182
181183ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
182184void expand_undef_array(CodeGen *g, ConstExprValue *const_val);
src/codegen.cpp+8-8
......@@ -3508,7 +3508,7 @@ static bool value_is_all_undef(CodeGen *g, ConstExprValue *const_val) {
35083508 case ConstValSpecialStatic:
35093509 if (const_val->type->id == ZigTypeIdStruct) {
35103510 for (size_t i = 0; i < const_val->type->data.structure.src_field_count; i += 1) {
3511 if (!value_is_all_undef(g, &const_val->data.x_struct.fields[i]))
3511 if (!value_is_all_undef(g, const_val->data.x_struct.fields[i]))
35123512 return false;
35133513 }
35143514 return true;
......@@ -6572,7 +6572,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
65726572 if (field->gen_index == SIZE_MAX) {
65736573 continue;
65746574 }
6575 LLVMValueRef child_val = pack_const_int(g, big_int_type_ref, &const_val->data.x_struct.fields[i]);
6575 LLVMValueRef child_val = pack_const_int(g, big_int_type_ref, const_val->data.x_struct.fields[i]);
65766576 uint32_t packed_bits_size = type_size_bits(g, field->type_entry);
65776577 if (is_big_endian) {
65786578 LLVMValueRef shift_amt = LLVMConstInt(big_int_type_ref, packed_bits_size, false);
......@@ -6840,7 +6840,7 @@ check: switch (const_val->special) {
68406840 }
68416841
68426842 if (src_field_index + 1 == src_field_index_end) {
6843 ConstExprValue *field_val = &const_val->data.x_struct.fields[src_field_index];
6843 ConstExprValue *field_val = const_val->data.x_struct.fields[src_field_index];
68446844 LLVMValueRef val = gen_const_val(g, field_val, "");
68456845 fields[type_struct_field->gen_index] = val;
68466846 make_unnamed_struct = make_unnamed_struct || is_llvm_value_unnamed_type(g, field_val->type, val);
......@@ -6858,7 +6858,7 @@ check: switch (const_val->special) {
68586858 continue;
68596859 }
68606860 LLVMValueRef child_val = pack_const_int(g, big_int_type_ref,
6861 &const_val->data.x_struct.fields[i]);
6861 const_val->data.x_struct.fields[i]);
68626862 uint32_t packed_bits_size = type_size_bits(g, it_field->type_entry);
68636863 if (is_big_endian) {
68646864 LLVMValueRef shift_amt = LLVMConstInt(big_int_type_ref,
......@@ -6897,7 +6897,7 @@ check: switch (const_val->special) {
68976897 if (type_struct_field->gen_index == SIZE_MAX) {
68986898 continue;
68996899 }
6900 ConstExprValue *field_val = &const_val->data.x_struct.fields[i];
6900 ConstExprValue *field_val = const_val->data.x_struct.fields[i];
69016901 assert(field_val->type != nullptr);
69026902 if ((err = ensure_const_val_repr(nullptr, g, nullptr, field_val,
69036903 type_struct_field->type_entry)))
......@@ -9074,13 +9074,13 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
90749074 this_val->parent.id = ConstParentIdArray;
90759075 this_val->parent.data.p_array.array_val = test_fn_array;
90769076 this_val->parent.data.p_array.elem_index = i;
9077 this_val->data.x_struct.fields = create_const_vals(2);
9077 this_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
90789078
9079 ConstExprValue *name_field = &this_val->data.x_struct.fields[0];
9079 ConstExprValue *name_field = this_val->data.x_struct.fields[0];
90809080 ConstExprValue *name_array_val = create_const_str_lit(g, &test_fn_entry->symbol_name);
90819081 init_const_slice(g, name_field, name_array_val, 0, buf_len(&test_fn_entry->symbol_name), true);
90829082
9083 ConstExprValue *fn_field = &this_val->data.x_struct.fields[1];
9083 ConstExprValue *fn_field = this_val->data.x_struct.fields[1];
90849084 fn_field->type = fn_type;
90859085 fn_field->special = ConstValSpecialStatic;
90869086 fn_field->data.x_ptr.special = ConstPtrSpecialFunction;
src/ir.cpp+237-245
......@@ -240,7 +240,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
240240 case ConstPtrSpecialBaseStruct: {
241241 ConstExprValue *struct_val = const_val->data.x_ptr.data.base_struct.struct_val;
242242 expand_undef_struct(g, struct_val);
243 result = &struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index];
243 result = struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index];
244244 break;
245245 }
246246 case ConstPtrSpecialBaseErrorUnionCode:
......@@ -10784,9 +10784,9 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_
1078410784 if (src->special != ConstValSpecialStatic)
1078510785 return;
1078610786 if (dest->type->id == ZigTypeIdStruct) {
10787 dest->data.x_struct.fields = create_const_vals(dest->type->data.structure.src_field_count);
10787 dest->data.x_struct.fields = alloc_const_vals_ptrs(dest->type->data.structure.src_field_count);
1078810788 for (size_t i = 0; i < dest->type->data.structure.src_field_count; i += 1) {
10789 copy_const_val(&dest->data.x_struct.fields[i], &src->data.x_struct.fields[i], false);
10789 copy_const_val(dest->data.x_struct.fields[i], src->data.x_struct.fields[i], false);
1079010790 }
1079110791 }
1079210792 }
......@@ -10982,8 +10982,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
1098210982
1098310983 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
1098410984 init_const_slice(ira->codegen, &result->value, pointee, 0, array_type->data.array.len, is_const);
10985 result->value.data.x_struct.fields[slice_ptr_index].data.x_ptr.mut =
10986 value->value.data.x_ptr.mut;
10985 result->value.data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = value->value.data.x_ptr.mut;
1098710986 result->value.type = wanted_type;
1098810987 return result;
1098910988 }
......@@ -13491,8 +13490,8 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
1349113490 if (!const_val)
1349213491 return nullptr;
1349313492
13494 ConstExprValue *ptr_field = &const_val->data.x_struct.fields[slice_ptr_index];
13495 ConstExprValue *len_field = &const_val->data.x_struct.fields[slice_len_index];
13493 ConstExprValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index];
13494 ConstExprValue *len_field = const_val->data.x_struct.fields[slice_len_index];
1349613495
1349713496 assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray);
1349813497 ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val;
......@@ -14820,11 +14819,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1482014819 } else if (is_slice(op1_type)) {
1482114820 ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry;
1482214821 child_type = ptr_type->data.pointer.child_type;
14823 ConstExprValue *ptr_val = &op1_val->data.x_struct.fields[slice_ptr_index];
14822 ConstExprValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index];
1482414823 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
1482514824 op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val;
1482614825 op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index;
14827 ConstExprValue *len_val = &op1_val->data.x_struct.fields[slice_len_index];
14826 ConstExprValue *len_val = op1_val->data.x_struct.fields[slice_len_index];
1482814827 op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint);
1482914828 } else {
1483014829 ir_add_error(ira, op1,
......@@ -14853,11 +14852,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1485314852 } else if (is_slice(op2_type)) {
1485414853 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
1485514854 op2_type_valid = ptr_type->data.pointer.child_type == child_type;
14856 ConstExprValue *ptr_val = &op2_val->data.x_struct.fields[slice_ptr_index];
14855 ConstExprValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index];
1485714856 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
1485814857 op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val;
1485914858 op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index;
14860 ConstExprValue *len_val = &op2_val->data.x_struct.fields[slice_len_index];
14859 ConstExprValue *len_val = op2_val->data.x_struct.fields[slice_len_index];
1486114860 op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint);
1486214861 } else {
1486314862 ir_add_error(ira, op2,
......@@ -14889,17 +14888,17 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1488914888 out_array_val->special = ConstValSpecialStatic;
1489014889 out_array_val->type = get_array_type(ira->codegen, child_type, new_len);
1489114890
14892 out_val->data.x_struct.fields = create_const_vals(2);
14891 out_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
1489314892
14894 out_val->data.x_struct.fields[slice_ptr_index].type = ptr_type;
14895 out_val->data.x_struct.fields[slice_ptr_index].special = ConstValSpecialStatic;
14896 out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.special = ConstPtrSpecialBaseArray;
14897 out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.data.base_array.array_val = out_array_val;
14898 out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.data.base_array.elem_index = 0;
14893 out_val->data.x_struct.fields[slice_ptr_index]->type = ptr_type;
14894 out_val->data.x_struct.fields[slice_ptr_index]->special = ConstValSpecialStatic;
14895 out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.special = ConstPtrSpecialBaseArray;
14896 out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.data.base_array.array_val = out_array_val;
14897 out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.data.base_array.elem_index = 0;
1489914898
14900 out_val->data.x_struct.fields[slice_len_index].type = ira->codegen->builtin_types.entry_usize;
14901 out_val->data.x_struct.fields[slice_len_index].special = ConstValSpecialStatic;
14902 bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index].data.x_bigint, new_len);
14899 out_val->data.x_struct.fields[slice_len_index]->type = ira->codegen->builtin_types.entry_usize;
14900 out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic;
14901 bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len);
1490314902 } else {
1490414903 new_len += 1; // null byte
1490514904
......@@ -16496,17 +16495,10 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1649616495 ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val,
1649716496 source_instr->source_node);
1649816497 struct_val->special = ConstValSpecialStatic;
16499 if (new_field_count > 16) {
16500 // This thing with 16 is a hack to allow this functionality to work without
16501 // modifying the ConstExprValue layout of structs. That reworking needs to be
16502 // done, but this hack lets us do it separately, in the future.
16503 zig_panic("TODO need to rework the layout of ConstExprValue for structs. This realloc would have caused invalid pointer references");
16504 }
16505 if (struct_val->data.x_struct.fields == nullptr) {
16506 struct_val->data.x_struct.fields = create_const_vals(16);
16507 }
16498 struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields,
16499 old_field_count, new_field_count);
1650816500
16509 ConstExprValue *field_val = &struct_val->data.x_struct.fields[old_field_count];
16501 ConstExprValue *field_val = struct_val->data.x_struct.fields[old_field_count];
1651016502 field_val->special = ConstValSpecialUndef;
1651116503 field_val->type = field->type_entry;
1651216504 field_val->parent.id = ConstParentIdStruct;
......@@ -18156,7 +18148,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1815618148
1815718149 init_const_slice(ira->codegen, array_ptr_val, array_init_val, 0, actual_array_type->data.array.len,
1815818150 false);
18159 array_ptr_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.mut = ConstPtrMutInfer;
18151 array_ptr_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutInfer;
1816018152 } else {
1816118153 ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node,
1816218154 buf_sprintf("expected array type or [_], found '%s'",
......@@ -18228,7 +18220,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1822818220 }
1822918221 return result;
1823018222 } else if (is_slice(array_type)) {
18231 ConstExprValue *ptr_field = &array_ptr_val->data.x_struct.fields[slice_ptr_index];
18223 ConstExprValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index];
1823218224 ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base);
1823318225 if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {
1823418226 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
......@@ -18237,7 +18229,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1823718229 result->value.type = return_type;
1823818230 return result;
1823918231 }
18240 ConstExprValue *len_field = &array_ptr_val->data.x_struct.fields[slice_len_index];
18232 ConstExprValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index];
1824118233 IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type);
1824218234 ConstExprValue *out_val = &result->value;
1824318235 uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint);
......@@ -18466,10 +18458,10 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1846618458 if (type_is_invalid(struct_val->type))
1846718459 return ira->codegen->invalid_instruction;
1846818460 if (initializing && struct_val->special == ConstValSpecialUndef) {
18469 struct_val->data.x_struct.fields = create_const_vals(struct_type->data.structure.src_field_count);
18461 struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count);
1847018462 struct_val->special = ConstValSpecialStatic;
1847118463 for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) {
18472 ConstExprValue *field_val = &struct_val->data.x_struct.fields[i];
18464 ConstExprValue *field_val = struct_val->data.x_struct.fields[i];
1847318465 field_val->special = ConstValSpecialUndef;
1847418466 field_val->type = resolve_struct_field_type(ira->codegen,
1847518467 &struct_type->data.structure.fields[i]);
......@@ -21005,17 +20997,17 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2100520997 declaration_val->special = ConstValSpecialStatic;
2100620998 declaration_val->type = type_info_declaration_type;
2100720999
21008 ConstExprValue *inner_fields = create_const_vals(3);
21000 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
2100921001 ConstExprValue *name = create_const_str_lit(ira->codegen, curr_entry->key);
21010 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(curr_entry->key), true);
21011 inner_fields[1].special = ConstValSpecialStatic;
21012 inner_fields[1].type = ira->codegen->builtin_types.entry_bool;
21013 inner_fields[1].data.x_bool = curr_entry->value->visib_mod == VisibModPub;
21014 inner_fields[2].special = ConstValSpecialStatic;
21015 inner_fields[2].type = type_info_declaration_data_type;
21016 inner_fields[2].parent.id = ConstParentIdStruct;
21017 inner_fields[2].parent.data.p_struct.struct_val = declaration_val;
21018 inner_fields[2].parent.data.p_struct.field_index = 1;
21002 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true);
21003 inner_fields[1]->special = ConstValSpecialStatic;
21004 inner_fields[1]->type = ira->codegen->builtin_types.entry_bool;
21005 inner_fields[1]->data.x_bool = curr_entry->value->visib_mod == VisibModPub;
21006 inner_fields[2]->special = ConstValSpecialStatic;
21007 inner_fields[2]->type = type_info_declaration_data_type;
21008 inner_fields[2]->parent.id = ConstParentIdStruct;
21009 inner_fields[2]->parent.data.p_struct.struct_val = declaration_val;
21010 inner_fields[2]->parent.data.p_struct.field_index = 1;
2101921011
2102021012 switch (curr_entry->value->id) {
2102121013 case TldIdVar:
......@@ -21027,19 +21019,19 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2102721019 if (var->const_value->type->id == ZigTypeIdMetaType) {
2102821020 // We have a variable of type 'type', so it's actually a type declaration.
2102921021 // 0: Data.Type: type
21030 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0);
21031 inner_fields[2].data.x_union.payload = var->const_value;
21022 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0);
21023 inner_fields[2]->data.x_union.payload = var->const_value;
2103221024 } else {
2103321025 // We have a variable of another type, so we store the type of the variable.
2103421026 // 1: Data.Var: type
21035 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 1);
21027 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1);
2103621028
2103721029 ConstExprValue *payload = create_const_vals(1);
2103821030 payload->special = ConstValSpecialStatic;
2103921031 payload->type = ira->codegen->builtin_types.entry_type;
2104021032 payload->data.x_type = var->const_value->type;
2104121033
21042 inner_fields[2].data.x_union.payload = payload;
21034 inner_fields[2]->data.x_union.payload = payload;
2104321035 }
2104421036
2104521037 break;
......@@ -21047,7 +21039,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2104721039 case TldIdFn:
2104821040 {
2104921041 // 2: Data.Fn: Data.FnDecl
21050 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2);
21042 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 2);
2105121043
2105221044 ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry;
2105321045 assert(!fn_entry->is_test);
......@@ -21063,63 +21055,63 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2106321055 fn_decl_val->special = ConstValSpecialStatic;
2106421056 fn_decl_val->type = type_info_fn_decl_type;
2106521057 fn_decl_val->parent.id = ConstParentIdUnion;
21066 fn_decl_val->parent.data.p_union.union_val = &inner_fields[2];
21058 fn_decl_val->parent.data.p_union.union_val = inner_fields[2];
2106721059
21068 ConstExprValue *fn_decl_fields = create_const_vals(9);
21060 ConstExprValue **fn_decl_fields = alloc_const_vals_ptrs(9);
2106921061 fn_decl_val->data.x_struct.fields = fn_decl_fields;
2107021062
2107121063 // fn_type: type
2107221064 ensure_field_index(fn_decl_val->type, "fn_type", 0);
21073 fn_decl_fields[0].special = ConstValSpecialStatic;
21074 fn_decl_fields[0].type = ira->codegen->builtin_types.entry_type;
21075 fn_decl_fields[0].data.x_type = fn_entry->type_entry;
21065 fn_decl_fields[0]->special = ConstValSpecialStatic;
21066 fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type;
21067 fn_decl_fields[0]->data.x_type = fn_entry->type_entry;
2107621068 // inline_type: Data.FnDecl.Inline
2107721069 ensure_field_index(fn_decl_val->type, "inline_type", 1);
21078 fn_decl_fields[1].special = ConstValSpecialStatic;
21079 fn_decl_fields[1].type = type_info_fn_decl_inline_type;
21080 bigint_init_unsigned(&fn_decl_fields[1].data.x_enum_tag, fn_entry->fn_inline);
21070 fn_decl_fields[1]->special = ConstValSpecialStatic;
21071 fn_decl_fields[1]->type = type_info_fn_decl_inline_type;
21072 bigint_init_unsigned(&fn_decl_fields[1]->data.x_enum_tag, fn_entry->fn_inline);
2108121073 // calling_convention: TypeInfo.CallingConvention
2108221074 ensure_field_index(fn_decl_val->type, "calling_convention", 2);
21083 fn_decl_fields[2].special = ConstValSpecialStatic;
21084 fn_decl_fields[2].type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
21085 bigint_init_unsigned(&fn_decl_fields[2].data.x_enum_tag, fn_node->cc);
21075 fn_decl_fields[2]->special = ConstValSpecialStatic;
21076 fn_decl_fields[2]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
21077 bigint_init_unsigned(&fn_decl_fields[2]->data.x_enum_tag, fn_node->cc);
2108621078 // is_var_args: bool
2108721079 ensure_field_index(fn_decl_val->type, "is_var_args", 3);
2108821080 bool is_varargs = fn_node->is_var_args;
21089 fn_decl_fields[3].special = ConstValSpecialStatic;
21090 fn_decl_fields[3].type = ira->codegen->builtin_types.entry_bool;
21091 fn_decl_fields[3].data.x_bool = is_varargs;
21081 fn_decl_fields[3]->special = ConstValSpecialStatic;
21082 fn_decl_fields[3]->type = ira->codegen->builtin_types.entry_bool;
21083 fn_decl_fields[3]->data.x_bool = is_varargs;
2109221084 // is_extern: bool
2109321085 ensure_field_index(fn_decl_val->type, "is_extern", 4);
21094 fn_decl_fields[4].special = ConstValSpecialStatic;
21095 fn_decl_fields[4].type = ira->codegen->builtin_types.entry_bool;
21096 fn_decl_fields[4].data.x_bool = fn_node->is_extern;
21086 fn_decl_fields[4]->special = ConstValSpecialStatic;
21087 fn_decl_fields[4]->type = ira->codegen->builtin_types.entry_bool;
21088 fn_decl_fields[4]->data.x_bool = fn_node->is_extern;
2109721089 // is_export: bool
2109821090 ensure_field_index(fn_decl_val->type, "is_export", 5);
21099 fn_decl_fields[5].special = ConstValSpecialStatic;
21100 fn_decl_fields[5].type = ira->codegen->builtin_types.entry_bool;
21101 fn_decl_fields[5].data.x_bool = fn_node->is_export;
21091 fn_decl_fields[5]->special = ConstValSpecialStatic;
21092 fn_decl_fields[5]->type = ira->codegen->builtin_types.entry_bool;
21093 fn_decl_fields[5]->data.x_bool = fn_node->is_export;
2110221094 // lib_name: ?[]const u8
2110321095 ensure_field_index(fn_decl_val->type, "lib_name", 6);
21104 fn_decl_fields[6].special = ConstValSpecialStatic;
21096 fn_decl_fields[6]->special = ConstValSpecialStatic;
2110521097 ZigType *u8_ptr = get_pointer_to_type_extra(
2110621098 ira->codegen, ira->codegen->builtin_types.entry_u8,
2110721099 true, false, PtrLenUnknown,
2110821100 0, 0, 0, false);
21109 fn_decl_fields[6].type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr));
21101 fn_decl_fields[6]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr));
2111021102 if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) {
21111 fn_decl_fields[6].data.x_optional = create_const_vals(1);
21103 fn_decl_fields[6]->data.x_optional = create_const_vals(1);
2111221104 ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name);
21113 init_const_slice(ira->codegen, fn_decl_fields[6].data.x_optional, lib_name, 0,
21105 init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0,
2111421106 buf_len(fn_node->lib_name), true);
2111521107 } else {
21116 fn_decl_fields[6].data.x_optional = nullptr;
21108 fn_decl_fields[6]->data.x_optional = nullptr;
2111721109 }
2111821110 // return_type: type
2111921111 ensure_field_index(fn_decl_val->type, "return_type", 7);
21120 fn_decl_fields[7].special = ConstValSpecialStatic;
21121 fn_decl_fields[7].type = ira->codegen->builtin_types.entry_type;
21122 fn_decl_fields[7].data.x_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;
21112 fn_decl_fields[7]->special = ConstValSpecialStatic;
21113 fn_decl_fields[7]->type = ira->codegen->builtin_types.entry_type;
21114 fn_decl_fields[7]->data.x_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;
2112321115 // arg_names: [][] const u8
2112421116 ensure_field_index(fn_decl_val->type, "arg_names", 8);
2112521117 size_t fn_arg_count = fn_entry->variable_list.length;
......@@ -21130,7 +21122,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2113021122 fn_arg_name_array->data.x_array.special = ConstArraySpecialNone;
2113121123 fn_arg_name_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count);
2113221124
21133 init_const_slice(ira->codegen, &fn_decl_fields[8], fn_arg_name_array, 0, fn_arg_count, false);
21125 init_const_slice(ira->codegen, fn_decl_fields[8], fn_arg_name_array, 0, fn_arg_count, false);
2113421126
2113521127 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
2113621128 ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index);
......@@ -21143,7 +21135,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2114321135 fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index;
2114421136 }
2114521137
21146 inner_fields[2].data.x_union.payload = fn_decl_val;
21138 inner_fields[2]->data.x_union.payload = fn_decl_val;
2114721139 break;
2114821140 }
2114921141 case TldIdContainer:
......@@ -21153,14 +21145,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2115321145 return ErrorSemanticAnalyzeFail;
2115421146
2115521147 // This is a type.
21156 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0);
21148 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0);
2115721149
2115821150 ConstExprValue *payload = create_const_vals(1);
2115921151 payload->special = ConstValSpecialStatic;
2116021152 payload->type = ira->codegen->builtin_types.entry_type;
2116121153 payload->data.x_type = type_entry;
2116221154
21163 inner_fields[2].data.x_union.payload = payload;
21155 inner_fields[2]->data.x_union.payload = payload;
2116421156
2116521157 break;
2116621158 }
......@@ -21169,7 +21161,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2116921161 }
2117021162
2117121163 declaration_val->data.x_struct.fields = inner_fields;
21172 declaration_index++;
21164 declaration_index += 1;
2117321165 }
2117421166
2117521167 assert(declaration_index == declaration_count);
......@@ -21225,42 +21217,42 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty
2122521217 result->special = ConstValSpecialStatic;
2122621218 result->type = type_info_pointer_type;
2122721219
21228 ConstExprValue *fields = create_const_vals(6);
21220 ConstExprValue **fields = alloc_const_vals_ptrs(6);
2122921221 result->data.x_struct.fields = fields;
2123021222
2123121223 // size: Size
2123221224 ensure_field_index(result->type, "size", 0);
2123321225 ZigType *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
2123421226 assertNoError(type_resolve(ira->codegen, type_info_pointer_size_type, ResolveStatusSizeKnown));
21235 fields[0].special = ConstValSpecialStatic;
21236 fields[0].type = type_info_pointer_size_type;
21237 bigint_init_unsigned(&fields[0].data.x_enum_tag, size_enum_index);
21227 fields[0]->special = ConstValSpecialStatic;
21228 fields[0]->type = type_info_pointer_size_type;
21229 bigint_init_unsigned(&fields[0]->data.x_enum_tag, size_enum_index);
2123821230
2123921231 // is_const: bool
2124021232 ensure_field_index(result->type, "is_const", 1);
21241 fields[1].special = ConstValSpecialStatic;
21242 fields[1].type = ira->codegen->builtin_types.entry_bool;
21243 fields[1].data.x_bool = attrs_type->data.pointer.is_const;
21233 fields[1]->special = ConstValSpecialStatic;
21234 fields[1]->type = ira->codegen->builtin_types.entry_bool;
21235 fields[1]->data.x_bool = attrs_type->data.pointer.is_const;
2124421236 // is_volatile: bool
2124521237 ensure_field_index(result->type, "is_volatile", 2);
21246 fields[2].special = ConstValSpecialStatic;
21247 fields[2].type = ira->codegen->builtin_types.entry_bool;
21248 fields[2].data.x_bool = attrs_type->data.pointer.is_volatile;
21238 fields[2]->special = ConstValSpecialStatic;
21239 fields[2]->type = ira->codegen->builtin_types.entry_bool;
21240 fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile;
2124921241 // alignment: u32
2125021242 ensure_field_index(result->type, "alignment", 3);
21251 fields[3].special = ConstValSpecialStatic;
21252 fields[3].type = ira->codegen->builtin_types.entry_num_lit_int;
21253 bigint_init_unsigned(&fields[3].data.x_bigint, get_ptr_align(ira->codegen, attrs_type));
21243 fields[3]->special = ConstValSpecialStatic;
21244 fields[3]->type = ira->codegen->builtin_types.entry_num_lit_int;
21245 bigint_init_unsigned(&fields[3]->data.x_bigint, get_ptr_align(ira->codegen, attrs_type));
2125421246 // child: type
2125521247 ensure_field_index(result->type, "child", 4);
21256 fields[4].special = ConstValSpecialStatic;
21257 fields[4].type = ira->codegen->builtin_types.entry_type;
21258 fields[4].data.x_type = attrs_type->data.pointer.child_type;
21248 fields[4]->special = ConstValSpecialStatic;
21249 fields[4]->type = ira->codegen->builtin_types.entry_type;
21250 fields[4]->data.x_type = attrs_type->data.pointer.child_type;
2125921251 // is_allowzero: bool
2126021252 ensure_field_index(result->type, "is_allowzero", 5);
21261 fields[5].special = ConstValSpecialStatic;
21262 fields[5].type = ira->codegen->builtin_types.entry_bool;
21263 fields[5].data.x_bool = attrs_type->data.pointer.allow_zero;
21253 fields[5]->special = ConstValSpecialStatic;
21254 fields[5]->type = ira->codegen->builtin_types.entry_bool;
21255 fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero;
2126421256
2126521257 return result;
2126621258};
......@@ -21271,14 +21263,14 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val,
2127121263 enum_field_val->special = ConstValSpecialStatic;
2127221264 enum_field_val->type = type_info_enum_field_type;
2127321265
21274 ConstExprValue *inner_fields = create_const_vals(2);
21275 inner_fields[1].special = ConstValSpecialStatic;
21276 inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
21266 ConstExprValue **inner_fields = alloc_const_vals_ptrs(2);
21267 inner_fields[1]->special = ConstValSpecialStatic;
21268 inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
2127721269
2127821270 ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name);
21279 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(enum_field->name), true);
21271 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true);
2128021272
21281 bigint_init_bigint(&inner_fields[1].data.x_bigint, &enum_field->value);
21273 bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value);
2128221274
2128321275 enum_field_val->data.x_struct.fields = inner_fields;
2128421276}
......@@ -21322,19 +21314,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2132221314 result->special = ConstValSpecialStatic;
2132321315 result->type = ir_type_info_get_type(ira, "Int", nullptr);
2132421316
21325 ConstExprValue *fields = create_const_vals(2);
21317 ConstExprValue **fields = alloc_const_vals_ptrs(2);
2132621318 result->data.x_struct.fields = fields;
2132721319
2132821320 // is_signed: bool
2132921321 ensure_field_index(result->type, "is_signed", 0);
21330 fields[0].special = ConstValSpecialStatic;
21331 fields[0].type = ira->codegen->builtin_types.entry_bool;
21332 fields[0].data.x_bool = type_entry->data.integral.is_signed;
21322 fields[0]->special = ConstValSpecialStatic;
21323 fields[0]->type = ira->codegen->builtin_types.entry_bool;
21324 fields[0]->data.x_bool = type_entry->data.integral.is_signed;
2133321325 // bits: u8
2133421326 ensure_field_index(result->type, "bits", 1);
21335 fields[1].special = ConstValSpecialStatic;
21336 fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
21337 bigint_init_unsigned(&fields[1].data.x_bigint, type_entry->data.integral.bit_count);
21327 fields[1]->special = ConstValSpecialStatic;
21328 fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
21329 bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.integral.bit_count);
2133821330
2133921331 break;
2134021332 }
......@@ -21344,14 +21336,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2134421336 result->special = ConstValSpecialStatic;
2134521337 result->type = ir_type_info_get_type(ira, "Float", nullptr);
2134621338
21347 ConstExprValue *fields = create_const_vals(1);
21339 ConstExprValue **fields = alloc_const_vals_ptrs(1);
2134821340 result->data.x_struct.fields = fields;
2134921341
2135021342 // bits: u8
2135121343 ensure_field_index(result->type, "bits", 0);
21352 fields[0].special = ConstValSpecialStatic;
21353 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
21354 bigint_init_unsigned(&fields->data.x_bigint, type_entry->data.floating.bit_count);
21344 fields[0]->special = ConstValSpecialStatic;
21345 fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int;
21346 bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.floating.bit_count);
2135521347
2135621348 break;
2135721349 }
......@@ -21368,19 +21360,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2136821360 result->special = ConstValSpecialStatic;
2136921361 result->type = ir_type_info_get_type(ira, "Array", nullptr);
2137021362
21371 ConstExprValue *fields = create_const_vals(2);
21363 ConstExprValue **fields = alloc_const_vals_ptrs(2);
2137221364 result->data.x_struct.fields = fields;
2137321365
2137421366 // len: usize
2137521367 ensure_field_index(result->type, "len", 0);
21376 fields[0].special = ConstValSpecialStatic;
21377 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
21378 bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len);
21368 fields[0]->special = ConstValSpecialStatic;
21369 fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int;
21370 bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.array.len);
2137921371 // child: type
2138021372 ensure_field_index(result->type, "child", 1);
21381 fields[1].special = ConstValSpecialStatic;
21382 fields[1].type = ira->codegen->builtin_types.entry_type;
21383 fields[1].data.x_type = type_entry->data.array.child_type;
21373 fields[1]->special = ConstValSpecialStatic;
21374 fields[1]->type = ira->codegen->builtin_types.entry_type;
21375 fields[1]->data.x_type = type_entry->data.array.child_type;
2138421376
2138521377 break;
2138621378 }
......@@ -21389,19 +21381,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2138921381 result->special = ConstValSpecialStatic;
2139021382 result->type = ir_type_info_get_type(ira, "Vector", nullptr);
2139121383
21392 ConstExprValue *fields = create_const_vals(2);
21384 ConstExprValue **fields = alloc_const_vals_ptrs(2);
2139321385 result->data.x_struct.fields = fields;
2139421386
2139521387 // len: usize
2139621388 ensure_field_index(result->type, "len", 0);
21397 fields[0].special = ConstValSpecialStatic;
21398 fields[0].type = ira->codegen->builtin_types.entry_num_lit_int;
21399 bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.vector.len);
21389 fields[0]->special = ConstValSpecialStatic;
21390 fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int;
21391 bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.vector.len);
2140021392 // child: type
2140121393 ensure_field_index(result->type, "child", 1);
21402 fields[1].special = ConstValSpecialStatic;
21403 fields[1].type = ira->codegen->builtin_types.entry_type;
21404 fields[1].data.x_type = type_entry->data.vector.elem_type;
21394 fields[1]->special = ConstValSpecialStatic;
21395 fields[1]->type = ira->codegen->builtin_types.entry_type;
21396 fields[1]->data.x_type = type_entry->data.vector.elem_type;
2140521397
2140621398 break;
2140721399 }
......@@ -21411,14 +21403,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2141121403 result->special = ConstValSpecialStatic;
2141221404 result->type = ir_type_info_get_type(ira, "Optional", nullptr);
2141321405
21414 ConstExprValue *fields = create_const_vals(1);
21406 ConstExprValue **fields = alloc_const_vals_ptrs(1);
2141521407 result->data.x_struct.fields = fields;
2141621408
2141721409 // child: type
2141821410 ensure_field_index(result->type, "child", 0);
21419 fields[0].special = ConstValSpecialStatic;
21420 fields[0].type = ira->codegen->builtin_types.entry_type;
21421 fields[0].data.x_type = type_entry->data.maybe.child_type;
21411 fields[0]->special = ConstValSpecialStatic;
21412 fields[0]->type = ira->codegen->builtin_types.entry_type;
21413 fields[0]->data.x_type = type_entry->data.maybe.child_type;
2142221414
2142321415 break;
2142421416 }
......@@ -21427,14 +21419,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2142721419 result->special = ConstValSpecialStatic;
2142821420 result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr);
2142921421
21430 ConstExprValue *fields = create_const_vals(1);
21422 ConstExprValue **fields = alloc_const_vals_ptrs(1);
2143121423 result->data.x_struct.fields = fields;
2143221424
2143321425 // child: ?type
2143421426 ensure_field_index(result->type, "child", 0);
21435 fields[0].special = ConstValSpecialStatic;
21436 fields[0].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
21437 fields[0].data.x_optional = (type_entry->data.any_frame.result_type == nullptr) ? nullptr :
21427 fields[0]->special = ConstValSpecialStatic;
21428 fields[0]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
21429 fields[0]->data.x_optional = (type_entry->data.any_frame.result_type == nullptr) ? nullptr :
2143821430 create_const_type(ira->codegen, type_entry->data.any_frame.result_type);
2143921431 break;
2144021432 }
......@@ -21444,19 +21436,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2144421436 result->special = ConstValSpecialStatic;
2144521437 result->type = ir_type_info_get_type(ira, "Enum", nullptr);
2144621438
21447 ConstExprValue *fields = create_const_vals(4);
21439 ConstExprValue **fields = alloc_const_vals_ptrs(4);
2144821440 result->data.x_struct.fields = fields;
2144921441
2145021442 // layout: ContainerLayout
2145121443 ensure_field_index(result->type, "layout", 0);
21452 fields[0].special = ConstValSpecialStatic;
21453 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21454 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.enumeration.layout);
21444 fields[0]->special = ConstValSpecialStatic;
21445 fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21446 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.enumeration.layout);
2145521447 // tag_type: type
2145621448 ensure_field_index(result->type, "tag_type", 1);
21457 fields[1].special = ConstValSpecialStatic;
21458 fields[1].type = ira->codegen->builtin_types.entry_type;
21459 fields[1].data.x_type = type_entry->data.enumeration.tag_int_type;
21449 fields[1]->special = ConstValSpecialStatic;
21450 fields[1]->type = ira->codegen->builtin_types.entry_type;
21451 fields[1]->data.x_type = type_entry->data.enumeration.tag_int_type;
2146021452 // fields: []TypeInfo.EnumField
2146121453 ensure_field_index(result->type, "fields", 2);
2146221454
......@@ -21472,7 +21464,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2147221464 enum_field_array->data.x_array.special = ConstArraySpecialNone;
2147321465 enum_field_array->data.x_array.data.s_none.elements = create_const_vals(enum_field_count);
2147421466
21475 init_const_slice(ira->codegen, &fields[2], enum_field_array, 0, enum_field_count, false);
21467 init_const_slice(ira->codegen, fields[2], enum_field_array, 0, enum_field_count, false);
2147621468
2147721469 for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++)
2147821470 {
......@@ -21485,7 +21477,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2148521477 }
2148621478 // decls: []TypeInfo.Declaration
2148721479 ensure_field_index(result->type, "decls", 3);
21488 if ((err = ir_make_type_info_decls(ira, source_instr, &fields[3],
21480 if ((err = ir_make_type_info_decls(ira, source_instr, fields[3],
2148921481 type_entry->data.enumeration.decls_scope)))
2149021482 {
2149121483 return err;
......@@ -21528,17 +21520,17 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2152821520 error_val->special = ConstValSpecialStatic;
2152921521 error_val->type = type_info_error_type;
2153021522
21531 ConstExprValue *inner_fields = create_const_vals(2);
21532 inner_fields[1].special = ConstValSpecialStatic;
21533 inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int;
21523 ConstExprValue **inner_fields = alloc_const_vals_ptrs(2);
21524 inner_fields[1]->special = ConstValSpecialStatic;
21525 inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
2153421526
2153521527 ConstExprValue *name = nullptr;
2153621528 if (error->cached_error_name_val != nullptr)
2153721529 name = error->cached_error_name_val;
2153821530 if (name == nullptr)
2153921531 name = create_const_str_lit(ira->codegen, &error->name);
21540 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(&error->name), true);
21541 bigint_init_unsigned(&inner_fields[1].data.x_bigint, error->value);
21532 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(&error->name), true);
21533 bigint_init_unsigned(&inner_fields[1]->data.x_bigint, error->value);
2154221534
2154321535 error_val->data.x_struct.fields = inner_fields;
2154421536 error_val->parent.id = ConstParentIdArray;
......@@ -21554,20 +21546,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2155421546 result->special = ConstValSpecialStatic;
2155521547 result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr);
2155621548
21557 ConstExprValue *fields = create_const_vals(2);
21549 ConstExprValue **fields = alloc_const_vals_ptrs(2);
2155821550 result->data.x_struct.fields = fields;
2155921551
2156021552 // error_set: type
2156121553 ensure_field_index(result->type, "error_set", 0);
21562 fields[0].special = ConstValSpecialStatic;
21563 fields[0].type = ira->codegen->builtin_types.entry_type;
21564 fields[0].data.x_type = type_entry->data.error_union.err_set_type;
21554 fields[0]->special = ConstValSpecialStatic;
21555 fields[0]->type = ira->codegen->builtin_types.entry_type;
21556 fields[0]->data.x_type = type_entry->data.error_union.err_set_type;
2156521557
2156621558 // payload: type
2156721559 ensure_field_index(result->type, "payload", 1);
21568 fields[1].special = ConstValSpecialStatic;
21569 fields[1].type = ira->codegen->builtin_types.entry_type;
21570 fields[1].data.x_type = type_entry->data.error_union.payload_type;
21560 fields[1]->special = ConstValSpecialStatic;
21561 fields[1]->type = ira->codegen->builtin_types.entry_type;
21562 fields[1]->data.x_type = type_entry->data.error_union.payload_type;
2157121563
2157221564 break;
2157321565 }
......@@ -21577,18 +21569,18 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2157721569 result->special = ConstValSpecialStatic;
2157821570 result->type = ir_type_info_get_type(ira, "Union", nullptr);
2157921571
21580 ConstExprValue *fields = create_const_vals(4);
21572 ConstExprValue **fields = alloc_const_vals_ptrs(4);
2158121573 result->data.x_struct.fields = fields;
2158221574
2158321575 // layout: ContainerLayout
2158421576 ensure_field_index(result->type, "layout", 0);
21585 fields[0].special = ConstValSpecialStatic;
21586 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21587 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout);
21577 fields[0]->special = ConstValSpecialStatic;
21578 fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21579 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.unionation.layout);
2158821580 // tag_type: ?type
2158921581 ensure_field_index(result->type, "tag_type", 1);
21590 fields[1].special = ConstValSpecialStatic;
21591 fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
21582 fields[1]->special = ConstValSpecialStatic;
21583 fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
2159221584
2159321585 AstNode *union_decl_node = type_entry->data.unionation.decl_node;
2159421586 if (union_decl_node->data.container_decl.auto_enum ||
......@@ -21598,9 +21590,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2159821590 tag_type->special = ConstValSpecialStatic;
2159921591 tag_type->type = ira->codegen->builtin_types.entry_type;
2160021592 tag_type->data.x_type = type_entry->data.unionation.tag_type;
21601 fields[1].data.x_optional = tag_type;
21593 fields[1]->data.x_optional = tag_type;
2160221594 } else {
21603 fields[1].data.x_optional = nullptr;
21595 fields[1]->data.x_optional = nullptr;
2160421596 }
2160521597 // fields: []TypeInfo.UnionField
2160621598 ensure_field_index(result->type, "fields", 2);
......@@ -21616,7 +21608,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2161621608 union_field_array->data.x_array.special = ConstArraySpecialNone;
2161721609 union_field_array->data.x_array.data.s_none.elements = create_const_vals(union_field_count);
2161821610
21619 init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);
21611 init_const_slice(ira->codegen, fields[2], union_field_array, 0, union_field_count, false);
2162021612
2162121613 ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
2162221614
......@@ -21627,23 +21619,23 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2162721619 union_field_val->special = ConstValSpecialStatic;
2162821620 union_field_val->type = type_info_union_field_type;
2162921621
21630 ConstExprValue *inner_fields = create_const_vals(3);
21631 inner_fields[1].special = ConstValSpecialStatic;
21632 inner_fields[1].type = get_optional_type(ira->codegen, type_info_enum_field_type);
21622 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
21623 inner_fields[1]->special = ConstValSpecialStatic;
21624 inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type);
2163321625
21634 if (fields[1].data.x_optional == nullptr) {
21635 inner_fields[1].data.x_optional = nullptr;
21626 if (fields[1]->data.x_optional == nullptr) {
21627 inner_fields[1]->data.x_optional = nullptr;
2163621628 } else {
21637 inner_fields[1].data.x_optional = create_const_vals(1);
21638 make_enum_field_val(ira, inner_fields[1].data.x_optional, union_field->enum_field, type_info_enum_field_type);
21629 inner_fields[1]->data.x_optional = create_const_vals(1);
21630 make_enum_field_val(ira, inner_fields[1]->data.x_optional, union_field->enum_field, type_info_enum_field_type);
2163921631 }
2164021632
21641 inner_fields[2].special = ConstValSpecialStatic;
21642 inner_fields[2].type = ira->codegen->builtin_types.entry_type;
21643 inner_fields[2].data.x_type = union_field->type_entry;
21633 inner_fields[2]->special = ConstValSpecialStatic;
21634 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
21635 inner_fields[2]->data.x_type = union_field->type_entry;
2164421636
2164521637 ConstExprValue *name = create_const_str_lit(ira->codegen, union_field->name);
21646 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(union_field->name), true);
21638 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true);
2164721639
2164821640 union_field_val->data.x_struct.fields = inner_fields;
2164921641 union_field_val->parent.id = ConstParentIdArray;
......@@ -21652,7 +21644,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2165221644 }
2165321645 // decls: []TypeInfo.Declaration
2165421646 ensure_field_index(result->type, "decls", 3);
21655 if ((err = ir_make_type_info_decls(ira, source_instr, &fields[3],
21647 if ((err = ir_make_type_info_decls(ira, source_instr, fields[3],
2165621648 type_entry->data.unionation.decls_scope)))
2165721649 {
2165821650 return err;
......@@ -21673,14 +21665,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2167321665 result->special = ConstValSpecialStatic;
2167421666 result->type = ir_type_info_get_type(ira, "Struct", nullptr);
2167521667
21676 ConstExprValue *fields = create_const_vals(3);
21668 ConstExprValue **fields = alloc_const_vals_ptrs(3);
2167721669 result->data.x_struct.fields = fields;
2167821670
2167921671 // layout: ContainerLayout
2168021672 ensure_field_index(result->type, "layout", 0);
21681 fields[0].special = ConstValSpecialStatic;
21682 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21683 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.structure.layout);
21673 fields[0]->special = ConstValSpecialStatic;
21674 fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
21675 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.structure.layout);
2168421676 // fields: []TypeInfo.StructField
2168521677 ensure_field_index(result->type, "fields", 1);
2168621678
......@@ -21696,7 +21688,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2169621688 struct_field_array->data.x_array.special = ConstArraySpecialNone;
2169721689 struct_field_array->data.x_array.data.s_none.elements = create_const_vals(struct_field_count);
2169821690
21699 init_const_slice(ira->codegen, &fields[1], struct_field_array, 0, struct_field_count, false);
21691 init_const_slice(ira->codegen, fields[1], struct_field_array, 0, struct_field_count, false);
2170021692
2170121693 for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) {
2170221694 TypeStructField *struct_field = &type_entry->data.structure.fields[struct_field_index];
......@@ -21705,9 +21697,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2170521697 struct_field_val->special = ConstValSpecialStatic;
2170621698 struct_field_val->type = type_info_struct_field_type;
2170721699
21708 ConstExprValue *inner_fields = create_const_vals(3);
21709 inner_fields[1].special = ConstValSpecialStatic;
21710 inner_fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int);
21700 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
21701 inner_fields[1]->special = ConstValSpecialStatic;
21702 inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int);
2171121703
2171221704 ZigType *field_type = resolve_struct_field_type(ira->codegen, struct_field);
2171321705 if (field_type == nullptr)
......@@ -21715,21 +21707,21 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2171521707 if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown)))
2171621708 return err;
2171721709 if (!type_has_bits(struct_field->type_entry)) {
21718 inner_fields[1].data.x_optional = nullptr;
21710 inner_fields[1]->data.x_optional = nullptr;
2171921711 } else {
2172021712 size_t byte_offset = struct_field->offset;
21721 inner_fields[1].data.x_optional = create_const_vals(1);
21722 inner_fields[1].data.x_optional->special = ConstValSpecialStatic;
21723 inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int;
21724 bigint_init_unsigned(&inner_fields[1].data.x_optional->data.x_bigint, byte_offset);
21713 inner_fields[1]->data.x_optional = create_const_vals(1);
21714 inner_fields[1]->data.x_optional->special = ConstValSpecialStatic;
21715 inner_fields[1]->data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int;
21716 bigint_init_unsigned(&inner_fields[1]->data.x_optional->data.x_bigint, byte_offset);
2172521717 }
2172621718
21727 inner_fields[2].special = ConstValSpecialStatic;
21728 inner_fields[2].type = ira->codegen->builtin_types.entry_type;
21729 inner_fields[2].data.x_type = struct_field->type_entry;
21719 inner_fields[2]->special = ConstValSpecialStatic;
21720 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
21721 inner_fields[2]->data.x_type = struct_field->type_entry;
2173021722
2173121723 ConstExprValue *name = create_const_str_lit(ira->codegen, struct_field->name);
21732 init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(struct_field->name), true);
21724 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true);
2173321725
2173421726 struct_field_val->data.x_struct.fields = inner_fields;
2173521727 struct_field_val->parent.id = ConstParentIdArray;
......@@ -21738,7 +21730,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2173821730 }
2173921731 // decls: []TypeInfo.Declaration
2174021732 ensure_field_index(result->type, "decls", 2);
21741 if ((err = ir_make_type_info_decls(ira, source_instr, &fields[2],
21733 if ((err = ir_make_type_info_decls(ira, source_instr, fields[2],
2174221734 type_entry->data.structure.decls_scope)))
2174321735 {
2174421736 return err;
......@@ -21752,38 +21744,38 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2175221744 result->special = ConstValSpecialStatic;
2175321745 result->type = ir_type_info_get_type(ira, "Fn", nullptr);
2175421746
21755 ConstExprValue *fields = create_const_vals(5);
21747 ConstExprValue **fields = alloc_const_vals_ptrs(5);
2175621748 result->data.x_struct.fields = fields;
2175721749
2175821750 // calling_convention: TypeInfo.CallingConvention
2175921751 ensure_field_index(result->type, "calling_convention", 0);
21760 fields[0].special = ConstValSpecialStatic;
21761 fields[0].type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
21762 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);
21752 fields[0]->special = ConstValSpecialStatic;
21753 fields[0]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
21754 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);
2176321755 // is_generic: bool
2176421756 ensure_field_index(result->type, "is_generic", 1);
2176521757 bool is_generic = type_entry->data.fn.is_generic;
21766 fields[1].special = ConstValSpecialStatic;
21767 fields[1].type = ira->codegen->builtin_types.entry_bool;
21768 fields[1].data.x_bool = is_generic;
21758 fields[1]->special = ConstValSpecialStatic;
21759 fields[1]->type = ira->codegen->builtin_types.entry_bool;
21760 fields[1]->data.x_bool = is_generic;
2176921761 // is_varargs: bool
2177021762 ensure_field_index(result->type, "is_var_args", 2);
2177121763 bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args;
21772 fields[2].special = ConstValSpecialStatic;
21773 fields[2].type = ira->codegen->builtin_types.entry_bool;
21774 fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args;
21764 fields[2]->special = ConstValSpecialStatic;
21765 fields[2]->type = ira->codegen->builtin_types.entry_bool;
21766 fields[2]->data.x_bool = type_entry->data.fn.fn_type_id.is_var_args;
2177521767 // return_type: ?type
2177621768 ensure_field_index(result->type, "return_type", 3);
21777 fields[3].special = ConstValSpecialStatic;
21778 fields[3].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
21769 fields[3]->special = ConstValSpecialStatic;
21770 fields[3]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
2177921771 if (type_entry->data.fn.fn_type_id.return_type == nullptr)
21780 fields[3].data.x_optional = nullptr;
21772 fields[3]->data.x_optional = nullptr;
2178121773 else {
2178221774 ConstExprValue *return_type = create_const_vals(1);
2178321775 return_type->special = ConstValSpecialStatic;
2178421776 return_type->type = ira->codegen->builtin_types.entry_type;
2178521777 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
21786 fields[3].data.x_optional = return_type;
21778 fields[3]->data.x_optional = return_type;
2178721779 }
2178821780 // args: []TypeInfo.FnArg
2178921781 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
......@@ -21799,7 +21791,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2179921791 fn_arg_array->data.x_array.special = ConstArraySpecialNone;
2180021792 fn_arg_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count);
2180121793
21802 init_const_slice(ira->codegen, &fields[4], fn_arg_array, 0, fn_arg_count, false);
21794 init_const_slice(ira->codegen, fields[4], fn_arg_array, 0, fn_arg_count, false);
2180321795
2180421796 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
2180521797 FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index];
......@@ -21811,24 +21803,24 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2181121803 bool arg_is_generic = fn_param_info->type == nullptr;
2181221804 if (arg_is_generic) assert(is_generic);
2181321805
21814 ConstExprValue *inner_fields = create_const_vals(3);
21815 inner_fields[0].special = ConstValSpecialStatic;
21816 inner_fields[0].type = ira->codegen->builtin_types.entry_bool;
21817 inner_fields[0].data.x_bool = arg_is_generic;
21818 inner_fields[1].special = ConstValSpecialStatic;
21819 inner_fields[1].type = ira->codegen->builtin_types.entry_bool;
21820 inner_fields[1].data.x_bool = fn_param_info->is_noalias;
21821 inner_fields[2].special = ConstValSpecialStatic;
21822 inner_fields[2].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
21806 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
21807 inner_fields[0]->special = ConstValSpecialStatic;
21808 inner_fields[0]->type = ira->codegen->builtin_types.entry_bool;
21809 inner_fields[0]->data.x_bool = arg_is_generic;
21810 inner_fields[1]->special = ConstValSpecialStatic;
21811 inner_fields[1]->type = ira->codegen->builtin_types.entry_bool;
21812 inner_fields[1]->data.x_bool = fn_param_info->is_noalias;
21813 inner_fields[2]->special = ConstValSpecialStatic;
21814 inner_fields[2]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type);
2182321815
2182421816 if (arg_is_generic)
21825 inner_fields[2].data.x_optional = nullptr;
21817 inner_fields[2]->data.x_optional = nullptr;
2182621818 else {
2182721819 ConstExprValue *arg_type = create_const_vals(1);
2182821820 arg_type->special = ConstValSpecialStatic;
2182921821 arg_type->type = ira->codegen->builtin_types.entry_type;
2183021822 arg_type->data.x_type = fn_param_info->type;
21831 inner_fields[2].data.x_optional = arg_type;
21823 inner_fields[2]->data.x_optional = arg_type;
2183221824 }
2183321825
2183421826 fn_arg_val->data.x_struct.fields = inner_fields;
......@@ -21889,8 +21881,8 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
2188921881static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
2189021882{
2189121883 ensure_field_index(struct_value->type, name, field_index);
21892 assert(struct_value->data.x_struct.fields[field_index].special == ConstValSpecialStatic);
21893 return &struct_value->data.x_struct.fields[field_index];
21884 assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic);
21885 return struct_value->data.x_struct.fields[field_index];
2189421886}
2189521887
2189621888static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
......@@ -22698,7 +22690,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2269822690 if (!val)
2269922691 return ira->codegen->invalid_instruction;
2270022692
22701 ConstExprValue *len_val = &val->data.x_struct.fields[slice_len_index];
22693 ConstExprValue *len_val = val->data.x_struct.fields[slice_len_index];
2270222694 if (value_is_comptime(len_val)) {
2270322695 known_len = bigint_as_u64(&len_val->data.x_bigint);
2270422696 have_known_len = true;
......@@ -22765,17 +22757,17 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
2276522757 return ira->codegen->invalid_instruction;
2276622758
2276722759 IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type);
22768 result->value.data.x_struct.fields = create_const_vals(2);
22760 result->value.data.x_struct.fields = alloc_const_vals_ptrs(2);
2276922761
22770 ConstExprValue *ptr_val = &result->value.data.x_struct.fields[slice_ptr_index];
22771 ConstExprValue *target_ptr_val = &target_val->data.x_struct.fields[slice_ptr_index];
22762 ConstExprValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index];
22763 ConstExprValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index];
2277222764 copy_const_val(ptr_val, target_ptr_val, false);
2277322765 ptr_val->type = dest_ptr_type;
2277422766
22775 ConstExprValue *len_val = &result->value.data.x_struct.fields[slice_len_index];
22767 ConstExprValue *len_val = result->value.data.x_struct.fields[slice_len_index];
2277622768 len_val->special = ConstValSpecialStatic;
2277722769 len_val->type = ira->codegen->builtin_types.entry_usize;
22778 ConstExprValue *target_len_val = &target_val->data.x_struct.fields[slice_len_index];
22770 ConstExprValue *target_len_val = target_val->data.x_struct.fields[slice_len_index];
2277922771 ZigType *elem_type = src_ptr_type->data.pointer.child_type;
2278022772 BigInt elem_size_bigint;
2278122773 bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type));
......@@ -23664,13 +23656,13 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2366423656 return ira->codegen->invalid_instruction;
2366523657 }
2366623658
23667 parent_ptr = &slice_ptr->data.x_struct.fields[slice_ptr_index];
23659 parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index];
2366823660 if (parent_ptr->special == ConstValSpecialUndef) {
2366923661 ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined"));
2367023662 return ira->codegen->invalid_instruction;
2367123663 }
2367223664
23673 ConstExprValue *len_val = &slice_ptr->data.x_struct.fields[slice_len_index];
23665 ConstExprValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index];
2367423666
2367523667 switch (parent_ptr->data.x_ptr.special) {
2367623668 case ConstPtrSpecialInvalid:
......@@ -23742,9 +23734,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2374223734
2374323735 IrInstruction *result = ir_const(ira, &instruction->base, return_type);
2374423736 ConstExprValue *out_val = &result->value;
23745 out_val->data.x_struct.fields = create_const_vals(2);
23737 out_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
2374623738
23747 ConstExprValue *ptr_val = &out_val->data.x_struct.fields[slice_ptr_index];
23739 ConstExprValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index];
2374823740
2374923741 if (array_val) {
2375023742 size_t index = abs_offset + start_scalar;
......@@ -23791,7 +23783,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2379123783 zig_panic("TODO");
2379223784 }
2379323785
23794 ConstExprValue *len_val = &out_val->data.x_struct.fields[slice_len_index];
23786 ConstExprValue *len_val = out_val->data.x_struct.fields[slice_len_index];
2379523787 init_const_usize(ira->codegen, len_val, end_scalar - start_scalar);
2379623788
2379723789 return result;
......@@ -25141,7 +25133,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
2514125133 TypeStructField *struct_field = &val->type->data.structure.fields[field_i];
2514225134 if (struct_field->gen_index == SIZE_MAX)
2514325135 continue;
25144 ConstExprValue *field_val = &val->data.x_struct.fields[field_i];
25136 ConstExprValue *field_val = val->data.x_struct.fields[field_i];
2514525137 size_t offset = struct_field->offset;
2514625138 buf_write_value_bytes(codegen, buf + offset, field_val);
2514725139 }
......@@ -25172,7 +25164,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
2517225164 if (field->gen_index != gen_i)
2517325165 break;
2517425166 uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry);
25175 buf_write_value_bytes(codegen, child_buf, &val->data.x_struct.fields[src_i]);
25167 buf_write_value_bytes(codegen, child_buf, val->data.x_struct.fields[src_i]);
2517625168 BigInt child_val;
2517725169 bigint_read_twos_complement(&child_val, child_buf, packed_bits_size, is_big_endian,
2517825170 false);
......@@ -25310,9 +25302,9 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2531025302 }
2531125303 case ContainerLayoutExtern: {
2531225304 size_t src_field_count = val->type->data.structure.src_field_count;
25313 val->data.x_struct.fields = create_const_vals(src_field_count);
25305 val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count);
2531425306 for (size_t field_i = 0; field_i < src_field_count; field_i += 1) {
25315 ConstExprValue *field_val = &val->data.x_struct.fields[field_i];
25307 ConstExprValue *field_val = val->data.x_struct.fields[field_i];
2531625308 field_val->special = ConstValSpecialStatic;
2531725309 TypeStructField *struct_field = &val->type->data.structure.fields[field_i];
2531825310 field_val->type = struct_field->type_entry;
......@@ -25327,7 +25319,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2532725319 }
2532825320 case ContainerLayoutPacked: {
2532925321 size_t src_field_count = val->type->data.structure.src_field_count;
25330 val->data.x_struct.fields = create_const_vals(src_field_count);
25322 val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count);
2533125323 size_t gen_field_count = val->type->data.structure.gen_field_count;
2533225324 size_t gen_i = 0;
2533325325 size_t src_i = 0;
......@@ -25349,7 +25341,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2534925341 src_assert(field->gen_index != SIZE_MAX, source_node);
2535025342 if (field->gen_index != gen_i)
2535125343 break;
25352 ConstExprValue *field_val = &val->data.x_struct.fields[src_i];
25344 ConstExprValue *field_val = val->data.x_struct.fields[src_i];
2535325345 field_val->special = ConstValSpecialStatic;
2535425346 field_val->type = field->type_entry;
2535525347 uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry);