authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-11-25 15:04:39-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-11-25 15:04:39-05:00
log8f3e972da6badf6df82c88ba0c60aca7b545f62c
tree69aff6bcef8a2a594e94e74717ede5e42b5f46f2
parentacd95546b73bafca6e73af6f22c5e7c963c5c0c3
signaturelock-open Commit is signed but in an unrecognized format.

unembed ZigValue from IrInstruction


5 files changed, 1454 insertions(+), 1451 deletions(-)

src/all_types.hpp+1-1
......@@ -2621,7 +2621,7 @@ struct IrInstruction {
26212621 Scope *scope;
26222622 AstNode *source_node;
26232623 LLVMValueRef llvm_value;
2624 ZigValue value;
2624 ZigValue *value;
26252625 uint32_t debug_id;
26262626 // if ref_count is zero and the instruction has no side effects,
26272627 // the instruction can be omitted in codegen
src/analyze.cpp+35-33
......@@ -1134,7 +1134,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent
11341134 case LazyValueIdPtrType: {
11351135 LazyValuePtrType *lazy_ptr_type = reinterpret_cast<LazyValuePtrType *>(type_val->data.x_lazy);
11361136
1137 if (parent_type_val == &lazy_ptr_type->elem_type->value) {
1137 if (parent_type_val == lazy_ptr_type->elem_type->value) {
11381138 // Does a struct which contains a pointer field to itself have bits? Yes.
11391139 *is_zero_bits = false;
11401140 return ErrorNone;
......@@ -1142,7 +1142,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent
11421142 if (parent_type_val == nullptr) {
11431143 parent_type_val = type_val;
11441144 }
1145 return type_val_resolve_zero_bits(g, &lazy_ptr_type->elem_type->value, parent_type,
1145 return type_val_resolve_zero_bits(g, lazy_ptr_type->elem_type->value, parent_type,
11461146 parent_type_val, is_zero_bits);
11471147 }
11481148 }
......@@ -1197,21 +1197,21 @@ static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ZigValue *type
11971197 zig_unreachable();
11981198 case LazyValueIdSliceType: {
11991199 LazyValueSliceType *lazy_slice_type = reinterpret_cast<LazyValueSliceType *>(type_val->data.x_lazy);
1200 return type_val_resolve_requires_comptime(g, &lazy_slice_type->elem_type->value);
1200 return type_val_resolve_requires_comptime(g, lazy_slice_type->elem_type->value);
12011201 }
12021202 case LazyValueIdPtrType: {
12031203 LazyValuePtrType *lazy_ptr_type = reinterpret_cast<LazyValuePtrType *>(type_val->data.x_lazy);
1204 return type_val_resolve_requires_comptime(g, &lazy_ptr_type->elem_type->value);
1204 return type_val_resolve_requires_comptime(g, lazy_ptr_type->elem_type->value);
12051205 }
12061206 case LazyValueIdOptType: {
12071207 LazyValueOptType *lazy_opt_type = reinterpret_cast<LazyValueOptType *>(type_val->data.x_lazy);
1208 return type_val_resolve_requires_comptime(g, &lazy_opt_type->payload_type->value);
1208 return type_val_resolve_requires_comptime(g, lazy_opt_type->payload_type->value);
12091209 }
12101210 case LazyValueIdFnType: {
12111211 LazyValueFnType *lazy_fn_type = reinterpret_cast<LazyValueFnType *>(type_val->data.x_lazy);
12121212 if (lazy_fn_type->is_generic)
12131213 return ReqCompTimeYes;
1214 switch (type_val_resolve_requires_comptime(g, &lazy_fn_type->return_type->value)) {
1214 switch (type_val_resolve_requires_comptime(g, lazy_fn_type->return_type->value)) {
12151215 case ReqCompTimeInvalid:
12161216 return ReqCompTimeInvalid;
12171217 case ReqCompTimeYes:
......@@ -1224,7 +1224,7 @@ static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ZigValue *type
12241224 AstNode *param_node = lazy_fn_type->proto_node->data.fn_proto.params.at(i);
12251225 bool param_is_var_args = param_node->data.param_decl.is_var_args;
12261226 if (param_is_var_args) break;
1227 switch (type_val_resolve_requires_comptime(g, &lazy_fn_type->param_types[i]->value)) {
1227 switch (type_val_resolve_requires_comptime(g, lazy_fn_type->param_types[i]->value)) {
12281228 case ReqCompTimeInvalid:
12291229 return ReqCompTimeInvalid;
12301230 case ReqCompTimeYes:
......@@ -1238,7 +1238,7 @@ static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ZigValue *type
12381238 case LazyValueIdErrUnionType: {
12391239 LazyValueErrUnionType *lazy_err_union_type =
12401240 reinterpret_cast<LazyValueErrUnionType *>(type_val->data.x_lazy);
1241 return type_val_resolve_requires_comptime(g, &lazy_err_union_type->payload_type->value);
1241 return type_val_resolve_requires_comptime(g, lazy_err_union_type->payload_type->value);
12421242 }
12431243 }
12441244 zig_unreachable();
......@@ -1267,7 +1267,7 @@ start_over:
12671267 case LazyValueIdSliceType: {
12681268 LazyValueSliceType *lazy_slice_type = reinterpret_cast<LazyValueSliceType *>(type_val->data.x_lazy);
12691269 bool is_zero_bits;
1270 if ((err = type_val_resolve_zero_bits(g, &lazy_slice_type->elem_type->value, nullptr,
1270 if ((err = type_val_resolve_zero_bits(g, lazy_slice_type->elem_type->value, nullptr,
12711271 nullptr, &is_zero_bits)))
12721272 {
12731273 return err;
......@@ -1284,7 +1284,7 @@ start_over:
12841284 case LazyValueIdPtrType: {
12851285 LazyValuePtrType *lazy_ptr_type = reinterpret_cast<LazyValuePtrType *>(type_val->data.x_lazy);
12861286 bool is_zero_bits;
1287 if ((err = type_val_resolve_zero_bits(g, &lazy_ptr_type->elem_type->value, nullptr,
1287 if ((err = type_val_resolve_zero_bits(g, lazy_ptr_type->elem_type->value, nullptr,
12881288 nullptr, &is_zero_bits)))
12891289 {
12901290 return err;
......@@ -1337,13 +1337,13 @@ Error type_val_resolve_abi_align(CodeGen *g, ZigValue *type_val, uint32_t *abi_a
13371337 return ErrorNone;
13381338 case LazyValueIdOptType: {
13391339 LazyValueOptType *lazy_opt_type = reinterpret_cast<LazyValueOptType *>(type_val->data.x_lazy);
1340 return type_val_resolve_abi_align(g, &lazy_opt_type->payload_type->value, abi_align);
1340 return type_val_resolve_abi_align(g, lazy_opt_type->payload_type->value, abi_align);
13411341 }
13421342 case LazyValueIdErrUnionType: {
13431343 LazyValueErrUnionType *lazy_err_union_type =
13441344 reinterpret_cast<LazyValueErrUnionType *>(type_val->data.x_lazy);
13451345 uint32_t payload_abi_align;
1346 if ((err = type_val_resolve_abi_align(g, &lazy_err_union_type->payload_type->value,
1346 if ((err = type_val_resolve_abi_align(g, lazy_err_union_type->payload_type->value,
13471347 &payload_abi_align)))
13481348 {
13491349 return err;
......@@ -1384,13 +1384,13 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigV
13841384 case LazyValueIdErrUnionType: {
13851385 LazyValueErrUnionType *lazy_err_union_type =
13861386 reinterpret_cast<LazyValueErrUnionType *>(type_val->data.x_lazy);
1387 switch (type_val_resolve_has_one_possible_value(g, &lazy_err_union_type->err_set_type->value)) {
1387 switch (type_val_resolve_has_one_possible_value(g, lazy_err_union_type->err_set_type->value)) {
13881388 case OnePossibleValueInvalid:
13891389 return OnePossibleValueInvalid;
13901390 case OnePossibleValueNo:
13911391 return OnePossibleValueNo;
13921392 case OnePossibleValueYes:
1393 return type_val_resolve_has_one_possible_value(g, &lazy_err_union_type->payload_type->value);
1393 return type_val_resolve_has_one_possible_value(g, lazy_err_union_type->payload_type->value);
13941394 }
13951395 }
13961396 }
......@@ -3985,7 +3985,7 @@ static void preview_use_decl(CodeGen *g, TldUsingNamespace *using_namespace, Sco
39853985 if (type_is_invalid(result->type)) {
39863986 dest_decls_scope->any_imports_failed = true;
39873987 using_namespace->base.resolution = TldResolutionInvalid;
3988 using_namespace->using_namespace_value = &g->invalid_instruction->value;
3988 using_namespace->using_namespace_value = g->invalid_instruction->value;
39893989 return;
39903990 }
39913991
......@@ -3994,7 +3994,7 @@ static void preview_use_decl(CodeGen *g, TldUsingNamespace *using_namespace, Sco
39943994 buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&result->data.x_type->name)));
39953995 dest_decls_scope->any_imports_failed = true;
39963996 using_namespace->base.resolution = TldResolutionInvalid;
3997 using_namespace->using_namespace_value = &g->invalid_instruction->value;
3997 using_namespace->using_namespace_value = g->invalid_instruction->value;
39983998 return;
39993999 }
40004000}
......@@ -6106,7 +6106,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
61066106 alloca_gen->base.id = IrInstructionIdAllocaGen;
61076107 alloca_gen->base.source_node = fn->proto_node;
61086108 alloca_gen->base.scope = fn->child_scope;
6109 alloca_gen->base.value.type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
6109 alloca_gen->base.value = allocate<ZigValue>(1, "ZigValue");
6110 alloca_gen->base.value->type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
61106111 alloca_gen->base.ref_count = 1;
61116112 alloca_gen->name_hint = "";
61126113 fn->alloca_gen_list.append(alloca_gen);
......@@ -6173,7 +6174,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
61736174 call->frame_result_loc = all_calls_alloca;
61746175 }
61756176 if (largest_call_frame_type != nullptr) {
6176 all_calls_alloca->value.type = get_pointer_to_type(g, largest_call_frame_type, false);
6177 all_calls_alloca->value->type = get_pointer_to_type(g, largest_call_frame_type, false);
61776178 }
61786179
61796180 // Since this frame is async, an await might represent a suspend point, and
......@@ -6184,7 +6185,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
61846185 IrInstructionAwaitGen *await = fn->await_list.at(i);
61856186 // TODO If this is a noasync await, it doesn't suspend
61866187 // https://github.com/ziglang/zig/issues/3157
6187 if (await->base.value.special != ConstValSpecialRuntime) {
6188 if (await->base.value->special != ConstValSpecialRuntime) {
61886189 // Known at comptime. No spill, no suspend.
61896190 continue;
61906191 }
......@@ -6211,10 +6212,10 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
62116212 }
62126213 if (await->base.ref_count == 0)
62136214 continue;
6214 if (!type_has_bits(await->base.value.type))
6215 if (!type_has_bits(await->base.value->type))
62156216 continue;
62166217 await->result_loc = ir_create_alloca(g, await->base.scope, await->base.source_node, fn,
6217 await->base.value.type, "");
6218 await->base.value->type, "");
62186219 }
62196220 for (size_t block_i = 0; block_i < fn->analyzed_executable.basic_block_list.length; block_i += 1) {
62206221 IrBasicBlock *block = fn->analyzed_executable.basic_block_list.at(block_i);
......@@ -6239,17 +6240,17 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
62396240 // This instruction does its own spilling specially, or otherwise doesn't need it.
62406241 continue;
62416242 }
6242 if (instruction->value.special != ConstValSpecialRuntime)
6243 if (instruction->value->special != ConstValSpecialRuntime)
62436244 continue;
62446245 if (instruction->ref_count == 0)
62456246 continue;
6246 if ((err = type_resolve(g, instruction->value.type, ResolveStatusZeroBitsKnown)))
6247 if ((err = type_resolve(g, instruction->value->type, ResolveStatusZeroBitsKnown)))
62476248 return ErrorSemanticAnalyzeFail;
6248 if (!type_has_bits(instruction->value.type))
6249 if (!type_has_bits(instruction->value->type))
62496250 continue;
62506251 if (scope_needs_spill(instruction->scope)) {
62516252 instruction->spill = ir_create_alloca(g, instruction->scope, instruction->source_node,
6252 fn, instruction->value.type, "");
6253 fn, instruction->value->type, "");
62536254 }
62546255 }
62556256 }
......@@ -6301,15 +6302,15 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
63016302 for (size_t alloca_i = 0; alloca_i < fn->alloca_gen_list.length; alloca_i += 1) {
63026303 IrInstructionAllocaGen *instruction = fn->alloca_gen_list.at(alloca_i);
63036304 instruction->field_index = SIZE_MAX;
6304 ZigType *ptr_type = instruction->base.value.type;
6305 ZigType *ptr_type = instruction->base.value->type;
63056306 assert(ptr_type->id == ZigTypeIdPointer);
63066307 ZigType *child_type = ptr_type->data.pointer.child_type;
63076308 if (!type_has_bits(child_type))
63086309 continue;
63096310 if (instruction->base.ref_count == 0)
63106311 continue;
6311 if (instruction->base.value.special != ConstValSpecialRuntime) {
6312 if (const_ptr_pointee(nullptr, g, &instruction->base.value, nullptr)->special !=
6312 if (instruction->base.value->special != ConstValSpecialRuntime) {
6313 if (const_ptr_pointee(nullptr, g, instruction->base.value, nullptr)->special !=
63136314 ConstValSpecialRuntime)
63146315 {
63156316 continue;
......@@ -6446,14 +6447,14 @@ bool ir_get_var_is_comptime(ZigVar *var) {
64466447 // When the is_comptime field references an instruction that has to get analyzed, this
64476448 // is the value.
64486449 if (var->is_comptime->child != nullptr) {
6449 assert(var->is_comptime->child->value.type->id == ZigTypeIdBool);
6450 return var->is_comptime->child->value.data.x_bool;
6450 assert(var->is_comptime->child->value->type->id == ZigTypeIdBool);
6451 return var->is_comptime->child->value->data.x_bool;
64516452 }
64526453 // As an optimization, is_comptime values which are constant are allowed
64536454 // to be omitted from analysis. In this case, there is no child instruction
64546455 // and we simply look at the unanalyzed const parent instruction.
6455 assert(var->is_comptime->value.type->id == ZigTypeIdBool);
6456 return var->is_comptime->value.data.x_bool;
6456 assert(var->is_comptime->value->type->id == ZigTypeIdBool);
6457 return var->is_comptime->value->data.x_bool;
64576458}
64586459
64596460bool const_values_equal_ptr(ZigValue *a, ZigValue *b) {
......@@ -9113,7 +9114,8 @@ IrInstruction *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node,
91139114 alloca_gen->base.id = IrInstructionIdAllocaGen;
91149115 alloca_gen->base.source_node = source_node;
91159116 alloca_gen->base.scope = scope;
9116 alloca_gen->base.value.type = get_pointer_to_type(g, var_type, false);
9117 alloca_gen->base.value = allocate<ZigValue>(1, "ZigValue");
9118 alloca_gen->base.value->type = get_pointer_to_type(g, var_type, false);
91179119 alloca_gen->base.ref_count = 1;
91189120 alloca_gen->name_hint = name_hint;
91199121 fn->alloca_gen_list.append(alloca_gen);
src/codegen.cpp+151-149
......@@ -1700,37 +1700,37 @@ static void gen_var_debug_decl(CodeGen *g, ZigVar *var) {
17001700
17011701static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {
17021702 Error err;
1703 if ((err = type_resolve(g, instruction->value.type, ResolveStatusZeroBitsKnown))) {
1703 if ((err = type_resolve(g, instruction->value->type, ResolveStatusZeroBitsKnown))) {
17041704 codegen_report_errors_and_exit(g);
17051705 }
1706 if (!type_has_bits(instruction->value.type))
1706 if (!type_has_bits(instruction->value->type))
17071707 return nullptr;
17081708 if (!instruction->llvm_value) {
17091709 if (instruction->id == IrInstructionIdAwaitGen) {
17101710 IrInstructionAwaitGen *await = reinterpret_cast<IrInstructionAwaitGen*>(instruction);
17111711 if (await->result_loc != nullptr) {
17121712 return get_handle_value(g, ir_llvm_value(g, await->result_loc),
1713 await->result_loc->value.type->data.pointer.child_type, await->result_loc->value.type);
1713 await->result_loc->value->type->data.pointer.child_type, await->result_loc->value->type);
17141714 }
17151715 }
17161716 if (instruction->spill != nullptr) {
1717 ZigType *ptr_type = instruction->spill->value.type;
1717 ZigType *ptr_type = instruction->spill->value->type;
17181718 ir_assert(ptr_type->id == ZigTypeIdPointer, instruction);
17191719 return get_handle_value(g, ir_llvm_value(g, instruction->spill),
1720 ptr_type->data.pointer.child_type, instruction->spill->value.type);
1720 ptr_type->data.pointer.child_type, instruction->spill->value->type);
17211721 }
1722 ir_assert(instruction->value.special != ConstValSpecialRuntime, instruction);
1723 assert(instruction->value.type);
1724 render_const_val(g, &instruction->value, "");
1722 ir_assert(instruction->value->special != ConstValSpecialRuntime, instruction);
1723 assert(instruction->value->type);
1724 render_const_val(g, instruction->value, "");
17251725 // we might have to do some pointer casting here due to the way union
17261726 // values are rendered with a type other than the one we expect
1727 if (handle_is_ptr(instruction->value.type)) {
1728 render_const_val_global(g, &instruction->value, "");
1729 ZigType *ptr_type = get_pointer_to_type(g, instruction->value.type, true);
1730 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_global, get_llvm_type(g, ptr_type), "");
1727 if (handle_is_ptr(instruction->value->type)) {
1728 render_const_val_global(g, instruction->value, "");
1729 ZigType *ptr_type = get_pointer_to_type(g, instruction->value->type, true);
1730 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value->global_refs->llvm_global, get_llvm_type(g, ptr_type), "");
17311731 } else {
1732 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_value,
1733 get_llvm_type(g, instruction->value.type), "");
1732 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value->global_refs->llvm_value,
1733 get_llvm_type(g, instruction->value->type), "");
17341734 }
17351735 assert(instruction->llvm_value);
17361736 }
......@@ -1791,7 +1791,7 @@ static bool iter_function_params_c_abi(CodeGen *g, ZigType *fn_type, FnWalk *fn_
17911791 if (src_i >= fn_walk->data.call.inst->arg_count)
17921792 return false;
17931793 IrInstruction *arg = fn_walk->data.call.inst->args[src_i];
1794 ty = arg->value.type;
1794 ty = arg->value->type;
17951795 source_node = arg->source_node;
17961796 val = ir_llvm_value(g, arg);
17971797 break;
......@@ -2029,7 +2029,7 @@ void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk) {
20292029 bool is_var_args = fn_walk->data.call.is_var_args;
20302030 for (size_t call_i = 0; call_i < instruction->arg_count; call_i += 1) {
20312031 IrInstruction *param_instruction = instruction->args[call_i];
2032 ZigType *param_type = param_instruction->value.type;
2032 ZigType *param_type = param_instruction->value->type;
20332033 if (is_var_args || type_has_bits(param_type)) {
20342034 LLVMValueRef param_value = ir_llvm_value(g, param_instruction);
20352035 assert(param_value);
......@@ -2345,13 +2345,13 @@ static LLVMValueRef gen_maybe_atomic_op(CodeGen *g, LLVMAtomicRMWBinOp op, LLVMV
23452345static void gen_async_return(CodeGen *g, IrInstructionReturn *instruction) {
23462346 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
23472347
2348 ZigType *operand_type = (instruction->operand != nullptr) ? instruction->operand->value.type : nullptr;
2348 ZigType *operand_type = (instruction->operand != nullptr) ? instruction->operand->value->type : nullptr;
23492349 bool operand_has_bits = (operand_type != nullptr) && type_has_bits(operand_type);
23502350 ZigType *ret_type = g->cur_fn->type_entry->data.fn.fn_type_id.return_type;
23512351 bool ret_type_has_bits = type_has_bits(ret_type);
23522352
23532353 if (operand_has_bits && instruction->operand != nullptr) {
2354 bool need_store = instruction->operand->value.special != ConstValSpecialRuntime || !handle_is_ptr(ret_type);
2354 bool need_store = instruction->operand->value->special != ConstValSpecialRuntime || !handle_is_ptr(ret_type);
23552355 if (need_store) {
23562356 // It didn't get written to the result ptr. We do that now.
23572357 ZigType *ret_ptr_type = get_pointer_to_type(g, ret_type, true);
......@@ -2448,9 +2448,9 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns
24482448 return nullptr;
24492449 }
24502450 assert(g->cur_ret_ptr);
2451 ir_assert(instruction->operand->value.special != ConstValSpecialRuntime, &instruction->base);
2451 ir_assert(instruction->operand->value->special != ConstValSpecialRuntime, &instruction->base);
24522452 LLVMValueRef value = ir_llvm_value(g, instruction->operand);
2453 ZigType *return_type = instruction->operand->value.type;
2453 ZigType *return_type = instruction->operand->value->type;
24542454 gen_assign_raw(g, g->cur_ret_ptr, get_pointer_to_type(g, return_type, false), value);
24552455 LLVMBuildRetVoid(g->builder);
24562456 } else if (g->cur_fn->type_entry->data.fn.fn_type_id.cc != CallingConventionAsync &&
......@@ -2784,7 +2784,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
27842784 IrInstruction *op1 = bin_op_instruction->op1;
27852785 IrInstruction *op2 = bin_op_instruction->op2;
27862786
2787 ZigType *operand_type = op1->value.type;
2787 ZigType *operand_type = op1->value->type;
27882788 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? operand_type->data.vector.elem_type : operand_type;
27892789
27902790 bool want_runtime_safety = bin_op_instruction->safety_check_on &&
......@@ -2884,7 +2884,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
28842884 case IrBinOpBitShiftLeftExact:
28852885 {
28862886 assert(scalar_type->id == ZigTypeIdInt);
2887 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value.type, scalar_type, op2_value);
2887 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value);
28882888 bool is_sloppy = (op_id == IrBinOpBitShiftLeftLossy);
28892889 if (is_sloppy) {
28902890 return LLVMBuildShl(g->builder, op1_value, op2_casted, "");
......@@ -2900,7 +2900,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
29002900 case IrBinOpBitShiftRightExact:
29012901 {
29022902 assert(scalar_type->id == ZigTypeIdInt);
2903 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value.type, scalar_type, op2_value);
2903 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value);
29042904 bool is_sloppy = (op_id == IrBinOpBitShiftRightLossy);
29052905 if (is_sloppy) {
29062906 if (scalar_type->data.integral.is_signed) {
......@@ -2990,8 +2990,8 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in
29902990static LLVMValueRef ir_render_resize_slice(CodeGen *g, IrExecutable *executable,
29912991 IrInstructionResizeSlice *instruction)
29922992{
2993 ZigType *actual_type = instruction->operand->value.type;
2994 ZigType *wanted_type = instruction->base.value.type;
2993 ZigType *actual_type = instruction->operand->value->type;
2994 ZigType *wanted_type = instruction->base.value->type;
29952995 LLVMValueRef expr_val = ir_llvm_value(g, instruction->operand);
29962996 assert(expr_val);
29972997
......@@ -3058,8 +3058,8 @@ static LLVMValueRef ir_render_resize_slice(CodeGen *g, IrExecutable *executable,
30583058static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
30593059 IrInstructionCast *cast_instruction)
30603060{
3061 ZigType *actual_type = cast_instruction->value->value.type;
3062 ZigType *wanted_type = cast_instruction->base.value.type;
3061 ZigType *actual_type = cast_instruction->value->value->type;
3062 ZigType *wanted_type = cast_instruction->base.value->type;
30633063 LLVMValueRef expr_val = ir_llvm_value(g, cast_instruction->value);
30643064 assert(expr_val);
30653065
......@@ -3136,8 +3136,8 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
31363136static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutable *executable,
31373137 IrInstructionPtrOfArrayToSlice *instruction)
31383138{
3139 ZigType *actual_type = instruction->operand->value.type;
3140 ZigType *slice_type = instruction->base.value.type;
3139 ZigType *actual_type = instruction->operand->value->type;
3140 ZigType *slice_type = instruction->base.value->type;
31413141 ZigType *slice_ptr_type = slice_type->data.structure.fields[slice_ptr_index]->type_entry;
31423142 size_t ptr_index = slice_type->data.structure.fields[slice_ptr_index]->gen_index;
31433143 size_t len_index = slice_type->data.structure.fields[slice_len_index]->gen_index;
......@@ -3173,7 +3173,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutable *ex
31733173static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
31743174 IrInstructionPtrCastGen *instruction)
31753175{
3176 ZigType *wanted_type = instruction->base.value.type;
3176 ZigType *wanted_type = instruction->base.value->type;
31773177 if (!type_has_bits(wanted_type)) {
31783178 return nullptr;
31793179 }
......@@ -3199,8 +3199,8 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
31993199static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
32003200 IrInstructionBitCastGen *instruction)
32013201{
3202 ZigType *wanted_type = instruction->base.value.type;
3203 ZigType *actual_type = instruction->operand->value.type;
3202 ZigType *wanted_type = instruction->base.value->type;
3203 ZigType *actual_type = instruction->operand->value->type;
32043204 LLVMValueRef value = ir_llvm_value(g, instruction->operand);
32053205
32063206 bool wanted_is_ptr = handle_is_ptr(wanted_type);
......@@ -3223,7 +3223,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
32233223static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executable,
32243224 IrInstructionWidenOrShorten *instruction)
32253225{
3226 ZigType *actual_type = instruction->target->value.type;
3226 ZigType *actual_type = instruction->target->value->type;
32273227 // TODO instead of this logic, use the Noop instruction to change the type from
32283228 // enum_tag to the underlying int type
32293229 ZigType *int_type;
......@@ -3234,11 +3234,11 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executa
32343234 }
32353235 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
32363236 return gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base), int_type,
3237 instruction->base.value.type, target_val);
3237 instruction->base.value->type, target_val);
32383238}
32393239
32403240static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutable *executable, IrInstructionIntToPtr *instruction) {
3241 ZigType *wanted_type = instruction->base.value.type;
3241 ZigType *wanted_type = instruction->base.value->type;
32423242 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
32433243 if (!ptr_allows_addr_zero(wanted_type) && ir_want_runtime_safety(g, &instruction->base)) {
32443244 LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(target_val));
......@@ -3256,19 +3256,19 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutable *executable, I
32563256}
32573257
32583258static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutable *executable, IrInstructionPtrToInt *instruction) {
3259 ZigType *wanted_type = instruction->base.value.type;
3259 ZigType *wanted_type = instruction->base.value->type;
32603260 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
32613261 return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), "");
32623262}
32633263
32643264static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable, IrInstructionIntToEnum *instruction) {
3265 ZigType *wanted_type = instruction->base.value.type;
3265 ZigType *wanted_type = instruction->base.value->type;
32663266 assert(wanted_type->id == ZigTypeIdEnum);
32673267 ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type;
32683268
32693269 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
32703270 LLVMValueRef tag_int_value = gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base),
3271 instruction->target->value.type, tag_int_type, target_val);
3271 instruction->target->value->type, tag_int_type, target_val);
32723272
32733273 if (ir_want_runtime_safety(g, &instruction->base)) {
32743274 LLVMBasicBlockRef bad_value_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadValue");
......@@ -3289,10 +3289,10 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable,
32893289}
32903290
32913291static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, IrInstructionIntToErr *instruction) {
3292 ZigType *wanted_type = instruction->base.value.type;
3292 ZigType *wanted_type = instruction->base.value->type;
32933293 assert(wanted_type->id == ZigTypeIdErrorSet);
32943294
3295 ZigType *actual_type = instruction->target->value.type;
3295 ZigType *actual_type = instruction->target->value->type;
32963296 assert(actual_type->id == ZigTypeIdInt);
32973297 assert(!actual_type->data.integral.is_signed);
32983298
......@@ -3306,11 +3306,11 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, I
33063306}
33073307
33083308static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, IrInstructionErrToInt *instruction) {
3309 ZigType *wanted_type = instruction->base.value.type;
3309 ZigType *wanted_type = instruction->base.value->type;
33103310 assert(wanted_type->id == ZigTypeIdInt);
33113311 assert(!wanted_type->data.integral.is_signed);
33123312
3313 ZigType *actual_type = instruction->target->value.type;
3313 ZigType *actual_type = instruction->target->value->type;
33143314 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
33153315
33163316 if (actual_type->id == ZigTypeIdErrorSet) {
......@@ -3360,7 +3360,7 @@ static LLVMValueRef ir_render_br(CodeGen *g, IrExecutable *executable, IrInstruc
33603360static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInstructionUnOp *un_op_instruction) {
33613361 IrUnOp op_id = un_op_instruction->op_id;
33623362 LLVMValueRef expr = ir_llvm_value(g, un_op_instruction->value);
3363 ZigType *operand_type = un_op_instruction->value->value.type;
3363 ZigType *operand_type = un_op_instruction->value->value->type;
33643364 ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? operand_type->data.vector.elem_type : operand_type;
33653365
33663366 switch (op_id) {
......@@ -3419,12 +3419,12 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable, IrI
34193419static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable,
34203420 IrInstructionLoadPtrGen *instruction)
34213421{
3422 ZigType *child_type = instruction->base.value.type;
3422 ZigType *child_type = instruction->base.value->type;
34233423 if (!type_has_bits(child_type))
34243424 return nullptr;
34253425
34263426 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
3427 ZigType *ptr_type = instruction->ptr->value.type;
3427 ZigType *ptr_type = instruction->ptr->value->type;
34283428 assert(ptr_type->id == ZigTypeIdPointer);
34293429
34303430 ir_assert(ptr_type->data.pointer.vector_index != VECTOR_INDEX_RUNTIME, &instruction->base);
......@@ -3622,7 +3622,7 @@ static void gen_undef_init(CodeGen *g, uint32_t ptr_align_bytes, ZigType *value_
36223622static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, IrInstructionStorePtr *instruction) {
36233623 Error err;
36243624
3625 ZigType *ptr_type = instruction->ptr->value.type;
3625 ZigType *ptr_type = instruction->ptr->value->type;
36263626 assert(ptr_type->id == ZigTypeIdPointer);
36273627 bool ptr_type_has_bits;
36283628 if ((err = type_has_bits2(g, ptr_type, &ptr_type_has_bits)))
......@@ -3639,13 +3639,13 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir
36393639 return nullptr;
36403640 }
36413641
3642 bool have_init_expr = !value_is_all_undef(g, &instruction->value->value);
3642 bool have_init_expr = !value_is_all_undef(g, instruction->value->value);
36433643 if (have_init_expr) {
36443644 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
36453645 LLVMValueRef value = ir_llvm_value(g, instruction->value);
36463646 gen_assign_raw(g, ptr, ptr_type, value);
36473647 } else if (ir_want_runtime_safety(g, &instruction->base)) {
3648 gen_undef_init(g, get_ptr_align(g, ptr_type), instruction->value->value.type,
3648 gen_undef_init(g, get_ptr_align(g, ptr_type), instruction->value->value->type,
36493649 ir_llvm_value(g, instruction->ptr));
36503650 }
36513651 return nullptr;
......@@ -3658,14 +3658,14 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutable *execut
36583658 LLVMValueRef index = ir_llvm_value(g, instruction->index);
36593659 LLVMValueRef value = ir_llvm_value(g, instruction->value);
36603660
3661 LLVMValueRef loaded_vector = gen_load(g, vector_ptr, instruction->vector_ptr->value.type, "");
3661 LLVMValueRef loaded_vector = gen_load(g, vector_ptr, instruction->vector_ptr->value->type, "");
36623662 LLVMValueRef modified_vector = LLVMBuildInsertElement(g->builder, loaded_vector, value, index, "");
3663 gen_store(g, modified_vector, vector_ptr, instruction->vector_ptr->value.type);
3663 gen_store(g, modified_vector, vector_ptr, instruction->vector_ptr->value->type);
36643664 return nullptr;
36653665}
36663666
36673667static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutable *executable, IrInstructionVarPtr *instruction) {
3668 if (instruction->base.value.special != ConstValSpecialRuntime)
3668 if (instruction->base.value->special != ConstValSpecialRuntime)
36693669 return ir_llvm_value(g, &instruction->base);
36703670 ZigVar *var = instruction->var;
36713671 if (type_has_bits(var->var_type)) {
......@@ -3679,7 +3679,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutable *executable, IrIn
36793679static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutable *executable,
36803680 IrInstructionReturnPtr *instruction)
36813681{
3682 if (!type_has_bits(instruction->base.value.type))
3682 if (!type_has_bits(instruction->base.value->type))
36833683 return nullptr;
36843684 ir_assert(g->cur_ret_ptr != nullptr, &instruction->base);
36853685 return g->cur_ret_ptr;
......@@ -3687,7 +3687,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutable *executable,
36873687
36883688static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrInstructionElemPtr *instruction) {
36893689 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);
3690 ZigType *array_ptr_type = instruction->array_ptr->value.type;
3690 ZigType *array_ptr_type = instruction->array_ptr->value->type;
36913691 assert(array_ptr_type->id == ZigTypeIdPointer);
36923692 ZigType *array_type = array_ptr_type->data.pointer.child_type;
36933693 LLVMValueRef subscript_value = ir_llvm_value(g, instruction->elem_index);
......@@ -3719,7 +3719,7 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
37193719 if (child_type->id == ZigTypeIdStruct &&
37203720 child_type->data.structure.layout == ContainerLayoutPacked)
37213721 {
3722 ZigType *ptr_type = instruction->base.value.type;
3722 ZigType *ptr_type = instruction->base.value->type;
37233723 size_t host_int_bytes = ptr_type->data.pointer.host_int_bytes;
37243724 if (host_int_bytes != 0) {
37253725 uint32_t size_in_bits = type_size_bits(g, ptr_type->data.pointer.child_type);
......@@ -3941,7 +3941,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
39413941 } else {
39423942 assert(instruction->fn_ref);
39433943 fn_val = ir_llvm_value(g, instruction->fn_ref);
3944 fn_type = instruction->fn_ref->value.type;
3944 fn_type = instruction->fn_ref->value->type;
39453945 callee_is_async = fn_type->data.fn.fn_type_id.cc == CallingConventionAsync;
39463946 }
39473947
......@@ -3975,8 +3975,8 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
39753975 LLVMPointerType(get_llvm_type(g, instruction->fn_entry->frame_type), 0), "");
39763976 }
39773977 } else {
3978 if (instruction->new_stack->value.type->id == ZigTypeIdPointer &&
3979 instruction->new_stack->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame)
3978 if (instruction->new_stack->value->type->id == ZigTypeIdPointer &&
3979 instruction->new_stack->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
39803980 {
39813981 frame_result_loc = ir_llvm_value(g, instruction->new_stack);
39823982 } else {
......@@ -4189,7 +4189,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
41894189 gen_resume(g, fn_val, frame_result_loc, ResumeIdCall);
41904190 if (instruction->new_stack != nullptr) {
41914191 return LLVMBuildBitCast(g->builder, frame_result_loc,
4192 get_llvm_type(g, instruction->base.value.type), "");
4192 get_llvm_type(g, instruction->base.value->type), "");
41934193 }
41944194 return nullptr;
41954195 } else if (instruction->modifier == CallModifierNoAsync && !fn_is_async(g->cur_fn)) {
......@@ -4214,7 +4214,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
42144214 LLVMPositionBuilderAtEnd(g->builder, ok_block);
42154215 }
42164216
4217 ZigType *result_type = instruction->base.value.type;
4217 ZigType *result_type = instruction->base.value->type;
42184218 ZigType *ptr_result_type = get_pointer_to_type(g, result_type, true);
42194219 return gen_await_early_return(g, &instruction->base, frame_result_loc,
42204220 result_type, ptr_result_type, result_loc, true);
......@@ -4285,7 +4285,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
42854285 return result_loc;
42864286 } else if (handle_is_ptr(src_return_type)) {
42874287 LLVMValueRef store_instr = LLVMBuildStore(g->builder, result, result_loc);
4288 LLVMSetAlignment(store_instr, get_ptr_align(g, instruction->result_loc->value.type));
4288 LLVMSetAlignment(store_instr, get_ptr_align(g, instruction->result_loc->value->type));
42894289 return result_loc;
42904290 } else if (!callee_is_async && instruction->modifier == CallModifierAsync) {
42914291 LLVMBuildStore(g->builder, result, ret_ptr);
......@@ -4300,12 +4300,12 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
43004300{
43014301 Error err;
43024302
4303 if (instruction->base.value.special != ConstValSpecialRuntime)
4303 if (instruction->base.value->special != ConstValSpecialRuntime)
43044304 return nullptr;
43054305
43064306 LLVMValueRef struct_ptr = ir_llvm_value(g, instruction->struct_ptr);
43074307 // not necessarily a pointer. could be ZigTypeIdStruct
4308 ZigType *struct_ptr_type = instruction->struct_ptr->value.type;
4308 ZigType *struct_ptr_type = instruction->struct_ptr->value->type;
43094309 TypeStructField *field = instruction->field;
43104310
43114311 if (!type_has_bits(field->type_entry))
......@@ -4324,7 +4324,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
43244324
43254325 ir_assert(field->gen_index != SIZE_MAX, &instruction->base);
43264326 LLVMValueRef field_ptr_val = LLVMBuildStructGEP(g->builder, struct_ptr, (unsigned)field->gen_index, "");
4327 ZigType *res_type = instruction->base.value.type;
4327 ZigType *res_type = instruction->base.value->type;
43284328 ir_assert(res_type->id == ZigTypeIdPointer, &instruction->base);
43294329 if (res_type->data.pointer.host_int_bytes != 0) {
43304330 // We generate packed structs with get_llvm_type_of_n_bytes, which is
......@@ -4340,10 +4340,10 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
43404340static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,
43414341 IrInstructionUnionFieldPtr *instruction)
43424342{
4343 if (instruction->base.value.special != ConstValSpecialRuntime)
4343 if (instruction->base.value->special != ConstValSpecialRuntime)
43444344 return nullptr;
43454345
4346 ZigType *union_ptr_type = instruction->union_ptr->value.type;
4346 ZigType *union_ptr_type = instruction->union_ptr->value->type;
43474347 assert(union_ptr_type->id == ZigTypeIdPointer);
43484348 ZigType *union_type = union_ptr_type->data.pointer.child_type;
43494349 assert(union_type->id == ZigTypeIdUnion);
......@@ -4528,7 +4528,7 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
45284528 buf_append_char(&constraint_buf, ',');
45294529 }
45304530
4531 ZigType *const type = ir_input->value.type;
4531 ZigType *const type = ir_input->value->type;
45324532 LLVMTypeRef type_ref = get_llvm_type(g, type);
45334533 LLVMValueRef value_ref = ir_llvm_value(g, ir_input);
45344534 // Handle integers of non pot bitsize by widening them.
......@@ -4558,7 +4558,7 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
45584558 if (instruction->return_count == 0) {
45594559 ret_type = LLVMVoidType();
45604560 } else {
4561 ret_type = get_llvm_type(g, instruction->base.value.type);
4561 ret_type = get_llvm_type(g, instruction->base.value->type);
45624562 }
45634563 LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, (unsigned)input_and_output_count, false);
45644564
......@@ -4588,16 +4588,16 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR
45884588static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable,
45894589 IrInstructionTestNonNull *instruction)
45904590{
4591 return gen_non_null_bit(g, instruction->value->value.type, ir_llvm_value(g, instruction->value));
4591 return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value));
45924592}
45934593
45944594static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *executable,
45954595 IrInstructionOptionalUnwrapPtr *instruction)
45964596{
4597 if (instruction->base.value.special != ConstValSpecialRuntime)
4597 if (instruction->base.value->special != ConstValSpecialRuntime)
45984598 return nullptr;
45994599
4600 ZigType *ptr_type = instruction->base_ptr->value.type;
4600 ZigType *ptr_type = instruction->base_ptr->value->type;
46014601 assert(ptr_type->id == ZigTypeIdPointer);
46024602 ZigType *maybe_type = ptr_type->data.pointer.child_type;
46034603 assert(maybe_type->id == ZigTypeIdOptional);
......@@ -4695,7 +4695,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn
46954695}
46964696
46974697static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstructionClz *instruction) {
4698 ZigType *int_type = instruction->op->value.type;
4698 ZigType *int_type = instruction->op->value->type;
46994699 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);
47004700 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
47014701 LLVMValueRef params[] {
......@@ -4703,11 +4703,11 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstru
47034703 LLVMConstNull(LLVMInt1Type()),
47044704 };
47054705 LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, params, 2, "");
4706 return gen_widen_or_shorten(g, false, int_type, instruction->base.value.type, wrong_size_int);
4706 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
47074707}
47084708
47094709static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstructionCtz *instruction) {
4710 ZigType *int_type = instruction->op->value.type;
4710 ZigType *int_type = instruction->op->value->type;
47114711 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);
47124712 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
47134713 LLVMValueRef params[] {
......@@ -4715,12 +4715,12 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
47154715 LLVMConstNull(LLVMInt1Type()),
47164716 };
47174717 LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, params, 2, "");
4718 return gen_widen_or_shorten(g, false, int_type, instruction->base.value.type, wrong_size_int);
4718 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
47194719}
47204720
47214721static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutable *executable, IrInstructionShuffleVector *instruction) {
4722 uint64_t len_a = instruction->a->value.type->data.vector.len;
4723 uint64_t len_mask = instruction->mask->value.type->data.vector.len;
4722 uint64_t len_a = instruction->a->value->type->data.vector.len;
4723 uint64_t len_mask = instruction->mask->value->type->data.vector.len;
47244724
47254725 // LLVM uses integers larger than the length of the first array to
47264726 // index into the second array. This was deemed unnecessarily fragile
......@@ -4730,10 +4730,10 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutable *executabl
47304730 IrInstruction *mask = instruction->mask;
47314731 LLVMValueRef *values = allocate<LLVMValueRef>(len_mask);
47324732 for (uint64_t i = 0; i < len_mask; i++) {
4733 if (mask->value.data.x_array.data.s_none.elements[i].special == ConstValSpecialUndef) {
4733 if (mask->value->data.x_array.data.s_none.elements[i].special == ConstValSpecialUndef) {
47344734 values[i] = LLVMGetUndef(LLVMInt32Type());
47354735 } else {
4736 int32_t v = bigint_as_signed(&mask->value.data.x_array.data.s_none.elements[i].data.x_bigint);
4736 int32_t v = bigint_as_signed(&mask->value->data.x_array.data.s_none.elements[i].data.x_bigint);
47374737 uint32_t index_val = (v >= 0) ? (uint32_t)v : (uint32_t)~v + (uint32_t)len_a;
47384738 values[i] = LLVMConstInt(LLVMInt32Type(), index_val, false);
47394739 }
......@@ -4749,10 +4749,10 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutable *executabl
47494749}
47504750
47514751static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutable *executable, IrInstructionSplatGen *instruction) {
4752 ZigType *result_type = instruction->base.value.type;
4752 ZigType *result_type = instruction->base.value->type;
47534753 ir_assert(result_type->id == ZigTypeIdVector, &instruction->base);
47544754 uint32_t len = result_type->data.vector.len;
4755 LLVMTypeRef op_llvm_type = LLVMVectorType(get_llvm_type(g, instruction->scalar->value.type), 1);
4755 LLVMTypeRef op_llvm_type = LLVMVectorType(get_llvm_type(g, instruction->scalar->value->type), 1);
47564756 LLVMTypeRef mask_llvm_type = LLVMVectorType(LLVMInt32Type(), len);
47574757 LLVMValueRef undef_vector = LLVMGetUndef(op_llvm_type);
47584758 LLVMValueRef op_vector = LLVMBuildInsertElement(g->builder, undef_vector,
......@@ -4761,11 +4761,11 @@ static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutable *executable, IrInst
47614761}
47624762
47634763static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutable *executable, IrInstructionPopCount *instruction) {
4764 ZigType *int_type = instruction->op->value.type;
4764 ZigType *int_type = instruction->op->value->type;
47654765 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
47664766 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
47674767 LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, &operand, 1, "");
4768 return gen_widen_or_shorten(g, false, int_type, instruction->base.value.type, wrong_size_int);
4768 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
47694769}
47704770
47714771static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) {
......@@ -4781,14 +4781,14 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, Ir
47814781}
47824782
47834783static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstructionPhi *instruction) {
4784 if (!type_has_bits(instruction->base.value.type))
4784 if (!type_has_bits(instruction->base.value->type))
47854785 return nullptr;
47864786
47874787 LLVMTypeRef phi_type;
4788 if (handle_is_ptr(instruction->base.value.type)) {
4789 phi_type = LLVMPointerType(get_llvm_type(g,instruction->base.value.type), 0);
4788 if (handle_is_ptr(instruction->base.value->type)) {
4789 phi_type = LLVMPointerType(get_llvm_type(g,instruction->base.value->type), 0);
47904790 } else {
4791 phi_type = get_llvm_type(g, instruction->base.value.type);
4791 phi_type = get_llvm_type(g, instruction->base.value->type);
47924792 }
47934793
47944794 LLVMValueRef phi = LLVMBuildPhi(g->builder, phi_type, "");
......@@ -4803,11 +4803,11 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstru
48034803}
48044804
48054805static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutable *executable, IrInstructionRefGen *instruction) {
4806 if (!type_has_bits(instruction->base.value.type)) {
4806 if (!type_has_bits(instruction->base.value->type)) {
48074807 return nullptr;
48084808 }
48094809 LLVMValueRef value = ir_llvm_value(g, instruction->operand);
4810 if (handle_is_ptr(instruction->operand->value.type)) {
4810 if (handle_is_ptr(instruction->operand->value->type)) {
48114811 return value;
48124812 } else {
48134813 LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
......@@ -4940,7 +4940,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
49404940static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable,
49414941 IrInstructionTagName *instruction)
49424942{
4943 ZigType *enum_type = instruction->target->value.type;
4943 ZigType *enum_type = instruction->target->value->type;
49444944 assert(enum_type->id == ZigTypeIdEnum);
49454945
49464946 LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type);
......@@ -4953,7 +4953,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable
49534953static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executable,
49544954 IrInstructionFieldParentPtr *instruction)
49554955{
4956 ZigType *container_ptr_type = instruction->base.value.type;
4956 ZigType *container_ptr_type = instruction->base.value->type;
49574957 assert(container_ptr_type->id == ZigTypeIdPointer);
49584958
49594959 ZigType *container_type = container_ptr_type->data.pointer.child_type;
......@@ -4986,7 +4986,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
49864986 return target_val;
49874987 }
49884988
4989 ZigType *target_type = instruction->base.value.type;
4989 ZigType *target_type = instruction->base.value->type;
49904990 uint32_t align_bytes;
49914991 LLVMValueRef ptr_val;
49924992
......@@ -5089,7 +5089,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn
50895089 LLVMValueRef result_val = ZigLLVMBuildCmpXchg(g->builder, ptr_val, cmp_val, new_val,
50905090 success_order, failure_order, instruction->is_weak);
50915091
5092 ZigType *optional_type = instruction->base.value.type;
5092 ZigType *optional_type = instruction->base.value->type;
50935093 assert(optional_type->id == ZigTypeIdOptional);
50945094 ZigType *child_type = optional_type->data.maybe.child_type;
50955095
......@@ -5100,7 +5100,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn
51005100 }
51015101
51025102 // When the cmpxchg is discarded, the result location will have no bits.
5103 if (!type_has_bits(instruction->result_loc->value.type)) {
5103 if (!type_has_bits(instruction->result_loc->value->type)) {
51045104 return nullptr;
51055105 }
51065106
......@@ -5127,8 +5127,8 @@ static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutable *executable, IrInst
51275127
51285128static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutable *executable, IrInstructionTruncate *instruction) {
51295129 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
5130 ZigType *dest_type = instruction->base.value.type;
5131 ZigType *src_type = instruction->target->value.type;
5130 ZigType *dest_type = instruction->base.value->type;
5131 ZigType *src_type = instruction->target->value->type;
51325132 if (dest_type == src_type) {
51335133 // no-op
51345134 return target_val;
......@@ -5147,10 +5147,10 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
51475147 LLVMTypeRef ptr_u8 = LLVMPointerType(LLVMInt8Type(), 0);
51485148 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
51495149
5150 ZigType *ptr_type = instruction->dest_ptr->value.type;
5150 ZigType *ptr_type = instruction->dest_ptr->value->type;
51515151 assert(ptr_type->id == ZigTypeIdPointer);
51525152
5153 bool val_is_undef = value_is_all_undef(g, &instruction->byte->value);
5153 bool val_is_undef = value_is_all_undef(g, instruction->byte->value);
51545154 LLVMValueRef fill_char;
51555155 if (val_is_undef && ir_want_runtime_safety_scope(g, instruction->base.scope)) {
51565156 fill_char = LLVMConstInt(LLVMInt8Type(), 0xaa, false);
......@@ -5176,8 +5176,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
51765176 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
51775177 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, ptr_u8, "");
51785178
5179 ZigType *dest_ptr_type = instruction->dest_ptr->value.type;
5180 ZigType *src_ptr_type = instruction->src_ptr->value.type;
5179 ZigType *dest_ptr_type = instruction->dest_ptr->value->type;
5180 ZigType *src_ptr_type = instruction->src_ptr->value->type;
51815181
51825182 assert(dest_ptr_type->id == ZigTypeIdPointer);
51835183 assert(src_ptr_type->id == ZigTypeIdPointer);
......@@ -5190,7 +5190,7 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
51905190
51915191static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInstructionSliceGen *instruction) {
51925192 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);
5193 ZigType *array_ptr_type = instruction->ptr->value.type;
5193 ZigType *array_ptr_type = instruction->ptr->value->type;
51945194 assert(array_ptr_type->id == ZigTypeIdPointer);
51955195 ZigType *array_type = array_ptr_type->data.pointer.child_type;
51965196 LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);
......@@ -5213,7 +5213,7 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
52135213 end_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, array_type->data.array.len, false);
52145214 }
52155215 if (want_runtime_safety) {
5216 if (instruction->start->value.special == ConstValSpecialRuntime || instruction->end) {
5216 if (instruction->start->value->special == ConstValSpecialRuntime || instruction->end) {
52175217 add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val);
52185218 }
52195219 if (instruction->end) {
......@@ -5255,13 +5255,13 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
52555255 }
52565256
52575257 if (type_has_bits(array_type)) {
5258 size_t gen_ptr_index = instruction->base.value.type->data.structure.fields[slice_ptr_index]->gen_index;
5258 size_t gen_ptr_index = instruction->base.value->type->data.structure.fields[slice_ptr_index]->gen_index;
52595259 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, "");
52605260 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, "");
52615261 gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false);
52625262 }
52635263
5264 size_t gen_len_index = instruction->base.value.type->data.structure.fields[slice_len_index]->gen_index;
5264 size_t gen_len_index = instruction->base.value->type->data.structure.fields[slice_len_index]->gen_index;
52655265 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, "");
52665266 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");
52675267 gen_store_untyped(g, len_value, len_field_ptr, 0, false);
......@@ -5375,8 +5375,8 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp
53755375 LLVMValueRef op2 = ir_llvm_value(g, instruction->op2);
53765376 LLVMValueRef ptr_result = ir_llvm_value(g, instruction->result_ptr);
53775377
5378 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, instruction->op2->value.type,
5379 instruction->op1->value.type, op2);
5378 LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, instruction->op2->value->type,
5379 instruction->op1->value->type, op2);
53805380
53815381 LLVMValueRef result = LLVMBuildShl(g->builder, op1, op2_casted, "");
53825382 LLVMValueRef orig_val;
......@@ -5387,7 +5387,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp
53875387 }
53885388 LLVMValueRef overflow_bit = LLVMBuildICmp(g->builder, LLVMIntNE, op1, orig_val, "");
53895389
5390 gen_store(g, result, ptr_result, instruction->result_ptr->value.type);
5390 gen_store(g, result, ptr_result, instruction->result_ptr->value->type);
53915391
53925392 return overflow_bit;
53935393}
......@@ -5425,13 +5425,13 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,
54255425 LLVMValueRef result_struct = LLVMBuildCall(g->builder, fn_val, params, 2, "");
54265426 LLVMValueRef result = LLVMBuildExtractValue(g->builder, result_struct, 0, "");
54275427 LLVMValueRef overflow_bit = LLVMBuildExtractValue(g->builder, result_struct, 1, "");
5428 gen_store(g, result, ptr_result, instruction->result_ptr->value.type);
5428 gen_store(g, result, ptr_result, instruction->result_ptr->value->type);
54295429
54305430 return overflow_bit;
54315431}
54325432
54335433static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrInstructionTestErrGen *instruction) {
5434 ZigType *err_union_type = instruction->err_union->value.type;
5434 ZigType *err_union_type = instruction->err_union->value->type;
54355435 ZigType *payload_type = err_union_type->data.error_union.payload_type;
54365436 LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union);
54375437
......@@ -5450,10 +5450,10 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI
54505450static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executable,
54515451 IrInstructionUnwrapErrCode *instruction)
54525452{
5453 if (instruction->base.value.special != ConstValSpecialRuntime)
5453 if (instruction->base.value->special != ConstValSpecialRuntime)
54545454 return nullptr;
54555455
5456 ZigType *ptr_type = instruction->err_union_ptr->value.type;
5456 ZigType *ptr_type = instruction->err_union_ptr->value->type;
54575457 assert(ptr_type->id == ZigTypeIdPointer);
54585458 ZigType *err_union_type = ptr_type->data.pointer.child_type;
54595459 ZigType *payload_type = err_union_type->data.error_union.payload_type;
......@@ -5470,14 +5470,14 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab
54705470static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable,
54715471 IrInstructionUnwrapErrPayload *instruction)
54725472{
5473 if (instruction->base.value.special != ConstValSpecialRuntime)
5473 if (instruction->base.value->special != ConstValSpecialRuntime)
54745474 return nullptr;
54755475
54765476 bool want_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base) &&
54775477 g->errors_by_index.length > 1;
5478 if (!want_safety && !type_has_bits(instruction->base.value.type))
5478 if (!want_safety && !type_has_bits(instruction->base.value->type))
54795479 return nullptr;
5480 ZigType *ptr_type = instruction->value->value.type;
5480 ZigType *ptr_type = instruction->value->value->type;
54815481 assert(ptr_type->id == ZigTypeIdPointer);
54825482 ZigType *err_union_type = ptr_type->data.pointer.child_type;
54835483 ZigType *payload_type = err_union_type->data.error_union.payload_type;
......@@ -5521,7 +5521,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu
55215521}
55225522
55235523static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutable *executable, IrInstructionOptionalWrap *instruction) {
5524 ZigType *wanted_type = instruction->base.value.type;
5524 ZigType *wanted_type = instruction->base.value->type;
55255525
55265526 assert(wanted_type->id == ZigTypeIdOptional);
55275527
......@@ -5548,7 +5548,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutable *executable
55485548 LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
55495549
55505550 LLVMValueRef val_ptr = LLVMBuildStructGEP(g->builder, result_loc, maybe_child_index, "");
5551 // child_type and instruction->value->value.type may differ by constness
5551 // child_type and instruction->value->value->type may differ by constness
55525552 gen_assign_raw(g, val_ptr, get_pointer_to_type(g, child_type, false), payload_val);
55535553 LLVMValueRef maybe_ptr = LLVMBuildStructGEP(g->builder, result_loc, maybe_null_index, "");
55545554 gen_store_untyped(g, LLVMConstAllOnes(LLVMInt1Type()), maybe_ptr, 0, false);
......@@ -5557,7 +5557,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutable *executable
55575557}
55585558
55595559static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapCode *instruction) {
5560 ZigType *wanted_type = instruction->base.value.type;
5560 ZigType *wanted_type = instruction->base.value->type;
55615561
55625562 assert(wanted_type->id == ZigTypeIdErrorUnion);
55635563
......@@ -5577,7 +5577,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable
55775577}
55785578
55795579static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapPayload *instruction) {
5580 ZigType *wanted_type = instruction->base.value.type;
5580 ZigType *wanted_type = instruction->base.value->type;
55815581
55825582 assert(wanted_type->id == ZigTypeIdErrorUnion);
55835583
......@@ -5608,7 +5608,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executa
56085608}
56095609
56105610static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, IrInstructionUnionTag *instruction) {
5611 ZigType *union_type = instruction->value->value.type;
5611 ZigType *union_type = instruction->value->value->type;
56125612
56135613 ZigType *tag_type = union_type->data.unionation.tag_type;
56145614 if (!type_has_bits(tag_type))
......@@ -5636,7 +5636,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutable *executable,
56365636 IrInstructionAtomicRmw *instruction)
56375637{
56385638 bool is_signed;
5639 ZigType *operand_type = instruction->operand->value.type;
5639 ZigType *operand_type = instruction->operand->value->type;
56405640 if (operand_type->id == ZigTypeIdInt) {
56415641 is_signed = operand_type->data.integral.is_signed;
56425642 } else {
......@@ -5665,7 +5665,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutable *executable,
56655665{
56665666 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->resolved_ordering);
56675667 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
5668 LLVMValueRef load_inst = gen_load(g, ptr, instruction->ptr->value.type, "");
5668 LLVMValueRef load_inst = gen_load(g, ptr, instruction->ptr->value->type, "");
56695669 LLVMSetOrdering(load_inst, ordering);
56705670 return load_inst;
56715671}
......@@ -5676,15 +5676,15 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutable *executable,
56765676 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->resolved_ordering);
56775677 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
56785678 LLVMValueRef value = ir_llvm_value(g, instruction->value);
5679 LLVMValueRef store_inst = gen_store(g, value, ptr, instruction->ptr->value.type);
5679 LLVMValueRef store_inst = gen_store(g, value, ptr, instruction->ptr->value->type);
56805680 LLVMSetOrdering(store_inst, ordering);
56815681 return nullptr;
56825682}
56835683
56845684static LLVMValueRef ir_render_float_op(CodeGen *g, IrExecutable *executable, IrInstructionFloatOp *instruction) {
56855685 LLVMValueRef op = ir_llvm_value(g, instruction->op1);
5686 assert(instruction->base.value.type->id == ZigTypeIdFloat);
5687 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value.type, ZigLLVMFnIdFloatOp, instruction->op);
5686 assert(instruction->base.value->type->id == ZigTypeIdFloat);
5687 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->op);
56885688 return LLVMBuildCall(g->builder, fn_val, &op, 1, "");
56895689}
56905690
......@@ -5692,9 +5692,9 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutable *executable, IrIn
56925692 LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);
56935693 LLVMValueRef op2 = ir_llvm_value(g, instruction->op2);
56945694 LLVMValueRef op3 = ir_llvm_value(g, instruction->op3);
5695 assert(instruction->base.value.type->id == ZigTypeIdFloat ||
5696 instruction->base.value.type->id == ZigTypeIdVector);
5697 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value.type, ZigLLVMFnIdFMA, BuiltinFnIdMulAdd);
5695 assert(instruction->base.value->type->id == ZigTypeIdFloat ||
5696 instruction->base.value->type->id == ZigTypeIdVector);
5697 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFMA, BuiltinFnIdMulAdd);
56985698 LLVMValueRef args[3] = {
56995699 op1,
57005700 op2,
......@@ -5705,7 +5705,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutable *executable, IrIn
57055705
57065706static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutable *executable, IrInstructionBswap *instruction) {
57075707 LLVMValueRef op = ir_llvm_value(g, instruction->op);
5708 ZigType *expr_type = instruction->base.value.type;
5708 ZigType *expr_type = instruction->base.value->type;
57095709 bool is_vector = expr_type->id == ZigTypeIdVector;
57105710 ZigType *int_type = is_vector ? expr_type->data.vector.elem_type : expr_type;
57115711 assert(int_type->id == ZigTypeIdInt);
......@@ -5739,16 +5739,16 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutable *executable, IrInst
57395739
57405740static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutable *executable, IrInstructionBitReverse *instruction) {
57415741 LLVMValueRef op = ir_llvm_value(g, instruction->op);
5742 ZigType *int_type = instruction->base.value.type;
5742 ZigType *int_type = instruction->base.value->type;
57435743 assert(int_type->id == ZigTypeIdInt);
5744 LLVMValueRef fn_val = get_int_builtin_fn(g, instruction->base.value.type, BuiltinFnIdBitReverse);
5744 LLVMValueRef fn_val = get_int_builtin_fn(g, instruction->base.value->type, BuiltinFnIdBitReverse);
57455745 return LLVMBuildCall(g->builder, fn_val, &op, 1, "");
57465746}
57475747
57485748static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutable *executable,
57495749 IrInstructionVectorToArray *instruction)
57505750{
5751 ZigType *array_type = instruction->base.value.type;
5751 ZigType *array_type = instruction->base.value->type;
57525752 assert(array_type->id == ZigTypeIdArray);
57535753 assert(handle_is_ptr(array_type));
57545754 LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
......@@ -5758,8 +5758,8 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutable *executab
57585758 bool bitcast_ok = elem_type->size_in_bits == elem_type->abi_size * 8;
57595759 if (bitcast_ok) {
57605760 LLVMValueRef casted_ptr = LLVMBuildBitCast(g->builder, result_loc,
5761 LLVMPointerType(get_llvm_type(g, instruction->vector->value.type), 0), "");
5762 uint32_t alignment = get_ptr_align(g, instruction->result_loc->value.type);
5761 LLVMPointerType(get_llvm_type(g, instruction->vector->value->type), 0), "");
5762 uint32_t alignment = get_ptr_align(g, instruction->result_loc->value->type);
57635763 gen_store_untyped(g, vector, casted_ptr, alignment, false);
57645764 } else {
57655765 // If the ABI size of the element type is not evenly divisible by size_in_bits, a simple bitcast
......@@ -5767,7 +5767,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutable *executab
57675767 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
57685768 LLVMTypeRef u32_type_ref = LLVMInt32Type();
57695769 LLVMValueRef zero = LLVMConstInt(usize_type_ref, 0, false);
5770 for (uintptr_t i = 0; i < instruction->vector->value.type->data.vector.len; i++) {
5770 for (uintptr_t i = 0; i < instruction->vector->value->type->data.vector.len; i++) {
57715771 LLVMValueRef index_usize = LLVMConstInt(usize_type_ref, i, false);
57725772 LLVMValueRef index_u32 = LLVMConstInt(u32_type_ref, i, false);
57735773 LLVMValueRef indexes[] = { zero, index_usize };
......@@ -5782,7 +5782,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutable *executab
57825782static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutable *executable,
57835783 IrInstructionArrayToVector *instruction)
57845784{
5785 ZigType *vector_type = instruction->base.value.type;
5785 ZigType *vector_type = instruction->base.value->type;
57865786 assert(vector_type->id == ZigTypeIdVector);
57875787 assert(!handle_is_ptr(vector_type));
57885788 LLVMValueRef array_ptr = ir_llvm_value(g, instruction->array);
......@@ -5793,7 +5793,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutable *executab
57935793 if (bitcast_ok) {
57945794 LLVMValueRef casted_ptr = LLVMBuildBitCast(g->builder, array_ptr,
57955795 LLVMPointerType(vector_type_ref, 0), "");
5796 ZigType *array_type = instruction->array->value.type;
5796 ZigType *array_type = instruction->array->value->type;
57975797 assert(array_type->id == ZigTypeIdArray);
57985798 uint32_t alignment = get_abi_alignment(g, array_type->data.array.child_type);
57995799 return gen_load_untyped(g, casted_ptr, alignment, false, "");
......@@ -5804,7 +5804,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutable *executab
58045804 LLVMTypeRef u32_type_ref = LLVMInt32Type();
58055805 LLVMValueRef zero = LLVMConstInt(usize_type_ref, 0, false);
58065806 LLVMValueRef vector = LLVMGetUndef(vector_type_ref);
5807 for (uintptr_t i = 0; i < instruction->base.value.type->data.vector.len; i++) {
5807 for (uintptr_t i = 0; i < instruction->base.value->type->data.vector.len; i++) {
58085808 LLVMValueRef index_usize = LLVMConstInt(usize_type_ref, i, false);
58095809 LLVMValueRef index_u32 = LLVMConstInt(u32_type_ref, i, false);
58105810 LLVMValueRef indexes[] = { zero, index_usize };
......@@ -5820,7 +5820,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutable *executable,
58205820 IrInstructionAssertZero *instruction)
58215821{
58225822 LLVMValueRef target = ir_llvm_value(g, instruction->target);
5823 ZigType *int_type = instruction->target->value.type;
5823 ZigType *int_type = instruction->target->value->type;
58245824 if (ir_want_runtime_safety(g, &instruction->base)) {
58255825 return gen_assert_zero(g, target, int_type);
58265826 }
......@@ -5831,7 +5831,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutable *executab
58315831 IrInstructionAssertNonNull *instruction)
58325832{
58335833 LLVMValueRef target = ir_llvm_value(g, instruction->target);
5834 ZigType *target_type = instruction->target->value.type;
5834 ZigType *target_type = instruction->target->value->type;
58355835
58365836 if (target_type->id == ZigTypeIdPointer) {
58375837 assert(target_type->data.pointer.ptr_len == PtrLenC);
......@@ -5917,7 +5917,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst
59175917 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
59185918 LLVMValueRef zero = LLVMConstNull(usize_type_ref);
59195919 LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame);
5920 ZigType *result_type = instruction->base.value.type;
5920 ZigType *result_type = instruction->base.value->type;
59215921 ZigType *ptr_result_type = get_pointer_to_type(g, result_type, true);
59225922
59235923 LLVMValueRef result_loc = (instruction->result_loc == nullptr) ?
......@@ -6000,7 +6000,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutable *executable, IrInst
60006000
60016001static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutable *executable, IrInstructionResume *instruction) {
60026002 LLVMValueRef frame = ir_llvm_value(g, instruction->frame);
6003 ZigType *frame_type = instruction->frame->value.type;
6003 ZigType *frame_type = instruction->frame->value->type;
60046004 assert(frame_type->id == ZigTypeIdAnyFrame);
60056005
60066006 gen_resume(g, nullptr, frame, ResumeIdManual);
......@@ -6354,7 +6354,7 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
63546354 instruction->llvm_value = ir_render_instruction(g, executable, instruction);
63556355 if (instruction->spill != nullptr) {
63566356 LLVMValueRef spill_ptr = ir_llvm_value(g, instruction->spill);
6357 gen_assign_raw(g, spill_ptr, instruction->spill->value.type, instruction->llvm_value);
6357 gen_assign_raw(g, spill_ptr, instruction->spill->value->type, instruction->llvm_value);
63586358 instruction->llvm_value = nullptr;
63596359 }
63606360 }
......@@ -7514,12 +7514,12 @@ static void do_code_gen(CodeGen *g) {
75147514 call->frame_result_loc = all_calls_alloca;
75157515 }
75167516 if (largest_call_frame_type != nullptr) {
7517 all_calls_alloca->value.type = get_pointer_to_type(g, largest_call_frame_type, false);
7517 all_calls_alloca->value->type = get_pointer_to_type(g, largest_call_frame_type, false);
75187518 }
75197519 // allocate temporary stack data
75207520 for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_gen_list.length; alloca_i += 1) {
75217521 IrInstructionAllocaGen *instruction = fn_table_entry->alloca_gen_list.at(alloca_i);
7522 ZigType *ptr_type = instruction->base.value.type;
7522 ZigType *ptr_type = instruction->base.value->type;
75237523 assert(ptr_type->id == ZigTypeIdPointer);
75247524 ZigType *child_type = ptr_type->data.pointer.child_type;
75257525 if (type_resolve(g, child_type, ResolveStatusSizeKnown))
......@@ -7528,8 +7528,8 @@ static void do_code_gen(CodeGen *g) {
75287528 continue;
75297529 if (instruction->base.ref_count == 0)
75307530 continue;
7531 if (instruction->base.value.special != ConstValSpecialRuntime) {
7532 if (const_ptr_pointee(nullptr, g, &instruction->base.value, nullptr)->special !=
7531 if (instruction->base.value->special != ConstValSpecialRuntime) {
7532 if (const_ptr_pointee(nullptr, g, instruction->base.value, nullptr)->special !=
75337533 ConstValSpecialRuntime)
75347534 {
75357535 continue;
......@@ -8632,12 +8632,14 @@ static void init(CodeGen *g) {
86328632
86338633 IrInstruction *sentinel_instructions = allocate<IrInstruction>(2);
86348634 g->invalid_instruction = &sentinel_instructions[0];
8635 g->invalid_instruction->value.type = g->builtin_types.entry_invalid;
8636 g->invalid_instruction->value.global_refs = allocate<ConstGlobalRefs>(1);
8635 g->invalid_instruction->value = allocate<ZigValue>(1, "ZigValue");
8636 g->invalid_instruction->value->type = g->builtin_types.entry_invalid;
8637 g->invalid_instruction->value->global_refs = allocate<ConstGlobalRefs>(1);
86378638
86388639 g->unreach_instruction = &sentinel_instructions[1];
8639 g->unreach_instruction->value.type = g->builtin_types.entry_unreachable;
8640 g->unreach_instruction->value.global_refs = allocate<ConstGlobalRefs>(1);
8640 g->unreach_instruction->value = allocate<ZigValue>(1, "ZigValue");
8641 g->unreach_instruction->value->type = g->builtin_types.entry_unreachable;
8642 g->unreach_instruction->value->global_refs = allocate<ConstGlobalRefs>(1);
86418643
86428644 g->const_void_val.special = ConstValSpecialStatic;
86438645 g->const_void_val.type = g->builtin_types.entry_void;
src/ir.cpp+1263-1264
......@@ -421,11 +421,11 @@ static bool value_is_comptime(ZigValue *const_val) {
421421}
422422
423423static bool instr_is_comptime(IrInstruction *instruction) {
424 return value_is_comptime(&instruction->value);
424 return value_is_comptime(instruction->value);
425425}
426426
427427static bool instr_is_unreachable(IrInstruction *instruction) {
428 return instruction->value.type && instruction->value.type->id == ZigTypeIdUnreachable;
428 return instruction->value->type && instruction->value->type->id == ZigTypeIdUnreachable;
429429}
430430
431431static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) {
......@@ -1156,7 +1156,8 @@ static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_no
11561156 special_instruction->base.source_node = source_node;
11571157 special_instruction->base.debug_id = exec_next_debug_id(irb->exec);
11581158 special_instruction->base.owner_bb = irb->current_basic_block;
1159 special_instruction->base.value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs");
1159 special_instruction->base.value = allocate<ZigValue>(1, "ZigValue");
1160 special_instruction->base.value->global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs");
11601161 return special_instruction;
11611162}
11621163
......@@ -1184,8 +1185,8 @@ static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *so
11841185 IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime)
11851186{
11861187 IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node);
1187 cond_br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
1188 cond_br_instruction->base.value.special = ConstValSpecialStatic;
1188 cond_br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
1189 cond_br_instruction->base.value->special = ConstValSpecialStatic;
11891190 cond_br_instruction->condition = condition;
11901191 cond_br_instruction->then_block = then_block;
11911192 cond_br_instruction->else_block = else_block;
......@@ -1203,8 +1204,8 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou
12031204 IrInstruction *operand)
12041205{
12051206 IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node);
1206 return_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
1207 return_instruction->base.value.special = ConstValSpecialStatic;
1207 return_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
1208 return_instruction->base.value->special = ConstValSpecialStatic;
12081209 return_instruction->operand = operand;
12091210
12101211 if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block);
......@@ -1214,54 +1215,54 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou
12141215
12151216static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) {
12161217 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1217 const_instruction->base.value.type = irb->codegen->builtin_types.entry_void;
1218 const_instruction->base.value.special = ConstValSpecialStatic;
1218 const_instruction->base.value->type = irb->codegen->builtin_types.entry_void;
1219 const_instruction->base.value->special = ConstValSpecialStatic;
12191220 return &const_instruction->base;
12201221}
12211222
12221223static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) {
12231224 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1224 const_instruction->base.value.special = ConstValSpecialUndef;
1225 const_instruction->base.value.type = irb->codegen->builtin_types.entry_undef;
1225 const_instruction->base.value->special = ConstValSpecialUndef;
1226 const_instruction->base.value->type = irb->codegen->builtin_types.entry_undef;
12261227 return &const_instruction->base;
12271228}
12281229
12291230static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) {
12301231 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1231 const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_int;
1232 const_instruction->base.value.special = ConstValSpecialStatic;
1233 bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value);
1232 const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int;
1233 const_instruction->base.value->special = ConstValSpecialStatic;
1234 bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value);
12341235 return &const_instruction->base;
12351236}
12361237
12371238static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) {
12381239 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1239 const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_int;
1240 const_instruction->base.value.special = ConstValSpecialStatic;
1241 bigint_init_bigint(&const_instruction->base.value.data.x_bigint, bigint);
1240 const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int;
1241 const_instruction->base.value->special = ConstValSpecialStatic;
1242 bigint_init_bigint(&const_instruction->base.value->data.x_bigint, bigint);
12421243 return &const_instruction->base;
12431244}
12441245
12451246static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) {
12461247 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1247 const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_float;
1248 const_instruction->base.value.special = ConstValSpecialStatic;
1249 bigfloat_init_bigfloat(&const_instruction->base.value.data.x_bigfloat, bigfloat);
1248 const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_float;
1249 const_instruction->base.value->special = ConstValSpecialStatic;
1250 bigfloat_init_bigfloat(&const_instruction->base.value->data.x_bigfloat, bigfloat);
12501251 return &const_instruction->base;
12511252}
12521253
12531254static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) {
12541255 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1255 const_instruction->base.value.type = irb->codegen->builtin_types.entry_null;
1256 const_instruction->base.value.special = ConstValSpecialStatic;
1256 const_instruction->base.value->type = irb->codegen->builtin_types.entry_null;
1257 const_instruction->base.value->special = ConstValSpecialStatic;
12571258 return &const_instruction->base;
12581259}
12591260
12601261static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) {
12611262 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1262 const_instruction->base.value.type = irb->codegen->builtin_types.entry_usize;
1263 const_instruction->base.value.special = ConstValSpecialStatic;
1264 bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value);
1263 const_instruction->base.value->type = irb->codegen->builtin_types.entry_usize;
1264 const_instruction->base.value->special = ConstValSpecialStatic;
1265 bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value);
12651266 return &const_instruction->base;
12661267}
12671268
......@@ -1269,9 +1270,9 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode
12691270 ZigType *type_entry)
12701271{
12711272 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
1272 const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;
1273 const_instruction->base.value.special = ConstValSpecialStatic;
1274 const_instruction->base.value.data.x_type = type_entry;
1273 const_instruction->base.value->type = irb->codegen->builtin_types.entry_type;
1274 const_instruction->base.value->special = ConstValSpecialStatic;
1275 const_instruction->base.value->data.x_type = type_entry;
12751276 return &const_instruction->base;
12761277}
12771278
......@@ -1285,35 +1286,35 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode
12851286
12861287static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) {
12871288 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
1288 const_instruction->base.value.type = fn_entry->type_entry;
1289 const_instruction->base.value.special = ConstValSpecialStatic;
1290 const_instruction->base.value.data.x_ptr.data.fn.fn_entry = fn_entry;
1291 const_instruction->base.value.data.x_ptr.mut = ConstPtrMutComptimeConst;
1292 const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialFunction;
1289 const_instruction->base.value->type = fn_entry->type_entry;
1290 const_instruction->base.value->special = ConstValSpecialStatic;
1291 const_instruction->base.value->data.x_ptr.data.fn.fn_entry = fn_entry;
1292 const_instruction->base.value->data.x_ptr.mut = ConstPtrMutComptimeConst;
1293 const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialFunction;
12931294 return &const_instruction->base;
12941295}
12951296
12961297static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) {
12971298 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1298 const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;
1299 const_instruction->base.value.special = ConstValSpecialStatic;
1300 const_instruction->base.value.data.x_type = import;
1299 const_instruction->base.value->type = irb->codegen->builtin_types.entry_type;
1300 const_instruction->base.value->special = ConstValSpecialStatic;
1301 const_instruction->base.value->data.x_type = import;
13011302 return &const_instruction->base;
13021303}
13031304
13041305static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) {
13051306 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1306 const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool;
1307 const_instruction->base.value.special = ConstValSpecialStatic;
1308 const_instruction->base.value.data.x_bool = value;
1307 const_instruction->base.value->type = irb->codegen->builtin_types.entry_bool;
1308 const_instruction->base.value->special = ConstValSpecialStatic;
1309 const_instruction->base.value->data.x_bool = value;
13091310 return &const_instruction->base;
13101311}
13111312
13121313static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) {
13131314 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1314 const_instruction->base.value.type = irb->codegen->builtin_types.entry_enum_literal;
1315 const_instruction->base.value.special = ConstValSpecialStatic;
1316 const_instruction->base.value.data.x_enum_literal = name;
1315 const_instruction->base.value->type = irb->codegen->builtin_types.entry_enum_literal;
1316 const_instruction->base.value->special = ConstValSpecialStatic;
1317 const_instruction->base.value->data.x_enum_literal = name;
13171318 return &const_instruction->base;
13181319}
13191320
......@@ -1321,19 +1322,20 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN
13211322 ZigFn *fn_entry, IrInstruction *first_arg)
13221323{
13231324 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
1324 const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry);
1325 const_instruction->base.value.special = ConstValSpecialStatic;
1326 const_instruction->base.value.data.x_bound_fn.fn = fn_entry;
1327 const_instruction->base.value.data.x_bound_fn.first_arg = first_arg;
1325 const_instruction->base.value->type = get_bound_fn_type(irb->codegen, fn_entry);
1326 const_instruction->base.value->special = ConstValSpecialStatic;
1327 const_instruction->base.value->data.x_bound_fn.fn = fn_entry;
1328 const_instruction->base.value->data.x_bound_fn.first_arg = first_arg;
13281329 return &const_instruction->base;
13291330}
13301331
13311332static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) {
13321333 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
1333 init_const_str_lit(irb->codegen, &const_instruction->base.value, str);
1334 init_const_str_lit(irb->codegen, const_instruction->base.value, str);
13341335
13351336 return &const_instruction->base;
13361337}
1338
13371339static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) {
13381340 IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str);
13391341 ir_instruction_append(irb->current_basic_block, instruction);
......@@ -1388,7 +1390,7 @@ static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *so
13881390static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) {
13891391 IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb,
13901392 source_instruction->scope, source_instruction->source_node);
1391 instruction->base.value.type = ty;
1393 instruction->base.value->type = ty;
13921394 return &instruction->base;
13931395}
13941396
......@@ -1513,7 +1515,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so
15131515{
15141516 IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb,
15151517 source_instruction->scope, source_instruction->source_node);
1516 call_instruction->base.value.type = return_type;
1518 call_instruction->base.value->type = return_type;
15171519 call_instruction->fn_entry = fn_entry;
15181520 call_instruction->fn_ref = fn_ref;
15191521 call_instruction->fn_inline = fn_inline;
......@@ -1558,8 +1560,8 @@ static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source
15581560 IrBasicBlock *dest_block, IrInstruction *is_comptime)
15591561{
15601562 IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node);
1561 br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
1562 br_instruction->base.value.special = ConstValSpecialStatic;
1563 br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
1564 br_instruction->base.value->special = ConstValSpecialStatic;
15631565 br_instruction->dest_block = dest_block;
15641566 br_instruction->is_comptime = is_comptime;
15651567
......@@ -1659,8 +1661,8 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop
16591661static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) {
16601662 IrInstructionUnreachable *unreachable_instruction =
16611663 ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node);
1662 unreachable_instruction->base.value.special = ConstValSpecialStatic;
1663 unreachable_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
1664 unreachable_instruction->base.value->special = ConstValSpecialStatic;
1665 unreachable_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
16641666 return &unreachable_instruction->base;
16651667}
16661668
......@@ -1668,8 +1670,8 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A
16681670 IrInstruction *ptr, IrInstruction *value)
16691671{
16701672 IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node);
1671 instruction->base.value.special = ConstValSpecialStatic;
1672 instruction->base.value.type = irb->codegen->builtin_types.entry_void;
1673 instruction->base.value->special = ConstValSpecialStatic;
1674 instruction->base.value->type = irb->codegen->builtin_types.entry_void;
16731675 instruction->ptr = ptr;
16741676 instruction->value = value;
16751677
......@@ -1684,7 +1686,7 @@ static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction *
16841686{
16851687 IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>(
16861688 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
1687 inst->base.value.type = ira->codegen->builtin_types.entry_void;
1689 inst->base.value->type = ira->codegen->builtin_types.entry_void;
16881690 inst->vector_ptr = vector_ptr;
16891691 inst->index = index;
16901692 inst->value = value;
......@@ -1700,8 +1702,8 @@ static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNod
17001702 ZigVar *var, IrInstruction *align_value, IrInstruction *ptr)
17011703{
17021704 IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node);
1703 decl_var_instruction->base.value.special = ConstValSpecialStatic;
1704 decl_var_instruction->base.value.type = irb->codegen->builtin_types.entry_void;
1705 decl_var_instruction->base.value->special = ConstValSpecialStatic;
1706 decl_var_instruction->base.value->type = irb->codegen->builtin_types.entry_void;
17051707 decl_var_instruction->var = var;
17061708 decl_var_instruction->align_value = align_value;
17071709 decl_var_instruction->ptr = ptr;
......@@ -1717,8 +1719,8 @@ static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *sourc
17171719{
17181720 IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb,
17191721 source_instruction->scope, source_instruction->source_node);
1720 decl_var_instruction->base.value.special = ConstValSpecialStatic;
1721 decl_var_instruction->base.value.type = ira->codegen->builtin_types.entry_void;
1722 decl_var_instruction->base.value->special = ConstValSpecialStatic;
1723 decl_var_instruction->base.value->type = ira->codegen->builtin_types.entry_void;
17221724 decl_var_instruction->var = var;
17231725 decl_var_instruction->var_ptr = var_ptr;
17241726
......@@ -1732,7 +1734,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc
17321734{
17331735 IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb,
17341736 source_instruction->scope, source_instruction->source_node);
1735 instruction->base.value.type = ty;
1737 instruction->base.value->type = ty;
17361738 instruction->operand = operand;
17371739 instruction->result_loc = result_loc;
17381740
......@@ -1747,8 +1749,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou
17471749{
17481750 IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>(
17491751 irb, scope, source_node);
1750 export_instruction->base.value.special = ConstValSpecialStatic;
1751 export_instruction->base.value.type = irb->codegen->builtin_types.entry_void;
1752 export_instruction->base.value->special = ConstValSpecialStatic;
1753 export_instruction->base.value->type = irb->codegen->builtin_types.entry_void;
17521754 export_instruction->name = name;
17531755 export_instruction->target = target;
17541756 export_instruction->linkage = linkage;
......@@ -1925,7 +1927,7 @@ static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *sour
19251927{
19261928 IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>(
19271929 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
1928 instruction->base.value.type = result_ty;
1930 instruction->base.value->type = result_ty;
19291931 instruction->operand = operand;
19301932 instruction->result_loc = result_loc;
19311933
......@@ -1940,7 +1942,7 @@ static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *s
19401942{
19411943 IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>(
19421944 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
1943 instruction->base.value.type = result_type;
1945 instruction->base.value->type = result_type;
19441946 instruction->operand = operand;
19451947 instruction->result_loc = result_loc;
19461948
......@@ -1955,7 +1957,7 @@ static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *sour
19551957{
19561958 IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>(
19571959 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
1958 instruction->base.value.type = result_type;
1960 instruction->base.value->type = result_type;
19591961 instruction->operand = operand;
19601962 instruction->result_loc = result_loc;
19611963
......@@ -2025,8 +2027,8 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A
20252027 IrInstruction *switch_prongs_void)
20262028{
20272029 IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node);
2028 instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
2029 instruction->base.value.special = ConstValSpecialStatic;
2030 instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
2031 instruction->base.value->special = ConstValSpecialStatic;
20302032 instruction->target_value = target_value;
20312033 instruction->else_block = else_block;
20322034 instruction->case_count = case_count;
......@@ -2122,7 +2124,7 @@ static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_ins
21222124{
21232125 IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb,
21242126 source_instruction->scope, source_instruction->source_node);
2125 instruction->base.value.type = result_type;
2127 instruction->base.value->type = result_type;
21262128 instruction->operand = operand;
21272129 instruction->result_loc = result_loc;
21282130
......@@ -2237,7 +2239,7 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source
22372239{
22382240 IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb,
22392241 source_instruction->scope, source_instruction->source_node);
2240 instruction->base.value.type = result_type;
2242 instruction->base.value->type = result_type;
22412243 instruction->ptr = ptr;
22422244 instruction->cmp_value = cmp_value;
22432245 instruction->new_value = new_value;
......@@ -2482,7 +2484,7 @@ static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_i
24822484{
24832485 IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>(
24842486 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2485 instruction->base.value.type = result_type;
2487 instruction->base.value->type = result_type;
24862488 instruction->scalar = scalar;
24872489
24882490 ir_ref_instruction(scalar, ira->new_irb.current_basic_block);
......@@ -2495,7 +2497,7 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i
24952497{
24962498 IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>(
24972499 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2498 instruction->base.value.type = slice_type;
2500 instruction->base.value->type = slice_type;
24992501 instruction->ptr = ptr;
25002502 instruction->start = start;
25012503 instruction->end = end;
......@@ -2709,7 +2711,7 @@ static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *sourc
27092711{
27102712 IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>(
27112713 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2712 instruction->base.value.type = ira->codegen->builtin_types.entry_bool;
2714 instruction->base.value->type = ira->codegen->builtin_types.entry_bool;
27132715 instruction->err_union = err_union;
27142716
27152717 ir_ref_instruction(err_union, ira->new_irb.current_basic_block);
......@@ -2792,7 +2794,7 @@ static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *sourc
27922794{
27932795 IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>(
27942796 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2795 instruction->base.value.type = ptr_type;
2797 instruction->base.value->type = ptr_type;
27962798 instruction->ptr = ptr;
27972799 instruction->safety_check_on = safety_check_on;
27982800
......@@ -2806,7 +2808,7 @@ static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *sourc
28062808{
28072809 IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>(
28082810 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2809 instruction->base.value.type = ty;
2811 instruction->base.value->type = ty;
28102812 instruction->ptr = ptr;
28112813 instruction->result_loc = result_loc;
28122814
......@@ -2845,7 +2847,7 @@ static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *sourc
28452847{
28462848 IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>(
28472849 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
2848 instruction->base.value.type = ty;
2850 instruction->base.value->type = ty;
28492851 instruction->operand = operand;
28502852
28512853 ir_ref_instruction(operand, ira->new_irb.current_basic_block);
......@@ -2997,8 +2999,8 @@ static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *s
29972999
29983000static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) {
29993001 IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node);
3000 instruction->base.value.special = ConstValSpecialStatic;
3001 instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable;
3002 instruction->base.value->special = ConstValSpecialStatic;
3003 instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable;
30023004 instruction->msg = msg;
30033005
30043006 ir_ref_instruction(msg, irb->current_basic_block);
......@@ -3328,7 +3330,7 @@ static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *so
33283330{
33293331 IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb,
33303332 source_instruction->scope, source_instruction->source_node);
3331 instruction->base.value.type = result_type;
3333 instruction->base.value->type = result_type;
33323334 instruction->vector = vector;
33333335 instruction->result_loc = result_loc;
33343336
......@@ -3343,7 +3345,7 @@ static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstructi
33433345{
33443346 IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb,
33453347 source_instruction->scope, source_instruction->source_node);
3346 instruction->base.value.type = result_type;
3348 instruction->base.value->type = result_type;
33473349 instruction->operand = operand;
33483350 instruction->result_loc = result_loc;
33493351
......@@ -3358,7 +3360,7 @@ static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *so
33583360{
33593361 IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb,
33603362 source_instruction->scope, source_instruction->source_node);
3361 instruction->base.value.type = result_type;
3363 instruction->base.value->type = result_type;
33623364 instruction->array = array;
33633365
33643366 ir_ref_instruction(array, ira->new_irb.current_basic_block);
......@@ -3371,7 +3373,7 @@ static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source
33713373{
33723374 IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb,
33733375 source_instruction->scope, source_instruction->source_node);
3374 instruction->base.value.type = ira->codegen->builtin_types.entry_void;
3376 instruction->base.value->type = ira->codegen->builtin_types.entry_void;
33753377 instruction->target = target;
33763378
33773379 ir_ref_instruction(target, ira->new_irb.current_basic_block);
......@@ -3384,7 +3386,7 @@ static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *so
33843386{
33853387 IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb,
33863388 source_instruction->scope, source_instruction->source_node);
3387 instruction->base.value.type = ira->codegen->builtin_types.entry_void;
3389 instruction->base.value->type = ira->codegen->builtin_types.entry_void;
33883390 instruction->target = target;
33893391
33903392 ir_ref_instruction(target, ira->new_irb.current_basic_block);
......@@ -3433,7 +3435,7 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s
34333435
34343436static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) {
34353437 IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node);
3436 instruction->base.value.type = irb->codegen->builtin_types.entry_void;
3438 instruction->base.value->type = irb->codegen->builtin_types.entry_void;
34373439
34383440 return instruction;
34393441}
......@@ -3442,7 +3444,7 @@ static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstN
34423444 IrInstructionSuspendBegin *begin)
34433445{
34443446 IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node);
3445 instruction->base.value.type = irb->codegen->builtin_types.entry_void;
3447 instruction->base.value->type = irb->codegen->builtin_types.entry_void;
34463448 instruction->begin = begin;
34473449
34483450 ir_ref_instruction(&begin->base, irb->current_basic_block);
......@@ -3467,7 +3469,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction *
34673469{
34683470 IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb,
34693471 source_instruction->scope, source_instruction->source_node);
3470 instruction->base.value.type = result_type;
3472 instruction->base.value->type = result_type;
34713473 instruction->frame = frame;
34723474 instruction->result_loc = result_loc;
34733475
......@@ -3479,7 +3481,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction *
34793481
34803482static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) {
34813483 IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node);
3482 instruction->base.value.type = irb->codegen->builtin_types.entry_void;
3484 instruction->base.value->type = irb->codegen->builtin_types.entry_void;
34833485 instruction->frame = frame;
34843486
34853487 ir_ref_instruction(frame, irb->current_basic_block);
......@@ -3491,8 +3493,8 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop
34913493 IrInstruction *operand, SpillId spill_id)
34923494{
34933495 IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node);
3494 instruction->base.value.special = ConstValSpecialStatic;
3495 instruction->base.value.type = irb->codegen->builtin_types.entry_void;
3496 instruction->base.value->special = ConstValSpecialStatic;
3497 instruction->base.value->type = irb->codegen->builtin_types.entry_void;
34963498 instruction->operand = operand;
34973499 instruction->spill_id = spill_id;
34983500
......@@ -3517,7 +3519,7 @@ static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction
35173519{
35183520 IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>(
35193521 &ira->new_irb, source_instruction->scope, source_instruction->source_node);
3520 instruction->base.value.type = vector->value.type->data.vector.elem_type;
3522 instruction->base.value->type = vector->value->type->data.vector.elem_type;
35213523 instruction->vector = vector;
35223524 instruction->index = index;
35233525
......@@ -3588,8 +3590,8 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o
35883590 Scope *defer_expr_scope = defer_node->data.defer.expr_scope;
35893591 IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope);
35903592 if (defer_expr_value != irb->codegen->invalid_instruction) {
3591 if (defer_expr_value->value.type != nullptr &&
3592 defer_expr_value->value.type->id == ZigTypeIdUnreachable)
3593 if (defer_expr_value->value->type != nullptr &&
3594 defer_expr_value->value->type->id == ZigTypeIdUnreachable)
35933595 {
35943596 is_noreturn = true;
35953597 } else {
......@@ -4411,7 +4413,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode
44114413 init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base);
44124414 tld_var->base.resolution = TldResolutionInvalid;
44134415 tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false,
4414 &g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid);
4416 g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid);
44154417 scope_decls->decl_table.put(var_name, &tld_var->base);
44164418}
44174419
......@@ -4424,10 +4426,10 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
44244426 if (buf_eql_str(variable_name, "_")) {
44254427 if (lval == LValPtr) {
44264428 IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node);
4427 const_instruction->base.value.type = get_pointer_to_type(irb->codegen,
4429 const_instruction->base.value->type = get_pointer_to_type(irb->codegen,
44284430 irb->codegen->builtin_types.entry_void, false);
4429 const_instruction->base.value.special = ConstValSpecialStatic;
4430 const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialDiscard;
4431 const_instruction->base.value->special = ConstValSpecialStatic;
4432 const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialDiscard;
44314433 return &const_instruction->base;
44324434 } else {
44334435 add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to"));
......@@ -8747,12 +8749,12 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) {
87478749 if (instruction->id == IrInstructionIdReturn) {
87488750 IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction;
87498751 IrInstruction *operand = ret_inst->operand;
8750 if (operand->value.special == ConstValSpecialRuntime) {
8752 if (operand->value->special == ConstValSpecialRuntime) {
87518753 exec_add_error_node(codegen, exec, operand->source_node,
87528754 buf_sprintf("unable to evaluate constant expression"));
8753 return &codegen->invalid_instruction->value;
8755 return codegen->invalid_instruction->value;
87548756 }
8755 return &operand->value;
8757 return operand->value;
87568758 } else if (ir_has_side_effects(instruction)) {
87578759 if (instr_is_comptime(instruction)) {
87588760 switch (instruction->id) {
......@@ -8769,7 +8771,7 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) {
87698771 }
87708772 exec_add_error_node(codegen, exec, instruction->source_node,
87718773 buf_sprintf("unable to evaluate constant expression"));
8772 return &codegen->invalid_instruction->value;
8774 return codegen->invalid_instruction->value;
87738775 }
87748776 }
87758777 zig_unreachable();
......@@ -10217,13 +10219,13 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1021710219 size_t i = 0;
1021810220 for (;;) {
1021910221 prev_inst = instructions[i];
10220 if (type_is_invalid(prev_inst->value.type)) {
10222 if (type_is_invalid(prev_inst->value->type)) {
1022110223 return ira->codegen->builtin_types.entry_invalid;
1022210224 }
10223 if (prev_inst->value.type->id == ZigTypeIdUnreachable) {
10225 if (prev_inst->value->type->id == ZigTypeIdUnreachable) {
1022410226 i += 1;
1022510227 if (i == instruction_count) {
10226 return prev_inst->value.type;
10228 return prev_inst->value->type;
1022710229 }
1022810230 continue;
1022910231 }
......@@ -10232,14 +10234,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1023210234 ErrorTableEntry **errors = nullptr;
1023310235 size_t errors_count = 0;
1023410236 ZigType *err_set_type = nullptr;
10235 if (prev_inst->value.type->id == ZigTypeIdErrorSet) {
10236 if (!resolve_inferred_error_set(ira->codegen, prev_inst->value.type, prev_inst->source_node)) {
10237 if (prev_inst->value->type->id == ZigTypeIdErrorSet) {
10238 if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->source_node)) {
1023710239 return ira->codegen->builtin_types.entry_invalid;
1023810240 }
10239 if (type_is_global_error_set(prev_inst->value.type)) {
10241 if (type_is_global_error_set(prev_inst->value->type)) {
1024010242 err_set_type = ira->codegen->builtin_types.entry_global_error_set;
1024110243 } else {
10242 err_set_type = prev_inst->value.type;
10244 err_set_type = prev_inst->value->type;
1024310245 update_errors_helper(ira->codegen, &errors, &errors_count);
1024410246
1024510247 for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {
......@@ -10250,12 +10252,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1025010252 }
1025110253 }
1025210254
10253 bool any_are_null = (prev_inst->value.type->id == ZigTypeIdNull);
10255 bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull);
1025410256 bool convert_to_const_slice = false;
1025510257 for (; i < instruction_count; i += 1) {
1025610258 IrInstruction *cur_inst = instructions[i];
10257 ZigType *cur_type = cur_inst->value.type;
10258 ZigType *prev_type = prev_inst->value.type;
10259 ZigType *cur_type = cur_inst->value->type;
10260 ZigType *prev_type = prev_inst->value->type;
1025910261
1026010262 if (type_is_invalid(cur_type)) {
1026110263 return cur_type;
......@@ -10559,20 +10561,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1055910561 }
1056010562
1056110563 if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdEnumLiteral) {
10562 TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value.data.x_enum_literal);
10564 TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value->data.x_enum_literal);
1056310565 if (field != nullptr) {
1056410566 continue;
1056510567 }
1056610568 }
1056710569 if (is_tagged_union(prev_type) && cur_type->id == ZigTypeIdEnumLiteral) {
10568 TypeUnionField *field = find_union_type_field(prev_type, cur_inst->value.data.x_enum_literal);
10570 TypeUnionField *field = find_union_type_field(prev_type, cur_inst->value->data.x_enum_literal);
1056910571 if (field != nullptr) {
1057010572 continue;
1057110573 }
1057210574 }
1057310575
1057410576 if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdEnumLiteral) {
10575 TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value.data.x_enum_literal);
10577 TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value->data.x_enum_literal);
1057610578 if (field != nullptr) {
1057710579 prev_inst = cur_inst;
1057810580 continue;
......@@ -10580,7 +10582,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1058010582 }
1058110583
1058210584 if (is_tagged_union(cur_type) && prev_type->id == ZigTypeIdEnumLiteral) {
10583 TypeUnionField *field = find_union_type_field(cur_type, prev_inst->value.data.x_enum_literal);
10585 TypeUnionField *field = find_union_type_field(cur_type, prev_inst->value->data.x_enum_literal);
1058410586 if (field != nullptr) {
1058510587 prev_inst = cur_inst;
1058610588 continue;
......@@ -10906,9 +10908,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1090610908 free(errors);
1090710909
1090810910 if (convert_to_const_slice) {
10909 if (prev_inst->value.type->id == ZigTypeIdArray) {
10911 if (prev_inst->value->type->id == ZigTypeIdArray) {
1091010912 ZigType *ptr_type = get_pointer_to_type_extra(
10911 ira->codegen, prev_inst->value.type->data.array.child_type,
10913 ira->codegen, prev_inst->value->type->data.array.child_type,
1091210914 true, false, PtrLenUnknown,
1091310915 0, 0, 0, false);
1091410916 ZigType *slice_type = get_slice_type(ira->codegen, ptr_type);
......@@ -10917,12 +10919,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1091710919 } else {
1091810920 return slice_type;
1091910921 }
10920 } else if (prev_inst->value.type->id == ZigTypeIdPointer) {
10921 ZigType *array_type = prev_inst->value.type->data.pointer.child_type;
10922 } else if (prev_inst->value->type->id == ZigTypeIdPointer) {
10923 ZigType *array_type = prev_inst->value->type->data.pointer.child_type;
1092210924 src_assert(array_type->id == ZigTypeIdArray, source_node);
1092310925 ZigType *ptr_type = get_pointer_to_type_extra2(
1092410926 ira->codegen, array_type->data.array.child_type,
10925 prev_inst->value.type->data.pointer.is_const, false,
10927 prev_inst->value->type->data.pointer.is_const, false,
1092610928 PtrLenUnknown,
1092710929 0, 0, 0, false,
1092810930 VECTOR_INDEX_NONE, nullptr, array_type->data.array.sentinel);
......@@ -10936,10 +10938,10 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1093610938 zig_unreachable();
1093710939 }
1093810940 } else if (err_set_type != nullptr) {
10939 if (prev_inst->value.type->id == ZigTypeIdErrorSet) {
10941 if (prev_inst->value->type->id == ZigTypeIdErrorSet) {
1094010942 return err_set_type;
10941 } else if (prev_inst->value.type->id == ZigTypeIdErrorUnion) {
10942 ZigType *payload_type = prev_inst->value.type->data.error_union.payload_type;
10943 } else if (prev_inst->value->type->id == ZigTypeIdErrorUnion) {
10944 ZigType *payload_type = prev_inst->value->type->data.error_union.payload_type;
1094310945 if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown)))
1094410946 return ira->codegen->builtin_types.entry_invalid;
1094510947 return get_error_union_type(ira->codegen, err_set_type, payload_type);
......@@ -10949,38 +10951,38 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1094910951 return ira->codegen->builtin_types.entry_invalid;
1095010952 return get_error_union_type(ira->codegen, err_set_type, payload_type);
1095110953 } else {
10952 if (prev_inst->value.type->id == ZigTypeIdComptimeInt ||
10953 prev_inst->value.type->id == ZigTypeIdComptimeFloat)
10954 if (prev_inst->value->type->id == ZigTypeIdComptimeInt ||
10955 prev_inst->value->type->id == ZigTypeIdComptimeFloat)
1095410956 {
1095510957 ir_add_error_node(ira, source_node,
1095610958 buf_sprintf("unable to make error union out of number literal"));
1095710959 return ira->codegen->builtin_types.entry_invalid;
10958 } else if (prev_inst->value.type->id == ZigTypeIdNull) {
10960 } else if (prev_inst->value->type->id == ZigTypeIdNull) {
1095910961 ir_add_error_node(ira, source_node,
1096010962 buf_sprintf("unable to make error union out of null literal"));
1096110963 return ira->codegen->builtin_types.entry_invalid;
1096210964 } else {
10963 if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown)))
10965 if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown)))
1096410966 return ira->codegen->builtin_types.entry_invalid;
10965 return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type);
10967 return get_error_union_type(ira->codegen, err_set_type, prev_inst->value->type);
1096610968 }
1096710969 }
10968 } else if (any_are_null && prev_inst->value.type->id != ZigTypeIdNull) {
10969 if (prev_inst->value.type->id == ZigTypeIdComptimeInt ||
10970 prev_inst->value.type->id == ZigTypeIdComptimeFloat)
10970 } else if (any_are_null && prev_inst->value->type->id != ZigTypeIdNull) {
10971 if (prev_inst->value->type->id == ZigTypeIdComptimeInt ||
10972 prev_inst->value->type->id == ZigTypeIdComptimeFloat)
1097110973 {
1097210974 ir_add_error_node(ira, source_node,
1097310975 buf_sprintf("unable to make maybe out of number literal"));
1097410976 return ira->codegen->builtin_types.entry_invalid;
10975 } else if (prev_inst->value.type->id == ZigTypeIdOptional) {
10976 return prev_inst->value.type;
10977 } else if (prev_inst->value->type->id == ZigTypeIdOptional) {
10978 return prev_inst->value->type;
1097710979 } else {
10978 if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown)))
10980 if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown)))
1097910981 return ira->codegen->builtin_types.entry_invalid;
10980 return get_optional_type(ira->codegen, prev_inst->value.type);
10982 return get_optional_type(ira->codegen, prev_inst->value->type);
1098110983 }
1098210984 } else {
10983 return prev_inst->value.type;
10985 return prev_inst->value->type;
1098410986 }
1098510987}
1098610988
......@@ -11106,8 +11108,8 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z
1110611108 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1110711109 old_instruction->scope, old_instruction->source_node);
1110811110 IrInstruction *new_instruction = &const_instruction->base;
11109 new_instruction->value.type = ty;
11110 new_instruction->value.special = ConstValSpecialStatic;
11111 new_instruction->value->type = ty;
11112 new_instruction->value->special = ConstValSpecialStatic;
1111111113 return new_instruction;
1111211114}
1111311115
......@@ -11116,15 +11118,15 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
1111611118{
1111711119 if (instr_is_comptime(value) || !type_has_bits(wanted_type)) {
1111811120 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
11119 if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, &value->value, value->value.type,
11120 &result->value, wanted_type))
11121 if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type,
11122 result->value, wanted_type))
1112111123 {
1112211124 return ira->codegen->invalid_instruction;
1112311125 }
1112411126 return result;
1112511127 } else {
1112611128 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op);
11127 result->value.type = wanted_type;
11129 result->value->type = wanted_type;
1112811130 return result;
1112911131 }
1113011132}
......@@ -11132,35 +11134,35 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
1113211134static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr,
1113311135 IrInstruction *value, ZigType *wanted_type)
1113411136{
11135 assert(value->value.type->id == ZigTypeIdPointer);
11137 assert(value->value->type->id == ZigTypeIdPointer);
1113611138
1113711139 Error err;
1113811140
11139 if ((err = type_resolve(ira->codegen, value->value.type->data.pointer.child_type,
11141 if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type,
1114011142 ResolveStatusAlignmentKnown)))
1114111143 {
1114211144 return ira->codegen->invalid_instruction;
1114311145 }
1114411146
11145 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type));
11147 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type));
1114611148
1114711149 if (instr_is_comptime(value)) {
11148 ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &value->value, source_instr->source_node);
11150 ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node);
1114911151 if (pointee == nullptr)
1115011152 return ira->codegen->invalid_instruction;
1115111153 if (pointee->special != ConstValSpecialRuntime) {
1115211154 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
11153 result->value.data.x_ptr.special = ConstPtrSpecialBaseArray;
11154 result->value.data.x_ptr.mut = value->value.data.x_ptr.mut;
11155 result->value.data.x_ptr.data.base_array.array_val = pointee;
11156 result->value.data.x_ptr.data.base_array.elem_index = 0;
11155 result->value->data.x_ptr.special = ConstPtrSpecialBaseArray;
11156 result->value->data.x_ptr.mut = value->value->data.x_ptr.mut;
11157 result->value->data.x_ptr.data.base_array.array_val = pointee;
11158 result->value->data.x_ptr.data.base_array.elem_index = 0;
1115711159 return result;
1115811160 }
1115911161 }
1116011162
1116111163 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node,
1116211164 wanted_type, value, CastOpBitCast);
11163 result->value.type = wanted_type;
11165 result->value->type = wanted_type;
1116411166 return result;
1116511167}
1116611168
......@@ -11169,28 +11171,28 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
1116911171{
1117011172 Error err;
1117111173
11172 if ((err = type_resolve(ira->codegen, array_ptr->value.type->data.pointer.child_type,
11174 if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type,
1117311175 ResolveStatusAlignmentKnown)))
1117411176 {
1117511177 return ira->codegen->invalid_instruction;
1117611178 }
1117711179
11178 wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type));
11180 wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type));
1117911181
1118011182 if (instr_is_comptime(array_ptr)) {
11181 ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &array_ptr->value, source_instr->source_node);
11183 ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr->value, source_instr->source_node);
1118211184 if (pointee == nullptr)
1118311185 return ira->codegen->invalid_instruction;
1118411186 if (pointee->special != ConstValSpecialRuntime) {
11185 assert(array_ptr->value.type->id == ZigTypeIdPointer);
11186 ZigType *array_type = array_ptr->value.type->data.pointer.child_type;
11187 assert(array_ptr->value->type->id == ZigTypeIdPointer);
11188 ZigType *array_type = array_ptr->value->type->data.pointer.child_type;
1118711189 assert(is_slice(wanted_type));
1118811190 bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const;
1118911191
1119011192 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
11191 init_const_slice(ira->codegen, &result->value, pointee, 0, array_type->data.array.len, is_const);
11192 result->value.data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value.data.x_ptr.mut;
11193 result->value.type = wanted_type;
11193 init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const);
11194 result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value->data.x_ptr.mut;
11195 result->value->type = wanted_type;
1119411196 return result;
1119511197 }
1119611198 }
......@@ -11198,7 +11200,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
1119811200 if (result_loc == nullptr) result_loc = no_result_loc();
1119911201 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true,
1120011202 false, true);
11201 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11203 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1120211204 return result_loc_inst;
1120311205 }
1120411206 return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst);
......@@ -11403,32 +11405,32 @@ static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruc
1140311405}
1140411406
1140511407static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) {
11406 if (instruction->value.type->id == ZigTypeIdUnreachable)
11408 if (instruction->value->type->id == ZigTypeIdUnreachable)
1140711409 ir_finish_bb(ira);
1140811410 return instruction;
1140911411}
1141011412
1141111413static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) {
1141211414 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type);
11413 result->value.data.x_type = ty;
11415 result->value->data.x_type = ty;
1141411416 return result;
1141511417}
1141611418
1141711419static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) {
1141811420 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool);
11419 result->value.data.x_bool = value;
11421 result->value->data.x_bool = value;
1142011422 return result;
1142111423}
1142211424
1142311425static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) {
1142411426 IrInstruction *result = ir_const(ira, source_instruction, ty);
11425 result->value.special = ConstValSpecialUndef;
11427 result->value->special = ConstValSpecialUndef;
1142611428 return result;
1142711429}
1142811430
1142911431static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) {
1143011432 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable);
11431 result->value.special = ConstValSpecialStatic;
11433 result->value->special = ConstValSpecialStatic;
1143211434 return result;
1143311435}
1143411436
......@@ -11438,7 +11440,7 @@ static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instru
1143811440
1143911441static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) {
1144011442 IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int);
11441 bigint_init_unsigned(&result->value.data.x_bigint, value);
11443 bigint_init_unsigned(&result->value->data.x_bigint, value);
1144211444 return result;
1144311445}
1144411446
......@@ -11449,7 +11451,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio
1144911451 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
1145011452 ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false);
1145111453 IrInstruction *const_instr = ir_const(ira, instruction, ptr_type);
11452 ZigValue *const_val = &const_instr->value;
11454 ZigValue *const_val = const_instr->value;
1145311455 const_val->data.x_ptr.special = ConstPtrSpecialRef;
1145411456 const_val->data.x_ptr.mut = ptr_mut;
1145511457 const_val->data.x_ptr.data.ref.pointee = pointee;
......@@ -11493,11 +11495,11 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode
1149311495static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) {
1149411496 Error err;
1149511497 if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node,
11496 &value->value, undef_allowed)))
11498 value->value, undef_allowed)))
1149711499 {
1149811500 return nullptr;
1149911501 }
11500 return &value->value;
11502 return value->value;
1150111503}
1150211504
1150311505ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
......@@ -11508,7 +11510,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1150811510 Error err;
1150911511
1151011512 if (expected_type != nullptr && type_is_invalid(expected_type))
11511 return &codegen->invalid_instruction->value;
11513 return codegen->invalid_instruction->value;
1151211514
1151311515 IrExecutable *ir_executable = allocate<IrExecutable>(1);
1151411516 ir_executable->source_node = source_node;
......@@ -11522,7 +11524,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1152211524
1152311525 if (ir_executable->first_err_trace_msg != nullptr) {
1152411526 codegen->trace_err = ir_executable->first_err_trace_msg;
11525 return &codegen->invalid_instruction->value;
11527 return codegen->invalid_instruction->value;
1152611528 }
1152711529
1152811530 if (codegen->verbose_ir) {
......@@ -11545,7 +11547,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1154511547 analyzed_executable->begin_scope = scope;
1154611548 ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node);
1154711549 if (type_is_invalid(result_type)) {
11548 return &codegen->invalid_instruction->value;
11550 return codegen->invalid_instruction->value;
1154911551 }
1155011552
1155111553 if (codegen->verbose_ir) {
......@@ -11556,21 +11558,21 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1155611558
1155711559 ZigValue *result = ir_exec_const_result(codegen, analyzed_executable);
1155811560 if (type_is_invalid(result->type))
11559 return &codegen->invalid_instruction->value;
11561 return codegen->invalid_instruction->value;
1156011562
1156111563 if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed)))
11562 return &codegen->invalid_instruction->value;
11564 return codegen->invalid_instruction->value;
1156311565
1156411566 return result;
1156511567}
1156611568
1156711569static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) {
11568 if (type_is_invalid(err_value->value.type))
11570 if (type_is_invalid(err_value->value->type))
1156911571 return nullptr;
1157011572
11571 if (err_value->value.type->id != ZigTypeIdErrorSet) {
11573 if (err_value->value->type->id != ZigTypeIdErrorSet) {
1157211574 ir_add_error(ira, err_value,
11573 buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value.type->name)));
11575 buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name)));
1157411576 return nullptr;
1157511577 }
1157611578
......@@ -11594,23 +11596,23 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN
1159411596}
1159511597
1159611598static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) {
11597 if (type_is_invalid(type_value->value.type))
11599 if (type_is_invalid(type_value->value->type))
1159811600 return nullptr;
1159911601
11600 if (type_value->value.type->id != ZigTypeIdMetaType) {
11602 if (type_value->value->type->id != ZigTypeIdMetaType) {
1160111603 ir_add_error(ira, type_value,
11602 buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name)));
11604 buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name)));
1160311605 return nullptr;
1160411606 }
1160511607
1160611608 Error err;
1160711609 if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node,
11608 &type_value->value, LazyOk)))
11610 type_value->value, LazyOk)))
1160911611 {
1161011612 return nullptr;
1161111613 }
1161211614
11613 return &type_value->value;
11615 return type_value->value;
1161411616}
1161511617
1161611618static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
......@@ -11663,12 +11665,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) {
1166311665}
1166411666
1166511667static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) {
11666 if (type_is_invalid(type_value->value.type))
11668 if (type_is_invalid(type_value->value->type))
1166711669 return ira->codegen->builtin_types.entry_invalid;
1166811670
11669 if (type_value->value.type->id != ZigTypeIdMetaType) {
11671 if (type_value->value->type->id != ZigTypeIdMetaType) {
1167011672 ErrorMsg *msg = ir_add_error(ira, type_value,
11671 buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value.type->name)));
11673 buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name)));
1167211674 add_error_note(ira->codegen, msg, op_source->source_node,
1167311675 buf_sprintf("`||` merges error sets; `or` performs boolean OR"));
1167411676 return ira->codegen->builtin_types.entry_invalid;
......@@ -11694,12 +11696,12 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
1169411696 if (fn_value == ira->codegen->invalid_instruction)
1169511697 return nullptr;
1169611698
11697 if (type_is_invalid(fn_value->value.type))
11699 if (type_is_invalid(fn_value->value->type))
1169811700 return nullptr;
1169911701
11700 if (fn_value->value.type->id != ZigTypeIdFn) {
11702 if (fn_value->value->type->id != ZigTypeIdFn) {
1170111703 ir_add_error_node(ira, fn_value->source_node,
11702 buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value.type->name)));
11704 buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name)));
1170311705 return nullptr;
1170411706 }
1170511707
......@@ -11722,7 +11724,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1172211724 if (instr_is_comptime(value)) {
1172311725 ZigType *payload_type = wanted_type->data.maybe.child_type;
1172411726 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
11725 if (type_is_invalid(casted_payload->value.type))
11727 if (type_is_invalid(casted_payload->value->type))
1172611728 return ira->codegen->invalid_instruction;
1172711729
1172811730 ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk);
......@@ -11731,13 +11733,13 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1173111733
1173211734 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1173311735 source_instr->scope, source_instr->source_node);
11734 const_instruction->base.value.special = ConstValSpecialStatic;
11736 const_instruction->base.value->special = ConstValSpecialStatic;
1173511737 if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) {
11736 copy_const_val(&const_instruction->base.value, val, val->data.x_ptr.mut == ConstPtrMutComptimeConst);
11738 copy_const_val(const_instruction->base.value, val, val->data.x_ptr.mut == ConstPtrMutComptimeConst);
1173711739 } else {
11738 const_instruction->base.value.data.x_optional = val;
11740 const_instruction->base.value->data.x_optional = val;
1173911741 }
11740 const_instruction->base.value.type = wanted_type;
11742 const_instruction->base.value->type = wanted_type;
1174111743 return &const_instruction->base;
1174211744 }
1174311745
......@@ -11747,12 +11749,12 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1174711749 IrInstruction *result_loc_inst = nullptr;
1174811750 if (result_loc != nullptr) {
1174911751 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true);
11750 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11752 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1175111753 return result_loc_inst;
1175211754 }
1175311755 }
1175411756 IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst);
11755 result->value.data.rh_maybe = RuntimeHintOptionalNonNull;
11757 result->value->data.rh_maybe = RuntimeHintOptionalNonNull;
1175611758 return result;
1175711759}
1175811760
......@@ -11765,7 +11767,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1176511767 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
1176611768 if (instr_is_comptime(value)) {
1176711769 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
11768 if (type_is_invalid(casted_payload->value.type))
11770 if (type_is_invalid(casted_payload->value->type))
1176911771 return ira->codegen->invalid_instruction;
1177011772
1177111773 ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad);
......@@ -11779,10 +11781,10 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1177911781
1178011782 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1178111783 source_instr->scope, source_instr->source_node);
11782 const_instruction->base.value.type = wanted_type;
11783 const_instruction->base.value.special = ConstValSpecialStatic;
11784 const_instruction->base.value.data.x_err_union.error_set = err_set_val;
11785 const_instruction->base.value.data.x_err_union.payload = val;
11784 const_instruction->base.value->type = wanted_type;
11785 const_instruction->base.value->special = ConstValSpecialStatic;
11786 const_instruction->base.value->data.x_err_union.error_set = err_set_val;
11787 const_instruction->base.value->data.x_err_union.payload = val;
1178611788 return &const_instruction->base;
1178711789 }
1178811790
......@@ -11790,7 +11792,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1179011792 if (handle_is_ptr(wanted_type)) {
1179111793 if (result_loc == nullptr) result_loc = no_result_loc();
1179211794 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true);
11793 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11795 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1179411796 return result_loc_inst;
1179511797 }
1179611798 } else {
......@@ -11798,14 +11800,14 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1179811800 }
1179911801
1180011802 IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst);
11801 result->value.data.rh_error_union = RuntimeHintErrorUnionNonError;
11803 result->value->data.rh_error_union = RuntimeHintErrorUnionNonError;
1180211804 return result;
1180311805}
1180411806
1180511807static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
1180611808 ZigType *wanted_type)
1180711809{
11808 assert(value->value.type->id == ZigTypeIdErrorSet);
11810 assert(value->value->type->id == ZigTypeIdErrorSet);
1180911811 assert(wanted_type->id == ZigTypeIdErrorSet);
1181011812
1181111813 if (instr_is_comptime(value)) {
......@@ -11834,14 +11836,14 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou
1183411836
1183511837 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1183611838 source_instr->scope, source_instr->source_node);
11837 const_instruction->base.value.type = wanted_type;
11838 const_instruction->base.value.special = ConstValSpecialStatic;
11839 const_instruction->base.value.data.x_err_set = val->data.x_err_set;
11839 const_instruction->base.value->type = wanted_type;
11840 const_instruction->base.value->special = ConstValSpecialStatic;
11841 const_instruction->base.value->data.x_err_set = val->data.x_err_set;
1184011842 return &const_instruction->base;
1184111843 }
1184211844
1184311845 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet);
11844 result->value.type = wanted_type;
11846 result->value->type = wanted_type;
1184511847 return result;
1184611848}
1184711849
......@@ -11861,7 +11863,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc
1186111863
1186211864 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node,
1186311865 wanted_type, frame_ptr, CastOpBitCast);
11864 result->value.type = wanted_type;
11866 result->value->type = wanted_type;
1186511867 return result;
1186611868}
1186711869
......@@ -11874,7 +11876,7 @@ static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruct
1187411876
1187511877 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node,
1187611878 wanted_type, value, CastOpBitCast);
11877 result->value.type = wanted_type;
11879 result->value->type = wanted_type;
1187811880 return result;
1187911881}
1188011882
......@@ -11898,10 +11900,10 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
1189811900
1189911901 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1190011902 source_instr->scope, source_instr->source_node);
11901 const_instruction->base.value.type = wanted_type;
11902 const_instruction->base.value.special = ConstValSpecialStatic;
11903 const_instruction->base.value.data.x_err_union.error_set = err_set_val;
11904 const_instruction->base.value.data.x_err_union.payload = nullptr;
11903 const_instruction->base.value->type = wanted_type;
11904 const_instruction->base.value->special = ConstValSpecialStatic;
11905 const_instruction->base.value->data.x_err_union.error_set = err_set_val;
11906 const_instruction->base.value->data.x_err_union.payload = nullptr;
1190511907 return &const_instruction->base;
1190611908 }
1190711909
......@@ -11909,7 +11911,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
1190911911 if (handle_is_ptr(wanted_type)) {
1191011912 if (result_loc == nullptr) result_loc = no_result_loc();
1191111913 result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true);
11912 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
11914 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1191311915 return result_loc_inst;
1191411916 }
1191511917 } else {
......@@ -11918,7 +11920,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
1191811920
1191911921
1192011922 IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst);
11921 result->value.data.rh_error_union = RuntimeHintErrorUnionError;
11923 result->value->data.rh_error_union = RuntimeHintErrorUnionError;
1192211924 return result;
1192311925}
1192411926
......@@ -11930,13 +11932,13 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so
1193011932 assert(val != nullptr);
1193111933
1193211934 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
11933 result->value.special = ConstValSpecialStatic;
11935 result->value->special = ConstValSpecialStatic;
1193411936 if (get_codegen_ptr_type(wanted_type) != nullptr) {
11935 result->value.data.x_ptr.special = ConstPtrSpecialNull;
11937 result->value->data.x_ptr.special = ConstPtrSpecialNull;
1193611938 } else if (is_opt_err_set(wanted_type)) {
11937 result->value.data.x_err_set = nullptr;
11939 result->value->data.x_err_set = nullptr;
1193811940 } else {
11939 result->value.data.x_optional = nullptr;
11941 result->value->data.x_optional = nullptr;
1194011942 }
1194111943 return result;
1194211944}
......@@ -11952,8 +11954,8 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction
1195211954 assert(val != nullptr);
1195311955
1195411956 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
11955 result->value.data.x_ptr.special = ConstPtrSpecialNull;
11956 result->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
11957 result->value->data.x_ptr.special = ConstPtrSpecialNull;
11958 result->value->data.x_ptr.mut = ConstPtrMutComptimeConst;
1195711959 return result;
1195811960}
1195911961
......@@ -11962,36 +11964,36 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
1196211964{
1196311965 Error err;
1196411966
11965 if (type_is_invalid(value->value.type))
11967 if (type_is_invalid(value->value->type))
1196611968 return ira->codegen->invalid_instruction;
1196711969
11968 if ((err = type_resolve(ira->codegen, value->value.type, ResolveStatusZeroBitsKnown)))
11970 if ((err = type_resolve(ira->codegen, value->value->type, ResolveStatusZeroBitsKnown)))
1196911971 return ira->codegen->invalid_instruction;
1197011972
1197111973 if (instr_is_comptime(value)) {
1197211974 ZigValue *val = ir_resolve_const(ira, value, LazyOk);
1197311975 if (!val)
1197411976 return ira->codegen->invalid_instruction;
11975 return ir_get_const_ptr(ira, source_instruction, val, value->value.type,
11977 return ir_get_const_ptr(ira, source_instruction, val, value->value->type,
1197611978 ConstPtrMutComptimeConst, is_const, is_volatile, 0);
1197711979 }
1197811980
11979 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,
11981 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value->type,
1198011982 is_const, is_volatile, PtrLenSingle, 0, 0, 0, false);
1198111983
1198211984 if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown)))
1198311985 return ira->codegen->invalid_instruction;
1198411986
1198511987 IrInstruction *result_loc;
11986 if (type_has_bits(ptr_type) && !handle_is_ptr(value->value.type)) {
11987 result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value.type, nullptr, true,
11988 if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) {
11989 result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, nullptr, true,
1198811990 false, true);
1198911991 } else {
1199011992 result_loc = nullptr;
1199111993 }
1199211994
1199311995 IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc);
11994 new_instruction->value.data.rh_ptr = RuntimeHintPtrStack;
11996 new_instruction->value->data.rh_ptr = RuntimeHintPtrStack;
1199511997 return new_instruction;
1199611998}
1199711999
......@@ -12004,39 +12006,39 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
1200412006
1200512007 IrInstruction *array_ptr = nullptr;
1200612008 IrInstruction *array;
12007 if (array_arg->value.type->id == ZigTypeIdPointer) {
12009 if (array_arg->value->type->id == ZigTypeIdPointer) {
1200812010 array = ir_get_deref(ira, source_instr, array_arg, nullptr);
1200912011 array_ptr = array_arg;
1201012012 } else {
1201112013 array = array_arg;
1201212014 }
12013 ZigType *array_type = array->value.type;
12015 ZigType *array_type = array->value->type;
1201412016 assert(array_type->id == ZigTypeIdArray);
1201512017
1201612018 if (instr_is_comptime(array) || array_type->data.array.len == 0) {
1201712019 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12018 init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true);
12019 result->value.type = wanted_type;
12020 init_const_slice(ira->codegen, result->value, array->value, 0, array_type->data.array.len, true);
12021 result->value->type = wanted_type;
1202012022 return result;
1202112023 }
1202212024
1202312025 IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize);
12024 init_const_usize(ira->codegen, &start->value, 0);
12026 init_const_usize(ira->codegen, start->value, 0);
1202512027
1202612028 IrInstruction *end = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize);
12027 init_const_usize(ira->codegen, &end->value, array_type->data.array.len);
12029 init_const_usize(ira->codegen, end->value, array_type->data.array.len);
1202812030
1202912031 if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false);
1203012032
1203112033 if (result_loc == nullptr) result_loc = no_result_loc();
1203212034 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr,
1203312035 true, false, true);
12034 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
12036 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1203512037 return result_loc_inst;
1203612038 }
1203712039 IrInstruction *result = ir_build_slice_gen(ira, source_instr, wanted_type, array_ptr, start, end, false, result_loc_inst);
12038 result->value.data.rh_slice.id = RuntimeHintSliceIdLen;
12039 result->value.data.rh_slice.len = array_type->data.array.len;
12040 result->value->data.rh_slice.id = RuntimeHintSliceIdLen;
12041 result->value->data.rh_slice.len = array_type->data.array.len;
1204012042
1204112043 return result;
1204212044}
......@@ -12065,19 +12067,19 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
1206512067
1206612068 IrInstruction *enum_target;
1206712069 ZigType *enum_type;
12068 if (target->value.type->id == ZigTypeIdUnion) {
12069 enum_type = ir_resolve_union_tag_type(ira, target, target->value.type);
12070 if (target->value->type->id == ZigTypeIdUnion) {
12071 enum_type = ir_resolve_union_tag_type(ira, target, target->value->type);
1207012072 if (type_is_invalid(enum_type))
1207112073 return ira->codegen->invalid_instruction;
1207212074 enum_target = ir_implicit_cast(ira, target, enum_type);
12073 if (type_is_invalid(enum_target->value.type))
12075 if (type_is_invalid(enum_target->value->type))
1207412076 return ira->codegen->invalid_instruction;
12075 } else if (target->value.type->id == ZigTypeIdEnum) {
12077 } else if (target->value->type->id == ZigTypeIdEnum) {
1207612078 enum_target = target;
12077 enum_type = target->value.type;
12079 enum_type = target->value->type;
1207812080 } else {
1207912081 ir_add_error(ira, target,
12080 buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name)));
12082 buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name)));
1208112083 return ira->codegen->invalid_instruction;
1208212084 }
1208312085
......@@ -12092,7 +12094,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
1209212094 enum_type->data.enumeration.src_field_count == 1)
1209312095 {
1209412096 IrInstruction *result = ir_const(ira, source_instr, tag_type);
12095 init_const_bigint(&result->value, tag_type,
12097 init_const_bigint(result->value, tag_type,
1209612098 &enum_type->data.enumeration.fields[0].value);
1209712099 return result;
1209812100 }
......@@ -12102,31 +12104,31 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
1210212104 if (!val)
1210312105 return ira->codegen->invalid_instruction;
1210412106 IrInstruction *result = ir_const(ira, source_instr, tag_type);
12105 init_const_bigint(&result->value, tag_type, &val->data.x_enum_tag);
12107 init_const_bigint(result->value, tag_type, &val->data.x_enum_tag);
1210612108 return result;
1210712109 }
1210812110
1210912111 IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope,
1211012112 source_instr->source_node, enum_target);
12111 result->value.type = tag_type;
12113 result->value->type = tag_type;
1211212114 return result;
1211312115}
1211412116
1211512117static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr,
1211612118 IrInstruction *target, ZigType *wanted_type)
1211712119{
12118 assert(target->value.type->id == ZigTypeIdUnion);
12120 assert(target->value->type->id == ZigTypeIdUnion);
1211912121 assert(wanted_type->id == ZigTypeIdEnum);
12120 assert(wanted_type == target->value.type->data.unionation.tag_type);
12122 assert(wanted_type == target->value->type->data.unionation.tag_type);
1212112123
1212212124 if (instr_is_comptime(target)) {
1212312125 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1212412126 if (!val)
1212512127 return ira->codegen->invalid_instruction;
1212612128 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12127 result->value.special = ConstValSpecialStatic;
12128 result->value.type = wanted_type;
12129 bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_union.tag);
12129 result->value->special = ConstValSpecialStatic;
12130 result->value->type = wanted_type;
12131 bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag);
1213012132 return result;
1213112133 }
1213212134
......@@ -12135,16 +12137,16 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou
1213512137 wanted_type->data.enumeration.src_field_count == 1)
1213612138 {
1213712139 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12138 result->value.special = ConstValSpecialStatic;
12139 result->value.type = wanted_type;
12140 TypeEnumField *enum_field = target->value.type->data.unionation.fields[0].enum_field;
12141 bigint_init_bigint(&result->value.data.x_enum_tag, &enum_field->value);
12140 result->value->special = ConstValSpecialStatic;
12141 result->value->type = wanted_type;
12142 TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field;
12143 bigint_init_bigint(&result->value->data.x_enum_tag, &enum_field->value);
1214212144 return result;
1214312145 }
1214412146
1214512147 IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope,
1214612148 source_instr->source_node, target);
12147 result->value.type = wanted_type;
12149 result->value->type = wanted_type;
1214812150 return result;
1214912151}
1215012152
......@@ -12152,7 +12154,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc
1215212154 IrInstruction *target, ZigType *wanted_type)
1215312155{
1215412156 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12155 result->value.special = ConstValSpecialUndef;
12157 result->value->special = ConstValSpecialUndef;
1215612158 return result;
1215712159}
1215812160
......@@ -12166,7 +12168,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
1216612168 return ira->codegen->invalid_instruction;
1216712169
1216812170 IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type);
12169 if (type_is_invalid(target->value.type))
12171 if (type_is_invalid(target->value->type))
1217012172 return ira->codegen->invalid_instruction;
1217112173
1217212174 if (instr_is_comptime(target)) {
......@@ -12201,12 +12203,12 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
1220112203 }
1220212204
1220312205 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12204 result->value.special = ConstValSpecialStatic;
12205 result->value.type = wanted_type;
12206 bigint_init_bigint(&result->value.data.x_union.tag, &val->data.x_enum_tag);
12207 result->value.data.x_union.payload = create_const_vals(1);
12208 result->value.data.x_union.payload->special = ConstValSpecialStatic;
12209 result->value.data.x_union.payload->type = field_type;
12206 result->value->special = ConstValSpecialStatic;
12207 result->value->type = wanted_type;
12208 bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag);
12209 result->value->data.x_union.payload = create_const_vals(1);
12210 result->value->data.x_union.payload->special = ConstValSpecialStatic;
12211 result->value->data.x_union.payload->type = field_type;
1221012212 return result;
1221112213 }
1221212214
......@@ -12214,7 +12216,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
1221412216 // and in fact it's a noop cast because the union value is just the enum value
1221512217 if (wanted_type->data.unionation.gen_field_count == 0) {
1221612218 IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop);
12217 result->value.type = wanted_type;
12219 result->value->type = wanted_type;
1221812220 return result;
1221912221 }
1222012222
......@@ -12259,16 +12261,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction
1225912261 {
1226012262 ir_add_error(ira, source_instr,
1226112263 buf_sprintf("cast from '%s' to '%s' truncates bits",
12262 buf_ptr(&target->value.type->name), buf_ptr(&wanted_type->name)));
12264 buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name)));
1226312265 return ira->codegen->invalid_instruction;
1226412266 }
1226512267 }
1226612268 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12267 result->value.type = wanted_type;
12269 result->value->type = wanted_type;
1226812270 if (wanted_type->id == ZigTypeIdInt) {
12269 bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint);
12271 bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint);
1227012272 } else {
12271 float_init_float(&result->value, val);
12273 float_init_float(result->value, val);
1227212274 }
1227312275 return result;
1227412276 }
......@@ -12278,16 +12280,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction
1227812280 // the target is zero.
1227912281 if (!type_has_bits(wanted_type)) {
1228012282 assert(wanted_type->id == ZigTypeIdInt);
12281 assert(type_has_bits(target->value.type));
12283 assert(type_has_bits(target->value->type));
1228212284 ir_build_assert_zero(ira, source_instr, target);
1228312285 IrInstruction *result = ir_const_unsigned(ira, source_instr, 0);
12284 result->value.type = wanted_type;
12286 result->value->type = wanted_type;
1228512287 return result;
1228612288 }
1228712289
1228812290 IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope,
1228912291 source_instr->source_node, target);
12290 result->value.type = wanted_type;
12292 result->value->type = wanted_type;
1229112293 return result;
1229212294}
1229312295
......@@ -12297,7 +12299,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
1229712299 Error err;
1229812300 assert(wanted_type->id == ZigTypeIdEnum);
1229912301
12300 ZigType *actual_type = target->value.type;
12302 ZigType *actual_type = target->value->type;
1230112303
1230212304 if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown)))
1230312305 return ira->codegen->invalid_instruction;
......@@ -12330,13 +12332,13 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
1233012332 }
1233112333
1233212334 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12333 bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_bigint);
12335 bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint);
1233412336 return result;
1233512337 }
1233612338
1233712339 IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope,
1233812340 source_instr->source_node, nullptr, target);
12339 result->value.type = wanted_type;
12341 result->value->type = wanted_type;
1234012342 return result;
1234112343}
1234212344
......@@ -12349,9 +12351,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
1234912351
1235012352 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
1235112353 if (wanted_type->id == ZigTypeIdComptimeFloat) {
12352 float_init_float(&result->value, val);
12354 float_init_float(result->value, val);
1235312355 } else if (wanted_type->id == ZigTypeIdComptimeInt) {
12354 bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint);
12356 bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint);
1235512357 } else {
1235612358 zig_unreachable();
1235712359 }
......@@ -12361,8 +12363,8 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
1236112363static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
1236212364 ZigType *wanted_type)
1236312365{
12364 assert(target->value.type->id == ZigTypeIdInt);
12365 assert(!target->value.type->data.integral.is_signed);
12366 assert(target->value->type->id == ZigTypeIdInt);
12367 assert(!target->value->type->data.integral.is_signed);
1236612368 assert(wanted_type->id == ZigTypeIdErrorSet);
1236712369
1236812370 if (instr_is_comptime(target)) {
......@@ -12389,7 +12391,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
1238912391 }
1239012392
1239112393 size_t index = bigint_as_usize(&val->data.x_bigint);
12392 result->value.data.x_err_set = ira->codegen->errors_by_index.at(index);
12394 result->value->data.x_err_set = ira->codegen->errors_by_index.at(index);
1239312395 return result;
1239412396 } else {
1239512397 ErrorTableEntry *err = nullptr;
......@@ -12412,13 +12414,13 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
1241212414 return ira->codegen->invalid_instruction;
1241312415 }
1241412416
12415 result->value.data.x_err_set = err;
12417 result->value->data.x_err_set = err;
1241612418 return result;
1241712419 }
1241812420 }
1241912421
1242012422 IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target);
12421 result->value.type = wanted_type;
12423 result->value->type = wanted_type;
1242212424 return result;
1242312425}
1242412426
......@@ -12427,7 +12429,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
1242712429{
1242812430 assert(wanted_type->id == ZigTypeIdInt);
1242912431
12430 ZigType *err_type = target->value.type;
12432 ZigType *err_type = target->value->type;
1243112433
1243212434 if (instr_is_comptime(target)) {
1243312435 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
......@@ -12444,11 +12446,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
1244412446 } else {
1244512447 zig_unreachable();
1244612448 }
12447 result->value.type = wanted_type;
12449 result->value->type = wanted_type;
1244812450 uint64_t err_value = err ? err->value : 0;
12449 bigint_init_unsigned(&result->value.data.x_bigint, err_value);
12451 bigint_init_unsigned(&result->value->data.x_bigint, err_value);
1245012452
12451 if (!bigint_fits_in_bits(&result->value.data.x_bigint,
12453 if (!bigint_fits_in_bits(&result->value->data.x_bigint,
1245212454 wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed))
1245312455 {
1245412456 ir_add_error_node(ira, source_instr->source_node,
......@@ -12474,12 +12476,12 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
1247412476 }
1247512477 if (err_set_type->data.error_set.err_count == 0) {
1247612478 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
12477 bigint_init_unsigned(&result->value.data.x_bigint, 0);
12479 bigint_init_unsigned(&result->value->data.x_bigint, 0);
1247812480 return result;
1247912481 } else if (err_set_type->data.error_set.err_count == 1) {
1248012482 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
1248112483 ErrorTableEntry *err = err_set_type->data.error_set.errors[0];
12482 bigint_init_unsigned(&result->value.data.x_bigint, err->value);
12484 bigint_init_unsigned(&result->value->data.x_bigint, err->value);
1248312485 return result;
1248412486 }
1248512487 }
......@@ -12493,7 +12495,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
1249312495 }
1249412496
1249512497 IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target);
12496 result->value.type = wanted_type;
12498 result->value->type = wanted_type;
1249712499 return result;
1249812500}
1249912501
......@@ -12502,10 +12504,10 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou
1250212504{
1250312505 assert(wanted_type->id == ZigTypeIdPointer);
1250412506 Error err;
12505 if ((err = type_resolve(ira->codegen, target->value.type->data.pointer.child_type, ResolveStatusAlignmentKnown)))
12507 if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown)))
1250612508 return ira->codegen->invalid_instruction;
12507 assert((wanted_type->data.pointer.is_const && target->value.type->data.pointer.is_const) || !target->value.type->data.pointer.is_const);
12508 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value.type));
12509 assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const);
12510 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type));
1250912511 ZigType *array_type = wanted_type->data.pointer.child_type;
1251012512 assert(array_type->id == ZigTypeIdArray);
1251112513 assert(array_type->data.array.len == 1);
......@@ -12530,11 +12532,11 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou
1253012532
1253112533 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1253212534 source_instr->scope, source_instr->source_node);
12533 const_instruction->base.value.type = wanted_type;
12534 const_instruction->base.value.special = ConstValSpecialStatic;
12535 const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialRef;
12536 const_instruction->base.value.data.x_ptr.data.ref.pointee = array_val;
12537 const_instruction->base.value.data.x_ptr.mut = val->data.x_ptr.mut;
12535 const_instruction->base.value->type = wanted_type;
12536 const_instruction->base.value->special = ConstValSpecialStatic;
12537 const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialRef;
12538 const_instruction->base.value->data.x_ptr.data.ref.pointee = array_val;
12539 const_instruction->base.value->data.x_ptr.mut = val->data.x_ptr.mut;
1253812540 return &const_instruction->base;
1253912541 }
1254012542 }
......@@ -12542,7 +12544,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou
1254212544 // pointer to array and pointer to single item are represented the same way at runtime
1254312545 IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node,
1254412546 wanted_type, target, CastOpBitCast);
12545 result->value.type = wanted_type;
12547 result->value->type = wanted_type;
1254612548 return result;
1254712549}
1254812550
......@@ -12726,8 +12728,8 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction *
1272612728 if (instr_is_comptime(array)) {
1272712729 // arrays and vectors have the same ZigValue representation
1272812730 IrInstruction *result = ir_const(ira, source_instr, vector_type);
12729 copy_const_val(&result->value, &array->value, false);
12730 result->value.type = vector_type;
12731 copy_const_val(result->value, array->value, false);
12732 result->value->type = vector_type;
1273112733 return result;
1273212734 }
1273312735 return ir_build_array_to_vector(ira, source_instr, array, vector_type);
......@@ -12739,8 +12741,8 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
1273912741 if (instr_is_comptime(vector)) {
1274012742 // arrays and vectors have the same ZigValue representation
1274112743 IrInstruction *result = ir_const(ira, source_instr, array_type);
12742 copy_const_val(&result->value, &vector->value, false);
12743 result->value.type = array_type;
12744 copy_const_val(result->value, vector->value, false);
12745 result->value->type = array_type;
1274412746 return result;
1274512747 }
1274612748 if (result_loc == nullptr) {
......@@ -12748,7 +12750,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
1274812750 }
1274912751 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr,
1275012752 true, false, true);
12751 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
12753 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1275212754 return result_loc_inst;
1275312755 }
1275412756 return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst);
......@@ -12761,23 +12763,23 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou
1276112763 if (instr_is_comptime(integer)) {
1276212764 unsigned_integer = integer;
1276312765 } else {
12764 assert(integer->value.type->id == ZigTypeIdInt);
12766 assert(integer->value->type->id == ZigTypeIdInt);
1276512767
12766 if (integer->value.type->data.integral.bit_count >
12768 if (integer->value->type->data.integral.bit_count >
1276712769 ira->codegen->builtin_types.entry_usize->data.integral.bit_count)
1276812770 {
1276912771 ir_add_error(ira, source_instr,
1277012772 buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'",
12771 buf_ptr(&integer->value.type->name),
12773 buf_ptr(&integer->value->type->name),
1277212774 buf_ptr(&dest_type->name)));
1277312775 return ira->codegen->invalid_instruction;
1277412776 }
1277512777
12776 if (integer->value.type->data.integral.is_signed) {
12778 if (integer->value->type->data.integral.is_signed) {
1277712779 ZigType *unsigned_int_type = get_int_type(ira->codegen, false,
12778 integer->value.type->data.integral.bit_count);
12780 integer->value->type->data.integral.bit_count);
1277912781 unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type);
12780 if (type_is_invalid(unsigned_integer->value.type))
12782 if (type_is_invalid(unsigned_integer->value->type))
1278112783 return ira->codegen->invalid_instruction;
1278212784 } else {
1278312785 unsigned_integer = integer;
......@@ -12807,16 +12809,16 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou
1280712809 if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown)))
1280812810 return ira->codegen->invalid_instruction;
1280912811
12810 TypeEnumField *field = find_enum_type_field(enum_type, value->value.data.x_enum_literal);
12812 TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal);
1281112813 if (field == nullptr) {
1281212814 ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'",
12813 buf_ptr(&enum_type->name), buf_ptr(value->value.data.x_enum_literal)));
12815 buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal)));
1281412816 add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node,
1281512817 buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name)));
1281612818 return ira->codegen->invalid_instruction;
1281712819 }
1281812820 IrInstruction *result = ir_const(ira, source_instr, enum_type);
12819 bigint_init_bigint(&result->value.data.x_enum_tag, &field->value);
12821 bigint_init_bigint(&result->value->data.x_enum_tag, &field->value);
1282012822
1282112823 return result;
1282212824}
......@@ -12885,7 +12887,7 @@ static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst
1288512887{
1288612888 IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false);
1288712889 IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr,
12888 struct_operand->value.type, false);
12890 struct_operand->value->type, false);
1288912891 return ir_get_deref(ira, source_instr, field_ptr, nullptr);
1289012892}
1289112893
......@@ -12893,7 +12895,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1289312895 ZigType *wanted_type, IrInstruction *value)
1289412896{
1289512897 Error err;
12896 ZigType *actual_type = value->value.type;
12898 ZigType *actual_type = value->value->type;
1289712899 AstNode *source_node = source_instr->source_node;
1289812900
1289912901 if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) {
......@@ -12915,13 +12917,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1291512917 }
1291612918
1291712919 if (const_cast_result.id == ConstCastResultIdFnCC) {
12918 ir_assert(value->value.type->id == ZigTypeIdFn, source_instr);
12920 ir_assert(value->value->type->id == ZigTypeIdFn, source_instr);
1291912921 // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok.
1292012922 if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync &&
1292112923 actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified)
1292212924 {
12923 ir_assert(value->value.data.x_ptr.special == ConstPtrSpecialFunction, source_instr);
12924 ZigFn *fn = value->value.data.x_ptr.data.fn.fn_entry;
12925 ir_assert(value->value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr);
12926 ZigFn *fn = value->value->data.x_ptr.data.fn.fn_entry;
1292512927 if (fn->inferred_async_node == nullptr) {
1292612928 fn->inferred_async_node = source_instr->source_node;
1292712929 }
......@@ -12963,7 +12965,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1296312965 {
1296412966 IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value,
1296512967 wanted_child_type);
12966 if (type_is_invalid(cast1->value.type))
12968 if (type_is_invalid(cast1->value->type))
1296712969 return ira->codegen->invalid_instruction;
1296812970 return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr);
1296912971 }
......@@ -12999,11 +13001,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1299913001 actual_type->id == ZigTypeIdComptimeFloat)
1300013002 {
1300113003 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
13002 if (type_is_invalid(cast1->value.type))
13004 if (type_is_invalid(cast1->value->type))
1300313005 return ira->codegen->invalid_instruction;
1300413006
1300513007 IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
13006 if (type_is_invalid(cast2->value.type))
13008 if (type_is_invalid(cast2->value->type))
1300713009 return ira->codegen->invalid_instruction;
1300813010
1300913011 return cast2;
......@@ -13018,29 +13020,29 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1301813020 (wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdComptimeInt ||
1301913021 wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat))
1302013022 {
13021 if (value->value.special == ConstValSpecialUndef) {
13023 if (value->value->special == ConstValSpecialUndef) {
1302213024 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
13023 result->value.special = ConstValSpecialUndef;
13025 result->value->special = ConstValSpecialUndef;
1302413026 return result;
1302513027 }
1302613028 if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) {
1302713029 if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) {
1302813030 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
1302913031 if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) {
13030 copy_const_val(&result->value, &value->value, false);
13031 result->value.type = wanted_type;
13032 copy_const_val(result->value, value->value, false);
13033 result->value->type = wanted_type;
1303213034 } else {
13033 float_init_bigint(&result->value.data.x_bigint, &value->value);
13035 float_init_bigint(&result->value->data.x_bigint, value->value);
1303413036 }
1303513037 return result;
1303613038 } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) {
1303713039 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
1303813040 if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) {
1303913041 BigFloat bf;
13040 bigfloat_init_bigint(&bf, &value->value.data.x_bigint);
13041 float_init_bigfloat(&result->value, &bf);
13042 bigfloat_init_bigint(&bf, &value->value->data.x_bigint);
13043 float_init_bigfloat(result->value, &bf);
1304213044 } else {
13043 float_init_float(&result->value, &value->value);
13045 float_init_float(result->value, value->value);
1304413046 }
1304513047 return result;
1304613048 }
......@@ -13102,11 +13104,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1310213104 source_node, false).id == ConstCastResultIdOk)
1310313105 {
1310413106 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value);
13105 if (type_is_invalid(cast1->value.type))
13107 if (type_is_invalid(cast1->value->type))
1310613108 return ira->codegen->invalid_instruction;
1310713109
1310813110 IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
13109 if (type_is_invalid(cast2->value.type))
13111 if (type_is_invalid(cast2->value->type))
1311013112 return ira->codegen->invalid_instruction;
1311113113
1311213114 return cast2;
......@@ -13121,11 +13123,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1312113123 actual_type->data.pointer.child_type->id == ZigTypeIdArray)
1312213124 {
1312313125 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value);
13124 if (type_is_invalid(cast1->value.type))
13126 if (type_is_invalid(cast1->value->type))
1312513127 return ira->codegen->invalid_instruction;
1312613128
1312713129 IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
13128 if (type_is_invalid(cast2->value.type))
13130 if (type_is_invalid(cast2->value->type))
1312913131 return ira->codegen->invalid_instruction;
1313013132
1313113133 return cast2;
......@@ -13202,11 +13204,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1320213204 if (ok_align) {
1320313205 if (wanted_type->id == ZigTypeIdErrorUnion) {
1320413206 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value);
13205 if (type_is_invalid(cast1->value.type))
13207 if (type_is_invalid(cast1->value->type))
1320613208 return ira->codegen->invalid_instruction;
1320713209
1320813210 IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
13209 if (type_is_invalid(cast2->value.type))
13211 if (type_is_invalid(cast2->value->type))
1321013212 return ira->codegen->invalid_instruction;
1321113213
1321213214 return cast2;
......@@ -13309,11 +13311,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1330913311 source_node, false).id == ConstCastResultIdOk)
1331013312 {
1331113313 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
13312 if (type_is_invalid(cast1->value.type))
13314 if (type_is_invalid(cast1->value->type))
1331313315 return ira->codegen->invalid_instruction;
1331413316
1331513317 IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1);
13316 if (type_is_invalid(cast2->value.type))
13318 if (type_is_invalid(cast2->value->type))
1331713319 return ira->codegen->invalid_instruction;
1331813320
1331913321 return cast2;
......@@ -13529,13 +13531,13 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou
1352913531 assert(value);
1353013532 assert(value != ira->codegen->invalid_instruction);
1353113533 assert(!expected_type || !type_is_invalid(expected_type));
13532 assert(value->value.type);
13533 assert(!type_is_invalid(value->value.type));
13534 assert(value->value->type);
13535 assert(!type_is_invalid(value->value->type));
1353413536 if (expected_type == nullptr)
1353513537 return value; // anything will do
13536 if (expected_type == value->value.type)
13538 if (expected_type == value->value->type)
1353713539 return value; // match
13538 if (value->value.type->id == ZigTypeIdUnreachable)
13540 if (value->value->type->id == ZigTypeIdUnreachable)
1353913541 return value;
1354013542
1354113543 return ir_analyze_cast(ira, value_source_instr, expected_type, value);
......@@ -13549,7 +13551,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1354913551 ResultLoc *result_loc)
1355013552{
1355113553 Error err;
13552 ZigType *ptr_type = ptr->value.type;
13554 ZigType *ptr_type = ptr->value->type;
1355313555 if (type_is_invalid(ptr_type))
1355413556 return ira->codegen->invalid_instruction;
1355513557
......@@ -13571,24 +13573,24 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1357113573 break;
1357213574 }
1357313575 if (instr_is_comptime(ptr)) {
13574 if (ptr->value.special == ConstValSpecialUndef) {
13576 if (ptr->value->special == ConstValSpecialUndef) {
1357513577 ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value"));
1357613578 return ira->codegen->invalid_instruction;
1357713579 }
13578 if (ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
13579 ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, &ptr->value);
13580 if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
13581 ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value);
1358013582 if (child_type == ira->codegen->builtin_types.entry_var) {
1358113583 child_type = pointee->type;
1358213584 }
1358313585 if (pointee->special != ConstValSpecialRuntime) {
1358413586 IrInstruction *result = ir_const(ira, source_instruction, child_type);
1358513587
13586 if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, &result->value,
13587 &ptr->value)))
13588 if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value,
13589 ptr->value)))
1358813590 {
1358913591 return ira->codegen->invalid_instruction;
1359013592 }
13591 result->value.type = child_type;
13593 result->value->type = child_type;
1359213594 return result;
1359313595 }
1359413596 }
......@@ -13626,7 +13628,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1362613628 if (result_loc == nullptr) result_loc = no_result_loc();
1362713629 result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr,
1362813630 true, false, true);
13629 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
13631 if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) {
1363013632 return result_loc_inst;
1363113633 }
1363213634 } else {
......@@ -13660,15 +13662,15 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode
1366013662}
1366113663
1366213664static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) {
13663 if (type_is_invalid(value->value.type))
13665 if (type_is_invalid(value->value->type))
1366413666 return false;
1366513667
1366613668 // Look for this pattern: `*align(@alignOf(T)) T`.
1366713669 // This can be resolved to be `*out = 0` without resolving any alignment.
13668 if (elem_type != nullptr && value->value.special == ConstValSpecialLazy &&
13669 value->value.data.x_lazy->id == LazyValueIdAlignOf)
13670 if (elem_type != nullptr && value->value->special == ConstValSpecialLazy &&
13671 value->value->data.x_lazy->id == LazyValueIdAlignOf)
1367013672 {
13671 LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value.data.x_lazy);
13673 LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value->data.x_lazy);
1367213674
1367313675 ZigType *lazy_elem_type = ir_resolve_type(lazy_align_of->ira, lazy_align_of->target_type);
1367413676 if (type_is_invalid(lazy_elem_type))
......@@ -13681,19 +13683,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem
1368113683 }
1368213684
1368313685 IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen));
13684 if (type_is_invalid(casted_value->value.type))
13686 if (type_is_invalid(casted_value->value->type))
1368513687 return false;
1368613688
1368713689 return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node,
13688 &casted_value->value, out);
13690 casted_value->value, out);
1368913691}
1369013692
1369113693static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) {
13692 if (type_is_invalid(value->value.type))
13694 if (type_is_invalid(value->value->type))
1369313695 return false;
1369413696
1369513697 IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type);
13696 if (type_is_invalid(casted_value->value.type))
13698 if (type_is_invalid(casted_value->value->type))
1369713699 return false;
1369813700
1369913701 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13709,11 +13711,11 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out
1370913711}
1371013712
1371113713static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) {
13712 if (type_is_invalid(value->value.type))
13714 if (type_is_invalid(value->value->type))
1371313715 return false;
1371413716
1371513717 IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool);
13716 if (type_is_invalid(casted_value->value.type))
13718 if (type_is_invalid(casted_value->value->type))
1371713719 return false;
1371813720
1371913721 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13733,7 +13735,7 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out)
1373313735}
1373413736
1373513737static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) {
13736 if (type_is_invalid(value->value.type))
13738 if (type_is_invalid(value->value->type))
1373713739 return false;
1373813740
1373913741 ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");
......@@ -13741,7 +13743,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1374113743 ZigType *atomic_order_type = atomic_order_val->data.x_type;
1374213744
1374313745 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type);
13744 if (type_is_invalid(casted_value->value.type))
13746 if (type_is_invalid(casted_value->value->type))
1374513747 return false;
1374613748
1374713749 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13753,7 +13755,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1375313755}
1375413756
1375513757static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) {
13756 if (type_is_invalid(value->value.type))
13758 if (type_is_invalid(value->value->type))
1375713759 return false;
1375813760
1375913761 ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");
......@@ -13761,7 +13763,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1376113763 ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
1376213764
1376313765 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type);
13764 if (type_is_invalid(casted_value->value.type))
13766 if (type_is_invalid(casted_value->value->type))
1376513767 return false;
1376613768
1376713769 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13773,7 +13775,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1377313775}
1377413776
1377513777static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) {
13776 if (type_is_invalid(value->value.type))
13778 if (type_is_invalid(value->value->type))
1377713779 return false;
1377813780
1377913781 ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");
......@@ -13781,7 +13783,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1378113783 ZigType *global_linkage_type = global_linkage_val->data.x_type;
1378213784
1378313785 IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type);
13784 if (type_is_invalid(casted_value->value.type))
13786 if (type_is_invalid(casted_value->value->type))
1378513787 return false;
1378613788
1378713789 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13793,7 +13795,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1379313795}
1379413796
1379513797static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) {
13796 if (type_is_invalid(value->value.type))
13798 if (type_is_invalid(value->value->type))
1379713799 return false;
1379813800
1379913801 ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");
......@@ -13801,7 +13803,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1380113803 ZigType *float_mode_type = float_mode_val->data.x_type;
1380213804
1380313805 IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type);
13804 if (type_is_invalid(casted_value->value.type))
13806 if (type_is_invalid(casted_value->value->type))
1380513807 return false;
1380613808
1380713809 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13813,14 +13815,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1381313815}
1381413816
1381513817static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
13816 if (type_is_invalid(value->value.type))
13818 if (type_is_invalid(value->value->type))
1381713819 return nullptr;
1381813820
1381913821 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
1382013822 true, false, PtrLenUnknown, 0, 0, 0, false);
1382113823 ZigType *str_type = get_slice_type(ira->codegen, ptr_type);
1382213824 IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type);
13823 if (type_is_invalid(casted_value->value.type))
13825 if (type_is_invalid(casted_value->value->type))
1382413826 return nullptr;
1382513827
1382613828 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -13858,7 +13860,7 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze
1385813860 IrInstructionAddImplicitReturnType *instruction)
1385913861{
1386013862 IrInstruction *value = instruction->value->child;
13861 if (type_is_invalid(value->value.type))
13863 if (type_is_invalid(value->value->type))
1386213864 return ir_unreach_error(ira);
1386313865
1386413866 if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) {
......@@ -13870,11 +13872,11 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze
1387013872
1387113873static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) {
1387213874 IrInstruction *operand = instruction->operand->child;
13873 if (type_is_invalid(operand->value.type))
13875 if (type_is_invalid(operand->value->type))
1387413876 return ir_unreach_error(ira);
1387513877
1387613878 IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type);
13877 if (type_is_invalid(casted_operand->value.type)) {
13879 if (type_is_invalid(casted_operand->value->type)) {
1387813880 AstNode *source_node = ira->explicit_return_type_source_node;
1387913881 if (source_node != nullptr) {
1388013882 ErrorMsg *msg = ira->codegen->errors.last();
......@@ -13890,13 +13892,13 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
1389013892 // result location mechanism took care of it.
1389113893 IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope,
1389213894 instruction->base.source_node, nullptr);
13893 result->value.type = ira->codegen->builtin_types.entry_unreachable;
13895 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1389413896 return ir_finish_anal(ira, result);
1389513897 }
1389613898
13897 if (casted_operand->value.special == ConstValSpecialRuntime &&
13898 casted_operand->value.type->id == ZigTypeIdPointer &&
13899 casted_operand->value.data.rh_ptr == RuntimeHintPtrStack)
13899 if (casted_operand->value->special == ConstValSpecialRuntime &&
13900 casted_operand->value->type->id == ZigTypeIdPointer &&
13901 casted_operand->value->data.rh_ptr == RuntimeHintPtrStack)
1390013902 {
1390113903 ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable"));
1390213904 return ir_unreach_error(ira);
......@@ -13904,23 +13906,23 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio
1390413906
1390513907 IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope,
1390613908 instruction->base.source_node, casted_operand);
13907 result->value.type = ira->codegen->builtin_types.entry_unreachable;
13909 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1390813910 return ir_finish_anal(ira, result);
1390913911}
1391013912
1391113913static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) {
1391213914 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
13913 copy_const_val(&result->value, &instruction->base.value, true);
13915 copy_const_val(result->value, instruction->base.value, true);
1391413916 return result;
1391513917}
1391613918
1391713919static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
1391813920 IrInstruction *op1 = bin_op_instruction->op1->child;
13919 if (type_is_invalid(op1->value.type))
13921 if (type_is_invalid(op1->value->type))
1392013922 return ira->codegen->invalid_instruction;
1392113923
1392213924 IrInstruction *op2 = bin_op_instruction->op2->child;
13923 if (type_is_invalid(op2->value.type))
13925 if (type_is_invalid(op2->value->type))
1392413926 return ira->codegen->invalid_instruction;
1392513927
1392613928 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
......@@ -13942,8 +13944,8 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
1394213944 if (op2_val == nullptr)
1394313945 return ira->codegen->invalid_instruction;
1394413946
13945 assert(casted_op1->value.type->id == ZigTypeIdBool);
13946 assert(casted_op2->value.type->id == ZigTypeIdBool);
13947 assert(casted_op1->value->type->id == ZigTypeIdBool);
13948 assert(casted_op2->value->type->id == ZigTypeIdBool);
1394713949 bool result_bool;
1394813950 if (bin_op_instruction->op_id == IrBinOpBoolOr) {
1394913951 result_bool = op1_val->data.x_bool || op2_val->data.x_bool;
......@@ -13958,7 +13960,7 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
1395813960 IrInstruction *result = ir_build_bin_op(&ira->new_irb,
1395913961 bin_op_instruction->base.scope, bin_op_instruction->base.source_node,
1396013962 bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on);
13961 result->value.type = bool_type;
13963 result->value->type = bool_type;
1396213964 return result;
1396313965}
1396413966
......@@ -14079,7 +14081,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) {
1407914081 LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy);
1408014082 IrAnalyze *ira = lazy_size_of->ira;
1408114083 bool is_zero_bits;
14082 if ((err = type_val_resolve_zero_bits(ira->codegen, &lazy_size_of->target_type->value,
14084 if ((err = type_val_resolve_zero_bits(ira->codegen, lazy_size_of->target_type->value,
1408314085 nullptr, nullptr, &is_zero_bits)))
1408414086 {
1408514087 return err;
......@@ -14098,27 +14100,27 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1409814100 Error err;
1409914101
1410014102 IrInstruction *op1 = bin_op_instruction->op1->child;
14101 if (type_is_invalid(op1->value.type))
14103 if (type_is_invalid(op1->value->type))
1410214104 return ira->codegen->invalid_instruction;
1410314105
1410414106 IrInstruction *op2 = bin_op_instruction->op2->child;
14105 if (type_is_invalid(op2->value.type))
14107 if (type_is_invalid(op2->value->type))
1410614108 return ira->codegen->invalid_instruction;
1410714109
1410814110 AstNode *source_node = bin_op_instruction->base.source_node;
1410914111
1411014112 IrBinOp op_id = bin_op_instruction->op_id;
1411114113 bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq);
14112 if (is_equality_cmp && op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdNull) {
14114 if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) {
1411314115 return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq));
1411414116 } else if (is_equality_cmp &&
14115 ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdOptional) ||
14116 (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdOptional)))
14117 ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) ||
14118 (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional)))
1411714119 {
1411814120 IrInstruction *maybe_op;
14119 if (op1->value.type->id == ZigTypeIdNull) {
14121 if (op1->value->type->id == ZigTypeIdNull) {
1412014122 maybe_op = op2;
14121 } else if (op2->value.type->id == ZigTypeIdNull) {
14123 } else if (op2->value->type->id == ZigTypeIdNull) {
1412214124 maybe_op = op1;
1412314125 } else {
1412414126 zig_unreachable();
......@@ -14134,26 +14136,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1413414136
1413514137 IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope,
1413614138 source_node, maybe_op);
14137 is_non_null->value.type = ira->codegen->builtin_types.entry_bool;
14139 is_non_null->value->type = ira->codegen->builtin_types.entry_bool;
1413814140
1413914141 if (op_id == IrBinOpCmpEq) {
1414014142 IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope,
1414114143 bin_op_instruction->base.source_node, is_non_null);
14142 result->value.type = ira->codegen->builtin_types.entry_bool;
14144 result->value->type = ira->codegen->builtin_types.entry_bool;
1414314145 return result;
1414414146 } else {
1414514147 return is_non_null;
1414614148 }
1414714149 } else if (is_equality_cmp &&
14148 ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdPointer &&
14149 op2->value.type->data.pointer.ptr_len == PtrLenC) ||
14150 (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdPointer &&
14151 op1->value.type->data.pointer.ptr_len == PtrLenC)))
14150 ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdPointer &&
14151 op2->value->type->data.pointer.ptr_len == PtrLenC) ||
14152 (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer &&
14153 op1->value->type->data.pointer.ptr_len == PtrLenC)))
1415214154 {
1415314155 IrInstruction *c_ptr_op;
14154 if (op1->value.type->id == ZigTypeIdNull) {
14156 if (op1->value->type->id == ZigTypeIdNull) {
1415514157 c_ptr_op = op2;
14156 } else if (op2->value.type->id == ZigTypeIdNull) {
14158 } else if (op2->value->type->id == ZigTypeIdNull) {
1415714159 c_ptr_op = op1;
1415814160 } else {
1415914161 zig_unreachable();
......@@ -14172,38 +14174,38 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1417214174 }
1417314175 IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope,
1417414176 source_node, c_ptr_op);
14175 is_non_null->value.type = ira->codegen->builtin_types.entry_bool;
14177 is_non_null->value->type = ira->codegen->builtin_types.entry_bool;
1417614178
1417714179 if (op_id == IrBinOpCmpEq) {
1417814180 IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope,
1417914181 bin_op_instruction->base.source_node, is_non_null);
14180 result->value.type = ira->codegen->builtin_types.entry_bool;
14182 result->value->type = ira->codegen->builtin_types.entry_bool;
1418114183 return result;
1418214184 } else {
1418314185 return is_non_null;
1418414186 }
14185 } else if (op1->value.type->id == ZigTypeIdNull || op2->value.type->id == ZigTypeIdNull) {
14186 ZigType *non_null_type = (op1->value.type->id == ZigTypeIdNull) ? op2->value.type : op1->value.type;
14187 } else if (op1->value->type->id == ZigTypeIdNull || op2->value->type->id == ZigTypeIdNull) {
14188 ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type;
1418714189 ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null",
1418814190 buf_ptr(&non_null_type->name)));
1418914191 return ira->codegen->invalid_instruction;
1419014192 } else if (is_equality_cmp && (
14191 (op1->value.type->id == ZigTypeIdEnumLiteral && op2->value.type->id == ZigTypeIdUnion) ||
14192 (op2->value.type->id == ZigTypeIdEnumLiteral && op1->value.type->id == ZigTypeIdUnion)))
14193 (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) ||
14194 (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion)))
1419314195 {
1419414196 // Support equality comparison between a union's tag value and a enum literal
14195 IrInstruction *union_val = op1->value.type->id == ZigTypeIdUnion ? op1 : op2;
14196 IrInstruction *enum_val = op1->value.type->id == ZigTypeIdUnion ? op2 : op1;
14197 IrInstruction *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2;
14198 IrInstruction *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1;
1419714199
14198 ZigType *tag_type = union_val->value.type->data.unionation.tag_type;
14200 ZigType *tag_type = union_val->value->type->data.unionation.tag_type;
1419914201 assert(tag_type != nullptr);
1420014202
1420114203 IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type);
14202 if (type_is_invalid(casted_union->value.type))
14204 if (type_is_invalid(casted_union->value->type))
1420314205 return ira->codegen->invalid_instruction;
1420414206
1420514207 IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type);
14206 if (type_is_invalid(casted_val->value.type))
14208 if (type_is_invalid(casted_val->value->type))
1420714209 return ira->codegen->invalid_instruction;
1420814210
1420914211 if (instr_is_comptime(casted_union)) {
......@@ -14224,17 +14226,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1422414226 IrInstruction *result = ir_build_bin_op(&ira->new_irb,
1422514227 bin_op_instruction->base.scope, bin_op_instruction->base.source_node,
1422614228 op_id, casted_union, casted_val, bin_op_instruction->safety_check_on);
14227 result->value.type = ira->codegen->builtin_types.entry_bool;
14229 result->value->type = ira->codegen->builtin_types.entry_bool;
1422814230
1422914231 return result;
1423014232 }
1423114233
14232 if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) {
14234 if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) {
1423314235 if (!is_equality_cmp) {
1423414236 ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors"));
1423514237 return ira->codegen->invalid_instruction;
1423614238 }
14237 ZigType *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node);
14239 ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node);
1423814240 if (type_is_invalid(intersect_type)) {
1423914241 return ira->codegen->invalid_instruction;
1424014242 }
......@@ -14247,7 +14249,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1424714249 // (and make it comptime known)
1424814250 // this is a function which is evaluated at comptime and returns an inferred error set will have an empty
1424914251 // error set.
14250 if (op1->value.type->data.error_set.err_count == 0 || op2->value.type->data.error_set.err_count == 0) {
14252 if (op1->value->type->data.error_set.err_count == 0 || op2->value->type->data.error_set.err_count == 0) {
1425114253 bool are_equal = false;
1425214254 bool answer;
1425314255 if (op_id == IrBinOpCmpEq) {
......@@ -14264,10 +14266,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1426414266 if (intersect_type->data.error_set.err_count == 0) {
1426514267 ir_add_error_node(ira, source_node,
1426614268 buf_sprintf("error sets '%s' and '%s' have no common errors",
14267 buf_ptr(&op1->value.type->name), buf_ptr(&op2->value.type->name)));
14269 buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name)));
1426814270 return ira->codegen->invalid_instruction;
1426914271 }
14270 if (op1->value.type->data.error_set.err_count == 1 && op2->value.type->data.error_set.err_count == 1) {
14272 if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) {
1427114273 bool are_equal = true;
1427214274 bool answer;
1427314275 if (op_id == IrBinOpCmpEq) {
......@@ -14305,7 +14307,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1430514307 IrInstruction *result = ir_build_bin_op(&ira->new_irb,
1430614308 bin_op_instruction->base.scope, bin_op_instruction->base.source_node,
1430714309 op_id, op1, op2, bin_op_instruction->safety_check_on);
14308 result->value.type = ira->codegen->builtin_types.entry_bool;
14310 result->value->type = ira->codegen->builtin_types.entry_bool;
1430914311 return result;
1431014312 }
1431114313
......@@ -14390,12 +14392,12 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1439014392 // Before resolving the values, we special case comparisons against zero. These can often be done
1439114393 // without resolving lazy values, preventing potential dependency loops.
1439214394 Cmp op1_cmp_zero;
14393 if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op1->value, &op1_cmp_zero))) {
14395 if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op1->value, &op1_cmp_zero))) {
1439414396 if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally;
1439514397 return ira->codegen->invalid_instruction;
1439614398 }
1439714399 Cmp op2_cmp_zero;
14398 if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op2->value, &op2_cmp_zero))) {
14400 if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op2->value, &op2_cmp_zero))) {
1439914401 if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally;
1440014402 return ira->codegen->invalid_instruction;
1440114403 }
......@@ -14430,26 +14432,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1443014432 }
1443114433never_mind_just_calculate_it_normally:
1443214434
14433 ZigValue *op1_val = one_possible_value ? &casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad);
14435 ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad);
1443414436 if (op1_val == nullptr)
1443514437 return ira->codegen->invalid_instruction;
14436 ZigValue *op2_val = one_possible_value ? &casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad);
14438 ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad);
1443714439 if (op2_val == nullptr)
1443814440 return ira->codegen->invalid_instruction;
1443914441 if (resolved_type->id != ZigTypeIdVector)
1444014442 return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value);
1444114443 IrInstruction *result = ir_const(ira, &bin_op_instruction->base,
1444214444 get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool));
14443 result->value.data.x_array.data.s_none.elements =
14445 result->value->data.x_array.data.s_none.elements =
1444414446 create_const_vals(resolved_type->data.vector.len);
1444514447
14446 expand_undef_array(ira->codegen, &result->value);
14448 expand_undef_array(ira->codegen, result->value);
1444714449 for (size_t i = 0;i < resolved_type->data.vector.len;i++) {
1444814450 IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type,
1444914451 &op1_val->data.x_array.data.s_none.elements[i],
1445014452 &op2_val->data.x_array.data.s_none.elements[i],
1445114453 bin_op_instruction, op_id, one_possible_value);
14452 copy_const_val(&result->value.data.x_array.data.s_none.elements[i], &cur_res->value, false);
14454 copy_const_val(&result->value->data.x_array.data.s_none.elements[i], cur_res->value, false);
1445314455 }
1445414456 return result;
1445514457 }
......@@ -14495,10 +14497,10 @@ never_mind_just_calculate_it_normally:
1449514497 bin_op_instruction->base.scope, bin_op_instruction->base.source_node,
1449614498 op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on);
1449714499 if (resolved_type->id == ZigTypeIdVector) {
14498 result->value.type = get_vector_type(ira->codegen, resolved_type->data.vector.len,
14500 result->value->type = get_vector_type(ira->codegen, resolved_type->data.vector.len,
1449914501 ira->codegen->builtin_types.entry_bool);
1450014502 } else {
14501 result->value.type = ira->codegen->builtin_types.entry_bool;
14503 result->value->type = ira->codegen->builtin_types.entry_bool;
1450214504 }
1450314505 return result;
1450414506}
......@@ -14687,7 +14689,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i
1468714689 ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val)
1468814690{
1468914691 IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry);
14690 ZigValue *out_val = &result_instruction->value;
14692 ZigValue *out_val = result_instruction->value;
1469114693 if (type_entry->id == ZigTypeIdVector) {
1469214694 expand_undef_array(ira->codegen, op1_val);
1469314695 expand_undef_array(ira->codegen, op2_val);
......@@ -14722,52 +14724,52 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i
1472214724
1472314725static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
1472414726 IrInstruction *op1 = bin_op_instruction->op1->child;
14725 if (type_is_invalid(op1->value.type))
14727 if (type_is_invalid(op1->value->type))
1472614728 return ira->codegen->invalid_instruction;
1472714729
14728 if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) {
14730 if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) {
1472914731 ir_add_error(ira, bin_op_instruction->op1,
1473014732 buf_sprintf("bit shifting operation expected integer type, found '%s'",
14731 buf_ptr(&op1->value.type->name)));
14733 buf_ptr(&op1->value->type->name)));
1473214734 return ira->codegen->invalid_instruction;
1473314735 }
1473414736
1473514737 IrInstruction *op2 = bin_op_instruction->op2->child;
14736 if (type_is_invalid(op2->value.type))
14738 if (type_is_invalid(op2->value->type))
1473714739 return ira->codegen->invalid_instruction;
1473814740
14739 if (op2->value.type->id != ZigTypeIdInt && op2->value.type->id != ZigTypeIdComptimeInt) {
14741 if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) {
1474014742 ir_add_error(ira, bin_op_instruction->op2,
1474114743 buf_sprintf("shift amount has to be an integer type, but found '%s'",
14742 buf_ptr(&op2->value.type->name)));
14744 buf_ptr(&op2->value->type->name)));
1474314745 return ira->codegen->invalid_instruction;
1474414746 }
1474514747
1474614748 IrInstruction *casted_op2;
1474714749 IrBinOp op_id = bin_op_instruction->op_id;
14748 if (op1->value.type->id == ZigTypeIdComptimeInt) {
14750 if (op1->value->type->id == ZigTypeIdComptimeInt) {
1474914751 casted_op2 = op2;
1475014752
1475114753 if (op_id == IrBinOpBitShiftLeftLossy) {
1475214754 op_id = IrBinOpBitShiftLeftExact;
1475314755 }
1475414756
14755 if (casted_op2->value.data.x_bigint.is_negative) {
14757 if (casted_op2->value->data.x_bigint.is_negative) {
1475614758 Buf *val_buf = buf_alloc();
14757 bigint_append_buf(val_buf, &casted_op2->value.data.x_bigint, 10);
14759 bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10);
1475814760 ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf)));
1475914761 return ira->codegen->invalid_instruction;
1476014762 }
1476114763 } else {
1476214764 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
14763 op1->value.type->data.integral.bit_count - 1);
14765 op1->value->type->data.integral.bit_count - 1);
1476414766 if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy &&
14765 op2->value.type->id == ZigTypeIdComptimeInt) {
14766 if (!bigint_fits_in_bits(&op2->value.data.x_bigint,
14767 op2->value->type->id == ZigTypeIdComptimeInt) {
14768 if (!bigint_fits_in_bits(&op2->value->data.x_bigint,
1476714769 shift_amt_type->data.integral.bit_count,
14768 op2->value.data.x_bigint.is_negative)) {
14770 op2->value->data.x_bigint.is_negative)) {
1476914771 Buf *val_buf = buf_alloc();
14770 bigint_append_buf(val_buf, &op2->value.data.x_bigint, 10);
14772 bigint_append_buf(val_buf, &op2->value->data.x_bigint, 10);
1477114773 ErrorMsg* msg = ir_add_error(ira,
1477214774 &bin_op_instruction->base,
1477314775 buf_sprintf("RHS of shift is too large for LHS type"));
......@@ -14796,22 +14798,22 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
1479614798 if (op2_val == nullptr)
1479714799 return ira->codegen->invalid_instruction;
1479814800
14799 return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value.type, op1_val, op_id, op2_val);
14800 } else if (op1->value.type->id == ZigTypeIdComptimeInt) {
14801 return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value->type, op1_val, op_id, op2_val);
14802 } else if (op1->value->type->id == ZigTypeIdComptimeInt) {
1480114803 ir_add_error(ira, &bin_op_instruction->base,
1480214804 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));
1480314805 return ira->codegen->invalid_instruction;
14804 } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value.data.x_bigint) == CmpEQ) {
14806 } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) {
1480514807 IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope,
14806 bin_op_instruction->base.source_node, op1->value.type, op1, CastOpNoop);
14807 result->value.type = op1->value.type;
14808 bin_op_instruction->base.source_node, op1->value->type, op1, CastOpNoop);
14809 result->value->type = op1->value->type;
1480814810 return result;
1480914811 }
1481014812
1481114813 IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope,
1481214814 bin_op_instruction->base.source_node, op_id,
1481314815 op1, casted_op2, bin_op_instruction->safety_check_on);
14814 result->value.type = op1->value.type;
14816 result->value->type = op1->value->type;
1481514817 return result;
1481614818}
1481714819
......@@ -14880,19 +14882,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1488014882 Error err;
1488114883
1488214884 IrInstruction *op1 = instruction->op1->child;
14883 if (type_is_invalid(op1->value.type))
14885 if (type_is_invalid(op1->value->type))
1488414886 return ira->codegen->invalid_instruction;
1488514887
1488614888 IrInstruction *op2 = instruction->op2->child;
14887 if (type_is_invalid(op2->value.type))
14889 if (type_is_invalid(op2->value->type))
1488814890 return ira->codegen->invalid_instruction;
1488914891
1489014892 IrBinOp op_id = instruction->op_id;
1489114893
1489214894 // look for pointer math
14893 if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) {
14895 if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) {
1489414896 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize);
14895 if (type_is_invalid(casted_op2->value.type))
14897 if (type_is_invalid(casted_op2->value->type))
1489614898 return ira->codegen->invalid_instruction;
1489714899
1489814900 // If either operand is undef, result is undef.
......@@ -14903,19 +14905,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1490314905 if (op1_val == nullptr)
1490414906 return ira->codegen->invalid_instruction;
1490514907 if (op1_val->special == ConstValSpecialUndef)
14906 return ir_const_undef(ira, &instruction->base, op1->value.type);
14908 return ir_const_undef(ira, &instruction->base, op1->value->type);
1490714909 }
1490814910 if (instr_is_comptime(casted_op2)) {
1490914911 op2_val = ir_resolve_const(ira, casted_op2, UndefOk);
1491014912 if (op2_val == nullptr)
1491114913 return ira->codegen->invalid_instruction;
1491214914 if (op2_val->special == ConstValSpecialUndef)
14913 return ir_const_undef(ira, &instruction->base, op1->value.type);
14915 return ir_const_undef(ira, &instruction->base, op1->value->type);
1491414916 }
1491514917
1491614918 if (op2_val != nullptr && op1_val != nullptr &&
14917 (op1->value.data.x_ptr.special == ConstPtrSpecialHardCodedAddr ||
14918 op1->value.data.x_ptr.special == ConstPtrSpecialNull))
14919 (op1->value->data.x_ptr.special == ConstPtrSpecialHardCodedAddr ||
14920 op1->value->data.x_ptr.special == ConstPtrSpecialNull))
1491914921 {
1492014922 uint64_t start_addr = (op1_val->data.x_ptr.special == ConstPtrSpecialNull) ?
1492114923 0 : op1_val->data.x_ptr.data.hard_coded_addr.addr;
......@@ -14935,15 +14937,15 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1493514937 zig_unreachable();
1493614938 }
1493714939 IrInstruction *result = ir_const(ira, &instruction->base, op1_val->type);
14938 result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
14939 result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar;
14940 result->value.data.x_ptr.data.hard_coded_addr.addr = new_addr;
14940 result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
14941 result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar;
14942 result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr;
1494114943 return result;
1494214944 }
1494314945
1494414946 IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope,
1494514947 instruction->base.source_node, op_id, op1, casted_op2, true);
14946 result->value.type = op1->value.type;
14948 result->value->type = op1->value->type;
1494714949 return result;
1494814950 }
1494914951
......@@ -14958,11 +14960,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1495814960 (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) ||
1495914961 resolved_type->id == ZigTypeIdFloat ||
1496014962 (resolved_type->id == ZigTypeIdComptimeFloat &&
14961 ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) !=
14962 (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) ||
14963 ((bigfloat_cmp_zero(&op1->value->data.x_bigfloat) != CmpGT) !=
14964 (bigfloat_cmp_zero(&op2->value->data.x_bigfloat) != CmpGT))) ||
1496314965 (resolved_type->id == ZigTypeIdComptimeInt &&
14964 ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) !=
14965 (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT)))
14966 ((bigint_cmp_zero(&op1->value->data.x_bigint) != CmpGT) !=
14967 (bigint_cmp_zero(&op2->value->data.x_bigint) != CmpGT)))
1496614968 );
1496714969 if (op_id == IrBinOpDivUnspecified && is_int) {
1496814970 if (is_signed_div) {
......@@ -14995,8 +14997,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1499514997 if (!ok) {
1499614998 ir_add_error(ira, &instruction->base,
1499714999 buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact",
14998 buf_ptr(&op1->value.type->name),
14999 buf_ptr(&op2->value.type->name)));
15000 buf_ptr(&op1->value->type->name),
15001 buf_ptr(&op2->value->type->name)));
1500015002 return ira->codegen->invalid_instruction;
1500115003 }
1500215004 } else {
......@@ -15015,7 +15017,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1501515017 if (op2_val == nullptr)
1501615018 return ira->codegen->invalid_instruction;
1501715019
15018 if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) {
15020 if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) {
1501915021 // the division by zero error will be caught later, but we don't
1502015022 // have a remainder function ambiguity problem
1502115023 ok = true;
......@@ -15035,7 +15037,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1503515037 if (op2_val == nullptr)
1503615038 return ira->codegen->invalid_instruction;
1503715039
15038 if (float_cmp_zero(&casted_op2->value) == CmpEQ) {
15040 if (float_cmp_zero(casted_op2->value) == CmpEQ) {
1503915041 // the division by zero error will be caught later, but we don't
1504015042 // have a remainder function ambiguity problem
1504115043 ok = true;
......@@ -15051,8 +15053,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1505115053 if (!ok) {
1505215054 ir_add_error(ira, &instruction->base,
1505315055 buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod",
15054 buf_ptr(&op1->value.type->name),
15055 buf_ptr(&op2->value.type->name)));
15056 buf_ptr(&op1->value->type->name),
15057 buf_ptr(&op2->value->type->name)));
1505615058 return ira->codegen->invalid_instruction;
1505715059 }
1505815060 }
......@@ -15076,8 +15078,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1507615078 AstNode *source_node = instruction->base.source_node;
1507715079 ir_add_error_node(ira, source_node,
1507815080 buf_sprintf("invalid operands to binary expression: '%s' and '%s'",
15079 buf_ptr(&op1->value.type->name),
15080 buf_ptr(&op2->value.type->name)));
15081 buf_ptr(&op1->value->type->name),
15082 buf_ptr(&op2->value->type->name)));
1508115083 return ira->codegen->invalid_instruction;
1508215084 }
1508315085
......@@ -15112,18 +15114,18 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1511215114
1511315115 IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope,
1511415116 instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on);
15115 result->value.type = resolved_type;
15117 result->value->type = resolved_type;
1511615118 return result;
1511715119}
1511815120
1511915121static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) {
1512015122 IrInstruction *op1 = instruction->op1->child;
15121 ZigType *op1_type = op1->value.type;
15123 ZigType *op1_type = op1->value->type;
1512215124 if (type_is_invalid(op1_type))
1512315125 return ira->codegen->invalid_instruction;
1512415126
1512515127 IrInstruction *op2 = instruction->op2->child;
15126 ZigType *op2_type = op2->value.type;
15128 ZigType *op2_type = op2->value->type;
1512715129 if (type_is_invalid(op2_type))
1512815130 return ira->codegen->invalid_instruction;
1512915131
......@@ -15178,8 +15180,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1517815180 op1_array_end = array_type->data.array.len;
1517915181 sentinel1 = array_type->data.array.sentinel;
1518015182 } else {
15181 ir_add_error(ira, op1,
15182 buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value.type->name)));
15183 ir_add_error(ira, op1, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name)));
1518315184 return ira->codegen->invalid_instruction;
1518415185 }
1518515186
......@@ -15229,13 +15230,13 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1522915230 sentinel2 = array_type->data.array.sentinel;
1523015231 } else {
1523115232 ir_add_error(ira, op2,
15232 buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name)));
15233 buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name)));
1523315234 return ira->codegen->invalid_instruction;
1523415235 }
1523515236 if (!op2_type_valid) {
1523615237 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
1523715238 buf_ptr(&child_type->name),
15238 buf_ptr(&op2->value.type->name)));
15239 buf_ptr(&op2->value->type->name)));
1523915240 return ira->codegen->invalid_instruction;
1524015241 }
1524115242
......@@ -15254,13 +15255,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1525415255
1525515256 // The type of result is populated in the following if blocks
1525615257 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
15257 ZigValue *out_val = &result->value;
15258 ZigValue *out_val = result->value;
1525815259
1525915260 ZigValue *out_array_val;
1526015261 size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index);
1526115262 if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) {
15262 result->value.type = get_array_type(ira->codegen, child_type, new_len, sentinel);
15263
15263 result->value->type = get_array_type(ira->codegen, child_type, new_len, sentinel);
1526415264 out_array_val = out_val;
1526515265 } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) {
1526615266 out_array_val = create_const_vals(1);
......@@ -15274,7 +15274,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1527415274 ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, child_type,
1527515275 true, false, PtrLenUnknown, 0, 0, 0, false,
1527615276 VECTOR_INDEX_NONE, nullptr, sentinel);
15277 result->value.type = get_slice_type(ira->codegen, ptr_type);
15277 result->value->type = get_slice_type(ira->codegen, ptr_type);
1527815278 out_array_val = create_const_vals(1);
1527915279 out_array_val->special = ConstValSpecialStatic;
1528015280 out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel);
......@@ -15291,9 +15291,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1529115291 out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic;
1529215292 bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len);
1529315293 } else {
15294 result->value.type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown,
15294 result->value->type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown,
1529515295 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel);
15296
1529715296 out_array_val = create_const_vals(1);
1529815297 out_array_val->special = ConstValSpecialStatic;
1529915298 out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel);
......@@ -15345,34 +15344,34 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1534515344
1534615345static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) {
1534715346 IrInstruction *op1 = instruction->op1->child;
15348 if (type_is_invalid(op1->value.type))
15347 if (type_is_invalid(op1->value->type))
1534915348 return ira->codegen->invalid_instruction;
1535015349
1535115350 IrInstruction *op2 = instruction->op2->child;
15352 if (type_is_invalid(op2->value.type))
15351 if (type_is_invalid(op2->value->type))
1535315352 return ira->codegen->invalid_instruction;
1535415353
1535515354 bool want_ptr_to_array = false;
1535615355 ZigType *array_type;
1535715356 ZigValue *array_val;
15358 if (op1->value.type->id == ZigTypeIdArray) {
15359 array_type = op1->value.type;
15357 if (op1->value->type->id == ZigTypeIdArray) {
15358 array_type = op1->value->type;
1536015359 array_val = ir_resolve_const(ira, op1, UndefOk);
1536115360 if (array_val == nullptr)
1536215361 return ira->codegen->invalid_instruction;
15363 } else if (op1->value.type->id == ZigTypeIdPointer && op1->value.type->data.pointer.ptr_len == PtrLenSingle &&
15364 op1->value.type->data.pointer.child_type->id == ZigTypeIdArray)
15362 } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle &&
15363 op1->value->type->data.pointer.child_type->id == ZigTypeIdArray)
1536515364 {
15366 array_type = op1->value.type->data.pointer.child_type;
15365 array_type = op1->value->type->data.pointer.child_type;
1536715366 IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr);
15368 if (type_is_invalid(array_inst->value.type))
15367 if (type_is_invalid(array_inst->value->type))
1536915368 return ira->codegen->invalid_instruction;
1537015369 array_val = ir_resolve_const(ira, array_inst, UndefOk);
1537115370 if (array_val == nullptr)
1537215371 return ira->codegen->invalid_instruction;
1537315372 want_ptr_to_array = true;
1537415373 } else {
15375 ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name)));
15374 ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name)));
1537615375 return ira->codegen->invalid_instruction;
1537715376 }
1537815377
......@@ -15397,7 +15396,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1539715396 array_result = ir_const_undef(ira, &instruction->base, result_array_type);
1539815397 } else {
1539915398 array_result = ir_const(ira, &instruction->base, result_array_type);
15400 ZigValue *out_val = &array_result->value;
15399 ZigValue *out_val = array_result->value;
1540115400
1540215401 switch (type_has_one_possible_value(ira->codegen, result_array_type)) {
1540315402 case OnePossibleValueInvalid:
......@@ -15554,16 +15553,16 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1555415553 IrInstruction *var_ptr = decl_var_instruction->ptr->child;
1555515554 // if this is null, a compiler error happened and did not initialize the variable.
1555615555 // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation.
15557 if (var_ptr == nullptr || type_is_invalid(var_ptr->value.type)) {
15556 if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) {
1555815557 ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base);
1555915558 var->var_type = ira->codegen->builtin_types.entry_invalid;
1556015559 return ira->codegen->invalid_instruction;
1556115560 }
1556215561
1556315562 // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value.
15564 ir_assert(var_ptr->value.type->id == ZigTypeIdPointer, &decl_var_instruction->base);
15563 ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base);
1556515564
15566 ZigType *result_type = var_ptr->value.type->data.pointer.child_type;
15565 ZigType *result_type = var_ptr->value->type->data.pointer.child_type;
1556715566 if (type_is_invalid(result_type)) {
1556815567 result_type = ira->codegen->builtin_types.entry_invalid;
1556915568 } else if (result_type->id == ZigTypeIdUnreachable || result_type->id == ZigTypeIdOpaque) {
......@@ -15571,8 +15570,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1557115570 }
1557215571
1557315572 ZigValue *init_val = nullptr;
15574 if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
15575 init_val = const_ptr_pointee(ira, ira->codegen, &var_ptr->value, decl_var_instruction->base.source_node);
15573 if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
15574 init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.source_node);
1557615575 if (is_comptime_var) {
1557715576 if (var->gen_is_const) {
1557815577 var->const_value = init_val;
......@@ -15665,23 +15664,23 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1566515664 if (init_val != nullptr && value_is_comptime(init_val)) {
1566615665 // Resolve ConstPtrMutInfer
1566715666 if (var->gen_is_const) {
15668 var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
15667 var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeConst;
1566915668 } else if (is_comptime_var) {
15670 var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar;
15669 var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar;
1567115670 } else {
1567215671 // we need a runtime ptr but we have a comptime val.
1567315672 // since it's a comptime val there are no instructions for it.
1567415673 // we memcpy the init value here
1567515674 IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr);
15676 if (type_is_invalid(deref->value.type)) {
15675 if (type_is_invalid(deref->value->type)) {
1567715676 var->var_type = ira->codegen->builtin_types.entry_invalid;
1567815677 return ira->codegen->invalid_instruction;
1567915678 }
1568015679 // If this assertion trips, something is wrong with the IR instructions, because
1568115680 // we expected the above deref to return a constant value, but it created a runtime
1568215681 // instruction.
15683 assert(deref->value.special != ConstValSpecialRuntime);
15684 var_ptr->value.special = ConstValSpecialRuntime;
15682 assert(deref->value->special != ConstValSpecialRuntime);
15683 var_ptr->value->special = ConstValSpecialRuntime;
1568515684 ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false);
1568615685 }
1568715686
......@@ -15718,7 +15717,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1571815717 }
1571915718
1572015719 IrInstruction *target = instruction->target->child;
15721 if (type_is_invalid(target->value.type)) {
15720 if (type_is_invalid(target->value->type)) {
1572215721 return ira->codegen->invalid_instruction;
1572315722 }
1572415723
......@@ -15748,13 +15747,13 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1574815747 }
1574915748
1575015749 bool want_var_export = false;
15751 switch (target->value.type->id) {
15750 switch (target->value->type->id) {
1575215751 case ZigTypeIdInvalid:
1575315752 case ZigTypeIdUnreachable:
1575415753 zig_unreachable();
1575515754 case ZigTypeIdFn: {
15756 assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction);
15757 ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry;
15755 assert(target->value->data.x_ptr.special == ConstPtrSpecialFunction);
15756 ZigFn *fn_entry = target->value->data.x_ptr.data.fn.fn_entry;
1575815757 tld_fn->fn_entry = fn_entry;
1575915758 CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc;
1576015759 switch (cc) {
......@@ -15778,51 +15777,51 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1577815777 }
1577915778 } break;
1578015779 case ZigTypeIdStruct:
15781 if (is_slice(target->value.type)) {
15780 if (is_slice(target->value->type)) {
1578215781 ir_add_error(ira, target,
15783 buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value.type->name)));
15784 } else if (target->value.type->data.structure.layout != ContainerLayoutExtern) {
15782 buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name)));
15783 } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) {
1578515784 ErrorMsg *msg = ir_add_error(ira, target,
1578615785 buf_sprintf("exported struct value must be declared extern"));
15787 add_error_note(ira->codegen, msg, target->value.type->data.structure.decl_node, buf_sprintf("declared here"));
15786 add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here"));
1578815787 } else {
1578915788 want_var_export = true;
1579015789 }
1579115790 break;
1579215791 case ZigTypeIdUnion:
15793 if (target->value.type->data.unionation.layout != ContainerLayoutExtern) {
15792 if (target->value->type->data.unionation.layout != ContainerLayoutExtern) {
1579415793 ErrorMsg *msg = ir_add_error(ira, target,
1579515794 buf_sprintf("exported union value must be declared extern"));
15796 add_error_note(ira->codegen, msg, target->value.type->data.unionation.decl_node, buf_sprintf("declared here"));
15795 add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here"));
1579715796 } else {
1579815797 want_var_export = true;
1579915798 }
1580015799 break;
1580115800 case ZigTypeIdEnum:
15802 if (target->value.type->data.enumeration.layout != ContainerLayoutExtern) {
15801 if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) {
1580315802 ErrorMsg *msg = ir_add_error(ira, target,
1580415803 buf_sprintf("exported enum value must be declared extern"));
15805 add_error_note(ira->codegen, msg, target->value.type->data.enumeration.decl_node, buf_sprintf("declared here"));
15804 add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here"));
1580615805 } else {
1580715806 want_var_export = true;
1580815807 }
1580915808 break;
1581015809 case ZigTypeIdArray: {
1581115810 bool ok_type;
15812 if ((err = type_allowed_in_extern(ira->codegen, target->value.type->data.array.child_type, &ok_type)))
15811 if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type)))
1581315812 return ira->codegen->invalid_instruction;
1581415813
1581515814 if (!ok_type) {
1581615815 ir_add_error(ira, target,
1581715816 buf_sprintf("array element type '%s' not extern-compatible",
15818 buf_ptr(&target->value.type->data.array.child_type->name)));
15817 buf_ptr(&target->value->type->data.array.child_type->name)));
1581915818 } else {
1582015819 want_var_export = true;
1582115820 }
1582215821 break;
1582315822 }
1582415823 case ZigTypeIdMetaType: {
15825 ZigType *type_value = target->value.data.x_type;
15824 ZigType *type_value = target->value->data.x_type;
1582615825 switch (type_value->id) {
1582715826 case ZigTypeIdInvalid:
1582815827 zig_unreachable();
......@@ -15898,7 +15897,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1589815897 case ZigTypeIdErrorUnion:
1589915898 case ZigTypeIdErrorSet:
1590015899 case ZigTypeIdVector:
15901 zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name));
15900 zig_panic("TODO export const value of type %s", buf_ptr(&target->value->type->name));
1590215901 case ZigTypeIdBoundFn:
1590315902 case ZigTypeIdArgTuple:
1590415903 case ZigTypeIdOpaque:
......@@ -15906,7 +15905,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
1590615905 case ZigTypeIdFnFrame:
1590715906 case ZigTypeIdAnyFrame:
1590815907 ir_add_error(ira, target,
15909 buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name)));
15908 buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name)));
1591015909 break;
1591115910 }
1591215911
......@@ -15936,7 +15935,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
1593615935 ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
1593715936 if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {
1593815937 IrInstruction *result = ir_const(ira, &instruction->base, optional_type);
15939 ZigValue *out_val = &result->value;
15938 ZigValue *out_val = result->value;
1594015939 assert(get_codegen_ptr_type(optional_type) != nullptr);
1594115940 out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
1594215941 out_val->data.x_ptr.data.hard_coded_addr.addr = 0;
......@@ -15944,13 +15943,13 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
1594415943 }
1594515944 IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope,
1594615945 instruction->base.source_node, instruction->optional);
15947 new_instruction->value.type = optional_type;
15946 new_instruction->value->type = optional_type;
1594815947 return new_instruction;
1594915948 } else {
1595015949 assert(ira->codegen->have_err_ret_tracing);
1595115950 IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope,
1595215951 instruction->base.source_node, instruction->optional);
15953 new_instruction->value.type = ptr_to_stack_trace_type;
15952 new_instruction->value->type = ptr_to_stack_trace_type;
1595415953 return new_instruction;
1595515954 }
1595615955}
......@@ -15959,11 +15958,11 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira,
1595915958 IrInstructionErrorUnion *instruction)
1596015959{
1596115960 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type);
15962 result->value.special = ConstValSpecialLazy;
15961 result->value->special = ConstValSpecialLazy;
1596315962
1596415963 LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1);
1596515964 lazy_err_union_type->ira = ira;
15966 result->value.data.x_lazy = &lazy_err_union_type->base;
15965 result->value->data.x_lazy = &lazy_err_union_type->base;
1596715966 lazy_err_union_type->base.id = LazyValueIdErrUnionType;
1596815967
1596915968 lazy_err_union_type->err_set_type = instruction->err_set->child;
......@@ -15986,10 +15985,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in
1598615985 pointee->special = ConstValSpecialUndef;
1598715986
1598815987 IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint);
15989 result->base.value.special = ConstValSpecialStatic;
15990 result->base.value.data.x_ptr.special = ConstPtrSpecialRef;
15991 result->base.value.data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer;
15992 result->base.value.data.x_ptr.data.ref.pointee = pointee;
15988 result->base.value->special = ConstValSpecialStatic;
15989 result->base.value->data.x_ptr.special = ConstPtrSpecialRef;
15990 result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer;
15991 result->base.value->data.x_ptr.data.ref.pointee = pointee;
1599315992
1599415993 bool var_type_has_bits;
1599515994 if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits)))
......@@ -16004,10 +16003,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in
1600416003 return ira->codegen->invalid_instruction;
1600516004 }
1600616005 }
16007 assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid);
16006 assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid);
1600816007
1600916008 pointee->type = var_type;
16010 result->base.value.type = get_pointer_to_type_extra(ira->codegen, var_type, false, false,
16009 result->base.value->type = get_pointer_to_type_extra(ira->codegen, var_type, false, false,
1601116010 PtrLenSingle, align, 0, 0, false);
1601216011
1601316012 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
......@@ -16031,7 +16030,7 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspe
1603116030 case ResultLocIdCast:
1603216031 return nullptr;
1603316032 case ResultLocIdInstruction:
16034 return result_loc->source_instruction->child->value.type;
16033 return result_loc->source_instruction->child->value->type;
1603516034 case ResultLocIdReturn:
1603616035 return ira->explicit_return_type;
1603716036 case ResultLocIdPeer:
......@@ -16064,12 +16063,12 @@ static bool type_can_bit_cast(ZigType *t) {
1606416063
1606516064static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) {
1606616065 ZigValue *undef_child = create_const_vals(1);
16067 undef_child->type = ptr->value.type->data.pointer.child_type;
16066 undef_child->type = ptr->value->type->data.pointer.child_type;
1606816067 undef_child->special = ConstValSpecialUndef;
16069 ptr->value.special = ConstValSpecialStatic;
16070 ptr->value.data.x_ptr.mut = ConstPtrMutInfer;
16071 ptr->value.data.x_ptr.special = ConstPtrSpecialRef;
16072 ptr->value.data.x_ptr.data.ref.pointee = undef_child;
16068 ptr->value->special = ConstValSpecialStatic;
16069 ptr->value->data.x_ptr.mut = ConstPtrMutInfer;
16070 ptr->value->data.x_ptr.special = ConstPtrSpecialRef;
16071 ptr->value->data.x_ptr.data.ref.pointee = undef_child;
1607316072}
1607416073
1607516074static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out) {
......@@ -16105,7 +16104,7 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su
1610516104 ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime)
1610616105{
1610716106 IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, "");
16108 alloca_gen->base.value.type = get_pointer_to_type_extra(ira->codegen, value_type, false, false,
16107 alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false,
1610916108 PtrLenSingle, 0, 0, 0, false);
1611016109 set_up_result_loc_for_inferred_comptime(&alloca_gen->base);
1611116110 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
......@@ -16158,7 +16157,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1615816157 if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime))
1615916158 return ira->codegen->invalid_instruction;
1616016159 bool is_comptime = force_comptime || (value != nullptr &&
16161 value->value.special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const);
16160 value->value->special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const);
1616216161
1616316162 if (alloca_src->base.child == nullptr || is_comptime) {
1616416163 uint32_t align = 0;
......@@ -16167,8 +16166,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1616716166 }
1616816167 IrInstruction *alloca_gen;
1616916168 if (is_comptime && value != nullptr) {
16170 if (align > value->value.global_refs->align) {
16171 value->value.global_refs->align = align;
16169 if (align > value->value->global_refs->align) {
16170 value->value->global_refs->align = align;
1617216171 }
1617316172 alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false);
1617416173 } else {
......@@ -16191,7 +16190,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1619116190 }
1619216191 case ResultLocIdReturn: {
1619316192 if (!non_null_comptime) {
16194 bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime;
16193 bool is_comptime = value != nullptr && value->value->special != ConstValSpecialRuntime;
1619516194 if (is_comptime)
1619616195 return nullptr;
1619716196 }
......@@ -16222,8 +16221,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1622216221 value_type, value, force_runtime, non_null_comptime, true);
1622316222 result_peer->suspend_pos.basic_block_index = SIZE_MAX;
1622416223 result_peer->suspend_pos.instruction_index = SIZE_MAX;
16225 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
16226 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
16224 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) ||
16225 parent_result_loc->value->type->id == ZigTypeIdUnreachable)
1622716226 {
1622816227 return parent_result_loc;
1622916228 }
......@@ -16270,19 +16269,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1627016269
1627116270 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
1627216271 peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true);
16273 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
16274 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
16272 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) ||
16273 parent_result_loc->value->type->id == ZigTypeIdUnreachable)
1627516274 {
1627616275 return parent_result_loc;
1627716276 }
1627816277 // because is_comptime is false, we mark this a runtime pointer
16279 parent_result_loc->value.special = ConstValSpecialRuntime;
16278 parent_result_loc->value->special = ConstValSpecialRuntime;
1628016279 result_loc->written = true;
1628116280 result_loc->resolved_loc = parent_result_loc;
1628216281 return result_loc->resolved_loc;
1628316282 }
1628416283 case ResultLocIdCast: {
16285 if (value != nullptr && value->value.special != ConstValSpecialRuntime)
16284 if (value != nullptr && value->value->special != ConstValSpecialRuntime)
1628616285 return nullptr;
1628716286 ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc);
1628816287 ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child);
......@@ -16313,19 +16312,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1631316312 casted_value = nullptr;
1631416313 }
1631516314
16316 if (casted_value != nullptr && type_is_invalid(casted_value->value.type)) {
16315 if (casted_value != nullptr && type_is_invalid(casted_value->value->type)) {
1631716316 return casted_value;
1631816317 }
1631916318
1632016319 bool old_parent_result_loc_written = result_cast->parent->written;
1632116320 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent,
1632216321 dest_type, casted_value, force_runtime, non_null_comptime, true);
16323 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
16324 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
16322 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) ||
16323 parent_result_loc->value->type->id == ZigTypeIdUnreachable)
1632516324 {
1632616325 return parent_result_loc;
1632716326 }
16328 ZigType *parent_ptr_type = parent_result_loc->value.type;
16327 ZigType *parent_ptr_type = parent_result_loc->value->type;
1632916328 assert(parent_ptr_type->id == ZigTypeIdPointer);
1633016329 if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type,
1633116330 ResolveStatusAlignmentKnown)))
......@@ -16358,7 +16357,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1635816357 {
1635916358 // we also need to check that this cast is OK.
1636016359 ConstCastOnly const_cast_result = types_match_const_cast_only(ira,
16361 parent_result_loc->value.type, ptr_type,
16360 parent_result_loc->value->type, ptr_type,
1636216361 result_cast->base.source_instruction->source_node, false);
1636316362 if (const_cast_result.id == ConstCastResultIdInvalid)
1636416363 return ira->codegen->invalid_instruction;
......@@ -16413,18 +16412,18 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
1641316412 bitcasted_value = nullptr;
1641416413 }
1641516414
16416 if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value.type)) {
16415 if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value->type)) {
1641716416 return bitcasted_value;
1641816417 }
1641916418
1642016419 IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent,
1642116420 dest_type, bitcasted_value, force_runtime, non_null_comptime, true);
16422 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) ||
16423 parent_result_loc->value.type->id == ZigTypeIdUnreachable)
16421 if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) ||
16422 parent_result_loc->value->type->id == ZigTypeIdUnreachable)
1642416423 {
1642516424 return parent_result_loc;
1642616425 }
16427 ZigType *parent_ptr_type = parent_result_loc->value.type;
16426 ZigType *parent_ptr_type = parent_result_loc->value->type;
1642816427 assert(parent_ptr_type->id == ZigTypeIdPointer);
1642916428 if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type,
1643016429 ResolveStatusAlignmentKnown)))
......@@ -16454,24 +16453,24 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1645416453{
1645516454 if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction &&
1645616455 instr_is_comptime(result_loc_pass1->source_instruction) &&
16457 result_loc_pass1->source_instruction->value.type->id == ZigTypeIdPointer &&
16458 result_loc_pass1->source_instruction->value.data.x_ptr.special == ConstPtrSpecialDiscard)
16456 result_loc_pass1->source_instruction->value->type->id == ZigTypeIdPointer &&
16457 result_loc_pass1->source_instruction->value->data.x_ptr.special == ConstPtrSpecialDiscard)
1645916458 {
1646016459 result_loc_pass1 = no_result_loc();
1646116460 }
1646216461 IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type,
1646316462 value, force_runtime, non_null_comptime);
16464 if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value.type)))
16463 if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type)))
1646516464 return result_loc;
1646616465
1646716466 if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) &&
16468 result_loc_pass1->written && result_loc->value.data.x_ptr.mut == ConstPtrMutInfer)
16467 result_loc_pass1->written && result_loc->value->data.x_ptr.mut == ConstPtrMutInfer)
1646916468 {
16470 result_loc->value.special = ConstValSpecialRuntime;
16469 result_loc->value->special = ConstValSpecialRuntime;
1647116470 }
1647216471
16473 ir_assert(result_loc->value.type->id == ZigTypeIdPointer, suspend_source_instr);
16474 ZigType *actual_elem_type = result_loc->value.type->data.pointer.child_type;
16472 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr);
16473 ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type;
1647516474 if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional &&
1647616475 value_type->id != ZigTypeIdNull)
1647716476 {
......@@ -16544,18 +16543,18 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira,
1654416543 result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(),
1654516544 implicit_elem_type, nullptr, false, true, true);
1654616545 if (result_loc != nullptr &&
16547 (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
16546 (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)))
1654816547 {
1654916548 return result_loc;
1655016549 }
16551 result_loc->value.special = ConstValSpecialRuntime;
16550 result_loc->value->special = ConstValSpecialRuntime;
1655216551 return result_loc;
1655316552 }
1655416553
1655516554 IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type);
16556 result->value.special = ConstValSpecialUndef;
16555 result->value->special = ConstValSpecialUndef;
1655716556 IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false);
16558 ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar;
16557 ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar;
1655916558 return ptr;
1656016559}
1656116560
......@@ -16605,9 +16604,9 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal
1660516604{
1660616605 ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base);
1660716606 IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child;
16608 if (type_is_invalid(ret_ptr_uncasted->value.type))
16607 if (type_is_invalid(ret_ptr_uncasted->value->type))
1660916608 return ira->codegen->invalid_instruction;
16610 if (ret_ptr_uncasted->value.type->id == ZigTypeIdVoid) {
16609 if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) {
1661116610 // Result location will be inside the async frame.
1661216611 return nullptr;
1661316612 }
......@@ -16632,7 +16631,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
1663216631 if (casted_new_stack != nullptr) {
1663316632 ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type;
1663416633 IrInstruction *ret_ptr = get_async_call_result_loc(ira, call_instruction, fn_ret_type);
16635 if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value.type))
16634 if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type))
1663616635 return ira->codegen->invalid_instruction;
1663716636
1663816637 ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type);
......@@ -16645,11 +16644,11 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc
1664516644 ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry);
1664616645 IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
1664716646 frame_type, nullptr, true, true, false);
16648 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
16647 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
1664916648 return result_loc;
1665016649 }
1665116650 result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false));
16652 if (type_is_invalid(result_loc->value.type))
16651 if (type_is_invalid(result_loc->value->type))
1665316652 return ira->codegen->invalid_instruction;
1665416653 return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count,
1665516654 casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack,
......@@ -16670,7 +16669,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
1667016669 return false;
1667116670
1667216671 casted_arg = ir_implicit_cast(ira, arg, param_type);
16673 if (type_is_invalid(casted_arg->value.type))
16672 if (type_is_invalid(casted_arg->value->type))
1667416673 return false;
1667516674 } else {
1667616675 casted_arg = arg;
......@@ -16710,7 +16709,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1671016709 return false;
1671116710
1671216711 casted_arg = ir_implicit_cast(ira, arg, param_type);
16713 if (type_is_invalid(casted_arg->value.type))
16712 if (type_is_invalid(casted_arg->value->type))
1671416713 return false;
1671516714 } else {
1671616715 arg_part_of_generic_id = true;
......@@ -16719,7 +16718,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1671916718 }
1672016719
1672116720 bool comptime_arg = param_decl_node->data.param_decl.is_comptime ||
16722 casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat;
16721 casted_arg->value->type->id == ZigTypeIdComptimeInt || casted_arg->value->type->id == ZigTypeIdComptimeFloat;
1672316722
1672416723 ZigValue *arg_val;
1672516724
......@@ -16729,7 +16728,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1672916728 if (!arg_val)
1673016729 return false;
1673116730 } else {
16732 arg_val = create_const_runtime(casted_arg->value.type);
16731 arg_val = create_const_runtime(casted_arg->value->type);
1673316732 }
1673416733 if (arg_part_of_generic_id) {
1673516734 copy_const_val(&generic_id->params[generic_id->param_count], arg_val, true);
......@@ -16745,8 +16744,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1674516744 var->shadowable = !comptime_arg;
1674616745
1674716746 *next_proto_i += 1;
16748 } else if (casted_arg->value.type->id == ZigTypeIdComptimeInt ||
16749 casted_arg->value.type->id == ZigTypeIdComptimeFloat)
16747 } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt ||
16748 casted_arg->value->type->id == ZigTypeIdComptimeFloat)
1675016749 {
1675116750 ir_add_error(ira, casted_arg,
1675216751 buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557"));
......@@ -16754,10 +16753,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1675416753 }
1675516754
1675616755 if (!comptime_arg) {
16757 switch (type_requires_comptime(ira->codegen, casted_arg->value.type)) {
16756 switch (type_requires_comptime(ira->codegen, casted_arg->value->type)) {
1675816757 case ReqCompTimeYes:
1675916758 ir_add_error(ira, casted_arg,
16760 buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value.type->name)));
16759 buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value->type->name)));
1676116760 return false;
1676216761 case ReqCompTimeInvalid:
1676316762 return false;
......@@ -16767,7 +16766,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1676716766
1676816767 casted_args[fn_type_id->param_count] = casted_arg;
1676916768 FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count];
16770 param_info->type = casted_arg->value.type;
16769 param_info->type = casted_arg->value->type;
1677116770 param_info->is_noalias = param_decl_node->data.param_decl.is_noalias;
1677216771 impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node;
1677316772 fn_type_id->param_count += 1;
......@@ -16813,7 +16812,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1681316812
1681416813 IrInstruction *result = ir_build_var_ptr(&ira->new_irb,
1681516814 instruction->scope, instruction->source_node, var);
16816 result->value.type = get_pointer_to_type_extra(ira->codegen, var->var_type,
16815 result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type,
1681716816 var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false);
1681816817
1681916818 if (linkage_makes_it_runtime)
......@@ -16846,10 +16845,10 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1684616845 assert(!comptime_var_mem);
1684716846 ptr_mut = ConstPtrMutRuntimeVar;
1684816847 }
16849 result->value.special = ConstValSpecialStatic;
16850 result->value.data.x_ptr.mut = ptr_mut;
16851 result->value.data.x_ptr.special = ConstPtrSpecialRef;
16852 result->value.data.x_ptr.data.ref.pointee = mem_slot;
16848 result->value->special = ConstValSpecialStatic;
16849 result->value->data.x_ptr.mut = ptr_mut;
16850 result->value->data.x_ptr.special = ConstPtrSpecialRef;
16851 result->value->data.x_ptr.data.ref.pointee = mem_slot;
1685316852 return result;
1685416853 }
1685516854 }
......@@ -16859,7 +16858,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1685916858no_mem_slot:
1686016859
1686116860 bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr);
16862 result->value.data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack;
16861 result->value->data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack;
1686316862
1686416863 return result;
1686516864}
......@@ -16881,11 +16880,11 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins
1688116880static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr,
1688216881 IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const)
1688316882{
16884 assert(ptr->value.type->id == ZigTypeIdPointer);
16883 assert(ptr->value->type->id == ZigTypeIdPointer);
1688516884
16886 if (ptr->value.data.x_ptr.special == ConstPtrSpecialDiscard) {
16887 if (uncasted_value->value.type->id == ZigTypeIdErrorUnion ||
16888 uncasted_value->value.type->id == ZigTypeIdErrorSet)
16885 if (ptr->value->data.x_ptr.special == ConstPtrSpecialDiscard) {
16886 if (uncasted_value->value->type->id == ZigTypeIdErrorUnion ||
16887 uncasted_value->value->type->id == ZigTypeIdErrorSet)
1688916888 {
1689016889 ir_add_error(ira, source_instr, buf_sprintf("error is discarded"));
1689116890 return ira->codegen->invalid_instruction;
......@@ -16893,7 +16892,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1689316892 return ir_const_void(ira, source_instr);
1689416893 }
1689516894
16896 InferredStructField *isf = ptr->value.type->data.pointer.inferred_struct_field;
16895 InferredStructField *isf = ptr->value->type->data.pointer.inferred_struct_field;
1689716896 if (allow_write_through_const && isf != nullptr) {
1689816897 // Now it's time to add the field to the struct type.
1689916898 uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count;
......@@ -16904,7 +16903,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1690416903
1690516904 TypeStructField *field = isf->inferred_struct_type->data.structure.fields[old_field_count];
1690616905 field->name = isf->field_name;
16907 field->type_entry = uncasted_value->value.type;
16906 field->type_entry = uncasted_value->value->type;
1690816907 field->type_val = create_const_type(ira->codegen, field->type_entry);
1690916908 field->src_index = old_field_count;
1691016909 field->decl_node = uncasted_value->source_node;
......@@ -16913,12 +16912,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1691316912 IrInstruction *casted_ptr;
1691416913 if (instr_is_comptime(ptr)) {
1691516914 casted_ptr = ir_const(ira, source_instr, struct_ptr_type);
16916 copy_const_val(&casted_ptr->value, &ptr->value, false);
16917 casted_ptr->value.type = struct_ptr_type;
16915 copy_const_val(casted_ptr->value, ptr->value, false);
16916 casted_ptr->value->type = struct_ptr_type;
1691816917 } else {
1691916918 casted_ptr = ir_build_cast(&ira->new_irb, source_instr->scope,
1692016919 source_instr->source_node, struct_ptr_type, ptr, CastOpNoop);
16921 casted_ptr->value.type = struct_ptr_type;
16920 casted_ptr->value->type = struct_ptr_type;
1692216921 }
1692316922 if (instr_is_comptime(casted_ptr)) {
1692416923 ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad);
......@@ -16944,12 +16943,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1694416943 isf->inferred_struct_type, true);
1694516944 }
1694616945
16947 if (ptr->value.type->data.pointer.is_const && !allow_write_through_const) {
16946 if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) {
1694816947 ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant"));
1694916948 return ira->codegen->invalid_instruction;
1695016949 }
1695116950
16952 ZigType *child_type = ptr->value.type->data.pointer.child_type;
16951 ZigType *child_type = ptr->value->type->data.pointer.child_type;
1695316952 IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type);
1695416953 if (value == ira->codegen->invalid_instruction)
1695516954 return ira->codegen->invalid_instruction;
......@@ -16963,16 +16962,16 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1696316962 break;
1696416963 }
1696516964
16966 if (instr_is_comptime(ptr) && ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) {
16967 if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst) {
16965 if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) {
16966 if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) {
1696816967 ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant"));
1696916968 return ira->codegen->invalid_instruction;
1697016969 }
16971 if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar ||
16972 ptr->value.data.x_ptr.mut == ConstPtrMutInfer)
16970 if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar ||
16971 ptr->value->data.x_ptr.mut == ConstPtrMutInfer)
1697316972 {
1697416973 if (instr_is_comptime(value)) {
16975 ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, &ptr->value, source_instr->source_node);
16974 ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node);
1697616975 if (dest_val == nullptr)
1697716976 return ira->codegen->invalid_instruction;
1697816977 if (dest_val->special != ConstValSpecialRuntime) {
......@@ -16982,9 +16981,9 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1698216981 // * "string literal used as comptime slice is memoized"
1698316982 // * "comptime modification of const struct field" - except modified to avoid
1698416983 // ConstPtrMutComptimeVar, thus defeating the logic below.
16985 bool same_global_refs = ptr->value.data.x_ptr.mut != ConstPtrMutComptimeVar;
16986 copy_const_val(dest_val, &value->value, same_global_refs);
16987 if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar &&
16984 bool same_global_refs = ptr->value->data.x_ptr.mut != ConstPtrMutComptimeVar;
16985 copy_const_val(dest_val, value->value, same_global_refs);
16986 if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar &&
1698816987 !ira->new_irb.current_basic_block->must_be_comptime_source_instr)
1698916988 {
1699016989 ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr;
......@@ -16992,12 +16991,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1699216991 return ir_const_void(ira, source_instr);
1699316992 }
1699416993 }
16995 if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) {
16996 ptr->value.special = ConstValSpecialRuntime;
16994 if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) {
16995 ptr->value->special = ConstValSpecialRuntime;
1699716996 } else {
1699816997 ir_add_error(ira, source_instr,
1699916998 buf_sprintf("cannot store runtime value in compile time variable"));
17000 ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, &ptr->value);
16999 ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value);
1700117000 dest_val->type = ira->codegen->builtin_types.entry_invalid;
1700217001
1700317002 return ira->codegen->invalid_instruction;
......@@ -17009,7 +17008,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1700917008 case ReqCompTimeInvalid:
1701017009 return ira->codegen->invalid_instruction;
1701117010 case ReqCompTimeYes:
17012 switch (type_has_one_possible_value(ira->codegen, ptr->value.type)) {
17011 switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) {
1701317012 case OnePossibleValueInvalid:
1701417013 return ira->codegen->invalid_instruction;
1701517014 case OnePossibleValueNo:
......@@ -17025,7 +17024,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1702517024 }
1702617025
1702717026 if (instr_is_comptime(value)) {
17028 mark_comptime_value_escape(ira, source_instr, &value->value);
17027 mark_comptime_value_escape(ira, source_instr, value->value);
1702917028 }
1703017029
1703117030 // If this is a store to a pointer with a runtime-known vector index,
......@@ -17034,7 +17033,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1703417033 // explaining why it is impossible for this store to work. Which is that
1703517034 // the pointer address is of the vector; without the element index being known
1703617035 // we cannot properly perform the insertion.
17037 if (ptr->value.type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) {
17036 if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) {
1703817037 if (ptr->id == IrInstructionIdElemPtr) {
1703917038 IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr;
1704017039 return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr,
......@@ -17042,7 +17041,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1704217041 }
1704317042 ir_add_error(ira, ptr,
1704417043 buf_sprintf("unable to determine vector element index of type '%s'",
17045 buf_ptr(&ptr->value.type->name)));
17044 buf_ptr(&ptr->value->type->name)));
1704617045 return ira->codegen->invalid_instruction;
1704717046 }
1704817047
......@@ -17058,12 +17057,12 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall
1705817057 return nullptr;
1705917058
1706017059 IrInstruction *new_stack = call_instruction->new_stack->child;
17061 if (type_is_invalid(new_stack->value.type))
17060 if (type_is_invalid(new_stack->value->type))
1706217061 return ira->codegen->invalid_instruction;
1706317062
1706417063 if (call_instruction->is_async_call_builtin &&
17065 fn_entry != nullptr && new_stack->value.type->id == ZigTypeIdPointer &&
17066 new_stack->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame)
17064 fn_entry != nullptr && new_stack->value->type->id == ZigTypeIdPointer &&
17065 new_stack->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
1706717066 {
1706817067 ZigType *needed_frame_type = get_pointer_to_type(ira->codegen,
1706917068 get_fn_frame_type(ira->codegen, fn_entry), false);
......@@ -17097,7 +17096,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1709717096
1709817097 size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0;
1709917098 for (size_t i = 0; i < call_instruction->arg_count; i += 1) {
17100 ZigValue *arg_tuple_value = &call_instruction->args[i]->child->value;
17099 ZigValue *arg_tuple_value = call_instruction->args[i]->child->value;
1710117100 if (arg_tuple_value->type->id == ZigTypeIdArgTuple) {
1710217101 call_param_count -= 1;
1710317102 call_param_count += arg_tuple_value->data.x_arg_tuple.end_index -
......@@ -17152,7 +17151,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1715217151
1715317152 size_t next_proto_i = 0;
1715417153 if (first_arg_ptr) {
17155 assert(first_arg_ptr->value.type->id == ZigTypeIdPointer);
17154 assert(first_arg_ptr->value->type->id == ZigTypeIdPointer);
1715617155
1715717156 bool first_arg_known_bare = false;
1715817157 if (fn_type_id->next_param_index >= 1) {
......@@ -17163,11 +17162,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1716317162 }
1716417163
1716517164 IrInstruction *first_arg;
17166 if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) {
17165 if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) {
1716717166 first_arg = first_arg_ptr;
1716817167 } else {
1716917168 first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr);
17170 if (type_is_invalid(first_arg->value.type))
17169 if (type_is_invalid(first_arg->value->type))
1717117170 return ira->codegen->invalid_instruction;
1717217171 }
1717317172
......@@ -17184,7 +17183,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1718417183
1718517184 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
1718617185 IrInstruction *old_arg = call_instruction->args[call_i]->child;
17187 if (type_is_invalid(old_arg->value.type))
17186 if (type_is_invalid(old_arg->value->type))
1718817187 return ira->codegen->invalid_instruction;
1718917188
1719017189 if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i))
......@@ -17250,8 +17249,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1725017249 }
1725117250
1725217251 IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type);
17253 copy_const_val(&new_instruction->value, result, true);
17254 new_instruction->value.type = return_type;
17252 copy_const_val(new_instruction->value, result, true);
17253 new_instruction->value->type = return_type;
1725517254 return ir_finish_anal(ira, new_instruction);
1725617255 }
1725717256
......@@ -17266,11 +17265,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1726617265 size_t new_fn_arg_count = first_arg_1_or_0;
1726717266 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
1726817267 IrInstruction *arg = call_instruction->args[call_i]->child;
17269 if (type_is_invalid(arg->value.type))
17268 if (type_is_invalid(arg->value->type))
1727017269 return ira->codegen->invalid_instruction;
1727117270
17272 if (arg->value.type->id == ZigTypeIdArgTuple) {
17273 new_fn_arg_count += arg->value.data.x_arg_tuple.end_index - arg->value.data.x_arg_tuple.start_index;
17271 if (arg->value->type->id == ZigTypeIdArgTuple) {
17272 new_fn_arg_count += arg->value->data.x_arg_tuple.end_index - arg->value->data.x_arg_tuple.start_index;
1727417273 } else {
1727517274 new_fn_arg_count += 1;
1727617275 }
......@@ -17299,7 +17298,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1729917298 size_t next_proto_i = 0;
1730017299
1730117300 if (first_arg_ptr) {
17302 assert(first_arg_ptr->value.type->id == ZigTypeIdPointer);
17301 assert(first_arg_ptr->value->type->id == ZigTypeIdPointer);
1730317302
1730417303 bool first_arg_known_bare = false;
1730517304 if (fn_type_id->next_param_index >= 1) {
......@@ -17310,11 +17309,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1731017309 }
1731117310
1731217311 IrInstruction *first_arg;
17313 if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) {
17312 if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) {
1731417313 first_arg = first_arg_ptr;
1731517314 } else {
1731617315 first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr);
17317 if (type_is_invalid(first_arg->value.type))
17316 if (type_is_invalid(first_arg->value->type))
1731817317 return ira->codegen->invalid_instruction;
1731917318 }
1732017319
......@@ -17332,12 +17331,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1733217331 assert(parent_fn_entry);
1733317332 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
1733417333 IrInstruction *arg = call_instruction->args[call_i]->child;
17335 if (type_is_invalid(arg->value.type))
17334 if (type_is_invalid(arg->value->type))
1733617335 return ira->codegen->invalid_instruction;
1733717336
17338 if (arg->value.type->id == ZigTypeIdArgTuple) {
17339 for (size_t arg_tuple_i = arg->value.data.x_arg_tuple.start_index;
17340 arg_tuple_i < arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1)
17337 if (arg->value->type->id == ZigTypeIdArgTuple) {
17338 for (size_t arg_tuple_i = arg->value->data.x_arg_tuple.start_index;
17339 arg_tuple_i < arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1)
1734117340 {
1734217341 AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i);
1734317342 assert(param_decl_node->type == NodeTypeParamDecl);
......@@ -17354,11 +17353,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1735417353 return ira->codegen->invalid_instruction;
1735517354 }
1735617355 IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var);
17357 if (type_is_invalid(arg_var_ptr_inst->value.type))
17356 if (type_is_invalid(arg_var_ptr_inst->value->type))
1735817357 return ira->codegen->invalid_instruction;
1735917358
1736017359 IrInstruction *arg_tuple_arg = ir_get_deref(ira, arg, arg_var_ptr_inst, nullptr);
17361 if (type_is_invalid(arg_tuple_arg->value.type))
17360 if (type_is_invalid(arg_tuple_arg->value->type))
1736217361 return ira->codegen->invalid_instruction;
1736317362
1736417363 if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg_tuple_arg, &impl_fn->child_scope,
......@@ -17407,7 +17406,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1740717406 nullptr, UndefBad);
1740817407 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
1740917408 impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr);
17410 copy_const_val(&const_instruction->base.value, align_result, true);
17409 copy_const_val(const_instruction->base.value, align_result, true);
1741117410
1741217411 uint32_t align_bytes = 0;
1741317412 ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes);
......@@ -17468,7 +17467,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1746817467 }
1746917468
1747017469 IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, impl_fn);
17471 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type))
17470 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type))
1747217471 return ira->codegen->invalid_instruction;
1747317472
1747417473 size_t impl_param_count = impl_fn_type_id->param_count;
......@@ -17483,17 +17482,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1748317482 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
1748417483 impl_fn_type_id->return_type, nullptr, true, true, false);
1748517484 if (result_loc != nullptr) {
17486 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
17485 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
1748717486 return result_loc;
1748817487 }
17489 if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) {
17488 if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) {
1749017489 ir_reset_result(call_instruction->result_loc);
1749117490 result_loc = nullptr;
1749217491 }
1749317492 }
1749417493 } else if (call_instruction->is_async_call_builtin) {
1749517494 result_loc = get_async_call_result_loc(ira, call_instruction, impl_fn_type_id->return_type);
17496 if (result_loc != nullptr && type_is_invalid(result_loc->value.type))
17495 if (result_loc != nullptr && type_is_invalid(result_loc->value->type))
1749717496 return ira->codegen->invalid_instruction;
1749817497 } else {
1749917498 result_loc = nullptr;
......@@ -17530,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1753017529 IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count);
1753117530 size_t next_arg_index = 0;
1753217531 if (first_arg_ptr) {
17533 assert(first_arg_ptr->value.type->id == ZigTypeIdPointer);
17532 assert(first_arg_ptr->value->type->id == ZigTypeIdPointer);
1753417533
1753517534 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
1753617535 if (type_is_invalid(param_type))
......@@ -17538,17 +17537,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1753817537
1753917538 IrInstruction *first_arg;
1754017539 if (param_type->id == ZigTypeIdPointer &&
17541 handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type))
17540 handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type))
1754217541 {
1754317542 first_arg = first_arg_ptr;
1754417543 } else {
1754517544 first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr);
17546 if (type_is_invalid(first_arg->value.type))
17545 if (type_is_invalid(first_arg->value->type))
1754717546 return ira->codegen->invalid_instruction;
1754817547 }
1754917548
1755017549 IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type);
17551 if (type_is_invalid(casted_arg->value.type))
17550 if (type_is_invalid(casted_arg->value->type))
1755217551 return ira->codegen->invalid_instruction;
1755317552
1755417553 casted_args[next_arg_index] = casted_arg;
......@@ -17556,12 +17555,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1755617555 }
1755717556 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
1755817557 IrInstruction *old_arg = call_instruction->args[call_i]->child;
17559 if (type_is_invalid(old_arg->value.type))
17558 if (type_is_invalid(old_arg->value->type))
1756017559 return ira->codegen->invalid_instruction;
1756117560
17562 if (old_arg->value.type->id == ZigTypeIdArgTuple) {
17563 for (size_t arg_tuple_i = old_arg->value.data.x_arg_tuple.start_index;
17564 arg_tuple_i < old_arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1)
17561 if (old_arg->value->type->id == ZigTypeIdArgTuple) {
17562 for (size_t arg_tuple_i = old_arg->value->data.x_arg_tuple.start_index;
17563 arg_tuple_i < old_arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1)
1756517564 {
1756617565 ZigVar *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i);
1756717566 if (arg_var == nullptr) {
......@@ -17570,11 +17569,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1757017569 return ira->codegen->invalid_instruction;
1757117570 }
1757217571 IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, old_arg, arg_var);
17573 if (type_is_invalid(arg_var_ptr_inst->value.type))
17572 if (type_is_invalid(arg_var_ptr_inst->value->type))
1757417573 return ira->codegen->invalid_instruction;
1757517574
1757617575 IrInstruction *arg_tuple_arg = ir_get_deref(ira, old_arg, arg_var_ptr_inst, nullptr);
17577 if (type_is_invalid(arg_tuple_arg->value.type))
17576 if (type_is_invalid(arg_tuple_arg->value->type))
1757817577 return ira->codegen->invalid_instruction;
1757917578
1758017579 IrInstruction *casted_arg;
......@@ -17583,7 +17582,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1758317582 if (type_is_invalid(param_type))
1758417583 return ira->codegen->invalid_instruction;
1758517584 casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type);
17586 if (type_is_invalid(casted_arg->value.type))
17585 if (type_is_invalid(casted_arg->value->type))
1758717586 return ira->codegen->invalid_instruction;
1758817587 } else {
1758917588 casted_arg = arg_tuple_arg;
......@@ -17599,7 +17598,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1759917598 if (type_is_invalid(param_type))
1760017599 return ira->codegen->invalid_instruction;
1760117600 casted_arg = ir_implicit_cast(ira, old_arg, param_type);
17602 if (type_is_invalid(casted_arg->value.type))
17601 if (type_is_invalid(casted_arg->value->type))
1760317602 return ira->codegen->invalid_instruction;
1760417603 } else {
1760517604 casted_arg = old_arg;
......@@ -17623,7 +17622,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1762317622 }
1762417623
1762517624 IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, fn_entry);
17626 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type))
17625 if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type))
1762717626 return ira->codegen->invalid_instruction;
1762817627
1762917628 if (call_instruction->modifier == CallModifierAsync) {
......@@ -17645,17 +17644,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1764517644 result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
1764617645 return_type, nullptr, true, true, false);
1764717646 if (result_loc != nullptr) {
17648 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
17647 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
1764917648 return result_loc;
1765017649 }
17651 if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) {
17650 if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) {
1765217651 ir_reset_result(call_instruction->result_loc);
1765317652 result_loc = nullptr;
1765417653 }
1765517654 }
1765617655 } else if (call_instruction->is_async_call_builtin) {
1765717656 result_loc = get_async_call_result_loc(ira, call_instruction, return_type);
17658 if (result_loc != nullptr && type_is_invalid(result_loc->value.type))
17657 if (result_loc != nullptr && type_is_invalid(result_loc->value->type))
1765917658 return ira->codegen->invalid_instruction;
1766017659 } else {
1766117660 result_loc = nullptr;
......@@ -17672,14 +17671,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1767217671
1767317672static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) {
1767417673 IrInstruction *fn_ref = call_instruction->fn_ref->child;
17675 if (type_is_invalid(fn_ref->value.type))
17674 if (type_is_invalid(fn_ref->value->type))
1767617675 return ira->codegen->invalid_instruction;
1767717676
1767817677 bool is_comptime = call_instruction->is_comptime ||
1767917678 ir_should_inline(ira->new_irb.exec, call_instruction->base.scope);
1768017679
1768117680 if (is_comptime || instr_is_comptime(fn_ref)) {
17682 if (fn_ref->value.type->id == ZigTypeIdMetaType) {
17681 if (fn_ref->value->type->id == ZigTypeIdMetaType) {
1768317682 ZigType *ty = ir_resolve_type(ira, fn_ref);
1768417683 if (ty == nullptr)
1768517684 return ira->codegen->invalid_instruction;
......@@ -17688,30 +17687,30 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC
1768817687 add_error_note(ira->codegen, msg, call_instruction->base.source_node,
1768917688 buf_sprintf("use @as builtin for type coercion"));
1769017689 return ira->codegen->invalid_instruction;
17691 } else if (fn_ref->value.type->id == ZigTypeIdFn) {
17690 } else if (fn_ref->value->type->id == ZigTypeIdFn) {
1769217691 ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref);
17693 ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value.type;
17692 ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type;
1769417693 return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type,
1769517694 fn_ref, nullptr, is_comptime, call_instruction->fn_inline);
17696 } else if (fn_ref->value.type->id == ZigTypeIdBoundFn) {
17697 assert(fn_ref->value.special == ConstValSpecialStatic);
17698 ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn;
17699 IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg;
17695 } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) {
17696 assert(fn_ref->value->special == ConstValSpecialStatic);
17697 ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn;
17698 IrInstruction *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg;
1770017699 return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry,
1770117700 fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline);
1770217701 } else {
1770317702 ir_add_error_node(ira, fn_ref->source_node,
17704 buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name)));
17703 buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name)));
1770517704 return ira->codegen->invalid_instruction;
1770617705 }
1770717706 }
1770817707
17709 if (fn_ref->value.type->id == ZigTypeIdFn) {
17710 return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type,
17708 if (fn_ref->value->type->id == ZigTypeIdFn) {
17709 return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value->type,
1771117710 fn_ref, nullptr, false, call_instruction->fn_inline);
1771217711 } else {
1771317712 ir_add_error_node(ira, fn_ref->source_node,
17714 buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name)));
17713 buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name)));
1771517714 return ira->codegen->invalid_instruction;
1771617715 }
1771717716}
......@@ -17803,11 +17802,11 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
1780317802
1780417803static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) {
1780517804 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type);
17806 result->value.special = ConstValSpecialLazy;
17805 result->value->special = ConstValSpecialLazy;
1780717806
1780817807 LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1);
1780917808 lazy_opt_type->ira = ira;
17810 result->value.data.x_lazy = &lazy_opt_type->base;
17809 result->value->data.x_lazy = &lazy_opt_type->base;
1781117810 lazy_opt_type->base.id = LazyValueIdOptType;
1781217811
1781317812 lazy_opt_type->payload_type = instruction->value->child;
......@@ -17854,7 +17853,7 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i
1785417853
1785517854static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) {
1785617855 IrInstruction *value = instruction->value->child;
17857 ZigType *expr_type = value->value.type;
17856 ZigType *expr_type = value->value->type;
1785817857 if (type_is_invalid(expr_type))
1785917858 return ira->codegen->invalid_instruction;
1786017859
......@@ -17877,7 +17876,7 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins
1787717876 return ira->codegen->invalid_instruction;
1787817877
1787917878 IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type);
17880 ZigValue *out_val = &result_instruction->value;
17879 ZigValue *out_val = result_instruction->value;
1788117880 if (expr_type->id == ZigTypeIdVector) {
1788217881 expand_undef_array(ira->codegen, operand_val);
1788317882 out_val->special = ConstValSpecialUndef;
......@@ -17911,13 +17910,13 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins
1791117910 IrInstruction *result = ir_build_un_op(&ira->new_irb,
1791217911 instruction->base.scope, instruction->base.source_node,
1791317912 instruction->op_id, value);
17914 result->value.type = expr_type;
17913 result->value->type = expr_type;
1791517914 return result;
1791617915}
1791717916
1791817917static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) {
1791917918 IrInstruction *value = instruction->value->child;
17920 ZigType *expr_type = value->value.type;
17919 ZigType *expr_type = value->value->type;
1792117920 if (type_is_invalid(expr_type))
1792217921 return ira->codegen->invalid_instruction;
1792317922
......@@ -17928,14 +17927,14 @@ static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *inst
1792817927 return ira->codegen->invalid_instruction;
1792917928
1793017929 IrInstruction *result = ir_const(ira, &instruction->base, expr_type);
17931 bigint_not(&result->value.data.x_bigint, &target_const_val->data.x_bigint,
17930 bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint,
1793217931 expr_type->data.integral.bit_count, expr_type->data.integral.is_signed);
1793317932 return result;
1793417933 }
1793517934
1793617935 IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope,
1793717936 instruction->base.source_node, IrUnOpBinNot, value);
17938 result->value.type = expr_type;
17937 result->value->type = expr_type;
1793917938 return result;
1794017939 }
1794117940
......@@ -17956,9 +17955,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction
1795617955 return ir_analyze_negation(ira, instruction);
1795717956 case IrUnOpDereference: {
1795817957 IrInstruction *ptr = instruction->value->child;
17959 if (type_is_invalid(ptr->value.type))
17958 if (type_is_invalid(ptr->value->type))
1796017959 return ira->codegen->invalid_instruction;
17961 ZigType *ptr_type = ptr->value.type;
17960 ZigType *ptr_type = ptr->value->type;
1796217961 if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) {
1796317962 ir_add_error_node(ira, instruction->base.source_node,
1796417963 buf_sprintf("index syntax required for unknown-length pointer type '%s'",
......@@ -17971,9 +17970,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction
1797117970 return ira->codegen->invalid_instruction;
1797217971
1797317972 // If the result needs to be an lvalue, type check it
17974 if (instruction->lval == LValPtr && result->value.type->id != ZigTypeIdPointer) {
17973 if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) {
1797517974 ir_add_error(ira, &instruction->base,
17976 buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value.type->name)));
17975 buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name)));
1797717976 return ira->codegen->invalid_instruction;
1797817977 }
1797917978
......@@ -18016,13 +18015,13 @@ static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr
1801618015
1801718016 IrInstruction *result = ir_build_br(&ira->new_irb,
1801818017 br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr);
18019 result->value.type = ira->codegen->builtin_types.entry_unreachable;
18018 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1802018019 return ir_finish_anal(ira, result);
1802118020}
1802218021
1802318022static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) {
1802418023 IrInstruction *condition = cond_br_instruction->condition->child;
18025 if (type_is_invalid(condition->value.type))
18024 if (type_is_invalid(condition->value->type))
1802618025 return ir_unreach_error(ira);
1802718026
1802818027 bool is_comptime;
......@@ -18031,7 +18030,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi
1803118030
1803218031 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
1803318032 IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type);
18034 if (type_is_invalid(casted_condition->value.type))
18033 if (type_is_invalid(casted_condition->value->type))
1803518034 return ir_unreach_error(ira);
1803618035
1803718036 if (is_comptime || instr_is_comptime(casted_condition)) {
......@@ -18053,7 +18052,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi
1805318052
1805418053 IrInstruction *result = ir_build_br(&ira->new_irb,
1805518054 cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr);
18056 result->value.type = ira->codegen->builtin_types.entry_unreachable;
18055 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1805718056 return ir_finish_anal(ira, result);
1805818057 }
1805918058
......@@ -18072,7 +18071,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi
1807218071 IrInstruction *result = ir_build_cond_br(&ira->new_irb,
1807318072 cond_br_instruction->base.scope, cond_br_instruction->base.source_node,
1807418073 casted_condition, new_then_block, new_else_block, nullptr);
18075 result->value.type = ira->codegen->builtin_types.entry_unreachable;
18074 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1807618075 return ir_finish_anal(ira, result);
1807718076}
1807818077
......@@ -18081,7 +18080,7 @@ static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira,
1808118080{
1808218081 IrInstruction *result = ir_build_unreachable(&ira->new_irb,
1808318082 unreachable_instruction->base.scope, unreachable_instruction->base.source_node);
18084 result->value.type = ira->codegen->builtin_types.entry_unreachable;
18083 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1808518084 return ir_finish_anal(ira, result);
1808618085}
1808718086
......@@ -18094,13 +18093,13 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1809418093 if (predecessor != ira->const_predecessor_bb)
1809518094 continue;
1809618095 IrInstruction *value = phi_instruction->incoming_values[i]->child;
18097 assert(value->value.type);
18098 if (type_is_invalid(value->value.type))
18096 assert(value->value->type);
18097 if (type_is_invalid(value->value->type))
1809918098 return ira->codegen->invalid_instruction;
1810018099
18101 if (value->value.special != ConstValSpecialRuntime) {
18100 if (value->value->special != ConstValSpecialRuntime) {
1810218101 IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr);
18103 copy_const_val(&result->value, &value->value, true);
18102 copy_const_val(result->value, value->value, true);
1810418103 return result;
1810518104 } else {
1810618105 return value;
......@@ -18126,7 +18125,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1812618125 } else {
1812718126 instructions[i] = ir_const(ira, this_peer->base.source_instruction,
1812818127 this_peer->base.implicit_elem_type);
18129 instructions[i]->value.special = ConstValSpecialRuntime;
18128 instructions[i]->value->special = ConstValSpecialRuntime;
1813018129 }
1813118130 } else {
1813218131 instructions[i] = gen_instruction;
......@@ -18147,7 +18146,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1814718146 IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent,
1814818147 peer_parent->resolved_type, nullptr, false, false, true);
1814918148 if (parent_result_loc != nullptr &&
18150 (type_is_invalid(parent_result_loc->value.type) || instr_is_unreachable(parent_result_loc)))
18149 (type_is_invalid(parent_result_loc->value->type) || instr_is_unreachable(parent_result_loc)))
1815118150 {
1815218151 return parent_result_loc;
1815318152 }
......@@ -18160,7 +18159,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1816018159 if (instrs_to_move.length != 0) {
1816118160 IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb;
1816218161 IrInstruction *branch_instruction = predecessor->instruction_list.pop();
18163 ir_assert(branch_instruction->value.type->id == ZigTypeIdUnreachable, &phi_instruction->base);
18162 ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base);
1816418163 while (instrs_to_move.length != 0) {
1816518164 predecessor->instruction_list.append(instrs_to_move.pop());
1816618165 }
......@@ -18197,10 +18196,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1819718196 IrInstruction *old_value = phi_instruction->incoming_values[i];
1819818197 assert(old_value);
1819918198 IrInstruction *new_value = old_value->child;
18200 if (!new_value || new_value->value.type->id == ZigTypeIdUnreachable || predecessor->other == nullptr)
18199 if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->other == nullptr)
1820118200 continue;
1820218201
18203 if (type_is_invalid(new_value->value.type))
18202 if (type_is_invalid(new_value->value->type))
1820418203 return ira->codegen->invalid_instruction;
1820518204
1820618205
......@@ -18212,7 +18211,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1821218211 if (new_incoming_blocks.length == 0) {
1821318212 IrInstruction *result = ir_build_unreachable(&ira->new_irb,
1821418213 phi_instruction->base.scope, phi_instruction->base.source_node);
18215 result->value.type = ira->codegen->builtin_types.entry_unreachable;
18214 result->value->type = ira->codegen->builtin_types.entry_unreachable;
1821618215 return ir_finish_anal(ira, result);
1821718216 }
1821818217
......@@ -18233,7 +18232,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1823318232 if (type_is_invalid(resolved_type))
1823418233 return ira->codegen->invalid_instruction;
1823518234 } else {
18236 ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value.type;
18235 ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type;
1823718236 ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base);
1823818237 resolved_type = resolved_loc_ptr_type->data.pointer.child_type;
1823918238 }
......@@ -18281,14 +18280,14 @@ skip_resolve_peer_types:
1828118280 IrInstruction *branch_instruction = predecessor->instruction_list.pop();
1828218281 ir_set_cursor_at_end(&ira->new_irb, predecessor);
1828318282 IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type);
18284 if (type_is_invalid(casted_value->value.type)) {
18283 if (type_is_invalid(casted_value->value->type)) {
1828518284 return ira->codegen->invalid_instruction;
1828618285 }
1828718286 new_incoming_values.items[i] = casted_value;
1828818287 predecessor->instruction_list.append(branch_instruction);
1828918288
18290 if (all_stack_ptrs && (casted_value->value.special != ConstValSpecialRuntime ||
18291 casted_value->value.data.rh_ptr != RuntimeHintPtrStack))
18289 if (all_stack_ptrs && (casted_value->value->special != ConstValSpecialRuntime ||
18290 casted_value->value->data.rh_ptr != RuntimeHintPtrStack))
1829218291 {
1829318292 all_stack_ptrs = false;
1829418293 }
......@@ -18298,11 +18297,11 @@ skip_resolve_peer_types:
1829818297 IrInstruction *result = ir_build_phi(&ira->new_irb,
1829918298 phi_instruction->base.scope, phi_instruction->base.source_node,
1830018299 new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr);
18301 result->value.type = resolved_type;
18300 result->value->type = resolved_type;
1830218301
1830318302 if (all_stack_ptrs) {
18304 assert(result->value.special == ConstValSpecialRuntime);
18305 result->value.data.rh_ptr = RuntimeHintPtrStack;
18303 assert(result->value->special == ConstValSpecialRuntime);
18304 result->value->data.rh_ptr = RuntimeHintPtrStack;
1830618305 }
1830718306
1830818307 return result;
......@@ -18358,13 +18357,13 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) {
1835818357static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) {
1835918358 Error err;
1836018359 IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child;
18361 if (type_is_invalid(array_ptr->value.type))
18360 if (type_is_invalid(array_ptr->value->type))
1836218361 return ira->codegen->invalid_instruction;
1836318362
18364 ZigValue *orig_array_ptr_val = &array_ptr->value;
18363 ZigValue *orig_array_ptr_val = array_ptr->value;
1836518364
1836618365 IrInstruction *elem_index = elem_ptr_instruction->elem_index->child;
18367 if (type_is_invalid(elem_index->value.type))
18366 if (type_is_invalid(elem_index->value->type))
1836818367 return ira->codegen->invalid_instruction;
1836918368
1837018369 ZigType *ptr_type = orig_array_ptr_val->type;
......@@ -18471,7 +18470,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1847118470 return ira->codegen->invalid_instruction;
1847218471 ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base);
1847318472 Buf *field_name = buf_alloc();
18474 bigint_append_buf(field_name, &casted_elem_index->value.data.x_bigint, 10);
18473 bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10);
1847518474 return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base,
1847618475 array_ptr, array_type);
1847718476 } else {
......@@ -18487,13 +18486,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1848718486
1848818487 bool safety_check_on = elem_ptr_instruction->safety_check_on;
1848918488 if (instr_is_comptime(casted_elem_index)) {
18490 uint64_t index = bigint_as_u64(&casted_elem_index->value.data.x_bigint);
18489 uint64_t index = bigint_as_u64(&casted_elem_index->value->data.x_bigint);
1849118490 if (array_type->id == ZigTypeIdArray) {
1849218491 uint64_t array_len = array_type->data.array.len;
1849318492 if (index == array_len && array_type->data.array.sentinel != nullptr) {
1849418493 ZigType *elem_type = array_type->data.array.child_type;
1849518494 IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type);
18496 copy_const_val(&sentinel_elem->value, array_type->data.array.sentinel, false);
18495 copy_const_val(sentinel_elem->value, array_type->data.array.sentinel, false);
1849718496 return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false);
1849818497 }
1849918498 if (index >= array_len) {
......@@ -18565,8 +18564,8 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1856518564 elem_val->parent.data.p_array.elem_index = i;
1856618565 }
1856718566 } else if (is_slice(array_type)) {
18568 ir_assert(array_ptr->value.type->id == ZigTypeIdPointer, &elem_ptr_instruction->base);
18569 ZigType *actual_array_type = array_ptr->value.type->data.pointer.child_type;
18567 ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base);
18568 ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type;
1857018569
1857118570 if (type_is_invalid(actual_array_type))
1857218571 return ira->codegen->invalid_instruction;
......@@ -18608,7 +18607,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1860818607 {
1860918608 if (array_type->id == ZigTypeIdPointer) {
1861018609 IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type);
18611 ZigValue *out_val = &result->value;
18610 ZigValue *out_val = result->value;
1861218611 out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut;
1861318612 size_t new_index;
1861418613 size_t mem_size;
......@@ -18688,12 +18687,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1868818687 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
1868918688 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false,
1869018689 elem_ptr_instruction->ptr_len, nullptr);
18691 result->value.type = return_type;
18690 result->value->type = return_type;
1869218691 return result;
1869318692 }
1869418693 ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index];
1869518694 IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type);
18696 ZigValue *out_val = &result->value;
18695 ZigValue *out_val = result->value;
1869718696 ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry;
1869818697 uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint);
1869918698 uint64_t full_slice_len = slice_len +
......@@ -18752,12 +18751,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1875218751 result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
1875318752 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index,
1875418753 false, elem_ptr_instruction->ptr_len, nullptr);
18755 result->value.type = return_type;
18756 result->value.special = ConstValSpecialStatic;
18754 result->value->type = return_type;
18755 result->value->special = ConstValSpecialStatic;
1875718756 } else {
1875818757 result = ir_const(ira, &elem_ptr_instruction->base, return_type);
1875918758 }
18760 ZigValue *out_val = &result->value;
18759 ZigValue *out_val = result->value;
1876118760 out_val->data.x_ptr.special = ConstPtrSpecialBaseArray;
1876218761 out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut;
1876318762 out_val->data.x_ptr.data.base_array.array_val = array_ptr_val;
......@@ -18814,7 +18813,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1881418813 IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope,
1881518814 elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on,
1881618815 elem_ptr_instruction->ptr_len, nullptr);
18817 result->value.type = return_type;
18816 result->value->type = return_type;
1881818817 return result;
1881918818}
1882018819
......@@ -18892,8 +18891,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1889218891 case OnePossibleValueNo:
1889318892 break;
1889418893 }
18895 bool is_const = struct_ptr->value.type->data.pointer.is_const;
18896 bool is_volatile = struct_ptr->value.type->data.pointer.is_volatile;
18894 bool is_const = struct_ptr->value->type->data.pointer.is_const;
18895 bool is_volatile = struct_ptr->value->type->data.pointer.is_volatile;
1889718896 ZigType *ptr_type;
1889818897 if (struct_type->data.structure.is_inferred) {
1889918898 ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
......@@ -18904,9 +18903,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1890418903 ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown;
1890518904 if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status)))
1890618905 return ira->codegen->invalid_instruction;
18907 assert(struct_ptr->value.type->id == ZigTypeIdPointer);
18908 uint32_t ptr_bit_offset = struct_ptr->value.type->data.pointer.bit_offset_in_host;
18909 uint32_t ptr_host_int_bytes = struct_ptr->value.type->data.pointer.host_int_bytes;
18906 assert(struct_ptr->value->type->id == ZigTypeIdPointer);
18907 uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host;
18908 uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes;
1891018909 uint32_t host_int_bytes_for_result_type = (ptr_host_int_bytes == 0) ?
1891118910 get_host_int_bytes(ira->codegen, struct_type, field) : ptr_host_int_bytes;
1891218911 ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
......@@ -18942,12 +18941,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1894218941 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
1894318942 result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope,
1894418943 source_instr->source_node, struct_ptr, field);
18945 result->value.type = ptr_type;
18946 result->value.special = ConstValSpecialStatic;
18944 result->value->type = ptr_type;
18945 result->value->special = ConstValSpecialStatic;
1894718946 } else {
1894818947 result = ir_const(ira, source_instr, ptr_type);
1894918948 }
18950 ZigValue *const_val = &result->value;
18949 ZigValue *const_val = result->value;
1895118950 const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct;
1895218951 const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
1895318952 const_val->data.x_ptr.data.base_struct.struct_val = struct_val;
......@@ -18957,7 +18956,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1895718956 }
1895818957 IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node,
1895918958 struct_ptr, field);
18960 result->value.type = ptr_type;
18959 result->value->type = ptr_type;
1896118960 return result;
1896218961}
1896318962
......@@ -18970,7 +18969,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n
1897018969 // the field type will then be available, and the field will be added to the inferred
1897118970 // struct.
1897218971
18973 ZigType *container_ptr_type = container_ptr->value.type;
18972 ZigType *container_ptr_type = container_ptr->value->type;
1897418973 ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr);
1897518974
1897618975 InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField");
......@@ -18984,14 +18983,14 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n
1898418983
1898518984 if (instr_is_comptime(container_ptr)) {
1898618985 IrInstruction *result = ir_const(ira, source_instr, field_ptr_type);
18987 copy_const_val(&result->value, &container_ptr->value, false);
18988 result->value.type = field_ptr_type;
18986 copy_const_val(result->value, container_ptr->value, false);
18987 result->value->type = field_ptr_type;
1898918988 return result;
1899018989 }
1899118990
1899218991 IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope,
1899318992 source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop);
18994 result->value.type = field_ptr_type;
18993 result->value->type = field_ptr_type;
1899518994 return result;
1899618995}
1899718996
......@@ -19011,7 +19010,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1901119010 if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown)))
1901219011 return ira->codegen->invalid_instruction;
1901319012
19014 assert(container_ptr->value.type->id == ZigTypeIdPointer);
19013 assert(container_ptr->value->type->id == ZigTypeIdPointer);
1901519014 if (bare_type->id == ZigTypeIdStruct) {
1901619015 TypeStructField *field = find_struct_type_field(bare_type, field_name);
1901719016 if (field != nullptr) {
......@@ -19028,8 +19027,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1902819027 }
1902919028
1903019029 if (bare_type->id == ZigTypeIdUnion) {
19031 bool is_const = container_ptr->value.type->data.pointer.is_const;
19032 bool is_volatile = container_ptr->value.type->data.pointer.is_volatile;
19030 bool is_const = container_ptr->value->type->data.pointer.is_const;
19031 bool is_volatile = container_ptr->value->type->data.pointer.is_volatile;
1903319032
1903419033 TypeUnionField *field = find_union_type_field(bare_type, field_name);
1903519034 if (field == nullptr) {
......@@ -19085,14 +19084,14 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1908519084 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
1908619085 result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope,
1908719086 source_instr->source_node, container_ptr, field, true, initializing);
19088 result->value.type = ptr_type;
19089 result->value.special = ConstValSpecialStatic;
19087 result->value->type = ptr_type;
19088 result->value->special = ConstValSpecialStatic;
1909019089 } else {
1909119090 result = ir_const(ira, source_instr, ptr_type);
1909219091 }
19093 ZigValue *const_val = &result->value;
19092 ZigValue *const_val = result->value;
1909419093 const_val->data.x_ptr.special = ConstPtrSpecialRef;
19095 const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut;
19094 const_val->data.x_ptr.mut = container_ptr->value->data.x_ptr.mut;
1909619095 const_val->data.x_ptr.data.ref.pointee = payload_val;
1909719096 return result;
1909819097 }
......@@ -19100,7 +19099,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1910019099
1910119100 IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope,
1910219101 source_instr->source_node, container_ptr, field, true, initializing);
19103 result->value.type = ptr_type;
19102 result->value->type = ptr_type;
1910419103 return result;
1910519104 }
1910619105
......@@ -19205,10 +19204,10 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n
1920519204static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) {
1920619205 Error err;
1920719206 IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child;
19208 if (type_is_invalid(container_ptr->value.type))
19207 if (type_is_invalid(container_ptr->value->type))
1920919208 return ira->codegen->invalid_instruction;
1921019209
19211 ZigType *container_type = container_ptr->value.type->data.pointer.child_type;
19210 ZigType *container_type = container_ptr->value->type->data.pointer.child_type;
1921219211
1921319212 Buf *field_name = field_ptr_instruction->field_name_buffer;
1921419213 if (!field_name) {
......@@ -19224,7 +19223,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1922419223 if (type_is_invalid(container_type)) {
1922519224 return ira->codegen->invalid_instruction;
1922619225 } else if (is_slice(container_type) || is_container_ref(container_type)) {
19227 assert(container_ptr->value.type->id == ZigTypeIdPointer);
19226 assert(container_ptr->value->type->id == ZigTypeIdPointer);
1922819227 if (container_type->id == ZigTypeIdPointer) {
1922919228 ZigType *bare_type = container_ref_type(container_type);
1923019229 IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr);
......@@ -19259,7 +19258,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1925919258 if (!container_ptr_val)
1926019259 return ira->codegen->invalid_instruction;
1926119260
19262 assert(container_ptr->value.type->id == ZigTypeIdPointer);
19261 assert(container_ptr->value->type->id == ZigTypeIdPointer);
1926319262 ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node);
1926419263 if (child_val == nullptr)
1926519264 return ira->codegen->invalid_instruction;
......@@ -19285,7 +19284,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1928519284 if (!container_ptr_val)
1928619285 return ira->codegen->invalid_instruction;
1928719286
19288 assert(container_ptr->value.type->id == ZigTypeIdPointer);
19287 assert(container_ptr->value->type->id == ZigTypeIdPointer);
1928919288 ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node);
1929019289 if (child_val == nullptr)
1929119290 return ira->codegen->invalid_instruction;
......@@ -19567,11 +19566,11 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1956719566
1956819567static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) {
1956919568 IrInstruction *ptr = instruction->ptr->child;
19570 if (type_is_invalid(ptr->value.type))
19569 if (type_is_invalid(ptr->value->type))
1957119570 return ira->codegen->invalid_instruction;
1957219571
1957319572 IrInstruction *value = instruction->value->child;
19574 if (type_is_invalid(value->value.type))
19573 if (type_is_invalid(value->value->type))
1957519574 return ira->codegen->invalid_instruction;
1957619575
1957719576 return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const);
......@@ -19579,14 +19578,14 @@ static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstruc
1957919578
1958019579static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) {
1958119580 IrInstruction *ptr = instruction->ptr->child;
19582 if (type_is_invalid(ptr->value.type))
19581 if (type_is_invalid(ptr->value->type))
1958319582 return ira->codegen->invalid_instruction;
1958419583 return ir_get_deref(ira, &instruction->base, ptr, nullptr);
1958519584}
1958619585
1958719586static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) {
1958819587 IrInstruction *expr_value = typeof_instruction->value->child;
19589 ZigType *type_entry = expr_value->value.type;
19588 ZigType *type_entry = expr_value->value->type;
1959019589 if (type_is_invalid(type_entry))
1959119590 return ira->codegen->invalid_instruction;
1959219591 return ir_const_type(ira, &typeof_instruction->base, type_entry);
......@@ -19749,11 +19748,11 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira,
1974919748 IrInstructionSliceType *slice_type_instruction)
1975019749{
1975119750 IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type);
19752 result->value.special = ConstValSpecialLazy;
19751 result->value->special = ConstValSpecialLazy;
1975319752
1975419753 LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1);
1975519754 lazy_slice_type->ira = ira;
19756 result->value.data.x_lazy = &lazy_slice_type->base;
19755 result->value->data.x_lazy = &lazy_slice_type->base;
1975719756 lazy_slice_type->base.id = LazyValueIdSliceType;
1975819757
1975919758 if (slice_type_instruction->align_value != nullptr) {
......@@ -19812,14 +19811,14 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1981219811
1981319812 for (size_t i = 0; i < asm_expr->input_list.length; i += 1) {
1981419813 IrInstruction *const input_value = asm_instruction->input_list[i]->child;
19815 if (type_is_invalid(input_value->value.type))
19814 if (type_is_invalid(input_value->value->type))
1981619815 return ira->codegen->invalid_instruction;
1981719816
1981819817 if (instr_is_comptime(input_value) &&
19819 (input_value->value.type->id == ZigTypeIdComptimeInt ||
19820 input_value->value.type->id == ZigTypeIdComptimeFloat)) {
19818 (input_value->value->type->id == ZigTypeIdComptimeInt ||
19819 input_value->value->type->id == ZigTypeIdComptimeFloat)) {
1982119820 ir_add_error_node(ira, input_value->source_node,
19822 buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name)));
19821 buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name)));
1982319822 return ira->codegen->invalid_instruction;
1982419823 }
1982519824
......@@ -19831,7 +19830,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1983119830 asm_instruction->asm_template, asm_instruction->token_list, asm_instruction->token_list_len,
1983219831 input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count,
1983319832 asm_instruction->has_side_effects);
19834 result->value.type = return_type;
19833 result->value->type = return_type;
1983519834 return result;
1983619835}
1983719836
......@@ -19853,10 +19852,10 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1985319852 ZigValue *sentinel_val;
1985419853 if (array_type_instruction->sentinel != nullptr) {
1985519854 IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child;
19856 if (type_is_invalid(uncasted_sentinel->value.type))
19855 if (type_is_invalid(uncasted_sentinel->value->type))
1985719856 return ira->codegen->invalid_instruction;
1985819857 IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type);
19859 if (type_is_invalid(sentinel->value.type))
19858 if (type_is_invalid(sentinel->value->type))
1986019859 return ira->codegen->invalid_instruction;
1986119860 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
1986219861 if (sentinel_val == nullptr)
......@@ -19909,11 +19908,11 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1990919908
1991019909static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) {
1991119910 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int);
19912 result->value.special = ConstValSpecialLazy;
19911 result->value->special = ConstValSpecialLazy;
1991319912
1991419913 LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1);
1991519914 lazy_size_of->ira = ira;
19916 result->value.data.x_lazy = &lazy_size_of->base;
19915 result->value->data.x_lazy = &lazy_size_of->base;
1991719916 lazy_size_of->base.id = LazyValueIdSizeOf;
1991819917
1991919918 lazy_size_of->target_type = instruction->type_value->child;
......@@ -19924,7 +19923,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi
1992419923}
1992519924
1992619925static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) {
19927 ZigType *type_entry = value->value.type;
19926 ZigType *type_entry = value->value->type;
1992819927
1992919928 if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) {
1993019929 if (instr_is_comptime(value)) {
......@@ -19941,7 +19940,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so
1994119940
1994219941 IrInstruction *result = ir_build_test_nonnull(&ira->new_irb,
1994319942 source_inst->scope, source_inst->source_node, value);
19944 result->value.type = ira->codegen->builtin_types.entry_bool;
19943 result->value->type = ira->codegen->builtin_types.entry_bool;
1994519944 return result;
1994619945 } else if (type_entry->id == ZigTypeIdOptional) {
1994719946 if (instr_is_comptime(value)) {
......@@ -19956,7 +19955,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so
1995619955
1995719956 IrInstruction *result = ir_build_test_nonnull(&ira->new_irb,
1995819957 source_inst->scope, source_inst->source_node, value);
19959 result->value.type = ira->codegen->builtin_types.entry_bool;
19958 result->value->type = ira->codegen->builtin_types.entry_bool;
1996019959 return result;
1996119960 } else if (type_entry->id == ZigTypeIdNull) {
1996219961 return ir_const_bool(ira, source_inst, false);
......@@ -19967,23 +19966,23 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so
1996719966
1996819967static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) {
1996919968 IrInstruction *value = instruction->value->child;
19970 if (type_is_invalid(value->value.type))
19969 if (type_is_invalid(value->value->type))
1997119970 return ira->codegen->invalid_instruction;
1997219971
1997319972 return ir_analyze_test_non_null(ira, &instruction->base, value);
1997419973}
1997519974
1997619975static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) {
19977 ir_assert(ptr->value.type->id == ZigTypeIdPointer, ptr);
19978 ZigType *elem_type = ptr->value.type->data.pointer.child_type;
19976 ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr);
19977 ZigType *elem_type = ptr->value->type->data.pointer.child_type;
1997919978 if (elem_type != g->builtin_types.entry_var)
1998019979 return elem_type;
1998119980
19982 if (ir_resolve_lazy(g, ptr->source_node, &ptr->value))
19981 if (ir_resolve_lazy(g, ptr->source_node, ptr->value))
1998319982 return g->builtin_types.entry_invalid;
1998419983
19985 assert(value_is_comptime(&ptr->value));
19986 ZigValue *pointee = const_ptr_pointee_unchecked(g, &ptr->value);
19984 assert(value_is_comptime(ptr->value));
19985 ZigValue *pointee = const_ptr_pointee_unchecked(g, ptr->value);
1998719986 return pointee->type;
1998819987}
1998919988
......@@ -20028,7 +20027,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2002820027
2002920028 ZigType *child_type = type_entry->data.maybe.child_type;
2003020029 ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type,
20031 base_ptr->value.type->data.pointer.is_const, base_ptr->value.type->data.pointer.is_volatile,
20030 base_ptr->value->type->data.pointer.is_const, base_ptr->value->type->data.pointer.is_volatile,
2003220031 PtrLenSingle, 0, 0, 0, false);
2003320032
2003420033 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry);
......@@ -20079,12 +20078,12 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2007920078 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
2008020079 result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope,
2008120080 source_instr->source_node, base_ptr, false, initializing);
20082 result->value.type = result_type;
20083 result->value.special = ConstValSpecialStatic;
20081 result->value->type = result_type;
20082 result->value->special = ConstValSpecialStatic;
2008420083 } else {
2008520084 result = ir_const(ira, source_instr, result_type);
2008620085 }
20087 ZigValue *result_val = &result->value;
20086 ZigValue *result_val = result->value;
2008820087 result_val->data.x_ptr.special = ConstPtrSpecialRef;
2008920088 result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
2009020089 switch (type_has_one_possible_value(ira->codegen, child_type)) {
......@@ -20109,7 +20108,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2010920108
2011020109 IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope,
2011120110 source_instr->source_node, base_ptr, safety_check_on, initializing);
20112 result->value.type = result_type;
20111 result->value->type = result_type;
2011320112 return result;
2011420113}
2011520114
......@@ -20117,7 +20116,7 @@ static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira,
2011720116 IrInstructionOptionalUnwrapPtr *instruction)
2011820117{
2011920118 IrInstruction *base_ptr = instruction->base_ptr->child;
20120 if (type_is_invalid(base_ptr->value.type))
20119 if (type_is_invalid(base_ptr->value->type))
2012120120 return ira->codegen->invalid_instruction;
2012220121
2012320122 return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr,
......@@ -20130,7 +20129,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt
2013020129 return ira->codegen->invalid_instruction;
2013120130
2013220131 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
20133 if (type_is_invalid(op->value.type))
20132 if (type_is_invalid(op->value->type))
2013420133 return ira->codegen->invalid_instruction;
2013520134
2013620135 if (int_type->data.integral.bit_count == 0)
......@@ -20142,14 +20141,14 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt
2014220141 return ira->codegen->invalid_instruction;
2014320142 if (val->special == ConstValSpecialUndef)
2014420143 return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int);
20145 size_t result_usize = bigint_ctz(&op->value.data.x_bigint, int_type->data.integral.bit_count);
20144 size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count);
2014620145 return ir_const_unsigned(ira, &instruction->base, result_usize);
2014720146 }
2014820147
2014920148 ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count);
2015020149 IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope,
2015120150 instruction->base.source_node, nullptr, op);
20152 result->value.type = return_type;
20151 result->value->type = return_type;
2015320152 return result;
2015420153}
2015520154
......@@ -20159,7 +20158,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl
2015920158 return ira->codegen->invalid_instruction;
2016020159
2016120160 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
20162 if (type_is_invalid(op->value.type))
20161 if (type_is_invalid(op->value->type))
2016320162 return ira->codegen->invalid_instruction;
2016420163
2016520164 if (int_type->data.integral.bit_count == 0)
......@@ -20171,14 +20170,14 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl
2017120170 return ira->codegen->invalid_instruction;
2017220171 if (val->special == ConstValSpecialUndef)
2017320172 return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int);
20174 size_t result_usize = bigint_clz(&op->value.data.x_bigint, int_type->data.integral.bit_count);
20173 size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count);
2017520174 return ir_const_unsigned(ira, &instruction->base, result_usize);
2017620175 }
2017720176
2017820177 ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count);
2017920178 IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope,
2018020179 instruction->base.source_node, nullptr, op);
20181 result->value.type = return_type;
20180 result->value->type = return_type;
2018220181 return result;
2018320182}
2018420183
......@@ -20188,7 +20187,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc
2018820187 return ira->codegen->invalid_instruction;
2018920188
2019020189 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
20191 if (type_is_invalid(op->value.type))
20190 if (type_is_invalid(op->value->type))
2019220191 return ira->codegen->invalid_instruction;
2019320192
2019420193 if (int_type->data.integral.bit_count == 0)
......@@ -20212,33 +20211,33 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc
2021220211 ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count);
2021320212 IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope,
2021420213 instruction->base.source_node, nullptr, op);
20215 result->value.type = return_type;
20214 result->value->type = return_type;
2021620215 return result;
2021720216}
2021820217
2021920218static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) {
20220 if (type_is_invalid(value->value.type))
20219 if (type_is_invalid(value->value->type))
2022120220 return ira->codegen->invalid_instruction;
2022220221
20223 if (value->value.type->id == ZigTypeIdEnum) {
20222 if (value->value->type->id == ZigTypeIdEnum) {
2022420223 return value;
2022520224 }
2022620225
20227 if (value->value.type->id != ZigTypeIdUnion) {
20226 if (value->value->type->id != ZigTypeIdUnion) {
2022820227 ir_add_error(ira, value,
20229 buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name)));
20228 buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name)));
2023020229 return ira->codegen->invalid_instruction;
2023120230 }
20232 if (!value->value.type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) {
20231 if (!value->value->type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) {
2023320232 ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum"));
20234 if (value->value.type->data.unionation.decl_node != nullptr) {
20235 add_error_note(ira->codegen, msg, value->value.type->data.unionation.decl_node,
20233 if (value->value->type->data.unionation.decl_node != nullptr) {
20234 add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node,
2023620235 buf_sprintf("declared here"));
2023720236 }
2023820237 return ira->codegen->invalid_instruction;
2023920238 }
2024020239
20241 ZigType *tag_type = value->value.type->data.unionation.tag_type;
20240 ZigType *tag_type = value->value->type->data.unionation.tag_type;
2024220241 assert(tag_type->id == ZigTypeIdEnum);
2024320242
2024420243 if (instr_is_comptime(value)) {
......@@ -20248,14 +20247,14 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
2024820247
2024920248 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb,
2025020249 source_instr->scope, source_instr->source_node);
20251 const_instruction->base.value.type = tag_type;
20252 const_instruction->base.value.special = ConstValSpecialStatic;
20253 bigint_init_bigint(&const_instruction->base.value.data.x_enum_tag, &val->data.x_union.tag);
20250 const_instruction->base.value->type = tag_type;
20251 const_instruction->base.value->special = ConstValSpecialStatic;
20252 bigint_init_bigint(&const_instruction->base.value->data.x_enum_tag, &val->data.x_union.tag);
2025420253 return &const_instruction->base;
2025520254 }
2025620255
2025720256 IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value);
20258 result->value.type = tag_type;
20257 result->value->type = tag_type;
2025920258 return result;
2026020259}
2026120260
......@@ -20263,11 +20262,11 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2026320262 IrInstructionSwitchBr *switch_br_instruction)
2026420263{
2026520264 IrInstruction *target_value = switch_br_instruction->target_value->child;
20266 if (type_is_invalid(target_value->value.type))
20265 if (type_is_invalid(target_value->value->type))
2026720266 return ir_unreach_error(ira);
2026820267
2026920268 if (switch_br_instruction->switch_prongs_void != nullptr) {
20270 if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value.type)) {
20269 if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value->type)) {
2027120270 return ir_unreach_error(ira);
2027220271 }
2027320272 }
......@@ -20288,17 +20287,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2028820287 for (size_t i = 0; i < case_count; i += 1) {
2028920288 IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i];
2029020289 IrInstruction *case_value = old_case->value->child;
20291 if (type_is_invalid(case_value->value.type))
20290 if (type_is_invalid(case_value->value->type))
2029220291 return ir_unreach_error(ira);
2029320292
20294 if (case_value->value.type->id == ZigTypeIdEnum) {
20293 if (case_value->value->type->id == ZigTypeIdEnum) {
2029520294 case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value);
20296 if (type_is_invalid(case_value->value.type))
20295 if (type_is_invalid(case_value->value->type))
2029720296 return ir_unreach_error(ira);
2029820297 }
2029920298
20300 IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type);
20301 if (type_is_invalid(casted_case_value->value.type))
20299 IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type);
20300 if (type_is_invalid(casted_case_value->value->type))
2030220301 return ir_unreach_error(ira);
2030320302
2030420303 ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad);
......@@ -20318,7 +20317,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2031820317 IrInstruction *result = ir_build_br(&ira->new_irb,
2031920318 switch_br_instruction->base.scope, switch_br_instruction->base.source_node,
2032020319 new_dest_block, nullptr);
20321 result->value.type = ira->codegen->builtin_types.entry_unreachable;
20320 result->value->type = ira->codegen->builtin_types.entry_unreachable;
2032220321 return ir_finish_anal(ira, result);
2032320322 }
2032420323 }
......@@ -20338,17 +20337,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2033820337
2033920338 IrInstruction *old_value = old_case->value;
2034020339 IrInstruction *new_value = old_value->child;
20341 if (type_is_invalid(new_value->value.type))
20340 if (type_is_invalid(new_value->value->type))
2034220341 continue;
2034320342
20344 if (new_value->value.type->id == ZigTypeIdEnum) {
20343 if (new_value->value->type->id == ZigTypeIdEnum) {
2034520344 new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value);
20346 if (type_is_invalid(new_value->value.type))
20345 if (type_is_invalid(new_value->value->type))
2034720346 continue;
2034820347 }
2034920348
20350 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type);
20351 if (type_is_invalid(casted_new_value->value.type))
20349 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type);
20350 if (type_is_invalid(casted_new_value->value->type))
2035220351 continue;
2035320352
2035420353 if (!ir_resolve_const(ira, casted_new_value, UndefBad))
......@@ -20368,7 +20367,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2036820367 IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb,
2036920368 switch_br_instruction->base.scope, switch_br_instruction->base.source_node,
2037020369 target_value, new_else_block, case_count, cases, nullptr, nullptr);
20371 switch_br->base.value.type = ira->codegen->builtin_types.entry_unreachable;
20370 switch_br->base.value->type = ira->codegen->builtin_types.entry_unreachable;
2037220371 return ir_finish_anal(ira, &switch_br->base);
2037320372}
2037420373
......@@ -20377,20 +20376,20 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2037720376{
2037820377 Error err;
2037920378 IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child;
20380 if (type_is_invalid(target_value_ptr->value.type))
20379 if (type_is_invalid(target_value_ptr->value->type))
2038120380 return ira->codegen->invalid_instruction;
2038220381
20383 if (target_value_ptr->value.type->id == ZigTypeIdMetaType) {
20382 if (target_value_ptr->value->type->id == ZigTypeIdMetaType) {
2038420383 assert(instr_is_comptime(target_value_ptr));
20385 ZigType *ptr_type = target_value_ptr->value.data.x_type;
20384 ZigType *ptr_type = target_value_ptr->value->data.x_type;
2038620385 assert(ptr_type->id == ZigTypeIdPointer);
2038720386 return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type);
2038820387 }
2038920388
20390 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
20389 ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type;
2039120390 ZigValue *pointee_val = nullptr;
20392 if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
20393 pointee_val = const_ptr_pointee(ira, ira->codegen, &target_value_ptr->value, target_value_ptr->source_node);
20391 if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
20392 pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->source_node);
2039420393 if (pointee_val == nullptr)
2039520394 return ira->codegen->invalid_instruction;
2039620395
......@@ -20416,13 +20415,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2041620415 case ZigTypeIdErrorSet: {
2041720416 if (pointee_val) {
2041820417 IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr);
20419 copy_const_val(&result->value, pointee_val, true);
20420 result->value.type = target_type;
20418 copy_const_val(result->value, pointee_val, true);
20419 result->value->type = target_type;
2042120420 return result;
2042220421 }
2042320422
2042420423 IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr);
20425 result->value.type = target_type;
20424 result->value->type = target_type;
2042620425 return result;
2042720426 }
2042820427 case ZigTypeIdUnion: {
......@@ -20441,22 +20440,22 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2044120440 assert(tag_type->id == ZigTypeIdEnum);
2044220441 if (pointee_val) {
2044320442 IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type);
20444 bigint_init_bigint(&result->value.data.x_enum_tag, &pointee_val->data.x_union.tag);
20443 bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag);
2044520444 return result;
2044620445 }
2044720446 if (tag_type->data.enumeration.src_field_count == 1) {
2044820447 IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type);
2044920448 TypeEnumField *only_field = &tag_type->data.enumeration.fields[0];
20450 bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value);
20449 bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value);
2045120450 return result;
2045220451 }
2045320452
2045420453 IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr);
20455 union_value->value.type = target_type;
20454 union_value->value->type = target_type;
2045620455
2045720456 IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope,
2045820457 switch_target_instruction->base.source_node, union_value);
20459 union_tag_inst->value.type = tag_type;
20458 union_tag_inst->value->type = tag_type;
2046020459 return union_tag_inst;
2046120460 }
2046220461 case ZigTypeIdEnum: {
......@@ -20465,18 +20464,18 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2046520464 if (target_type->data.enumeration.src_field_count < 2) {
2046620465 TypeEnumField *only_field = &target_type->data.enumeration.fields[0];
2046720466 IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type);
20468 bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value);
20467 bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value);
2046920468 return result;
2047020469 }
2047120470
2047220471 if (pointee_val) {
2047320472 IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type);
20474 bigint_init_bigint(&result->value.data.x_enum_tag, &pointee_val->data.x_enum_tag);
20473 bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag);
2047520474 return result;
2047620475 }
2047720476
2047820477 IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr);
20479 enum_value->value.type = target_type;
20478 enum_value->value->type = target_type;
2048020479 return enum_value;
2048120480 }
2048220481 case ZigTypeIdErrorUnion:
......@@ -20501,12 +20500,12 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2050120500
2050220501static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) {
2050320502 IrInstruction *target_value_ptr = instruction->target_value_ptr->child;
20504 if (type_is_invalid(target_value_ptr->value.type))
20503 if (type_is_invalid(target_value_ptr->value->type))
2050520504 return ira->codegen->invalid_instruction;
2050620505
20507 ZigType *ref_type = target_value_ptr->value.type;
20506 ZigType *ref_type = target_value_ptr->value->type;
2050820507 assert(ref_type->id == ZigTypeIdPointer);
20509 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
20508 ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type;
2051020509 if (target_type->id == ZigTypeIdUnion) {
2051120510 ZigType *enum_type = target_type->data.unionation.tag_type;
2051220511 assert(enum_type != nullptr);
......@@ -20514,11 +20513,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2051420513 assert(instruction->prongs_len > 0);
2051520514
2051620515 IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child;
20517 if (type_is_invalid(first_prong_value->value.type))
20516 if (type_is_invalid(first_prong_value->value->type))
2051820517 return ira->codegen->invalid_instruction;
2051920518
2052020519 IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type);
20521 if (type_is_invalid(first_casted_prong_value->value.type))
20520 if (type_is_invalid(first_casted_prong_value->value->type))
2052220521 return ira->codegen->invalid_instruction;
2052320522
2052420523 ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad);
......@@ -20530,11 +20529,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2053020529 ErrorMsg *invalid_payload_msg = nullptr;
2053120530 for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) {
2053220531 IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child;
20533 if (type_is_invalid(this_prong_inst->value.type))
20532 if (type_is_invalid(this_prong_inst->value->type))
2053420533 return ira->codegen->invalid_instruction;
2053520534
2053620535 IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type);
20537 if (type_is_invalid(this_casted_prong_value->value.type))
20536 if (type_is_invalid(this_casted_prong_value->value->type))
2053820537 return ira->codegen->invalid_instruction;
2053920538
2054020539 ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad);
......@@ -20571,7 +20570,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2057120570 IrInstruction *result = ir_const(ira, &instruction->base,
2057220571 get_pointer_to_type(ira->codegen, first_field->type_entry,
2057320572 target_val_ptr->type->data.pointer.is_const));
20574 ZigValue *out_val = &result->value;
20573 ZigValue *out_val = result->value;
2057520574 out_val->data.x_ptr.special = ConstPtrSpecialRef;
2057620575 out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut;
2057720576 out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload;
......@@ -20580,8 +20579,8 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2058020579
2058120580 IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb,
2058220581 instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false);
20583 result->value.type = get_pointer_to_type(ira->codegen, first_field->type_entry,
20584 target_value_ptr->value.type->data.pointer.is_const);
20582 result->value->type = get_pointer_to_type(ira->codegen, first_field->type_entry,
20583 target_value_ptr->value->type->data.pointer.is_const);
2058520584 return result;
2058620585 } else if (target_type->id == ZigTypeIdErrorSet) {
2058720586 // construct an error set from the prong values
......@@ -20624,12 +20623,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira,
2062420623 IrInstructionSwitchElseVar *instruction)
2062520624{
2062620625 IrInstruction *target_value_ptr = instruction->target_value_ptr->child;
20627 if (type_is_invalid(target_value_ptr->value.type))
20626 if (type_is_invalid(target_value_ptr->value->type))
2062820627 return ira->codegen->invalid_instruction;
2062920628
20630 ZigType *ref_type = target_value_ptr->value.type;
20629 ZigType *ref_type = target_value_ptr->value->type;
2063120630 assert(ref_type->id == ZigTypeIdPointer);
20632 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
20631 ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type;
2063320632 if (target_type->id == ZigTypeIdErrorSet) {
2063420633 // make a new set that has the other cases removed
2063520634 if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) {
......@@ -20645,12 +20644,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira,
2064520644 for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) {
2064620645 IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i];
2064720646 IrInstruction *case_expr = br_case->value->child;
20648 if (case_expr->value.type->id == ZigTypeIdErrorSet) {
20647 if (case_expr->value->type->id == ZigTypeIdErrorSet) {
2064920648 ErrorTableEntry *err = ir_resolve_error(ira, case_expr);
2065020649 if (err == nullptr)
2065120650 return ira->codegen->invalid_instruction;
2065220651 errors[err->value] = err;
20653 } else if (case_expr->value.type->id == ZigTypeIdMetaType) {
20652 } else if (case_expr->value->type->id == ZigTypeIdMetaType) {
2065420653 ZigType *err_set_type = ir_resolve_type(ira, case_expr);
2065520654 if (type_is_invalid(err_set_type))
2065620655 return ira->codegen->invalid_instruction;
......@@ -20742,7 +20741,7 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio
2074220741
2074320742static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) {
2074420743 IrInstruction *value = ref_instruction->value->child;
20745 if (type_is_invalid(value->value.type))
20744 if (type_is_invalid(value->value->type))
2074620745 return ira->codegen->invalid_instruction;
2074720746 return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile);
2074820747}
......@@ -20768,13 +20767,13 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc
2076820767 if (type_is_invalid(type_field->type_entry))
2076920768 return ira->codegen->invalid_instruction;
2077020769
20771 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
20770 if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) {
2077220771 if (instr_is_comptime(field_result_loc) &&
20773 field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
20772 field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar)
2077420773 {
2077520774 // nothing
2077620775 } else {
20777 result_loc->value.special = ConstValSpecialRuntime;
20776 result_loc->value->special = ConstValSpecialRuntime;
2077820777 }
2077920778 }
2078020779
......@@ -20803,7 +20802,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
2080320802 }
2080420803 IrInstructionContainerInitFieldsField *field = &fields[0];
2080520804 IrInstruction *field_result_loc = field->result_loc->child;
20806 if (type_is_invalid(field_result_loc->value.type))
20805 if (type_is_invalid(field_result_loc->value->type))
2080720806 return ira->codegen->invalid_instruction;
2080820807
2080920808 return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name,
......@@ -20850,7 +20849,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
2085020849 IrInstructionContainerInitFieldsField *field = &fields[i];
2085120850
2085220851 IrInstruction *field_result_loc = field->result_loc->child;
20853 if (type_is_invalid(field_result_loc->value.type))
20852 if (type_is_invalid(field_result_loc->value->type))
2085420853 return ira->codegen->invalid_instruction;
2085520854
2085620855 TypeStructField *type_field = find_struct_type_field(container_type, field->name);
......@@ -20874,7 +20873,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
2087420873 field_assign_nodes[field_index] = field->source_node;
2087520874
2087620875 if (instr_is_comptime(field_result_loc) &&
20877 field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
20876 field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar)
2087820877 {
2087920878 const_ptrs.append(field_result_loc);
2088020879 } else {
......@@ -20912,12 +20911,12 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
2091220911 return ira->codegen->invalid_instruction;
2091320912
2091420913 IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type);
20915 copy_const_val(&runtime_inst->value, field->init_val, true);
20914 copy_const_val(runtime_inst->value, field->init_val, true);
2091620915
2091720916 IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc,
2091820917 container_type, true);
2091920918 ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false);
20920 if (instr_is_comptime(field_ptr) && field_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
20919 if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
2092120920 const_ptrs.append(field_ptr);
2092220921 } else {
2092320922 first_non_const_instruction = result_loc;
......@@ -20926,13 +20925,13 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
2092620925 if (any_missing)
2092720926 return ira->codegen->invalid_instruction;
2092820927
20929 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
20928 if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) {
2093020929 if (const_ptrs.length != actual_field_count) {
20931 result_loc->value.special = ConstValSpecialRuntime;
20930 result_loc->value->special = ConstValSpecialRuntime;
2093220931 for (size_t i = 0; i < const_ptrs.length; i += 1) {
2093320932 IrInstruction *field_result_loc = const_ptrs.at(i);
2093420933 IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr);
20935 field_result_loc->value.special = ConstValSpecialRuntime;
20934 field_result_loc->value->special = ConstValSpecialRuntime;
2093620935 ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false);
2093720936 }
2093820937 }
......@@ -20954,11 +20953,11 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2095420953{
2095520954 ir_assert(instruction->result_loc != nullptr, &instruction->base);
2095620955 IrInstruction *result_loc = instruction->result_loc->child;
20957 if (type_is_invalid(result_loc->value.type))
20956 if (type_is_invalid(result_loc->value->type))
2095820957 return result_loc;
20959 ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base);
20958 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base);
2096020959
20961 ZigType *container_type = result_loc->value.type->data.pointer.child_type;
20960 ZigType *container_type = result_loc->value->type->data.pointer.child_type;
2096220961
2096320962 size_t elem_count = instruction->item_count;
2096420963
......@@ -20980,7 +20979,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2098020979 if (container_type->id == ZigTypeIdStruct && elem_count == 0) {
2098120980 ir_assert(instruction->result_loc != nullptr, &instruction->base);
2098220981 IrInstruction *result_loc = instruction->result_loc->child;
20983 if (type_is_invalid(result_loc->value.type))
20982 if (type_is_invalid(result_loc->value->type))
2098420983 return result_loc;
2098520984 return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc);
2098620985 }
......@@ -21041,13 +21040,13 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2104121040
2104221041 for (size_t i = 0; i < elem_count; i += 1) {
2104321042 IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child;
21044 if (type_is_invalid(elem_result_loc->value.type))
21043 if (type_is_invalid(elem_result_loc->value->type))
2104521044 return ira->codegen->invalid_instruction;
2104621045
21047 assert(elem_result_loc->value.type->id == ZigTypeIdPointer);
21046 assert(elem_result_loc->value->type->id == ZigTypeIdPointer);
2104821047
2104921048 if (instr_is_comptime(elem_result_loc) &&
21050 elem_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
21049 elem_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar)
2105121050 {
2105221051 const_ptrs.append(elem_result_loc);
2105321052 } else {
......@@ -21055,14 +21054,14 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2105521054 }
2105621055 }
2105721056
21058 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) {
21057 if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) {
2105921058 if (const_ptrs.length != elem_count) {
21060 result_loc->value.special = ConstValSpecialRuntime;
21059 result_loc->value->special = ConstValSpecialRuntime;
2106121060 for (size_t i = 0; i < const_ptrs.length; i += 1) {
2106221061 IrInstruction *elem_result_loc = const_ptrs.at(i);
21063 assert(elem_result_loc->value.special == ConstValSpecialStatic);
21062 assert(elem_result_loc->value->special == ConstValSpecialStatic);
2106421063 IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr);
21065 elem_result_loc->value.special = ConstValSpecialRuntime;
21064 elem_result_loc->value->special = ConstValSpecialRuntime;
2106621065 ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false);
2106721066 }
2106821067 }
......@@ -21078,7 +21077,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
2107821077 return ira->codegen->invalid_instruction;
2107921078 }
2108021079
21081 ZigType *result_elem_type = result_loc->value.type->data.pointer.child_type;
21080 ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type;
2108221081 if (is_slice(result_elem_type)) {
2108321082 ErrorMsg *msg = ir_add_error(ira, &instruction->base,
2108421083 buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'",
......@@ -21095,11 +21094,11 @@ static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ir
2109521094{
2109621095 ir_assert(instruction->result_loc != nullptr, &instruction->base);
2109721096 IrInstruction *result_loc = instruction->result_loc->child;
21098 if (type_is_invalid(result_loc->value.type))
21097 if (type_is_invalid(result_loc->value->type))
2109921098 return result_loc;
2110021099
21101 ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base);
21102 ZigType *container_type = result_loc->value.type->data.pointer.child_type;
21100 ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base);
21101 ZigType *container_type = result_loc->value->type->data.pointer.child_type;
2110321102
2110421103 return ir_analyze_container_init_fields(ira, &instruction->base, container_type,
2110521104 instruction->field_count, instruction->fields, result_loc);
......@@ -21123,15 +21122,15 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr
2112321122 fprintf(stderr, "| ");
2112421123 for (size_t i = 0; i < instruction->msg_count; i += 1) {
2112521124 IrInstruction *msg = instruction->msg_list[i]->child;
21126 if (type_is_invalid(msg->value.type))
21125 if (type_is_invalid(msg->value->type))
2112721126 return ira->codegen->invalid_instruction;
2112821127 buf_resize(&buf, 0);
21129 if (msg->value.special == ConstValSpecialLazy) {
21128 if (msg->value->special == ConstValSpecialLazy) {
2113021129 // Resolve any lazy value that's passed, we need its value
21131 if (ir_resolve_lazy(ira->codegen, msg->source_node, &msg->value))
21130 if (ir_resolve_lazy(ira->codegen, msg->source_node, msg->value))
2113221131 return ira->codegen->invalid_instruction;
2113321132 }
21134 render_const_value(ira->codegen, &buf, &msg->value);
21133 render_const_value(ira->codegen, &buf, msg->value);
2113521134 const char *comma_str = (i != 0) ? ", " : "";
2113621135 fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf));
2113721136 }
......@@ -21150,11 +21149,11 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr
2115021149
2115121150static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) {
2115221151 IrInstruction *value = instruction->value->child;
21153 if (type_is_invalid(value->value.type))
21152 if (type_is_invalid(value->value->type))
2115421153 return ira->codegen->invalid_instruction;
2115521154
2115621155 IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set);
21157 if (type_is_invalid(casted_value->value.type))
21156 if (type_is_invalid(casted_value->value->type))
2115821157 return ira->codegen->invalid_instruction;
2115921158
2116021159 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
......@@ -21164,14 +21163,14 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct
2116421163 ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad);
2116521164 if (val == nullptr)
2116621165 return ira->codegen->invalid_instruction;
21167 ErrorTableEntry *err = casted_value->value.data.x_err_set;
21166 ErrorTableEntry *err = casted_value->value->data.x_err_set;
2116821167 if (!err->cached_error_name_val) {
2116921168 ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee;
2117021169 err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true);
2117121170 }
2117221171 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
21173 copy_const_val(&result->value, err->cached_error_name_val, true);
21174 result->value.type = str_type;
21172 copy_const_val(result->value, err->cached_error_name_val, true);
21173 result->value->type = str_type;
2117521174 return result;
2117621175 }
2117721176
......@@ -21179,25 +21178,25 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct
2117921178
2118021179 IrInstruction *result = ir_build_err_name(&ira->new_irb,
2118121180 instruction->base.scope, instruction->base.source_node, value);
21182 result->value.type = str_type;
21181 result->value->type = str_type;
2118321182 return result;
2118421183}
2118521184
2118621185static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) {
2118721186 Error err;
2118821187 IrInstruction *target = instruction->target->child;
21189 if (type_is_invalid(target->value.type))
21188 if (type_is_invalid(target->value->type))
2119021189 return ira->codegen->invalid_instruction;
2119121190
21192 assert(target->value.type->id == ZigTypeIdEnum);
21191 assert(target->value->type->id == ZigTypeIdEnum);
2119321192
2119421193 if (instr_is_comptime(target)) {
21195 if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown)))
21194 if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown)))
2119621195 return ira->codegen->invalid_instruction;
21197 TypeEnumField *field = find_enum_field_by_tag(target->value.type, &target->value.data.x_bigint);
21196 TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint);
2119821197 ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee;
2119921198 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
21200 init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true);
21199 init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true);
2120121200 return result;
2120221201 }
2120321202
......@@ -21207,7 +21206,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns
2120721206 ira->codegen, ira->codegen->builtin_types.entry_u8,
2120821207 true, false, PtrLenUnknown,
2120921208 0, 0, 0, false);
21210 result->value.type = get_slice_type(ira->codegen, u8_ptr_type);
21209 result->value->type = get_slice_type(ira->codegen, u8_ptr_type);
2121121210 return result;
2121221211}
2121321212
......@@ -21226,7 +21225,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2122621225 return ira->codegen->invalid_instruction;
2122721226
2122821227 IrInstruction *field_ptr = instruction->field_ptr->child;
21229 if (type_is_invalid(field_ptr->value.type))
21228 if (type_is_invalid(field_ptr->value->type))
2123021229 return ira->codegen->invalid_instruction;
2123121230
2123221231 if (container_type->id != ZigTypeIdStruct) {
......@@ -21246,9 +21245,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2124621245 return ira->codegen->invalid_instruction;
2124721246 }
2124821247
21249 if (field_ptr->value.type->id != ZigTypeIdPointer) {
21248 if (field_ptr->value->type->id != ZigTypeIdPointer) {
2125021249 ir_add_error(ira, field_ptr,
21251 buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name)));
21250 buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name)));
2125221251 return ira->codegen->invalid_instruction;
2125321252 }
2125421253
......@@ -21257,17 +21256,17 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2125721256 uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type);
2125821257
2125921258 ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,
21260 field_ptr->value.type->data.pointer.is_const,
21261 field_ptr->value.type->data.pointer.is_volatile,
21259 field_ptr->value->type->data.pointer.is_const,
21260 field_ptr->value->type->data.pointer.is_volatile,
2126221261 PtrLenSingle,
2126321262 field_ptr_align, 0, 0, false);
2126421263 IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type);
21265 if (type_is_invalid(casted_field_ptr->value.type))
21264 if (type_is_invalid(casted_field_ptr->value->type))
2126621265 return ira->codegen->invalid_instruction;
2126721266
2126821267 ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type,
21269 casted_field_ptr->value.type->data.pointer.is_const,
21270 casted_field_ptr->value.type->data.pointer.is_volatile,
21268 casted_field_ptr->value->type->data.pointer.is_const,
21269 casted_field_ptr->value->type->data.pointer.is_volatile,
2127121270 PtrLenSingle,
2127221271 parent_ptr_align, 0, 0, false);
2127321272
......@@ -21291,7 +21290,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2129121290 }
2129221291
2129321292 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
21294 ZigValue *out_val = &result->value;
21293 ZigValue *out_val = result->value;
2129521294 out_val->data.x_ptr.special = ConstPtrSpecialRef;
2129621295 out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val;
2129721296 out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut;
......@@ -21300,7 +21299,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2130021299
2130121300 IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope,
2130221301 instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field);
21303 result->value.type = result_type;
21302 result->value->type = result_type;
2130421303 return result;
2130521304}
2130621305
......@@ -21350,7 +21349,7 @@ static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira,
2135021349 IrInstructionByteOffsetOf *instruction)
2135121350{
2135221351 IrInstruction *type_value = instruction->type_value->child;
21353 if (type_is_invalid(type_value->value.type))
21352 if (type_is_invalid(type_value->value->type))
2135421353 return ira->codegen->invalid_instruction;
2135521354
2135621355 IrInstruction *field_name_value = instruction->field_name->child;
......@@ -21366,7 +21365,7 @@ static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira,
2136621365 IrInstructionBitOffsetOf *instruction)
2136721366{
2136821367 IrInstruction *type_value = instruction->type_value->child;
21369 if (type_is_invalid(type_value->value.type))
21368 if (type_is_invalid(type_value->value->type))
2137021369 return ira->codegen->invalid_instruction;
2137121370 IrInstruction *field_name_value = instruction->field_name->child;
2137221371 size_t byte_offset = 0;
......@@ -22381,7 +22380,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
2238122380 return ira->codegen->invalid_instruction;
2238222381
2238322382 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
22384 ZigValue *out_val = &result->value;
22383 ZigValue *out_val = result->value;
2238522384 bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry));
2238622385 out_val->data.x_union.payload = payload;
2238722386
......@@ -22407,10 +22406,10 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst
2240722406 IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type);
2240822407 IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst,
2240922408 get_optional_type(ira->codegen, elem_type));
22410 if (type_is_invalid(casted_field_inst->value.type))
22409 if (type_is_invalid(casted_field_inst->value->type))
2241122410 return ErrorSemanticAnalyzeFail;
2241222411
22413 *result = casted_field_inst->value.data.x_optional;
22412 *result = casted_field_inst->value->data.x_optional;
2241422413 return ErrorNone;
2241522414}
2241622415
......@@ -22549,11 +22548,11 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi
2254922548
2255022549static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) {
2255122550 IrInstruction *type_info_ir = instruction->type_info->child;
22552 if (type_is_invalid(type_info_ir->value.type))
22551 if (type_is_invalid(type_info_ir->value->type))
2255322552 return ira->codegen->invalid_instruction;
2255422553
2255522554 IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr));
22556 if (type_is_invalid(casted_ir->value.type))
22555 if (type_is_invalid(casted_ir->value->type))
2255722556 return ira->codegen->invalid_instruction;
2255822557
2255922558 ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad);
......@@ -22579,7 +22578,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
2257922578 ZigType *result_type = var_value->data.x_type;
2258022579
2258122580 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
22582 bigint_init_unsigned(&result->value.data.x_enum_tag, type_id_index(type_entry));
22581 bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry));
2258322582 return result;
2258422583}
2258522584
......@@ -22607,7 +22606,7 @@ static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstruc
2260722606 type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry));
2260822607 }
2260922608 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
22610 copy_const_val(&result->value, type_entry->cached_const_name_val, true);
22609 copy_const_val(result->value, type_entry->cached_const_name_val, true);
2261122610 return result;
2261222611}
2261322612
......@@ -22796,7 +22795,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
2279622795
2279722796static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) {
2279822797 IrInstruction *name_value = instruction->name->child;
22799 if (type_is_invalid(name_value->value.type))
22798 if (type_is_invalid(name_value->value->type))
2280022799 return ira->codegen->invalid_instruction;
2280122800
2280222801 Buf *include_name = ir_resolve_str(ira, name_value);
......@@ -22814,7 +22813,7 @@ static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstruc
2281422813
2281522814static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) {
2281622815 IrInstruction *name = instruction->name->child;
22817 if (type_is_invalid(name->value.type))
22816 if (type_is_invalid(name->value->type))
2281822817 return ira->codegen->invalid_instruction;
2281922818
2282022819 Buf *define_name = ir_resolve_str(ira, name);
......@@ -22822,12 +22821,12 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct
2282222821 return ira->codegen->invalid_instruction;
2282322822
2282422823 IrInstruction *value = instruction->value->child;
22825 if (type_is_invalid(value->value.type))
22824 if (type_is_invalid(value->value->type))
2282622825 return ira->codegen->invalid_instruction;
2282722826
2282822827 Buf *define_value = nullptr;
2282922828 // The second parameter is either a string or void (equivalent to "")
22830 if (value->value.type->id != ZigTypeIdVoid) {
22829 if (value->value->type->id != ZigTypeIdVoid) {
2283122830 define_value = ir_resolve_str(ira, value);
2283222831 if (!define_value)
2283322832 return ira->codegen->invalid_instruction;
......@@ -22845,7 +22844,7 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct
2284522844
2284622845static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) {
2284722846 IrInstruction *name = instruction->name->child;
22848 if (type_is_invalid(name->value.type))
22847 if (type_is_invalid(name->value->type))
2284922848 return ira->codegen->invalid_instruction;
2285022849
2285122850 Buf *undef_name = ir_resolve_str(ira, name);
......@@ -22863,7 +22862,7 @@ static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructi
2286322862
2286422863static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) {
2286522864 IrInstruction *name = instruction->name->child;
22866 if (type_is_invalid(name->value.type))
22865 if (type_is_invalid(name->value->type))
2286722866 return ira->codegen->invalid_instruction;
2286822867
2286922868 Buf *rel_file_path = ir_resolve_str(ira, name);
......@@ -22898,7 +22897,7 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru
2289822897 ZigType *result_type = get_array_type(ira->codegen,
2289922898 ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr);
2290022899 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
22901 init_const_str_lit(ira->codegen, &result->value, file_contents);
22900 init_const_str_lit(ira->codegen, result->value, file_contents);
2290222901 return result;
2290322902}
2290422903
......@@ -22908,25 +22907,25 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2290822907 return ira->codegen->invalid_instruction;
2290922908
2291022909 IrInstruction *ptr = instruction->ptr->child;
22911 if (type_is_invalid(ptr->value.type))
22910 if (type_is_invalid(ptr->value->type))
2291222911 return ira->codegen->invalid_instruction;
2291322912
2291422913 // TODO let this be volatile
2291522914 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
2291622915 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);
22917 if (type_is_invalid(casted_ptr->value.type))
22916 if (type_is_invalid(casted_ptr->value->type))
2291822917 return ira->codegen->invalid_instruction;
2291922918
2292022919 IrInstruction *cmp_value = instruction->cmp_value->child;
22921 if (type_is_invalid(cmp_value->value.type))
22920 if (type_is_invalid(cmp_value->value->type))
2292222921 return ira->codegen->invalid_instruction;
2292322922
2292422923 IrInstruction *new_value = instruction->new_value->child;
22925 if (type_is_invalid(new_value->value.type))
22924 if (type_is_invalid(new_value->value->type))
2292622925 return ira->codegen->invalid_instruction;
2292722926
2292822927 IrInstruction *success_order_value = instruction->success_order_value->child;
22929 if (type_is_invalid(success_order_value->value.type))
22928 if (type_is_invalid(success_order_value->value->type))
2293022929 return ira->codegen->invalid_instruction;
2293122930
2293222931 AtomicOrder success_order;
......@@ -22934,7 +22933,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2293422933 return ira->codegen->invalid_instruction;
2293522934
2293622935 IrInstruction *failure_order_value = instruction->failure_order_value->child;
22937 if (type_is_invalid(failure_order_value->value.type))
22936 if (type_is_invalid(failure_order_value->value->type))
2293822937 return ira->codegen->invalid_instruction;
2293922938
2294022939 AtomicOrder failure_order;
......@@ -22942,11 +22941,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2294222941 return ira->codegen->invalid_instruction;
2294322942
2294422943 IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type);
22945 if (type_is_invalid(casted_cmp_value->value.type))
22944 if (type_is_invalid(casted_cmp_value->value->type))
2294622945 return ira->codegen->invalid_instruction;
2294722946
2294822947 IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type);
22949 if (type_is_invalid(casted_new_value->value.type))
22948 if (type_is_invalid(casted_new_value->value->type))
2295022949 return ira->codegen->invalid_instruction;
2295122950
2295222951 if (success_order < AtomicOrderMonotonic) {
......@@ -22970,7 +22969,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2297022969 return ira->codegen->invalid_instruction;
2297122970 }
2297222971
22973 if (instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar &&
22972 if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar &&
2297422973 instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) {
2297522974 zig_panic("TODO compile-time execution of cmpxchg");
2297622975 }
......@@ -22980,7 +22979,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2298022979 if (handle_is_ptr(result_type)) {
2298122980 result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
2298222981 result_type, nullptr, true, false, true);
22983 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
22982 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
2298422983 return result_loc;
2298522984 }
2298622985 } else {
......@@ -22994,7 +22993,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi
2299422993
2299522994static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) {
2299622995 IrInstruction *order_value = instruction->order_value->child;
22997 if (type_is_invalid(order_value->value.type))
22996 if (type_is_invalid(order_value->value->type))
2299822997 return ira->codegen->invalid_instruction;
2299922998
2300022999 AtomicOrder order;
......@@ -23009,7 +23008,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
2300923008
2301023009 IrInstruction *result = ir_build_fence(&ira->new_irb,
2301123010 instruction->base.scope, instruction->base.source_node, order_value, order);
23012 result->value.type = ira->codegen->builtin_types.entry_void;
23011 result->value->type = ira->codegen->builtin_types.entry_void;
2301323012 return result;
2301423013}
2301523014
......@@ -23027,7 +23026,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
2302723026 }
2302823027
2302923028 IrInstruction *target = instruction->target->child;
23030 ZigType *src_type = target->value.type;
23029 ZigType *src_type = target->value->type;
2303123030 if (type_is_invalid(src_type))
2303223031 return ira->codegen->invalid_instruction;
2303323032
......@@ -23048,14 +23047,14 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
2304823047 return ira->codegen->invalid_instruction;
2304923048
2305023049 IrInstruction *result = ir_const(ira, &instruction->base, dest_type);
23051 bigint_truncate(&result->value.data.x_bigint, &val->data.x_bigint,
23050 bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint,
2305223051 dest_type->data.integral.bit_count, dest_type->data.integral.is_signed);
2305323052 return result;
2305423053 }
2305523054
2305623055 if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) {
2305723056 IrInstruction *result = ir_const(ira, &instruction->base, dest_type);
23058 bigint_init_unsigned(&result->value.data.x_bigint, 0);
23057 bigint_init_unsigned(&result->value->data.x_bigint, 0);
2305923058 return result;
2306023059 }
2306123060
......@@ -23071,7 +23070,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
2307123070
2307223071 IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope,
2307323072 instruction->base.source_node, dest_type_value, target);
23074 new_instruction->value.type = dest_type;
23073 new_instruction->value->type = dest_type;
2307523074 return new_instruction;
2307623075}
2307723076
......@@ -23086,12 +23085,12 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
2308623085 }
2308723086
2308823087 IrInstruction *target = instruction->target->child;
23089 if (type_is_invalid(target->value.type))
23088 if (type_is_invalid(target->value->type))
2309023089 return ira->codegen->invalid_instruction;
2309123090
23092 if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) {
23091 if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) {
2309323092 ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'",
23094 buf_ptr(&target->value.type->name)));
23093 buf_ptr(&target->value->type->name)));
2309523094 return ira->codegen->invalid_instruction;
2309623095 }
2309723096
......@@ -23120,15 +23119,15 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru
2312023119 }
2312123120
2312223121 IrInstruction *target = instruction->target->child;
23123 if (type_is_invalid(target->value.type))
23122 if (type_is_invalid(target->value->type))
2312423123 return ira->codegen->invalid_instruction;
2312523124
23126 if (target->value.type->id == ZigTypeIdComptimeInt ||
23127 target->value.type->id == ZigTypeIdComptimeFloat)
23125 if (target->value->type->id == ZigTypeIdComptimeInt ||
23126 target->value->type->id == ZigTypeIdComptimeFloat)
2312823127 {
2312923128 if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) {
2313023129 CastOp op;
23131 if (target->value.type->id == ZigTypeIdComptimeInt) {
23130 if (target->value->type->id == ZigTypeIdComptimeInt) {
2313223131 op = CastOpIntToFloat;
2313323132 } else {
2313423133 op = CastOpNumLitToConcrete;
......@@ -23139,9 +23138,9 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru
2313923138 }
2314023139 }
2314123140
23142 if (target->value.type->id != ZigTypeIdFloat) {
23141 if (target->value->type->id != ZigTypeIdFloat) {
2314323142 ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'",
23144 buf_ptr(&target->value.type->name)));
23143 buf_ptr(&target->value->type->name)));
2314523144 return ira->codegen->invalid_instruction;
2314623145 }
2314723146
......@@ -23160,12 +23159,12 @@ static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInst
2316023159 }
2316123160
2316223161 IrInstruction *target = instruction->target->child;
23163 if (type_is_invalid(target->value.type))
23162 if (type_is_invalid(target->value->type))
2316423163 return ira->codegen->invalid_instruction;
2316523164
23166 if (target->value.type->id != ZigTypeIdErrorSet) {
23165 if (target->value->type->id != ZigTypeIdErrorSet) {
2316723166 ir_add_error(ira, instruction->target,
23168 buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value.type->name)));
23167 buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name)));
2316923168 return ira->codegen->invalid_instruction;
2317023169 }
2317123170
......@@ -23180,20 +23179,20 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2318023179 return ira->codegen->invalid_instruction;
2318123180
2318223181 IrInstruction *target = instruction->target->child;
23183 if (type_is_invalid(target->value.type))
23182 if (type_is_invalid(target->value->type))
2318423183 return ira->codegen->invalid_instruction;
2318523184
2318623185 bool src_ptr_const;
2318723186 bool src_ptr_volatile;
2318823187 uint32_t src_ptr_align;
23189 if (target->value.type->id == ZigTypeIdPointer) {
23190 src_ptr_const = target->value.type->data.pointer.is_const;
23191 src_ptr_volatile = target->value.type->data.pointer.is_volatile;
23188 if (target->value->type->id == ZigTypeIdPointer) {
23189 src_ptr_const = target->value->type->data.pointer.is_const;
23190 src_ptr_volatile = target->value->type->data.pointer.is_volatile;
2319223191
23193 if ((err = resolve_ptr_align(ira, target->value.type, &src_ptr_align)))
23192 if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align)))
2319423193 return ira->codegen->invalid_instruction;
23195 } else if (is_slice(target->value.type)) {
23196 ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry;
23194 } else if (is_slice(target->value->type)) {
23195 ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry;
2319723196 src_ptr_const = src_ptr_type->data.pointer.is_const;
2319823197 src_ptr_volatile = src_ptr_type->data.pointer.is_volatile;
2319923198
......@@ -23203,10 +23202,10 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2320323202 src_ptr_const = true;
2320423203 src_ptr_volatile = false;
2320523204
23206 if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusAlignmentKnown)))
23205 if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown)))
2320723206 return ira->codegen->invalid_instruction;
2320823207
23209 src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);
23208 src_ptr_align = get_abi_alignment(ira->codegen, target->value->type);
2321023209 }
2321123210
2321223211 if (src_ptr_align != 0) {
......@@ -23225,7 +23224,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2322523224 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
2322623225
2322723226 IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice);
23228 if (type_is_invalid(casted_value->value.type))
23227 if (type_is_invalid(casted_value->value->type))
2322923228 return ira->codegen->invalid_instruction;
2323023229
2323123230 bool have_known_len = false;
......@@ -23245,12 +23244,12 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2324523244
2324623245 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
2324723246 dest_slice_type, nullptr, true, false, true);
23248 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) {
23247 if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) {
2324923248 return result_loc;
2325023249 }
2325123250
23252 if (casted_value->value.data.rh_slice.id == RuntimeHintSliceIdLen) {
23253 known_len = casted_value->value.data.rh_slice.len;
23251 if (casted_value->value->data.rh_slice.id == RuntimeHintSliceIdLen) {
23252 known_len = casted_value->value->data.rh_slice.len;
2325423253 have_known_len = true;
2325523254 }
2325623255
......@@ -23277,16 +23276,16 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
2327723276 Error err;
2327823277
2327923278 IrInstruction *target = instruction->target->child;
23280 if (type_is_invalid(target->value.type))
23279 if (type_is_invalid(target->value->type))
2328123280 return ira->codegen->invalid_instruction;
2328223281
23283 if (!is_slice(target->value.type)) {
23282 if (!is_slice(target->value->type)) {
2328423283 ir_add_error(ira, instruction->target,
23285 buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name)));
23284 buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name)));
2328623285 return ira->codegen->invalid_instruction;
2328723286 }
2328823287
23289 ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry;
23288 ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry;
2329023289
2329123290 uint32_t alignment;
2329223291 if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment)))
......@@ -23303,14 +23302,14 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
2330323302 return ira->codegen->invalid_instruction;
2330423303
2330523304 IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type);
23306 result->value.data.x_struct.fields = alloc_const_vals_ptrs(2);
23305 result->value->data.x_struct.fields = alloc_const_vals_ptrs(2);
2330723306
23308 ZigValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index];
23307 ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index];
2330923308 ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index];
2331023309 copy_const_val(ptr_val, target_ptr_val, false);
2331123310 ptr_val->type = dest_ptr_type;
2331223311
23313 ZigValue *len_val = result->value.data.x_struct.fields[slice_len_index];
23312 ZigValue *len_val = result->value->data.x_struct.fields[slice_len_index];
2331423313 len_val->special = ConstValSpecialStatic;
2331523314 len_val->type = ira->codegen->builtin_types.entry_usize;
2331623315 ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index];
......@@ -23324,7 +23323,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
2332423323
2332523324 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
2332623325 dest_slice_type, nullptr, true, false, true);
23327 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
23326 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
2332823327 return result_loc;
2332923328 }
2333023329
......@@ -23351,12 +23350,12 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst
2335123350 return ira->codegen->invalid_instruction;
2335223351
2335323352 IrInstruction *target = instruction->target->child;
23354 if (type_is_invalid(target->value.type))
23353 if (type_is_invalid(target->value->type))
2335523354 return ira->codegen->invalid_instruction;
2335623355
23357 if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) {
23356 if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) {
2335823357 ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'",
23359 buf_ptr(&target->value.type->name)));
23358 buf_ptr(&target->value->type->name)));
2336023359 return ira->codegen->invalid_instruction;
2336123360 }
2336223361
......@@ -23369,16 +23368,16 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst
2336923368 return ira->codegen->invalid_instruction;
2337023369
2337123370 IrInstruction *target = instruction->target->child;
23372 if (type_is_invalid(target->value.type))
23371 if (type_is_invalid(target->value->type))
2337323372 return ira->codegen->invalid_instruction;
2337423373
23375 if (target->value.type->id == ZigTypeIdComptimeInt) {
23374 if (target->value->type->id == ZigTypeIdComptimeInt) {
2337623375 return ir_implicit_cast(ira, target, dest_type);
2337723376 }
2337823377
23379 if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) {
23378 if (target->value->type->id != ZigTypeIdFloat && target->value->type->id != ZigTypeIdComptimeFloat) {
2338023379 ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'",
23381 buf_ptr(&target->value.type->name)));
23380 buf_ptr(&target->value->type->name)));
2338223381 return ira->codegen->invalid_instruction;
2338323382 }
2338423383
......@@ -23387,15 +23386,15 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst
2338723386
2338823387static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) {
2338923388 IrInstruction *target = instruction->target->child;
23390 if (type_is_invalid(target->value.type))
23389 if (type_is_invalid(target->value->type))
2339123390 return ira->codegen->invalid_instruction;
2339223391
2339323392 IrInstruction *casted_target;
23394 if (target->value.type->id == ZigTypeIdErrorSet) {
23393 if (target->value->type->id == ZigTypeIdErrorSet) {
2339523394 casted_target = target;
2339623395 } else {
2339723396 casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set);
23398 if (type_is_invalid(casted_target->value.type))
23397 if (type_is_invalid(casted_target->value->type))
2339923398 return ira->codegen->invalid_instruction;
2340023399 }
2340123400
......@@ -23404,11 +23403,11 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru
2340423403
2340523404static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) {
2340623405 IrInstruction *target = instruction->target->child;
23407 if (type_is_invalid(target->value.type))
23406 if (type_is_invalid(target->value->type))
2340823407 return ira->codegen->invalid_instruction;
2340923408
2341023409 IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type);
23411 if (type_is_invalid(casted_target->value.type))
23410 if (type_is_invalid(casted_target->value->type))
2341223411 return ira->codegen->invalid_instruction;
2341323412
2341423413 return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set);
......@@ -23416,12 +23415,12 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru
2341623415
2341723416static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) {
2341823417 IrInstruction *target = instruction->target->child;
23419 if (type_is_invalid(target->value.type))
23418 if (type_is_invalid(target->value->type))
2342023419 return ira->codegen->invalid_instruction;
2342123420
23422 if (target->value.type->id != ZigTypeIdBool) {
23421 if (target->value->type->id != ZigTypeIdBool) {
2342323422 ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'",
23424 buf_ptr(&target->value.type->name)));
23423 buf_ptr(&target->value->type->name)));
2342523424 return ira->codegen->invalid_instruction;
2342623425 }
2342723426
......@@ -23472,48 +23471,48 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2347223471 ir_assert(is_valid_vector_elem_type(scalar_type), source_instr);
2347323472
2347423473 uint32_t len_mask;
23475 if (mask->value.type->id == ZigTypeIdVector) {
23476 len_mask = mask->value.type->data.vector.len;
23477 } else if (mask->value.type->id == ZigTypeIdArray) {
23478 len_mask = mask->value.type->data.array.len;
23474 if (mask->value->type->id == ZigTypeIdVector) {
23475 len_mask = mask->value->type->data.vector.len;
23476 } else if (mask->value->type->id == ZigTypeIdArray) {
23477 len_mask = mask->value->type->data.array.len;
2347923478 } else {
2348023479 ir_add_error(ira, mask,
2348123480 buf_sprintf("expected vector or array, found '%s'",
23482 buf_ptr(&mask->value.type->name)));
23481 buf_ptr(&mask->value->type->name)));
2348323482 return ira->codegen->invalid_instruction;
2348423483 }
2348523484 mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask,
2348623485 ira->codegen->builtin_types.entry_i32));
23487 if (type_is_invalid(mask->value.type))
23486 if (type_is_invalid(mask->value->type))
2348823487 return ira->codegen->invalid_instruction;
2348923488
2349023489 uint32_t len_a;
23491 if (a->value.type->id == ZigTypeIdVector) {
23492 len_a = a->value.type->data.vector.len;
23493 } else if (a->value.type->id == ZigTypeIdArray) {
23494 len_a = a->value.type->data.array.len;
23495 } else if (a->value.type->id == ZigTypeIdUndefined) {
23490 if (a->value->type->id == ZigTypeIdVector) {
23491 len_a = a->value->type->data.vector.len;
23492 } else if (a->value->type->id == ZigTypeIdArray) {
23493 len_a = a->value->type->data.array.len;
23494 } else if (a->value->type->id == ZigTypeIdUndefined) {
2349623495 len_a = UINT32_MAX;
2349723496 } else {
2349823497 ir_add_error(ira, a,
2349923498 buf_sprintf("expected vector or array with element type '%s', found '%s'",
2350023499 buf_ptr(&scalar_type->name),
23501 buf_ptr(&a->value.type->name)));
23500 buf_ptr(&a->value->type->name)));
2350223501 return ira->codegen->invalid_instruction;
2350323502 }
2350423503
2350523504 uint32_t len_b;
23506 if (b->value.type->id == ZigTypeIdVector) {
23507 len_b = b->value.type->data.vector.len;
23508 } else if (b->value.type->id == ZigTypeIdArray) {
23509 len_b = b->value.type->data.array.len;
23510 } else if (b->value.type->id == ZigTypeIdUndefined) {
23505 if (b->value->type->id == ZigTypeIdVector) {
23506 len_b = b->value->type->data.vector.len;
23507 } else if (b->value->type->id == ZigTypeIdArray) {
23508 len_b = b->value->type->data.array.len;
23509 } else if (b->value->type->id == ZigTypeIdUndefined) {
2351123510 len_b = UINT32_MAX;
2351223511 } else {
2351323512 ir_add_error(ira, b,
2351423513 buf_sprintf("expected vector or array with element type '%s', found '%s'",
2351523514 buf_ptr(&scalar_type->name),
23516 buf_ptr(&b->value.type->name)));
23515 buf_ptr(&b->value->type->name)));
2351723516 return ira->codegen->invalid_instruction;
2351823517 }
2351923518
......@@ -23526,7 +23525,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2352623525 a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));
2352723526 } else {
2352823527 a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type));
23529 if (type_is_invalid(a->value.type))
23528 if (type_is_invalid(a->value->type))
2353023529 return ira->codegen->invalid_instruction;
2353123530 }
2353223531
......@@ -23535,7 +23534,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2353523534 b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));
2353623535 } else {
2353723536 b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type));
23538 if (type_is_invalid(b->value.type))
23537 if (type_is_invalid(b->value->type))
2353923538 return ira->codegen->invalid_instruction;
2354023539 }
2354123540
......@@ -23559,12 +23558,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2355923558 v = (uint32_t)~v_i32;
2356023559 chosen_operand = b;
2356123560 }
23562 if (v >= chosen_operand->value.type->data.vector.len) {
23561 if (v >= chosen_operand->value->type->data.vector.len) {
2356323562 ErrorMsg *msg = ir_add_error(ira, mask,
2356423563 buf_sprintf("mask index '%u' has out-of-bounds selection", i));
2356523564 add_error_note(ira->codegen, msg, chosen_operand->source_node,
2356623565 buf_sprintf("selected index '%u' out of bounds of %s", v,
23567 buf_ptr(&chosen_operand->value.type->name)));
23566 buf_ptr(&chosen_operand->value->type->name)));
2356823567 if (chosen_operand == a && v < len_a + len_b) {
2356923568 add_error_note(ira->codegen, msg, b->source_node,
2357023569 buf_create_from_str("selections from the second vector are specified with negative numbers"));
......@@ -23587,10 +23586,10 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2358723586 expand_undef_array(ira->codegen, b_val);
2358823587
2358923588 IrInstruction *result = ir_const(ira, source_instr, result_type);
23590 result->value.data.x_array.data.s_none.elements = create_const_vals(len_mask);
23589 result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask);
2359123590 for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) {
2359223591 ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i];
23593 ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i];
23592 ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i];
2359423593 if (mask_elem_val->special == ConstValSpecialUndef) {
2359523594 result_elem_val->special = ConstValSpecialUndef;
2359623595 continue;
......@@ -23598,13 +23597,13 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2359823597 int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint);
2359923598 // We've already checked for and emitted compile errors for index out of bounds here.
2360023599 ZigValue *src_elem_val = (v >= 0) ?
23601 &a->value.data.x_array.data.s_none.elements[v] :
23602 &b->value.data.x_array.data.s_none.elements[~v];
23600 &a->value->data.x_array.data.s_none.elements[v] :
23601 &b->value->data.x_array.data.s_none.elements[~v];
2360323602 copy_const_val(result_elem_val, src_elem_val, false);
2360423603
2360523604 ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr);
2360623605 }
23607 result->value.special = ConstValSpecialStatic;
23606 result->value->special = ConstValSpecialStatic;
2360823607 return result;
2360923608 }
2361023609
......@@ -23620,12 +23619,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2362023619
2362123620 IrInstruction *expand_mask = ir_const(ira, mask,
2362223621 get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32));
23623 expand_mask->value.data.x_array.data.s_none.elements = create_const_vals(len_max);
23622 expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max);
2362423623 uint32_t i = 0;
2362523624 for (; i < len_min; i += 1)
23626 bigint_init_unsigned(&expand_mask->value.data.x_array.data.s_none.elements[i].data.x_bigint, i);
23625 bigint_init_unsigned(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, i);
2362723626 for (; i < len_max; i += 1)
23628 bigint_init_signed(&expand_mask->value.data.x_array.data.s_none.elements[i].data.x_bigint, -1);
23627 bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1);
2362923628
2363023629 IrInstruction *undef = ir_const_undef(ira, source_instr,
2363123630 get_vector_type(ira->codegen, len_min, scalar_type));
......@@ -23640,7 +23639,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2364023639 IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb,
2364123640 source_instr->scope, source_instr->source_node,
2364223641 nullptr, a, b, mask);
23643 result->value.type = result_type;
23642 result->value->type = result_type;
2364423643 return result;
2364523644}
2364623645
......@@ -23650,15 +23649,15 @@ static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrIn
2365023649 return ira->codegen->invalid_instruction;
2365123650
2365223651 IrInstruction *a = instruction->a->child;
23653 if (type_is_invalid(a->value.type))
23652 if (type_is_invalid(a->value->type))
2365423653 return ira->codegen->invalid_instruction;
2365523654
2365623655 IrInstruction *b = instruction->b->child;
23657 if (type_is_invalid(b->value.type))
23656 if (type_is_invalid(b->value->type))
2365823657 return ira->codegen->invalid_instruction;
2365923658
2366023659 IrInstruction *mask = instruction->mask->child;
23661 if (type_is_invalid(mask->value.type))
23660 if (type_is_invalid(mask->value->type))
2366223661 return ira->codegen->invalid_instruction;
2366323662
2366423663 return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask);
......@@ -23668,11 +23667,11 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction
2366823667 Error err;
2366923668
2367023669 IrInstruction *len = instruction->len->child;
23671 if (type_is_invalid(len->value.type))
23670 if (type_is_invalid(len->value->type))
2367223671 return ira->codegen->invalid_instruction;
2367323672
2367423673 IrInstruction *scalar = instruction->scalar->child;
23675 if (type_is_invalid(scalar->value.type))
23674 if (type_is_invalid(scalar->value->type))
2367623675 return ira->codegen->invalid_instruction;
2367723676
2367823677 uint64_t len_u64;
......@@ -23680,10 +23679,10 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction
2368023679 return ira->codegen->invalid_instruction;
2368123680 uint32_t len_int = len_u64;
2368223681
23683 if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value.type)))
23682 if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value->type)))
2368423683 return ira->codegen->invalid_instruction;
2368523684
23686 ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type);
23685 ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type);
2368723686
2368823687 if (instr_is_comptime(scalar)) {
2368923688 ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk);
......@@ -23693,9 +23692,9 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction
2369323692 return ir_const_undef(ira, &instruction->base, return_type);
2369423693
2369523694 IrInstruction *result = ir_const(ira, &instruction->base, return_type);
23696 result->value.data.x_array.data.s_none.elements = create_const_vals(len_int);
23695 result->value->data.x_array.data.s_none.elements = create_const_vals(len_int);
2369723696 for (uint32_t i = 0; i < len_int; i += 1) {
23698 copy_const_val(&result->value.data.x_array.data.s_none.elements[i], scalar_val, false);
23697 copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val, false);
2369923698 }
2370023699 return result;
2370123700 }
......@@ -23705,13 +23704,13 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction
2370523704
2370623705static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) {
2370723706 IrInstruction *value = instruction->value->child;
23708 if (type_is_invalid(value->value.type))
23707 if (type_is_invalid(value->value->type))
2370923708 return ira->codegen->invalid_instruction;
2371023709
2371123710 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
2371223711
2371323712 IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type);
23714 if (type_is_invalid(casted_value->value.type))
23713 if (type_is_invalid(casted_value->value->type))
2371523714 return ira->codegen->invalid_instruction;
2371623715
2371723716 if (instr_is_comptime(casted_value)) {
......@@ -23724,7 +23723,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct
2372423723
2372523724 IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope,
2372623725 instruction->base.source_node, casted_value);
23727 result->value.type = bool_type;
23726 result->value->type = bool_type;
2372823727 return result;
2372923728}
2373023729
......@@ -23732,18 +23731,18 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2373223731 Error err;
2373323732
2373423733 IrInstruction *dest_ptr = instruction->dest_ptr->child;
23735 if (type_is_invalid(dest_ptr->value.type))
23734 if (type_is_invalid(dest_ptr->value->type))
2373623735 return ira->codegen->invalid_instruction;
2373723736
2373823737 IrInstruction *byte_value = instruction->byte->child;
23739 if (type_is_invalid(byte_value->value.type))
23738 if (type_is_invalid(byte_value->value->type))
2374023739 return ira->codegen->invalid_instruction;
2374123740
2374223741 IrInstruction *count_value = instruction->count->child;
23743 if (type_is_invalid(count_value->value.type))
23742 if (type_is_invalid(count_value->value->type))
2374423743 return ira->codegen->invalid_instruction;
2374523744
23746 ZigType *dest_uncasted_type = dest_ptr->value.type;
23745 ZigType *dest_uncasted_type = dest_ptr->value->type;
2374723746 bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) &&
2374823747 dest_uncasted_type->data.pointer.is_volatile;
2374923748
......@@ -23760,15 +23759,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2376023759 PtrLenUnknown, dest_align, 0, 0, false);
2376123760
2376223761 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);
23763 if (type_is_invalid(casted_dest_ptr->value.type))
23762 if (type_is_invalid(casted_dest_ptr->value->type))
2376423763 return ira->codegen->invalid_instruction;
2376523764
2376623765 IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8);
23767 if (type_is_invalid(casted_byte->value.type))
23766 if (type_is_invalid(casted_byte->value->type))
2376823767 return ira->codegen->invalid_instruction;
2376923768
2377023769 IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize);
23771 if (type_is_invalid(casted_count->value.type))
23770 if (type_is_invalid(casted_count->value->type))
2377223771 return ira->codegen->invalid_instruction;
2377323772
2377423773 // TODO test this at comptime with u8 and non-u8 types
......@@ -23788,8 +23787,8 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2378823787 if (count_val == nullptr)
2378923788 return ira->codegen->invalid_instruction;
2379023789
23791 if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr &&
23792 casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
23790 if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr &&
23791 casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar)
2379323792 {
2379423793 ZigValue *dest_elements;
2379523794 size_t start;
......@@ -23845,7 +23844,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2384523844
2384623845 IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node,
2384723846 casted_dest_ptr, casted_byte, casted_count);
23848 result->value.type = ira->codegen->builtin_types.entry_void;
23847 result->value->type = ira->codegen->builtin_types.entry_void;
2384923848 return result;
2385023849}
2385123850
......@@ -23853,20 +23852,20 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2385323852 Error err;
2385423853
2385523854 IrInstruction *dest_ptr = instruction->dest_ptr->child;
23856 if (type_is_invalid(dest_ptr->value.type))
23855 if (type_is_invalid(dest_ptr->value->type))
2385723856 return ira->codegen->invalid_instruction;
2385823857
2385923858 IrInstruction *src_ptr = instruction->src_ptr->child;
23860 if (type_is_invalid(src_ptr->value.type))
23859 if (type_is_invalid(src_ptr->value->type))
2386123860 return ira->codegen->invalid_instruction;
2386223861
2386323862 IrInstruction *count_value = instruction->count->child;
23864 if (type_is_invalid(count_value->value.type))
23863 if (type_is_invalid(count_value->value->type))
2386523864 return ira->codegen->invalid_instruction;
2386623865
2386723866 ZigType *u8 = ira->codegen->builtin_types.entry_u8;
23868 ZigType *dest_uncasted_type = dest_ptr->value.type;
23869 ZigType *src_uncasted_type = src_ptr->value.type;
23867 ZigType *dest_uncasted_type = dest_ptr->value->type;
23868 ZigType *src_uncasted_type = src_ptr->value->type;
2387023869 bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) &&
2387123870 dest_uncasted_type->data.pointer.is_volatile;
2387223871 bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) &&
......@@ -23895,15 +23894,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2389523894 PtrLenUnknown, src_align, 0, 0, false);
2389623895
2389723896 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);
23898 if (type_is_invalid(casted_dest_ptr->value.type))
23897 if (type_is_invalid(casted_dest_ptr->value->type))
2389923898 return ira->codegen->invalid_instruction;
2390023899
2390123900 IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const);
23902 if (type_is_invalid(casted_src_ptr->value.type))
23901 if (type_is_invalid(casted_src_ptr->value->type))
2390323902 return ira->codegen->invalid_instruction;
2390423903
2390523904 IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize);
23906 if (type_is_invalid(casted_count->value.type))
23905 if (type_is_invalid(casted_count->value->type))
2390723906 return ira->codegen->invalid_instruction;
2390823907
2390923908 // TODO test this at comptime with u8 and non-u8 types
......@@ -24024,35 +24023,35 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2402424023
2402524024 IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node,
2402624025 casted_dest_ptr, casted_src_ptr, casted_count);
24027 result->value.type = ira->codegen->builtin_types.entry_void;
24026 result->value->type = ira->codegen->builtin_types.entry_void;
2402824027 return result;
2402924028}
2403024029
2403124030static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) {
2403224031 IrInstruction *ptr_ptr = instruction->ptr->child;
24033 if (type_is_invalid(ptr_ptr->value.type))
24032 if (type_is_invalid(ptr_ptr->value->type))
2403424033 return ira->codegen->invalid_instruction;
2403524034
24036 ZigType *ptr_ptr_type = ptr_ptr->value.type;
24035 ZigType *ptr_ptr_type = ptr_ptr->value->type;
2403724036 assert(ptr_ptr_type->id == ZigTypeIdPointer);
2403824037 ZigType *array_type = ptr_ptr_type->data.pointer.child_type;
2403924038
2404024039 IrInstruction *start = instruction->start->child;
24041 if (type_is_invalid(start->value.type))
24040 if (type_is_invalid(start->value->type))
2404224041 return ira->codegen->invalid_instruction;
2404324042
2404424043 ZigType *usize = ira->codegen->builtin_types.entry_usize;
2404524044 IrInstruction *casted_start = ir_implicit_cast(ira, start, usize);
24046 if (type_is_invalid(casted_start->value.type))
24045 if (type_is_invalid(casted_start->value->type))
2404724046 return ira->codegen->invalid_instruction;
2404824047
2404924048 IrInstruction *end;
2405024049 if (instruction->end) {
2405124050 end = instruction->end->child;
24052 if (type_is_invalid(end->value.type))
24051 if (type_is_invalid(end->value->type))
2405324052 return ira->codegen->invalid_instruction;
2405424053 end = ir_implicit_cast(ira, end, usize);
24055 if (type_is_invalid(end->value.type))
24054 if (type_is_invalid(end->value->type))
2405624055 return ira->codegen->invalid_instruction;
2405724056 } else {
2405824057 end = nullptr;
......@@ -24061,8 +24060,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2406124060 ZigType *return_type;
2406224061
2406324062 if (array_type->id == ZigTypeIdArray) {
24064 bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic &&
24065 ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst;
24063 bool is_comptime_const = ptr_ptr->value->special == ConstValSpecialStatic &&
24064 ptr_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst;
2406624065 ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,
2406724066 ptr_ptr_type->data.pointer.is_const || is_comptime_const,
2406824067 ptr_ptr_type->data.pointer.is_volatile,
......@@ -24103,8 +24102,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2410324102 }
2410424103
2410524104 if (instr_is_comptime(ptr_ptr) &&
24106 value_is_comptime(&casted_start->value) &&
24107 (!end || value_is_comptime(&end->value)))
24105 value_is_comptime(casted_start->value) &&
24106 (!end || value_is_comptime(end->value)))
2410824107 {
2410924108 ZigValue *array_val;
2411024109 ZigValue *parent_ptr;
......@@ -24117,7 +24116,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2411724116 if (array_type->id == ZigTypeIdPointer) {
2411824117 ZigType *child_array_type = array_type->data.pointer.child_type;
2411924118 assert(child_array_type->id == ZigTypeIdArray);
24120 parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node);
24119 parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node);
2412124120 if (parent_ptr == nullptr)
2412224121 return ira->codegen->invalid_instruction;
2412324122
......@@ -24136,7 +24135,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2413624135 abs_offset = 0;
2413724136 }
2413824137 } else {
24139 array_val = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node);
24138 array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node);
2414024139 if (array_val == nullptr)
2414124140 return ira->codegen->invalid_instruction;
2414224141 rel_end = array_type->data.array.len;
......@@ -24145,7 +24144,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2414524144 }
2414624145 } else if (array_type->id == ZigTypeIdPointer) {
2414724146 assert(array_type->data.pointer.ptr_len == PtrLenUnknown);
24148 parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node);
24147 parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node);
2414924148 if (parent_ptr == nullptr)
2415024149 return ira->codegen->invalid_instruction;
2415124150
......@@ -24193,7 +24192,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2419324192 zig_panic("TODO slice of null ptr");
2419424193 }
2419524194 } else if (is_slice(array_type)) {
24196 ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node);
24195 ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node);
2419724196 if (slice_ptr == nullptr)
2419824197 return ira->codegen->invalid_instruction;
2419924198
......@@ -24279,7 +24278,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2427924278 }
2428024279
2428124280 IrInstruction *result = ir_const(ira, &instruction->base, return_type);
24282 ZigValue *out_val = &result->value;
24281 ZigValue *out_val = result->value;
2428324282 out_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
2428424283
2428524284 ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index];
......@@ -24289,7 +24288,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2428924288 bool is_const = slice_is_const(return_type);
2429024289 init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown);
2429124290 if (array_type->id == ZigTypeIdArray) {
24292 ptr_val->data.x_ptr.mut = ptr_ptr->value.data.x_ptr.mut;
24291 ptr_val->data.x_ptr.mut = ptr_ptr->value->data.x_ptr.mut;
2429324292 } else if (is_slice(array_type)) {
2429424293 ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut;
2429524294 } else if (array_type->id == ZigTypeIdPointer) {
......@@ -24337,7 +24336,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2433724336
2433824337 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
2433924338 return_type, nullptr, true, false, true);
24340 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
24339 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
2434124340 return result_loc;
2434224341 }
2434324342 return ir_build_slice_gen(ira, &instruction->base, return_type,
......@@ -24347,7 +24346,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2434724346static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) {
2434824347 Error err;
2434924348 IrInstruction *container = instruction->container->child;
24350 if (type_is_invalid(container->value.type))
24349 if (type_is_invalid(container->value->type))
2435124350 return ira->codegen->invalid_instruction;
2435224351 ZigType *container_type = ir_resolve_type(ira, container);
2435324352
......@@ -24448,7 +24447,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr
2444824447 TypeStructField *field = container_type->data.structure.fields[member_index];
2444924448
2445024449 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
24451 init_const_str_lit(ira->codegen, &result->value, field->name);
24450 init_const_str_lit(ira->codegen, result->value, field->name);
2445224451 return result;
2445324452 } else if (container_type->id == ZigTypeIdEnum) {
2445424453 if (member_index >= container_type->data.enumeration.src_field_count) {
......@@ -24460,7 +24459,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr
2446024459 TypeEnumField *field = &container_type->data.enumeration.fields[member_index];
2446124460
2446224461 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
24463 init_const_str_lit(ira->codegen, &result->value, field->name);
24462 init_const_str_lit(ira->codegen, result->value, field->name);
2446424463 return result;
2446524464 } else if (container_type->id == ZigTypeIdUnion) {
2446624465 if (member_index >= container_type->data.unionation.src_field_count) {
......@@ -24472,7 +24471,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr
2447224471 TypeUnionField *field = &container_type->data.unionation.fields[member_index];
2447324472
2447424473 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
24475 init_const_str_lit(ira->codegen, &result->value, field->name);
24474 init_const_str_lit(ira->codegen, result->value, field->name);
2447624475 return result;
2447724476 } else {
2447824477 ir_add_error(ira, container_type_value,
......@@ -24512,21 +24511,21 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc
2451224511static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) {
2451324512 IrInstruction *result = ir_build_breakpoint(&ira->new_irb,
2451424513 instruction->base.scope, instruction->base.source_node);
24515 result->value.type = ira->codegen->builtin_types.entry_void;
24514 result->value->type = ira->codegen->builtin_types.entry_void;
2451624515 return result;
2451724516}
2451824517
2451924518static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) {
2452024519 IrInstruction *result = ir_build_return_address(&ira->new_irb,
2452124520 instruction->base.scope, instruction->base.source_node);
24522 result->value.type = ira->codegen->builtin_types.entry_usize;
24521 result->value->type = ira->codegen->builtin_types.entry_usize;
2452324522 return result;
2452424523}
2452524524
2452624525static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) {
2452724526 IrInstruction *result = ir_build_frame_address(&ira->new_irb,
2452824527 instruction->base.scope, instruction->base.source_node);
24529 result->value.type = ira->codegen->builtin_types.entry_usize;
24528 result->value->type = ira->codegen->builtin_types.entry_usize;
2453024529 return result;
2453124530}
2453224531
......@@ -24542,7 +24541,7 @@ static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInst
2454224541 ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false);
2454324542
2454424543 IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node);
24545 result->value.type = ptr_frame_type;
24544 result->value->type = ptr_frame_type;
2454624545 return result;
2454724546}
2454824547
......@@ -24563,12 +24562,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru
2456324562
2456424563static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) {
2456524564 IrInstruction *fn = instruction->fn->child;
24566 if (type_is_invalid(fn->value.type))
24565 if (type_is_invalid(fn->value->type))
2456724566 return ira->codegen->invalid_instruction;
2456824567
24569 if (fn->value.type->id != ZigTypeIdFn) {
24568 if (fn->value->type->id != ZigTypeIdFn) {
2457024569 ir_add_error(ira, fn,
24571 buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value.type->name)));
24570 buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name)));
2457224571 return ira->codegen->invalid_instruction;
2457324572 }
2457424573
......@@ -24576,7 +24575,7 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru
2457624575
2457724576 IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope,
2457824577 instruction->base.source_node, fn);
24579 result->value.type = ira->codegen->builtin_types.entry_usize;
24578 result->value->type = ira->codegen->builtin_types.entry_usize;
2458024579 return result;
2458124580}
2458224581
......@@ -24587,11 +24586,11 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct
2458724586 // field: []align(@alignOf(Node)) Node,
2458824587 // };
2458924588 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int);
24590 result->value.special = ConstValSpecialLazy;
24589 result->value->special = ConstValSpecialLazy;
2459124590
2459224591 LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1);
2459324592 lazy_align_of->ira = ira;
24594 result->value.data.x_lazy = &lazy_align_of->base;
24593 result->value->data.x_lazy = &lazy_align_of->base;
2459524594 lazy_align_of->base.id = LazyValueIdAlignOf;
2459624595
2459724596 lazy_align_of->target_type = instruction->type_value->child;
......@@ -24605,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2460524604 Error err;
2460624605
2460724606 IrInstruction *type_value = instruction->type_value->child;
24608 if (type_is_invalid(type_value->value.type))
24607 if (type_is_invalid(type_value->value->type))
2460924608 return ira->codegen->invalid_instruction;
2461024609
2461124610 ZigType *dest_type = ir_resolve_type(ira, type_value);
......@@ -24619,15 +24618,15 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2461924618 }
2462024619
2462124620 IrInstruction *op1 = instruction->op1->child;
24622 if (type_is_invalid(op1->value.type))
24621 if (type_is_invalid(op1->value->type))
2462324622 return ira->codegen->invalid_instruction;
2462424623
2462524624 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type);
24626 if (type_is_invalid(casted_op1->value.type))
24625 if (type_is_invalid(casted_op1->value->type))
2462724626 return ira->codegen->invalid_instruction;
2462824627
2462924628 IrInstruction *op2 = instruction->op2->child;
24630 if (type_is_invalid(op2->value.type))
24629 if (type_is_invalid(op2->value->type))
2463124630 return ira->codegen->invalid_instruction;
2463224631
2463324632 IrInstruction *casted_op2;
......@@ -24638,20 +24637,20 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2463824637 } else {
2463924638 casted_op2 = ir_implicit_cast(ira, op2, dest_type);
2464024639 }
24641 if (type_is_invalid(casted_op2->value.type))
24640 if (type_is_invalid(casted_op2->value->type))
2464224641 return ira->codegen->invalid_instruction;
2464324642
2464424643 IrInstruction *result_ptr = instruction->result_ptr->child;
24645 if (type_is_invalid(result_ptr->value.type))
24644 if (type_is_invalid(result_ptr->value->type))
2464624645 return ira->codegen->invalid_instruction;
2464724646
2464824647 ZigType *expected_ptr_type;
24649 if (result_ptr->value.type->id == ZigTypeIdPointer) {
24648 if (result_ptr->value->type->id == ZigTypeIdPointer) {
2465024649 uint32_t alignment;
24651 if ((err = resolve_ptr_align(ira, result_ptr->value.type, &alignment)))
24650 if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment)))
2465224651 return ira->codegen->invalid_instruction;
2465324652 expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type,
24654 false, result_ptr->value.type->data.pointer.is_volatile,
24653 false, result_ptr->value->type->data.pointer.is_volatile,
2465524654 PtrLenSingle,
2465624655 alignment, 0, 0, false);
2465724656 } else {
......@@ -24659,7 +24658,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2465924658 }
2466024659
2466124660 IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type);
24662 if (type_is_invalid(casted_result_ptr->value.type))
24661 if (type_is_invalid(casted_result_ptr->value->type))
2466324662 return ira->codegen->invalid_instruction;
2466424663
2466524664 if (instr_is_comptime(casted_op1) &&
......@@ -24716,7 +24715,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2471624715 IrInstruction *result = ir_build_overflow_op(&ira->new_irb,
2471724716 instruction->base.scope, instruction->base.source_node,
2471824717 instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type);
24719 result->value.type = ira->codegen->builtin_types.entry_bool;
24718 result->value->type = ira->codegen->builtin_types.entry_bool;
2472024719 return result;
2472124720}
2472224721
......@@ -24749,7 +24748,7 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z
2474924748
2475024749static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) {
2475124750 IrInstruction *type_value = instruction->type_value->child;
24752 if (type_is_invalid(type_value->value.type))
24751 if (type_is_invalid(type_value->value->type))
2475324752 return ira->codegen->invalid_instruction;
2475424753
2475524754 ZigType *expr_type = ir_resolve_type(ira, type_value);
......@@ -24765,27 +24764,27 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2476524764 }
2476624765
2476724766 IrInstruction *op1 = instruction->op1->child;
24768 if (type_is_invalid(op1->value.type))
24767 if (type_is_invalid(op1->value->type))
2476924768 return ira->codegen->invalid_instruction;
2477024769
2477124770 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type);
24772 if (type_is_invalid(casted_op1->value.type))
24771 if (type_is_invalid(casted_op1->value->type))
2477324772 return ira->codegen->invalid_instruction;
2477424773
2477524774 IrInstruction *op2 = instruction->op2->child;
24776 if (type_is_invalid(op2->value.type))
24775 if (type_is_invalid(op2->value->type))
2477724776 return ira->codegen->invalid_instruction;
2477824777
2477924778 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type);
24780 if (type_is_invalid(casted_op2->value.type))
24779 if (type_is_invalid(casted_op2->value->type))
2478124780 return ira->codegen->invalid_instruction;
2478224781
2478324782 IrInstruction *op3 = instruction->op3->child;
24784 if (type_is_invalid(op3->value.type))
24783 if (type_is_invalid(op3->value->type))
2478524784 return ira->codegen->invalid_instruction;
2478624785
2478724786 IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type);
24788 if (type_is_invalid(casted_op3->value.type))
24787 if (type_is_invalid(casted_op3->value->type))
2478924788 return ira->codegen->invalid_instruction;
2479024789
2479124790 if (instr_is_comptime(casted_op1) &&
......@@ -24802,7 +24801,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2480224801 return ira->codegen->invalid_instruction;
2480324802
2480424803 IrInstruction *result = ir_const(ira, &instruction->base, expr_type);
24805 ZigValue *out_val = &result->value;
24804 ZigValue *out_val = result->value;
2480624805
2480724806 if (expr_type->id == ZigTypeIdVector) {
2480824807 expand_undef_array(ira->codegen, op1_const);
......@@ -24835,13 +24834,13 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2483524834 IrInstruction *result = ir_build_mul_add(&ira->new_irb,
2483624835 instruction->base.scope, instruction->base.source_node,
2483724836 type_value, casted_op1, casted_op2, casted_op3);
24838 result->value.type = expr_type;
24837 result->value->type = expr_type;
2483924838 return result;
2484024839}
2484124840
2484224841static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) {
2484324842 IrInstruction *base_ptr = instruction->base_ptr->child;
24844 if (type_is_invalid(base_ptr->value.type))
24843 if (type_is_invalid(base_ptr->value->type))
2484524844 return ira->codegen->invalid_instruction;
2484624845
2484724846 IrInstruction *value;
......@@ -24851,7 +24850,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct
2485124850 value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr);
2485224851 }
2485324852
24854 ZigType *type_entry = value->value.type;
24853 ZigType *type_entry = value->value->type;
2485524854 if (type_is_invalid(type_entry))
2485624855 return ira->codegen->invalid_instruction;
2485724856 if (type_entry->id == ZigTypeIdErrorUnion) {
......@@ -24890,7 +24889,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct
2489024889static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr,
2489124890 IrInstruction *base_ptr, bool initializing)
2489224891{
24893 ZigType *ptr_type = base_ptr->value.type;
24892 ZigType *ptr_type = base_ptr->value->type;
2489424893
2489524894 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
2489624895 assert(ptr_type->id == ZigTypeIdPointer);
......@@ -24946,12 +24945,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *
2494624945 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
2494724946 result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope,
2494824947 source_instr->source_node, base_ptr);
24949 result->value.type = result_type;
24950 result->value.special = ConstValSpecialStatic;
24948 result->value->type = result_type;
24949 result->value->special = ConstValSpecialStatic;
2495124950 } else {
2495224951 result = ir_const(ira, source_instr, result_type);
2495324952 }
24954 ZigValue *const_val = &result->value;
24953 ZigValue *const_val = result->value;
2495524954 const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode;
2495624955 const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val;
2495724956 const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
......@@ -24961,7 +24960,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *
2496124960
2496224961 IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb,
2496324962 source_instr->scope, source_instr->source_node, base_ptr);
24964 result->value.type = result_type;
24963 result->value->type = result_type;
2496524964 return result;
2496624965}
2496724966
......@@ -24969,7 +24968,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
2496924968 IrInstructionUnwrapErrCode *instruction)
2497024969{
2497124970 IrInstruction *base_ptr = instruction->err_union_ptr->child;
24972 if (type_is_invalid(base_ptr->value.type))
24971 if (type_is_invalid(base_ptr->value->type))
2497324972 return ira->codegen->invalid_instruction;
2497424973 return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false);
2497524974}
......@@ -24977,7 +24976,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
2497724976static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr,
2497824977 IrInstruction *base_ptr, bool safety_check_on, bool initializing)
2497924978{
24980 ZigType *ptr_type = base_ptr->value.type;
24979 ZigType *ptr_type = base_ptr->value->type;
2498124980
2498224981 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
2498324982 assert(ptr_type->id == ZigTypeIdPointer);
......@@ -25036,14 +25035,14 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct
2503625035 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
2503725036 result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope,
2503825037 source_instr->source_node, base_ptr, safety_check_on, initializing);
25039 result->value.type = result_type;
25040 result->value.special = ConstValSpecialStatic;
25038 result->value->type = result_type;
25039 result->value->special = ConstValSpecialStatic;
2504125040 } else {
2504225041 result = ir_const(ira, source_instr, result_type);
2504325042 }
25044 result->value.data.x_ptr.special = ConstPtrSpecialRef;
25045 result->value.data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload;
25046 result->value.data.x_ptr.mut = ptr_val->data.x_ptr.mut;
25043 result->value->data.x_ptr.special = ConstPtrSpecialRef;
25044 result->value->data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload;
25045 result->value->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
2504725046 return result;
2504825047 }
2504925048 }
......@@ -25051,7 +25050,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct
2505125050
2505225051 IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope,
2505325052 source_instr->source_node, base_ptr, safety_check_on, initializing);
25054 result->value.type = result_type;
25053 result->value->type = result_type;
2505525054 return result;
2505625055}
2505725056
......@@ -25060,7 +25059,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
2506025059{
2506125060 assert(instruction->value->child);
2506225061 IrInstruction *value = instruction->value->child;
25063 if (type_is_invalid(value->value.type))
25062 if (type_is_invalid(value->value->type))
2506425063 return ira->codegen->invalid_instruction;
2506525064
2506625065 return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false);
......@@ -25071,11 +25070,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
2507125070 assert(proto_node->type == NodeTypeFnProto);
2507225071
2507325072 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type);
25074 result->value.special = ConstValSpecialLazy;
25073 result->value->special = ConstValSpecialLazy;
2507525074
2507625075 LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1);
2507725076 lazy_fn_type->ira = ira;
25078 result->value.data.x_lazy = &lazy_fn_type->base;
25077 result->value->data.x_lazy = &lazy_fn_type->base;
2507925078 lazy_fn_type->base.id = LazyValueIdFnType;
2508025079
2508125080 if (proto_node->data.fn_proto.auto_err_set) {
......@@ -25110,7 +25109,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
2511025109 }
2511125110
2511225111 IrInstruction *param_type_value = instruction->param_types[param_index]->child;
25113 if (type_is_invalid(param_type_value->value.type))
25112 if (type_is_invalid(param_type_value->value->type))
2511425113 return ira->codegen->invalid_instruction;
2511525114 if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr)
2511625115 return ira->codegen->invalid_instruction;
......@@ -25132,7 +25131,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
2513225131
2513325132static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) {
2513425133 IrInstruction *value = instruction->value->child;
25135 if (type_is_invalid(value->value.type))
25134 if (type_is_invalid(value->value->type))
2513625135 return ira->codegen->invalid_instruction;
2513725136
2513825137 return ir_const_bool(ira, &instruction->base, instr_is_comptime(value));
......@@ -25142,7 +25141,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2514225141 IrInstructionCheckSwitchProngs *instruction)
2514325142{
2514425143 IrInstruction *target_value = instruction->target_value->child;
25145 ZigType *switch_type = target_value->value.type;
25144 ZigType *switch_type = target_value->value->type;
2514625145 if (type_is_invalid(switch_type))
2514725146 return ira->codegen->invalid_instruction;
2514825147
......@@ -25154,25 +25153,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2515425153 IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i];
2515525154
2515625155 IrInstruction *start_value_uncasted = range->start->child;
25157 if (type_is_invalid(start_value_uncasted->value.type))
25156 if (type_is_invalid(start_value_uncasted->value->type))
2515825157 return ira->codegen->invalid_instruction;
2515925158 IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type);
25160 if (type_is_invalid(start_value->value.type))
25159 if (type_is_invalid(start_value->value->type))
2516125160 return ira->codegen->invalid_instruction;
2516225161
2516325162 IrInstruction *end_value_uncasted = range->end->child;
25164 if (type_is_invalid(end_value_uncasted->value.type))
25163 if (type_is_invalid(end_value_uncasted->value->type))
2516525164 return ira->codegen->invalid_instruction;
2516625165 IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type);
25167 if (type_is_invalid(end_value->value.type))
25166 if (type_is_invalid(end_value->value->type))
2516825167 return ira->codegen->invalid_instruction;
2516925168
2517025169 BigInt start_index;
25171 bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag);
25170 bigint_init_bigint(&start_index, &start_value->value->data.x_enum_tag);
2517225171
25173 assert(end_value->value.type->id == ZigTypeIdEnum);
25172 assert(end_value->value->type->id == ZigTypeIdEnum);
2517425173 BigInt end_index;
25175 bigint_init_bigint(&end_index, &end_value->value.data.x_enum_tag);
25174 bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag);
2517625175
2517725176 BigInt field_index;
2517825177 bigint_init_bigint(&field_index, &start_index);
......@@ -25218,24 +25217,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2521825217 IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i];
2521925218
2522025219 IrInstruction *start_value_uncasted = range->start->child;
25221 if (type_is_invalid(start_value_uncasted->value.type))
25220 if (type_is_invalid(start_value_uncasted->value->type))
2522225221 return ira->codegen->invalid_instruction;
2522325222 IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type);
25224 if (type_is_invalid(start_value->value.type))
25223 if (type_is_invalid(start_value->value->type))
2522525224 return ira->codegen->invalid_instruction;
2522625225
2522725226 IrInstruction *end_value_uncasted = range->end->child;
25228 if (type_is_invalid(end_value_uncasted->value.type))
25227 if (type_is_invalid(end_value_uncasted->value->type))
2522925228 return ira->codegen->invalid_instruction;
2523025229 IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type);
25231 if (type_is_invalid(end_value->value.type))
25230 if (type_is_invalid(end_value->value->type))
2523225231 return ira->codegen->invalid_instruction;
2523325232
25234 ir_assert(start_value->value.type->id == ZigTypeIdErrorSet, &instruction->base);
25235 uint32_t start_index = start_value->value.data.x_err_set->value;
25233 ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base);
25234 uint32_t start_index = start_value->value->data.x_err_set->value;
2523625235
25237 ir_assert(end_value->value.type->id == ZigTypeIdErrorSet, &instruction->base);
25238 uint32_t end_index = end_value->value.data.x_err_set->value;
25236 ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base);
25237 uint32_t end_index = end_value->value->data.x_err_set->value;
2523925238
2524025239 if (start_index != end_index) {
2524125240 ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors"));
......@@ -25276,17 +25275,17 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2527625275 IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i];
2527725276
2527825277 IrInstruction *start_value = range->start->child;
25279 if (type_is_invalid(start_value->value.type))
25278 if (type_is_invalid(start_value->value->type))
2528025279 return ira->codegen->invalid_instruction;
2528125280 IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type);
25282 if (type_is_invalid(casted_start_value->value.type))
25281 if (type_is_invalid(casted_start_value->value->type))
2528325282 return ira->codegen->invalid_instruction;
2528425283
2528525284 IrInstruction *end_value = range->end->child;
25286 if (type_is_invalid(end_value->value.type))
25285 if (type_is_invalid(end_value->value->type))
2528725286 return ira->codegen->invalid_instruction;
2528825287 IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type);
25289 if (type_is_invalid(casted_end_value->value.type))
25288 if (type_is_invalid(casted_end_value->value->type))
2529025289 return ira->codegen->invalid_instruction;
2529125290
2529225291 ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad);
......@@ -25326,7 +25325,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2532625325 IrInstruction *value = range->start->child;
2532725326
2532825327 IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type);
25329 if (type_is_invalid(casted_value->value.type))
25328 if (type_is_invalid(casted_value->value->type))
2533025329 return ira->codegen->invalid_instruction;
2533125330
2533225331 ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad);
......@@ -25362,7 +25361,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze *
2536225361 IrInstructionCheckStatementIsVoid *instruction)
2536325362{
2536425363 IrInstruction *statement_value = instruction->statement_value->child;
25365 ZigType *statement_type = statement_value->value.type;
25364 ZigType *statement_type = statement_value->value->type;
2536625365 if (type_is_invalid(statement_type))
2536725366 return ira->codegen->invalid_instruction;
2536825367
......@@ -25375,7 +25374,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze *
2537525374
2537625375static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) {
2537725376 IrInstruction *msg = instruction->msg->child;
25378 if (type_is_invalid(msg->value.type))
25377 if (type_is_invalid(msg->value->type))
2537925378 return ir_unreach_error(ira);
2538025379
2538125380 if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) {
......@@ -25387,7 +25386,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction
2538725386 true, false, PtrLenUnknown, 0, 0, 0, false);
2538825387 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
2538925388 IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type);
25390 if (type_is_invalid(casted_msg->value.type))
25389 if (type_is_invalid(casted_msg->value->type))
2539125390 return ir_unreach_error(ira);
2539225391
2539325392 IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope,
......@@ -25398,7 +25397,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction
2539825397static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) {
2539925398 Error err;
2540025399
25401 ZigType *target_type = target->value.type;
25400 ZigType *target_type = target->value->type;
2540225401 assert(!type_is_invalid(target_type));
2540325402
2540425403 ZigType *result_type;
......@@ -25457,8 +25456,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
2545725456 }
2545825457
2545925458 IrInstruction *result = ir_const(ira, target, result_type);
25460 copy_const_val(&result->value, val, true);
25461 result->value.type = result_type;
25459 copy_const_val(result->value, val, true);
25460 result->value->type = result_type;
2546225461 return result;
2546325462 }
2546425463
......@@ -25468,7 +25467,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
2546825467 } else {
2546925468 result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop);
2547025469 }
25471 result->value.type = result_type;
25470 result->value->type = result_type;
2547225471 return result;
2547325472}
2547425473
......@@ -25477,7 +25476,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2547725476{
2547825477 Error err;
2547925478
25480 ZigType *src_type = ptr->value.type;
25479 ZigType *src_type = ptr->value->type;
2548125480 assert(!type_is_invalid(src_type));
2548225481
2548325482 if (src_type == dest_type) {
......@@ -25531,7 +25530,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2553125530 }
2553225531
2553325532 IrInstruction *result;
25534 if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) {
25533 if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) {
2553525534 result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on);
2553625535
2553725536 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))
......@@ -25539,8 +25538,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2553925538 } else {
2554025539 result = ir_const(ira, source_instr, dest_type);
2554125540 }
25542 copy_const_val(&result->value, val, true);
25543 result->value.type = dest_type;
25541 copy_const_val(result->value, val, true);
25542 result->value->type = dest_type;
2554425543
2554525544 // Keep the bigger alignment, it can only help-
2554625545 // unless the target is zero bits.
......@@ -25584,7 +25583,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2558425583 IrInstruction *result;
2558525584 if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) {
2558625585 result = ir_align_cast(ira, casted_ptr, src_align_bytes, false);
25587 if (type_is_invalid(result->value.type))
25586 if (type_is_invalid(result->value->type))
2558825587 return ira->codegen->invalid_instruction;
2558925588 } else {
2559025589 result = casted_ptr;
......@@ -25599,7 +25598,7 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct
2559925598 return ira->codegen->invalid_instruction;
2560025599
2560125600 IrInstruction *ptr = instruction->ptr->child;
25602 ZigType *src_type = ptr->value.type;
25601 ZigType *src_type = ptr->value->type;
2560325602 if (type_is_invalid(src_type))
2560425603 return ira->codegen->invalid_instruction;
2560525604
......@@ -25941,7 +25940,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_
2594125940{
2594225941 Error err;
2594325942
25944 ZigType *src_type = value->value.type;
25943 ZigType *src_type = value->value->type;
2594525944 ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr);
2594625945 ir_assert(type_can_bit_cast(src_type), source_instr);
2594725946 ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr);
......@@ -25982,7 +25981,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_
2598225981 IrInstruction *result = ir_const(ira, source_instr, dest_type);
2598325982 uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes);
2598425983 buf_write_value_bytes(ira->codegen, buf, val);
25985 if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, &result->value)))
25984 if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value)))
2598625985 return ira->codegen->invalid_instruction;
2598725986 return result;
2598825987 }
......@@ -25997,7 +25996,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
2599725996 ir_assert(type_has_bits(ptr_type), source_instr);
2599825997
2599925998 IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize);
26000 if (type_is_invalid(casted_int->value.type))
25999 if (type_is_invalid(casted_int->value->type))
2600126000 return ira->codegen->invalid_instruction;
2600226001
2600326002 if (instr_is_comptime(casted_int)) {
......@@ -26013,15 +26012,15 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
2601326012 }
2601426013
2601526014 IrInstruction *result = ir_const(ira, source_instr, ptr_type);
26016 result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
26017 result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar;
26018 result->value.data.x_ptr.data.hard_coded_addr.addr = addr;
26015 result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
26016 result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar;
26017 result->value->data.x_ptr.data.hard_coded_addr.addr = addr;
2601926018 return result;
2602026019 }
2602126020
2602226021 IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope,
2602326022 source_instr->source_node, nullptr, casted_int);
26024 result->value.type = ptr_type;
26023 result->value->type = ptr_type;
2602526024 return result;
2602626025}
2602726026
......@@ -26048,7 +26047,7 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru
2604826047
2604926048
2605026049 IrInstruction *target = instruction->target->child;
26051 if (type_is_invalid(target->value.type))
26050 if (type_is_invalid(target->value->type))
2605226051 return ira->codegen->invalid_instruction;
2605326052
2605426053 return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type);
......@@ -26058,7 +26057,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
2605826057 IrInstructionDeclRef *instruction)
2605926058{
2606026059 IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld);
26061 if (type_is_invalid(ref_instruction->value.type)) {
26060 if (type_is_invalid(ref_instruction->value->type)) {
2606226061 return ira->codegen->invalid_instruction;
2606326062 }
2606426063
......@@ -26072,21 +26071,21 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
2607226071static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) {
2607326072 Error err;
2607426073 IrInstruction *target = instruction->target->child;
26075 if (type_is_invalid(target->value.type))
26074 if (type_is_invalid(target->value->type))
2607626075 return ira->codegen->invalid_instruction;
2607726076
2607826077 ZigType *usize = ira->codegen->builtin_types.entry_usize;
2607926078
2608026079 // We check size explicitly so we can use get_src_ptr_type here.
26081 if (get_src_ptr_type(target->value.type) == nullptr) {
26080 if (get_src_ptr_type(target->value->type) == nullptr) {
2608226081 ir_add_error(ira, target,
26083 buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name)));
26082 buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name)));
2608426083 return ira->codegen->invalid_instruction;
2608526084 }
2608626085
26087 if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown)))
26086 if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown)))
2608826087 return ira->codegen->invalid_instruction;
26089 if (!type_has_bits(target->value.type)) {
26088 if (!type_has_bits(target->value->type)) {
2609026089 ir_add_error(ira, target,
2609126090 buf_sprintf("pointer to size 0 type has no address"));
2609226091 return ira->codegen->invalid_instruction;
......@@ -26098,25 +26097,25 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2609826097 return ira->codegen->invalid_instruction;
2609926098 if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {
2610026099 IrInstruction *result = ir_const(ira, &instruction->base, usize);
26101 bigint_init_unsigned(&result->value.data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr);
26102 result->value.type = usize;
26100 bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr);
26101 result->value->type = usize;
2610326102 return result;
2610426103 }
2610526104 }
2610626105
2610726106 IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope,
2610826107 instruction->base.source_node, target);
26109 result->value.type = usize;
26108 result->value->type = usize;
2611026109 return result;
2611126110}
2611226111
2611326112static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
2611426113 IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type);
26115 result->value.special = ConstValSpecialLazy;
26114 result->value->special = ConstValSpecialLazy;
2611626115
2611726116 LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1);
2611826117 lazy_ptr_type->ira = ira;
26119 result->value.data.x_lazy = &lazy_ptr_type->base;
26118 result->value->data.x_lazy = &lazy_ptr_type->base;
2612026119 lazy_ptr_type->base.id = LazyValueIdPtrType;
2612126120
2612226121 if (instruction->sentinel != nullptr) {
......@@ -26147,15 +26146,15 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct
2614726146
2614826147static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) {
2614926148 IrInstruction *target = instruction->target->child;
26150 if (type_is_invalid(target->value.type))
26149 if (type_is_invalid(target->value->type))
2615126150 return ira->codegen->invalid_instruction;
2615226151
2615326152 ZigType *elem_type = nullptr;
26154 if (is_slice(target->value.type)) {
26155 ZigType *slice_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry;
26153 if (is_slice(target->value->type)) {
26154 ZigType *slice_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry;
2615626155 elem_type = slice_ptr_type->data.pointer.child_type;
26157 } else if (target->value.type->id == ZigTypeIdPointer) {
26158 elem_type = target->value.type->data.pointer.child_type;
26156 } else if (target->value->type->id == ZigTypeIdPointer) {
26157 elem_type = target->value->type->data.pointer.child_type;
2615926158 }
2616026159
2616126160 uint32_t align_bytes;
......@@ -26164,7 +26163,7 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru
2616426163 return ira->codegen->invalid_instruction;
2616526164
2616626165 IrInstruction *result = ir_align_cast(ira, target, align_bytes, true);
26167 if (type_is_invalid(result->value.type))
26166 if (type_is_invalid(result->value->type))
2616826167 return ira->codegen->invalid_instruction;
2616926168
2617026169 return result;
......@@ -26350,13 +26349,13 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2635026349 return ira->codegen->invalid_instruction;
2635126350
2635226351 IrInstruction *ptr_inst = instruction->ptr->child;
26353 if (type_is_invalid(ptr_inst->value.type))
26352 if (type_is_invalid(ptr_inst->value->type))
2635426353 return ira->codegen->invalid_instruction;
2635526354
2635626355 // TODO let this be volatile
2635726356 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
2635826357 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
26359 if (type_is_invalid(casted_ptr->value.type))
26358 if (type_is_invalid(casted_ptr->value->type))
2636026359 return ira->codegen->invalid_instruction;
2636126360
2636226361 AtomicRmwOp op;
......@@ -26375,11 +26374,11 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2637526374 }
2637626375
2637726376 IrInstruction *operand = instruction->operand->child;
26378 if (type_is_invalid(operand->value.type))
26377 if (type_is_invalid(operand->value->type))
2637926378 return ira->codegen->invalid_instruction;
2638026379
2638126380 IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type);
26382 if (type_is_invalid(casted_operand->value.type))
26381 if (type_is_invalid(casted_operand->value->type))
2638326382 return ira->codegen->invalid_instruction;
2638426383
2638526384 AtomicOrder ordering;
......@@ -26395,7 +26394,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2639526394 }
2639626395 }
2639726396
26398 if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar)
26397 if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar)
2639926398 {
2640026399 zig_panic("TODO compile-time execution of atomicRmw");
2640126400 }
......@@ -26403,7 +26402,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru
2640326402 IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope,
2640426403 instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr,
2640526404 op, ordering);
26406 result->value.type = operand_type;
26405 result->value->type = operand_type;
2640726406 return result;
2640826407}
2640926408
......@@ -26413,12 +26412,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
2641326412 return ira->codegen->invalid_instruction;
2641426413
2641526414 IrInstruction *ptr_inst = instruction->ptr->child;
26416 if (type_is_invalid(ptr_inst->value.type))
26415 if (type_is_invalid(ptr_inst->value->type))
2641726416 return ira->codegen->invalid_instruction;
2641826417
2641926418 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);
2642026419 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
26421 if (type_is_invalid(casted_ptr->value.type))
26420 if (type_is_invalid(casted_ptr->value->type))
2642226421 return ira->codegen->invalid_instruction;
2642326422
2642426423 AtomicOrder ordering;
......@@ -26438,13 +26437,13 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
2643826437
2643926438 if (instr_is_comptime(casted_ptr)) {
2644026439 IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr);
26441 ir_assert(result->value.type != nullptr, &instruction->base);
26440 ir_assert(result->value->type != nullptr, &instruction->base);
2644226441 return result;
2644326442 }
2644426443
2644526444 IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope,
2644626445 instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering);
26447 result->value.type = operand_type;
26446 result->value->type = operand_type;
2644826447 return result;
2644926448}
2645026449
......@@ -26454,20 +26453,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
2645426453 return ira->codegen->invalid_instruction;
2645526454
2645626455 IrInstruction *ptr_inst = instruction->ptr->child;
26457 if (type_is_invalid(ptr_inst->value.type))
26456 if (type_is_invalid(ptr_inst->value->type))
2645826457 return ira->codegen->invalid_instruction;
2645926458
2646026459 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
2646126460 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
26462 if (type_is_invalid(casted_ptr->value.type))
26461 if (type_is_invalid(casted_ptr->value->type))
2646326462 return ira->codegen->invalid_instruction;
2646426463
2646526464 IrInstruction *value = instruction->value->child;
26466 if (type_is_invalid(value->value.type))
26465 if (type_is_invalid(value->value->type))
2646726466 return ira->codegen->invalid_instruction;
2646826467
2646926468 IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type);
26470 if (type_is_invalid(casted_value->value.type))
26469 if (type_is_invalid(casted_value->value->type))
2647126470 return ira->codegen->invalid_instruction;
2647226471
2647326472
......@@ -26488,20 +26487,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst
2648826487
2648926488 if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) {
2649026489 IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false);
26491 result->value.type = ira->codegen->builtin_types.entry_void;
26490 result->value->type = ira->codegen->builtin_types.entry_void;
2649226491 return result;
2649326492 }
2649426493
2649526494 IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope,
2649626495 instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering);
26497 result->value.type = ira->codegen->builtin_types.entry_void;
26496 result->value->type = ira->codegen->builtin_types.entry_void;
2649826497 return result;
2649926498}
2650026499
2650126500static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) {
2650226501 IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope,
2650326502 instruction->base.source_node);
26504 result->value.type = ira->codegen->builtin_types.entry_void;
26503 result->value->type = ira->codegen->builtin_types.entry_void;
2650526504 return result;
2650626505}
2650726506
......@@ -26687,7 +26686,7 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr,
2668726686
2668826687static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) {
2668926688 IrInstruction *type = instruction->type->child;
26690 if (type_is_invalid(type->value.type))
26689 if (type_is_invalid(type->value->type))
2669126690 return ira->codegen->invalid_instruction;
2669226691
2669326692 ZigType *expr_type = ir_resolve_type(ira, type);
......@@ -26702,11 +26701,11 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2670226701 }
2670326702
2670426703 IrInstruction *op1 = instruction->op1->child;
26705 if (type_is_invalid(op1->value.type))
26704 if (type_is_invalid(op1->value->type))
2670626705 return ira->codegen->invalid_instruction;
2670726706
2670826707 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type);
26709 if (type_is_invalid(casted_op1->value.type))
26708 if (type_is_invalid(casted_op1->value->type))
2671026709 return ira->codegen->invalid_instruction;
2671126710
2671226711 if (instr_is_comptime(casted_op1)) {
......@@ -26724,7 +26723,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2672426723 return ira->codegen->invalid_instruction;
2672526724
2672626725 IrInstruction *result = ir_const(ira, &instruction->base, expr_type);
26727 ZigValue *out_val = &result->value;
26726 ZigValue *out_val = result->value;
2672826727
2672926728 if (expr_type->id == ZigTypeIdVector) {
2673026729 expand_undef_array(ira->codegen, op1_const);
......@@ -26752,7 +26751,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2675226751
2675326752 IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope,
2675426753 instruction->base.source_node, nullptr, casted_op1, instruction->op);
26755 result->value.type = expr_type;
26754 result->value->type = expr_type;
2675626755 return result;
2675726756}
2675826757
......@@ -26764,16 +26763,16 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2676426763 return ira->codegen->invalid_instruction;
2676526764
2676626765 IrInstruction *uncasted_op = instruction->op->child;
26767 if (type_is_invalid(uncasted_op->value.type))
26766 if (type_is_invalid(uncasted_op->value->type))
2676826767 return ira->codegen->invalid_instruction;
2676926768
2677026769 uint32_t vector_len; // UINT32_MAX means not a vector
26771 if (uncasted_op->value.type->id == ZigTypeIdArray &&
26772 is_valid_vector_elem_type(uncasted_op->value.type->data.array.child_type))
26770 if (uncasted_op->value->type->id == ZigTypeIdArray &&
26771 is_valid_vector_elem_type(uncasted_op->value->type->data.array.child_type))
2677326772 {
26774 vector_len = uncasted_op->value.type->data.array.len;
26775 } else if (uncasted_op->value.type->id == ZigTypeIdVector) {
26776 vector_len = uncasted_op->value.type->data.vector.len;
26773 vector_len = uncasted_op->value->type->data.array.len;
26774 } else if (uncasted_op->value->type->id == ZigTypeIdVector) {
26775 vector_len = uncasted_op->value->type->data.vector.len;
2677726776 } else {
2677826777 vector_len = UINT32_MAX;
2677926778 }
......@@ -26782,7 +26781,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2678226781 ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type;
2678326782
2678426783 IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type);
26785 if (type_is_invalid(op->value.type))
26784 if (type_is_invalid(op->value->type))
2678626785 return ira->codegen->invalid_instruction;
2678726786
2678826787 if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0)
......@@ -26807,7 +26806,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2680726806 uint8_t *buf = allocate_nonzero<uint8_t>(buf_size);
2680826807 if (is_vector) {
2680926808 expand_undef_array(ira->codegen, val);
26810 result->value.data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len);
26809 result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len);
2681126810 for (unsigned i = 0; i < op_type->data.vector.len; i += 1) {
2681226811 ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i];
2681326812 if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node,
......@@ -26815,20 +26814,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2681526814 {
2681626815 return ira->codegen->invalid_instruction;
2681726816 }
26818 ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i];
26817 ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i];
2681926818 result_elem_val->type = int_type;
2682026819 result_elem_val->special = op_elem_val->special;
2682126820 if (op_elem_val->special == ConstValSpecialUndef)
2682226821 continue;
2682326822
2682426823 bigint_write_twos_complement(&op_elem_val->data.x_bigint, buf, int_type->data.integral.bit_count, true);
26825 bigint_read_twos_complement(&result->value.data.x_array.data.s_none.elements[i].data.x_bigint,
26824 bigint_read_twos_complement(&result->value->data.x_array.data.s_none.elements[i].data.x_bigint,
2682626825 buf, int_type->data.integral.bit_count, false,
2682726826 int_type->data.integral.is_signed);
2682826827 }
2682926828 } else {
2683026829 bigint_write_twos_complement(&val->data.x_bigint, buf, int_type->data.integral.bit_count, true);
26831 bigint_read_twos_complement(&result->value.data.x_bigint, buf, int_type->data.integral.bit_count, false,
26830 bigint_read_twos_complement(&result->value->data.x_bigint, buf, int_type->data.integral.bit_count, false,
2683226831 int_type->data.integral.is_signed);
2683326832 }
2683426833 free(buf);
......@@ -26837,7 +26836,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2683726836
2683826837 IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope,
2683926838 instruction->base.source_node, nullptr, op);
26840 result->value.type = op_type;
26839 result->value->type = op_type;
2684126840 return result;
2684226841}
2684326842
......@@ -26847,12 +26846,12 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
2684726846 return ira->codegen->invalid_instruction;
2684826847
2684926848 IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type);
26850 if (type_is_invalid(op->value.type))
26849 if (type_is_invalid(op->value->type))
2685126850 return ira->codegen->invalid_instruction;
2685226851
2685326852 if (int_type->data.integral.bit_count == 0) {
2685426853 IrInstruction *result = ir_const(ira, &instruction->base, int_type);
26855 bigint_init_unsigned(&result->value.data.x_bigint, 0);
26854 bigint_init_unsigned(&result->value->data.x_bigint, 0);
2685626855 return result;
2685726856 }
2685826857
......@@ -26881,7 +26880,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
2688126880 }
2688226881 }
2688326882
26884 bigint_read_twos_complement(&result->value.data.x_bigint,
26883 bigint_read_twos_complement(&result->value->data.x_bigint,
2688526884 result_buf,
2688626885 int_type->data.integral.bit_count,
2688726886 ira->codegen->is_big_endian,
......@@ -26892,14 +26891,14 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
2689226891
2689326892 IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope,
2689426893 instruction->base.source_node, nullptr, op);
26895 result->value.type = int_type;
26894 result->value->type = int_type;
2689626895 return result;
2689726896}
2689826897
2689926898
2690026899static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) {
2690126900 IrInstruction *target = instruction->target->child;
26902 if (type_is_invalid(target->value.type))
26901 if (type_is_invalid(target->value->type))
2690326902 return ira->codegen->invalid_instruction;
2690426903
2690526904 return ir_analyze_enum_to_int(ira, &instruction->base, target);
......@@ -26924,11 +26923,11 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr
2692426923 ZigType *tag_type = dest_type->data.enumeration.tag_int_type;
2692526924
2692626925 IrInstruction *target = instruction->target->child;
26927 if (type_is_invalid(target->value.type))
26926 if (type_is_invalid(target->value->type))
2692826927 return ira->codegen->invalid_instruction;
2692926928
2693026929 IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type);
26931 if (type_is_invalid(casted_target->value.type))
26930 if (type_is_invalid(casted_target->value->type))
2693226931 return ira->codegen->invalid_instruction;
2693326932
2693426933 return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type);
......@@ -26995,33 +26994,33 @@ static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Ir
2699526994
2699626995static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) {
2699726996 IrInstruction *value = instruction->value->child;
26998 if (type_is_invalid(value->value.type))
26997 if (type_is_invalid(value->value->type))
2699926998 return ira->codegen->invalid_instruction;
2700026999
2700127000 bool was_written = instruction->result_loc->written;
2700227001 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
27003 value->value.type, value, false, false, true);
27002 value->value->type, value, false, false, true);
2700427003 if (result_loc != nullptr) {
27005 if (type_is_invalid(result_loc->value.type))
27004 if (type_is_invalid(result_loc->value->type))
2700627005 return ira->codegen->invalid_instruction;
27007 if (result_loc->value.type->id == ZigTypeIdUnreachable)
27006 if (result_loc->value->type->id == ZigTypeIdUnreachable)
2700827007 return result_loc;
2700927008
2701027009 if (!was_written || instruction->result_loc->id == ResultLocIdPeer) {
2701127010 IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value,
2701227011 instruction->result_loc->allow_write_through_const);
27013 if (type_is_invalid(store_ptr->value.type)) {
27012 if (type_is_invalid(store_ptr->value->type)) {
2701427013 return ira->codegen->invalid_instruction;
2701527014 }
2701627015 }
2701727016
27018 if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer &&
27017 if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer &&
2701927018 instruction->result_loc->id != ResultLocIdPeer)
2702027019 {
2702127020 if (instr_is_comptime(value)) {
27022 result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst;
27021 result_loc->value->data.x_ptr.mut = ConstPtrMutComptimeConst;
2702327022 } else {
27024 result_loc->value.special = ConstValSpecialRuntime;
27023 result_loc->value->special = ConstValSpecialRuntime;
2702527024 }
2702627025 }
2702727026 }
......@@ -27031,12 +27030,12 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct
2703127030
2703227031static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) {
2703327032 IrInstruction *operand = instruction->operand->child;
27034 if (type_is_invalid(operand->value.type))
27033 if (type_is_invalid(operand->value->type))
2703527034 return operand;
2703627035
2703727036 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,
27038 &instruction->result_loc_cast->base, operand->value.type, operand, false, false, true);
27039 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
27037 &instruction->result_loc_cast->base, operand->value->type, operand, false, false, true);
27038 if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)))
2704027039 return result_loc;
2704127040
2704227041 if (instruction->result_loc_cast->parent->gen_instruction != nullptr) {
......@@ -27051,12 +27050,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns
2705127050
2705227051static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) {
2705327052 IrInstruction *operand = instruction->operand->child;
27054 if (type_is_invalid(operand->value.type))
27053 if (type_is_invalid(operand->value->type))
2705527054 return operand;
2705627055
2705727056 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,
27058 &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true);
27059 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
27057 &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, false, true);
27058 if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)))
2706027059 return result_loc;
2706127060
2706227061 if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) {
......@@ -27084,11 +27083,11 @@ static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *i
2708427083 return ira->codegen->invalid_instruction;
2708527084
2708627085 IrInstruction *field_result_loc = instruction->field_result_loc->child;
27087 if (type_is_invalid(field_result_loc->value.type))
27086 if (type_is_invalid(field_result_loc->value->type))
2708827087 return ira->codegen->invalid_instruction;
2708927088
2709027089 IrInstruction *result_loc = instruction->result_loc->child;
27091 if (type_is_invalid(result_loc->value.type))
27090 if (type_is_invalid(result_loc->value->type))
2709227091 return ira->codegen->invalid_instruction;
2709327092
2709427093 return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node,
......@@ -27105,7 +27104,7 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira,
2710527104 IrInstructionSuspendFinish *instruction)
2710627105{
2710727106 IrInstruction *begin_base = instruction->begin->base.child;
27108 if (type_is_invalid(begin_base->value.type))
27107 if (type_is_invalid(begin_base->value->type))
2710927108 return ira->codegen->invalid_instruction;
2711027109 ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base);
2711127110 IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base);
......@@ -27123,44 +27122,44 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira,
2712327122static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr,
2712427123 IrInstruction *frame_ptr, ZigFn **target_fn)
2712527124{
27126 if (type_is_invalid(frame_ptr->value.type))
27125 if (type_is_invalid(frame_ptr->value->type))
2712727126 return ira->codegen->invalid_instruction;
2712827127
2712927128 *target_fn = nullptr;
2713027129
2713127130 ZigType *result_type;
2713227131 IrInstruction *frame;
27133 if (frame_ptr->value.type->id == ZigTypeIdPointer &&
27134 frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle &&
27135 frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame)
27132 if (frame_ptr->value->type->id == ZigTypeIdPointer &&
27133 frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle &&
27134 frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
2713627135 {
27137 ZigFn *func = frame_ptr->value.type->data.pointer.child_type->data.frame.fn;
27136 ZigFn *func = frame_ptr->value->type->data.pointer.child_type->data.frame.fn;
2713827137 result_type = func->type_entry->data.fn.fn_type_id.return_type;
2713927138 *target_fn = func;
2714027139 frame = frame_ptr;
2714127140 } else {
2714227141 frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr);
27143 if (frame->value.type->id == ZigTypeIdPointer &&
27144 frame->value.type->data.pointer.ptr_len == PtrLenSingle &&
27145 frame->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame)
27142 if (frame->value->type->id == ZigTypeIdPointer &&
27143 frame->value->type->data.pointer.ptr_len == PtrLenSingle &&
27144 frame->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
2714627145 {
27147 ZigFn *func = frame->value.type->data.pointer.child_type->data.frame.fn;
27146 ZigFn *func = frame->value->type->data.pointer.child_type->data.frame.fn;
2714827147 result_type = func->type_entry->data.fn.fn_type_id.return_type;
2714927148 *target_fn = func;
27150 } else if (frame->value.type->id != ZigTypeIdAnyFrame ||
27151 frame->value.type->data.any_frame.result_type == nullptr)
27149 } else if (frame->value->type->id != ZigTypeIdAnyFrame ||
27150 frame->value->type->data.any_frame.result_type == nullptr)
2715227151 {
2715327152 ir_add_error(ira, source_instr,
27154 buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value.type->name)));
27153 buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name)));
2715527154 return ira->codegen->invalid_instruction;
2715627155 } else {
27157 result_type = frame->value.type->data.any_frame.result_type;
27156 result_type = frame->value->type->data.any_frame.result_type;
2715827157 }
2715927158 }
2716027159
2716127160 ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type);
2716227161 IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type);
27163 if (type_is_invalid(casted_frame->value.type))
27162 if (type_is_invalid(casted_frame->value->type))
2716427163 return ira->codegen->invalid_instruction;
2716527164
2716627165 return casted_frame;
......@@ -27168,14 +27167,14 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct
2716827167
2716927168static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) {
2717027169 IrInstruction *operand = instruction->frame->child;
27171 if (type_is_invalid(operand->value.type))
27170 if (type_is_invalid(operand->value->type))
2717227171 return ira->codegen->invalid_instruction;
2717327172 ZigFn *target_fn;
2717427173 IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn);
27175 if (type_is_invalid(frame->value.type))
27174 if (type_is_invalid(frame->value->type))
2717627175 return ira->codegen->invalid_instruction;
2717727176
27178 ZigType *result_type = frame->value.type->data.any_frame.result_type;
27177 ZigType *result_type = frame->value->type->data.any_frame.result_type;
2717927178
2718027179 ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec);
2718127180 ir_assert(fn_entry != nullptr, &instruction->base);
......@@ -27195,7 +27194,7 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction
2719527194 if (type_has_bits(result_type)) {
2719627195 result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,
2719727196 result_type, nullptr, true, true, true);
27198 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
27197 if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)))
2719927198 return result_loc;
2720027199 } else {
2720127200 result_loc = nullptr;
......@@ -27209,13 +27208,13 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction
2720927208
2721027209static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) {
2721127210 IrInstruction *frame_ptr = instruction->frame->child;
27212 if (type_is_invalid(frame_ptr->value.type))
27211 if (type_is_invalid(frame_ptr->value->type))
2721327212 return ira->codegen->invalid_instruction;
2721427213
2721527214 IrInstruction *frame;
27216 if (frame_ptr->value.type->id == ZigTypeIdPointer &&
27217 frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle &&
27218 frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame)
27215 if (frame_ptr->value->type->id == ZigTypeIdPointer &&
27216 frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle &&
27217 frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame)
2721927218 {
2722027219 frame = frame_ptr;
2722127220 } else {
......@@ -27224,7 +27223,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio
2722427223
2722527224 ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr);
2722627225 IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type);
27227 if (type_is_invalid(casted_frame->value.type))
27226 if (type_is_invalid(casted_frame->value->type))
2722827227 return ira->codegen->invalid_instruction;
2722927228
2723027229 return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame);
......@@ -27235,10 +27234,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr
2723527234 return ir_const_void(ira, &instruction->base);
2723627235
2723727236 IrInstruction *operand = instruction->operand->child;
27238 if (type_is_invalid(operand->value.type))
27237 if (type_is_invalid(operand->value->type))
2723927238 return ira->codegen->invalid_instruction;
2724027239
27241 if (!type_has_bits(operand->value.type))
27240 if (!type_has_bits(operand->value->type))
2724227241 return ir_const_void(ira, &instruction->base);
2724327242
2724427243 ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base);
......@@ -27251,10 +27250,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr
2725127250
2725227251static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) {
2725327252 IrInstruction *operand = instruction->begin->operand->child;
27254 if (type_is_invalid(operand->value.type))
27253 if (type_is_invalid(operand->value->type))
2725527254 return ira->codegen->invalid_instruction;
2725627255
27257 if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value.type))
27256 if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value->type))
2725827257 return operand;
2725927258
2726027259 ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base);
......@@ -27262,7 +27261,7 @@ static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstruc
2726227261
2726327262 IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope,
2726427263 instruction->base.source_node, begin);
27265 result->value.type = operand->value.type;
27264 result->value->type = operand->value->type;
2726627265 return result;
2726727266}
2726827267
......@@ -27628,10 +27627,10 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
2762827627 }
2762927628 IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction);
2763027629 if (new_instruction != nullptr) {
27631 ir_assert(new_instruction->value.type != nullptr || new_instruction->value.type != nullptr, old_instruction);
27630 ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction);
2763227631 old_instruction->child = new_instruction;
2763327632
27634 if (type_is_invalid(new_instruction->value.type)) {
27633 if (type_is_invalid(new_instruction->value->type)) {
2763527634 if (new_exec->first_err_trace_msg != nullptr) {
2763627635 ira->codegen->trace_err = new_exec->first_err_trace_msg;
2763727636 } else {
......@@ -27648,7 +27647,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
2764827647 }
2764927648
2765027649 // unreachable instructions do their own control flow.
27651 if (new_instruction->value.type->id == ZigTypeIdUnreachable)
27650 if (new_instruction->value->type->id == ZigTypeIdUnreachable)
2765227651 continue;
2765327652 }
2765427653
......@@ -27958,8 +27957,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2795827957 LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy);
2795927958 IrAnalyze *ira = lazy_align_of->ira;
2796027959
27961 if (lazy_align_of->target_type->value.special == ConstValSpecialStatic) {
27962 switch (lazy_align_of->target_type->value.data.x_type->id) {
27960 if (lazy_align_of->target_type->value->special == ConstValSpecialStatic) {
27961 switch (lazy_align_of->target_type->value->data.x_type->id) {
2796327962 case ZigTypeIdInvalid:
2796427963 zig_unreachable();
2796527964 case ZigTypeIdMetaType:
......@@ -27975,7 +27974,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2797527974 case ZigTypeIdOpaque:
2797627975 ir_add_error(ira, lazy_align_of->target_type,
2797727976 buf_sprintf("no align available for type '%s'",
27978 buf_ptr(&lazy_align_of->target_type->value.data.x_type->name)));
27977 buf_ptr(&lazy_align_of->target_type->value->data.x_type->name)));
2797927978 return ErrorSemanticAnalyzeFail;
2798027979 case ZigTypeIdBool:
2798127980 case ZigTypeIdInt:
......@@ -27997,7 +27996,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2799727996 }
2799827997
2799927998 uint32_t align_in_bytes;
28000 if ((err = type_val_resolve_abi_align(ira->codegen, &lazy_align_of->target_type->value,
27999 if ((err = type_val_resolve_abi_align(ira->codegen, lazy_align_of->target_type->value,
2800128000 &align_in_bytes)))
2800228001 {
2800328002 return err;
......@@ -28012,8 +28011,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2801228011 LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy);
2801328012 IrAnalyze *ira = lazy_size_of->ira;
2801428013
28015 if (lazy_size_of->target_type->value.special == ConstValSpecialStatic) {
28016 switch (lazy_size_of->target_type->value.data.x_type->id) {
28014 if (lazy_size_of->target_type->value->special == ConstValSpecialStatic) {
28015 switch (lazy_size_of->target_type->value->data.x_type->id) {
2801728016 case ZigTypeIdInvalid: // handled above
2801828017 zig_unreachable();
2801928018 case ZigTypeIdUnreachable:
......@@ -28024,7 +28023,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2802428023 case ZigTypeIdOpaque:
2802528024 ir_add_error(ira, lazy_size_of->target_type,
2802628025 buf_sprintf("no size available for type '%s'",
28027 buf_ptr(&lazy_size_of->target_type->value.data.x_type->name)));
28026 buf_ptr(&lazy_size_of->target_type->value->data.x_type->name)));
2802828027 return ErrorSemanticAnalyzeFail;
2802928028 case ZigTypeIdMetaType:
2803028029 case ZigTypeIdEnumLiteral:
......@@ -28052,7 +28051,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2805228051
2805328052 size_t abi_size;
2805428053 size_t size_in_bits;
28055 if ((err = type_val_resolve_abi_size(ira->codegen, source_node, &lazy_size_of->target_type->value,
28054 if ((err = type_val_resolve_abi_size(ira->codegen, source_node, lazy_size_of->target_type->value,
2805628055 &abi_size, &size_in_bits)))
2805728056 {
2805828057 return err;
......@@ -28073,10 +28072,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2807328072
2807428073 ZigValue *sentinel_val;
2807528074 if (lazy_slice_type->sentinel != nullptr) {
28076 if (type_is_invalid(lazy_slice_type->sentinel->value.type))
28075 if (type_is_invalid(lazy_slice_type->sentinel->value->type))
2807728076 return ErrorSemanticAnalyzeFail;
2807828077 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type);
28079 if (type_is_invalid(sentinel->value.type))
28078 if (type_is_invalid(sentinel->value->type))
2808028079 return ErrorSemanticAnalyzeFail;
2808128080 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
2808228081 if (sentinel_val == nullptr)
......@@ -28151,10 +28150,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2815128150
2815228151 ZigValue *sentinel_val;
2815328152 if (lazy_ptr_type->sentinel != nullptr) {
28154 if (type_is_invalid(lazy_ptr_type->sentinel->value.type))
28153 if (type_is_invalid(lazy_ptr_type->sentinel->value->type))
2815528154 return ErrorSemanticAnalyzeFail;
2815628155 IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type);
28157 if (type_is_invalid(sentinel->value.type))
28156 if (type_is_invalid(sentinel->value->type))
2815828157 return ErrorSemanticAnalyzeFail;
2815928158 sentinel_val = ir_resolve_const(ira, sentinel, UndefBad);
2816028159 if (sentinel_val == nullptr)
src/ir_print.cpp+4-4
......@@ -389,7 +389,7 @@ static void ir_print_indent(IrPrint *irp) {
389389static void ir_print_prefix(IrPrint *irp, IrInstruction *instruction, bool trailing) {
390390 ir_print_indent(irp);
391391 const char mark = trailing ? ':' : '#';
392 const char *type_name = instruction->value.type ? buf_ptr(&instruction->value.type->name) : "(unknown)";
392 const char *type_name = instruction->value->type ? buf_ptr(&instruction->value->type->name) : "(unknown)";
393393 const char *ref_count = ir_has_side_effects(instruction) ?
394394 "-" : buf_ptr(buf_sprintf("%" PRIu32 "", instruction->ref_count));
395395 fprintf(irp->f, "%c%-3" PRIu32 "| %-22s| %-12s| %-2s| ", mark, instruction->debug_id,
......@@ -417,8 +417,8 @@ static void ir_print_other_instruction(IrPrint *irp, IrInstruction *instruction)
417417 return;
418418 }
419419
420 if (instruction->value.special != ConstValSpecialRuntime) {
421 ir_print_const_value(irp, &instruction->value);
420 if (instruction->value->special != ConstValSpecialRuntime) {
421 ir_print_const_value(irp, instruction->value);
422422 } else {
423423 ir_print_var_instruction(irp, instruction);
424424 }
......@@ -438,7 +438,7 @@ static void ir_print_return(IrPrint *irp, IrInstructionReturn *instruction) {
438438}
439439
440440static void ir_print_const(IrPrint *irp, IrInstructionConst *const_instruction) {
441 ir_print_const_value(irp, &const_instruction->base.value);
441 ir_print_const_value(irp, const_instruction->base.value);
442442}
443443
444444static const char *ir_bin_op_id_str(IrBinOp op_id) {