| ... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
| 19 | #include <errno.h> | 19 | #include <errno.h> |
| 20 | | 20 | |
| 21 | struct IrExecContext { | 21 | struct IrExecContext { |
| 22 | ZigList<ConstExprValue *> mem_slot_list; | 22 | ZigList<ZigValue *> mem_slot_list; |
| 23 | }; | 23 | }; |
| 24 | | 24 | |
| 25 | struct IrBuilder { | 25 | struct IrBuilder { |
| ... | @@ -204,14 +204,14 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * | ... | @@ -204,14 +204,14 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * |
| 204 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc); | 204 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc); |
| 205 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); | 205 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); |
| 206 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); | 206 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); |
| 207 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val); | 207 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val); |
| 208 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val); | 208 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); |
| 209 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 209 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 210 | ConstExprValue *out_val, ConstExprValue *ptr_val); | 210 | ZigValue *out_val, ZigValue *ptr_val); |
| 211 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, | 211 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, |
| 212 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on); | 212 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on); |
| 213 | static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); | 213 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); |
| 214 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs); | 214 | static void copy_const_val(ZigValue *dest, ZigValue *src, bool same_global_refs); |
| 215 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); | 215 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); |
| 216 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 216 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 217 | ZigType *ptr_type); | 217 | ZigType *ptr_type); |
| ... | @@ -244,10 +244,10 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -244,10 +244,10 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 244 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); | 244 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); |
| 245 | static ResultLoc *no_result_loc(void); | 245 | static ResultLoc *no_result_loc(void); |
| 246 | | 246 | |
| 247 | static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *const_val) { | 247 | static ZigValue *const_ptr_pointee_unchecked(CodeGen *g, ZigValue *const_val) { |
| 248 | assert(get_src_ptr_type(const_val->type) != nullptr); | 248 | assert(get_src_ptr_type(const_val->type) != nullptr); |
| 249 | assert(const_val->special == ConstValSpecialStatic); | 249 | assert(const_val->special == ConstValSpecialStatic); |
| 250 | ConstExprValue *result; | 250 | ZigValue *result; |
| 251 | | 251 | |
| 252 | switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) { | 252 | switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) { |
| 253 | case OnePossibleValueInvalid: | 253 | case OnePossibleValueInvalid: |
| ... | @@ -265,7 +265,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c | ... | @@ -265,7 +265,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c |
| 265 | result = const_val->data.x_ptr.data.ref.pointee; | 265 | result = const_val->data.x_ptr.data.ref.pointee; |
| 266 | break; | 266 | break; |
| 267 | case ConstPtrSpecialBaseArray: { | 267 | case ConstPtrSpecialBaseArray: { |
| 268 | ConstExprValue *array_val = const_val->data.x_ptr.data.base_array.array_val; | 268 | ZigValue *array_val = const_val->data.x_ptr.data.base_array.array_val; |
| 269 | if (const_val->data.x_ptr.data.base_array.elem_index == array_val->type->data.array.len) { | 269 | if (const_val->data.x_ptr.data.base_array.elem_index == array_val->type->data.array.len) { |
| 270 | result = array_val->type->data.array.sentinel; | 270 | result = array_val->type->data.array.sentinel; |
| 271 | } else { | 271 | } else { |
| ... | @@ -275,7 +275,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c | ... | @@ -275,7 +275,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c |
| 275 | break; | 275 | break; |
| 276 | } | 276 | } |
| 277 | case ConstPtrSpecialBaseStruct: { | 277 | case ConstPtrSpecialBaseStruct: { |
| 278 | ConstExprValue *struct_val = const_val->data.x_ptr.data.base_struct.struct_val; | 278 | ZigValue *struct_val = const_val->data.x_ptr.data.base_struct.struct_val; |
| 279 | expand_undef_struct(g, struct_val); | 279 | expand_undef_struct(g, struct_val); |
| 280 | result = struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index]; | 280 | result = struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index]; |
| 281 | break; | 281 | break; |
| ... | @@ -317,7 +317,7 @@ static bool slice_is_const(ZigType *type) { | ... | @@ -317,7 +317,7 @@ static bool slice_is_const(ZigType *type) { |
| 317 | return type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; | 317 | return type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; |
| 318 | } | 318 | } |
| 319 | | 319 | |
| 320 | // This function returns true when you can change the type of a ConstExprValue and the | 320 | // This function returns true when you can change the type of a ZigValue and the |
| 321 | // value remains meaningful. | 321 | // value remains meaningful. |
| 322 | static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expected, ZigType *actual) { | 322 | static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expected, ZigType *actual) { |
| 323 | if (expected == actual) | 323 | if (expected == actual) |
| ... | @@ -416,16 +416,16 @@ static Buf *exec_c_import_buf(IrExecutable *exec) { | ... | @@ -416,16 +416,16 @@ static Buf *exec_c_import_buf(IrExecutable *exec) { |
| 416 | return exec->c_import_buf; | 416 | return exec->c_import_buf; |
| 417 | } | 417 | } |
| 418 | | 418 | |
| 419 | static bool value_is_comptime(ConstExprValue *const_val) { | 419 | static bool value_is_comptime(ZigValue *const_val) { |
| 420 | return const_val->special != ConstValSpecialRuntime; | 420 | return const_val->special != ConstValSpecialRuntime; |
| 421 | } | 421 | } |
| 422 | | 422 | |
| 423 | static bool instr_is_comptime(IrInstruction *instruction) { | 423 | static bool instr_is_comptime(IrInstruction *instruction) { |
| 424 | return value_is_comptime(&instruction->value); | 424 | return value_is_comptime(instruction->value); |
| 425 | } | 425 | } |
| 426 | | 426 | |
| 427 | static bool instr_is_unreachable(IrInstruction *instruction) { | 427 | static 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; |
| 429 | } | 429 | } |
| 430 | | 430 | |
| 431 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { | 431 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { |
| ... | @@ -449,7 +449,7 @@ static void ir_ref_var(ZigVar *var) { | ... | @@ -449,7 +449,7 @@ static void ir_ref_var(ZigVar *var) { |
| 449 | } | 449 | } |
| 450 | | 450 | |
| 451 | ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { | 451 | ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| 452 | ConstExprValue *result = ir_eval_const_value(ira->codegen, scope, node, ira->codegen->builtin_types.entry_type, | 452 | ZigValue *result = ir_eval_const_value(ira->codegen, scope, node, ira->codegen->builtin_types.entry_type, |
| 453 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, nullptr, | 453 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, nullptr, |
| 454 | node, nullptr, ira->new_irb.exec, nullptr, UndefBad); | 454 | node, nullptr, ira->new_irb.exec, nullptr, UndefBad); |
| 455 | | 455 | |
| ... | @@ -1156,7 +1156,24 @@ static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_no | ... | @@ -1156,7 +1156,24 @@ static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_no |
| 1156 | special_instruction->base.source_node = source_node; | 1156 | special_instruction->base.source_node = source_node; |
| 1157 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 1157 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); |
| 1158 | special_instruction->base.owner_bb = irb->current_basic_block; | 1158 | 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"); |
| | 1161 | return special_instruction; |
| | 1162 | } |
| | 1163 | |
| | 1164 | template<typename T> |
| | 1165 | static T *ir_create_instruction_noval(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| | 1166 | const char *name = nullptr; |
| | 1167 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 1168 | T *dummy = nullptr; |
| | 1169 | name = ir_instruction_type_str(ir_instruction_id(dummy)); |
| | 1170 | #endif |
| | 1171 | T *special_instruction = allocate<T>(1, name); |
| | 1172 | special_instruction->base.id = ir_instruction_id(special_instruction); |
| | 1173 | special_instruction->base.scope = scope; |
| | 1174 | special_instruction->base.source_node = source_node; |
| | 1175 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); |
| | 1176 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1160 | return special_instruction; | 1177 | return special_instruction; |
| 1161 | } | 1178 | } |
| 1162 | | 1179 | |
| ... | @@ -1184,8 +1201,8 @@ static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -1184,8 +1201,8 @@ static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *so |
| 1184 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) | 1201 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) |
| 1185 | { | 1202 | { |
| 1186 | IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node); | 1203 | 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; | 1204 | cond_br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1188 | cond_br_instruction->base.value.special = ConstValSpecialStatic; | 1205 | cond_br_instruction->base.value->special = ConstValSpecialStatic; |
| 1189 | cond_br_instruction->condition = condition; | 1206 | cond_br_instruction->condition = condition; |
| 1190 | cond_br_instruction->then_block = then_block; | 1207 | cond_br_instruction->then_block = then_block; |
| 1191 | cond_br_instruction->else_block = else_block; | 1208 | cond_br_instruction->else_block = else_block; |
| ... | @@ -1203,8 +1220,8 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1203,8 +1220,8 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1203 | IrInstruction *operand) | 1220 | IrInstruction *operand) |
| 1204 | { | 1221 | { |
| 1205 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); | 1222 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); |
| 1206 | return_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1223 | return_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1207 | return_instruction->base.value.special = ConstValSpecialStatic; | 1224 | return_instruction->base.value->special = ConstValSpecialStatic; |
| 1208 | return_instruction->operand = operand; | 1225 | return_instruction->operand = operand; |
| 1209 | | 1226 | |
| 1210 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); | 1227 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); |
| ... | @@ -1213,55 +1230,64 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1213,55 +1230,64 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1213 | } | 1230 | } |
| 1214 | | 1231 | |
| 1215 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1232 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1216 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1233 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1217 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1234 | memprof_intern_count.x_void += 1; |
| 1218 | const_instruction->base.value.special = ConstValSpecialStatic; | 1235 | #endif |
| | 1236 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); |
| | 1237 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| | 1238 | const_instruction->base.value = &irb->codegen->intern_values.x_void; |
| 1219 | return &const_instruction->base; | 1239 | return &const_instruction->base; |
| 1220 | } | 1240 | } |
| 1221 | | 1241 | |
| 1222 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1242 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1223 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1243 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1224 | const_instruction->base.value.special = ConstValSpecialUndef; | 1244 | memprof_intern_count.x_undefined += 1; |
| 1225 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_undef; | 1245 | #endif |
| | 1246 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); |
| | 1247 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| | 1248 | const_instruction->base.value = &irb->codegen->intern_values.x_undefined; |
| 1226 | return &const_instruction->base; | 1249 | return &const_instruction->base; |
| 1227 | } | 1250 | } |
| 1228 | | 1251 | |
| 1229 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 1252 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1230 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1253 | 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; | 1254 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1232 | const_instruction->base.value.special = ConstValSpecialStatic; | 1255 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1233 | bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value); | 1256 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); |
| 1234 | return &const_instruction->base; | 1257 | return &const_instruction->base; |
| 1235 | } | 1258 | } |
| 1236 | | 1259 | |
| 1237 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { | 1260 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { |
| 1238 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1261 | 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; | 1262 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1240 | const_instruction->base.value.special = ConstValSpecialStatic; | 1263 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1241 | bigint_init_bigint(&const_instruction->base.value.data.x_bigint, bigint); | 1264 | bigint_init_bigint(&const_instruction->base.value->data.x_bigint, bigint); |
| 1242 | return &const_instruction->base; | 1265 | return &const_instruction->base; |
| 1243 | } | 1266 | } |
| 1244 | | 1267 | |
| 1245 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { | 1268 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { |
| 1246 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1269 | 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; | 1270 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_float; |
| 1248 | const_instruction->base.value.special = ConstValSpecialStatic; | 1271 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1249 | bigfloat_init_bigfloat(&const_instruction->base.value.data.x_bigfloat, bigfloat); | 1272 | bigfloat_init_bigfloat(&const_instruction->base.value->data.x_bigfloat, bigfloat); |
| 1250 | return &const_instruction->base; | 1273 | return &const_instruction->base; |
| 1251 | } | 1274 | } |
| 1252 | | 1275 | |
| 1253 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1276 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1254 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1277 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1255 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_null; | 1278 | memprof_intern_count.x_null += 1; |
| 1256 | const_instruction->base.value.special = ConstValSpecialStatic; | 1279 | #endif |
| | 1280 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); |
| | 1281 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| | 1282 | const_instruction->base.value = &irb->codegen->intern_values.x_null; |
| 1257 | return &const_instruction->base; | 1283 | return &const_instruction->base; |
| 1258 | } | 1284 | } |
| 1259 | | 1285 | |
| 1260 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 1286 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1261 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1287 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1262 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_usize; | 1288 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_usize; |
| 1263 | const_instruction->base.value.special = ConstValSpecialStatic; | 1289 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1264 | bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value); | 1290 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); |
| 1265 | return &const_instruction->base; | 1291 | return &const_instruction->base; |
| 1266 | } | 1292 | } |
| 1267 | | 1293 | |
| ... | @@ -1269,9 +1295,9 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1269,9 +1295,9 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode |
| 1269 | ZigType *type_entry) | 1295 | ZigType *type_entry) |
| 1270 | { | 1296 | { |
| 1271 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1297 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1272 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; | 1298 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; |
| 1273 | const_instruction->base.value.special = ConstValSpecialStatic; | 1299 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1274 | const_instruction->base.value.data.x_type = type_entry; | 1300 | const_instruction->base.value->data.x_type = type_entry; |
| 1275 | return &const_instruction->base; | 1301 | return &const_instruction->base; |
| 1276 | } | 1302 | } |
| 1277 | | 1303 | |
| ... | @@ -1285,35 +1311,35 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1285,35 +1311,35 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode |
| 1285 | | 1311 | |
| 1286 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | 1312 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { |
| 1287 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1313 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1288 | const_instruction->base.value.type = fn_entry->type_entry; | 1314 | const_instruction->base.value->type = fn_entry->type_entry; |
| 1289 | const_instruction->base.value.special = ConstValSpecialStatic; | 1315 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1290 | const_instruction->base.value.data.x_ptr.data.fn.fn_entry = fn_entry; | 1316 | const_instruction->base.value->data.x_ptr.data.fn.fn_entry = fn_entry; |
| 1291 | const_instruction->base.value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 1317 | const_instruction->base.value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 1292 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialFunction; | 1318 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialFunction; |
| 1293 | return &const_instruction->base; | 1319 | return &const_instruction->base; |
| 1294 | } | 1320 | } |
| 1295 | | 1321 | |
| 1296 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { | 1322 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { |
| 1297 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1323 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1298 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; | 1324 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; |
| 1299 | const_instruction->base.value.special = ConstValSpecialStatic; | 1325 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1300 | const_instruction->base.value.data.x_type = import; | 1326 | const_instruction->base.value->data.x_type = import; |
| 1301 | return &const_instruction->base; | 1327 | return &const_instruction->base; |
| 1302 | } | 1328 | } |
| 1303 | | 1329 | |
| 1304 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { | 1330 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { |
| 1305 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1331 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1306 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool; | 1332 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_bool; |
| 1307 | const_instruction->base.value.special = ConstValSpecialStatic; | 1333 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1308 | const_instruction->base.value.data.x_bool = value; | 1334 | const_instruction->base.value->data.x_bool = value; |
| 1309 | return &const_instruction->base; | 1335 | return &const_instruction->base; |
| 1310 | } | 1336 | } |
| 1311 | | 1337 | |
| 1312 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { | 1338 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 1313 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1339 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1314 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_enum_literal; | 1340 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_enum_literal; |
| 1315 | const_instruction->base.value.special = ConstValSpecialStatic; | 1341 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1316 | const_instruction->base.value.data.x_enum_literal = name; | 1342 | const_instruction->base.value->data.x_enum_literal = name; |
| 1317 | return &const_instruction->base; | 1343 | return &const_instruction->base; |
| 1318 | } | 1344 | } |
| 1319 | | 1345 | |
| ... | @@ -1321,19 +1347,20 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN | ... | @@ -1321,19 +1347,20 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN |
| 1321 | ZigFn *fn_entry, IrInstruction *first_arg) | 1347 | ZigFn *fn_entry, IrInstruction *first_arg) |
| 1322 | { | 1348 | { |
| 1323 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1349 | 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); | 1350 | const_instruction->base.value->type = get_bound_fn_type(irb->codegen, fn_entry); |
| 1325 | const_instruction->base.value.special = ConstValSpecialStatic; | 1351 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1326 | const_instruction->base.value.data.x_bound_fn.fn = fn_entry; | 1352 | const_instruction->base.value->data.x_bound_fn.fn = fn_entry; |
| 1327 | const_instruction->base.value.data.x_bound_fn.first_arg = first_arg; | 1353 | const_instruction->base.value->data.x_bound_fn.first_arg = first_arg; |
| 1328 | return &const_instruction->base; | 1354 | return &const_instruction->base; |
| 1329 | } | 1355 | } |
| 1330 | | 1356 | |
| 1331 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 1357 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1332 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1358 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1333 | init_const_str_lit(irb->codegen, &const_instruction->base.value, str); | 1359 | init_const_str_lit(irb->codegen, const_instruction->base.value, str); |
| 1334 | | 1360 | |
| 1335 | return &const_instruction->base; | 1361 | return &const_instruction->base; |
| 1336 | } | 1362 | } |
| | 1363 | |
| 1337 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 1364 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1338 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); | 1365 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); |
| 1339 | ir_instruction_append(irb->current_basic_block, instruction); | 1366 | ir_instruction_append(irb->current_basic_block, instruction); |
| ... | @@ -1388,7 +1415,7 @@ static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -1388,7 +1415,7 @@ static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *so |
| 1388 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 1415 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 1389 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, | 1416 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, |
| 1390 | source_instruction->scope, source_instruction->source_node); | 1417 | source_instruction->scope, source_instruction->source_node); |
| 1391 | instruction->base.value.type = ty; | 1418 | instruction->base.value->type = ty; |
| 1392 | return &instruction->base; | 1419 | return &instruction->base; |
| 1393 | } | 1420 | } |
| 1394 | | 1421 | |
| ... | @@ -1513,7 +1540,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so | ... | @@ -1513,7 +1540,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so |
| 1513 | { | 1540 | { |
| 1514 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, | 1541 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, |
| 1515 | source_instruction->scope, source_instruction->source_node); | 1542 | source_instruction->scope, source_instruction->source_node); |
| 1516 | call_instruction->base.value.type = return_type; | 1543 | call_instruction->base.value->type = return_type; |
| 1517 | call_instruction->fn_entry = fn_entry; | 1544 | call_instruction->fn_entry = fn_entry; |
| 1518 | call_instruction->fn_ref = fn_ref; | 1545 | call_instruction->fn_ref = fn_ref; |
| 1519 | call_instruction->fn_inline = fn_inline; | 1546 | call_instruction->fn_inline = fn_inline; |
| ... | @@ -1558,8 +1585,8 @@ static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -1558,8 +1585,8 @@ static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source |
| 1558 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 1585 | IrBasicBlock *dest_block, IrInstruction *is_comptime) |
| 1559 | { | 1586 | { |
| 1560 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); | 1587 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); |
| 1561 | br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1588 | br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1562 | br_instruction->base.value.special = ConstValSpecialStatic; | 1589 | br_instruction->base.value->special = ConstValSpecialStatic; |
| 1563 | br_instruction->dest_block = dest_block; | 1590 | br_instruction->dest_block = dest_block; |
| 1564 | br_instruction->is_comptime = is_comptime; | 1591 | br_instruction->is_comptime = is_comptime; |
| 1565 | | 1592 | |
| ... | @@ -1659,8 +1686,8 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop | ... | @@ -1659,8 +1686,8 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop |
| 1659 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1686 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1660 | IrInstructionUnreachable *unreachable_instruction = | 1687 | IrInstructionUnreachable *unreachable_instruction = |
| 1661 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); | 1688 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); |
| 1662 | unreachable_instruction->base.value.special = ConstValSpecialStatic; | 1689 | unreachable_instruction->base.value->special = ConstValSpecialStatic; |
| 1663 | unreachable_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1690 | unreachable_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1664 | return &unreachable_instruction->base; | 1691 | return &unreachable_instruction->base; |
| 1665 | } | 1692 | } |
| 1666 | | 1693 | |
| ... | @@ -1668,8 +1695,8 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A | ... | @@ -1668,8 +1695,8 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A |
| 1668 | IrInstruction *ptr, IrInstruction *value) | 1695 | IrInstruction *ptr, IrInstruction *value) |
| 1669 | { | 1696 | { |
| 1670 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); | 1697 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); |
| 1671 | instruction->base.value.special = ConstValSpecialStatic; | 1698 | instruction->base.value->special = ConstValSpecialStatic; |
| 1672 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1699 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1673 | instruction->ptr = ptr; | 1700 | instruction->ptr = ptr; |
| 1674 | instruction->value = value; | 1701 | instruction->value = value; |
| 1675 | | 1702 | |
| ... | @@ -1684,7 +1711,7 @@ static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction * | ... | @@ -1684,7 +1711,7 @@ static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction * |
| 1684 | { | 1711 | { |
| 1685 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( | 1712 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( |
| 1686 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1713 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1687 | inst->base.value.type = ira->codegen->builtin_types.entry_void; | 1714 | inst->base.value->type = ira->codegen->builtin_types.entry_void; |
| 1688 | inst->vector_ptr = vector_ptr; | 1715 | inst->vector_ptr = vector_ptr; |
| 1689 | inst->index = index; | 1716 | inst->index = index; |
| 1690 | inst->value = value; | 1717 | inst->value = value; |
| ... | @@ -1700,8 +1727,8 @@ static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -1700,8 +1727,8 @@ static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNod |
| 1700 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) | 1727 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) |
| 1701 | { | 1728 | { |
| 1702 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); | 1729 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); |
| 1703 | decl_var_instruction->base.value.special = ConstValSpecialStatic; | 1730 | decl_var_instruction->base.value->special = ConstValSpecialStatic; |
| 1704 | decl_var_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1731 | decl_var_instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1705 | decl_var_instruction->var = var; | 1732 | decl_var_instruction->var = var; |
| 1706 | decl_var_instruction->align_value = align_value; | 1733 | decl_var_instruction->align_value = align_value; |
| 1707 | decl_var_instruction->ptr = ptr; | 1734 | decl_var_instruction->ptr = ptr; |
| ... | @@ -1717,8 +1744,8 @@ static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -1717,8 +1744,8 @@ static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *sourc |
| 1717 | { | 1744 | { |
| 1718 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, | 1745 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, |
| 1719 | source_instruction->scope, source_instruction->source_node); | 1746 | source_instruction->scope, source_instruction->source_node); |
| 1720 | decl_var_instruction->base.value.special = ConstValSpecialStatic; | 1747 | decl_var_instruction->base.value->special = ConstValSpecialStatic; |
| 1721 | decl_var_instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 1748 | decl_var_instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 1722 | decl_var_instruction->var = var; | 1749 | decl_var_instruction->var = var; |
| 1723 | decl_var_instruction->var_ptr = var_ptr; | 1750 | decl_var_instruction->var_ptr = var_ptr; |
| 1724 | | 1751 | |
| ... | @@ -1732,7 +1759,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -1732,7 +1759,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc |
| 1732 | { | 1759 | { |
| 1733 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, | 1760 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, |
| 1734 | source_instruction->scope, source_instruction->source_node); | 1761 | source_instruction->scope, source_instruction->source_node); |
| 1735 | instruction->base.value.type = ty; | 1762 | instruction->base.value->type = ty; |
| 1736 | instruction->operand = operand; | 1763 | instruction->operand = operand; |
| 1737 | instruction->result_loc = result_loc; | 1764 | instruction->result_loc = result_loc; |
| 1738 | | 1765 | |
| ... | @@ -1747,8 +1774,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1747,8 +1774,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1747 | { | 1774 | { |
| 1748 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( | 1775 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( |
| 1749 | irb, scope, source_node); | 1776 | irb, scope, source_node); |
| 1750 | export_instruction->base.value.special = ConstValSpecialStatic; | 1777 | export_instruction->base.value->special = ConstValSpecialStatic; |
| 1751 | export_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1778 | export_instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1752 | export_instruction->name = name; | 1779 | export_instruction->name = name; |
| 1753 | export_instruction->target = target; | 1780 | export_instruction->target = target; |
| 1754 | export_instruction->linkage = linkage; | 1781 | export_instruction->linkage = linkage; |
| ... | @@ -1925,7 +1952,7 @@ static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *sour | ... | @@ -1925,7 +1952,7 @@ static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *sour |
| 1925 | { | 1952 | { |
| 1926 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( | 1953 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( |
| 1927 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1954 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1928 | instruction->base.value.type = result_ty; | 1955 | instruction->base.value->type = result_ty; |
| 1929 | instruction->operand = operand; | 1956 | instruction->operand = operand; |
| 1930 | instruction->result_loc = result_loc; | 1957 | instruction->result_loc = result_loc; |
| 1931 | | 1958 | |
| ... | @@ -1940,7 +1967,7 @@ static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *s | ... | @@ -1940,7 +1967,7 @@ static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *s |
| 1940 | { | 1967 | { |
| 1941 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( | 1968 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( |
| 1942 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1969 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1943 | instruction->base.value.type = result_type; | 1970 | instruction->base.value->type = result_type; |
| 1944 | instruction->operand = operand; | 1971 | instruction->operand = operand; |
| 1945 | instruction->result_loc = result_loc; | 1972 | instruction->result_loc = result_loc; |
| 1946 | | 1973 | |
| ... | @@ -1955,7 +1982,7 @@ static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *sour | ... | @@ -1955,7 +1982,7 @@ static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *sour |
| 1955 | { | 1982 | { |
| 1956 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( | 1983 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( |
| 1957 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1984 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1958 | instruction->base.value.type = result_type; | 1985 | instruction->base.value->type = result_type; |
| 1959 | instruction->operand = operand; | 1986 | instruction->operand = operand; |
| 1960 | instruction->result_loc = result_loc; | 1987 | instruction->result_loc = result_loc; |
| 1961 | | 1988 | |
| ... | @@ -2025,8 +2052,8 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2025,8 +2052,8 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2025 | IrInstruction *switch_prongs_void) | 2052 | IrInstruction *switch_prongs_void) |
| 2026 | { | 2053 | { |
| 2027 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); | 2054 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); |
| 2028 | instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 2055 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 2029 | instruction->base.value.special = ConstValSpecialStatic; | 2056 | instruction->base.value->special = ConstValSpecialStatic; |
| 2030 | instruction->target_value = target_value; | 2057 | instruction->target_value = target_value; |
| 2031 | instruction->else_block = else_block; | 2058 | instruction->else_block = else_block; |
| 2032 | instruction->case_count = case_count; | 2059 | instruction->case_count = case_count; |
| ... | @@ -2122,7 +2149,7 @@ static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -2122,7 +2149,7 @@ static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_ins |
| 2122 | { | 2149 | { |
| 2123 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, | 2150 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, |
| 2124 | source_instruction->scope, source_instruction->source_node); | 2151 | source_instruction->scope, source_instruction->source_node); |
| 2125 | instruction->base.value.type = result_type; | 2152 | instruction->base.value->type = result_type; |
| 2126 | instruction->operand = operand; | 2153 | instruction->operand = operand; |
| 2127 | instruction->result_loc = result_loc; | 2154 | instruction->result_loc = result_loc; |
| 2128 | | 2155 | |
| ... | @@ -2237,7 +2264,7 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source | ... | @@ -2237,7 +2264,7 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source |
| 2237 | { | 2264 | { |
| 2238 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, | 2265 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, |
| 2239 | source_instruction->scope, source_instruction->source_node); | 2266 | source_instruction->scope, source_instruction->source_node); |
| 2240 | instruction->base.value.type = result_type; | 2267 | instruction->base.value->type = result_type; |
| 2241 | instruction->ptr = ptr; | 2268 | instruction->ptr = ptr; |
| 2242 | instruction->cmp_value = cmp_value; | 2269 | instruction->cmp_value = cmp_value; |
| 2243 | instruction->new_value = new_value; | 2270 | instruction->new_value = new_value; |
| ... | @@ -2482,7 +2509,7 @@ static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -2482,7 +2509,7 @@ static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_i |
| 2482 | { | 2509 | { |
| 2483 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( | 2510 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( |
| 2484 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2511 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2485 | instruction->base.value.type = result_type; | 2512 | instruction->base.value->type = result_type; |
| 2486 | instruction->scalar = scalar; | 2513 | instruction->scalar = scalar; |
| 2487 | | 2514 | |
| 2488 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); | 2515 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); |
| ... | @@ -2495,7 +2522,7 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -2495,7 +2522,7 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i |
| 2495 | { | 2522 | { |
| 2496 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( | 2523 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( |
| 2497 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2524 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2498 | instruction->base.value.type = slice_type; | 2525 | instruction->base.value->type = slice_type; |
| 2499 | instruction->ptr = ptr; | 2526 | instruction->ptr = ptr; |
| 2500 | instruction->start = start; | 2527 | instruction->start = start; |
| 2501 | instruction->end = end; | 2528 | instruction->end = end; |
| ... | @@ -2709,7 +2736,7 @@ static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2709,7 +2736,7 @@ static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2709 | { | 2736 | { |
| 2710 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( | 2737 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( |
| 2711 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2738 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2712 | instruction->base.value.type = ira->codegen->builtin_types.entry_bool; | 2739 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 2713 | instruction->err_union = err_union; | 2740 | instruction->err_union = err_union; |
| 2714 | | 2741 | |
| 2715 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); | 2742 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); |
| ... | @@ -2792,7 +2819,7 @@ static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2792,7 +2819,7 @@ static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2792 | { | 2819 | { |
| 2793 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( | 2820 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( |
| 2794 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2821 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2795 | instruction->base.value.type = ptr_type; | 2822 | instruction->base.value->type = ptr_type; |
| 2796 | instruction->ptr = ptr; | 2823 | instruction->ptr = ptr; |
| 2797 | instruction->safety_check_on = safety_check_on; | 2824 | instruction->safety_check_on = safety_check_on; |
| 2798 | | 2825 | |
| ... | @@ -2806,7 +2833,7 @@ static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2806,7 +2833,7 @@ static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2806 | { | 2833 | { |
| 2807 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( | 2834 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( |
| 2808 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2835 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2809 | instruction->base.value.type = ty; | 2836 | instruction->base.value->type = ty; |
| 2810 | instruction->ptr = ptr; | 2837 | instruction->ptr = ptr; |
| 2811 | instruction->result_loc = result_loc; | 2838 | instruction->result_loc = result_loc; |
| 2812 | | 2839 | |
| ... | @@ -2845,7 +2872,7 @@ static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2845,7 +2872,7 @@ static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2845 | { | 2872 | { |
| 2846 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( | 2873 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( |
| 2847 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2874 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2848 | instruction->base.value.type = ty; | 2875 | instruction->base.value->type = ty; |
| 2849 | instruction->operand = operand; | 2876 | instruction->operand = operand; |
| 2850 | | 2877 | |
| 2851 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 2878 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); |
| ... | @@ -2997,8 +3024,8 @@ static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2997,8 +3024,8 @@ static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *s |
| 2997 | | 3024 | |
| 2998 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 3025 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { |
| 2999 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); | 3026 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); |
| 3000 | instruction->base.value.special = ConstValSpecialStatic; | 3027 | instruction->base.value->special = ConstValSpecialStatic; |
| 3001 | instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 3028 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 3002 | instruction->msg = msg; | 3029 | instruction->msg = msg; |
| 3003 | | 3030 | |
| 3004 | ir_ref_instruction(msg, irb->current_basic_block); | 3031 | ir_ref_instruction(msg, irb->current_basic_block); |
| ... | @@ -3328,7 +3355,7 @@ static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *so | ... | @@ -3328,7 +3355,7 @@ static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *so |
| 3328 | { | 3355 | { |
| 3329 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, | 3356 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, |
| 3330 | source_instruction->scope, source_instruction->source_node); | 3357 | source_instruction->scope, source_instruction->source_node); |
| 3331 | instruction->base.value.type = result_type; | 3358 | instruction->base.value->type = result_type; |
| 3332 | instruction->vector = vector; | 3359 | instruction->vector = vector; |
| 3333 | instruction->result_loc = result_loc; | 3360 | instruction->result_loc = result_loc; |
| 3334 | | 3361 | |
| ... | @@ -3343,7 +3370,7 @@ static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstructi | ... | @@ -3343,7 +3370,7 @@ static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstructi |
| 3343 | { | 3370 | { |
| 3344 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, | 3371 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, |
| 3345 | source_instruction->scope, source_instruction->source_node); | 3372 | source_instruction->scope, source_instruction->source_node); |
| 3346 | instruction->base.value.type = result_type; | 3373 | instruction->base.value->type = result_type; |
| 3347 | instruction->operand = operand; | 3374 | instruction->operand = operand; |
| 3348 | instruction->result_loc = result_loc; | 3375 | instruction->result_loc = result_loc; |
| 3349 | | 3376 | |
| ... | @@ -3358,7 +3385,7 @@ static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *so | ... | @@ -3358,7 +3385,7 @@ static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *so |
| 3358 | { | 3385 | { |
| 3359 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, | 3386 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, |
| 3360 | source_instruction->scope, source_instruction->source_node); | 3387 | source_instruction->scope, source_instruction->source_node); |
| 3361 | instruction->base.value.type = result_type; | 3388 | instruction->base.value->type = result_type; |
| 3362 | instruction->array = array; | 3389 | instruction->array = array; |
| 3363 | | 3390 | |
| 3364 | ir_ref_instruction(array, ira->new_irb.current_basic_block); | 3391 | ir_ref_instruction(array, ira->new_irb.current_basic_block); |
| ... | @@ -3371,7 +3398,7 @@ static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source | ... | @@ -3371,7 +3398,7 @@ static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source |
| 3371 | { | 3398 | { |
| 3372 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, | 3399 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, |
| 3373 | source_instruction->scope, source_instruction->source_node); | 3400 | source_instruction->scope, source_instruction->source_node); |
| 3374 | instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 3401 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3375 | instruction->target = target; | 3402 | instruction->target = target; |
| 3376 | | 3403 | |
| 3377 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 3404 | ir_ref_instruction(target, ira->new_irb.current_basic_block); |
| ... | @@ -3384,7 +3411,7 @@ static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -3384,7 +3411,7 @@ static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *so |
| 3384 | { | 3411 | { |
| 3385 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, | 3412 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, |
| 3386 | source_instruction->scope, source_instruction->source_node); | 3413 | source_instruction->scope, source_instruction->source_node); |
| 3387 | instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 3414 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3388 | instruction->target = target; | 3415 | instruction->target = target; |
| 3389 | | 3416 | |
| 3390 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 3417 | ir_ref_instruction(target, ira->new_irb.current_basic_block); |
| ... | @@ -3433,7 +3460,7 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3433,7 +3460,7 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s |
| 3433 | | 3460 | |
| 3434 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3461 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 3435 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); | 3462 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); |
| 3436 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3463 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3437 | | 3464 | |
| 3438 | return instruction; | 3465 | return instruction; |
| 3439 | } | 3466 | } |
| ... | @@ -3442,7 +3469,7 @@ static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3442,7 +3469,7 @@ static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstN |
| 3442 | IrInstructionSuspendBegin *begin) | 3469 | IrInstructionSuspendBegin *begin) |
| 3443 | { | 3470 | { |
| 3444 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); | 3471 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); |
| 3445 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3472 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3446 | instruction->begin = begin; | 3473 | instruction->begin = begin; |
| 3447 | | 3474 | |
| 3448 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 3475 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| ... | @@ -3467,7 +3494,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * | ... | @@ -3467,7 +3494,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * |
| 3467 | { | 3494 | { |
| 3468 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, | 3495 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, |
| 3469 | source_instruction->scope, source_instruction->source_node); | 3496 | source_instruction->scope, source_instruction->source_node); |
| 3470 | instruction->base.value.type = result_type; | 3497 | instruction->base.value->type = result_type; |
| 3471 | instruction->frame = frame; | 3498 | instruction->frame = frame; |
| 3472 | instruction->result_loc = result_loc; | 3499 | instruction->result_loc = result_loc; |
| 3473 | | 3500 | |
| ... | @@ -3479,7 +3506,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * | ... | @@ -3479,7 +3506,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * |
| 3479 | | 3506 | |
| 3480 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { | 3507 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { |
| 3481 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); | 3508 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); |
| 3482 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3509 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3483 | instruction->frame = frame; | 3510 | instruction->frame = frame; |
| 3484 | | 3511 | |
| 3485 | ir_ref_instruction(frame, irb->current_basic_block); | 3512 | ir_ref_instruction(frame, irb->current_basic_block); |
| ... | @@ -3491,8 +3518,8 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop | ... | @@ -3491,8 +3518,8 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop |
| 3491 | IrInstruction *operand, SpillId spill_id) | 3518 | IrInstruction *operand, SpillId spill_id) |
| 3492 | { | 3519 | { |
| 3493 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); | 3520 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); |
| 3494 | instruction->base.value.special = ConstValSpecialStatic; | 3521 | instruction->base.value->special = ConstValSpecialStatic; |
| 3495 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3522 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3496 | instruction->operand = operand; | 3523 | instruction->operand = operand; |
| 3497 | instruction->spill_id = spill_id; | 3524 | instruction->spill_id = spill_id; |
| 3498 | | 3525 | |
| ... | @@ -3517,7 +3544,7 @@ static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction | ... | @@ -3517,7 +3544,7 @@ static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction |
| 3517 | { | 3544 | { |
| 3518 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( | 3545 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( |
| 3519 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3546 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3520 | instruction->base.value.type = vector->value.type->data.vector.elem_type; | 3547 | instruction->base.value->type = vector->value->type->data.vector.elem_type; |
| 3521 | instruction->vector = vector; | 3548 | instruction->vector = vector; |
| 3522 | instruction->index = index; | 3549 | instruction->index = index; |
| 3523 | | 3550 | |
| ... | @@ -3588,8 +3615,8 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -3588,8 +3615,8 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 3588 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; | 3615 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; |
| 3589 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); | 3616 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); |
| 3590 | if (defer_expr_value != irb->codegen->invalid_instruction) { | 3617 | if (defer_expr_value != irb->codegen->invalid_instruction) { |
| 3591 | if (defer_expr_value->value.type != nullptr && | 3618 | if (defer_expr_value->value->type != nullptr && |
| 3592 | defer_expr_value->value.type->id == ZigTypeIdUnreachable) | 3619 | defer_expr_value->value->type->id == ZigTypeIdUnreachable) |
| 3593 | { | 3620 | { |
| 3594 | is_noreturn = true; | 3621 | is_noreturn = true; |
| 3595 | } else { | 3622 | } else { |
| ... | @@ -4411,7 +4438,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode | ... | @@ -4411,7 +4438,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 4411 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); | 4438 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); |
| 4412 | tld_var->base.resolution = TldResolutionInvalid; | 4439 | tld_var->base.resolution = TldResolutionInvalid; |
| 4413 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, | 4440 | 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); | 4441 | g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid); |
| 4415 | scope_decls->decl_table.put(var_name, &tld_var->base); | 4442 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 4416 | } | 4443 | } |
| 4417 | | 4444 | |
| ... | @@ -4424,10 +4451,10 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4424,10 +4451,10 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4424 | if (buf_eql_str(variable_name, "_")) { | 4451 | if (buf_eql_str(variable_name, "_")) { |
| 4425 | if (lval == LValPtr) { | 4452 | if (lval == LValPtr) { |
| 4426 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); | 4453 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); |
| 4427 | const_instruction->base.value.type = get_pointer_to_type(irb->codegen, | 4454 | const_instruction->base.value->type = get_pointer_to_type(irb->codegen, |
| 4428 | irb->codegen->builtin_types.entry_void, false); | 4455 | irb->codegen->builtin_types.entry_void, false); |
| 4429 | const_instruction->base.value.special = ConstValSpecialStatic; | 4456 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 4430 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialDiscard; | 4457 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialDiscard; |
| 4431 | return &const_instruction->base; | 4458 | return &const_instruction->base; |
| 4432 | } else { | 4459 | } else { |
| 4433 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); | 4460 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); |
| ... | @@ -8698,26 +8725,26 @@ static void ir_assert(bool ok, IrInstruction *source_instruction) { | ... | @@ -8698,26 +8725,26 @@ static void ir_assert(bool ok, IrInstruction *source_instruction) { |
| 8698 | // This function takes a comptime ptr and makes the child const value conform to the type | 8725 | // This function takes a comptime ptr and makes the child const value conform to the type |
| 8699 | // described by the pointer. | 8726 | // described by the pointer. |
| 8700 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 8727 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 8701 | ConstExprValue *ptr_val) | 8728 | ZigValue *ptr_val) |
| 8702 | { | 8729 | { |
| 8703 | Error err; | 8730 | Error err; |
| 8704 | assert(ptr_val->type->id == ZigTypeIdPointer); | 8731 | assert(ptr_val->type->id == ZigTypeIdPointer); |
| 8705 | assert(ptr_val->special == ConstValSpecialStatic); | 8732 | assert(ptr_val->special == ConstValSpecialStatic); |
| 8706 | ConstExprValue tmp = {}; | 8733 | ZigValue tmp = {}; |
| 8707 | tmp.special = ConstValSpecialStatic; | 8734 | tmp.special = ConstValSpecialStatic; |
| 8708 | tmp.type = ptr_val->type->data.pointer.child_type; | 8735 | tmp.type = ptr_val->type->data.pointer.child_type; |
| 8709 | if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val))) | 8736 | if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val))) |
| 8710 | return err; | 8737 | return err; |
| 8711 | ConstExprValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val); | 8738 | ZigValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val); |
| 8712 | copy_const_val(child_val, &tmp, false); | 8739 | copy_const_val(child_val, &tmp, false); |
| 8713 | return ErrorNone; | 8740 | return ErrorNone; |
| 8714 | } | 8741 | } |
| 8715 | | 8742 | |
| 8716 | ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprValue *const_val, | 8743 | ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_val, |
| 8717 | AstNode *source_node) | 8744 | AstNode *source_node) |
| 8718 | { | 8745 | { |
| 8719 | Error err; | 8746 | Error err; |
| 8720 | ConstExprValue *val = const_ptr_pointee_unchecked(codegen, const_val); | 8747 | ZigValue *val = const_ptr_pointee_unchecked(codegen, const_val); |
| 8721 | assert(val != nullptr); | 8748 | assert(val != nullptr); |
| 8722 | assert(const_val->type->id == ZigTypeIdPointer); | 8749 | assert(const_val->type->id == ZigTypeIdPointer); |
| 8723 | ZigType *expected_type = const_val->type->data.pointer.child_type; | 8750 | ZigType *expected_type = const_val->type->data.pointer.child_type; |
| ... | @@ -8740,19 +8767,19 @@ ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprVal | ... | @@ -8740,19 +8767,19 @@ ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprVal |
| 8740 | return val; | 8767 | return val; |
| 8741 | } | 8768 | } |
| 8742 | | 8769 | |
| 8743 | static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { | 8770 | static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { |
| 8744 | IrBasicBlock *bb = exec->basic_block_list.at(0); | 8771 | IrBasicBlock *bb = exec->basic_block_list.at(0); |
| 8745 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { | 8772 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 8746 | IrInstruction *instruction = bb->instruction_list.at(i); | 8773 | IrInstruction *instruction = bb->instruction_list.at(i); |
| 8747 | if (instruction->id == IrInstructionIdReturn) { | 8774 | if (instruction->id == IrInstructionIdReturn) { |
| 8748 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; | 8775 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; |
| 8749 | IrInstruction *operand = ret_inst->operand; | 8776 | IrInstruction *operand = ret_inst->operand; |
| 8750 | if (operand->value.special == ConstValSpecialRuntime) { | 8777 | if (operand->value->special == ConstValSpecialRuntime) { |
| 8751 | exec_add_error_node(codegen, exec, operand->source_node, | 8778 | exec_add_error_node(codegen, exec, operand->source_node, |
| 8752 | buf_sprintf("unable to evaluate constant expression")); | 8779 | buf_sprintf("unable to evaluate constant expression")); |
| 8753 | return &codegen->invalid_instruction->value; | 8780 | return codegen->invalid_instruction->value; |
| 8754 | } | 8781 | } |
| 8755 | return &operand->value; | 8782 | return operand->value; |
| 8756 | } else if (ir_has_side_effects(instruction)) { | 8783 | } else if (ir_has_side_effects(instruction)) { |
| 8757 | if (instr_is_comptime(instruction)) { | 8784 | if (instr_is_comptime(instruction)) { |
| 8758 | switch (instruction->id) { | 8785 | switch (instruction->id) { |
| ... | @@ -8769,7 +8796,7 @@ static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec | ... | @@ -8769,7 +8796,7 @@ static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec |
| 8769 | } | 8796 | } |
| 8770 | exec_add_error_node(codegen, exec, instruction->source_node, | 8797 | exec_add_error_node(codegen, exec, instruction->source_node, |
| 8771 | buf_sprintf("unable to evaluate constant expression")); | 8798 | buf_sprintf("unable to evaluate constant expression")); |
| 8772 | return &codegen->invalid_instruction->value; | 8799 | return codegen->invalid_instruction->value; |
| 8773 | } | 8800 | } |
| 8774 | } | 8801 | } |
| 8775 | zig_unreachable(); | 8802 | zig_unreachable(); |
| ... | @@ -8783,14 +8810,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so | ... | @@ -8783,14 +8810,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so |
| 8783 | return true; | 8810 | return true; |
| 8784 | } | 8811 | } |
| 8785 | | 8812 | |
| 8786 | static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) { | 8813 | static bool const_val_fits_in_num_lit(ZigValue *const_val, ZigType *num_lit_type) { |
| 8787 | return ((num_lit_type->id == ZigTypeIdComptimeFloat && | 8814 | return ((num_lit_type->id == ZigTypeIdComptimeFloat && |
| 8788 | (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) || | 8815 | (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) || |
| 8789 | (num_lit_type->id == ZigTypeIdComptimeInt && | 8816 | (num_lit_type->id == ZigTypeIdComptimeInt && |
| 8790 | (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt))); | 8817 | (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt))); |
| 8791 | } | 8818 | } |
| 8792 | | 8819 | |
| 8793 | static bool float_has_fraction(ConstExprValue *const_val) { | 8820 | static bool float_has_fraction(ZigValue *const_val) { |
| 8794 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8821 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8795 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); | 8822 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); |
| 8796 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8823 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8818,7 +8845,7 @@ static bool float_has_fraction(ConstExprValue *const_val) { | ... | @@ -8818,7 +8845,7 @@ static bool float_has_fraction(ConstExprValue *const_val) { |
| 8818 | } | 8845 | } |
| 8819 | } | 8846 | } |
| 8820 | | 8847 | |
| 8821 | static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | 8848 | static void float_append_buf(Buf *buf, ZigValue *const_val) { |
| 8822 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8849 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8823 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); | 8850 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); |
| 8824 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8851 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8856,7 +8883,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | ... | @@ -8856,7 +8883,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 8856 | } | 8883 | } |
| 8857 | } | 8884 | } |
| 8858 | | 8885 | |
| 8859 | static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | 8886 | static void float_init_bigint(BigInt *bigint, ZigValue *const_val) { |
| 8860 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8887 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8861 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); | 8888 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); |
| 8862 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8889 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8903,7 +8930,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | ... | @@ -8903,7 +8930,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 8903 | } | 8930 | } |
| 8904 | } | 8931 | } |
| 8905 | | 8932 | |
| 8906 | static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | 8933 | static void float_init_bigfloat(ZigValue *dest_val, BigFloat *bigfloat) { |
| 8907 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8934 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8908 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); | 8935 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); |
| 8909 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8936 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8930,7 +8957,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | ... | @@ -8930,7 +8957,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 8930 | } | 8957 | } |
| 8931 | } | 8958 | } |
| 8932 | | 8959 | |
| 8933 | static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | 8960 | static void float_init_f16(ZigValue *dest_val, float16_t x) { |
| 8934 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8961 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8935 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); | 8962 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); |
| 8936 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8963 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8955,7 +8982,7 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | ... | @@ -8955,7 +8982,7 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { |
| 8955 | } | 8982 | } |
| 8956 | } | 8983 | } |
| 8957 | | 8984 | |
| 8958 | static void float_init_f32(ConstExprValue *dest_val, float x) { | 8985 | static void float_init_f32(ZigValue *dest_val, float x) { |
| 8959 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8986 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8960 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); | 8987 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); |
| 8961 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8988 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8984,7 +9011,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { | ... | @@ -8984,7 +9011,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 8984 | } | 9011 | } |
| 8985 | } | 9012 | } |
| 8986 | | 9013 | |
| 8987 | static void float_init_f64(ConstExprValue *dest_val, double x) { | 9014 | static void float_init_f64(ZigValue *dest_val, double x) { |
| 8988 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 9015 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8989 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); | 9016 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); |
| 8990 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 9017 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9013,7 +9040,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { | ... | @@ -9013,7 +9040,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 9013 | } | 9040 | } |
| 9014 | } | 9041 | } |
| 9015 | | 9042 | |
| 9016 | static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | 9043 | static void float_init_f128(ZigValue *dest_val, float128_t x) { |
| 9017 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 9044 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 9018 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); | 9045 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); |
| 9019 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 9046 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9046,7 +9073,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | ... | @@ -9046,7 +9073,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 9046 | } | 9073 | } |
| 9047 | } | 9074 | } |
| 9048 | | 9075 | |
| 9049 | static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) { | 9076 | static void float_init_float(ZigValue *dest_val, ZigValue *src_val) { |
| 9050 | if (src_val->type->id == ZigTypeIdComptimeFloat) { | 9077 | if (src_val->type->id == ZigTypeIdComptimeFloat) { |
| 9051 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); | 9078 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); |
| 9052 | } else if (src_val->type->id == ZigTypeIdFloat) { | 9079 | } else if (src_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9071,7 +9098,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) | ... | @@ -9071,7 +9098,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) |
| 9071 | } | 9098 | } |
| 9072 | } | 9099 | } |
| 9073 | | 9100 | |
| 9074 | static bool float_is_nan(ConstExprValue *op) { | 9101 | static bool float_is_nan(ZigValue *op) { |
| 9075 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9102 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9076 | return bigfloat_is_nan(&op->data.x_bigfloat); | 9103 | return bigfloat_is_nan(&op->data.x_bigfloat); |
| 9077 | } else if (op->type->id == ZigTypeIdFloat) { | 9104 | } else if (op->type->id == ZigTypeIdFloat) { |
| ... | @@ -9092,7 +9119,7 @@ static bool float_is_nan(ConstExprValue *op) { | ... | @@ -9092,7 +9119,7 @@ static bool float_is_nan(ConstExprValue *op) { |
| 9092 | } | 9119 | } |
| 9093 | } | 9120 | } |
| 9094 | | 9121 | |
| 9095 | static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | 9122 | static Cmp float_cmp(ZigValue *op1, ZigValue *op2) { |
| 9096 | assert(op1->type == op2->type); | 9123 | assert(op1->type == op2->type); |
| 9097 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9124 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 9098 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); | 9125 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| ... | @@ -9138,7 +9165,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | ... | @@ -9138,7 +9165,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 9138 | } | 9165 | } |
| 9139 | } | 9166 | } |
| 9140 | | 9167 | |
| 9141 | static Cmp float_cmp_zero(ConstExprValue *op) { | 9168 | static Cmp float_cmp_zero(ZigValue *op) { |
| 9142 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9169 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9143 | return bigfloat_cmp_zero(&op->data.x_bigfloat); | 9170 | return bigfloat_cmp_zero(&op->data.x_bigfloat); |
| 9144 | } else if (op->type->id == ZigTypeIdFloat) { | 9171 | } else if (op->type->id == ZigTypeIdFloat) { |
| ... | @@ -9188,7 +9215,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) { | ... | @@ -9188,7 +9215,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) { |
| 9188 | } | 9215 | } |
| 9189 | } | 9216 | } |
| 9190 | | 9217 | |
| 9191 | static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9218 | static void float_add(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9192 | assert(op1->type == op2->type); | 9219 | assert(op1->type == op2->type); |
| 9193 | out_val->type = op1->type; | 9220 | out_val->type = op1->type; |
| 9194 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9221 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9215,7 +9242,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9215,7 +9242,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9215 | } | 9242 | } |
| 9216 | } | 9243 | } |
| 9217 | | 9244 | |
| 9218 | static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9245 | static void float_sub(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9219 | assert(op1->type == op2->type); | 9246 | assert(op1->type == op2->type); |
| 9220 | out_val->type = op1->type; | 9247 | out_val->type = op1->type; |
| 9221 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9248 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9242,7 +9269,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9242,7 +9269,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9242 | } | 9269 | } |
| 9243 | } | 9270 | } |
| 9244 | | 9271 | |
| 9245 | static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9272 | static void float_mul(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9246 | assert(op1->type == op2->type); | 9273 | assert(op1->type == op2->type); |
| 9247 | out_val->type = op1->type; | 9274 | out_val->type = op1->type; |
| 9248 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9275 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9269,7 +9296,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9269,7 +9296,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9269 | } | 9296 | } |
| 9270 | } | 9297 | } |
| 9271 | | 9298 | |
| 9272 | static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9299 | static void float_div(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9273 | assert(op1->type == op2->type); | 9300 | assert(op1->type == op2->type); |
| 9274 | out_val->type = op1->type; | 9301 | out_val->type = op1->type; |
| 9275 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9302 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9296,7 +9323,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9296,7 +9323,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9296 | } | 9323 | } |
| 9297 | } | 9324 | } |
| 9298 | | 9325 | |
| 9299 | static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9326 | static void float_div_trunc(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9300 | assert(op1->type == op2->type); | 9327 | assert(op1->type == op2->type); |
| 9301 | out_val->type = op1->type; | 9328 | out_val->type = op1->type; |
| 9302 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9329 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9325,7 +9352,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -9325,7 +9352,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 9325 | } | 9352 | } |
| 9326 | } | 9353 | } |
| 9327 | | 9354 | |
| 9328 | static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9355 | static void float_div_floor(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9329 | assert(op1->type == op2->type); | 9356 | assert(op1->type == op2->type); |
| 9330 | out_val->type = op1->type; | 9357 | out_val->type = op1->type; |
| 9331 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9358 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9354,7 +9381,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -9354,7 +9381,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 9354 | } | 9381 | } |
| 9355 | } | 9382 | } |
| 9356 | | 9383 | |
| 9357 | static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9384 | static void float_rem(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9358 | assert(op1->type == op2->type); | 9385 | assert(op1->type == op2->type); |
| 9359 | out_val->type = op1->type; | 9386 | out_val->type = op1->type; |
| 9360 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9387 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9399,7 +9426,7 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* | ... | @@ -9399,7 +9426,7 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* |
| 9399 | f128M_sub(a, c, c); | 9426 | f128M_sub(a, c, c); |
| 9400 | } | 9427 | } |
| 9401 | | 9428 | |
| 9402 | static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9429 | static void float_mod(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9403 | assert(op1->type == op2->type); | 9430 | assert(op1->type == op2->type); |
| 9404 | out_val->type = op1->type; | 9431 | out_val->type = op1->type; |
| 9405 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9432 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9426,7 +9453,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9426,7 +9453,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9426 | } | 9453 | } |
| 9427 | } | 9454 | } |
| 9428 | | 9455 | |
| 9429 | static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | 9456 | static void float_negate(ZigValue *out_val, ZigValue *op) { |
| 9430 | out_val->type = op->type; | 9457 | out_val->type = op->type; |
| 9431 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9458 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9432 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); | 9459 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); |
| ... | @@ -9457,7 +9484,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | ... | @@ -9457,7 +9484,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { |
| 9457 | } | 9484 | } |
| 9458 | } | 9485 | } |
| 9459 | | 9486 | |
| 9460 | void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | 9487 | void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) { |
| 9461 | if (op->type->id == ZigTypeIdFloat) { | 9488 | if (op->type->id == ZigTypeIdFloat) { |
| 9462 | switch (op->type->data.floating.bit_count) { | 9489 | switch (op->type->data.floating.bit_count) { |
| 9463 | case 16: | 9490 | case 16: |
| ... | @@ -9480,7 +9507,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | ... | @@ -9480,7 +9507,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { |
| 9480 | } | 9507 | } |
| 9481 | } | 9508 | } |
| 9482 | | 9509 | |
| 9483 | void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) { | 9510 | void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { |
| 9484 | if (val->type->id == ZigTypeIdFloat) { | 9511 | if (val->type->id == ZigTypeIdFloat) { |
| 9485 | switch (val->type->data.floating.bit_count) { | 9512 | switch (val->type->data.floating.bit_count) { |
| 9486 | case 16: | 9513 | case 16: |
| ... | @@ -9510,7 +9537,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -9510,7 +9537,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 9510 | return false; | 9537 | return false; |
| 9511 | } | 9538 | } |
| 9512 | | 9539 | |
| 9513 | ConstExprValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef); | 9540 | ZigValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef); |
| 9514 | if (const_val == nullptr) | 9541 | if (const_val == nullptr) |
| 9515 | return false; | 9542 | return false; |
| 9516 | | 9543 | |
| ... | @@ -10217,13 +10244,13 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10217,13 +10244,13 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10217 | size_t i = 0; | 10244 | size_t i = 0; |
| 10218 | for (;;) { | 10245 | for (;;) { |
| 10219 | prev_inst = instructions[i]; | 10246 | prev_inst = instructions[i]; |
| 10220 | if (type_is_invalid(prev_inst->value.type)) { | 10247 | if (type_is_invalid(prev_inst->value->type)) { |
| 10221 | return ira->codegen->builtin_types.entry_invalid; | 10248 | return ira->codegen->builtin_types.entry_invalid; |
| 10222 | } | 10249 | } |
| 10223 | if (prev_inst->value.type->id == ZigTypeIdUnreachable) { | 10250 | if (prev_inst->value->type->id == ZigTypeIdUnreachable) { |
| 10224 | i += 1; | 10251 | i += 1; |
| 10225 | if (i == instruction_count) { | 10252 | if (i == instruction_count) { |
| 10226 | return prev_inst->value.type; | 10253 | return prev_inst->value->type; |
| 10227 | } | 10254 | } |
| 10228 | continue; | 10255 | continue; |
| 10229 | } | 10256 | } |
| ... | @@ -10232,14 +10259,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10232,14 +10259,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10232 | ErrorTableEntry **errors = nullptr; | 10259 | ErrorTableEntry **errors = nullptr; |
| 10233 | size_t errors_count = 0; | 10260 | size_t errors_count = 0; |
| 10234 | ZigType *err_set_type = nullptr; | 10261 | ZigType *err_set_type = nullptr; |
| 10235 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { | 10262 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10236 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value.type, prev_inst->source_node)) { | 10263 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->source_node)) { |
| 10237 | return ira->codegen->builtin_types.entry_invalid; | 10264 | return ira->codegen->builtin_types.entry_invalid; |
| 10238 | } | 10265 | } |
| 10239 | if (type_is_global_error_set(prev_inst->value.type)) { | 10266 | if (type_is_global_error_set(prev_inst->value->type)) { |
| 10240 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; | 10267 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; |
| 10241 | } else { | 10268 | } else { |
| 10242 | err_set_type = prev_inst->value.type; | 10269 | err_set_type = prev_inst->value->type; |
| 10243 | update_errors_helper(ira->codegen, &errors, &errors_count); | 10270 | update_errors_helper(ira->codegen, &errors, &errors_count); |
| 10244 | | 10271 | |
| 10245 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { | 10272 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { |
| ... | @@ -10250,12 +10277,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10250,12 +10277,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10250 | } | 10277 | } |
| 10251 | } | 10278 | } |
| 10252 | | 10279 | |
| 10253 | bool any_are_null = (prev_inst->value.type->id == ZigTypeIdNull); | 10280 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); |
| 10254 | bool convert_to_const_slice = false; | 10281 | bool convert_to_const_slice = false; |
| 10255 | for (; i < instruction_count; i += 1) { | 10282 | for (; i < instruction_count; i += 1) { |
| 10256 | IrInstruction *cur_inst = instructions[i]; | 10283 | IrInstruction *cur_inst = instructions[i]; |
| 10257 | ZigType *cur_type = cur_inst->value.type; | 10284 | ZigType *cur_type = cur_inst->value->type; |
| 10258 | ZigType *prev_type = prev_inst->value.type; | 10285 | ZigType *prev_type = prev_inst->value->type; |
| 10259 | | 10286 | |
| 10260 | if (type_is_invalid(cur_type)) { | 10287 | if (type_is_invalid(cur_type)) { |
| 10261 | return cur_type; | 10288 | return cur_type; |
| ... | @@ -10559,20 +10586,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10559,20 +10586,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10559 | } | 10586 | } |
| 10560 | | 10587 | |
| 10561 | if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdEnumLiteral) { | 10588 | 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); | 10589 | TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value->data.x_enum_literal); |
| 10563 | if (field != nullptr) { | 10590 | if (field != nullptr) { |
| 10564 | continue; | 10591 | continue; |
| 10565 | } | 10592 | } |
| 10566 | } | 10593 | } |
| 10567 | if (is_tagged_union(prev_type) && cur_type->id == ZigTypeIdEnumLiteral) { | 10594 | 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); | 10595 | TypeUnionField *field = find_union_type_field(prev_type, cur_inst->value->data.x_enum_literal); |
| 10569 | if (field != nullptr) { | 10596 | if (field != nullptr) { |
| 10570 | continue; | 10597 | continue; |
| 10571 | } | 10598 | } |
| 10572 | } | 10599 | } |
| 10573 | | 10600 | |
| 10574 | if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdEnumLiteral) { | 10601 | 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); | 10602 | TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value->data.x_enum_literal); |
| 10576 | if (field != nullptr) { | 10603 | if (field != nullptr) { |
| 10577 | prev_inst = cur_inst; | 10604 | prev_inst = cur_inst; |
| 10578 | continue; | 10605 | continue; |
| ... | @@ -10580,7 +10607,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10580,7 +10607,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10580 | } | 10607 | } |
| 10581 | | 10608 | |
| 10582 | if (is_tagged_union(cur_type) && prev_type->id == ZigTypeIdEnumLiteral) { | 10609 | 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); | 10610 | TypeUnionField *field = find_union_type_field(cur_type, prev_inst->value->data.x_enum_literal); |
| 10584 | if (field != nullptr) { | 10611 | if (field != nullptr) { |
| 10585 | prev_inst = cur_inst; | 10612 | prev_inst = cur_inst; |
| 10586 | continue; | 10613 | continue; |
| ... | @@ -10906,9 +10933,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10906,9 +10933,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10906 | free(errors); | 10933 | free(errors); |
| 10907 | | 10934 | |
| 10908 | if (convert_to_const_slice) { | 10935 | if (convert_to_const_slice) { |
| 10909 | if (prev_inst->value.type->id == ZigTypeIdArray) { | 10936 | if (prev_inst->value->type->id == ZigTypeIdArray) { |
| 10910 | ZigType *ptr_type = get_pointer_to_type_extra( | 10937 | ZigType *ptr_type = get_pointer_to_type_extra( |
| 10911 | ira->codegen, prev_inst->value.type->data.array.child_type, | 10938 | ira->codegen, prev_inst->value->type->data.array.child_type, |
| 10912 | true, false, PtrLenUnknown, | 10939 | true, false, PtrLenUnknown, |
| 10913 | 0, 0, 0, false); | 10940 | 0, 0, 0, false); |
| 10914 | ZigType *slice_type = get_slice_type(ira->codegen, ptr_type); | 10941 | ZigType *slice_type = get_slice_type(ira->codegen, ptr_type); |
| ... | @@ -10917,12 +10944,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10917,12 +10944,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10917 | } else { | 10944 | } else { |
| 10918 | return slice_type; | 10945 | return slice_type; |
| 10919 | } | 10946 | } |
| 10920 | } else if (prev_inst->value.type->id == ZigTypeIdPointer) { | 10947 | } else if (prev_inst->value->type->id == ZigTypeIdPointer) { |
| 10921 | ZigType *array_type = prev_inst->value.type->data.pointer.child_type; | 10948 | ZigType *array_type = prev_inst->value->type->data.pointer.child_type; |
| 10922 | src_assert(array_type->id == ZigTypeIdArray, source_node); | 10949 | src_assert(array_type->id == ZigTypeIdArray, source_node); |
| 10923 | ZigType *ptr_type = get_pointer_to_type_extra2( | 10950 | ZigType *ptr_type = get_pointer_to_type_extra2( |
| 10924 | ira->codegen, array_type->data.array.child_type, | 10951 | ira->codegen, array_type->data.array.child_type, |
| 10925 | prev_inst->value.type->data.pointer.is_const, false, | 10952 | prev_inst->value->type->data.pointer.is_const, false, |
| 10926 | PtrLenUnknown, | 10953 | PtrLenUnknown, |
| 10927 | 0, 0, 0, false, | 10954 | 0, 0, 0, false, |
| 10928 | VECTOR_INDEX_NONE, nullptr, array_type->data.array.sentinel); | 10955 | VECTOR_INDEX_NONE, nullptr, array_type->data.array.sentinel); |
| ... | @@ -10936,10 +10963,10 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10936,10 +10963,10 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10936 | zig_unreachable(); | 10963 | zig_unreachable(); |
| 10937 | } | 10964 | } |
| 10938 | } else if (err_set_type != nullptr) { | 10965 | } else if (err_set_type != nullptr) { |
| 10939 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { | 10966 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10940 | return err_set_type; | 10967 | return err_set_type; |
| 10941 | } else if (prev_inst->value.type->id == ZigTypeIdErrorUnion) { | 10968 | } else if (prev_inst->value->type->id == ZigTypeIdErrorUnion) { |
| 10942 | ZigType *payload_type = prev_inst->value.type->data.error_union.payload_type; | 10969 | ZigType *payload_type = prev_inst->value->type->data.error_union.payload_type; |
| 10943 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) | 10970 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) |
| 10944 | return ira->codegen->builtin_types.entry_invalid; | 10971 | return ira->codegen->builtin_types.entry_invalid; |
| 10945 | return get_error_union_type(ira->codegen, err_set_type, payload_type); | 10972 | return get_error_union_type(ira->codegen, err_set_type, payload_type); |
| ... | @@ -10949,44 +10976,44 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10949,44 +10976,44 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10949 | return ira->codegen->builtin_types.entry_invalid; | 10976 | return ira->codegen->builtin_types.entry_invalid; |
| 10950 | return get_error_union_type(ira->codegen, err_set_type, payload_type); | 10977 | return get_error_union_type(ira->codegen, err_set_type, payload_type); |
| 10951 | } else { | 10978 | } else { |
| 10952 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || | 10979 | if (prev_inst->value->type->id == ZigTypeIdComptimeInt || |
| 10953 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) | 10980 | prev_inst->value->type->id == ZigTypeIdComptimeFloat) |
| 10954 | { | 10981 | { |
| 10955 | ir_add_error_node(ira, source_node, | 10982 | ir_add_error_node(ira, source_node, |
| 10956 | buf_sprintf("unable to make error union out of number literal")); | 10983 | buf_sprintf("unable to make error union out of number literal")); |
| 10957 | return ira->codegen->builtin_types.entry_invalid; | 10984 | return ira->codegen->builtin_types.entry_invalid; |
| 10958 | } else if (prev_inst->value.type->id == ZigTypeIdNull) { | 10985 | } else if (prev_inst->value->type->id == ZigTypeIdNull) { |
| 10959 | ir_add_error_node(ira, source_node, | 10986 | ir_add_error_node(ira, source_node, |
| 10960 | buf_sprintf("unable to make error union out of null literal")); | 10987 | buf_sprintf("unable to make error union out of null literal")); |
| 10961 | return ira->codegen->builtin_types.entry_invalid; | 10988 | return ira->codegen->builtin_types.entry_invalid; |
| 10962 | } else { | 10989 | } else { |
| 10963 | if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown))) | 10990 | if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown))) |
| 10964 | return ira->codegen->builtin_types.entry_invalid; | 10991 | return ira->codegen->builtin_types.entry_invalid; |
| 10965 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type); | 10992 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value->type); |
| 10966 | } | 10993 | } |
| 10967 | } | 10994 | } |
| 10968 | } else if (any_are_null && prev_inst->value.type->id != ZigTypeIdNull) { | 10995 | } else if (any_are_null && prev_inst->value->type->id != ZigTypeIdNull) { |
| 10969 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || | 10996 | if (prev_inst->value->type->id == ZigTypeIdComptimeInt || |
| 10970 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) | 10997 | prev_inst->value->type->id == ZigTypeIdComptimeFloat) |
| 10971 | { | 10998 | { |
| 10972 | ir_add_error_node(ira, source_node, | 10999 | ir_add_error_node(ira, source_node, |
| 10973 | buf_sprintf("unable to make maybe out of number literal")); | 11000 | buf_sprintf("unable to make maybe out of number literal")); |
| 10974 | return ira->codegen->builtin_types.entry_invalid; | 11001 | return ira->codegen->builtin_types.entry_invalid; |
| 10975 | } else if (prev_inst->value.type->id == ZigTypeIdOptional) { | 11002 | } else if (prev_inst->value->type->id == ZigTypeIdOptional) { |
| 10976 | return prev_inst->value.type; | 11003 | return prev_inst->value->type; |
| 10977 | } else { | 11004 | } else { |
| 10978 | if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown))) | 11005 | if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown))) |
| 10979 | return ira->codegen->builtin_types.entry_invalid; | 11006 | return ira->codegen->builtin_types.entry_invalid; |
| 10980 | return get_optional_type(ira->codegen, prev_inst->value.type); | 11007 | return get_optional_type(ira->codegen, prev_inst->value->type); |
| 10981 | } | 11008 | } |
| 10982 | } else { | 11009 | } else { |
| 10983 | return prev_inst->value.type; | 11010 | return prev_inst->value->type; |
| 10984 | } | 11011 | } |
| 10985 | } | 11012 | } |
| 10986 | | 11013 | |
| 10987 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs) { | 11014 | static void copy_const_val(ZigValue *dest, ZigValue *src, bool same_global_refs) { |
| 10988 | ConstGlobalRefs *global_refs = dest->global_refs; | 11015 | ConstGlobalRefs *global_refs = dest->global_refs; |
| 10989 | memcpy(dest, src, sizeof(ConstExprValue)); | 11016 | memcpy(dest, src, sizeof(ZigValue)); |
| 10990 | if (!same_global_refs) { | 11017 | if (!same_global_refs) { |
| 10991 | dest->global_refs = global_refs; | 11018 | dest->global_refs = global_refs; |
| 10992 | if (src->special != ConstValSpecialStatic) | 11019 | if (src->special != ConstValSpecialStatic) |
| ... | @@ -11002,8 +11029,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ | ... | @@ -11002,8 +11029,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ |
| 11002 | | 11029 | |
| 11003 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, | 11030 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, |
| 11004 | CastOp cast_op, | 11031 | CastOp cast_op, |
| 11005 | ConstExprValue *other_val, ZigType *other_type, | 11032 | ZigValue *other_val, ZigType *other_type, |
| 11006 | ConstExprValue *const_val, ZigType *new_type) | 11033 | ZigValue *const_val, ZigType *new_type) |
| 11007 | { | 11034 | { |
| 11008 | const_val->special = other_val->special; | 11035 | const_val->special = other_val->special; |
| 11009 | | 11036 | |
| ... | @@ -11106,25 +11133,31 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z | ... | @@ -11106,25 +11133,31 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z |
| 11106 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11133 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11107 | old_instruction->scope, old_instruction->source_node); | 11134 | old_instruction->scope, old_instruction->source_node); |
| 11108 | IrInstruction *new_instruction = &const_instruction->base; | 11135 | IrInstruction *new_instruction = &const_instruction->base; |
| 11109 | new_instruction->value.type = ty; | 11136 | new_instruction->value->type = ty; |
| 11110 | new_instruction->value.special = ConstValSpecialStatic; | 11137 | new_instruction->value->special = ConstValSpecialStatic; |
| 11111 | return new_instruction; | 11138 | return new_instruction; |
| 11112 | } | 11139 | } |
| 11113 | | 11140 | |
| | 11141 | static IrInstruction *ir_const_noval(IrAnalyze *ira, IrInstruction *old_instruction) { |
| | 11142 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(&ira->new_irb, |
| | 11143 | old_instruction->scope, old_instruction->source_node); |
| | 11144 | return &const_instruction->base; |
| | 11145 | } |
| | 11146 | |
| 11114 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 11147 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 11115 | ZigType *wanted_type, CastOp cast_op) | 11148 | ZigType *wanted_type, CastOp cast_op) |
| 11116 | { | 11149 | { |
| 11117 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { | 11150 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { |
| 11118 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11151 | 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, | 11152 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, |
| 11120 | &result->value, wanted_type)) | 11153 | result->value, wanted_type)) |
| 11121 | { | 11154 | { |
| 11122 | return ira->codegen->invalid_instruction; | 11155 | return ira->codegen->invalid_instruction; |
| 11123 | } | 11156 | } |
| 11124 | return result; | 11157 | return result; |
| 11125 | } else { | 11158 | } else { |
| 11126 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); | 11159 | 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; | 11160 | result->value->type = wanted_type; |
| 11128 | return result; | 11161 | return result; |
| 11129 | } | 11162 | } |
| 11130 | } | 11163 | } |
| ... | @@ -11132,35 +11165,35 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11132,35 +11165,35 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11132 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 11165 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, |
| 11133 | IrInstruction *value, ZigType *wanted_type) | 11166 | IrInstruction *value, ZigType *wanted_type) |
| 11134 | { | 11167 | { |
| 11135 | assert(value->value.type->id == ZigTypeIdPointer); | 11168 | assert(value->value->type->id == ZigTypeIdPointer); |
| 11136 | | 11169 | |
| 11137 | Error err; | 11170 | Error err; |
| 11138 | | 11171 | |
| 11139 | if ((err = type_resolve(ira->codegen, value->value.type->data.pointer.child_type, | 11172 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, |
| 11140 | ResolveStatusAlignmentKnown))) | 11173 | ResolveStatusAlignmentKnown))) |
| 11141 | { | 11174 | { |
| 11142 | return ira->codegen->invalid_instruction; | 11175 | return ira->codegen->invalid_instruction; |
| 11143 | } | 11176 | } |
| 11144 | | 11177 | |
| 11145 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type)); | 11178 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); |
| 11146 | | 11179 | |
| 11147 | if (instr_is_comptime(value)) { | 11180 | if (instr_is_comptime(value)) { |
| 11148 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, &value->value, source_instr->source_node); | 11181 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); |
| 11149 | if (pointee == nullptr) | 11182 | if (pointee == nullptr) |
| 11150 | return ira->codegen->invalid_instruction; | 11183 | return ira->codegen->invalid_instruction; |
| 11151 | if (pointee->special != ConstValSpecialRuntime) { | 11184 | if (pointee->special != ConstValSpecialRuntime) { |
| 11152 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11185 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11153 | result->value.data.x_ptr.special = ConstPtrSpecialBaseArray; | 11186 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 11154 | result->value.data.x_ptr.mut = value->value.data.x_ptr.mut; | 11187 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; |
| 11155 | result->value.data.x_ptr.data.base_array.array_val = pointee; | 11188 | result->value->data.x_ptr.data.base_array.array_val = pointee; |
| 11156 | result->value.data.x_ptr.data.base_array.elem_index = 0; | 11189 | result->value->data.x_ptr.data.base_array.elem_index = 0; |
| 11157 | return result; | 11190 | return result; |
| 11158 | } | 11191 | } |
| 11159 | } | 11192 | } |
| 11160 | | 11193 | |
| 11161 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11194 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11162 | wanted_type, value, CastOpBitCast); | 11195 | wanted_type, value, CastOpBitCast); |
| 11163 | result->value.type = wanted_type; | 11196 | result->value->type = wanted_type; |
| 11164 | return result; | 11197 | return result; |
| 11165 | } | 11198 | } |
| 11166 | | 11199 | |
| ... | @@ -11169,28 +11202,28 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11169,28 +11202,28 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11169 | { | 11202 | { |
| 11170 | Error err; | 11203 | Error err; |
| 11171 | | 11204 | |
| 11172 | if ((err = type_resolve(ira->codegen, array_ptr->value.type->data.pointer.child_type, | 11205 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, |
| 11173 | ResolveStatusAlignmentKnown))) | 11206 | ResolveStatusAlignmentKnown))) |
| 11174 | { | 11207 | { |
| 11175 | return ira->codegen->invalid_instruction; | 11208 | return ira->codegen->invalid_instruction; |
| 11176 | } | 11209 | } |
| 11177 | | 11210 | |
| 11178 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type)); | 11211 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); |
| 11179 | | 11212 | |
| 11180 | if (instr_is_comptime(array_ptr)) { | 11213 | if (instr_is_comptime(array_ptr)) { |
| 11181 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, &array_ptr->value, source_instr->source_node); | 11214 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr->value, source_instr->source_node); |
| 11182 | if (pointee == nullptr) | 11215 | if (pointee == nullptr) |
| 11183 | return ira->codegen->invalid_instruction; | 11216 | return ira->codegen->invalid_instruction; |
| 11184 | if (pointee->special != ConstValSpecialRuntime) { | 11217 | if (pointee->special != ConstValSpecialRuntime) { |
| 11185 | assert(array_ptr->value.type->id == ZigTypeIdPointer); | 11218 | assert(array_ptr->value->type->id == ZigTypeIdPointer); |
| 11186 | ZigType *array_type = array_ptr->value.type->data.pointer.child_type; | 11219 | ZigType *array_type = array_ptr->value->type->data.pointer.child_type; |
| 11187 | assert(is_slice(wanted_type)); | 11220 | assert(is_slice(wanted_type)); |
| 11188 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; | 11221 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; |
| 11189 | | 11222 | |
| 11190 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11223 | 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); | 11224 | 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; | 11225 | 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; | 11226 | result->value->type = wanted_type; |
| 11194 | return result; | 11227 | return result; |
| 11195 | } | 11228 | } |
| 11196 | } | 11229 | } |
| ... | @@ -11198,7 +11231,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11198,7 +11231,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11198 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11231 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11199 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, | 11232 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, |
| 11200 | false, true); | 11233 | false, true); |
| 11201 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 11234 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11202 | return result_loc_inst; | 11235 | return result_loc_inst; |
| 11203 | } | 11236 | } |
| 11204 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); | 11237 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); |
| ... | @@ -11403,53 +11436,61 @@ static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -11403,53 +11436,61 @@ static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruc |
| 11403 | } | 11436 | } |
| 11404 | | 11437 | |
| 11405 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { | 11438 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { |
| 11406 | if (instruction->value.type->id == ZigTypeIdUnreachable) | 11439 | if (instruction->value->type->id == ZigTypeIdUnreachable) |
| 11407 | ir_finish_bb(ira); | 11440 | ir_finish_bb(ira); |
| 11408 | return instruction; | 11441 | return instruction; |
| 11409 | } | 11442 | } |
| 11410 | | 11443 | |
| 11411 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 11444 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 11412 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); | 11445 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); |
| 11413 | result->value.data.x_type = ty; | 11446 | result->value->data.x_type = ty; |
| 11414 | return result; | 11447 | return result; |
| 11415 | } | 11448 | } |
| 11416 | | 11449 | |
| 11417 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { | 11450 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { |
| 11418 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); | 11451 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); |
| 11419 | result->value.data.x_bool = value; | 11452 | result->value->data.x_bool = value; |
| 11420 | return result; | 11453 | return result; |
| 11421 | } | 11454 | } |
| 11422 | | 11455 | |
| 11423 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 11456 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 11424 | IrInstruction *result = ir_const(ira, source_instruction, ty); | 11457 | IrInstruction *result = ir_const(ira, source_instruction, ty); |
| 11425 | result->value.special = ConstValSpecialUndef; | 11458 | result->value->special = ConstValSpecialUndef; |
| 11426 | return result; | 11459 | return result; |
| 11427 | } | 11460 | } |
| 11428 | | 11461 | |
| 11429 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { | 11462 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { |
| 11430 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable); | 11463 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 11431 | result->value.special = ConstValSpecialStatic; | 11464 | memprof_intern_count.x_unreachable += 1; |
| | 11465 | #endif |
| | 11466 | IrInstruction *result = ir_const_noval(ira, source_instruction); |
| | 11467 | result->value = &ira->codegen->intern_values.x_unreachable; |
| 11432 | return result; | 11468 | return result; |
| 11433 | } | 11469 | } |
| 11434 | | 11470 | |
| 11435 | static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) { | 11471 | static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) { |
| 11436 | return ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_void); | 11472 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 11473 | memprof_intern_count.x_void += 1; |
| | 11474 | #endif |
| | 11475 | IrInstruction *result = ir_const_noval(ira, source_instruction); |
| | 11476 | result->value = &ira->codegen->intern_values.x_void; |
| | 11477 | return result; |
| 11437 | } | 11478 | } |
| 11438 | | 11479 | |
| 11439 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { | 11480 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { |
| 11440 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); | 11481 | 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); | 11482 | bigint_init_unsigned(&result->value->data.x_bigint, value); |
| 11442 | return result; | 11483 | return result; |
| 11443 | } | 11484 | } |
| 11444 | | 11485 | |
| 11445 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, | 11486 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 11446 | ConstExprValue *pointee, ZigType *pointee_type, | 11487 | ZigValue *pointee, ZigType *pointee_type, |
| 11447 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) | 11488 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) |
| 11448 | { | 11489 | { |
| 11449 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, | 11490 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, |
| 11450 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); | 11491 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 11451 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); | 11492 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); |
| 11452 | ConstExprValue *const_val = &const_instr->value; | 11493 | ZigValue *const_val = const_instr->value; |
| 11453 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 11494 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 11454 | const_val->data.x_ptr.mut = ptr_mut; | 11495 | const_val->data.x_ptr.mut = ptr_mut; |
| 11455 | const_val->data.x_ptr.data.ref.pointee = pointee; | 11496 | const_val->data.x_ptr.data.ref.pointee = pointee; |
| ... | @@ -11457,7 +11498,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -11457,7 +11498,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio |
| 11457 | } | 11498 | } |
| 11458 | | 11499 | |
| 11459 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 11500 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 11460 | ConstExprValue *val, UndefAllowed undef_allowed) | 11501 | ZigValue *val, UndefAllowed undef_allowed) |
| 11461 | { | 11502 | { |
| 11462 | Error err; | 11503 | Error err; |
| 11463 | for (;;) { | 11504 | for (;;) { |
| ... | @@ -11490,17 +11531,17 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -11490,17 +11531,17 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 11490 | } | 11531 | } |
| 11491 | } | 11532 | } |
| 11492 | | 11533 | |
| 11493 | static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { | 11534 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { |
| 11494 | Error err; | 11535 | Error err; |
| 11495 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, | 11536 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, |
| 11496 | &value->value, undef_allowed))) | 11537 | value->value, undef_allowed))) |
| 11497 | { | 11538 | { |
| 11498 | return nullptr; | 11539 | return nullptr; |
| 11499 | } | 11540 | } |
| 11500 | return &value->value; | 11541 | return value->value; |
| 11501 | } | 11542 | } |
| 11502 | | 11543 | |
| 11503 | ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 11544 | ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11504 | ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota, | 11545 | ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota, |
| 11505 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, | 11546 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, |
| 11506 | IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) | 11547 | IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) |
| ... | @@ -11508,7 +11549,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod | ... | @@ -11508,7 +11549,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod |
| 11508 | Error err; | 11549 | Error err; |
| 11509 | | 11550 | |
| 11510 | if (expected_type != nullptr && type_is_invalid(expected_type)) | 11551 | if (expected_type != nullptr && type_is_invalid(expected_type)) |
| 11511 | return &codegen->invalid_instruction->value; | 11552 | return codegen->invalid_instruction->value; |
| 11512 | | 11553 | |
| 11513 | IrExecutable *ir_executable = allocate<IrExecutable>(1); | 11554 | IrExecutable *ir_executable = allocate<IrExecutable>(1); |
| 11514 | ir_executable->source_node = source_node; | 11555 | ir_executable->source_node = source_node; |
| ... | @@ -11522,7 +11563,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod | ... | @@ -11522,7 +11563,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod |
| 11522 | | 11563 | |
| 11523 | if (ir_executable->first_err_trace_msg != nullptr) { | 11564 | if (ir_executable->first_err_trace_msg != nullptr) { |
| 11524 | codegen->trace_err = ir_executable->first_err_trace_msg; | 11565 | codegen->trace_err = ir_executable->first_err_trace_msg; |
| 11525 | return &codegen->invalid_instruction->value; | 11566 | return codegen->invalid_instruction->value; |
| 11526 | } | 11567 | } |
| 11527 | | 11568 | |
| 11528 | if (codegen->verbose_ir) { | 11569 | if (codegen->verbose_ir) { |
| ... | @@ -11545,7 +11586,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod | ... | @@ -11545,7 +11586,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod |
| 11545 | analyzed_executable->begin_scope = scope; | 11586 | analyzed_executable->begin_scope = scope; |
| 11546 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); | 11587 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); |
| 11547 | if (type_is_invalid(result_type)) { | 11588 | if (type_is_invalid(result_type)) { |
| 11548 | return &codegen->invalid_instruction->value; | 11589 | return codegen->invalid_instruction->value; |
| 11549 | } | 11590 | } |
| 11550 | | 11591 | |
| 11551 | if (codegen->verbose_ir) { | 11592 | if (codegen->verbose_ir) { |
| ... | @@ -11554,27 +11595,27 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod | ... | @@ -11554,27 +11595,27 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod |
| 11554 | fprintf(stderr, "}\n"); | 11595 | fprintf(stderr, "}\n"); |
| 11555 | } | 11596 | } |
| 11556 | | 11597 | |
| 11557 | ConstExprValue *result = ir_exec_const_result(codegen, analyzed_executable); | 11598 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); |
| 11558 | if (type_is_invalid(result->type)) | 11599 | if (type_is_invalid(result->type)) |
| 11559 | return &codegen->invalid_instruction->value; | 11600 | return codegen->invalid_instruction->value; |
| 11560 | | 11601 | |
| 11561 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) | 11602 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) |
| 11562 | return &codegen->invalid_instruction->value; | 11603 | return codegen->invalid_instruction->value; |
| 11563 | | 11604 | |
| 11564 | return result; | 11605 | return result; |
| 11565 | } | 11606 | } |
| 11566 | | 11607 | |
| 11567 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { | 11608 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { |
| 11568 | if (type_is_invalid(err_value->value.type)) | 11609 | if (type_is_invalid(err_value->value->type)) |
| 11569 | return nullptr; | 11610 | return nullptr; |
| 11570 | | 11611 | |
| 11571 | if (err_value->value.type->id != ZigTypeIdErrorSet) { | 11612 | if (err_value->value->type->id != ZigTypeIdErrorSet) { |
| 11572 | ir_add_error(ira, err_value, | 11613 | ir_add_error(ira, err_value, |
| 11573 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value.type->name))); | 11614 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); |
| 11574 | return nullptr; | 11615 | return nullptr; |
| 11575 | } | 11616 | } |
| 11576 | | 11617 | |
| 11577 | ConstExprValue *const_val = ir_resolve_const(ira, err_value, UndefBad); | 11618 | ZigValue *const_val = ir_resolve_const(ira, err_value, UndefBad); |
| 11578 | if (!const_val) | 11619 | if (!const_val) |
| 11579 | return nullptr; | 11620 | return nullptr; |
| 11580 | | 11621 | |
| ... | @@ -11583,7 +11624,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu | ... | @@ -11583,7 +11624,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu |
| 11583 | } | 11624 | } |
| 11584 | | 11625 | |
| 11585 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 11626 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 11586 | ConstExprValue *val) | 11627 | ZigValue *val) |
| 11587 | { | 11628 | { |
| 11588 | Error err; | 11629 | Error err; |
| 11589 | if ((err = ir_resolve_const_val(codegen, exec, source_node, val, UndefBad))) | 11630 | if ((err = ir_resolve_const_val(codegen, exec, source_node, val, UndefBad))) |
| ... | @@ -11593,28 +11634,28 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN | ... | @@ -11593,28 +11634,28 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN |
| 11593 | return val->data.x_type; | 11634 | return val->data.x_type; |
| 11594 | } | 11635 | } |
| 11595 | | 11636 | |
| 11596 | static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { | 11637 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { |
| 11597 | if (type_is_invalid(type_value->value.type)) | 11638 | if (type_is_invalid(type_value->value->type)) |
| 11598 | return nullptr; | 11639 | return nullptr; |
| 11599 | | 11640 | |
| 11600 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 11641 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 11601 | ir_add_error(ira, type_value, | 11642 | ir_add_error(ira, type_value, |
| 11602 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); | 11643 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); |
| 11603 | return nullptr; | 11644 | return nullptr; |
| 11604 | } | 11645 | } |
| 11605 | | 11646 | |
| 11606 | Error err; | 11647 | Error err; |
| 11607 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, | 11648 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, |
| 11608 | &type_value->value, LazyOk))) | 11649 | type_value->value, LazyOk))) |
| 11609 | { | 11650 | { |
| 11610 | return nullptr; | 11651 | return nullptr; |
| 11611 | } | 11652 | } |
| 11612 | | 11653 | |
| 11613 | return &type_value->value; | 11654 | return type_value->value; |
| 11614 | } | 11655 | } |
| 11615 | | 11656 | |
| 11616 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 11657 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 11617 | ConstExprValue *val = ir_resolve_type_lazy(ira, type_value); | 11658 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); |
| 11618 | if (val == nullptr) | 11659 | if (val == nullptr) |
| 11619 | return ira->codegen->builtin_types.entry_invalid; | 11660 | return ira->codegen->builtin_types.entry_invalid; |
| 11620 | | 11661 | |
| ... | @@ -11663,18 +11704,18 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -11663,18 +11704,18 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 11663 | } | 11704 | } |
| 11664 | | 11705 | |
| 11665 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { | 11706 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { |
| 11666 | if (type_is_invalid(type_value->value.type)) | 11707 | if (type_is_invalid(type_value->value->type)) |
| 11667 | return ira->codegen->builtin_types.entry_invalid; | 11708 | return ira->codegen->builtin_types.entry_invalid; |
| 11668 | | 11709 | |
| 11669 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 11710 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 11670 | ErrorMsg *msg = ir_add_error(ira, type_value, | 11711 | ErrorMsg *msg = ir_add_error(ira, type_value, |
| 11671 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value.type->name))); | 11712 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); |
| 11672 | add_error_note(ira->codegen, msg, op_source->source_node, | 11713 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 11673 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 11714 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| 11674 | return ira->codegen->builtin_types.entry_invalid; | 11715 | return ira->codegen->builtin_types.entry_invalid; |
| 11675 | } | 11716 | } |
| 11676 | | 11717 | |
| 11677 | ConstExprValue *const_val = ir_resolve_const(ira, type_value, UndefBad); | 11718 | ZigValue *const_val = ir_resolve_const(ira, type_value, UndefBad); |
| 11678 | if (!const_val) | 11719 | if (!const_val) |
| 11679 | return ira->codegen->builtin_types.entry_invalid; | 11720 | return ira->codegen->builtin_types.entry_invalid; |
| 11680 | | 11721 | |
| ... | @@ -11694,16 +11735,16 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -11694,16 +11735,16 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 11694 | if (fn_value == ira->codegen->invalid_instruction) | 11735 | if (fn_value == ira->codegen->invalid_instruction) |
| 11695 | return nullptr; | 11736 | return nullptr; |
| 11696 | | 11737 | |
| 11697 | if (type_is_invalid(fn_value->value.type)) | 11738 | if (type_is_invalid(fn_value->value->type)) |
| 11698 | return nullptr; | 11739 | return nullptr; |
| 11699 | | 11740 | |
| 11700 | if (fn_value->value.type->id != ZigTypeIdFn) { | 11741 | if (fn_value->value->type->id != ZigTypeIdFn) { |
| 11701 | ir_add_error_node(ira, fn_value->source_node, | 11742 | ir_add_error_node(ira, fn_value->source_node, |
| 11702 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value.type->name))); | 11743 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); |
| 11703 | return nullptr; | 11744 | return nullptr; |
| 11704 | } | 11745 | } |
| 11705 | | 11746 | |
| 11706 | ConstExprValue *const_val = ir_resolve_const(ira, fn_value, UndefBad); | 11747 | ZigValue *const_val = ir_resolve_const(ira, fn_value, UndefBad); |
| 11707 | if (!const_val) | 11748 | if (!const_val) |
| 11708 | return nullptr; | 11749 | return nullptr; |
| 11709 | | 11750 | |
| ... | @@ -11722,22 +11763,22 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11722,22 +11763,22 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11722 | if (instr_is_comptime(value)) { | 11763 | if (instr_is_comptime(value)) { |
| 11723 | ZigType *payload_type = wanted_type->data.maybe.child_type; | 11764 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 11724 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 11765 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11725 | if (type_is_invalid(casted_payload->value.type)) | 11766 | if (type_is_invalid(casted_payload->value->type)) |
| 11726 | return ira->codegen->invalid_instruction; | 11767 | return ira->codegen->invalid_instruction; |
| 11727 | | 11768 | |
| 11728 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 11769 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| 11729 | if (!val) | 11770 | if (!val) |
| 11730 | return ira->codegen->invalid_instruction; | 11771 | return ira->codegen->invalid_instruction; |
| 11731 | | 11772 | |
| 11732 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11773 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11733 | source_instr->scope, source_instr->source_node); | 11774 | source_instr->scope, source_instr->source_node); |
| 11734 | const_instruction->base.value.special = ConstValSpecialStatic; | 11775 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11735 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { | 11776 | 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); | 11777 | copy_const_val(const_instruction->base.value, val, val->data.x_ptr.mut == ConstPtrMutComptimeConst); |
| 11737 | } else { | 11778 | } else { |
| 11738 | const_instruction->base.value.data.x_optional = val; | 11779 | const_instruction->base.value->data.x_optional = val; |
| 11739 | } | 11780 | } |
| 11740 | const_instruction->base.value.type = wanted_type; | 11781 | const_instruction->base.value->type = wanted_type; |
| 11741 | return &const_instruction->base; | 11782 | return &const_instruction->base; |
| 11742 | } | 11783 | } |
| 11743 | | 11784 | |
| ... | @@ -11747,12 +11788,12 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11747,12 +11788,12 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11747 | IrInstruction *result_loc_inst = nullptr; | 11788 | IrInstruction *result_loc_inst = nullptr; |
| 11748 | if (result_loc != nullptr) { | 11789 | if (result_loc != nullptr) { |
| 11749 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11790 | 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)) { | 11791 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11751 | return result_loc_inst; | 11792 | return result_loc_inst; |
| 11752 | } | 11793 | } |
| 11753 | } | 11794 | } |
| 11754 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); | 11795 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11755 | result->value.data.rh_maybe = RuntimeHintOptionalNonNull; | 11796 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; |
| 11756 | return result; | 11797 | return result; |
| 11757 | } | 11798 | } |
| 11758 | | 11799 | |
| ... | @@ -11765,24 +11806,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11765,24 +11806,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11765 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; | 11806 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 11766 | if (instr_is_comptime(value)) { | 11807 | if (instr_is_comptime(value)) { |
| 11767 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 11808 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11768 | if (type_is_invalid(casted_payload->value.type)) | 11809 | if (type_is_invalid(casted_payload->value->type)) |
| 11769 | return ira->codegen->invalid_instruction; | 11810 | return ira->codegen->invalid_instruction; |
| 11770 | | 11811 | |
| 11771 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefBad); | 11812 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| 11772 | if (!val) | 11813 | if (!val) |
| 11773 | return ira->codegen->invalid_instruction; | 11814 | return ira->codegen->invalid_instruction; |
| 11774 | | 11815 | |
| 11775 | ConstExprValue *err_set_val = create_const_vals(1); | 11816 | ZigValue *err_set_val = create_const_vals(1); |
| 11776 | err_set_val->type = err_set_type; | 11817 | err_set_val->type = err_set_type; |
| 11777 | err_set_val->special = ConstValSpecialStatic; | 11818 | err_set_val->special = ConstValSpecialStatic; |
| 11778 | err_set_val->data.x_err_set = nullptr; | 11819 | err_set_val->data.x_err_set = nullptr; |
| 11779 | | 11820 | |
| 11780 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11821 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11781 | source_instr->scope, source_instr->source_node); | 11822 | source_instr->scope, source_instr->source_node); |
| 11782 | const_instruction->base.value.type = wanted_type; | 11823 | const_instruction->base.value->type = wanted_type; |
| 11783 | const_instruction->base.value.special = ConstValSpecialStatic; | 11824 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11784 | const_instruction->base.value.data.x_err_union.error_set = err_set_val; | 11825 | const_instruction->base.value->data.x_err_union.error_set = err_set_val; |
| 11785 | const_instruction->base.value.data.x_err_union.payload = val; | 11826 | const_instruction->base.value->data.x_err_union.payload = val; |
| 11786 | return &const_instruction->base; | 11827 | return &const_instruction->base; |
| 11787 | } | 11828 | } |
| 11788 | | 11829 | |
| ... | @@ -11790,7 +11831,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11790,7 +11831,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11790 | if (handle_is_ptr(wanted_type)) { | 11831 | if (handle_is_ptr(wanted_type)) { |
| 11791 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11832 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11792 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11833 | 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)) { | 11834 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11794 | return result_loc_inst; | 11835 | return result_loc_inst; |
| 11795 | } | 11836 | } |
| 11796 | } else { | 11837 | } else { |
| ... | @@ -11798,18 +11839,18 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11798,18 +11839,18 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11798 | } | 11839 | } |
| 11799 | | 11840 | |
| 11800 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); | 11841 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11801 | result->value.data.rh_error_union = RuntimeHintErrorUnionNonError; | 11842 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; |
| 11802 | return result; | 11843 | return result; |
| 11803 | } | 11844 | } |
| 11804 | | 11845 | |
| 11805 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 11846 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 11806 | ZigType *wanted_type) | 11847 | ZigType *wanted_type) |
| 11807 | { | 11848 | { |
| 11808 | assert(value->value.type->id == ZigTypeIdErrorSet); | 11849 | assert(value->value->type->id == ZigTypeIdErrorSet); |
| 11809 | assert(wanted_type->id == ZigTypeIdErrorSet); | 11850 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 11810 | | 11851 | |
| 11811 | if (instr_is_comptime(value)) { | 11852 | if (instr_is_comptime(value)) { |
| 11812 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11853 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11813 | if (!val) | 11854 | if (!val) |
| 11814 | return ira->codegen->invalid_instruction; | 11855 | return ira->codegen->invalid_instruction; |
| 11815 | | 11856 | |
| ... | @@ -11834,14 +11875,14 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -11834,14 +11875,14 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 11834 | | 11875 | |
| 11835 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11876 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11836 | source_instr->scope, source_instr->source_node); | 11877 | source_instr->scope, source_instr->source_node); |
| 11837 | const_instruction->base.value.type = wanted_type; | 11878 | const_instruction->base.value->type = wanted_type; |
| 11838 | const_instruction->base.value.special = ConstValSpecialStatic; | 11879 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11839 | const_instruction->base.value.data.x_err_set = val->data.x_err_set; | 11880 | const_instruction->base.value->data.x_err_set = val->data.x_err_set; |
| 11840 | return &const_instruction->base; | 11881 | return &const_instruction->base; |
| 11841 | } | 11882 | } |
| 11842 | | 11883 | |
| 11843 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet); | 11884 | 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; | 11885 | result->value->type = wanted_type; |
| 11845 | return result; | 11886 | return result; |
| 11846 | } | 11887 | } |
| 11847 | | 11888 | |
| ... | @@ -11849,7 +11890,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -11849,7 +11890,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 11849 | IrInstruction *frame_ptr, ZigType *wanted_type) | 11890 | IrInstruction *frame_ptr, ZigType *wanted_type) |
| 11850 | { | 11891 | { |
| 11851 | if (instr_is_comptime(frame_ptr)) { | 11892 | if (instr_is_comptime(frame_ptr)) { |
| 11852 | ConstExprValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); | 11893 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); |
| 11853 | if (ptr_val == nullptr) | 11894 | if (ptr_val == nullptr) |
| 11854 | return ira->codegen->invalid_instruction; | 11895 | return ira->codegen->invalid_instruction; |
| 11855 | | 11896 | |
| ... | @@ -11861,7 +11902,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -11861,7 +11902,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 11861 | | 11902 | |
| 11862 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11903 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11863 | wanted_type, frame_ptr, CastOpBitCast); | 11904 | wanted_type, frame_ptr, CastOpBitCast); |
| 11864 | result->value.type = wanted_type; | 11905 | result->value->type = wanted_type; |
| 11865 | return result; | 11906 | return result; |
| 11866 | } | 11907 | } |
| 11867 | | 11908 | |
| ... | @@ -11874,7 +11915,7 @@ static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruct | ... | @@ -11874,7 +11915,7 @@ static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruct |
| 11874 | | 11915 | |
| 11875 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11916 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11876 | wanted_type, value, CastOpBitCast); | 11917 | wanted_type, value, CastOpBitCast); |
| 11877 | result->value.type = wanted_type; | 11918 | result->value->type = wanted_type; |
| 11878 | return result; | 11919 | return result; |
| 11879 | } | 11920 | } |
| 11880 | | 11921 | |
| ... | @@ -11887,21 +11928,21 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11887,21 +11928,21 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11887 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | 11928 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 11888 | | 11929 | |
| 11889 | if (instr_is_comptime(casted_value)) { | 11930 | if (instr_is_comptime(casted_value)) { |
| 11890 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 11931 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 11891 | if (!val) | 11932 | if (!val) |
| 11892 | return ira->codegen->invalid_instruction; | 11933 | return ira->codegen->invalid_instruction; |
| 11893 | | 11934 | |
| 11894 | ConstExprValue *err_set_val = create_const_vals(1); | 11935 | ZigValue *err_set_val = create_const_vals(1); |
| 11895 | err_set_val->special = ConstValSpecialStatic; | 11936 | err_set_val->special = ConstValSpecialStatic; |
| 11896 | err_set_val->type = wanted_type->data.error_union.err_set_type; | 11937 | err_set_val->type = wanted_type->data.error_union.err_set_type; |
| 11897 | err_set_val->data.x_err_set = val->data.x_err_set; | 11938 | err_set_val->data.x_err_set = val->data.x_err_set; |
| 11898 | | 11939 | |
| 11899 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11940 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11900 | source_instr->scope, source_instr->source_node); | 11941 | source_instr->scope, source_instr->source_node); |
| 11901 | const_instruction->base.value.type = wanted_type; | 11942 | const_instruction->base.value->type = wanted_type; |
| 11902 | const_instruction->base.value.special = ConstValSpecialStatic; | 11943 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11903 | const_instruction->base.value.data.x_err_union.error_set = err_set_val; | 11944 | const_instruction->base.value->data.x_err_union.error_set = err_set_val; |
| 11904 | const_instruction->base.value.data.x_err_union.payload = nullptr; | 11945 | const_instruction->base.value->data.x_err_union.payload = nullptr; |
| 11905 | return &const_instruction->base; | 11946 | return &const_instruction->base; |
| 11906 | } | 11947 | } |
| 11907 | | 11948 | |
| ... | @@ -11909,7 +11950,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11909,7 +11950,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11909 | if (handle_is_ptr(wanted_type)) { | 11950 | if (handle_is_ptr(wanted_type)) { |
| 11910 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11951 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11911 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11952 | 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)) { | 11953 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11913 | return result_loc_inst; | 11954 | return result_loc_inst; |
| 11914 | } | 11955 | } |
| 11915 | } else { | 11956 | } else { |
| ... | @@ -11918,7 +11959,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11918,7 +11959,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11918 | | 11959 | |
| 11919 | | 11960 | |
| 11920 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); | 11961 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11921 | result->value.data.rh_error_union = RuntimeHintErrorUnionError; | 11962 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; |
| 11922 | return result; | 11963 | return result; |
| 11923 | } | 11964 | } |
| 11924 | | 11965 | |
| ... | @@ -11926,17 +11967,17 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -11926,17 +11967,17 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 11926 | assert(wanted_type->id == ZigTypeIdOptional); | 11967 | assert(wanted_type->id == ZigTypeIdOptional); |
| 11927 | assert(instr_is_comptime(value)); | 11968 | assert(instr_is_comptime(value)); |
| 11928 | | 11969 | |
| 11929 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11970 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11930 | assert(val != nullptr); | 11971 | assert(val != nullptr); |
| 11931 | | 11972 | |
| 11932 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11973 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11933 | result->value.special = ConstValSpecialStatic; | 11974 | result->value->special = ConstValSpecialStatic; |
| 11934 | if (get_codegen_ptr_type(wanted_type) != nullptr) { | 11975 | if (get_codegen_ptr_type(wanted_type) != nullptr) { |
| 11935 | result->value.data.x_ptr.special = ConstPtrSpecialNull; | 11976 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 11936 | } else if (is_opt_err_set(wanted_type)) { | 11977 | } else if (is_opt_err_set(wanted_type)) { |
| 11937 | result->value.data.x_err_set = nullptr; | 11978 | result->value->data.x_err_set = nullptr; |
| 11938 | } else { | 11979 | } else { |
| 11939 | result->value.data.x_optional = nullptr; | 11980 | result->value->data.x_optional = nullptr; |
| 11940 | } | 11981 | } |
| 11941 | return result; | 11982 | return result; |
| 11942 | } | 11983 | } |
| ... | @@ -11948,12 +11989,12 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction | ... | @@ -11948,12 +11989,12 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction |
| 11948 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); | 11989 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); |
| 11949 | assert(instr_is_comptime(value)); | 11990 | assert(instr_is_comptime(value)); |
| 11950 | | 11991 | |
| 11951 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11992 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11952 | assert(val != nullptr); | 11993 | assert(val != nullptr); |
| 11953 | | 11994 | |
| 11954 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11995 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11955 | result->value.data.x_ptr.special = ConstPtrSpecialNull; | 11996 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 11956 | result->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 11997 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 11957 | return result; | 11998 | return result; |
| 11958 | } | 11999 | } |
| 11959 | | 12000 | |
| ... | @@ -11962,36 +12003,36 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -11962,36 +12003,36 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 11962 | { | 12003 | { |
| 11963 | Error err; | 12004 | Error err; |
| 11964 | | 12005 | |
| 11965 | if (type_is_invalid(value->value.type)) | 12006 | if (type_is_invalid(value->value->type)) |
| 11966 | return ira->codegen->invalid_instruction; | 12007 | return ira->codegen->invalid_instruction; |
| 11967 | | 12008 | |
| 11968 | if ((err = type_resolve(ira->codegen, value->value.type, ResolveStatusZeroBitsKnown))) | 12009 | if ((err = type_resolve(ira->codegen, value->value->type, ResolveStatusZeroBitsKnown))) |
| 11969 | return ira->codegen->invalid_instruction; | 12010 | return ira->codegen->invalid_instruction; |
| 11970 | | 12011 | |
| 11971 | if (instr_is_comptime(value)) { | 12012 | if (instr_is_comptime(value)) { |
| 11972 | ConstExprValue *val = ir_resolve_const(ira, value, LazyOk); | 12013 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); |
| 11973 | if (!val) | 12014 | if (!val) |
| 11974 | return ira->codegen->invalid_instruction; | 12015 | return ira->codegen->invalid_instruction; |
| 11975 | return ir_get_const_ptr(ira, source_instruction, val, value->value.type, | 12016 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, |
| 11976 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); | 12017 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); |
| 11977 | } | 12018 | } |
| 11978 | | 12019 | |
| 11979 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type, | 12020 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value->type, |
| 11980 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 12021 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 11981 | | 12022 | |
| 11982 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) | 12023 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) |
| 11983 | return ira->codegen->invalid_instruction; | 12024 | return ira->codegen->invalid_instruction; |
| 11984 | | 12025 | |
| 11985 | IrInstruction *result_loc; | 12026 | IrInstruction *result_loc; |
| 11986 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value.type)) { | 12027 | 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, | 12028 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, nullptr, true, |
| 11988 | false, true); | 12029 | false, true); |
| 11989 | } else { | 12030 | } else { |
| 11990 | result_loc = nullptr; | 12031 | result_loc = nullptr; |
| 11991 | } | 12032 | } |
| 11992 | | 12033 | |
| 11993 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); | 12034 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); |
| 11994 | new_instruction->value.data.rh_ptr = RuntimeHintPtrStack; | 12035 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; |
| 11995 | return new_instruction; | 12036 | return new_instruction; |
| 11996 | } | 12037 | } |
| 11997 | | 12038 | |
| ... | @@ -12004,39 +12045,39 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s | ... | @@ -12004,39 +12045,39 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s |
| 12004 | | 12045 | |
| 12005 | IrInstruction *array_ptr = nullptr; | 12046 | IrInstruction *array_ptr = nullptr; |
| 12006 | IrInstruction *array; | 12047 | IrInstruction *array; |
| 12007 | if (array_arg->value.type->id == ZigTypeIdPointer) { | 12048 | if (array_arg->value->type->id == ZigTypeIdPointer) { |
| 12008 | array = ir_get_deref(ira, source_instr, array_arg, nullptr); | 12049 | array = ir_get_deref(ira, source_instr, array_arg, nullptr); |
| 12009 | array_ptr = array_arg; | 12050 | array_ptr = array_arg; |
| 12010 | } else { | 12051 | } else { |
| 12011 | array = array_arg; | 12052 | array = array_arg; |
| 12012 | } | 12053 | } |
| 12013 | ZigType *array_type = array->value.type; | 12054 | ZigType *array_type = array->value->type; |
| 12014 | assert(array_type->id == ZigTypeIdArray); | 12055 | assert(array_type->id == ZigTypeIdArray); |
| 12015 | | 12056 | |
| 12016 | if (instr_is_comptime(array) || array_type->data.array.len == 0) { | 12057 | if (instr_is_comptime(array) || array_type->data.array.len == 0) { |
| 12017 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12058 | 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); | 12059 | init_const_slice(ira->codegen, result->value, array->value, 0, array_type->data.array.len, true); |
| 12019 | result->value.type = wanted_type; | 12060 | result->value->type = wanted_type; |
| 12020 | return result; | 12061 | return result; |
| 12021 | } | 12062 | } |
| 12022 | | 12063 | |
| 12023 | IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | 12064 | IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); |
| 12024 | init_const_usize(ira->codegen, &start->value, 0); | 12065 | init_const_usize(ira->codegen, start->value, 0); |
| 12025 | | 12066 | |
| 12026 | IrInstruction *end = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | 12067 | 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); | 12068 | init_const_usize(ira->codegen, end->value, array_type->data.array.len); |
| 12028 | | 12069 | |
| 12029 | if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false); | 12070 | if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false); |
| 12030 | | 12071 | |
| 12031 | if (result_loc == nullptr) result_loc = no_result_loc(); | 12072 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12032 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, | 12073 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, |
| 12033 | true, false, true); | 12074 | true, false, true); |
| 12034 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 12075 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 12035 | return result_loc_inst; | 12076 | return result_loc_inst; |
| 12036 | } | 12077 | } |
| 12037 | IrInstruction *result = ir_build_slice_gen(ira, source_instr, wanted_type, array_ptr, start, end, false, result_loc_inst); | 12078 | 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; | 12079 | result->value->data.rh_slice.id = RuntimeHintSliceIdLen; |
| 12039 | result->value.data.rh_slice.len = array_type->data.array.len; | 12080 | result->value->data.rh_slice.len = array_type->data.array.len; |
| 12040 | | 12081 | |
| 12041 | return result; | 12082 | return result; |
| 12042 | } | 12083 | } |
| ... | @@ -12065,19 +12106,19 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12065,19 +12106,19 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12065 | | 12106 | |
| 12066 | IrInstruction *enum_target; | 12107 | IrInstruction *enum_target; |
| 12067 | ZigType *enum_type; | 12108 | ZigType *enum_type; |
| 12068 | if (target->value.type->id == ZigTypeIdUnion) { | 12109 | if (target->value->type->id == ZigTypeIdUnion) { |
| 12069 | enum_type = ir_resolve_union_tag_type(ira, target, target->value.type); | 12110 | enum_type = ir_resolve_union_tag_type(ira, target, target->value->type); |
| 12070 | if (type_is_invalid(enum_type)) | 12111 | if (type_is_invalid(enum_type)) |
| 12071 | return ira->codegen->invalid_instruction; | 12112 | return ira->codegen->invalid_instruction; |
| 12072 | enum_target = ir_implicit_cast(ira, target, enum_type); | 12113 | enum_target = ir_implicit_cast(ira, target, enum_type); |
| 12073 | if (type_is_invalid(enum_target->value.type)) | 12114 | if (type_is_invalid(enum_target->value->type)) |
| 12074 | return ira->codegen->invalid_instruction; | 12115 | return ira->codegen->invalid_instruction; |
| 12075 | } else if (target->value.type->id == ZigTypeIdEnum) { | 12116 | } else if (target->value->type->id == ZigTypeIdEnum) { |
| 12076 | enum_target = target; | 12117 | enum_target = target; |
| 12077 | enum_type = target->value.type; | 12118 | enum_type = target->value->type; |
| 12078 | } else { | 12119 | } else { |
| 12079 | ir_add_error(ira, target, | 12120 | ir_add_error(ira, target, |
| 12080 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); | 12121 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); |
| 12081 | return ira->codegen->invalid_instruction; | 12122 | return ira->codegen->invalid_instruction; |
| 12082 | } | 12123 | } |
| 12083 | | 12124 | |
| ... | @@ -12092,41 +12133,41 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12092,41 +12133,41 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12092 | enum_type->data.enumeration.src_field_count == 1) | 12133 | enum_type->data.enumeration.src_field_count == 1) |
| 12093 | { | 12134 | { |
| 12094 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 12135 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 12095 | init_const_bigint(&result->value, tag_type, | 12136 | init_const_bigint(result->value, tag_type, |
| 12096 | &enum_type->data.enumeration.fields[0].value); | 12137 | &enum_type->data.enumeration.fields[0].value); |
| 12097 | return result; | 12138 | return result; |
| 12098 | } | 12139 | } |
| 12099 | | 12140 | |
| 12100 | if (instr_is_comptime(enum_target)) { | 12141 | if (instr_is_comptime(enum_target)) { |
| 12101 | ConstExprValue *val = ir_resolve_const(ira, enum_target, UndefBad); | 12142 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); |
| 12102 | if (!val) | 12143 | if (!val) |
| 12103 | return ira->codegen->invalid_instruction; | 12144 | return ira->codegen->invalid_instruction; |
| 12104 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 12145 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 12105 | init_const_bigint(&result->value, tag_type, &val->data.x_enum_tag); | 12146 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); |
| 12106 | return result; | 12147 | return result; |
| 12107 | } | 12148 | } |
| 12108 | | 12149 | |
| 12109 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 12150 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, |
| 12110 | source_instr->source_node, enum_target); | 12151 | source_instr->source_node, enum_target); |
| 12111 | result->value.type = tag_type; | 12152 | result->value->type = tag_type; |
| 12112 | return result; | 12153 | return result; |
| 12113 | } | 12154 | } |
| 12114 | | 12155 | |
| 12115 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, | 12156 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, |
| 12116 | IrInstruction *target, ZigType *wanted_type) | 12157 | IrInstruction *target, ZigType *wanted_type) |
| 12117 | { | 12158 | { |
| 12118 | assert(target->value.type->id == ZigTypeIdUnion); | 12159 | assert(target->value->type->id == ZigTypeIdUnion); |
| 12119 | assert(wanted_type->id == ZigTypeIdEnum); | 12160 | assert(wanted_type->id == ZigTypeIdEnum); |
| 12120 | assert(wanted_type == target->value.type->data.unionation.tag_type); | 12161 | assert(wanted_type == target->value->type->data.unionation.tag_type); |
| 12121 | | 12162 | |
| 12122 | if (instr_is_comptime(target)) { | 12163 | if (instr_is_comptime(target)) { |
| 12123 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12164 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12124 | if (!val) | 12165 | if (!val) |
| 12125 | return ira->codegen->invalid_instruction; | 12166 | return ira->codegen->invalid_instruction; |
| 12126 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12167 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12127 | result->value.special = ConstValSpecialStatic; | 12168 | result->value->special = ConstValSpecialStatic; |
| 12128 | result->value.type = wanted_type; | 12169 | result->value->type = wanted_type; |
| 12129 | bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_union.tag); | 12170 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); |
| 12130 | return result; | 12171 | return result; |
| 12131 | } | 12172 | } |
| 12132 | | 12173 | |
| ... | @@ -12135,16 +12176,16 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12135,16 +12176,16 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12135 | wanted_type->data.enumeration.src_field_count == 1) | 12176 | wanted_type->data.enumeration.src_field_count == 1) |
| 12136 | { | 12177 | { |
| 12137 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12178 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12138 | result->value.special = ConstValSpecialStatic; | 12179 | result->value->special = ConstValSpecialStatic; |
| 12139 | result->value.type = wanted_type; | 12180 | result->value->type = wanted_type; |
| 12140 | TypeEnumField *enum_field = target->value.type->data.unionation.fields[0].enum_field; | 12181 | 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); | 12182 | bigint_init_bigint(&result->value->data.x_enum_tag, &enum_field->value); |
| 12142 | return result; | 12183 | return result; |
| 12143 | } | 12184 | } |
| 12144 | | 12185 | |
| 12145 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, | 12186 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, |
| 12146 | source_instr->source_node, target); | 12187 | source_instr->source_node, target); |
| 12147 | result->value.type = wanted_type; | 12188 | result->value->type = wanted_type; |
| 12148 | return result; | 12189 | return result; |
| 12149 | } | 12190 | } |
| 12150 | | 12191 | |
| ... | @@ -12152,7 +12193,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc | ... | @@ -12152,7 +12193,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc |
| 12152 | IrInstruction *target, ZigType *wanted_type) | 12193 | IrInstruction *target, ZigType *wanted_type) |
| 12153 | { | 12194 | { |
| 12154 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12195 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12155 | result->value.special = ConstValSpecialUndef; | 12196 | result->value->special = ConstValSpecialUndef; |
| 12156 | return result; | 12197 | return result; |
| 12157 | } | 12198 | } |
| 12158 | | 12199 | |
| ... | @@ -12166,11 +12207,11 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12166,11 +12207,11 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12166 | return ira->codegen->invalid_instruction; | 12207 | return ira->codegen->invalid_instruction; |
| 12167 | | 12208 | |
| 12168 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | 12209 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12169 | if (type_is_invalid(target->value.type)) | 12210 | if (type_is_invalid(target->value->type)) |
| 12170 | return ira->codegen->invalid_instruction; | 12211 | return ira->codegen->invalid_instruction; |
| 12171 | | 12212 | |
| 12172 | if (instr_is_comptime(target)) { | 12213 | if (instr_is_comptime(target)) { |
| 12173 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12214 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12174 | if (!val) | 12215 | if (!val) |
| 12175 | return ira->codegen->invalid_instruction; | 12216 | return ira->codegen->invalid_instruction; |
| 12176 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); | 12217 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); |
| ... | @@ -12201,12 +12242,12 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12201,12 +12242,12 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12201 | } | 12242 | } |
| 12202 | | 12243 | |
| 12203 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12244 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12204 | result->value.special = ConstValSpecialStatic; | 12245 | result->value->special = ConstValSpecialStatic; |
| 12205 | result->value.type = wanted_type; | 12246 | result->value->type = wanted_type; |
| 12206 | bigint_init_bigint(&result->value.data.x_union.tag, &val->data.x_enum_tag); | 12247 | 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); | 12248 | result->value->data.x_union.payload = create_const_vals(1); |
| 12208 | result->value.data.x_union.payload->special = ConstValSpecialStatic; | 12249 | result->value->data.x_union.payload->special = ConstValSpecialStatic; |
| 12209 | result->value.data.x_union.payload->type = field_type; | 12250 | result->value->data.x_union.payload->type = field_type; |
| 12210 | return result; | 12251 | return result; |
| 12211 | } | 12252 | } |
| 12212 | | 12253 | |
| ... | @@ -12214,7 +12255,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12214,7 +12255,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12214 | // and in fact it's a noop cast because the union value is just the enum value | 12255 | // and in fact it's a noop cast because the union value is just the enum value |
| 12215 | if (wanted_type->data.unionation.gen_field_count == 0) { | 12256 | if (wanted_type->data.unionation.gen_field_count == 0) { |
| 12216 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); | 12257 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); |
| 12217 | result->value.type = wanted_type; | 12258 | result->value->type = wanted_type; |
| 12218 | return result; | 12259 | return result; |
| 12219 | } | 12260 | } |
| 12220 | | 12261 | |
| ... | @@ -12245,7 +12286,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12245,7 +12286,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12245 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); | 12286 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); |
| 12246 | | 12287 | |
| 12247 | if (instr_is_comptime(target)) { | 12288 | if (instr_is_comptime(target)) { |
| 12248 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12289 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12249 | if (!val) | 12290 | if (!val) |
| 12250 | return ira->codegen->invalid_instruction; | 12291 | return ira->codegen->invalid_instruction; |
| 12251 | if (wanted_type->id == ZigTypeIdInt) { | 12292 | if (wanted_type->id == ZigTypeIdInt) { |
| ... | @@ -12259,16 +12300,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12259,16 +12300,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12259 | { | 12300 | { |
| 12260 | ir_add_error(ira, source_instr, | 12301 | ir_add_error(ira, source_instr, |
| 12261 | buf_sprintf("cast from '%s' to '%s' truncates bits", | 12302 | buf_sprintf("cast from '%s' to '%s' truncates bits", |
| 12262 | buf_ptr(&target->value.type->name), buf_ptr(&wanted_type->name))); | 12303 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); |
| 12263 | return ira->codegen->invalid_instruction; | 12304 | return ira->codegen->invalid_instruction; |
| 12264 | } | 12305 | } |
| 12265 | } | 12306 | } |
| 12266 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12307 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12267 | result->value.type = wanted_type; | 12308 | result->value->type = wanted_type; |
| 12268 | if (wanted_type->id == ZigTypeIdInt) { | 12309 | if (wanted_type->id == ZigTypeIdInt) { |
| 12269 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 12310 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| 12270 | } else { | 12311 | } else { |
| 12271 | float_init_float(&result->value, val); | 12312 | float_init_float(result->value, val); |
| 12272 | } | 12313 | } |
| 12273 | return result; | 12314 | return result; |
| 12274 | } | 12315 | } |
| ... | @@ -12278,16 +12319,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12278,16 +12319,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12278 | // the target is zero. | 12319 | // the target is zero. |
| 12279 | if (!type_has_bits(wanted_type)) { | 12320 | if (!type_has_bits(wanted_type)) { |
| 12280 | assert(wanted_type->id == ZigTypeIdInt); | 12321 | assert(wanted_type->id == ZigTypeIdInt); |
| 12281 | assert(type_has_bits(target->value.type)); | 12322 | assert(type_has_bits(target->value->type)); |
| 12282 | ir_build_assert_zero(ira, source_instr, target); | 12323 | ir_build_assert_zero(ira, source_instr, target); |
| 12283 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); | 12324 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); |
| 12284 | result->value.type = wanted_type; | 12325 | result->value->type = wanted_type; |
| 12285 | return result; | 12326 | return result; |
| 12286 | } | 12327 | } |
| 12287 | | 12328 | |
| 12288 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 12329 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, |
| 12289 | source_instr->source_node, target); | 12330 | source_instr->source_node, target); |
| 12290 | result->value.type = wanted_type; | 12331 | result->value->type = wanted_type; |
| 12291 | return result; | 12332 | return result; |
| 12292 | } | 12333 | } |
| 12293 | | 12334 | |
| ... | @@ -12297,7 +12338,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12297,7 +12338,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12297 | Error err; | 12338 | Error err; |
| 12298 | assert(wanted_type->id == ZigTypeIdEnum); | 12339 | assert(wanted_type->id == ZigTypeIdEnum); |
| 12299 | | 12340 | |
| 12300 | ZigType *actual_type = target->value.type; | 12341 | ZigType *actual_type = target->value->type; |
| 12301 | | 12342 | |
| 12302 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) | 12343 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) |
| 12303 | return ira->codegen->invalid_instruction; | 12344 | return ira->codegen->invalid_instruction; |
| ... | @@ -12313,7 +12354,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12313,7 +12354,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12313 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); | 12354 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); |
| 12314 | | 12355 | |
| 12315 | if (instr_is_comptime(target)) { | 12356 | if (instr_is_comptime(target)) { |
| 12316 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12357 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12317 | if (!val) | 12358 | if (!val) |
| 12318 | return ira->codegen->invalid_instruction; | 12359 | return ira->codegen->invalid_instruction; |
| 12319 | | 12360 | |
| ... | @@ -12330,28 +12371,28 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12330,28 +12371,28 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12330 | } | 12371 | } |
| 12331 | | 12372 | |
| 12332 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12373 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12333 | bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_bigint); | 12374 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); |
| 12334 | return result; | 12375 | return result; |
| 12335 | } | 12376 | } |
| 12336 | | 12377 | |
| 12337 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, | 12378 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, |
| 12338 | source_instr->source_node, nullptr, target); | 12379 | source_instr->source_node, nullptr, target); |
| 12339 | result->value.type = wanted_type; | 12380 | result->value->type = wanted_type; |
| 12340 | return result; | 12381 | return result; |
| 12341 | } | 12382 | } |
| 12342 | | 12383 | |
| 12343 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, | 12384 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, |
| 12344 | IrInstruction *target, ZigType *wanted_type) | 12385 | IrInstruction *target, ZigType *wanted_type) |
| 12345 | { | 12386 | { |
| 12346 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12387 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12347 | if (!val) | 12388 | if (!val) |
| 12348 | return ira->codegen->invalid_instruction; | 12389 | return ira->codegen->invalid_instruction; |
| 12349 | | 12390 | |
| 12350 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12391 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12351 | if (wanted_type->id == ZigTypeIdComptimeFloat) { | 12392 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 12352 | float_init_float(&result->value, val); | 12393 | float_init_float(result->value, val); |
| 12353 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { | 12394 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| 12354 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 12395 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| 12355 | } else { | 12396 | } else { |
| 12356 | zig_unreachable(); | 12397 | zig_unreachable(); |
| 12357 | } | 12398 | } |
| ... | @@ -12361,12 +12402,12 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -12361,12 +12402,12 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 12361 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 12402 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 12362 | ZigType *wanted_type) | 12403 | ZigType *wanted_type) |
| 12363 | { | 12404 | { |
| 12364 | assert(target->value.type->id == ZigTypeIdInt); | 12405 | assert(target->value->type->id == ZigTypeIdInt); |
| 12365 | assert(!target->value.type->data.integral.is_signed); | 12406 | assert(!target->value->type->data.integral.is_signed); |
| 12366 | assert(wanted_type->id == ZigTypeIdErrorSet); | 12407 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 12367 | | 12408 | |
| 12368 | if (instr_is_comptime(target)) { | 12409 | if (instr_is_comptime(target)) { |
| 12369 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12410 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12370 | if (!val) | 12411 | if (!val) |
| 12371 | return ira->codegen->invalid_instruction; | 12412 | return ira->codegen->invalid_instruction; |
| 12372 | | 12413 | |
| ... | @@ -12389,7 +12430,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12389,7 +12430,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12389 | } | 12430 | } |
| 12390 | | 12431 | |
| 12391 | size_t index = bigint_as_usize(&val->data.x_bigint); | 12432 | size_t index = bigint_as_usize(&val->data.x_bigint); |
| 12392 | result->value.data.x_err_set = ira->codegen->errors_by_index.at(index); | 12433 | result->value->data.x_err_set = ira->codegen->errors_by_index.at(index); |
| 12393 | return result; | 12434 | return result; |
| 12394 | } else { | 12435 | } else { |
| 12395 | ErrorTableEntry *err = nullptr; | 12436 | ErrorTableEntry *err = nullptr; |
| ... | @@ -12412,13 +12453,13 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12412,13 +12453,13 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12412 | return ira->codegen->invalid_instruction; | 12453 | return ira->codegen->invalid_instruction; |
| 12413 | } | 12454 | } |
| 12414 | | 12455 | |
| 12415 | result->value.data.x_err_set = err; | 12456 | result->value->data.x_err_set = err; |
| 12416 | return result; | 12457 | return result; |
| 12417 | } | 12458 | } |
| 12418 | } | 12459 | } |
| 12419 | | 12460 | |
| 12420 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 12461 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); |
| 12421 | result->value.type = wanted_type; | 12462 | result->value->type = wanted_type; |
| 12422 | return result; | 12463 | return result; |
| 12423 | } | 12464 | } |
| 12424 | | 12465 | |
| ... | @@ -12427,10 +12468,10 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12427,10 +12468,10 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12427 | { | 12468 | { |
| 12428 | assert(wanted_type->id == ZigTypeIdInt); | 12469 | assert(wanted_type->id == ZigTypeIdInt); |
| 12429 | | 12470 | |
| 12430 | ZigType *err_type = target->value.type; | 12471 | ZigType *err_type = target->value->type; |
| 12431 | | 12472 | |
| 12432 | if (instr_is_comptime(target)) { | 12473 | if (instr_is_comptime(target)) { |
| 12433 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12474 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12434 | if (!val) | 12475 | if (!val) |
| 12435 | return ira->codegen->invalid_instruction; | 12476 | return ira->codegen->invalid_instruction; |
| 12436 | | 12477 | |
| ... | @@ -12444,11 +12485,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12444,11 +12485,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12444 | } else { | 12485 | } else { |
| 12445 | zig_unreachable(); | 12486 | zig_unreachable(); |
| 12446 | } | 12487 | } |
| 12447 | result->value.type = wanted_type; | 12488 | result->value->type = wanted_type; |
| 12448 | uint64_t err_value = err ? err->value : 0; | 12489 | uint64_t err_value = err ? err->value : 0; |
| 12449 | bigint_init_unsigned(&result->value.data.x_bigint, err_value); | 12490 | bigint_init_unsigned(&result->value->data.x_bigint, err_value); |
| 12450 | | 12491 | |
| 12451 | if (!bigint_fits_in_bits(&result->value.data.x_bigint, | 12492 | if (!bigint_fits_in_bits(&result->value->data.x_bigint, |
| 12452 | wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) | 12493 | wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) |
| 12453 | { | 12494 | { |
| 12454 | ir_add_error_node(ira, source_instr->source_node, | 12495 | ir_add_error_node(ira, source_instr->source_node, |
| ... | @@ -12474,12 +12515,12 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12474,12 +12515,12 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12474 | } | 12515 | } |
| 12475 | if (err_set_type->data.error_set.err_count == 0) { | 12516 | if (err_set_type->data.error_set.err_count == 0) { |
| 12476 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12517 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12477 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 12518 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 12478 | return result; | 12519 | return result; |
| 12479 | } else if (err_set_type->data.error_set.err_count == 1) { | 12520 | } else if (err_set_type->data.error_set.err_count == 1) { |
| 12480 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12521 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12481 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; | 12522 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; |
| 12482 | bigint_init_unsigned(&result->value.data.x_bigint, err->value); | 12523 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); |
| 12483 | return result; | 12524 | return result; |
| 12484 | } | 12525 | } |
| 12485 | } | 12526 | } |
| ... | @@ -12493,7 +12534,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12493,7 +12534,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12493 | } | 12534 | } |
| 12494 | | 12535 | |
| 12495 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 12536 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); |
| 12496 | result->value.type = wanted_type; | 12537 | result->value->type = wanted_type; |
| 12497 | return result; | 12538 | return result; |
| 12498 | } | 12539 | } |
| 12499 | | 12540 | |
| ... | @@ -12502,25 +12543,25 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12502,25 +12543,25 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12502 | { | 12543 | { |
| 12503 | assert(wanted_type->id == ZigTypeIdPointer); | 12544 | assert(wanted_type->id == ZigTypeIdPointer); |
| 12504 | Error err; | 12545 | Error err; |
| 12505 | if ((err = type_resolve(ira->codegen, target->value.type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 12546 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 12506 | return ira->codegen->invalid_instruction; | 12547 | 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); | 12548 | 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)); | 12549 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); |
| 12509 | ZigType *array_type = wanted_type->data.pointer.child_type; | 12550 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| 12510 | assert(array_type->id == ZigTypeIdArray); | 12551 | assert(array_type->id == ZigTypeIdArray); |
| 12511 | assert(array_type->data.array.len == 1); | 12552 | assert(array_type->data.array.len == 1); |
| 12512 | | 12553 | |
| 12513 | if (instr_is_comptime(target)) { | 12554 | if (instr_is_comptime(target)) { |
| 12514 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12555 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12515 | if (!val) | 12556 | if (!val) |
| 12516 | return ira->codegen->invalid_instruction; | 12557 | return ira->codegen->invalid_instruction; |
| 12517 | | 12558 | |
| 12518 | assert(val->type->id == ZigTypeIdPointer); | 12559 | assert(val->type->id == ZigTypeIdPointer); |
| 12519 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 12560 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 12520 | if (pointee == nullptr) | 12561 | if (pointee == nullptr) |
| 12521 | return ira->codegen->invalid_instruction; | 12562 | return ira->codegen->invalid_instruction; |
| 12522 | if (pointee->special != ConstValSpecialRuntime) { | 12563 | if (pointee->special != ConstValSpecialRuntime) { |
| 12523 | ConstExprValue *array_val = create_const_vals(1); | 12564 | ZigValue *array_val = create_const_vals(1); |
| 12524 | array_val->special = ConstValSpecialStatic; | 12565 | array_val->special = ConstValSpecialStatic; |
| 12525 | array_val->type = array_type; | 12566 | array_val->type = array_type; |
| 12526 | array_val->data.x_array.special = ConstArraySpecialNone; | 12567 | array_val->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -12530,11 +12571,11 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12530,11 +12571,11 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12530 | | 12571 | |
| 12531 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 12572 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 12532 | source_instr->scope, source_instr->source_node); | 12573 | source_instr->scope, source_instr->source_node); |
| 12533 | const_instruction->base.value.type = wanted_type; | 12574 | const_instruction->base.value->type = wanted_type; |
| 12534 | const_instruction->base.value.special = ConstValSpecialStatic; | 12575 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 12535 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialRef; | 12576 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 12536 | const_instruction->base.value.data.x_ptr.data.ref.pointee = array_val; | 12577 | 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; | 12578 | const_instruction->base.value->data.x_ptr.mut = val->data.x_ptr.mut; |
| 12538 | return &const_instruction->base; | 12579 | return &const_instruction->base; |
| 12539 | } | 12580 | } |
| 12540 | } | 12581 | } |
| ... | @@ -12542,7 +12583,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12542,7 +12583,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12542 | // pointer to array and pointer to single item are represented the same way at runtime | 12583 | // pointer to array and pointer to single item are represented the same way at runtime |
| 12543 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, | 12584 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, |
| 12544 | wanted_type, target, CastOpBitCast); | 12585 | wanted_type, target, CastOpBitCast); |
| 12545 | result->value.type = wanted_type; | 12586 | result->value->type = wanted_type; |
| 12546 | return result; | 12587 | return result; |
| 12547 | } | 12588 | } |
| 12548 | | 12589 | |
| ... | @@ -12724,10 +12765,10 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * | ... | @@ -12724,10 +12765,10 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * |
| 12724 | IrInstruction *array, ZigType *vector_type) | 12765 | IrInstruction *array, ZigType *vector_type) |
| 12725 | { | 12766 | { |
| 12726 | if (instr_is_comptime(array)) { | 12767 | if (instr_is_comptime(array)) { |
| 12727 | // arrays and vectors have the same ConstExprValue representation | 12768 | // arrays and vectors have the same ZigValue representation |
| 12728 | IrInstruction *result = ir_const(ira, source_instr, vector_type); | 12769 | IrInstruction *result = ir_const(ira, source_instr, vector_type); |
| 12729 | copy_const_val(&result->value, &array->value, false); | 12770 | copy_const_val(result->value, array->value, false); |
| 12730 | result->value.type = vector_type; | 12771 | result->value->type = vector_type; |
| 12731 | return result; | 12772 | return result; |
| 12732 | } | 12773 | } |
| 12733 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); | 12774 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); |
| ... | @@ -12737,10 +12778,10 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -12737,10 +12778,10 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 12737 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) | 12778 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) |
| 12738 | { | 12779 | { |
| 12739 | if (instr_is_comptime(vector)) { | 12780 | if (instr_is_comptime(vector)) { |
| 12740 | // arrays and vectors have the same ConstExprValue representation | 12781 | // arrays and vectors have the same ZigValue representation |
| 12741 | IrInstruction *result = ir_const(ira, source_instr, array_type); | 12782 | IrInstruction *result = ir_const(ira, source_instr, array_type); |
| 12742 | copy_const_val(&result->value, &vector->value, false); | 12783 | copy_const_val(result->value, vector->value, false); |
| 12743 | result->value.type = array_type; | 12784 | result->value->type = array_type; |
| 12744 | return result; | 12785 | return result; |
| 12745 | } | 12786 | } |
| 12746 | if (result_loc == nullptr) { | 12787 | if (result_loc == nullptr) { |
| ... | @@ -12748,7 +12789,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -12748,7 +12789,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 12748 | } | 12789 | } |
| 12749 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, | 12790 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, |
| 12750 | true, false, true); | 12791 | true, false, true); |
| 12751 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 12792 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 12752 | return result_loc_inst; | 12793 | return result_loc_inst; |
| 12753 | } | 12794 | } |
| 12754 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); | 12795 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); |
| ... | @@ -12761,23 +12802,23 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12761,23 +12802,23 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 12761 | if (instr_is_comptime(integer)) { | 12802 | if (instr_is_comptime(integer)) { |
| 12762 | unsigned_integer = integer; | 12803 | unsigned_integer = integer; |
| 12763 | } else { | 12804 | } else { |
| 12764 | assert(integer->value.type->id == ZigTypeIdInt); | 12805 | assert(integer->value->type->id == ZigTypeIdInt); |
| 12765 | | 12806 | |
| 12766 | if (integer->value.type->data.integral.bit_count > | 12807 | if (integer->value->type->data.integral.bit_count > |
| 12767 | ira->codegen->builtin_types.entry_usize->data.integral.bit_count) | 12808 | ira->codegen->builtin_types.entry_usize->data.integral.bit_count) |
| 12768 | { | 12809 | { |
| 12769 | ir_add_error(ira, source_instr, | 12810 | ir_add_error(ira, source_instr, |
| 12770 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", | 12811 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", |
| 12771 | buf_ptr(&integer->value.type->name), | 12812 | buf_ptr(&integer->value->type->name), |
| 12772 | buf_ptr(&dest_type->name))); | 12813 | buf_ptr(&dest_type->name))); |
| 12773 | return ira->codegen->invalid_instruction; | 12814 | return ira->codegen->invalid_instruction; |
| 12774 | } | 12815 | } |
| 12775 | | 12816 | |
| 12776 | if (integer->value.type->data.integral.is_signed) { | 12817 | if (integer->value->type->data.integral.is_signed) { |
| 12777 | ZigType *unsigned_int_type = get_int_type(ira->codegen, false, | 12818 | ZigType *unsigned_int_type = get_int_type(ira->codegen, false, |
| 12778 | integer->value.type->data.integral.bit_count); | 12819 | integer->value->type->data.integral.bit_count); |
| 12779 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); | 12820 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); |
| 12780 | if (type_is_invalid(unsigned_integer->value.type)) | 12821 | if (type_is_invalid(unsigned_integer->value->type)) |
| 12781 | return ira->codegen->invalid_instruction; | 12822 | return ira->codegen->invalid_instruction; |
| 12782 | } else { | 12823 | } else { |
| 12783 | unsigned_integer = integer; | 12824 | unsigned_integer = integer; |
| ... | @@ -12807,16 +12848,16 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12807,16 +12848,16 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou |
| 12807 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) | 12848 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) |
| 12808 | return ira->codegen->invalid_instruction; | 12849 | return ira->codegen->invalid_instruction; |
| 12809 | | 12850 | |
| 12810 | TypeEnumField *field = find_enum_type_field(enum_type, value->value.data.x_enum_literal); | 12851 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); |
| 12811 | if (field == nullptr) { | 12852 | if (field == nullptr) { |
| 12812 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'", | 12853 | 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))); | 12854 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); |
| 12814 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, | 12855 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, |
| 12815 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); | 12856 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); |
| 12816 | return ira->codegen->invalid_instruction; | 12857 | return ira->codegen->invalid_instruction; |
| 12817 | } | 12858 | } |
| 12818 | IrInstruction *result = ir_const(ira, source_instr, enum_type); | 12859 | IrInstruction *result = ir_const(ira, source_instr, enum_type); |
| 12819 | bigint_init_bigint(&result->value.data.x_enum_tag, &field->value); | 12860 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); |
| 12820 | | 12861 | |
| 12821 | return result; | 12862 | return result; |
| 12822 | } | 12863 | } |
| ... | @@ -12885,7 +12926,7 @@ static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst | ... | @@ -12885,7 +12926,7 @@ static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst |
| 12885 | { | 12926 | { |
| 12886 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); | 12927 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); |
| 12887 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, | 12928 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, |
| 12888 | struct_operand->value.type, false); | 12929 | struct_operand->value->type, false); |
| 12889 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); | 12930 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); |
| 12890 | } | 12931 | } |
| 12891 | | 12932 | |
| ... | @@ -12893,7 +12934,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12893,7 +12934,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12893 | ZigType *wanted_type, IrInstruction *value) | 12934 | ZigType *wanted_type, IrInstruction *value) |
| 12894 | { | 12935 | { |
| 12895 | Error err; | 12936 | Error err; |
| 12896 | ZigType *actual_type = value->value.type; | 12937 | ZigType *actual_type = value->value->type; |
| 12897 | AstNode *source_node = source_instr->source_node; | 12938 | AstNode *source_node = source_instr->source_node; |
| 12898 | | 12939 | |
| 12899 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { | 12940 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { |
| ... | @@ -12915,13 +12956,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12915,13 +12956,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12915 | } | 12956 | } |
| 12916 | | 12957 | |
| 12917 | if (const_cast_result.id == ConstCastResultIdFnCC) { | 12958 | if (const_cast_result.id == ConstCastResultIdFnCC) { |
| 12918 | ir_assert(value->value.type->id == ZigTypeIdFn, source_instr); | 12959 | ir_assert(value->value->type->id == ZigTypeIdFn, source_instr); |
| 12919 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. | 12960 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. |
| 12920 | if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync && | 12961 | if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync && |
| 12921 | actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified) | 12962 | actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified) |
| 12922 | { | 12963 | { |
| 12923 | ir_assert(value->value.data.x_ptr.special == ConstPtrSpecialFunction, source_instr); | 12964 | ir_assert(value->value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| 12924 | ZigFn *fn = value->value.data.x_ptr.data.fn.fn_entry; | 12965 | ZigFn *fn = value->value->data.x_ptr.data.fn.fn_entry; |
| 12925 | if (fn->inferred_async_node == nullptr) { | 12966 | if (fn->inferred_async_node == nullptr) { |
| 12926 | fn->inferred_async_node = source_instr->source_node; | 12967 | fn->inferred_async_node = source_instr->source_node; |
| 12927 | } | 12968 | } |
| ... | @@ -12963,7 +13004,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12963,7 +13004,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12963 | { | 13004 | { |
| 12964 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, | 13005 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, |
| 12965 | wanted_child_type); | 13006 | wanted_child_type); |
| 12966 | if (type_is_invalid(cast1->value.type)) | 13007 | if (type_is_invalid(cast1->value->type)) |
| 12967 | return ira->codegen->invalid_instruction; | 13008 | return ira->codegen->invalid_instruction; |
| 12968 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); | 13009 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); |
| 12969 | } | 13010 | } |
| ... | @@ -12999,11 +13040,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12999,11 +13040,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12999 | actual_type->id == ZigTypeIdComptimeFloat) | 13040 | actual_type->id == ZigTypeIdComptimeFloat) |
| 13000 | { | 13041 | { |
| 13001 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 13042 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13002 | if (type_is_invalid(cast1->value.type)) | 13043 | if (type_is_invalid(cast1->value->type)) |
| 13003 | return ira->codegen->invalid_instruction; | 13044 | return ira->codegen->invalid_instruction; |
| 13004 | | 13045 | |
| 13005 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13046 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13006 | if (type_is_invalid(cast2->value.type)) | 13047 | if (type_is_invalid(cast2->value->type)) |
| 13007 | return ira->codegen->invalid_instruction; | 13048 | return ira->codegen->invalid_instruction; |
| 13008 | | 13049 | |
| 13009 | return cast2; | 13050 | return cast2; |
| ... | @@ -13018,29 +13059,29 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13018,29 +13059,29 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13018 | (wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdComptimeInt || | 13059 | (wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdComptimeInt || |
| 13019 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) | 13060 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) |
| 13020 | { | 13061 | { |
| 13021 | if (value->value.special == ConstValSpecialUndef) { | 13062 | if (value->value->special == ConstValSpecialUndef) { |
| 13022 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13063 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13023 | result->value.special = ConstValSpecialUndef; | 13064 | result->value->special = ConstValSpecialUndef; |
| 13024 | return result; | 13065 | return result; |
| 13025 | } | 13066 | } |
| 13026 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { | 13067 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 13027 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { | 13068 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 13028 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13069 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13029 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 13070 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13030 | copy_const_val(&result->value, &value->value, false); | 13071 | copy_const_val(result->value, value->value, false); |
| 13031 | result->value.type = wanted_type; | 13072 | result->value->type = wanted_type; |
| 13032 | } else { | 13073 | } else { |
| 13033 | float_init_bigint(&result->value.data.x_bigint, &value->value); | 13074 | float_init_bigint(&result->value->data.x_bigint, value->value); |
| 13034 | } | 13075 | } |
| 13035 | return result; | 13076 | return result; |
| 13036 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { | 13077 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { |
| 13037 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13078 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13038 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 13079 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13039 | BigFloat bf; | 13080 | BigFloat bf; |
| 13040 | bigfloat_init_bigint(&bf, &value->value.data.x_bigint); | 13081 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); |
| 13041 | float_init_bigfloat(&result->value, &bf); | 13082 | float_init_bigfloat(result->value, &bf); |
| 13042 | } else { | 13083 | } else { |
| 13043 | float_init_float(&result->value, &value->value); | 13084 | float_init_float(result->value, value->value); |
| 13044 | } | 13085 | } |
| 13045 | return result; | 13086 | return result; |
| 13046 | } | 13087 | } |
| ... | @@ -13102,11 +13143,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13102,11 +13143,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13102 | source_node, false).id == ConstCastResultIdOk) | 13143 | source_node, false).id == ConstCastResultIdOk) |
| 13103 | { | 13144 | { |
| 13104 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 13145 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13105 | if (type_is_invalid(cast1->value.type)) | 13146 | if (type_is_invalid(cast1->value->type)) |
| 13106 | return ira->codegen->invalid_instruction; | 13147 | return ira->codegen->invalid_instruction; |
| 13107 | | 13148 | |
| 13108 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13149 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13109 | if (type_is_invalid(cast2->value.type)) | 13150 | if (type_is_invalid(cast2->value->type)) |
| 13110 | return ira->codegen->invalid_instruction; | 13151 | return ira->codegen->invalid_instruction; |
| 13111 | | 13152 | |
| 13112 | return cast2; | 13153 | return cast2; |
| ... | @@ -13121,11 +13162,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13121,11 +13162,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13121 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 13162 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13122 | { | 13163 | { |
| 13123 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 13164 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13124 | if (type_is_invalid(cast1->value.type)) | 13165 | if (type_is_invalid(cast1->value->type)) |
| 13125 | return ira->codegen->invalid_instruction; | 13166 | return ira->codegen->invalid_instruction; |
| 13126 | | 13167 | |
| 13127 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13168 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13128 | if (type_is_invalid(cast2->value.type)) | 13169 | if (type_is_invalid(cast2->value->type)) |
| 13129 | return ira->codegen->invalid_instruction; | 13170 | return ira->codegen->invalid_instruction; |
| 13130 | | 13171 | |
| 13131 | return cast2; | 13172 | return cast2; |
| ... | @@ -13202,11 +13243,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13202,11 +13243,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13202 | if (ok_align) { | 13243 | if (ok_align) { |
| 13203 | if (wanted_type->id == ZigTypeIdErrorUnion) { | 13244 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 13204 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); | 13245 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); |
| 13205 | if (type_is_invalid(cast1->value.type)) | 13246 | if (type_is_invalid(cast1->value->type)) |
| 13206 | return ira->codegen->invalid_instruction; | 13247 | return ira->codegen->invalid_instruction; |
| 13207 | | 13248 | |
| 13208 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13249 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13209 | if (type_is_invalid(cast2->value.type)) | 13250 | if (type_is_invalid(cast2->value->type)) |
| 13210 | return ira->codegen->invalid_instruction; | 13251 | return ira->codegen->invalid_instruction; |
| 13211 | | 13252 | |
| 13212 | return cast2; | 13253 | return cast2; |
| ... | @@ -13309,11 +13350,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13309,11 +13350,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13309 | source_node, false).id == ConstCastResultIdOk) | 13350 | source_node, false).id == ConstCastResultIdOk) |
| 13310 | { | 13351 | { |
| 13311 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 13352 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13312 | if (type_is_invalid(cast1->value.type)) | 13353 | if (type_is_invalid(cast1->value->type)) |
| 13313 | return ira->codegen->invalid_instruction; | 13354 | return ira->codegen->invalid_instruction; |
| 13314 | | 13355 | |
| 13315 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13356 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13316 | if (type_is_invalid(cast2->value.type)) | 13357 | if (type_is_invalid(cast2->value->type)) |
| 13317 | return ira->codegen->invalid_instruction; | 13358 | return ira->codegen->invalid_instruction; |
| 13318 | | 13359 | |
| 13319 | return cast2; | 13360 | return cast2; |
| ... | @@ -13529,13 +13570,13 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou | ... | @@ -13529,13 +13570,13 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou |
| 13529 | assert(value); | 13570 | assert(value); |
| 13530 | assert(value != ira->codegen->invalid_instruction); | 13571 | assert(value != ira->codegen->invalid_instruction); |
| 13531 | assert(!expected_type || !type_is_invalid(expected_type)); | 13572 | assert(!expected_type || !type_is_invalid(expected_type)); |
| 13532 | assert(value->value.type); | 13573 | assert(value->value->type); |
| 13533 | assert(!type_is_invalid(value->value.type)); | 13574 | assert(!type_is_invalid(value->value->type)); |
| 13534 | if (expected_type == nullptr) | 13575 | if (expected_type == nullptr) |
| 13535 | return value; // anything will do | 13576 | return value; // anything will do |
| 13536 | if (expected_type == value->value.type) | 13577 | if (expected_type == value->value->type) |
| 13537 | return value; // match | 13578 | return value; // match |
| 13538 | if (value->value.type->id == ZigTypeIdUnreachable) | 13579 | if (value->value->type->id == ZigTypeIdUnreachable) |
| 13539 | return value; | 13580 | return value; |
| 13540 | | 13581 | |
| 13541 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); | 13582 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); |
| ... | @@ -13549,7 +13590,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13549,7 +13590,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13549 | ResultLoc *result_loc) | 13590 | ResultLoc *result_loc) |
| 13550 | { | 13591 | { |
| 13551 | Error err; | 13592 | Error err; |
| 13552 | ZigType *ptr_type = ptr->value.type; | 13593 | ZigType *ptr_type = ptr->value->type; |
| 13553 | if (type_is_invalid(ptr_type)) | 13594 | if (type_is_invalid(ptr_type)) |
| 13554 | return ira->codegen->invalid_instruction; | 13595 | return ira->codegen->invalid_instruction; |
| 13555 | | 13596 | |
| ... | @@ -13571,24 +13612,24 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13571,24 +13612,24 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13571 | break; | 13612 | break; |
| 13572 | } | 13613 | } |
| 13573 | if (instr_is_comptime(ptr)) { | 13614 | if (instr_is_comptime(ptr)) { |
| 13574 | if (ptr->value.special == ConstValSpecialUndef) { | 13615 | if (ptr->value->special == ConstValSpecialUndef) { |
| 13575 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); | 13616 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); |
| 13576 | return ira->codegen->invalid_instruction; | 13617 | return ira->codegen->invalid_instruction; |
| 13577 | } | 13618 | } |
| 13578 | if (ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 13619 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 13579 | ConstExprValue *pointee = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 13620 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 13580 | if (child_type == ira->codegen->builtin_types.entry_var) { | 13621 | if (child_type == ira->codegen->builtin_types.entry_var) { |
| 13581 | child_type = pointee->type; | 13622 | child_type = pointee->type; |
| 13582 | } | 13623 | } |
| 13583 | if (pointee->special != ConstValSpecialRuntime) { | 13624 | if (pointee->special != ConstValSpecialRuntime) { |
| 13584 | IrInstruction *result = ir_const(ira, source_instruction, child_type); | 13625 | IrInstruction *result = ir_const(ira, source_instruction, child_type); |
| 13585 | | 13626 | |
| 13586 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, &result->value, | 13627 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, |
| 13587 | &ptr->value))) | 13628 | ptr->value))) |
| 13588 | { | 13629 | { |
| 13589 | return ira->codegen->invalid_instruction; | 13630 | return ira->codegen->invalid_instruction; |
| 13590 | } | 13631 | } |
| 13591 | result->value.type = child_type; | 13632 | result->value->type = child_type; |
| 13592 | return result; | 13633 | return result; |
| 13593 | } | 13634 | } |
| 13594 | } | 13635 | } |
| ... | @@ -13626,7 +13667,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13626,7 +13667,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13626 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13667 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 13627 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, | 13668 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, |
| 13628 | true, false, true); | 13669 | true, false, true); |
| 13629 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 13670 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 13630 | return result_loc_inst; | 13671 | return result_loc_inst; |
| 13631 | } | 13672 | } |
| 13632 | } else { | 13673 | } else { |
| ... | @@ -13637,7 +13678,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13637,7 +13678,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13637 | } | 13678 | } |
| 13638 | | 13679 | |
| 13639 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13680 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 13640 | ConstExprValue *const_val, uint32_t *out) | 13681 | ZigValue *const_val, uint32_t *out) |
| 13641 | { | 13682 | { |
| 13642 | Error err; | 13683 | Error err; |
| 13643 | if ((err = ir_resolve_const_val(codegen, exec, source_node, const_val, UndefBad))) | 13684 | if ((err = ir_resolve_const_val(codegen, exec, source_node, const_val, UndefBad))) |
| ... | @@ -13660,15 +13701,15 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -13660,15 +13701,15 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 13660 | } | 13701 | } |
| 13661 | | 13702 | |
| 13662 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { | 13703 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { |
| 13663 | if (type_is_invalid(value->value.type)) | 13704 | if (type_is_invalid(value->value->type)) |
| 13664 | return false; | 13705 | return false; |
| 13665 | | 13706 | |
| 13666 | // Look for this pattern: `*align(@alignOf(T)) T`. | 13707 | // Look for this pattern: `*align(@alignOf(T)) T`. |
| 13667 | // This can be resolved to be `*out = 0` without resolving any alignment. | 13708 | // This can be resolved to be `*out = 0` without resolving any alignment. |
| 13668 | if (elem_type != nullptr && value->value.special == ConstValSpecialLazy && | 13709 | if (elem_type != nullptr && value->value->special == ConstValSpecialLazy && |
| 13669 | value->value.data.x_lazy->id == LazyValueIdAlignOf) | 13710 | value->value->data.x_lazy->id == LazyValueIdAlignOf) |
| 13670 | { | 13711 | { |
| 13671 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value.data.x_lazy); | 13712 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value->data.x_lazy); |
| 13672 | | 13713 | |
| 13673 | ZigType *lazy_elem_type = ir_resolve_type(lazy_align_of->ira, lazy_align_of->target_type); | 13714 | ZigType *lazy_elem_type = ir_resolve_type(lazy_align_of->ira, lazy_align_of->target_type); |
| 13674 | if (type_is_invalid(lazy_elem_type)) | 13715 | if (type_is_invalid(lazy_elem_type)) |
| ... | @@ -13681,22 +13722,22 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem | ... | @@ -13681,22 +13722,22 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem |
| 13681 | } | 13722 | } |
| 13682 | | 13723 | |
| 13683 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | 13724 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); |
| 13684 | if (type_is_invalid(casted_value->value.type)) | 13725 | if (type_is_invalid(casted_value->value->type)) |
| 13685 | return false; | 13726 | return false; |
| 13686 | | 13727 | |
| 13687 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, | 13728 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, |
| 13688 | &casted_value->value, out); | 13729 | casted_value->value, out); |
| 13689 | } | 13730 | } |
| 13690 | | 13731 | |
| 13691 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { | 13732 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { |
| 13692 | if (type_is_invalid(value->value.type)) | 13733 | if (type_is_invalid(value->value->type)) |
| 13693 | return false; | 13734 | return false; |
| 13694 | | 13735 | |
| 13695 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); | 13736 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); |
| 13696 | if (type_is_invalid(casted_value->value.type)) | 13737 | if (type_is_invalid(casted_value->value->type)) |
| 13697 | return false; | 13738 | return false; |
| 13698 | | 13739 | |
| 13699 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13740 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13700 | if (!const_val) | 13741 | if (!const_val) |
| 13701 | return false; | 13742 | return false; |
| 13702 | | 13743 | |
| ... | @@ -13709,14 +13750,14 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out | ... | @@ -13709,14 +13750,14 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out |
| 13709 | } | 13750 | } |
| 13710 | | 13751 | |
| 13711 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | 13752 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 13712 | if (type_is_invalid(value->value.type)) | 13753 | if (type_is_invalid(value->value->type)) |
| 13713 | return false; | 13754 | return false; |
| 13714 | | 13755 | |
| 13715 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | 13756 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 13716 | if (type_is_invalid(casted_value->value.type)) | 13757 | if (type_is_invalid(casted_value->value->type)) |
| 13717 | return false; | 13758 | return false; |
| 13718 | | 13759 | |
| 13719 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13760 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13720 | if (!const_val) | 13761 | if (!const_val) |
| 13721 | return false; | 13762 | return false; |
| 13722 | | 13763 | |
| ... | @@ -13733,18 +13774,18 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) | ... | @@ -13733,18 +13774,18 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 13733 | } | 13774 | } |
| 13734 | | 13775 | |
| 13735 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { | 13776 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { |
| 13736 | if (type_is_invalid(value->value.type)) | 13777 | if (type_is_invalid(value->value->type)) |
| 13737 | return false; | 13778 | return false; |
| 13738 | | 13779 | |
| 13739 | ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); | 13780 | ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); |
| 13740 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); | 13781 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); |
| 13741 | ZigType *atomic_order_type = atomic_order_val->data.x_type; | 13782 | ZigType *atomic_order_type = atomic_order_val->data.x_type; |
| 13742 | | 13783 | |
| 13743 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | 13784 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 13744 | if (type_is_invalid(casted_value->value.type)) | 13785 | if (type_is_invalid(casted_value->value->type)) |
| 13745 | return false; | 13786 | return false; |
| 13746 | | 13787 | |
| 13747 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13788 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13748 | if (!const_val) | 13789 | if (!const_val) |
| 13749 | return false; | 13790 | return false; |
| 13750 | | 13791 | |
| ... | @@ -13753,18 +13794,18 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -13753,18 +13794,18 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13753 | } | 13794 | } |
| 13754 | | 13795 | |
| 13755 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { | 13796 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { |
| 13756 | if (type_is_invalid(value->value.type)) | 13797 | if (type_is_invalid(value->value->type)) |
| 13757 | return false; | 13798 | return false; |
| 13758 | | 13799 | |
| 13759 | ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); | 13800 | ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); |
| 13760 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); | 13801 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); |
| 13761 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; | 13802 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; |
| 13762 | | 13803 | |
| 13763 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | 13804 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| 13764 | if (type_is_invalid(casted_value->value.type)) | 13805 | if (type_is_invalid(casted_value->value->type)) |
| 13765 | return false; | 13806 | return false; |
| 13766 | | 13807 | |
| 13767 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13808 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13768 | if (!const_val) | 13809 | if (!const_val) |
| 13769 | return false; | 13810 | return false; |
| 13770 | | 13811 | |
| ... | @@ -13773,18 +13814,18 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -13773,18 +13814,18 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13773 | } | 13814 | } |
| 13774 | | 13815 | |
| 13775 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { | 13816 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { |
| 13776 | if (type_is_invalid(value->value.type)) | 13817 | if (type_is_invalid(value->value->type)) |
| 13777 | return false; | 13818 | return false; |
| 13778 | | 13819 | |
| 13779 | ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); | 13820 | ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); |
| 13780 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); | 13821 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); |
| 13781 | ZigType *global_linkage_type = global_linkage_val->data.x_type; | 13822 | ZigType *global_linkage_type = global_linkage_val->data.x_type; |
| 13782 | | 13823 | |
| 13783 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | 13824 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 13784 | if (type_is_invalid(casted_value->value.type)) | 13825 | if (type_is_invalid(casted_value->value->type)) |
| 13785 | return false; | 13826 | return false; |
| 13786 | | 13827 | |
| 13787 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13828 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13788 | if (!const_val) | 13829 | if (!const_val) |
| 13789 | return false; | 13830 | return false; |
| 13790 | | 13831 | |
| ... | @@ -13793,18 +13834,18 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -13793,18 +13834,18 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13793 | } | 13834 | } |
| 13794 | | 13835 | |
| 13795 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { | 13836 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { |
| 13796 | if (type_is_invalid(value->value.type)) | 13837 | if (type_is_invalid(value->value->type)) |
| 13797 | return false; | 13838 | return false; |
| 13798 | | 13839 | |
| 13799 | ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); | 13840 | ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); |
| 13800 | assert(float_mode_val->type->id == ZigTypeIdMetaType); | 13841 | assert(float_mode_val->type->id == ZigTypeIdMetaType); |
| 13801 | ZigType *float_mode_type = float_mode_val->data.x_type; | 13842 | ZigType *float_mode_type = float_mode_val->data.x_type; |
| 13802 | | 13843 | |
| 13803 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); | 13844 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| 13804 | if (type_is_invalid(casted_value->value.type)) | 13845 | if (type_is_invalid(casted_value->value->type)) |
| 13805 | return false; | 13846 | return false; |
| 13806 | | 13847 | |
| 13807 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13848 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13808 | if (!const_val) | 13849 | if (!const_val) |
| 13809 | return false; | 13850 | return false; |
| 13810 | | 13851 | |
| ... | @@ -13813,25 +13854,25 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -13813,25 +13854,25 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13813 | } | 13854 | } |
| 13814 | | 13855 | |
| 13815 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | 13856 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13816 | if (type_is_invalid(value->value.type)) | 13857 | if (type_is_invalid(value->value->type)) |
| 13817 | return nullptr; | 13858 | return nullptr; |
| 13818 | | 13859 | |
| 13819 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 13860 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 13820 | true, false, PtrLenUnknown, 0, 0, 0, false); | 13861 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 13821 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); | 13862 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 13822 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); | 13863 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); |
| 13823 | if (type_is_invalid(casted_value->value.type)) | 13864 | if (type_is_invalid(casted_value->value->type)) |
| 13824 | return nullptr; | 13865 | return nullptr; |
| 13825 | | 13866 | |
| 13826 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13867 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13827 | if (!const_val) | 13868 | if (!const_val) |
| 13828 | return nullptr; | 13869 | return nullptr; |
| 13829 | | 13870 | |
| 13830 | ConstExprValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index]; | 13871 | ZigValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index]; |
| 13831 | ConstExprValue *len_field = const_val->data.x_struct.fields[slice_len_index]; | 13872 | ZigValue *len_field = const_val->data.x_struct.fields[slice_len_index]; |
| 13832 | | 13873 | |
| 13833 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); | 13874 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 13834 | ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; | 13875 | ZigValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; |
| 13835 | expand_undef_array(ira->codegen, array_val); | 13876 | expand_undef_array(ira->codegen, array_val); |
| 13836 | size_t len = bigint_as_usize(&len_field->data.x_bigint); | 13877 | size_t len = bigint_as_usize(&len_field->data.x_bigint); |
| 13837 | if (array_val->data.x_array.special == ConstArraySpecialBuf && len == buf_len(array_val->data.x_array.data.s_buf)) { | 13878 | if (array_val->data.x_array.special == ConstArraySpecialBuf && len == buf_len(array_val->data.x_array.data.s_buf)) { |
| ... | @@ -13841,7 +13882,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -13841,7 +13882,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13841 | buf_resize(result, len); | 13882 | buf_resize(result, len); |
| 13842 | for (size_t i = 0; i < len; i += 1) { | 13883 | for (size_t i = 0; i < len; i += 1) { |
| 13843 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; | 13884 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; |
| 13844 | ConstExprValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; | 13885 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; |
| 13845 | if (char_val->special == ConstValSpecialUndef) { | 13886 | if (char_val->special == ConstValSpecialUndef) { |
| 13846 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); | 13887 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); |
| 13847 | return nullptr; | 13888 | return nullptr; |
| ... | @@ -13858,7 +13899,7 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -13858,7 +13899,7 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 13858 | IrInstructionAddImplicitReturnType *instruction) | 13899 | IrInstructionAddImplicitReturnType *instruction) |
| 13859 | { | 13900 | { |
| 13860 | IrInstruction *value = instruction->value->child; | 13901 | IrInstruction *value = instruction->value->child; |
| 13861 | if (type_is_invalid(value->value.type)) | 13902 | if (type_is_invalid(value->value->type)) |
| 13862 | return ir_unreach_error(ira); | 13903 | return ir_unreach_error(ira); |
| 13863 | | 13904 | |
| 13864 | if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) { | 13905 | if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) { |
| ... | @@ -13870,11 +13911,11 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -13870,11 +13911,11 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 13870 | | 13911 | |
| 13871 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { | 13912 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { |
| 13872 | IrInstruction *operand = instruction->operand->child; | 13913 | IrInstruction *operand = instruction->operand->child; |
| 13873 | if (type_is_invalid(operand->value.type)) | 13914 | if (type_is_invalid(operand->value->type)) |
| 13874 | return ir_unreach_error(ira); | 13915 | return ir_unreach_error(ira); |
| 13875 | | 13916 | |
| 13876 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | 13917 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); |
| 13877 | if (type_is_invalid(casted_operand->value.type)) { | 13918 | if (type_is_invalid(casted_operand->value->type)) { |
| 13878 | AstNode *source_node = ira->explicit_return_type_source_node; | 13919 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 13879 | if (source_node != nullptr) { | 13920 | if (source_node != nullptr) { |
| 13880 | ErrorMsg *msg = ira->codegen->errors.last(); | 13921 | ErrorMsg *msg = ira->codegen->errors.last(); |
| ... | @@ -13890,13 +13931,13 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -13890,13 +13931,13 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 13890 | // result location mechanism took care of it. | 13931 | // result location mechanism took care of it. |
| 13891 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 13932 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, |
| 13892 | instruction->base.source_node, nullptr); | 13933 | instruction->base.source_node, nullptr); |
| 13893 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 13934 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 13894 | return ir_finish_anal(ira, result); | 13935 | return ir_finish_anal(ira, result); |
| 13895 | } | 13936 | } |
| 13896 | | 13937 | |
| 13897 | if (casted_operand->value.special == ConstValSpecialRuntime && | 13938 | if (casted_operand->value->special == ConstValSpecialRuntime && |
| 13898 | casted_operand->value.type->id == ZigTypeIdPointer && | 13939 | casted_operand->value->type->id == ZigTypeIdPointer && |
| 13899 | casted_operand->value.data.rh_ptr == RuntimeHintPtrStack) | 13940 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) |
| 13900 | { | 13941 | { |
| 13901 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); | 13942 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); |
| 13902 | return ir_unreach_error(ira); | 13943 | return ir_unreach_error(ira); |
| ... | @@ -13904,23 +13945,23 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -13904,23 +13945,23 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 13904 | | 13945 | |
| 13905 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 13946 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, |
| 13906 | instruction->base.source_node, casted_operand); | 13947 | instruction->base.source_node, casted_operand); |
| 13907 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 13948 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 13908 | return ir_finish_anal(ira, result); | 13949 | return ir_finish_anal(ira, result); |
| 13909 | } | 13950 | } |
| 13910 | | 13951 | |
| 13911 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { | 13952 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { |
| 13912 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 13953 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 13913 | copy_const_val(&result->value, &instruction->base.value, true); | 13954 | copy_const_val(result->value, instruction->base.value, true); |
| 13914 | return result; | 13955 | return result; |
| 13915 | } | 13956 | } |
| 13916 | | 13957 | |
| 13917 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 13958 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| 13918 | IrInstruction *op1 = bin_op_instruction->op1->child; | 13959 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 13919 | if (type_is_invalid(op1->value.type)) | 13960 | if (type_is_invalid(op1->value->type)) |
| 13920 | return ira->codegen->invalid_instruction; | 13961 | return ira->codegen->invalid_instruction; |
| 13921 | | 13962 | |
| 13922 | IrInstruction *op2 = bin_op_instruction->op2->child; | 13963 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 13923 | if (type_is_invalid(op2->value.type)) | 13964 | if (type_is_invalid(op2->value->type)) |
| 13924 | return ira->codegen->invalid_instruction; | 13965 | return ira->codegen->invalid_instruction; |
| 13925 | | 13966 | |
| 13926 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 13967 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| ... | @@ -13934,16 +13975,16 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -13934,16 +13975,16 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13934 | return ira->codegen->invalid_instruction; | 13975 | return ira->codegen->invalid_instruction; |
| 13935 | | 13976 | |
| 13936 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 13977 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 13937 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 13978 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 13938 | if (op1_val == nullptr) | 13979 | if (op1_val == nullptr) |
| 13939 | return ira->codegen->invalid_instruction; | 13980 | return ira->codegen->invalid_instruction; |
| 13940 | | 13981 | |
| 13941 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 13982 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 13942 | if (op2_val == nullptr) | 13983 | if (op2_val == nullptr) |
| 13943 | return ira->codegen->invalid_instruction; | 13984 | return ira->codegen->invalid_instruction; |
| 13944 | | 13985 | |
| 13945 | assert(casted_op1->value.type->id == ZigTypeIdBool); | 13986 | assert(casted_op1->value->type->id == ZigTypeIdBool); |
| 13946 | assert(casted_op2->value.type->id == ZigTypeIdBool); | 13987 | assert(casted_op2->value->type->id == ZigTypeIdBool); |
| 13947 | bool result_bool; | 13988 | bool result_bool; |
| 13948 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { | 13989 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { |
| 13949 | result_bool = op1_val->data.x_bool || op2_val->data.x_bool; | 13990 | result_bool = op1_val->data.x_bool || op2_val->data.x_bool; |
| ... | @@ -13958,7 +13999,7 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -13958,7 +13999,7 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13958 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 13999 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 13959 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14000 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 13960 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 14001 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 13961 | result->value.type = bool_type; | 14002 | result->value->type = bool_type; |
| 13962 | return result; | 14003 | return result; |
| 13963 | } | 14004 | } |
| 13964 | | 14005 | |
| ... | @@ -13981,7 +14022,7 @@ static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { | ... | @@ -13981,7 +14022,7 @@ static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { |
| 13981 | } | 14022 | } |
| 13982 | } | 14023 | } |
| 13983 | | 14024 | |
| 13984 | static bool optional_value_is_null(ConstExprValue *val) { | 14025 | static bool optional_value_is_null(ZigValue *val) { |
| 13985 | assert(val->special == ConstValSpecialStatic); | 14026 | assert(val->special == ConstValSpecialStatic); |
| 13986 | if (get_codegen_ptr_type(val->type) != nullptr) { | 14027 | if (get_codegen_ptr_type(val->type) != nullptr) { |
| 13987 | if (val->data.x_ptr.special == ConstPtrSpecialNull) { | 14028 | if (val->data.x_ptr.special == ConstPtrSpecialNull) { |
| ... | @@ -13999,7 +14040,7 @@ static bool optional_value_is_null(ConstExprValue *val) { | ... | @@ -13999,7 +14040,7 @@ static bool optional_value_is_null(ConstExprValue *val) { |
| 13999 | } | 14040 | } |
| 14000 | | 14041 | |
| 14001 | static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | 14042 | static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, |
| 14002 | ConstExprValue *op1_val, ConstExprValue *op2_val, IrInstructionBinOp *bin_op_instruction, IrBinOp op_id, | 14043 | ZigValue *op1_val, ZigValue *op2_val, IrInstructionBinOp *bin_op_instruction, IrBinOp op_id, |
| 14003 | bool one_possible_value) { | 14044 | bool one_possible_value) { |
| 14004 | if (op1_val->special == ConstValSpecialUndef || | 14045 | if (op1_val->special == ConstValSpecialUndef || |
| 14005 | op2_val->special == ConstValSpecialUndef) | 14046 | op2_val->special == ConstValSpecialUndef) |
| ... | @@ -14052,7 +14093,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14052,7 +14093,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14052 | } | 14093 | } |
| 14053 | | 14094 | |
| 14054 | // Returns ErrorNotLazy when the value cannot be determined | 14095 | // Returns ErrorNotLazy when the value cannot be determined |
| 14055 | static Error lazy_cmp_zero(AstNode *source_node, ConstExprValue *val, Cmp *result) { | 14096 | static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { |
| 14056 | Error err; | 14097 | Error err; |
| 14057 | | 14098 | |
| 14058 | switch (val->special) { | 14099 | switch (val->special) { |
| ... | @@ -14079,7 +14120,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ConstExprValue *val, Cmp *resul | ... | @@ -14079,7 +14120,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ConstExprValue *val, Cmp *resul |
| 14079 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); | 14120 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); |
| 14080 | IrAnalyze *ira = lazy_size_of->ira; | 14121 | IrAnalyze *ira = lazy_size_of->ira; |
| 14081 | bool is_zero_bits; | 14122 | bool is_zero_bits; |
| 14082 | if ((err = type_val_resolve_zero_bits(ira->codegen, &lazy_size_of->target_type->value, | 14123 | if ((err = type_val_resolve_zero_bits(ira->codegen, lazy_size_of->target_type->value, |
| 14083 | nullptr, nullptr, &is_zero_bits))) | 14124 | nullptr, nullptr, &is_zero_bits))) |
| 14084 | { | 14125 | { |
| 14085 | return err; | 14126 | return err; |
| ... | @@ -14098,33 +14139,33 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14098,33 +14139,33 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14098 | Error err; | 14139 | Error err; |
| 14099 | | 14140 | |
| 14100 | IrInstruction *op1 = bin_op_instruction->op1->child; | 14141 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 14101 | if (type_is_invalid(op1->value.type)) | 14142 | if (type_is_invalid(op1->value->type)) |
| 14102 | return ira->codegen->invalid_instruction; | 14143 | return ira->codegen->invalid_instruction; |
| 14103 | | 14144 | |
| 14104 | IrInstruction *op2 = bin_op_instruction->op2->child; | 14145 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 14105 | if (type_is_invalid(op2->value.type)) | 14146 | if (type_is_invalid(op2->value->type)) |
| 14106 | return ira->codegen->invalid_instruction; | 14147 | return ira->codegen->invalid_instruction; |
| 14107 | | 14148 | |
| 14108 | AstNode *source_node = bin_op_instruction->base.source_node; | 14149 | AstNode *source_node = bin_op_instruction->base.source_node; |
| 14109 | | 14150 | |
| 14110 | IrBinOp op_id = bin_op_instruction->op_id; | 14151 | IrBinOp op_id = bin_op_instruction->op_id; |
| 14111 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); | 14152 | 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) { | 14153 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { |
| 14113 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); | 14154 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); |
| 14114 | } else if (is_equality_cmp && | 14155 | } else if (is_equality_cmp && |
| 14115 | ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdOptional) || | 14156 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || |
| 14116 | (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdOptional))) | 14157 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) |
| 14117 | { | 14158 | { |
| 14118 | IrInstruction *maybe_op; | 14159 | IrInstruction *maybe_op; |
| 14119 | if (op1->value.type->id == ZigTypeIdNull) { | 14160 | if (op1->value->type->id == ZigTypeIdNull) { |
| 14120 | maybe_op = op2; | 14161 | maybe_op = op2; |
| 14121 | } else if (op2->value.type->id == ZigTypeIdNull) { | 14162 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| 14122 | maybe_op = op1; | 14163 | maybe_op = op1; |
| 14123 | } else { | 14164 | } else { |
| 14124 | zig_unreachable(); | 14165 | zig_unreachable(); |
| 14125 | } | 14166 | } |
| 14126 | if (instr_is_comptime(maybe_op)) { | 14167 | if (instr_is_comptime(maybe_op)) { |
| 14127 | ConstExprValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); | 14168 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); |
| 14128 | if (!maybe_val) | 14169 | if (!maybe_val) |
| 14129 | return ira->codegen->invalid_instruction; | 14170 | return ira->codegen->invalid_instruction; |
| 14130 | bool is_null = optional_value_is_null(maybe_val); | 14171 | bool is_null = optional_value_is_null(maybe_val); |
| ... | @@ -14134,32 +14175,32 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14134,32 +14175,32 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14134 | | 14175 | |
| 14135 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 14176 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, |
| 14136 | source_node, maybe_op); | 14177 | source_node, maybe_op); |
| 14137 | is_non_null->value.type = ira->codegen->builtin_types.entry_bool; | 14178 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; |
| 14138 | | 14179 | |
| 14139 | if (op_id == IrBinOpCmpEq) { | 14180 | if (op_id == IrBinOpCmpEq) { |
| 14140 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 14181 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, |
| 14141 | bin_op_instruction->base.source_node, is_non_null); | 14182 | bin_op_instruction->base.source_node, is_non_null); |
| 14142 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14183 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14143 | return result; | 14184 | return result; |
| 14144 | } else { | 14185 | } else { |
| 14145 | return is_non_null; | 14186 | return is_non_null; |
| 14146 | } | 14187 | } |
| 14147 | } else if (is_equality_cmp && | 14188 | } else if (is_equality_cmp && |
| 14148 | ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdPointer && | 14189 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdPointer && |
| 14149 | op2->value.type->data.pointer.ptr_len == PtrLenC) || | 14190 | op2->value->type->data.pointer.ptr_len == PtrLenC) || |
| 14150 | (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdPointer && | 14191 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && |
| 14151 | op1->value.type->data.pointer.ptr_len == PtrLenC))) | 14192 | op1->value->type->data.pointer.ptr_len == PtrLenC))) |
| 14152 | { | 14193 | { |
| 14153 | IrInstruction *c_ptr_op; | 14194 | IrInstruction *c_ptr_op; |
| 14154 | if (op1->value.type->id == ZigTypeIdNull) { | 14195 | if (op1->value->type->id == ZigTypeIdNull) { |
| 14155 | c_ptr_op = op2; | 14196 | c_ptr_op = op2; |
| 14156 | } else if (op2->value.type->id == ZigTypeIdNull) { | 14197 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| 14157 | c_ptr_op = op1; | 14198 | c_ptr_op = op1; |
| 14158 | } else { | 14199 | } else { |
| 14159 | zig_unreachable(); | 14200 | zig_unreachable(); |
| 14160 | } | 14201 | } |
| 14161 | if (instr_is_comptime(c_ptr_op)) { | 14202 | if (instr_is_comptime(c_ptr_op)) { |
| 14162 | ConstExprValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); | 14203 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); |
| 14163 | if (!c_ptr_val) | 14204 | if (!c_ptr_val) |
| 14164 | return ira->codegen->invalid_instruction; | 14205 | return ira->codegen->invalid_instruction; |
| 14165 | if (c_ptr_val->special == ConstValSpecialUndef) | 14206 | if (c_ptr_val->special == ConstValSpecialUndef) |
| ... | @@ -14172,46 +14213,46 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14172,46 +14213,46 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14172 | } | 14213 | } |
| 14173 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 14214 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, |
| 14174 | source_node, c_ptr_op); | 14215 | source_node, c_ptr_op); |
| 14175 | is_non_null->value.type = ira->codegen->builtin_types.entry_bool; | 14216 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; |
| 14176 | | 14217 | |
| 14177 | if (op_id == IrBinOpCmpEq) { | 14218 | if (op_id == IrBinOpCmpEq) { |
| 14178 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 14219 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, |
| 14179 | bin_op_instruction->base.source_node, is_non_null); | 14220 | bin_op_instruction->base.source_node, is_non_null); |
| 14180 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14221 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14181 | return result; | 14222 | return result; |
| 14182 | } else { | 14223 | } else { |
| 14183 | return is_non_null; | 14224 | return is_non_null; |
| 14184 | } | 14225 | } |
| 14185 | } else if (op1->value.type->id == ZigTypeIdNull || op2->value.type->id == ZigTypeIdNull) { | 14226 | } 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; | 14227 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; |
| 14187 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", | 14228 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", |
| 14188 | buf_ptr(&non_null_type->name))); | 14229 | buf_ptr(&non_null_type->name))); |
| 14189 | return ira->codegen->invalid_instruction; | 14230 | return ira->codegen->invalid_instruction; |
| 14190 | } else if (is_equality_cmp && ( | 14231 | } else if (is_equality_cmp && ( |
| 14191 | (op1->value.type->id == ZigTypeIdEnumLiteral && op2->value.type->id == ZigTypeIdUnion) || | 14232 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || |
| 14192 | (op2->value.type->id == ZigTypeIdEnumLiteral && op1->value.type->id == ZigTypeIdUnion))) | 14233 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) |
| 14193 | { | 14234 | { |
| 14194 | // Support equality comparison between a union's tag value and a enum literal | 14235 | // Support equality comparison between a union's tag value and a enum literal |
| 14195 | IrInstruction *union_val = op1->value.type->id == ZigTypeIdUnion ? op1 : op2; | 14236 | IrInstruction *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; |
| 14196 | IrInstruction *enum_val = op1->value.type->id == ZigTypeIdUnion ? op2 : op1; | 14237 | IrInstruction *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; |
| 14197 | | 14238 | |
| 14198 | ZigType *tag_type = union_val->value.type->data.unionation.tag_type; | 14239 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 14199 | assert(tag_type != nullptr); | 14240 | assert(tag_type != nullptr); |
| 14200 | | 14241 | |
| 14201 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); | 14242 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); |
| 14202 | if (type_is_invalid(casted_union->value.type)) | 14243 | if (type_is_invalid(casted_union->value->type)) |
| 14203 | return ira->codegen->invalid_instruction; | 14244 | return ira->codegen->invalid_instruction; |
| 14204 | | 14245 | |
| 14205 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | 14246 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); |
| 14206 | if (type_is_invalid(casted_val->value.type)) | 14247 | if (type_is_invalid(casted_val->value->type)) |
| 14207 | return ira->codegen->invalid_instruction; | 14248 | return ira->codegen->invalid_instruction; |
| 14208 | | 14249 | |
| 14209 | if (instr_is_comptime(casted_union)) { | 14250 | if (instr_is_comptime(casted_union)) { |
| 14210 | ConstExprValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); | 14251 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); |
| 14211 | if (!const_union_val) | 14252 | if (!const_union_val) |
| 14212 | return ira->codegen->invalid_instruction; | 14253 | return ira->codegen->invalid_instruction; |
| 14213 | | 14254 | |
| 14214 | ConstExprValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); | 14255 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); |
| 14215 | if (!const_enum_val) | 14256 | if (!const_enum_val) |
| 14216 | return ira->codegen->invalid_instruction; | 14257 | return ira->codegen->invalid_instruction; |
| 14217 | | 14258 | |
| ... | @@ -14224,17 +14265,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14224,17 +14265,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14224 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 14265 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 14225 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14266 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14226 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); | 14267 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); |
| 14227 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14268 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14228 | | 14269 | |
| 14229 | return result; | 14270 | return result; |
| 14230 | } | 14271 | } |
| 14231 | | 14272 | |
| 14232 | if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) { | 14273 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { |
| 14233 | if (!is_equality_cmp) { | 14274 | if (!is_equality_cmp) { |
| 14234 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); | 14275 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); |
| 14235 | return ira->codegen->invalid_instruction; | 14276 | return ira->codegen->invalid_instruction; |
| 14236 | } | 14277 | } |
| 14237 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node); | 14278 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); |
| 14238 | if (type_is_invalid(intersect_type)) { | 14279 | if (type_is_invalid(intersect_type)) { |
| 14239 | return ira->codegen->invalid_instruction; | 14280 | return ira->codegen->invalid_instruction; |
| 14240 | } | 14281 | } |
| ... | @@ -14247,7 +14288,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14247,7 +14288,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14247 | // (and make it comptime known) | 14288 | // (and make it comptime known) |
| 14248 | // this is a function which is evaluated at comptime and returns an inferred error set will have an empty | 14289 | // this is a function which is evaluated at comptime and returns an inferred error set will have an empty |
| 14249 | // error set. | 14290 | // error set. |
| 14250 | if (op1->value.type->data.error_set.err_count == 0 || op2->value.type->data.error_set.err_count == 0) { | 14291 | if (op1->value->type->data.error_set.err_count == 0 || op2->value->type->data.error_set.err_count == 0) { |
| 14251 | bool are_equal = false; | 14292 | bool are_equal = false; |
| 14252 | bool answer; | 14293 | bool answer; |
| 14253 | if (op_id == IrBinOpCmpEq) { | 14294 | if (op_id == IrBinOpCmpEq) { |
| ... | @@ -14264,10 +14305,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14264,10 +14305,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14264 | if (intersect_type->data.error_set.err_count == 0) { | 14305 | if (intersect_type->data.error_set.err_count == 0) { |
| 14265 | ir_add_error_node(ira, source_node, | 14306 | ir_add_error_node(ira, source_node, |
| 14266 | buf_sprintf("error sets '%s' and '%s' have no common errors", | 14307 | buf_sprintf("error sets '%s' and '%s' have no common errors", |
| 14267 | buf_ptr(&op1->value.type->name), buf_ptr(&op2->value.type->name))); | 14308 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 14268 | return ira->codegen->invalid_instruction; | 14309 | return ira->codegen->invalid_instruction; |
| 14269 | } | 14310 | } |
| 14270 | if (op1->value.type->data.error_set.err_count == 1 && op2->value.type->data.error_set.err_count == 1) { | 14311 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { |
| 14271 | bool are_equal = true; | 14312 | bool are_equal = true; |
| 14272 | bool answer; | 14313 | bool answer; |
| 14273 | if (op_id == IrBinOpCmpEq) { | 14314 | if (op_id == IrBinOpCmpEq) { |
| ... | @@ -14282,10 +14323,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14282,10 +14323,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14282 | } | 14323 | } |
| 14283 | | 14324 | |
| 14284 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 14325 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 14285 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 14326 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14286 | if (op1_val == nullptr) | 14327 | if (op1_val == nullptr) |
| 14287 | return ira->codegen->invalid_instruction; | 14328 | return ira->codegen->invalid_instruction; |
| 14288 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 14329 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 14289 | if (op2_val == nullptr) | 14330 | if (op2_val == nullptr) |
| 14290 | return ira->codegen->invalid_instruction; | 14331 | return ira->codegen->invalid_instruction; |
| 14291 | | 14332 | |
| ... | @@ -14305,7 +14346,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14305,7 +14346,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14305 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 14346 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 14306 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14347 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14307 | op_id, op1, op2, bin_op_instruction->safety_check_on); | 14348 | op_id, op1, op2, bin_op_instruction->safety_check_on); |
| 14308 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14349 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14309 | return result; | 14350 | return result; |
| 14310 | } | 14351 | } |
| 14311 | | 14352 | |
| ... | @@ -14390,12 +14431,12 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14390,12 +14431,12 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14390 | // Before resolving the values, we special case comparisons against zero. These can often be done | 14431 | // Before resolving the values, we special case comparisons against zero. These can often be done |
| 14391 | // without resolving lazy values, preventing potential dependency loops. | 14432 | // without resolving lazy values, preventing potential dependency loops. |
| 14392 | Cmp op1_cmp_zero; | 14433 | Cmp op1_cmp_zero; |
| 14393 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op1->value, &op1_cmp_zero))) { | 14434 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op1->value, &op1_cmp_zero))) { |
| 14394 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; | 14435 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; |
| 14395 | return ira->codegen->invalid_instruction; | 14436 | return ira->codegen->invalid_instruction; |
| 14396 | } | 14437 | } |
| 14397 | Cmp op2_cmp_zero; | 14438 | Cmp op2_cmp_zero; |
| 14398 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op2->value, &op2_cmp_zero))) { | 14439 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op2->value, &op2_cmp_zero))) { |
| 14399 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; | 14440 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; |
| 14400 | return ira->codegen->invalid_instruction; | 14441 | return ira->codegen->invalid_instruction; |
| 14401 | } | 14442 | } |
| ... | @@ -14430,33 +14471,33 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14430,33 +14471,33 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14430 | } | 14471 | } |
| 14431 | never_mind_just_calculate_it_normally: | 14472 | never_mind_just_calculate_it_normally: |
| 14432 | | 14473 | |
| 14433 | ConstExprValue *op1_val = one_possible_value ? &casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); | 14474 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); |
| 14434 | if (op1_val == nullptr) | 14475 | if (op1_val == nullptr) |
| 14435 | return ira->codegen->invalid_instruction; | 14476 | return ira->codegen->invalid_instruction; |
| 14436 | ConstExprValue *op2_val = one_possible_value ? &casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); | 14477 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); |
| 14437 | if (op2_val == nullptr) | 14478 | if (op2_val == nullptr) |
| 14438 | return ira->codegen->invalid_instruction; | 14479 | return ira->codegen->invalid_instruction; |
| 14439 | if (resolved_type->id != ZigTypeIdVector) | 14480 | if (resolved_type->id != ZigTypeIdVector) |
| 14440 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); | 14481 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); |
| 14441 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, | 14482 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, |
| 14442 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); | 14483 | 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 = | 14484 | result->value->data.x_array.data.s_none.elements = |
| 14444 | create_const_vals(resolved_type->data.vector.len); | 14485 | create_const_vals(resolved_type->data.vector.len); |
| 14445 | | 14486 | |
| 14446 | expand_undef_array(ira->codegen, &result->value); | 14487 | expand_undef_array(ira->codegen, result->value); |
| 14447 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { | 14488 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| 14448 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | 14489 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, |
| 14449 | &op1_val->data.x_array.data.s_none.elements[i], | 14490 | &op1_val->data.x_array.data.s_none.elements[i], |
| 14450 | &op2_val->data.x_array.data.s_none.elements[i], | 14491 | &op2_val->data.x_array.data.s_none.elements[i], |
| 14451 | bin_op_instruction, op_id, one_possible_value); | 14492 | 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); | 14493 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], cur_res->value, false); |
| 14453 | } | 14494 | } |
| 14454 | return result; | 14495 | return result; |
| 14455 | } | 14496 | } |
| 14456 | | 14497 | |
| 14457 | // some comparisons with unsigned numbers can be evaluated | 14498 | // some comparisons with unsigned numbers can be evaluated |
| 14458 | if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) { | 14499 | if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) { |
| 14459 | ConstExprValue *known_left_val; | 14500 | ZigValue *known_left_val; |
| 14460 | IrBinOp flipped_op_id; | 14501 | IrBinOp flipped_op_id; |
| 14461 | if (instr_is_comptime(casted_op1)) { | 14502 | if (instr_is_comptime(casted_op1)) { |
| 14462 | known_left_val = ir_resolve_const(ira, casted_op1, UndefBad); | 14503 | known_left_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| ... | @@ -14495,16 +14536,16 @@ never_mind_just_calculate_it_normally: | ... | @@ -14495,16 +14536,16 @@ never_mind_just_calculate_it_normally: |
| 14495 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14536 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14496 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 14537 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14497 | if (resolved_type->id == ZigTypeIdVector) { | 14538 | if (resolved_type->id == ZigTypeIdVector) { |
| 14498 | result->value.type = get_vector_type(ira->codegen, resolved_type->data.vector.len, | 14539 | result->value->type = get_vector_type(ira->codegen, resolved_type->data.vector.len, |
| 14499 | ira->codegen->builtin_types.entry_bool); | 14540 | ira->codegen->builtin_types.entry_bool); |
| 14500 | } else { | 14541 | } else { |
| 14501 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14542 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14502 | } | 14543 | } |
| 14503 | return result; | 14544 | return result; |
| 14504 | } | 14545 | } |
| 14505 | | 14546 | |
| 14506 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 14547 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, |
| 14507 | ConstExprValue *op1_val, IrBinOp op_id, ConstExprValue *op2_val, ConstExprValue *out_val) | 14548 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 14508 | { | 14549 | { |
| 14509 | bool is_int; | 14550 | bool is_int; |
| 14510 | bool is_float; | 14551 | bool is_float; |
| ... | @@ -14646,7 +14687,7 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -14646,7 +14687,7 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 14646 | } | 14687 | } |
| 14647 | } else { | 14688 | } else { |
| 14648 | float_div_trunc(out_val, op1_val, op2_val); | 14689 | float_div_trunc(out_val, op1_val, op2_val); |
| 14649 | ConstExprValue remainder = {}; | 14690 | ZigValue remainder = {}; |
| 14650 | float_rem(&remainder, op1_val, op2_val); | 14691 | float_rem(&remainder, op1_val, op2_val); |
| 14651 | if (float_cmp_zero(&remainder) != CmpEQ) { | 14692 | if (float_cmp_zero(&remainder) != CmpEQ) { |
| 14652 | return ir_add_error(ira, source_instr, buf_sprintf("exact division had a remainder")); | 14693 | return ir_add_error(ira, source_instr, buf_sprintf("exact division had a remainder")); |
| ... | @@ -14684,10 +14725,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -14684,10 +14725,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 14684 | | 14725 | |
| 14685 | // This works on operands that have already been checked to be comptime known. | 14726 | // This works on operands that have already been checked to be comptime known. |
| 14686 | static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_instr, | 14727 | static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_instr, |
| 14687 | ZigType *type_entry, ConstExprValue *op1_val, IrBinOp op_id, ConstExprValue *op2_val) | 14728 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 14688 | { | 14729 | { |
| 14689 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); | 14730 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); |
| 14690 | ConstExprValue *out_val = &result_instruction->value; | 14731 | ZigValue *out_val = result_instruction->value; |
| 14691 | if (type_entry->id == ZigTypeIdVector) { | 14732 | if (type_entry->id == ZigTypeIdVector) { |
| 14692 | expand_undef_array(ira->codegen, op1_val); | 14733 | expand_undef_array(ira->codegen, op1_val); |
| 14693 | expand_undef_array(ira->codegen, op2_val); | 14734 | expand_undef_array(ira->codegen, op2_val); |
| ... | @@ -14696,9 +14737,9 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -14696,9 +14737,9 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14696 | size_t len = type_entry->data.vector.len; | 14737 | size_t len = type_entry->data.vector.len; |
| 14697 | ZigType *scalar_type = type_entry->data.vector.elem_type; | 14738 | ZigType *scalar_type = type_entry->data.vector.elem_type; |
| 14698 | for (size_t i = 0; i < len; i += 1) { | 14739 | for (size_t i = 0; i < len; i += 1) { |
| 14699 | ConstExprValue *scalar_op1_val = &op1_val->data.x_array.data.s_none.elements[i]; | 14740 | ZigValue *scalar_op1_val = &op1_val->data.x_array.data.s_none.elements[i]; |
| 14700 | ConstExprValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i]; | 14741 | ZigValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i]; |
| 14701 | ConstExprValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 14742 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 14702 | assert(scalar_op1_val->type == scalar_type); | 14743 | assert(scalar_op1_val->type == scalar_type); |
| 14703 | assert(scalar_op2_val->type == scalar_type); | 14744 | assert(scalar_op2_val->type == scalar_type); |
| 14704 | assert(scalar_out_val->type == scalar_type); | 14745 | assert(scalar_out_val->type == scalar_type); |
| ... | @@ -14722,52 +14763,52 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -14722,52 +14763,52 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14722 | | 14763 | |
| 14723 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 14764 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| 14724 | IrInstruction *op1 = bin_op_instruction->op1->child; | 14765 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 14725 | if (type_is_invalid(op1->value.type)) | 14766 | if (type_is_invalid(op1->value->type)) |
| 14726 | return ira->codegen->invalid_instruction; | 14767 | return ira->codegen->invalid_instruction; |
| 14727 | | 14768 | |
| 14728 | if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) { | 14769 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { |
| 14729 | ir_add_error(ira, bin_op_instruction->op1, | 14770 | ir_add_error(ira, bin_op_instruction->op1, |
| 14730 | buf_sprintf("bit shifting operation expected integer type, found '%s'", | 14771 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 14731 | buf_ptr(&op1->value.type->name))); | 14772 | buf_ptr(&op1->value->type->name))); |
| 14732 | return ira->codegen->invalid_instruction; | 14773 | return ira->codegen->invalid_instruction; |
| 14733 | } | 14774 | } |
| 14734 | | 14775 | |
| 14735 | IrInstruction *op2 = bin_op_instruction->op2->child; | 14776 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 14736 | if (type_is_invalid(op2->value.type)) | 14777 | if (type_is_invalid(op2->value->type)) |
| 14737 | return ira->codegen->invalid_instruction; | 14778 | return ira->codegen->invalid_instruction; |
| 14738 | | 14779 | |
| 14739 | if (op2->value.type->id != ZigTypeIdInt && op2->value.type->id != ZigTypeIdComptimeInt) { | 14780 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { |
| 14740 | ir_add_error(ira, bin_op_instruction->op2, | 14781 | ir_add_error(ira, bin_op_instruction->op2, |
| 14741 | buf_sprintf("shift amount has to be an integer type, but found '%s'", | 14782 | buf_sprintf("shift amount has to be an integer type, but found '%s'", |
| 14742 | buf_ptr(&op2->value.type->name))); | 14783 | buf_ptr(&op2->value->type->name))); |
| 14743 | return ira->codegen->invalid_instruction; | 14784 | return ira->codegen->invalid_instruction; |
| 14744 | } | 14785 | } |
| 14745 | | 14786 | |
| 14746 | IrInstruction *casted_op2; | 14787 | IrInstruction *casted_op2; |
| 14747 | IrBinOp op_id = bin_op_instruction->op_id; | 14788 | IrBinOp op_id = bin_op_instruction->op_id; |
| 14748 | if (op1->value.type->id == ZigTypeIdComptimeInt) { | 14789 | if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 14749 | casted_op2 = op2; | 14790 | casted_op2 = op2; |
| 14750 | | 14791 | |
| 14751 | if (op_id == IrBinOpBitShiftLeftLossy) { | 14792 | if (op_id == IrBinOpBitShiftLeftLossy) { |
| 14752 | op_id = IrBinOpBitShiftLeftExact; | 14793 | op_id = IrBinOpBitShiftLeftExact; |
| 14753 | } | 14794 | } |
| 14754 | | 14795 | |
| 14755 | if (casted_op2->value.data.x_bigint.is_negative) { | 14796 | if (casted_op2->value->data.x_bigint.is_negative) { |
| 14756 | Buf *val_buf = buf_alloc(); | 14797 | Buf *val_buf = buf_alloc(); |
| 14757 | bigint_append_buf(val_buf, &casted_op2->value.data.x_bigint, 10); | 14798 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); |
| 14758 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); | 14799 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 14759 | return ira->codegen->invalid_instruction; | 14800 | return ira->codegen->invalid_instruction; |
| 14760 | } | 14801 | } |
| 14761 | } else { | 14802 | } else { |
| 14762 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 14803 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 14763 | op1->value.type->data.integral.bit_count - 1); | 14804 | op1->value->type->data.integral.bit_count - 1); |
| 14764 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && | 14805 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && |
| 14765 | op2->value.type->id == ZigTypeIdComptimeInt) { | 14806 | op2->value->type->id == ZigTypeIdComptimeInt) { |
| 14766 | if (!bigint_fits_in_bits(&op2->value.data.x_bigint, | 14807 | if (!bigint_fits_in_bits(&op2->value->data.x_bigint, |
| 14767 | shift_amt_type->data.integral.bit_count, | 14808 | shift_amt_type->data.integral.bit_count, |
| 14768 | op2->value.data.x_bigint.is_negative)) { | 14809 | op2->value->data.x_bigint.is_negative)) { |
| 14769 | Buf *val_buf = buf_alloc(); | 14810 | Buf *val_buf = buf_alloc(); |
| 14770 | bigint_append_buf(val_buf, &op2->value.data.x_bigint, 10); | 14811 | bigint_append_buf(val_buf, &op2->value->data.x_bigint, 10); |
| 14771 | ErrorMsg* msg = ir_add_error(ira, | 14812 | ErrorMsg* msg = ir_add_error(ira, |
| 14772 | &bin_op_instruction->base, | 14813 | &bin_op_instruction->base, |
| 14773 | buf_sprintf("RHS of shift is too large for LHS type")); | 14814 | buf_sprintf("RHS of shift is too large for LHS type")); |
| ... | @@ -14788,30 +14829,30 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -14788,30 +14829,30 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 14788 | } | 14829 | } |
| 14789 | | 14830 | |
| 14790 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { | 14831 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { |
| 14791 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 14832 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14792 | if (op1_val == nullptr) | 14833 | if (op1_val == nullptr) |
| 14793 | return ira->codegen->invalid_instruction; | 14834 | return ira->codegen->invalid_instruction; |
| 14794 | | 14835 | |
| 14795 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 14836 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 14796 | if (op2_val == nullptr) | 14837 | if (op2_val == nullptr) |
| 14797 | return ira->codegen->invalid_instruction; | 14838 | return ira->codegen->invalid_instruction; |
| 14798 | | 14839 | |
| 14799 | return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value.type, op1_val, op_id, op2_val); | 14840 | 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) { | 14841 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 14801 | ir_add_error(ira, &bin_op_instruction->base, | 14842 | ir_add_error(ira, &bin_op_instruction->base, |
| 14802 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); | 14843 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 14803 | return ira->codegen->invalid_instruction; | 14844 | return ira->codegen->invalid_instruction; |
| 14804 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value.data.x_bigint) == CmpEQ) { | 14845 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { |
| 14805 | IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, | 14846 | 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); | 14847 | bin_op_instruction->base.source_node, op1->value->type, op1, CastOpNoop); |
| 14807 | result->value.type = op1->value.type; | 14848 | result->value->type = op1->value->type; |
| 14808 | return result; | 14849 | return result; |
| 14809 | } | 14850 | } |
| 14810 | | 14851 | |
| 14811 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, | 14852 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, |
| 14812 | bin_op_instruction->base.source_node, op_id, | 14853 | bin_op_instruction->base.source_node, op_id, |
| 14813 | op1, casted_op2, bin_op_instruction->safety_check_on); | 14854 | op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14814 | result->value.type = op1->value.type; | 14855 | result->value->type = op1->value->type; |
| 14815 | return result; | 14856 | return result; |
| 14816 | } | 14857 | } |
| 14817 | | 14858 | |
| ... | @@ -14880,42 +14921,42 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14880,42 +14921,42 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14880 | Error err; | 14921 | Error err; |
| 14881 | | 14922 | |
| 14882 | IrInstruction *op1 = instruction->op1->child; | 14923 | IrInstruction *op1 = instruction->op1->child; |
| 14883 | if (type_is_invalid(op1->value.type)) | 14924 | if (type_is_invalid(op1->value->type)) |
| 14884 | return ira->codegen->invalid_instruction; | 14925 | return ira->codegen->invalid_instruction; |
| 14885 | | 14926 | |
| 14886 | IrInstruction *op2 = instruction->op2->child; | 14927 | IrInstruction *op2 = instruction->op2->child; |
| 14887 | if (type_is_invalid(op2->value.type)) | 14928 | if (type_is_invalid(op2->value->type)) |
| 14888 | return ira->codegen->invalid_instruction; | 14929 | return ira->codegen->invalid_instruction; |
| 14889 | | 14930 | |
| 14890 | IrBinOp op_id = instruction->op_id; | 14931 | IrBinOp op_id = instruction->op_id; |
| 14891 | | 14932 | |
| 14892 | // look for pointer math | 14933 | // look for pointer math |
| 14893 | if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) { | 14934 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { |
| 14894 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | 14935 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| 14895 | if (type_is_invalid(casted_op2->value.type)) | 14936 | if (type_is_invalid(casted_op2->value->type)) |
| 14896 | return ira->codegen->invalid_instruction; | 14937 | return ira->codegen->invalid_instruction; |
| 14897 | | 14938 | |
| 14898 | // If either operand is undef, result is undef. | 14939 | // If either operand is undef, result is undef. |
| 14899 | ConstExprValue *op1_val = nullptr; | 14940 | ZigValue *op1_val = nullptr; |
| 14900 | ConstExprValue *op2_val = nullptr; | 14941 | ZigValue *op2_val = nullptr; |
| 14901 | if (instr_is_comptime(op1)) { | 14942 | if (instr_is_comptime(op1)) { |
| 14902 | op1_val = ir_resolve_const(ira, op1, UndefOk); | 14943 | op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 14903 | if (op1_val == nullptr) | 14944 | if (op1_val == nullptr) |
| 14904 | return ira->codegen->invalid_instruction; | 14945 | return ira->codegen->invalid_instruction; |
| 14905 | if (op1_val->special == ConstValSpecialUndef) | 14946 | if (op1_val->special == ConstValSpecialUndef) |
| 14906 | return ir_const_undef(ira, &instruction->base, op1->value.type); | 14947 | return ir_const_undef(ira, &instruction->base, op1->value->type); |
| 14907 | } | 14948 | } |
| 14908 | if (instr_is_comptime(casted_op2)) { | 14949 | if (instr_is_comptime(casted_op2)) { |
| 14909 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); | 14950 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); |
| 14910 | if (op2_val == nullptr) | 14951 | if (op2_val == nullptr) |
| 14911 | return ira->codegen->invalid_instruction; | 14952 | return ira->codegen->invalid_instruction; |
| 14912 | if (op2_val->special == ConstValSpecialUndef) | 14953 | if (op2_val->special == ConstValSpecialUndef) |
| 14913 | return ir_const_undef(ira, &instruction->base, op1->value.type); | 14954 | return ir_const_undef(ira, &instruction->base, op1->value->type); |
| 14914 | } | 14955 | } |
| 14915 | | 14956 | |
| 14916 | if (op2_val != nullptr && op1_val != nullptr && | 14957 | if (op2_val != nullptr && op1_val != nullptr && |
| 14917 | (op1->value.data.x_ptr.special == ConstPtrSpecialHardCodedAddr || | 14958 | (op1->value->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || |
| 14918 | op1->value.data.x_ptr.special == ConstPtrSpecialNull)) | 14959 | op1->value->data.x_ptr.special == ConstPtrSpecialNull)) |
| 14919 | { | 14960 | { |
| 14920 | uint64_t start_addr = (op1_val->data.x_ptr.special == ConstPtrSpecialNull) ? | 14961 | uint64_t start_addr = (op1_val->data.x_ptr.special == ConstPtrSpecialNull) ? |
| 14921 | 0 : op1_val->data.x_ptr.data.hard_coded_addr.addr; | 14962 | 0 : op1_val->data.x_ptr.data.hard_coded_addr.addr; |
| ... | @@ -14935,15 +14976,15 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14935,15 +14976,15 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14935 | zig_unreachable(); | 14976 | zig_unreachable(); |
| 14936 | } | 14977 | } |
| 14937 | IrInstruction *result = ir_const(ira, &instruction->base, op1_val->type); | 14978 | IrInstruction *result = ir_const(ira, &instruction->base, op1_val->type); |
| 14938 | result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 14979 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 14939 | result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar; | 14980 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 14940 | result->value.data.x_ptr.data.hard_coded_addr.addr = new_addr; | 14981 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; |
| 14941 | return result; | 14982 | return result; |
| 14942 | } | 14983 | } |
| 14943 | | 14984 | |
| 14944 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 14985 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, |
| 14945 | instruction->base.source_node, op_id, op1, casted_op2, true); | 14986 | instruction->base.source_node, op_id, op1, casted_op2, true); |
| 14946 | result->value.type = op1->value.type; | 14987 | result->value->type = op1->value->type; |
| 14947 | return result; | 14988 | return result; |
| 14948 | } | 14989 | } |
| 14949 | | 14990 | |
| ... | @@ -14958,21 +14999,21 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14958,21 +14999,21 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14958 | (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || | 14999 | (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || |
| 14959 | resolved_type->id == ZigTypeIdFloat || | 15000 | resolved_type->id == ZigTypeIdFloat || |
| 14960 | (resolved_type->id == ZigTypeIdComptimeFloat && | 15001 | (resolved_type->id == ZigTypeIdComptimeFloat && |
| 14961 | ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) != | 15002 | ((bigfloat_cmp_zero(&op1->value->data.x_bigfloat) != CmpGT) != |
| 14962 | (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) || | 15003 | (bigfloat_cmp_zero(&op2->value->data.x_bigfloat) != CmpGT))) || |
| 14963 | (resolved_type->id == ZigTypeIdComptimeInt && | 15004 | (resolved_type->id == ZigTypeIdComptimeInt && |
| 14964 | ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) != | 15005 | ((bigint_cmp_zero(&op1->value->data.x_bigint) != CmpGT) != |
| 14965 | (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT))) | 15006 | (bigint_cmp_zero(&op2->value->data.x_bigint) != CmpGT))) |
| 14966 | ); | 15007 | ); |
| 14967 | if (op_id == IrBinOpDivUnspecified && is_int) { | 15008 | if (op_id == IrBinOpDivUnspecified && is_int) { |
| 14968 | if (is_signed_div) { | 15009 | if (is_signed_div) { |
| 14969 | bool ok = false; | 15010 | bool ok = false; |
| 14970 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 15011 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 14971 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 15012 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14972 | if (op1_val == nullptr) | 15013 | if (op1_val == nullptr) |
| 14973 | return ira->codegen->invalid_instruction; | 15014 | return ira->codegen->invalid_instruction; |
| 14974 | | 15015 | |
| 14975 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 15016 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 14976 | if (op2_val == nullptr) | 15017 | if (op2_val == nullptr) |
| 14977 | return ira->codegen->invalid_instruction; | 15018 | return ira->codegen->invalid_instruction; |
| 14978 | | 15019 | |
| ... | @@ -14995,8 +15036,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14995,8 +15036,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14995 | if (!ok) { | 15036 | if (!ok) { |
| 14996 | ir_add_error(ira, &instruction->base, | 15037 | ir_add_error(ira, &instruction->base, |
| 14997 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", | 15038 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", |
| 14998 | buf_ptr(&op1->value.type->name), | 15039 | buf_ptr(&op1->value->type->name), |
| 14999 | buf_ptr(&op2->value.type->name))); | 15040 | buf_ptr(&op2->value->type->name))); |
| 15000 | return ira->codegen->invalid_instruction; | 15041 | return ira->codegen->invalid_instruction; |
| 15001 | } | 15042 | } |
| 15002 | } else { | 15043 | } else { |
| ... | @@ -15006,16 +15047,16 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15006,16 +15047,16 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15006 | if (is_signed_div && (is_int || is_float)) { | 15047 | if (is_signed_div && (is_int || is_float)) { |
| 15007 | bool ok = false; | 15048 | bool ok = false; |
| 15008 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 15049 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15009 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 15050 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15010 | if (op1_val == nullptr) | 15051 | if (op1_val == nullptr) |
| 15011 | return ira->codegen->invalid_instruction; | 15052 | return ira->codegen->invalid_instruction; |
| 15012 | | 15053 | |
| 15013 | if (is_int) { | 15054 | if (is_int) { |
| 15014 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 15055 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15015 | if (op2_val == nullptr) | 15056 | if (op2_val == nullptr) |
| 15016 | return ira->codegen->invalid_instruction; | 15057 | return ira->codegen->invalid_instruction; |
| 15017 | | 15058 | |
| 15018 | if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) { | 15059 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { |
| 15019 | // the division by zero error will be caught later, but we don't | 15060 | // the division by zero error will be caught later, but we don't |
| 15020 | // have a remainder function ambiguity problem | 15061 | // have a remainder function ambiguity problem |
| 15021 | ok = true; | 15062 | ok = true; |
| ... | @@ -15031,17 +15072,17 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15031,17 +15072,17 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15031 | if (casted_op2 == ira->codegen->invalid_instruction) | 15072 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 15032 | return ira->codegen->invalid_instruction; | 15073 | return ira->codegen->invalid_instruction; |
| 15033 | | 15074 | |
| 15034 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15075 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15035 | if (op2_val == nullptr) | 15076 | if (op2_val == nullptr) |
| 15036 | return ira->codegen->invalid_instruction; | 15077 | return ira->codegen->invalid_instruction; |
| 15037 | | 15078 | |
| 15038 | if (float_cmp_zero(&casted_op2->value) == CmpEQ) { | 15079 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { |
| 15039 | // the division by zero error will be caught later, but we don't | 15080 | // the division by zero error will be caught later, but we don't |
| 15040 | // have a remainder function ambiguity problem | 15081 | // have a remainder function ambiguity problem |
| 15041 | ok = true; | 15082 | ok = true; |
| 15042 | } else { | 15083 | } else { |
| 15043 | ConstExprValue rem_result = {}; | 15084 | ZigValue rem_result = {}; |
| 15044 | ConstExprValue mod_result = {}; | 15085 | ZigValue mod_result = {}; |
| 15045 | float_rem(&rem_result, op1_val, op2_val); | 15086 | float_rem(&rem_result, op1_val, op2_val); |
| 15046 | float_mod(&mod_result, op1_val, op2_val); | 15087 | float_mod(&mod_result, op1_val, op2_val); |
| 15047 | ok = float_cmp(&rem_result, &mod_result) == CmpEQ; | 15088 | ok = float_cmp(&rem_result, &mod_result) == CmpEQ; |
| ... | @@ -15051,8 +15092,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15051,8 +15092,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15051 | if (!ok) { | 15092 | if (!ok) { |
| 15052 | ir_add_error(ira, &instruction->base, | 15093 | ir_add_error(ira, &instruction->base, |
| 15053 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", | 15094 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", |
| 15054 | buf_ptr(&op1->value.type->name), | 15095 | buf_ptr(&op1->value->type->name), |
| 15055 | buf_ptr(&op2->value.type->name))); | 15096 | buf_ptr(&op2->value->type->name))); |
| 15056 | return ira->codegen->invalid_instruction; | 15097 | return ira->codegen->invalid_instruction; |
| 15057 | } | 15098 | } |
| 15058 | } | 15099 | } |
| ... | @@ -15076,8 +15117,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15076,8 +15117,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15076 | AstNode *source_node = instruction->base.source_node; | 15117 | AstNode *source_node = instruction->base.source_node; |
| 15077 | ir_add_error_node(ira, source_node, | 15118 | ir_add_error_node(ira, source_node, |
| 15078 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", | 15119 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", |
| 15079 | buf_ptr(&op1->value.type->name), | 15120 | buf_ptr(&op1->value->type->name), |
| 15080 | buf_ptr(&op2->value.type->name))); | 15121 | buf_ptr(&op2->value->type->name))); |
| 15081 | return ira->codegen->invalid_instruction; | 15122 | return ira->codegen->invalid_instruction; |
| 15082 | } | 15123 | } |
| 15083 | | 15124 | |
| ... | @@ -15100,10 +15141,10 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15100,10 +15141,10 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15100 | return ira->codegen->invalid_instruction; | 15141 | return ira->codegen->invalid_instruction; |
| 15101 | | 15142 | |
| 15102 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 15143 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 15103 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 15144 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 15104 | if (op1_val == nullptr) | 15145 | if (op1_val == nullptr) |
| 15105 | return ira->codegen->invalid_instruction; | 15146 | return ira->codegen->invalid_instruction; |
| 15106 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15147 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15107 | if (op2_val == nullptr) | 15148 | if (op2_val == nullptr) |
| 15108 | return ira->codegen->invalid_instruction; | 15149 | return ira->codegen->invalid_instruction; |
| 15109 | | 15150 | |
| ... | @@ -15112,31 +15153,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15112,31 +15153,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15112 | | 15153 | |
| 15113 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 15154 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, |
| 15114 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); | 15155 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); |
| 15115 | result->value.type = resolved_type; | 15156 | result->value->type = resolved_type; |
| 15116 | return result; | 15157 | return result; |
| 15117 | } | 15158 | } |
| 15118 | | 15159 | |
| 15119 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 15160 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 15120 | IrInstruction *op1 = instruction->op1->child; | 15161 | IrInstruction *op1 = instruction->op1->child; |
| 15121 | ZigType *op1_type = op1->value.type; | 15162 | ZigType *op1_type = op1->value->type; |
| 15122 | if (type_is_invalid(op1_type)) | 15163 | if (type_is_invalid(op1_type)) |
| 15123 | return ira->codegen->invalid_instruction; | 15164 | return ira->codegen->invalid_instruction; |
| 15124 | | 15165 | |
| 15125 | IrInstruction *op2 = instruction->op2->child; | 15166 | IrInstruction *op2 = instruction->op2->child; |
| 15126 | ZigType *op2_type = op2->value.type; | 15167 | ZigType *op2_type = op2->value->type; |
| 15127 | if (type_is_invalid(op2_type)) | 15168 | if (type_is_invalid(op2_type)) |
| 15128 | return ira->codegen->invalid_instruction; | 15169 | return ira->codegen->invalid_instruction; |
| 15129 | | 15170 | |
| 15130 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 15171 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15131 | if (!op1_val) | 15172 | if (!op1_val) |
| 15132 | return ira->codegen->invalid_instruction; | 15173 | return ira->codegen->invalid_instruction; |
| 15133 | | 15174 | |
| 15134 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 15175 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15135 | if (!op2_val) | 15176 | if (!op2_val) |
| 15136 | return ira->codegen->invalid_instruction; | 15177 | return ira->codegen->invalid_instruction; |
| 15137 | | 15178 | |
| 15138 | ConstExprValue *sentinel1 = nullptr; | 15179 | ZigValue *sentinel1 = nullptr; |
| 15139 | ConstExprValue *op1_array_val; | 15180 | ZigValue *op1_array_val; |
| 15140 | size_t op1_array_index; | 15181 | size_t op1_array_index; |
| 15141 | size_t op1_array_end; | 15182 | size_t op1_array_end; |
| 15142 | ZigType *child_type; | 15183 | ZigType *child_type; |
| ... | @@ -15159,11 +15200,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15159,11 +15200,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15159 | } else if (is_slice(op1_type)) { | 15200 | } else if (is_slice(op1_type)) { |
| 15160 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index]->type_entry; | 15201 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 15161 | child_type = ptr_type->data.pointer.child_type; | 15202 | child_type = ptr_type->data.pointer.child_type; |
| 15162 | ConstExprValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index]; | 15203 | ZigValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index]; |
| 15163 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 15204 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 15164 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 15205 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 15165 | op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; | 15206 | op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 15166 | ConstExprValue *len_val = op1_val->data.x_struct.fields[slice_len_index]; | 15207 | ZigValue *len_val = op1_val->data.x_struct.fields[slice_len_index]; |
| 15167 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); | 15208 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 15168 | sentinel1 = ptr_type->data.pointer.sentinel; | 15209 | sentinel1 = ptr_type->data.pointer.sentinel; |
| 15169 | } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle && | 15210 | } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle && |
| ... | @@ -15178,13 +15219,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15178,13 +15219,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15178 | op1_array_end = array_type->data.array.len; | 15219 | op1_array_end = array_type->data.array.len; |
| 15179 | sentinel1 = array_type->data.array.sentinel; | 15220 | sentinel1 = array_type->data.array.sentinel; |
| 15180 | } else { | 15221 | } else { |
| 15181 | ir_add_error(ira, op1, | 15222 | ir_add_error(ira, op1, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); |
| 15182 | buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value.type->name))); | | |
| 15183 | return ira->codegen->invalid_instruction; | 15223 | return ira->codegen->invalid_instruction; |
| 15184 | } | 15224 | } |
| 15185 | | 15225 | |
| 15186 | ConstExprValue *sentinel2 = nullptr; | 15226 | ZigValue *sentinel2 = nullptr; |
| 15187 | ConstExprValue *op2_array_val; | 15227 | ZigValue *op2_array_val; |
| 15188 | size_t op2_array_index; | 15228 | size_t op2_array_index; |
| 15189 | size_t op2_array_end; | 15229 | size_t op2_array_end; |
| 15190 | bool op2_type_valid; | 15230 | bool op2_type_valid; |
| ... | @@ -15207,11 +15247,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15207,11 +15247,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15207 | } else if (is_slice(op2_type)) { | 15247 | } else if (is_slice(op2_type)) { |
| 15208 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index]->type_entry; | 15248 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 15209 | op2_type_valid = ptr_type->data.pointer.child_type == child_type; | 15249 | op2_type_valid = ptr_type->data.pointer.child_type == child_type; |
| 15210 | ConstExprValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index]; | 15250 | ZigValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index]; |
| 15211 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 15251 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 15212 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 15252 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 15213 | op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; | 15253 | op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 15214 | ConstExprValue *len_val = op2_val->data.x_struct.fields[slice_len_index]; | 15254 | ZigValue *len_val = op2_val->data.x_struct.fields[slice_len_index]; |
| 15215 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); | 15255 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 15216 | | 15256 | |
| 15217 | sentinel2 = ptr_type->data.pointer.sentinel; | 15257 | sentinel2 = ptr_type->data.pointer.sentinel; |
| ... | @@ -15229,17 +15269,17 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15229,17 +15269,17 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15229 | sentinel2 = array_type->data.array.sentinel; | 15269 | sentinel2 = array_type->data.array.sentinel; |
| 15230 | } else { | 15270 | } else { |
| 15231 | ir_add_error(ira, op2, | 15271 | ir_add_error(ira, op2, |
| 15232 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name))); | 15272 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); |
| 15233 | return ira->codegen->invalid_instruction; | 15273 | return ira->codegen->invalid_instruction; |
| 15234 | } | 15274 | } |
| 15235 | if (!op2_type_valid) { | 15275 | if (!op2_type_valid) { |
| 15236 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 15276 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 15237 | buf_ptr(&child_type->name), | 15277 | buf_ptr(&child_type->name), |
| 15238 | buf_ptr(&op2->value.type->name))); | 15278 | buf_ptr(&op2->value->type->name))); |
| 15239 | return ira->codegen->invalid_instruction; | 15279 | return ira->codegen->invalid_instruction; |
| 15240 | } | 15280 | } |
| 15241 | | 15281 | |
| 15242 | ConstExprValue *sentinel; | 15282 | ZigValue *sentinel; |
| 15243 | if (sentinel1 != nullptr && sentinel2 != nullptr) { | 15283 | if (sentinel1 != nullptr && sentinel2 != nullptr) { |
| 15244 | // When there is a sentinel mismatch, no sentinel on the result. The type system | 15284 | // When there is a sentinel mismatch, no sentinel on the result. The type system |
| 15245 | // will catch this if it is a problem. | 15285 | // will catch this if it is a problem. |
| ... | @@ -15254,13 +15294,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15254,13 +15294,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15254 | | 15294 | |
| 15255 | // The type of result is populated in the following if blocks | 15295 | // The type of result is populated in the following if blocks |
| 15256 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 15296 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 15257 | ConstExprValue *out_val = &result->value; | 15297 | ZigValue *out_val = result->value; |
| 15258 | | 15298 | |
| 15259 | ConstExprValue *out_array_val; | 15299 | ZigValue *out_array_val; |
| 15260 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); | 15300 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); |
| 15261 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { | 15301 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { |
| 15262 | result->value.type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15302 | result->value->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| 15263 | | | |
| 15264 | out_array_val = out_val; | 15303 | out_array_val = out_val; |
| 15265 | } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { | 15304 | } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { |
| 15266 | out_array_val = create_const_vals(1); | 15305 | out_array_val = create_const_vals(1); |
| ... | @@ -15274,7 +15313,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15274,7 +15313,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15274 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, child_type, | 15313 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, child_type, |
| 15275 | true, false, PtrLenUnknown, 0, 0, 0, false, | 15314 | true, false, PtrLenUnknown, 0, 0, 0, false, |
| 15276 | VECTOR_INDEX_NONE, nullptr, sentinel); | 15315 | VECTOR_INDEX_NONE, nullptr, sentinel); |
| 15277 | result->value.type = get_slice_type(ira->codegen, ptr_type); | 15316 | result->value->type = get_slice_type(ira->codegen, ptr_type); |
| 15278 | out_array_val = create_const_vals(1); | 15317 | out_array_val = create_const_vals(1); |
| 15279 | out_array_val->special = ConstValSpecialStatic; | 15318 | out_array_val->special = ConstValSpecialStatic; |
| 15280 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15319 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | @@ -15291,9 +15330,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15291,9 +15330,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15291 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; | 15330 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; |
| 15292 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); | 15331 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); |
| 15293 | } else { | 15332 | } else { |
| 15294 | result->value.type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, | 15333 | result->value->type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, |
| 15295 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); | 15334 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); |
| 15296 | | | |
| 15297 | out_array_val = create_const_vals(1); | 15335 | out_array_val = create_const_vals(1); |
| 15298 | out_array_val->special = ConstValSpecialStatic; | 15336 | out_array_val->special = ConstValSpecialStatic; |
| 15299 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15337 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | @@ -15317,21 +15355,21 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15317,21 +15355,21 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15317 | | 15355 | |
| 15318 | size_t next_index = 0; | 15356 | size_t next_index = 0; |
| 15319 | for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) { | 15357 | for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) { |
| 15320 | ConstExprValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; | 15358 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 15321 | copy_const_val(elem_dest_val, &op1_array_val->data.x_array.data.s_none.elements[i], false); | 15359 | copy_const_val(elem_dest_val, &op1_array_val->data.x_array.data.s_none.elements[i], false); |
| 15322 | elem_dest_val->parent.id = ConstParentIdArray; | 15360 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15323 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15361 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 15324 | elem_dest_val->parent.data.p_array.elem_index = next_index; | 15362 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 15325 | } | 15363 | } |
| 15326 | for (size_t i = op2_array_index; i < op2_array_end; i += 1, next_index += 1) { | 15364 | for (size_t i = op2_array_index; i < op2_array_end; i += 1, next_index += 1) { |
| 15327 | ConstExprValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; | 15365 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 15328 | copy_const_val(elem_dest_val, &op2_array_val->data.x_array.data.s_none.elements[i], false); | 15366 | copy_const_val(elem_dest_val, &op2_array_val->data.x_array.data.s_none.elements[i], false); |
| 15329 | elem_dest_val->parent.id = ConstParentIdArray; | 15367 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15330 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15368 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 15331 | elem_dest_val->parent.data.p_array.elem_index = next_index; | 15369 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 15332 | } | 15370 | } |
| 15333 | if (next_index < full_len) { | 15371 | if (next_index < full_len) { |
| 15334 | ConstExprValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; | 15372 | ZigValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; |
| 15335 | copy_const_val(elem_dest_val, sentinel, false); | 15373 | copy_const_val(elem_dest_val, sentinel, false); |
| 15336 | elem_dest_val->parent.id = ConstParentIdArray; | 15374 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15337 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15375 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| ... | @@ -15345,34 +15383,34 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15345,34 +15383,34 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15345 | | 15383 | |
| 15346 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 15384 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 15347 | IrInstruction *op1 = instruction->op1->child; | 15385 | IrInstruction *op1 = instruction->op1->child; |
| 15348 | if (type_is_invalid(op1->value.type)) | 15386 | if (type_is_invalid(op1->value->type)) |
| 15349 | return ira->codegen->invalid_instruction; | 15387 | return ira->codegen->invalid_instruction; |
| 15350 | | 15388 | |
| 15351 | IrInstruction *op2 = instruction->op2->child; | 15389 | IrInstruction *op2 = instruction->op2->child; |
| 15352 | if (type_is_invalid(op2->value.type)) | 15390 | if (type_is_invalid(op2->value->type)) |
| 15353 | return ira->codegen->invalid_instruction; | 15391 | return ira->codegen->invalid_instruction; |
| 15354 | | 15392 | |
| 15355 | bool want_ptr_to_array = false; | 15393 | bool want_ptr_to_array = false; |
| 15356 | ZigType *array_type; | 15394 | ZigType *array_type; |
| 15357 | ConstExprValue *array_val; | 15395 | ZigValue *array_val; |
| 15358 | if (op1->value.type->id == ZigTypeIdArray) { | 15396 | if (op1->value->type->id == ZigTypeIdArray) { |
| 15359 | array_type = op1->value.type; | 15397 | array_type = op1->value->type; |
| 15360 | array_val = ir_resolve_const(ira, op1, UndefOk); | 15398 | array_val = ir_resolve_const(ira, op1, UndefOk); |
| 15361 | if (array_val == nullptr) | 15399 | if (array_val == nullptr) |
| 15362 | return ira->codegen->invalid_instruction; | 15400 | return ira->codegen->invalid_instruction; |
| 15363 | } else if (op1->value.type->id == ZigTypeIdPointer && op1->value.type->data.pointer.ptr_len == PtrLenSingle && | 15401 | } 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) | 15402 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) |
| 15365 | { | 15403 | { |
| 15366 | array_type = op1->value.type->data.pointer.child_type; | 15404 | array_type = op1->value->type->data.pointer.child_type; |
| 15367 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); | 15405 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); |
| 15368 | if (type_is_invalid(array_inst->value.type)) | 15406 | if (type_is_invalid(array_inst->value->type)) |
| 15369 | return ira->codegen->invalid_instruction; | 15407 | return ira->codegen->invalid_instruction; |
| 15370 | array_val = ir_resolve_const(ira, array_inst, UndefOk); | 15408 | array_val = ir_resolve_const(ira, array_inst, UndefOk); |
| 15371 | if (array_val == nullptr) | 15409 | if (array_val == nullptr) |
| 15372 | return ira->codegen->invalid_instruction; | 15410 | return ira->codegen->invalid_instruction; |
| 15373 | want_ptr_to_array = true; | 15411 | want_ptr_to_array = true; |
| 15374 | } else { | 15412 | } else { |
| 15375 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name))); | 15413 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); |
| 15376 | return ira->codegen->invalid_instruction; | 15414 | return ira->codegen->invalid_instruction; |
| 15377 | } | 15415 | } |
| 15378 | | 15416 | |
| ... | @@ -15397,7 +15435,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15397,7 +15435,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15397 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); | 15435 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); |
| 15398 | } else { | 15436 | } else { |
| 15399 | array_result = ir_const(ira, &instruction->base, result_array_type); | 15437 | array_result = ir_const(ira, &instruction->base, result_array_type); |
| 15400 | ConstExprValue *out_val = &array_result->value; | 15438 | ZigValue *out_val = array_result->value; |
| 15401 | | 15439 | |
| 15402 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { | 15440 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { |
| 15403 | case OnePossibleValueInvalid: | 15441 | case OnePossibleValueInvalid: |
| ... | @@ -15416,7 +15454,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15416,7 +15454,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15416 | uint64_t i = 0; | 15454 | uint64_t i = 0; |
| 15417 | for (uint64_t x = 0; x < mult_amt; x += 1) { | 15455 | for (uint64_t x = 0; x < mult_amt; x += 1) { |
| 15418 | for (uint64_t y = 0; y < old_array_len; y += 1) { | 15456 | for (uint64_t y = 0; y < old_array_len; y += 1) { |
| 15419 | ConstExprValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; | 15457 | ZigValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 15420 | copy_const_val(elem_dest_val, &array_val->data.x_array.data.s_none.elements[y], false); | 15458 | copy_const_val(elem_dest_val, &array_val->data.x_array.data.s_none.elements[y], false); |
| 15421 | elem_dest_val->parent.id = ConstParentIdArray; | 15459 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15422 | elem_dest_val->parent.data.p_array.array_val = out_val; | 15460 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| ... | @@ -15427,7 +15465,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15427,7 +15465,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15427 | assert(i == new_array_len); | 15465 | assert(i == new_array_len); |
| 15428 | | 15466 | |
| 15429 | if (array_type->data.array.sentinel != nullptr) { | 15467 | if (array_type->data.array.sentinel != nullptr) { |
| 15430 | ConstExprValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; | 15468 | ZigValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 15431 | copy_const_val(elem_dest_val, array_type->data.array.sentinel, false); | 15469 | copy_const_val(elem_dest_val, array_type->data.array.sentinel, false); |
| 15432 | elem_dest_val->parent.id = ConstParentIdArray; | 15470 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15433 | elem_dest_val->parent.data.p_array.array_val = out_val; | 15471 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| ... | @@ -15554,25 +15592,25 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15554,25 +15592,25 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15554 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; | 15592 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; |
| 15555 | // if this is null, a compiler error happened and did not initialize the variable. | 15593 | // if this is null, a compiler error happened and did not initialize the variable. |
| 15556 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. | 15594 | // 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)) { | 15595 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { |
| 15558 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); | 15596 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); |
| 15559 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 15597 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 15560 | return ira->codegen->invalid_instruction; | 15598 | return ira->codegen->invalid_instruction; |
| 15561 | } | 15599 | } |
| 15562 | | 15600 | |
| 15563 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. | 15601 | // 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); | 15602 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base); |
| 15565 | | 15603 | |
| 15566 | ZigType *result_type = var_ptr->value.type->data.pointer.child_type; | 15604 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; |
| 15567 | if (type_is_invalid(result_type)) { | 15605 | if (type_is_invalid(result_type)) { |
| 15568 | result_type = ira->codegen->builtin_types.entry_invalid; | 15606 | result_type = ira->codegen->builtin_types.entry_invalid; |
| 15569 | } else if (result_type->id == ZigTypeIdUnreachable || result_type->id == ZigTypeIdOpaque) { | 15607 | } else if (result_type->id == ZigTypeIdUnreachable || result_type->id == ZigTypeIdOpaque) { |
| 15570 | zig_unreachable(); | 15608 | zig_unreachable(); |
| 15571 | } | 15609 | } |
| 15572 | | 15610 | |
| 15573 | ConstExprValue *init_val = nullptr; | 15611 | ZigValue *init_val = nullptr; |
| 15574 | if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15612 | 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); | 15613 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.source_node); |
| 15576 | if (is_comptime_var) { | 15614 | if (is_comptime_var) { |
| 15577 | if (var->gen_is_const) { | 15615 | if (var->gen_is_const) { |
| 15578 | var->const_value = init_val; | 15616 | var->const_value = init_val; |
| ... | @@ -15631,7 +15669,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15631,7 +15669,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15631 | new_var->owner_exec = var->owner_exec; | 15669 | new_var->owner_exec = var->owner_exec; |
| 15632 | new_var->align_bytes = var->align_bytes; | 15670 | new_var->align_bytes = var->align_bytes; |
| 15633 | if (var->mem_slot_index != SIZE_MAX) { | 15671 | if (var->mem_slot_index != SIZE_MAX) { |
| 15634 | ConstExprValue *vals = create_const_vals(1); | 15672 | ZigValue *vals = create_const_vals(1); |
| 15635 | new_var->mem_slot_index = ira->exec_context.mem_slot_list.length; | 15673 | new_var->mem_slot_index = ira->exec_context.mem_slot_list.length; |
| 15636 | ira->exec_context.mem_slot_list.append(vals); | 15674 | ira->exec_context.mem_slot_list.append(vals); |
| 15637 | } | 15675 | } |
| ... | @@ -15665,29 +15703,29 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15665,29 +15703,29 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15665 | if (init_val != nullptr && value_is_comptime(init_val)) { | 15703 | if (init_val != nullptr && value_is_comptime(init_val)) { |
| 15666 | // Resolve ConstPtrMutInfer | 15704 | // Resolve ConstPtrMutInfer |
| 15667 | if (var->gen_is_const) { | 15705 | if (var->gen_is_const) { |
| 15668 | var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 15706 | var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 15669 | } else if (is_comptime_var) { | 15707 | } else if (is_comptime_var) { |
| 15670 | var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar; | 15708 | var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15671 | } else { | 15709 | } else { |
| 15672 | // we need a runtime ptr but we have a comptime val. | 15710 | // we need a runtime ptr but we have a comptime val. |
| 15673 | // since it's a comptime val there are no instructions for it. | 15711 | // since it's a comptime val there are no instructions for it. |
| 15674 | // we memcpy the init value here | 15712 | // we memcpy the init value here |
| 15675 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); | 15713 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); |
| 15676 | if (type_is_invalid(deref->value.type)) { | 15714 | if (type_is_invalid(deref->value->type)) { |
| 15677 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 15715 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 15678 | return ira->codegen->invalid_instruction; | 15716 | return ira->codegen->invalid_instruction; |
| 15679 | } | 15717 | } |
| 15680 | // If this assertion trips, something is wrong with the IR instructions, because | 15718 | // If this assertion trips, something is wrong with the IR instructions, because |
| 15681 | // we expected the above deref to return a constant value, but it created a runtime | 15719 | // we expected the above deref to return a constant value, but it created a runtime |
| 15682 | // instruction. | 15720 | // instruction. |
| 15683 | assert(deref->value.special != ConstValSpecialRuntime); | 15721 | assert(deref->value->special != ConstValSpecialRuntime); |
| 15684 | var_ptr->value.special = ConstValSpecialRuntime; | 15722 | var_ptr->value->special = ConstValSpecialRuntime; |
| 15685 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); | 15723 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); |
| 15686 | } | 15724 | } |
| 15687 | | 15725 | |
| 15688 | if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) { | 15726 | if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) { |
| 15689 | assert(var->mem_slot_index < ira->exec_context.mem_slot_list.length); | 15727 | assert(var->mem_slot_index < ira->exec_context.mem_slot_list.length); |
| 15690 | ConstExprValue *mem_slot = ira->exec_context.mem_slot_list.at(var->mem_slot_index); | 15728 | ZigValue *mem_slot = ira->exec_context.mem_slot_list.at(var->mem_slot_index); |
| 15691 | copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const); | 15729 | copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const); |
| 15692 | | 15730 | |
| 15693 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { | 15731 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { |
| ... | @@ -15718,7 +15756,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15718,7 +15756,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15718 | } | 15756 | } |
| 15719 | | 15757 | |
| 15720 | IrInstruction *target = instruction->target->child; | 15758 | IrInstruction *target = instruction->target->child; |
| 15721 | if (type_is_invalid(target->value.type)) { | 15759 | if (type_is_invalid(target->value->type)) { |
| 15722 | return ira->codegen->invalid_instruction; | 15760 | return ira->codegen->invalid_instruction; |
| 15723 | } | 15761 | } |
| 15724 | | 15762 | |
| ... | @@ -15748,13 +15786,13 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15748,13 +15786,13 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15748 | } | 15786 | } |
| 15749 | | 15787 | |
| 15750 | bool want_var_export = false; | 15788 | bool want_var_export = false; |
| 15751 | switch (target->value.type->id) { | 15789 | switch (target->value->type->id) { |
| 15752 | case ZigTypeIdInvalid: | 15790 | case ZigTypeIdInvalid: |
| 15753 | case ZigTypeIdUnreachable: | 15791 | case ZigTypeIdUnreachable: |
| 15754 | zig_unreachable(); | 15792 | zig_unreachable(); |
| 15755 | case ZigTypeIdFn: { | 15793 | case ZigTypeIdFn: { |
| 15756 | assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); | 15794 | assert(target->value->data.x_ptr.special == ConstPtrSpecialFunction); |
| 15757 | ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; | 15795 | ZigFn *fn_entry = target->value->data.x_ptr.data.fn.fn_entry; |
| 15758 | tld_fn->fn_entry = fn_entry; | 15796 | tld_fn->fn_entry = fn_entry; |
| 15759 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 15797 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| 15760 | switch (cc) { | 15798 | switch (cc) { |
| ... | @@ -15778,51 +15816,51 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15778,51 +15816,51 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15778 | } | 15816 | } |
| 15779 | } break; | 15817 | } break; |
| 15780 | case ZigTypeIdStruct: | 15818 | case ZigTypeIdStruct: |
| 15781 | if (is_slice(target->value.type)) { | 15819 | if (is_slice(target->value->type)) { |
| 15782 | ir_add_error(ira, target, | 15820 | ir_add_error(ira, target, |
| 15783 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value.type->name))); | 15821 | 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) { | 15822 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { |
| 15785 | ErrorMsg *msg = ir_add_error(ira, target, | 15823 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15786 | buf_sprintf("exported struct value must be declared extern")); | 15824 | 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")); | 15825 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); |
| 15788 | } else { | 15826 | } else { |
| 15789 | want_var_export = true; | 15827 | want_var_export = true; |
| 15790 | } | 15828 | } |
| 15791 | break; | 15829 | break; |
| 15792 | case ZigTypeIdUnion: | 15830 | case ZigTypeIdUnion: |
| 15793 | if (target->value.type->data.unionation.layout != ContainerLayoutExtern) { | 15831 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { |
| 15794 | ErrorMsg *msg = ir_add_error(ira, target, | 15832 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15795 | buf_sprintf("exported union value must be declared extern")); | 15833 | 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")); | 15834 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); |
| 15797 | } else { | 15835 | } else { |
| 15798 | want_var_export = true; | 15836 | want_var_export = true; |
| 15799 | } | 15837 | } |
| 15800 | break; | 15838 | break; |
| 15801 | case ZigTypeIdEnum: | 15839 | case ZigTypeIdEnum: |
| 15802 | if (target->value.type->data.enumeration.layout != ContainerLayoutExtern) { | 15840 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { |
| 15803 | ErrorMsg *msg = ir_add_error(ira, target, | 15841 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15804 | buf_sprintf("exported enum value must be declared extern")); | 15842 | 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")); | 15843 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 15806 | } else { | 15844 | } else { |
| 15807 | want_var_export = true; | 15845 | want_var_export = true; |
| 15808 | } | 15846 | } |
| 15809 | break; | 15847 | break; |
| 15810 | case ZigTypeIdArray: { | 15848 | case ZigTypeIdArray: { |
| 15811 | bool ok_type; | 15849 | bool ok_type; |
| 15812 | if ((err = type_allowed_in_extern(ira->codegen, target->value.type->data.array.child_type, &ok_type))) | 15850 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) |
| 15813 | return ira->codegen->invalid_instruction; | 15851 | return ira->codegen->invalid_instruction; |
| 15814 | | 15852 | |
| 15815 | if (!ok_type) { | 15853 | if (!ok_type) { |
| 15816 | ir_add_error(ira, target, | 15854 | ir_add_error(ira, target, |
| 15817 | buf_sprintf("array element type '%s' not extern-compatible", | 15855 | buf_sprintf("array element type '%s' not extern-compatible", |
| 15818 | buf_ptr(&target->value.type->data.array.child_type->name))); | 15856 | buf_ptr(&target->value->type->data.array.child_type->name))); |
| 15819 | } else { | 15857 | } else { |
| 15820 | want_var_export = true; | 15858 | want_var_export = true; |
| 15821 | } | 15859 | } |
| 15822 | break; | 15860 | break; |
| 15823 | } | 15861 | } |
| 15824 | case ZigTypeIdMetaType: { | 15862 | case ZigTypeIdMetaType: { |
| 15825 | ZigType *type_value = target->value.data.x_type; | 15863 | ZigType *type_value = target->value->data.x_type; |
| 15826 | switch (type_value->id) { | 15864 | switch (type_value->id) { |
| 15827 | case ZigTypeIdInvalid: | 15865 | case ZigTypeIdInvalid: |
| 15828 | zig_unreachable(); | 15866 | zig_unreachable(); |
| ... | @@ -15898,7 +15936,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15898,7 +15936,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15898 | case ZigTypeIdErrorUnion: | 15936 | case ZigTypeIdErrorUnion: |
| 15899 | case ZigTypeIdErrorSet: | 15937 | case ZigTypeIdErrorSet: |
| 15900 | case ZigTypeIdVector: | 15938 | case ZigTypeIdVector: |
| 15901 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name)); | 15939 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value->type->name)); |
| 15902 | case ZigTypeIdBoundFn: | 15940 | case ZigTypeIdBoundFn: |
| 15903 | case ZigTypeIdArgTuple: | 15941 | case ZigTypeIdArgTuple: |
| 15904 | case ZigTypeIdOpaque: | 15942 | case ZigTypeIdOpaque: |
| ... | @@ -15906,7 +15944,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15906,7 +15944,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15906 | case ZigTypeIdFnFrame: | 15944 | case ZigTypeIdFnFrame: |
| 15907 | case ZigTypeIdAnyFrame: | 15945 | case ZigTypeIdAnyFrame: |
| 15908 | ir_add_error(ira, target, | 15946 | ir_add_error(ira, target, |
| 15909 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); | 15947 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); |
| 15910 | break; | 15948 | break; |
| 15911 | } | 15949 | } |
| 15912 | | 15950 | |
| ... | @@ -15936,7 +15974,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | ... | @@ -15936,7 +15974,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 15936 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); | 15974 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); |
| 15937 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { | 15975 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { |
| 15938 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); | 15976 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); |
| 15939 | ConstExprValue *out_val = &result->value; | 15977 | ZigValue *out_val = result->value; |
| 15940 | assert(get_codegen_ptr_type(optional_type) != nullptr); | 15978 | assert(get_codegen_ptr_type(optional_type) != nullptr); |
| 15941 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 15979 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 15942 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; | 15980 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; |
| ... | @@ -15944,13 +15982,13 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | ... | @@ -15944,13 +15982,13 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 15944 | } | 15982 | } |
| 15945 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 15983 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, |
| 15946 | instruction->base.source_node, instruction->optional); | 15984 | instruction->base.source_node, instruction->optional); |
| 15947 | new_instruction->value.type = optional_type; | 15985 | new_instruction->value->type = optional_type; |
| 15948 | return new_instruction; | 15986 | return new_instruction; |
| 15949 | } else { | 15987 | } else { |
| 15950 | assert(ira->codegen->have_err_ret_tracing); | 15988 | assert(ira->codegen->have_err_ret_tracing); |
| 15951 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 15989 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, |
| 15952 | instruction->base.source_node, instruction->optional); | 15990 | instruction->base.source_node, instruction->optional); |
| 15953 | new_instruction->value.type = ptr_to_stack_trace_type; | 15991 | new_instruction->value->type = ptr_to_stack_trace_type; |
| 15954 | return new_instruction; | 15992 | return new_instruction; |
| 15955 | } | 15993 | } |
| 15956 | } | 15994 | } |
| ... | @@ -15959,11 +15997,11 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -15959,11 +15997,11 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 15959 | IrInstructionErrorUnion *instruction) | 15997 | IrInstructionErrorUnion *instruction) |
| 15960 | { | 15998 | { |
| 15961 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 15999 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 15962 | result->value.special = ConstValSpecialLazy; | 16000 | result->value->special = ConstValSpecialLazy; |
| 15963 | | 16001 | |
| 15964 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1); | 16002 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1); |
| 15965 | lazy_err_union_type->ira = ira; | 16003 | lazy_err_union_type->ira = ira; |
| 15966 | result->value.data.x_lazy = &lazy_err_union_type->base; | 16004 | result->value->data.x_lazy = &lazy_err_union_type->base; |
| 15967 | lazy_err_union_type->base.id = LazyValueIdErrUnionType; | 16005 | lazy_err_union_type->base.id = LazyValueIdErrUnionType; |
| 15968 | | 16006 | |
| 15969 | lazy_err_union_type->err_set_type = instruction->err_set->child; | 16007 | lazy_err_union_type->err_set_type = instruction->err_set->child; |
| ... | @@ -15982,14 +16020,14 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -15982,14 +16020,14 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 15982 | { | 16020 | { |
| 15983 | Error err; | 16021 | Error err; |
| 15984 | | 16022 | |
| 15985 | ConstExprValue *pointee = create_const_vals(1); | 16023 | ZigValue *pointee = create_const_vals(1); |
| 15986 | pointee->special = ConstValSpecialUndef; | 16024 | pointee->special = ConstValSpecialUndef; |
| 15987 | | 16025 | |
| 15988 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); | 16026 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); |
| 15989 | result->base.value.special = ConstValSpecialStatic; | 16027 | result->base.value->special = ConstValSpecialStatic; |
| 15990 | result->base.value.data.x_ptr.special = ConstPtrSpecialRef; | 16028 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 15991 | result->base.value.data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; | 16029 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; |
| 15992 | result->base.value.data.x_ptr.data.ref.pointee = pointee; | 16030 | result->base.value->data.x_ptr.data.ref.pointee = pointee; |
| 15993 | | 16031 | |
| 15994 | bool var_type_has_bits; | 16032 | bool var_type_has_bits; |
| 15995 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) | 16033 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) |
| ... | @@ -16004,10 +16042,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -16004,10 +16042,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 16004 | return ira->codegen->invalid_instruction; | 16042 | return ira->codegen->invalid_instruction; |
| 16005 | } | 16043 | } |
| 16006 | } | 16044 | } |
| 16007 | assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid); | 16045 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); |
| 16008 | | 16046 | |
| 16009 | pointee->type = var_type; | 16047 | pointee->type = var_type; |
| 16010 | result->base.value.type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, | 16048 | result->base.value->type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, |
| 16011 | PtrLenSingle, align, 0, 0, false); | 16049 | PtrLenSingle, align, 0, 0, false); |
| 16012 | | 16050 | |
| 16013 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 16051 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| ... | @@ -16031,7 +16069,7 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16031,7 +16069,7 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspe |
| 16031 | case ResultLocIdCast: | 16069 | case ResultLocIdCast: |
| 16032 | return nullptr; | 16070 | return nullptr; |
| 16033 | case ResultLocIdInstruction: | 16071 | case ResultLocIdInstruction: |
| 16034 | return result_loc->source_instruction->child->value.type; | 16072 | return result_loc->source_instruction->child->value->type; |
| 16035 | case ResultLocIdReturn: | 16073 | case ResultLocIdReturn: |
| 16036 | return ira->explicit_return_type; | 16074 | return ira->explicit_return_type; |
| 16037 | case ResultLocIdPeer: | 16075 | case ResultLocIdPeer: |
| ... | @@ -16063,13 +16101,13 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -16063,13 +16101,13 @@ static bool type_can_bit_cast(ZigType *t) { |
| 16063 | } | 16101 | } |
| 16064 | | 16102 | |
| 16065 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { | 16103 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { |
| 16066 | ConstExprValue *undef_child = create_const_vals(1); | 16104 | ZigValue *undef_child = create_const_vals(1); |
| 16067 | undef_child->type = ptr->value.type->data.pointer.child_type; | 16105 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 16068 | undef_child->special = ConstValSpecialUndef; | 16106 | undef_child->special = ConstValSpecialUndef; |
| 16069 | ptr->value.special = ConstValSpecialStatic; | 16107 | ptr->value->special = ConstValSpecialStatic; |
| 16070 | ptr->value.data.x_ptr.mut = ConstPtrMutInfer; | 16108 | ptr->value->data.x_ptr.mut = ConstPtrMutInfer; |
| 16071 | ptr->value.data.x_ptr.special = ConstPtrSpecialRef; | 16109 | ptr->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16072 | ptr->value.data.x_ptr.data.ref.pointee = undef_child; | 16110 | ptr->value->data.x_ptr.data.ref.pointee = undef_child; |
| 16073 | } | 16111 | } |
| 16074 | | 16112 | |
| 16075 | static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out) { | 16113 | static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out) { |
| ... | @@ -16105,7 +16143,7 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su | ... | @@ -16105,7 +16143,7 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su |
| 16105 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) | 16143 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) |
| 16106 | { | 16144 | { |
| 16107 | IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); | 16145 | 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, | 16146 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 16109 | PtrLenSingle, 0, 0, 0, false); | 16147 | PtrLenSingle, 0, 0, 0, false); |
| 16110 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); | 16148 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); |
| 16111 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 16149 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| ... | @@ -16158,7 +16196,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16158,7 +16196,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16158 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) | 16196 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) |
| 16159 | return ira->codegen->invalid_instruction; | 16197 | return ira->codegen->invalid_instruction; |
| 16160 | bool is_comptime = force_comptime || (value != nullptr && | 16198 | bool is_comptime = force_comptime || (value != nullptr && |
| 16161 | value->value.special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); | 16199 | value->value->special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); |
| 16162 | | 16200 | |
| 16163 | if (alloca_src->base.child == nullptr || is_comptime) { | 16201 | if (alloca_src->base.child == nullptr || is_comptime) { |
| 16164 | uint32_t align = 0; | 16202 | uint32_t align = 0; |
| ... | @@ -16167,8 +16205,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16167,8 +16205,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16167 | } | 16205 | } |
| 16168 | IrInstruction *alloca_gen; | 16206 | IrInstruction *alloca_gen; |
| 16169 | if (is_comptime && value != nullptr) { | 16207 | if (is_comptime && value != nullptr) { |
| 16170 | if (align > value->value.global_refs->align) { | 16208 | if (align > value->value->global_refs->align) { |
| 16171 | value->value.global_refs->align = align; | 16209 | value->value->global_refs->align = align; |
| 16172 | } | 16210 | } |
| 16173 | alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false); | 16211 | alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false); |
| 16174 | } else { | 16212 | } else { |
| ... | @@ -16191,7 +16229,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16191,7 +16229,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16191 | } | 16229 | } |
| 16192 | case ResultLocIdReturn: { | 16230 | case ResultLocIdReturn: { |
| 16193 | if (!non_null_comptime) { | 16231 | if (!non_null_comptime) { |
| 16194 | bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime; | 16232 | bool is_comptime = value != nullptr && value->value->special != ConstValSpecialRuntime; |
| 16195 | if (is_comptime) | 16233 | if (is_comptime) |
| 16196 | return nullptr; | 16234 | return nullptr; |
| 16197 | } | 16235 | } |
| ... | @@ -16222,8 +16260,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16222,8 +16260,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16222 | value_type, value, force_runtime, non_null_comptime, true); | 16260 | value_type, value, force_runtime, non_null_comptime, true); |
| 16223 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; | 16261 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; |
| 16224 | result_peer->suspend_pos.instruction_index = SIZE_MAX; | 16262 | result_peer->suspend_pos.instruction_index = SIZE_MAX; |
| 16225 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16263 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16226 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16264 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16227 | { | 16265 | { |
| 16228 | return parent_result_loc; | 16266 | return parent_result_loc; |
| 16229 | } | 16267 | } |
| ... | @@ -16270,19 +16308,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16270,19 +16308,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16270 | | 16308 | |
| 16271 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 16309 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 16272 | peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true); | 16310 | 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) || | 16311 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16274 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16312 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16275 | { | 16313 | { |
| 16276 | return parent_result_loc; | 16314 | return parent_result_loc; |
| 16277 | } | 16315 | } |
| 16278 | // because is_comptime is false, we mark this a runtime pointer | 16316 | // because is_comptime is false, we mark this a runtime pointer |
| 16279 | parent_result_loc->value.special = ConstValSpecialRuntime; | 16317 | parent_result_loc->value->special = ConstValSpecialRuntime; |
| 16280 | result_loc->written = true; | 16318 | result_loc->written = true; |
| 16281 | result_loc->resolved_loc = parent_result_loc; | 16319 | result_loc->resolved_loc = parent_result_loc; |
| 16282 | return result_loc->resolved_loc; | 16320 | return result_loc->resolved_loc; |
| 16283 | } | 16321 | } |
| 16284 | case ResultLocIdCast: { | 16322 | case ResultLocIdCast: { |
| 16285 | if (value != nullptr && value->value.special != ConstValSpecialRuntime) | 16323 | if (value != nullptr && value->value->special != ConstValSpecialRuntime) |
| 16286 | return nullptr; | 16324 | return nullptr; |
| 16287 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); | 16325 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); |
| 16288 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); | 16326 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| ... | @@ -16313,19 +16351,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16313,19 +16351,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16313 | casted_value = nullptr; | 16351 | casted_value = nullptr; |
| 16314 | } | 16352 | } |
| 16315 | | 16353 | |
| 16316 | if (casted_value != nullptr && type_is_invalid(casted_value->value.type)) { | 16354 | if (casted_value != nullptr && type_is_invalid(casted_value->value->type)) { |
| 16317 | return casted_value; | 16355 | return casted_value; |
| 16318 | } | 16356 | } |
| 16319 | | 16357 | |
| 16320 | bool old_parent_result_loc_written = result_cast->parent->written; | 16358 | bool old_parent_result_loc_written = result_cast->parent->written; |
| 16321 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | 16359 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, |
| 16322 | dest_type, casted_value, force_runtime, non_null_comptime, true); | 16360 | dest_type, casted_value, force_runtime, non_null_comptime, true); |
| 16323 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16361 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16324 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16362 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16325 | { | 16363 | { |
| 16326 | return parent_result_loc; | 16364 | return parent_result_loc; |
| 16327 | } | 16365 | } |
| 16328 | ZigType *parent_ptr_type = parent_result_loc->value.type; | 16366 | ZigType *parent_ptr_type = parent_result_loc->value->type; |
| 16329 | assert(parent_ptr_type->id == ZigTypeIdPointer); | 16367 | assert(parent_ptr_type->id == ZigTypeIdPointer); |
| 16330 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 16368 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 16331 | ResolveStatusAlignmentKnown))) | 16369 | ResolveStatusAlignmentKnown))) |
| ... | @@ -16358,7 +16396,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16358,7 +16396,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16358 | { | 16396 | { |
| 16359 | // we also need to check that this cast is OK. | 16397 | // we also need to check that this cast is OK. |
| 16360 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | 16398 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, |
| 16361 | parent_result_loc->value.type, ptr_type, | 16399 | parent_result_loc->value->type, ptr_type, |
| 16362 | result_cast->base.source_instruction->source_node, false); | 16400 | result_cast->base.source_instruction->source_node, false); |
| 16363 | if (const_cast_result.id == ConstCastResultIdInvalid) | 16401 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 16364 | return ira->codegen->invalid_instruction; | 16402 | return ira->codegen->invalid_instruction; |
| ... | @@ -16413,18 +16451,18 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16413,18 +16451,18 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16413 | bitcasted_value = nullptr; | 16451 | bitcasted_value = nullptr; |
| 16414 | } | 16452 | } |
| 16415 | | 16453 | |
| 16416 | if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value.type)) { | 16454 | if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value->type)) { |
| 16417 | return bitcasted_value; | 16455 | return bitcasted_value; |
| 16418 | } | 16456 | } |
| 16419 | | 16457 | |
| 16420 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | 16458 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, |
| 16421 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); | 16459 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); |
| 16422 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16460 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16423 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16461 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16424 | { | 16462 | { |
| 16425 | return parent_result_loc; | 16463 | return parent_result_loc; |
| 16426 | } | 16464 | } |
| 16427 | ZigType *parent_ptr_type = parent_result_loc->value.type; | 16465 | ZigType *parent_ptr_type = parent_result_loc->value->type; |
| 16428 | assert(parent_ptr_type->id == ZigTypeIdPointer); | 16466 | assert(parent_ptr_type->id == ZigTypeIdPointer); |
| 16429 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 16467 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 16430 | ResolveStatusAlignmentKnown))) | 16468 | ResolveStatusAlignmentKnown))) |
| ... | @@ -16454,24 +16492,24 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -16454,24 +16492,24 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 16454 | { | 16492 | { |
| 16455 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && | 16493 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && |
| 16456 | instr_is_comptime(result_loc_pass1->source_instruction) && | 16494 | instr_is_comptime(result_loc_pass1->source_instruction) && |
| 16457 | result_loc_pass1->source_instruction->value.type->id == ZigTypeIdPointer && | 16495 | result_loc_pass1->source_instruction->value->type->id == ZigTypeIdPointer && |
| 16458 | result_loc_pass1->source_instruction->value.data.x_ptr.special == ConstPtrSpecialDiscard) | 16496 | result_loc_pass1->source_instruction->value->data.x_ptr.special == ConstPtrSpecialDiscard) |
| 16459 | { | 16497 | { |
| 16460 | result_loc_pass1 = no_result_loc(); | 16498 | result_loc_pass1 = no_result_loc(); |
| 16461 | } | 16499 | } |
| 16462 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | 16500 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 16463 | value, force_runtime, non_null_comptime); | 16501 | value, force_runtime, non_null_comptime); |
| 16464 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value.type))) | 16502 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) |
| 16465 | return result_loc; | 16503 | return result_loc; |
| 16466 | | 16504 | |
| 16467 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && | 16505 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && |
| 16468 | result_loc_pass1->written && result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) | 16506 | result_loc_pass1->written && result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) |
| 16469 | { | 16507 | { |
| 16470 | result_loc->value.special = ConstValSpecialRuntime; | 16508 | result_loc->value->special = ConstValSpecialRuntime; |
| 16471 | } | 16509 | } |
| 16472 | | 16510 | |
| 16473 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, suspend_source_instr); | 16511 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr); |
| 16474 | ZigType *actual_elem_type = result_loc->value.type->data.pointer.child_type; | 16512 | ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type; |
| 16475 | if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && | 16513 | if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| 16476 | value_type->id != ZigTypeIdNull) | 16514 | value_type->id != ZigTypeIdNull) |
| 16477 | { | 16515 | { |
| ... | @@ -16544,18 +16582,18 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -16544,18 +16582,18 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 16544 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), | 16582 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), |
| 16545 | implicit_elem_type, nullptr, false, true, true); | 16583 | implicit_elem_type, nullptr, false, true, true); |
| 16546 | if (result_loc != nullptr && | 16584 | if (result_loc != nullptr && |
| 16547 | (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 16585 | (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 16548 | { | 16586 | { |
| 16549 | return result_loc; | 16587 | return result_loc; |
| 16550 | } | 16588 | } |
| 16551 | result_loc->value.special = ConstValSpecialRuntime; | 16589 | result_loc->value->special = ConstValSpecialRuntime; |
| 16552 | return result_loc; | 16590 | return result_loc; |
| 16553 | } | 16591 | } |
| 16554 | | 16592 | |
| 16555 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); | 16593 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); |
| 16556 | result->value.special = ConstValSpecialUndef; | 16594 | result->value->special = ConstValSpecialUndef; |
| 16557 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); | 16595 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); |
| 16558 | ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar; | 16596 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16559 | return ptr; | 16597 | return ptr; |
| 16560 | } | 16598 | } |
| 16561 | | 16599 | |
| ... | @@ -16605,9 +16643,9 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal | ... | @@ -16605,9 +16643,9 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal |
| 16605 | { | 16643 | { |
| 16606 | ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base); | 16644 | ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base); |
| 16607 | IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child; | 16645 | IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child; |
| 16608 | if (type_is_invalid(ret_ptr_uncasted->value.type)) | 16646 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| 16609 | return ira->codegen->invalid_instruction; | 16647 | return ira->codegen->invalid_instruction; |
| 16610 | if (ret_ptr_uncasted->value.type->id == ZigTypeIdVoid) { | 16648 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { |
| 16611 | // Result location will be inside the async frame. | 16649 | // Result location will be inside the async frame. |
| 16612 | return nullptr; | 16650 | return nullptr; |
| 16613 | } | 16651 | } |
| ... | @@ -16632,7 +16670,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc | ... | @@ -16632,7 +16670,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc |
| 16632 | if (casted_new_stack != nullptr) { | 16670 | if (casted_new_stack != nullptr) { |
| 16633 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; | 16671 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 16634 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, call_instruction, fn_ret_type); | 16672 | 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)) | 16673 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) |
| 16636 | return ira->codegen->invalid_instruction; | 16674 | return ira->codegen->invalid_instruction; |
| 16637 | | 16675 | |
| 16638 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); | 16676 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| ... | @@ -16645,11 +16683,11 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc | ... | @@ -16645,11 +16683,11 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc |
| 16645 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); | 16683 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 16646 | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 16684 | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 16647 | frame_type, nullptr, true, true, false); | 16685 | frame_type, nullptr, true, true, false); |
| 16648 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 16686 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 16649 | return result_loc; | 16687 | return result_loc; |
| 16650 | } | 16688 | } |
| 16651 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); | 16689 | 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)) | 16690 | if (type_is_invalid(result_loc->value->type)) |
| 16653 | return ira->codegen->invalid_instruction; | 16691 | return ira->codegen->invalid_instruction; |
| 16654 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, | 16692 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, |
| 16655 | casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack, | 16693 | casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack, |
| ... | @@ -16670,13 +16708,13 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -16670,13 +16708,13 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 16670 | return false; | 16708 | return false; |
| 16671 | | 16709 | |
| 16672 | casted_arg = ir_implicit_cast(ira, arg, param_type); | 16710 | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16673 | if (type_is_invalid(casted_arg->value.type)) | 16711 | if (type_is_invalid(casted_arg->value->type)) |
| 16674 | return false; | 16712 | return false; |
| 16675 | } else { | 16713 | } else { |
| 16676 | casted_arg = arg; | 16714 | casted_arg = arg; |
| 16677 | } | 16715 | } |
| 16678 | | 16716 | |
| 16679 | ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk); | 16717 | ZigValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk); |
| 16680 | if (!arg_val) | 16718 | if (!arg_val) |
| 16681 | return false; | 16719 | return false; |
| 16682 | | 16720 | |
| ... | @@ -16710,7 +16748,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16710,7 +16748,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16710 | return false; | 16748 | return false; |
| 16711 | | 16749 | |
| 16712 | casted_arg = ir_implicit_cast(ira, arg, param_type); | 16750 | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16713 | if (type_is_invalid(casted_arg->value.type)) | 16751 | if (type_is_invalid(casted_arg->value->type)) |
| 16714 | return false; | 16752 | return false; |
| 16715 | } else { | 16753 | } else { |
| 16716 | arg_part_of_generic_id = true; | 16754 | arg_part_of_generic_id = true; |
| ... | @@ -16719,9 +16757,9 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16719,9 +16757,9 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16719 | } | 16757 | } |
| 16720 | | 16758 | |
| 16721 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || | 16759 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || |
| 16722 | casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat; | 16760 | casted_arg->value->type->id == ZigTypeIdComptimeInt || casted_arg->value->type->id == ZigTypeIdComptimeFloat; |
| 16723 | | 16761 | |
| 16724 | ConstExprValue *arg_val; | 16762 | ZigValue *arg_val; |
| 16725 | | 16763 | |
| 16726 | if (comptime_arg) { | 16764 | if (comptime_arg) { |
| 16727 | arg_part_of_generic_id = true; | 16765 | arg_part_of_generic_id = true; |
| ... | @@ -16729,7 +16767,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16729,7 +16767,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16729 | if (!arg_val) | 16767 | if (!arg_val) |
| 16730 | return false; | 16768 | return false; |
| 16731 | } else { | 16769 | } else { |
| 16732 | arg_val = create_const_runtime(casted_arg->value.type); | 16770 | arg_val = create_const_runtime(casted_arg->value->type); |
| 16733 | } | 16771 | } |
| 16734 | if (arg_part_of_generic_id) { | 16772 | if (arg_part_of_generic_id) { |
| 16735 | copy_const_val(&generic_id->params[generic_id->param_count], arg_val, true); | 16773 | copy_const_val(&generic_id->params[generic_id->param_count], arg_val, true); |
| ... | @@ -16745,8 +16783,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16745,8 +16783,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16745 | var->shadowable = !comptime_arg; | 16783 | var->shadowable = !comptime_arg; |
| 16746 | | 16784 | |
| 16747 | *next_proto_i += 1; | 16785 | *next_proto_i += 1; |
| 16748 | } else if (casted_arg->value.type->id == ZigTypeIdComptimeInt || | 16786 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || |
| 16749 | casted_arg->value.type->id == ZigTypeIdComptimeFloat) | 16787 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) |
| 16750 | { | 16788 | { |
| 16751 | ir_add_error(ira, casted_arg, | 16789 | ir_add_error(ira, casted_arg, |
| 16752 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); | 16790 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| ... | @@ -16754,10 +16792,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16754,10 +16792,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16754 | } | 16792 | } |
| 16755 | | 16793 | |
| 16756 | if (!comptime_arg) { | 16794 | if (!comptime_arg) { |
| 16757 | switch (type_requires_comptime(ira->codegen, casted_arg->value.type)) { | 16795 | switch (type_requires_comptime(ira->codegen, casted_arg->value->type)) { |
| 16758 | case ReqCompTimeYes: | 16796 | case ReqCompTimeYes: |
| 16759 | ir_add_error(ira, casted_arg, | 16797 | ir_add_error(ira, casted_arg, |
| 16760 | buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value.type->name))); | 16798 | buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value->type->name))); |
| 16761 | return false; | 16799 | return false; |
| 16762 | case ReqCompTimeInvalid: | 16800 | case ReqCompTimeInvalid: |
| 16763 | return false; | 16801 | return false; |
| ... | @@ -16767,7 +16805,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16767,7 +16805,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16767 | | 16805 | |
| 16768 | casted_args[fn_type_id->param_count] = casted_arg; | 16806 | casted_args[fn_type_id->param_count] = casted_arg; |
| 16769 | FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count]; | 16807 | FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count]; |
| 16770 | param_info->type = casted_arg->value.type; | 16808 | param_info->type = casted_arg->value->type; |
| 16771 | param_info->is_noalias = param_decl_node->data.param_decl.is_noalias; | 16809 | param_info->is_noalias = param_decl_node->data.param_decl.is_noalias; |
| 16772 | impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node; | 16810 | impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node; |
| 16773 | fn_type_id->param_count += 1; | 16811 | fn_type_id->param_count += 1; |
| ... | @@ -16805,7 +16843,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16805,7 +16843,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16805 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) | 16843 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) |
| 16806 | return ira->codegen->invalid_instruction; | 16844 | return ira->codegen->invalid_instruction; |
| 16807 | | 16845 | |
| 16808 | ConstExprValue *mem_slot = nullptr; | 16846 | ZigValue *mem_slot = nullptr; |
| 16809 | | 16847 | |
| 16810 | bool comptime_var_mem = ir_get_var_is_comptime(var); | 16848 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| 16811 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; | 16849 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| ... | @@ -16813,7 +16851,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16813,7 +16851,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16813 | | 16851 | |
| 16814 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, | 16852 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, |
| 16815 | instruction->scope, instruction->source_node, var); | 16853 | instruction->scope, instruction->source_node, var); |
| 16816 | result->value.type = get_pointer_to_type_extra(ira->codegen, var->var_type, | 16854 | result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type, |
| 16817 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); | 16855 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); |
| 16818 | | 16856 | |
| 16819 | if (linkage_makes_it_runtime) | 16857 | if (linkage_makes_it_runtime) |
| ... | @@ -16846,10 +16884,10 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16846,10 +16884,10 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16846 | assert(!comptime_var_mem); | 16884 | assert(!comptime_var_mem); |
| 16847 | ptr_mut = ConstPtrMutRuntimeVar; | 16885 | ptr_mut = ConstPtrMutRuntimeVar; |
| 16848 | } | 16886 | } |
| 16849 | result->value.special = ConstValSpecialStatic; | 16887 | result->value->special = ConstValSpecialStatic; |
| 16850 | result->value.data.x_ptr.mut = ptr_mut; | 16888 | result->value->data.x_ptr.mut = ptr_mut; |
| 16851 | result->value.data.x_ptr.special = ConstPtrSpecialRef; | 16889 | result->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16852 | result->value.data.x_ptr.data.ref.pointee = mem_slot; | 16890 | result->value->data.x_ptr.data.ref.pointee = mem_slot; |
| 16853 | return result; | 16891 | return result; |
| 16854 | } | 16892 | } |
| 16855 | } | 16893 | } |
| ... | @@ -16859,13 +16897,13 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16859,13 +16897,13 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16859 | no_mem_slot: | 16897 | no_mem_slot: |
| 16860 | | 16898 | |
| 16861 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); | 16899 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); |
| 16862 | result->value.data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; | 16900 | result->value->data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; |
| 16863 | | 16901 | |
| 16864 | return result; | 16902 | return result; |
| 16865 | } | 16903 | } |
| 16866 | | 16904 | |
| 16867 | // This function is called when a comptime value becomes accessible at runtime. | 16905 | // This function is called when a comptime value becomes accessible at runtime. |
| 16868 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *val) { | 16906 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *val) { |
| 16869 | ir_assert(value_is_comptime(val), source_instr); | 16907 | ir_assert(value_is_comptime(val), source_instr); |
| 16870 | if (val->special == ConstValSpecialUndef) | 16908 | if (val->special == ConstValSpecialUndef) |
| 16871 | return; | 16909 | return; |
| ... | @@ -16881,11 +16919,11 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -16881,11 +16919,11 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins |
| 16881 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 16919 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, |
| 16882 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) | 16920 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) |
| 16883 | { | 16921 | { |
| 16884 | assert(ptr->value.type->id == ZigTypeIdPointer); | 16922 | assert(ptr->value->type->id == ZigTypeIdPointer); |
| 16885 | | 16923 | |
| 16886 | if (ptr->value.data.x_ptr.special == ConstPtrSpecialDiscard) { | 16924 | if (ptr->value->data.x_ptr.special == ConstPtrSpecialDiscard) { |
| 16887 | if (uncasted_value->value.type->id == ZigTypeIdErrorUnion || | 16925 | if (uncasted_value->value->type->id == ZigTypeIdErrorUnion || |
| 16888 | uncasted_value->value.type->id == ZigTypeIdErrorSet) | 16926 | uncasted_value->value->type->id == ZigTypeIdErrorSet) |
| 16889 | { | 16927 | { |
| 16890 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); | 16928 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); |
| 16891 | return ira->codegen->invalid_instruction; | 16929 | return ira->codegen->invalid_instruction; |
| ... | @@ -16893,7 +16931,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16893,7 +16931,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16893 | return ir_const_void(ira, source_instr); | 16931 | return ir_const_void(ira, source_instr); |
| 16894 | } | 16932 | } |
| 16895 | | 16933 | |
| 16896 | InferredStructField *isf = ptr->value.type->data.pointer.inferred_struct_field; | 16934 | InferredStructField *isf = ptr->value->type->data.pointer.inferred_struct_field; |
| 16897 | if (allow_write_through_const && isf != nullptr) { | 16935 | if (allow_write_through_const && isf != nullptr) { |
| 16898 | // Now it's time to add the field to the struct type. | 16936 | // Now it's time to add the field to the struct type. |
| 16899 | uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count; | 16937 | uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count; |
| ... | @@ -16904,7 +16942,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16904,7 +16942,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16904 | | 16942 | |
| 16905 | TypeStructField *field = isf->inferred_struct_type->data.structure.fields[old_field_count]; | 16943 | TypeStructField *field = isf->inferred_struct_type->data.structure.fields[old_field_count]; |
| 16906 | field->name = isf->field_name; | 16944 | field->name = isf->field_name; |
| 16907 | field->type_entry = uncasted_value->value.type; | 16945 | field->type_entry = uncasted_value->value->type; |
| 16908 | field->type_val = create_const_type(ira->codegen, field->type_entry); | 16946 | field->type_val = create_const_type(ira->codegen, field->type_entry); |
| 16909 | field->src_index = old_field_count; | 16947 | field->src_index = old_field_count; |
| 16910 | field->decl_node = uncasted_value->source_node; | 16948 | field->decl_node = uncasted_value->source_node; |
| ... | @@ -16913,25 +16951,25 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16913,25 +16951,25 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16913 | IrInstruction *casted_ptr; | 16951 | IrInstruction *casted_ptr; |
| 16914 | if (instr_is_comptime(ptr)) { | 16952 | if (instr_is_comptime(ptr)) { |
| 16915 | casted_ptr = ir_const(ira, source_instr, struct_ptr_type); | 16953 | casted_ptr = ir_const(ira, source_instr, struct_ptr_type); |
| 16916 | copy_const_val(&casted_ptr->value, &ptr->value, false); | 16954 | copy_const_val(casted_ptr->value, ptr->value, false); |
| 16917 | casted_ptr->value.type = struct_ptr_type; | 16955 | casted_ptr->value->type = struct_ptr_type; |
| 16918 | } else { | 16956 | } else { |
| 16919 | casted_ptr = ir_build_cast(&ira->new_irb, source_instr->scope, | 16957 | casted_ptr = ir_build_cast(&ira->new_irb, source_instr->scope, |
| 16920 | source_instr->source_node, struct_ptr_type, ptr, CastOpNoop); | 16958 | source_instr->source_node, struct_ptr_type, ptr, CastOpNoop); |
| 16921 | casted_ptr->value.type = struct_ptr_type; | 16959 | casted_ptr->value->type = struct_ptr_type; |
| 16922 | } | 16960 | } |
| 16923 | if (instr_is_comptime(casted_ptr)) { | 16961 | if (instr_is_comptime(casted_ptr)) { |
| 16924 | ConstExprValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); | 16962 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); |
| 16925 | if (!ptr_val) | 16963 | if (!ptr_val) |
| 16926 | return ira->codegen->invalid_instruction; | 16964 | return ira->codegen->invalid_instruction; |
| 16927 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 16965 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 16928 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, | 16966 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 16929 | source_instr->source_node); | 16967 | source_instr->source_node); |
| 16930 | struct_val->special = ConstValSpecialStatic; | 16968 | struct_val->special = ConstValSpecialStatic; |
| 16931 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, | 16969 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, |
| 16932 | old_field_count, new_field_count); | 16970 | old_field_count, new_field_count); |
| 16933 | | 16971 | |
| 16934 | ConstExprValue *field_val = struct_val->data.x_struct.fields[old_field_count]; | 16972 | ZigValue *field_val = struct_val->data.x_struct.fields[old_field_count]; |
| 16935 | field_val->special = ConstValSpecialUndef; | 16973 | field_val->special = ConstValSpecialUndef; |
| 16936 | field_val->type = field->type_entry; | 16974 | field_val->type = field->type_entry; |
| 16937 | field_val->parent.id = ConstParentIdStruct; | 16975 | field_val->parent.id = ConstParentIdStruct; |
| ... | @@ -16944,12 +16982,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16944,12 +16982,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16944 | isf->inferred_struct_type, true); | 16982 | isf->inferred_struct_type, true); |
| 16945 | } | 16983 | } |
| 16946 | | 16984 | |
| 16947 | if (ptr->value.type->data.pointer.is_const && !allow_write_through_const) { | 16985 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { |
| 16948 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 16986 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 16949 | return ira->codegen->invalid_instruction; | 16987 | return ira->codegen->invalid_instruction; |
| 16950 | } | 16988 | } |
| 16951 | | 16989 | |
| 16952 | ZigType *child_type = ptr->value.type->data.pointer.child_type; | 16990 | ZigType *child_type = ptr->value->type->data.pointer.child_type; |
| 16953 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); | 16991 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); |
| 16954 | if (value == ira->codegen->invalid_instruction) | 16992 | if (value == ira->codegen->invalid_instruction) |
| 16955 | return ira->codegen->invalid_instruction; | 16993 | return ira->codegen->invalid_instruction; |
| ... | @@ -16963,16 +17001,16 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16963,16 +17001,16 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16963 | break; | 17001 | break; |
| 16964 | } | 17002 | } |
| 16965 | | 17003 | |
| 16966 | if (instr_is_comptime(ptr) && ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 17004 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 16967 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst) { | 17005 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { |
| 16968 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 17006 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 16969 | return ira->codegen->invalid_instruction; | 17007 | return ira->codegen->invalid_instruction; |
| 16970 | } | 17008 | } |
| 16971 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar || | 17009 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || |
| 16972 | ptr->value.data.x_ptr.mut == ConstPtrMutInfer) | 17010 | ptr->value->data.x_ptr.mut == ConstPtrMutInfer) |
| 16973 | { | 17011 | { |
| 16974 | if (instr_is_comptime(value)) { | 17012 | if (instr_is_comptime(value)) { |
| 16975 | ConstExprValue *dest_val = const_ptr_pointee(ira, ira->codegen, &ptr->value, source_instr->source_node); | 17013 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); |
| 16976 | if (dest_val == nullptr) | 17014 | if (dest_val == nullptr) |
| 16977 | return ira->codegen->invalid_instruction; | 17015 | return ira->codegen->invalid_instruction; |
| 16978 | if (dest_val->special != ConstValSpecialRuntime) { | 17016 | if (dest_val->special != ConstValSpecialRuntime) { |
| ... | @@ -16982,9 +17020,9 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16982,9 +17020,9 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16982 | // * "string literal used as comptime slice is memoized" | 17020 | // * "string literal used as comptime slice is memoized" |
| 16983 | // * "comptime modification of const struct field" - except modified to avoid | 17021 | // * "comptime modification of const struct field" - except modified to avoid |
| 16984 | // ConstPtrMutComptimeVar, thus defeating the logic below. | 17022 | // ConstPtrMutComptimeVar, thus defeating the logic below. |
| 16985 | bool same_global_refs = ptr->value.data.x_ptr.mut != ConstPtrMutComptimeVar; | 17023 | bool same_global_refs = ptr->value->data.x_ptr.mut != ConstPtrMutComptimeVar; |
| 16986 | copy_const_val(dest_val, &value->value, same_global_refs); | 17024 | copy_const_val(dest_val, value->value, same_global_refs); |
| 16987 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar && | 17025 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar && |
| 16988 | !ira->new_irb.current_basic_block->must_be_comptime_source_instr) | 17026 | !ira->new_irb.current_basic_block->must_be_comptime_source_instr) |
| 16989 | { | 17027 | { |
| 16990 | ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr; | 17028 | ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr; |
| ... | @@ -16992,12 +17030,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16992,12 +17030,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16992 | return ir_const_void(ira, source_instr); | 17030 | return ir_const_void(ira, source_instr); |
| 16993 | } | 17031 | } |
| 16994 | } | 17032 | } |
| 16995 | if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) { | 17033 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 16996 | ptr->value.special = ConstValSpecialRuntime; | 17034 | ptr->value->special = ConstValSpecialRuntime; |
| 16997 | } else { | 17035 | } else { |
| 16998 | ir_add_error(ira, source_instr, | 17036 | ir_add_error(ira, source_instr, |
| 16999 | buf_sprintf("cannot store runtime value in compile time variable")); | 17037 | buf_sprintf("cannot store runtime value in compile time variable")); |
| 17000 | ConstExprValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 17038 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 17001 | dest_val->type = ira->codegen->builtin_types.entry_invalid; | 17039 | dest_val->type = ira->codegen->builtin_types.entry_invalid; |
| 17002 | | 17040 | |
| 17003 | return ira->codegen->invalid_instruction; | 17041 | return ira->codegen->invalid_instruction; |
| ... | @@ -17009,7 +17047,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17009,7 +17047,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17009 | case ReqCompTimeInvalid: | 17047 | case ReqCompTimeInvalid: |
| 17010 | return ira->codegen->invalid_instruction; | 17048 | return ira->codegen->invalid_instruction; |
| 17011 | case ReqCompTimeYes: | 17049 | case ReqCompTimeYes: |
| 17012 | switch (type_has_one_possible_value(ira->codegen, ptr->value.type)) { | 17050 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { |
| 17013 | case OnePossibleValueInvalid: | 17051 | case OnePossibleValueInvalid: |
| 17014 | return ira->codegen->invalid_instruction; | 17052 | return ira->codegen->invalid_instruction; |
| 17015 | case OnePossibleValueNo: | 17053 | case OnePossibleValueNo: |
| ... | @@ -17025,7 +17063,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17025,7 +17063,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17025 | } | 17063 | } |
| 17026 | | 17064 | |
| 17027 | if (instr_is_comptime(value)) { | 17065 | if (instr_is_comptime(value)) { |
| 17028 | mark_comptime_value_escape(ira, source_instr, &value->value); | 17066 | mark_comptime_value_escape(ira, source_instr, value->value); |
| 17029 | } | 17067 | } |
| 17030 | | 17068 | |
| 17031 | // If this is a store to a pointer with a runtime-known vector index, | 17069 | // If this is a store to a pointer with a runtime-known vector index, |
| ... | @@ -17034,7 +17072,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17034,7 +17072,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17034 | // explaining why it is impossible for this store to work. Which is that | 17072 | // explaining why it is impossible for this store to work. Which is that |
| 17035 | // the pointer address is of the vector; without the element index being known | 17073 | // the pointer address is of the vector; without the element index being known |
| 17036 | // we cannot properly perform the insertion. | 17074 | // we cannot properly perform the insertion. |
| 17037 | if (ptr->value.type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 17075 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 17038 | if (ptr->id == IrInstructionIdElemPtr) { | 17076 | if (ptr->id == IrInstructionIdElemPtr) { |
| 17039 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 17077 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; |
| 17040 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, | 17078 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, |
| ... | @@ -17042,7 +17080,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17042,7 +17080,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17042 | } | 17080 | } |
| 17043 | ir_add_error(ira, ptr, | 17081 | ir_add_error(ira, ptr, |
| 17044 | buf_sprintf("unable to determine vector element index of type '%s'", | 17082 | buf_sprintf("unable to determine vector element index of type '%s'", |
| 17045 | buf_ptr(&ptr->value.type->name))); | 17083 | buf_ptr(&ptr->value->type->name))); |
| 17046 | return ira->codegen->invalid_instruction; | 17084 | return ira->codegen->invalid_instruction; |
| 17047 | } | 17085 | } |
| 17048 | | 17086 | |
| ... | @@ -17058,12 +17096,12 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall | ... | @@ -17058,12 +17096,12 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall |
| 17058 | return nullptr; | 17096 | return nullptr; |
| 17059 | | 17097 | |
| 17060 | IrInstruction *new_stack = call_instruction->new_stack->child; | 17098 | IrInstruction *new_stack = call_instruction->new_stack->child; |
| 17061 | if (type_is_invalid(new_stack->value.type)) | 17099 | if (type_is_invalid(new_stack->value->type)) |
| 17062 | return ira->codegen->invalid_instruction; | 17100 | return ira->codegen->invalid_instruction; |
| 17063 | | 17101 | |
| 17064 | if (call_instruction->is_async_call_builtin && | 17102 | if (call_instruction->is_async_call_builtin && |
| 17065 | fn_entry != nullptr && new_stack->value.type->id == ZigTypeIdPointer && | 17103 | fn_entry != nullptr && new_stack->value->type->id == ZigTypeIdPointer && |
| 17066 | new_stack->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 17104 | new_stack->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 17067 | { | 17105 | { |
| 17068 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, | 17106 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, |
| 17069 | get_fn_frame_type(ira->codegen, fn_entry), false); | 17107 | get_fn_frame_type(ira->codegen, fn_entry), false); |
| ... | @@ -17097,7 +17135,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17097,7 +17135,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17097 | | 17135 | |
| 17098 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; | 17136 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; |
| 17099 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { | 17137 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 17100 | ConstExprValue *arg_tuple_value = &call_instruction->args[i]->child->value; | 17138 | ZigValue *arg_tuple_value = call_instruction->args[i]->child->value; |
| 17101 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { | 17139 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { |
| 17102 | call_param_count -= 1; | 17140 | call_param_count -= 1; |
| 17103 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - | 17141 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - |
| ... | @@ -17152,7 +17190,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17152,7 +17190,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17152 | | 17190 | |
| 17153 | size_t next_proto_i = 0; | 17191 | size_t next_proto_i = 0; |
| 17154 | if (first_arg_ptr) { | 17192 | if (first_arg_ptr) { |
| 17155 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17193 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17156 | | 17194 | |
| 17157 | bool first_arg_known_bare = false; | 17195 | bool first_arg_known_bare = false; |
| 17158 | if (fn_type_id->next_param_index >= 1) { | 17196 | if (fn_type_id->next_param_index >= 1) { |
| ... | @@ -17163,11 +17201,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17163,11 +17201,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17163 | } | 17201 | } |
| 17164 | | 17202 | |
| 17165 | IrInstruction *first_arg; | 17203 | IrInstruction *first_arg; |
| 17166 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) { | 17204 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 17167 | first_arg = first_arg_ptr; | 17205 | first_arg = first_arg_ptr; |
| 17168 | } else { | 17206 | } else { |
| 17169 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17207 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17170 | if (type_is_invalid(first_arg->value.type)) | 17208 | if (type_is_invalid(first_arg->value->type)) |
| 17171 | return ira->codegen->invalid_instruction; | 17209 | return ira->codegen->invalid_instruction; |
| 17172 | } | 17210 | } |
| 17173 | | 17211 | |
| ... | @@ -17184,7 +17222,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17184,7 +17222,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17184 | | 17222 | |
| 17185 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17223 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17186 | IrInstruction *old_arg = call_instruction->args[call_i]->child; | 17224 | IrInstruction *old_arg = call_instruction->args[call_i]->child; |
| 17187 | if (type_is_invalid(old_arg->value.type)) | 17225 | if (type_is_invalid(old_arg->value->type)) |
| 17188 | return ira->codegen->invalid_instruction; | 17226 | return ira->codegen->invalid_instruction; |
| 17189 | | 17227 | |
| 17190 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) | 17228 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| ... | @@ -17207,7 +17245,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17207,7 +17245,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17207 | } | 17245 | } |
| 17208 | | 17246 | |
| 17209 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); | 17247 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); |
| 17210 | ConstExprValue *result = nullptr; | 17248 | ZigValue *result = nullptr; |
| 17211 | if (cacheable) { | 17249 | if (cacheable) { |
| 17212 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); | 17250 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); |
| 17213 | if (entry) | 17251 | if (entry) |
| ... | @@ -17250,8 +17288,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17250,8 +17288,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17250 | } | 17288 | } |
| 17251 | | 17289 | |
| 17252 | IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type); | 17290 | IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type); |
| 17253 | copy_const_val(&new_instruction->value, result, true); | 17291 | copy_const_val(new_instruction->value, result, true); |
| 17254 | new_instruction->value.type = return_type; | 17292 | new_instruction->value->type = return_type; |
| 17255 | return ir_finish_anal(ira, new_instruction); | 17293 | return ir_finish_anal(ira, new_instruction); |
| 17256 | } | 17294 | } |
| 17257 | | 17295 | |
| ... | @@ -17266,11 +17304,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17266,11 +17304,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17266 | size_t new_fn_arg_count = first_arg_1_or_0; | 17304 | size_t new_fn_arg_count = first_arg_1_or_0; |
| 17267 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17305 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17268 | IrInstruction *arg = call_instruction->args[call_i]->child; | 17306 | IrInstruction *arg = call_instruction->args[call_i]->child; |
| 17269 | if (type_is_invalid(arg->value.type)) | 17307 | if (type_is_invalid(arg->value->type)) |
| 17270 | return ira->codegen->invalid_instruction; | 17308 | return ira->codegen->invalid_instruction; |
| 17271 | | 17309 | |
| 17272 | if (arg->value.type->id == ZigTypeIdArgTuple) { | 17310 | 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; | 17311 | new_fn_arg_count += arg->value->data.x_arg_tuple.end_index - arg->value->data.x_arg_tuple.start_index; |
| 17274 | } else { | 17312 | } else { |
| 17275 | new_fn_arg_count += 1; | 17313 | new_fn_arg_count += 1; |
| 17276 | } | 17314 | } |
| ... | @@ -17299,7 +17337,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17299,7 +17337,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17299 | size_t next_proto_i = 0; | 17337 | size_t next_proto_i = 0; |
| 17300 | | 17338 | |
| 17301 | if (first_arg_ptr) { | 17339 | if (first_arg_ptr) { |
| 17302 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17340 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17303 | | 17341 | |
| 17304 | bool first_arg_known_bare = false; | 17342 | bool first_arg_known_bare = false; |
| 17305 | if (fn_type_id->next_param_index >= 1) { | 17343 | if (fn_type_id->next_param_index >= 1) { |
| ... | @@ -17310,11 +17348,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17310,11 +17348,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17310 | } | 17348 | } |
| 17311 | | 17349 | |
| 17312 | IrInstruction *first_arg; | 17350 | IrInstruction *first_arg; |
| 17313 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) { | 17351 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 17314 | first_arg = first_arg_ptr; | 17352 | first_arg = first_arg_ptr; |
| 17315 | } else { | 17353 | } else { |
| 17316 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17354 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17317 | if (type_is_invalid(first_arg->value.type)) | 17355 | if (type_is_invalid(first_arg->value->type)) |
| 17318 | return ira->codegen->invalid_instruction; | 17356 | return ira->codegen->invalid_instruction; |
| 17319 | } | 17357 | } |
| 17320 | | 17358 | |
| ... | @@ -17332,12 +17370,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17332,12 +17370,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17332 | assert(parent_fn_entry); | 17370 | assert(parent_fn_entry); |
| 17333 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17371 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17334 | IrInstruction *arg = call_instruction->args[call_i]->child; | 17372 | IrInstruction *arg = call_instruction->args[call_i]->child; |
| 17335 | if (type_is_invalid(arg->value.type)) | 17373 | if (type_is_invalid(arg->value->type)) |
| 17336 | return ira->codegen->invalid_instruction; | 17374 | return ira->codegen->invalid_instruction; |
| 17337 | | 17375 | |
| 17338 | if (arg->value.type->id == ZigTypeIdArgTuple) { | 17376 | if (arg->value->type->id == ZigTypeIdArgTuple) { |
| 17339 | for (size_t arg_tuple_i = arg->value.data.x_arg_tuple.start_index; | 17377 | 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) | 17378 | arg_tuple_i < arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1) |
| 17341 | { | 17379 | { |
| 17342 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); | 17380 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 17343 | assert(param_decl_node->type == NodeTypeParamDecl); | 17381 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | @@ -17354,11 +17392,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17354,11 +17392,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17354 | return ira->codegen->invalid_instruction; | 17392 | return ira->codegen->invalid_instruction; |
| 17355 | } | 17393 | } |
| 17356 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var); | 17394 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var); |
| 17357 | if (type_is_invalid(arg_var_ptr_inst->value.type)) | 17395 | if (type_is_invalid(arg_var_ptr_inst->value->type)) |
| 17358 | return ira->codegen->invalid_instruction; | 17396 | return ira->codegen->invalid_instruction; |
| 17359 | | 17397 | |
| 17360 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, arg, arg_var_ptr_inst, nullptr); | 17398 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, arg, arg_var_ptr_inst, nullptr); |
| 17361 | if (type_is_invalid(arg_tuple_arg->value.type)) | 17399 | if (type_is_invalid(arg_tuple_arg->value->type)) |
| 17362 | return ira->codegen->invalid_instruction; | 17400 | return ira->codegen->invalid_instruction; |
| 17363 | | 17401 | |
| 17364 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg_tuple_arg, &impl_fn->child_scope, | 17402 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg_tuple_arg, &impl_fn->child_scope, |
| ... | @@ -17392,7 +17430,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17392,7 +17430,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17392 | first_var_arg = inst_fn_type_id.param_count; | 17430 | first_var_arg = inst_fn_type_id.param_count; |
| 17393 | } | 17431 | } |
| 17394 | | 17432 | |
| 17395 | ConstExprValue *var_args_val = create_const_arg_tuple(ira->codegen, | 17433 | ZigValue *var_args_val = create_const_arg_tuple(ira->codegen, |
| 17396 | first_var_arg, inst_fn_type_id.param_count); | 17434 | first_var_arg, inst_fn_type_id.param_count); |
| 17397 | ZigVar *var = add_variable(ira->codegen, param_decl_node, | 17435 | ZigVar *var = add_variable(ira->codegen, param_decl_node, |
| 17398 | impl_fn->child_scope, param_name, true, var_args_val, nullptr, var_args_val->type); | 17436 | impl_fn->child_scope, param_name, true, var_args_val, nullptr, var_args_val->type); |
| ... | @@ -17400,14 +17438,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17400,14 +17438,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17400 | } | 17438 | } |
| 17401 | | 17439 | |
| 17402 | if (fn_proto_node->data.fn_proto.align_expr != nullptr) { | 17440 | if (fn_proto_node->data.fn_proto.align_expr != nullptr) { |
| 17403 | ConstExprValue *align_result = ir_eval_const_value(ira->codegen, impl_fn->child_scope, | 17441 | ZigValue *align_result = ir_eval_const_value(ira->codegen, impl_fn->child_scope, |
| 17404 | fn_proto_node->data.fn_proto.align_expr, get_align_amt_type(ira->codegen), | 17442 | fn_proto_node->data.fn_proto.align_expr, get_align_amt_type(ira->codegen), |
| 17405 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, | 17443 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, |
| 17406 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, | 17444 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, |
| 17407 | nullptr, UndefBad); | 17445 | nullptr, UndefBad); |
| 17408 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 17446 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 17409 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); | 17447 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 17410 | copy_const_val(&const_instruction->base.value, align_result, true); | 17448 | copy_const_val(const_instruction->base.value, align_result, true); |
| 17411 | | 17449 | |
| 17412 | uint32_t align_bytes = 0; | 17450 | uint32_t align_bytes = 0; |
| 17413 | ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes); | 17451 | ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes); |
| ... | @@ -17468,7 +17506,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17468,7 +17506,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17468 | } | 17506 | } |
| 17469 | | 17507 | |
| 17470 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, impl_fn); | 17508 | 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)) | 17509 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 17472 | return ira->codegen->invalid_instruction; | 17510 | return ira->codegen->invalid_instruction; |
| 17473 | | 17511 | |
| 17474 | size_t impl_param_count = impl_fn_type_id->param_count; | 17512 | size_t impl_param_count = impl_fn_type_id->param_count; |
| ... | @@ -17483,17 +17521,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17483,17 +17521,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17483 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 17521 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 17484 | impl_fn_type_id->return_type, nullptr, true, true, false); | 17522 | impl_fn_type_id->return_type, nullptr, true, true, false); |
| 17485 | if (result_loc != nullptr) { | 17523 | if (result_loc != nullptr) { |
| 17486 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 17524 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 17487 | return result_loc; | 17525 | return result_loc; |
| 17488 | } | 17526 | } |
| 17489 | if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) { | 17527 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17490 | ir_reset_result(call_instruction->result_loc); | 17528 | ir_reset_result(call_instruction->result_loc); |
| 17491 | result_loc = nullptr; | 17529 | result_loc = nullptr; |
| 17492 | } | 17530 | } |
| 17493 | } | 17531 | } |
| 17494 | } else if (call_instruction->is_async_call_builtin) { | 17532 | } else if (call_instruction->is_async_call_builtin) { |
| 17495 | result_loc = get_async_call_result_loc(ira, call_instruction, impl_fn_type_id->return_type); | 17533 | 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)) | 17534 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 17497 | return ira->codegen->invalid_instruction; | 17535 | return ira->codegen->invalid_instruction; |
| 17498 | } else { | 17536 | } else { |
| 17499 | result_loc = nullptr; | 17537 | result_loc = nullptr; |
| ... | @@ -17530,7 +17568,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17530,7 +17568,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17530 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); | 17568 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); |
| 17531 | size_t next_arg_index = 0; | 17569 | size_t next_arg_index = 0; |
| 17532 | if (first_arg_ptr) { | 17570 | if (first_arg_ptr) { |
| 17533 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17571 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17534 | | 17572 | |
| 17535 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 17573 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 17536 | if (type_is_invalid(param_type)) | 17574 | if (type_is_invalid(param_type)) |
| ... | @@ -17538,17 +17576,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17538,17 +17576,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17538 | | 17576 | |
| 17539 | IrInstruction *first_arg; | 17577 | IrInstruction *first_arg; |
| 17540 | if (param_type->id == ZigTypeIdPointer && | 17578 | if (param_type->id == ZigTypeIdPointer && |
| 17541 | handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) | 17579 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) |
| 17542 | { | 17580 | { |
| 17543 | first_arg = first_arg_ptr; | 17581 | first_arg = first_arg_ptr; |
| 17544 | } else { | 17582 | } else { |
| 17545 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17583 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17546 | if (type_is_invalid(first_arg->value.type)) | 17584 | if (type_is_invalid(first_arg->value->type)) |
| 17547 | return ira->codegen->invalid_instruction; | 17585 | return ira->codegen->invalid_instruction; |
| 17548 | } | 17586 | } |
| 17549 | | 17587 | |
| 17550 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); | 17588 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 17551 | if (type_is_invalid(casted_arg->value.type)) | 17589 | if (type_is_invalid(casted_arg->value->type)) |
| 17552 | return ira->codegen->invalid_instruction; | 17590 | return ira->codegen->invalid_instruction; |
| 17553 | | 17591 | |
| 17554 | casted_args[next_arg_index] = casted_arg; | 17592 | casted_args[next_arg_index] = casted_arg; |
| ... | @@ -17556,12 +17594,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17556,12 +17594,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17556 | } | 17594 | } |
| 17557 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17595 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17558 | IrInstruction *old_arg = call_instruction->args[call_i]->child; | 17596 | IrInstruction *old_arg = call_instruction->args[call_i]->child; |
| 17559 | if (type_is_invalid(old_arg->value.type)) | 17597 | if (type_is_invalid(old_arg->value->type)) |
| 17560 | return ira->codegen->invalid_instruction; | 17598 | return ira->codegen->invalid_instruction; |
| 17561 | | 17599 | |
| 17562 | if (old_arg->value.type->id == ZigTypeIdArgTuple) { | 17600 | if (old_arg->value->type->id == ZigTypeIdArgTuple) { |
| 17563 | for (size_t arg_tuple_i = old_arg->value.data.x_arg_tuple.start_index; | 17601 | 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) | 17602 | arg_tuple_i < old_arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1) |
| 17565 | { | 17603 | { |
| 17566 | ZigVar *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i); | 17604 | ZigVar *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i); |
| 17567 | if (arg_var == nullptr) { | 17605 | if (arg_var == nullptr) { |
| ... | @@ -17570,11 +17608,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17570,11 +17608,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17570 | return ira->codegen->invalid_instruction; | 17608 | return ira->codegen->invalid_instruction; |
| 17571 | } | 17609 | } |
| 17572 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, old_arg, arg_var); | 17610 | 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)) | 17611 | if (type_is_invalid(arg_var_ptr_inst->value->type)) |
| 17574 | return ira->codegen->invalid_instruction; | 17612 | return ira->codegen->invalid_instruction; |
| 17575 | | 17613 | |
| 17576 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, old_arg, arg_var_ptr_inst, nullptr); | 17614 | 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)) | 17615 | if (type_is_invalid(arg_tuple_arg->value->type)) |
| 17578 | return ira->codegen->invalid_instruction; | 17616 | return ira->codegen->invalid_instruction; |
| 17579 | | 17617 | |
| 17580 | IrInstruction *casted_arg; | 17618 | IrInstruction *casted_arg; |
| ... | @@ -17583,7 +17621,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17583,7 +17621,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17583 | if (type_is_invalid(param_type)) | 17621 | if (type_is_invalid(param_type)) |
| 17584 | return ira->codegen->invalid_instruction; | 17622 | return ira->codegen->invalid_instruction; |
| 17585 | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type); | 17623 | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type); |
| 17586 | if (type_is_invalid(casted_arg->value.type)) | 17624 | if (type_is_invalid(casted_arg->value->type)) |
| 17587 | return ira->codegen->invalid_instruction; | 17625 | return ira->codegen->invalid_instruction; |
| 17588 | } else { | 17626 | } else { |
| 17589 | casted_arg = arg_tuple_arg; | 17627 | casted_arg = arg_tuple_arg; |
| ... | @@ -17599,7 +17637,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17599,7 +17637,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17599 | if (type_is_invalid(param_type)) | 17637 | if (type_is_invalid(param_type)) |
| 17600 | return ira->codegen->invalid_instruction; | 17638 | return ira->codegen->invalid_instruction; |
| 17601 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); | 17639 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 17602 | if (type_is_invalid(casted_arg->value.type)) | 17640 | if (type_is_invalid(casted_arg->value->type)) |
| 17603 | return ira->codegen->invalid_instruction; | 17641 | return ira->codegen->invalid_instruction; |
| 17604 | } else { | 17642 | } else { |
| 17605 | casted_arg = old_arg; | 17643 | casted_arg = old_arg; |
| ... | @@ -17623,7 +17661,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17623,7 +17661,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17623 | } | 17661 | } |
| 17624 | | 17662 | |
| 17625 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, fn_entry); | 17663 | 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)) | 17664 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 17627 | return ira->codegen->invalid_instruction; | 17665 | return ira->codegen->invalid_instruction; |
| 17628 | | 17666 | |
| 17629 | if (call_instruction->modifier == CallModifierAsync) { | 17667 | if (call_instruction->modifier == CallModifierAsync) { |
| ... | @@ -17645,17 +17683,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17645,17 +17683,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17645 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 17683 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 17646 | return_type, nullptr, true, true, false); | 17684 | return_type, nullptr, true, true, false); |
| 17647 | if (result_loc != nullptr) { | 17685 | if (result_loc != nullptr) { |
| 17648 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 17686 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 17649 | return result_loc; | 17687 | return result_loc; |
| 17650 | } | 17688 | } |
| 17651 | if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) { | 17689 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17652 | ir_reset_result(call_instruction->result_loc); | 17690 | ir_reset_result(call_instruction->result_loc); |
| 17653 | result_loc = nullptr; | 17691 | result_loc = nullptr; |
| 17654 | } | 17692 | } |
| 17655 | } | 17693 | } |
| 17656 | } else if (call_instruction->is_async_call_builtin) { | 17694 | } else if (call_instruction->is_async_call_builtin) { |
| 17657 | result_loc = get_async_call_result_loc(ira, call_instruction, return_type); | 17695 | result_loc = get_async_call_result_loc(ira, call_instruction, return_type); |
| 17658 | if (result_loc != nullptr && type_is_invalid(result_loc->value.type)) | 17696 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 17659 | return ira->codegen->invalid_instruction; | 17697 | return ira->codegen->invalid_instruction; |
| 17660 | } else { | 17698 | } else { |
| 17661 | result_loc = nullptr; | 17699 | result_loc = nullptr; |
| ... | @@ -17672,14 +17710,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17672,14 +17710,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17672 | | 17710 | |
| 17673 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { | 17711 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { |
| 17674 | IrInstruction *fn_ref = call_instruction->fn_ref->child; | 17712 | IrInstruction *fn_ref = call_instruction->fn_ref->child; |
| 17675 | if (type_is_invalid(fn_ref->value.type)) | 17713 | if (type_is_invalid(fn_ref->value->type)) |
| 17676 | return ira->codegen->invalid_instruction; | 17714 | return ira->codegen->invalid_instruction; |
| 17677 | | 17715 | |
| 17678 | bool is_comptime = call_instruction->is_comptime || | 17716 | bool is_comptime = call_instruction->is_comptime || |
| 17679 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); | 17717 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); |
| 17680 | | 17718 | |
| 17681 | if (is_comptime || instr_is_comptime(fn_ref)) { | 17719 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 17682 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { | 17720 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { |
| 17683 | ZigType *ty = ir_resolve_type(ira, fn_ref); | 17721 | ZigType *ty = ir_resolve_type(ira, fn_ref); |
| 17684 | if (ty == nullptr) | 17722 | if (ty == nullptr) |
| 17685 | return ira->codegen->invalid_instruction; | 17723 | return ira->codegen->invalid_instruction; |
| ... | @@ -17688,30 +17726,30 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -17688,30 +17726,30 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 17688 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, | 17726 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, |
| 17689 | buf_sprintf("use @as builtin for type coercion")); | 17727 | buf_sprintf("use @as builtin for type coercion")); |
| 17690 | return ira->codegen->invalid_instruction; | 17728 | return ira->codegen->invalid_instruction; |
| 17691 | } else if (fn_ref->value.type->id == ZigTypeIdFn) { | 17729 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 17692 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); | 17730 | 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; | 17731 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; |
| 17694 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type, | 17732 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type, |
| 17695 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); | 17733 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); |
| 17696 | } else if (fn_ref->value.type->id == ZigTypeIdBoundFn) { | 17734 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 17697 | assert(fn_ref->value.special == ConstValSpecialStatic); | 17735 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 17698 | ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; | 17736 | 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; | 17737 | IrInstruction *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 17700 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 17738 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 17701 | fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); | 17739 | fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); |
| 17702 | } else { | 17740 | } else { |
| 17703 | ir_add_error_node(ira, fn_ref->source_node, | 17741 | ir_add_error_node(ira, fn_ref->source_node, |
| 17704 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name))); | 17742 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 17705 | return ira->codegen->invalid_instruction; | 17743 | return ira->codegen->invalid_instruction; |
| 17706 | } | 17744 | } |
| 17707 | } | 17745 | } |
| 17708 | | 17746 | |
| 17709 | if (fn_ref->value.type->id == ZigTypeIdFn) { | 17747 | if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 17710 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type, | 17748 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value->type, |
| 17711 | fn_ref, nullptr, false, call_instruction->fn_inline); | 17749 | fn_ref, nullptr, false, call_instruction->fn_inline); |
| 17712 | } else { | 17750 | } else { |
| 17713 | ir_add_error_node(ira, fn_ref->source_node, | 17751 | ir_add_error_node(ira, fn_ref->source_node, |
| 17714 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name))); | 17752 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 17715 | return ira->codegen->invalid_instruction; | 17753 | return ira->codegen->invalid_instruction; |
| 17716 | } | 17754 | } |
| 17717 | } | 17755 | } |
| ... | @@ -17719,12 +17757,12 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -17719,12 +17757,12 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 17719 | // out_val->type must be the type to read the pointer as | 17757 | // out_val->type must be the type to read the pointer as |
| 17720 | // if the type is different than the actual type then it does a comptime byte reinterpretation | 17758 | // if the type is different than the actual type then it does a comptime byte reinterpretation |
| 17721 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 17759 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 17722 | ConstExprValue *out_val, ConstExprValue *ptr_val) | 17760 | ZigValue *out_val, ZigValue *ptr_val) |
| 17723 | { | 17761 | { |
| 17724 | Error err; | 17762 | Error err; |
| 17725 | assert(out_val->type != nullptr); | 17763 | assert(out_val->type != nullptr); |
| 17726 | | 17764 | |
| 17727 | ConstExprValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val); | 17765 | ZigValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val); |
| 17728 | src_assert(pointee->type != nullptr, source_node); | 17766 | src_assert(pointee->type != nullptr, source_node); |
| 17729 | | 17767 | |
| 17730 | if ((err = type_resolve(codegen, pointee->type, ResolveStatusSizeKnown))) | 17768 | if ((err = type_resolve(codegen, pointee->type, ResolveStatusSizeKnown))) |
| ... | @@ -17765,7 +17803,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17765,7 +17803,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17765 | return ErrorSemanticAnalyzeFail; | 17803 | return ErrorSemanticAnalyzeFail; |
| 17766 | } | 17804 | } |
| 17767 | case ConstPtrSpecialBaseArray: { | 17805 | case ConstPtrSpecialBaseArray: { |
| 17768 | ConstExprValue *array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 17806 | ZigValue *array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 17769 | assert(array_val->type->id == ZigTypeIdArray); | 17807 | assert(array_val->type->id == ZigTypeIdArray); |
| 17770 | if (array_val->data.x_array.special != ConstArraySpecialNone) | 17808 | if (array_val->data.x_array.special != ConstArraySpecialNone) |
| 17771 | zig_panic("TODO"); | 17809 | zig_panic("TODO"); |
| ... | @@ -17782,7 +17820,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17782,7 +17820,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17782 | Buf buf = BUF_INIT; | 17820 | Buf buf = BUF_INIT; |
| 17783 | buf_resize(&buf, elem_count * elem_size); | 17821 | buf_resize(&buf, elem_count * elem_size); |
| 17784 | for (size_t i = 0; i < elem_count; i += 1) { | 17822 | for (size_t i = 0; i < elem_count; i += 1) { |
| 17785 | ConstExprValue *elem_val = &array_val->data.x_array.data.s_none.elements[elem_index + i]; | 17823 | ZigValue *elem_val = &array_val->data.x_array.data.s_none.elements[elem_index + i]; |
| 17786 | buf_write_value_bytes(codegen, (uint8_t*)buf_ptr(&buf) + (i * elem_size), elem_val); | 17824 | buf_write_value_bytes(codegen, (uint8_t*)buf_ptr(&buf) + (i * elem_size), elem_val); |
| 17787 | } | 17825 | } |
| 17788 | if ((err = buf_read_value_bytes(ira, codegen, source_node, (uint8_t*)buf_ptr(&buf), out_val))) | 17826 | if ((err = buf_read_value_bytes(ira, codegen, source_node, (uint8_t*)buf_ptr(&buf), out_val))) |
| ... | @@ -17803,11 +17841,11 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17803,11 +17841,11 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17803 | | 17841 | |
| 17804 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17842 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17805 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 17843 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 17806 | result->value.special = ConstValSpecialLazy; | 17844 | result->value->special = ConstValSpecialLazy; |
| 17807 | | 17845 | |
| 17808 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); | 17846 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); |
| 17809 | lazy_opt_type->ira = ira; | 17847 | lazy_opt_type->ira = ira; |
| 17810 | result->value.data.x_lazy = &lazy_opt_type->base; | 17848 | result->value->data.x_lazy = &lazy_opt_type->base; |
| 17811 | lazy_opt_type->base.id = LazyValueIdOptType; | 17849 | lazy_opt_type->base.id = LazyValueIdOptType; |
| 17812 | | 17850 | |
| 17813 | lazy_opt_type->payload_type = instruction->value->child; | 17851 | lazy_opt_type->payload_type = instruction->value->child; |
| ... | @@ -17818,7 +17856,7 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -17818,7 +17856,7 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp |
| 17818 | } | 17856 | } |
| 17819 | | 17857 | |
| 17820 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *scalar_type, | 17858 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *scalar_type, |
| 17821 | ConstExprValue *operand_val, ConstExprValue *scalar_out_val, bool is_wrap_op) | 17859 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) |
| 17822 | { | 17860 | { |
| 17823 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); | 17861 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); |
| 17824 | | 17862 | |
| ... | @@ -17854,7 +17892,7 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -17854,7 +17892,7 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i |
| 17854 | | 17892 | |
| 17855 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17893 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17856 | IrInstruction *value = instruction->value->child; | 17894 | IrInstruction *value = instruction->value->child; |
| 17857 | ZigType *expr_type = value->value.type; | 17895 | ZigType *expr_type = value->value->type; |
| 17858 | if (type_is_invalid(expr_type)) | 17896 | if (type_is_invalid(expr_type)) |
| 17859 | return ira->codegen->invalid_instruction; | 17897 | return ira->codegen->invalid_instruction; |
| 17860 | | 17898 | |
| ... | @@ -17872,20 +17910,20 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -17872,20 +17910,20 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 17872 | ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; | 17910 | ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; |
| 17873 | | 17911 | |
| 17874 | if (instr_is_comptime(value)) { | 17912 | if (instr_is_comptime(value)) { |
| 17875 | ConstExprValue *operand_val = ir_resolve_const(ira, value, UndefBad); | 17913 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); |
| 17876 | if (!operand_val) | 17914 | if (!operand_val) |
| 17877 | return ira->codegen->invalid_instruction; | 17915 | return ira->codegen->invalid_instruction; |
| 17878 | | 17916 | |
| 17879 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); | 17917 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); |
| 17880 | ConstExprValue *out_val = &result_instruction->value; | 17918 | ZigValue *out_val = result_instruction->value; |
| 17881 | if (expr_type->id == ZigTypeIdVector) { | 17919 | if (expr_type->id == ZigTypeIdVector) { |
| 17882 | expand_undef_array(ira->codegen, operand_val); | 17920 | expand_undef_array(ira->codegen, operand_val); |
| 17883 | out_val->special = ConstValSpecialUndef; | 17921 | out_val->special = ConstValSpecialUndef; |
| 17884 | expand_undef_array(ira->codegen, out_val); | 17922 | expand_undef_array(ira->codegen, out_val); |
| 17885 | size_t len = expr_type->data.vector.len; | 17923 | size_t len = expr_type->data.vector.len; |
| 17886 | for (size_t i = 0; i < len; i += 1) { | 17924 | for (size_t i = 0; i < len; i += 1) { |
| 17887 | ConstExprValue *scalar_operand_val = &operand_val->data.x_array.data.s_none.elements[i]; | 17925 | ZigValue *scalar_operand_val = &operand_val->data.x_array.data.s_none.elements[i]; |
| 17888 | ConstExprValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 17926 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 17889 | assert(scalar_operand_val->type == scalar_type); | 17927 | assert(scalar_operand_val->type == scalar_type); |
| 17890 | assert(scalar_out_val->type == scalar_type); | 17928 | assert(scalar_out_val->type == scalar_type); |
| 17891 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, | 17929 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, |
| ... | @@ -17911,31 +17949,31 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -17911,31 +17949,31 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 17911 | IrInstruction *result = ir_build_un_op(&ira->new_irb, | 17949 | IrInstruction *result = ir_build_un_op(&ira->new_irb, |
| 17912 | instruction->base.scope, instruction->base.source_node, | 17950 | instruction->base.scope, instruction->base.source_node, |
| 17913 | instruction->op_id, value); | 17951 | instruction->op_id, value); |
| 17914 | result->value.type = expr_type; | 17952 | result->value->type = expr_type; |
| 17915 | return result; | 17953 | return result; |
| 17916 | } | 17954 | } |
| 17917 | | 17955 | |
| 17918 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17956 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17919 | IrInstruction *value = instruction->value->child; | 17957 | IrInstruction *value = instruction->value->child; |
| 17920 | ZigType *expr_type = value->value.type; | 17958 | ZigType *expr_type = value->value->type; |
| 17921 | if (type_is_invalid(expr_type)) | 17959 | if (type_is_invalid(expr_type)) |
| 17922 | return ira->codegen->invalid_instruction; | 17960 | return ira->codegen->invalid_instruction; |
| 17923 | | 17961 | |
| 17924 | if (expr_type->id == ZigTypeIdInt) { | 17962 | if (expr_type->id == ZigTypeIdInt) { |
| 17925 | if (instr_is_comptime(value)) { | 17963 | if (instr_is_comptime(value)) { |
| 17926 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 17964 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 17927 | if (target_const_val == nullptr) | 17965 | if (target_const_val == nullptr) |
| 17928 | return ira->codegen->invalid_instruction; | 17966 | return ira->codegen->invalid_instruction; |
| 17929 | | 17967 | |
| 17930 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 17968 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 17931 | bigint_not(&result->value.data.x_bigint, &target_const_val->data.x_bigint, | 17969 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, |
| 17932 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); | 17970 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 17933 | return result; | 17971 | return result; |
| 17934 | } | 17972 | } |
| 17935 | | 17973 | |
| 17936 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, | 17974 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, |
| 17937 | instruction->base.source_node, IrUnOpBinNot, value); | 17975 | instruction->base.source_node, IrUnOpBinNot, value); |
| 17938 | result->value.type = expr_type; | 17976 | result->value->type = expr_type; |
| 17939 | return result; | 17977 | return result; |
| 17940 | } | 17978 | } |
| 17941 | | 17979 | |
| ... | @@ -17956,9 +17994,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -17956,9 +17994,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 17956 | return ir_analyze_negation(ira, instruction); | 17994 | return ir_analyze_negation(ira, instruction); |
| 17957 | case IrUnOpDereference: { | 17995 | case IrUnOpDereference: { |
| 17958 | IrInstruction *ptr = instruction->value->child; | 17996 | IrInstruction *ptr = instruction->value->child; |
| 17959 | if (type_is_invalid(ptr->value.type)) | 17997 | if (type_is_invalid(ptr->value->type)) |
| 17960 | return ira->codegen->invalid_instruction; | 17998 | return ira->codegen->invalid_instruction; |
| 17961 | ZigType *ptr_type = ptr->value.type; | 17999 | ZigType *ptr_type = ptr->value->type; |
| 17962 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { | 18000 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { |
| 17963 | ir_add_error_node(ira, instruction->base.source_node, | 18001 | ir_add_error_node(ira, instruction->base.source_node, |
| 17964 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", | 18002 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", |
| ... | @@ -17971,9 +18009,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -17971,9 +18009,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 17971 | return ira->codegen->invalid_instruction; | 18009 | return ira->codegen->invalid_instruction; |
| 17972 | | 18010 | |
| 17973 | // If the result needs to be an lvalue, type check it | 18011 | // If the result needs to be an lvalue, type check it |
| 17974 | if (instruction->lval == LValPtr && result->value.type->id != ZigTypeIdPointer) { | 18012 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { |
| 17975 | ir_add_error(ira, &instruction->base, | 18013 | ir_add_error(ira, &instruction->base, |
| 17976 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value.type->name))); | 18014 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); |
| 17977 | return ira->codegen->invalid_instruction; | 18015 | return ira->codegen->invalid_instruction; |
| 17978 | } | 18016 | } |
| 17979 | | 18017 | |
| ... | @@ -18016,13 +18054,13 @@ static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr | ... | @@ -18016,13 +18054,13 @@ static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr |
| 18016 | | 18054 | |
| 18017 | IrInstruction *result = ir_build_br(&ira->new_irb, | 18055 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 18018 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); | 18056 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); |
| 18019 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18057 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18020 | return ir_finish_anal(ira, result); | 18058 | return ir_finish_anal(ira, result); |
| 18021 | } | 18059 | } |
| 18022 | | 18060 | |
| 18023 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { | 18061 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { |
| 18024 | IrInstruction *condition = cond_br_instruction->condition->child; | 18062 | IrInstruction *condition = cond_br_instruction->condition->child; |
| 18025 | if (type_is_invalid(condition->value.type)) | 18063 | if (type_is_invalid(condition->value->type)) |
| 18026 | return ir_unreach_error(ira); | 18064 | return ir_unreach_error(ira); |
| 18027 | | 18065 | |
| 18028 | bool is_comptime; | 18066 | bool is_comptime; |
| ... | @@ -18031,7 +18069,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18031,7 +18069,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18031 | | 18069 | |
| 18032 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 18070 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 18033 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); | 18071 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); |
| 18034 | if (type_is_invalid(casted_condition->value.type)) | 18072 | if (type_is_invalid(casted_condition->value->type)) |
| 18035 | return ir_unreach_error(ira); | 18073 | return ir_unreach_error(ira); |
| 18036 | | 18074 | |
| 18037 | if (is_comptime || instr_is_comptime(casted_condition)) { | 18075 | if (is_comptime || instr_is_comptime(casted_condition)) { |
| ... | @@ -18053,7 +18091,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18053,7 +18091,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18053 | | 18091 | |
| 18054 | IrInstruction *result = ir_build_br(&ira->new_irb, | 18092 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 18055 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr); | 18093 | 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; | 18094 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18057 | return ir_finish_anal(ira, result); | 18095 | return ir_finish_anal(ira, result); |
| 18058 | } | 18096 | } |
| 18059 | | 18097 | |
| ... | @@ -18072,7 +18110,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18072,7 +18110,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18072 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, | 18110 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, |
| 18073 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, | 18111 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, |
| 18074 | casted_condition, new_then_block, new_else_block, nullptr); | 18112 | casted_condition, new_then_block, new_else_block, nullptr); |
| 18075 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18113 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18076 | return ir_finish_anal(ira, result); | 18114 | return ir_finish_anal(ira, result); |
| 18077 | } | 18115 | } |
| 18078 | | 18116 | |
| ... | @@ -18081,7 +18119,7 @@ static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, | ... | @@ -18081,7 +18119,7 @@ static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, |
| 18081 | { | 18119 | { |
| 18082 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 18120 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, |
| 18083 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); | 18121 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); |
| 18084 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18122 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18085 | return ir_finish_anal(ira, result); | 18123 | return ir_finish_anal(ira, result); |
| 18086 | } | 18124 | } |
| 18087 | | 18125 | |
| ... | @@ -18094,13 +18132,13 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18094,13 +18132,13 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18094 | if (predecessor != ira->const_predecessor_bb) | 18132 | if (predecessor != ira->const_predecessor_bb) |
| 18095 | continue; | 18133 | continue; |
| 18096 | IrInstruction *value = phi_instruction->incoming_values[i]->child; | 18134 | IrInstruction *value = phi_instruction->incoming_values[i]->child; |
| 18097 | assert(value->value.type); | 18135 | assert(value->value->type); |
| 18098 | if (type_is_invalid(value->value.type)) | 18136 | if (type_is_invalid(value->value->type)) |
| 18099 | return ira->codegen->invalid_instruction; | 18137 | return ira->codegen->invalid_instruction; |
| 18100 | | 18138 | |
| 18101 | if (value->value.special != ConstValSpecialRuntime) { | 18139 | if (value->value->special != ConstValSpecialRuntime) { |
| 18102 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); | 18140 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); |
| 18103 | copy_const_val(&result->value, &value->value, true); | 18141 | copy_const_val(result->value, value->value, true); |
| 18104 | return result; | 18142 | return result; |
| 18105 | } else { | 18143 | } else { |
| 18106 | return value; | 18144 | return value; |
| ... | @@ -18126,7 +18164,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18126,7 +18164,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18126 | } else { | 18164 | } else { |
| 18127 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, | 18165 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, |
| 18128 | this_peer->base.implicit_elem_type); | 18166 | this_peer->base.implicit_elem_type); |
| 18129 | instructions[i]->value.special = ConstValSpecialRuntime; | 18167 | instructions[i]->value->special = ConstValSpecialRuntime; |
| 18130 | } | 18168 | } |
| 18131 | } else { | 18169 | } else { |
| 18132 | instructions[i] = gen_instruction; | 18170 | instructions[i] = gen_instruction; |
| ... | @@ -18147,7 +18185,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18147,7 +18185,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18147 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | 18185 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, |
| 18148 | peer_parent->resolved_type, nullptr, false, false, true); | 18186 | peer_parent->resolved_type, nullptr, false, false, true); |
| 18149 | if (parent_result_loc != nullptr && | 18187 | if (parent_result_loc != nullptr && |
| 18150 | (type_is_invalid(parent_result_loc->value.type) || instr_is_unreachable(parent_result_loc))) | 18188 | (type_is_invalid(parent_result_loc->value->type) || instr_is_unreachable(parent_result_loc))) |
| 18151 | { | 18189 | { |
| 18152 | return parent_result_loc; | 18190 | return parent_result_loc; |
| 18153 | } | 18191 | } |
| ... | @@ -18160,7 +18198,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18160,7 +18198,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18160 | if (instrs_to_move.length != 0) { | 18198 | if (instrs_to_move.length != 0) { |
| 18161 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; | 18199 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; |
| 18162 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 18200 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); |
| 18163 | ir_assert(branch_instruction->value.type->id == ZigTypeIdUnreachable, &phi_instruction->base); | 18201 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base); |
| 18164 | while (instrs_to_move.length != 0) { | 18202 | while (instrs_to_move.length != 0) { |
| 18165 | predecessor->instruction_list.append(instrs_to_move.pop()); | 18203 | predecessor->instruction_list.append(instrs_to_move.pop()); |
| 18166 | } | 18204 | } |
| ... | @@ -18197,10 +18235,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18197,10 +18235,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18197 | IrInstruction *old_value = phi_instruction->incoming_values[i]; | 18235 | IrInstruction *old_value = phi_instruction->incoming_values[i]; |
| 18198 | assert(old_value); | 18236 | assert(old_value); |
| 18199 | IrInstruction *new_value = old_value->child; | 18237 | IrInstruction *new_value = old_value->child; |
| 18200 | if (!new_value || new_value->value.type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) | 18238 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) |
| 18201 | continue; | 18239 | continue; |
| 18202 | | 18240 | |
| 18203 | if (type_is_invalid(new_value->value.type)) | 18241 | if (type_is_invalid(new_value->value->type)) |
| 18204 | return ira->codegen->invalid_instruction; | 18242 | return ira->codegen->invalid_instruction; |
| 18205 | | 18243 | |
| 18206 | | 18244 | |
| ... | @@ -18212,7 +18250,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18212,7 +18250,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18212 | if (new_incoming_blocks.length == 0) { | 18250 | if (new_incoming_blocks.length == 0) { |
| 18213 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 18251 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, |
| 18214 | phi_instruction->base.scope, phi_instruction->base.source_node); | 18252 | phi_instruction->base.scope, phi_instruction->base.source_node); |
| 18215 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18253 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18216 | return ir_finish_anal(ira, result); | 18254 | return ir_finish_anal(ira, result); |
| 18217 | } | 18255 | } |
| 18218 | | 18256 | |
| ... | @@ -18233,7 +18271,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18233,7 +18271,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18233 | if (type_is_invalid(resolved_type)) | 18271 | if (type_is_invalid(resolved_type)) |
| 18234 | return ira->codegen->invalid_instruction; | 18272 | return ira->codegen->invalid_instruction; |
| 18235 | } else { | 18273 | } else { |
| 18236 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value.type; | 18274 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; |
| 18237 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); | 18275 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); |
| 18238 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; | 18276 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; |
| 18239 | } | 18277 | } |
| ... | @@ -18281,14 +18319,14 @@ skip_resolve_peer_types: | ... | @@ -18281,14 +18319,14 @@ skip_resolve_peer_types: |
| 18281 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 18319 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); |
| 18282 | ir_set_cursor_at_end(&ira->new_irb, predecessor); | 18320 | ir_set_cursor_at_end(&ira->new_irb, predecessor); |
| 18283 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | 18321 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 18284 | if (type_is_invalid(casted_value->value.type)) { | 18322 | if (type_is_invalid(casted_value->value->type)) { |
| 18285 | return ira->codegen->invalid_instruction; | 18323 | return ira->codegen->invalid_instruction; |
| 18286 | } | 18324 | } |
| 18287 | new_incoming_values.items[i] = casted_value; | 18325 | new_incoming_values.items[i] = casted_value; |
| 18288 | predecessor->instruction_list.append(branch_instruction); | 18326 | predecessor->instruction_list.append(branch_instruction); |
| 18289 | | 18327 | |
| 18290 | if (all_stack_ptrs && (casted_value->value.special != ConstValSpecialRuntime || | 18328 | if (all_stack_ptrs && (casted_value->value->special != ConstValSpecialRuntime || |
| 18291 | casted_value->value.data.rh_ptr != RuntimeHintPtrStack)) | 18329 | casted_value->value->data.rh_ptr != RuntimeHintPtrStack)) |
| 18292 | { | 18330 | { |
| 18293 | all_stack_ptrs = false; | 18331 | all_stack_ptrs = false; |
| 18294 | } | 18332 | } |
| ... | @@ -18298,11 +18336,11 @@ skip_resolve_peer_types: | ... | @@ -18298,11 +18336,11 @@ skip_resolve_peer_types: |
| 18298 | IrInstruction *result = ir_build_phi(&ira->new_irb, | 18336 | IrInstruction *result = ir_build_phi(&ira->new_irb, |
| 18299 | phi_instruction->base.scope, phi_instruction->base.source_node, | 18337 | phi_instruction->base.scope, phi_instruction->base.source_node, |
| 18300 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); | 18338 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); |
| 18301 | result->value.type = resolved_type; | 18339 | result->value->type = resolved_type; |
| 18302 | | 18340 | |
| 18303 | if (all_stack_ptrs) { | 18341 | if (all_stack_ptrs) { |
| 18304 | assert(result->value.special == ConstValSpecialRuntime); | 18342 | assert(result->value->special == ConstValSpecialRuntime); |
| 18305 | result->value.data.rh_ptr = RuntimeHintPtrStack; | 18343 | result->value->data.rh_ptr = RuntimeHintPtrStack; |
| 18306 | } | 18344 | } |
| 18307 | | 18345 | |
| 18308 | return result; | 18346 | return result; |
| ... | @@ -18358,13 +18396,13 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { | ... | @@ -18358,13 +18396,13 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { |
| 18358 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { | 18396 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { |
| 18359 | Error err; | 18397 | Error err; |
| 18360 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; | 18398 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; |
| 18361 | if (type_is_invalid(array_ptr->value.type)) | 18399 | if (type_is_invalid(array_ptr->value->type)) |
| 18362 | return ira->codegen->invalid_instruction; | 18400 | return ira->codegen->invalid_instruction; |
| 18363 | | 18401 | |
| 18364 | ConstExprValue *orig_array_ptr_val = &array_ptr->value; | 18402 | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 18365 | | 18403 | |
| 18366 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; | 18404 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; |
| 18367 | if (type_is_invalid(elem_index->value.type)) | 18405 | if (type_is_invalid(elem_index->value->type)) |
| 18368 | return ira->codegen->invalid_instruction; | 18406 | return ira->codegen->invalid_instruction; |
| 18369 | | 18407 | |
| 18370 | ZigType *ptr_type = orig_array_ptr_val->type; | 18408 | ZigType *ptr_type = orig_array_ptr_val->type; |
| ... | @@ -18428,10 +18466,10 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18428,10 +18466,10 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18428 | return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index]->type_entry, | 18466 | return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index]->type_entry, |
| 18429 | elem_ptr_instruction->ptr_len); | 18467 | elem_ptr_instruction->ptr_len); |
| 18430 | } else if (array_type->id == ZigTypeIdArgTuple) { | 18468 | } else if (array_type->id == ZigTypeIdArgTuple) { |
| 18431 | ConstExprValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); | 18469 | ZigValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); |
| 18432 | if (!ptr_val) | 18470 | if (!ptr_val) |
| 18433 | return ira->codegen->invalid_instruction; | 18471 | return ira->codegen->invalid_instruction; |
| 18434 | ConstExprValue *args_val = const_ptr_pointee(ira, ira->codegen, ptr_val, elem_ptr_instruction->base.source_node); | 18472 | ZigValue *args_val = const_ptr_pointee(ira, ira->codegen, ptr_val, elem_ptr_instruction->base.source_node); |
| 18435 | if (args_val == nullptr) | 18473 | if (args_val == nullptr) |
| 18436 | return ira->codegen->invalid_instruction; | 18474 | return ira->codegen->invalid_instruction; |
| 18437 | size_t start = args_val->data.x_arg_tuple.start_index; | 18475 | size_t start = args_val->data.x_arg_tuple.start_index; |
| ... | @@ -18471,7 +18509,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18471,7 +18509,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18471 | return ira->codegen->invalid_instruction; | 18509 | return ira->codegen->invalid_instruction; |
| 18472 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); | 18510 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); |
| 18473 | Buf *field_name = buf_alloc(); | 18511 | Buf *field_name = buf_alloc(); |
| 18474 | bigint_append_buf(field_name, &casted_elem_index->value.data.x_bigint, 10); | 18512 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); |
| 18475 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, | 18513 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, |
| 18476 | array_ptr, array_type); | 18514 | array_ptr, array_type); |
| 18477 | } else { | 18515 | } else { |
| ... | @@ -18487,13 +18525,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18487,13 +18525,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18487 | | 18525 | |
| 18488 | bool safety_check_on = elem_ptr_instruction->safety_check_on; | 18526 | bool safety_check_on = elem_ptr_instruction->safety_check_on; |
| 18489 | if (instr_is_comptime(casted_elem_index)) { | 18527 | if (instr_is_comptime(casted_elem_index)) { |
| 18490 | uint64_t index = bigint_as_u64(&casted_elem_index->value.data.x_bigint); | 18528 | uint64_t index = bigint_as_u64(&casted_elem_index->value->data.x_bigint); |
| 18491 | if (array_type->id == ZigTypeIdArray) { | 18529 | if (array_type->id == ZigTypeIdArray) { |
| 18492 | uint64_t array_len = array_type->data.array.len; | 18530 | uint64_t array_len = array_type->data.array.len; |
| 18493 | if (index == array_len && array_type->data.array.sentinel != nullptr) { | 18531 | if (index == array_len && array_type->data.array.sentinel != nullptr) { |
| 18494 | ZigType *elem_type = array_type->data.array.child_type; | 18532 | ZigType *elem_type = array_type->data.array.child_type; |
| 18495 | IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type); | 18533 | 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); | 18534 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel, false); |
| 18497 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); | 18535 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); |
| 18498 | } | 18536 | } |
| 18499 | if (index >= array_len) { | 18537 | if (index >= array_len) { |
| ... | @@ -18544,7 +18582,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18544,7 +18582,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18544 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || | 18582 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || |
| 18545 | array_type->id == ZigTypeIdArray)) | 18583 | array_type->id == ZigTypeIdArray)) |
| 18546 | { | 18584 | { |
| 18547 | ConstExprValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 18585 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 18548 | elem_ptr_instruction->base.source_node); | 18586 | elem_ptr_instruction->base.source_node); |
| 18549 | if (array_ptr_val == nullptr) | 18587 | if (array_ptr_val == nullptr) |
| 18550 | return ira->codegen->invalid_instruction; | 18588 | return ira->codegen->invalid_instruction; |
| ... | @@ -18557,7 +18595,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18557,7 +18595,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18557 | array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len); | 18595 | array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len); |
| 18558 | array_ptr_val->special = ConstValSpecialStatic; | 18596 | array_ptr_val->special = ConstValSpecialStatic; |
| 18559 | for (size_t i = 0; i < array_type->data.array.len; i += 1) { | 18597 | for (size_t i = 0; i < array_type->data.array.len; i += 1) { |
| 18560 | ConstExprValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i]; | 18598 | ZigValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i]; |
| 18561 | elem_val->special = ConstValSpecialUndef; | 18599 | elem_val->special = ConstValSpecialUndef; |
| 18562 | elem_val->type = array_type->data.array.child_type; | 18600 | elem_val->type = array_type->data.array.child_type; |
| 18563 | elem_val->parent.id = ConstParentIdArray; | 18601 | elem_val->parent.id = ConstParentIdArray; |
| ... | @@ -18565,8 +18603,8 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18565,8 +18603,8 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18565 | elem_val->parent.data.p_array.elem_index = i; | 18603 | elem_val->parent.data.p_array.elem_index = i; |
| 18566 | } | 18604 | } |
| 18567 | } else if (is_slice(array_type)) { | 18605 | } else if (is_slice(array_type)) { |
| 18568 | ir_assert(array_ptr->value.type->id == ZigTypeIdPointer, &elem_ptr_instruction->base); | 18606 | 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; | 18607 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; |
| 18570 | | 18608 | |
| 18571 | if (type_is_invalid(actual_array_type)) | 18609 | if (type_is_invalid(actual_array_type)) |
| 18572 | return ira->codegen->invalid_instruction; | 18610 | return ira->codegen->invalid_instruction; |
| ... | @@ -18576,14 +18614,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18576,14 +18614,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18576 | return ira->codegen->invalid_instruction; | 18614 | return ira->codegen->invalid_instruction; |
| 18577 | } | 18615 | } |
| 18578 | | 18616 | |
| 18579 | ConstExprValue *array_init_val = create_const_vals(1); | 18617 | ZigValue *array_init_val = create_const_vals(1); |
| 18580 | array_init_val->special = ConstValSpecialStatic; | 18618 | array_init_val->special = ConstValSpecialStatic; |
| 18581 | array_init_val->type = actual_array_type; | 18619 | array_init_val->type = actual_array_type; |
| 18582 | array_init_val->data.x_array.special = ConstArraySpecialNone; | 18620 | array_init_val->data.x_array.special = ConstArraySpecialNone; |
| 18583 | array_init_val->data.x_array.data.s_none.elements = create_const_vals(actual_array_type->data.array.len); | 18621 | array_init_val->data.x_array.data.s_none.elements = create_const_vals(actual_array_type->data.array.len); |
| 18584 | array_init_val->special = ConstValSpecialStatic; | 18622 | array_init_val->special = ConstValSpecialStatic; |
| 18585 | for (size_t i = 0; i < actual_array_type->data.array.len; i += 1) { | 18623 | for (size_t i = 0; i < actual_array_type->data.array.len; i += 1) { |
| 18586 | ConstExprValue *elem_val = &array_init_val->data.x_array.data.s_none.elements[i]; | 18624 | ZigValue *elem_val = &array_init_val->data.x_array.data.s_none.elements[i]; |
| 18587 | elem_val->special = ConstValSpecialUndef; | 18625 | elem_val->special = ConstValSpecialUndef; |
| 18588 | elem_val->type = actual_array_type->data.array.child_type; | 18626 | elem_val->type = actual_array_type->data.array.child_type; |
| 18589 | elem_val->parent.id = ConstParentIdArray; | 18627 | elem_val->parent.id = ConstParentIdArray; |
| ... | @@ -18608,7 +18646,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18608,7 +18646,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18608 | { | 18646 | { |
| 18609 | if (array_type->id == ZigTypeIdPointer) { | 18647 | if (array_type->id == ZigTypeIdPointer) { |
| 18610 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18648 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18611 | ConstExprValue *out_val = &result->value; | 18649 | ZigValue *out_val = result->value; |
| 18612 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 18650 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 18613 | size_t new_index; | 18651 | size_t new_index; |
| 18614 | size_t mem_size; | 18652 | size_t mem_size; |
| ... | @@ -18619,7 +18657,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18619,7 +18657,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18619 | zig_unreachable(); | 18657 | zig_unreachable(); |
| 18620 | case ConstPtrSpecialRef: | 18658 | case ConstPtrSpecialRef: |
| 18621 | if (array_ptr_val->data.x_ptr.data.ref.pointee->type->id == ZigTypeIdArray) { | 18659 | if (array_ptr_val->data.x_ptr.data.ref.pointee->type->id == ZigTypeIdArray) { |
| 18622 | ConstExprValue *array_val = array_ptr_val->data.x_ptr.data.ref.pointee; | 18660 | ZigValue *array_val = array_ptr_val->data.x_ptr.data.ref.pointee; |
| 18623 | new_index = index; | 18661 | new_index = index; |
| 18624 | ZigType *array_type = array_val->type; | 18662 | ZigType *array_type = array_val->type; |
| 18625 | mem_size = array_type->data.array.len; | 18663 | mem_size = array_type->data.array.len; |
| ... | @@ -18682,18 +18720,18 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18682,18 +18720,18 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18682 | } | 18720 | } |
| 18683 | return result; | 18721 | return result; |
| 18684 | } else if (is_slice(array_type)) { | 18722 | } else if (is_slice(array_type)) { |
| 18685 | ConstExprValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; | 18723 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 18686 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); | 18724 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); |
| 18687 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 18725 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 18688 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18726 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18689 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, | 18727 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, |
| 18690 | elem_ptr_instruction->ptr_len, nullptr); | 18728 | elem_ptr_instruction->ptr_len, nullptr); |
| 18691 | result->value.type = return_type; | 18729 | result->value->type = return_type; |
| 18692 | return result; | 18730 | return result; |
| 18693 | } | 18731 | } |
| 18694 | ConstExprValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; | 18732 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 18695 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18733 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18696 | ConstExprValue *out_val = &result->value; | 18734 | ZigValue *out_val = result->value; |
| 18697 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; | 18735 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 18698 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); | 18736 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 18699 | uint64_t full_slice_len = slice_len + | 18737 | uint64_t full_slice_len = slice_len + |
| ... | @@ -18752,12 +18790,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18752,12 +18790,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18752 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18790 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18753 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, | 18791 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, |
| 18754 | false, elem_ptr_instruction->ptr_len, nullptr); | 18792 | false, elem_ptr_instruction->ptr_len, nullptr); |
| 18755 | result->value.type = return_type; | 18793 | result->value->type = return_type; |
| 18756 | result->value.special = ConstValSpecialStatic; | 18794 | result->value->special = ConstValSpecialStatic; |
| 18757 | } else { | 18795 | } else { |
| 18758 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18796 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18759 | } | 18797 | } |
| 18760 | ConstExprValue *out_val = &result->value; | 18798 | ZigValue *out_val = result->value; |
| 18761 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 18799 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 18762 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; | 18800 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; |
| 18763 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; | 18801 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; |
| ... | @@ -18814,7 +18852,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18814,7 +18852,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18814 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18852 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18815 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, | 18853 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, |
| 18816 | elem_ptr_instruction->ptr_len, nullptr); | 18854 | elem_ptr_instruction->ptr_len, nullptr); |
| 18817 | result->value.type = return_type; | 18855 | result->value->type = return_type; |
| 18818 | return result; | 18856 | return result; |
| 18819 | } | 18857 | } |
| 18820 | | 18858 | |
| ... | @@ -18892,8 +18930,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18892,8 +18930,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18892 | case OnePossibleValueNo: | 18930 | case OnePossibleValueNo: |
| 18893 | break; | 18931 | break; |
| 18894 | } | 18932 | } |
| 18895 | bool is_const = struct_ptr->value.type->data.pointer.is_const; | 18933 | bool is_const = struct_ptr->value->type->data.pointer.is_const; |
| 18896 | bool is_volatile = struct_ptr->value.type->data.pointer.is_volatile; | 18934 | bool is_volatile = struct_ptr->value->type->data.pointer.is_volatile; |
| 18897 | ZigType *ptr_type; | 18935 | ZigType *ptr_type; |
| 18898 | if (struct_type->data.structure.is_inferred) { | 18936 | if (struct_type->data.structure.is_inferred) { |
| 18899 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 18937 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| ... | @@ -18904,9 +18942,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18904,9 +18942,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18904 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; | 18942 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; |
| 18905 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) | 18943 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) |
| 18906 | return ira->codegen->invalid_instruction; | 18944 | return ira->codegen->invalid_instruction; |
| 18907 | assert(struct_ptr->value.type->id == ZigTypeIdPointer); | 18945 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); |
| 18908 | uint32_t ptr_bit_offset = struct_ptr->value.type->data.pointer.bit_offset_in_host; | 18946 | 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; | 18947 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; |
| 18910 | uint32_t host_int_bytes_for_result_type = (ptr_host_int_bytes == 0) ? | 18948 | uint32_t host_int_bytes_for_result_type = (ptr_host_int_bytes == 0) ? |
| 18911 | get_host_int_bytes(ira->codegen, struct_type, field) : ptr_host_int_bytes; | 18949 | get_host_int_bytes(ira->codegen, struct_type, field) : ptr_host_int_bytes; |
| 18912 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 18950 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| ... | @@ -18915,12 +18953,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18915,12 +18953,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18915 | (uint32_t)host_int_bytes_for_result_type, false); | 18953 | (uint32_t)host_int_bytes_for_result_type, false); |
| 18916 | } | 18954 | } |
| 18917 | if (instr_is_comptime(struct_ptr)) { | 18955 | if (instr_is_comptime(struct_ptr)) { |
| 18918 | ConstExprValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); | 18956 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); |
| 18919 | if (!ptr_val) | 18957 | if (!ptr_val) |
| 18920 | return ira->codegen->invalid_instruction; | 18958 | return ira->codegen->invalid_instruction; |
| 18921 | | 18959 | |
| 18922 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 18960 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 18923 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 18961 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 18924 | if (struct_val == nullptr) | 18962 | if (struct_val == nullptr) |
| 18925 | return ira->codegen->invalid_instruction; | 18963 | return ira->codegen->invalid_instruction; |
| 18926 | if (type_is_invalid(struct_val->type)) | 18964 | if (type_is_invalid(struct_val->type)) |
| ... | @@ -18929,7 +18967,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18929,7 +18967,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18929 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); | 18967 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 18930 | struct_val->special = ConstValSpecialStatic; | 18968 | struct_val->special = ConstValSpecialStatic; |
| 18931 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { | 18969 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { |
| 18932 | ConstExprValue *field_val = struct_val->data.x_struct.fields[i]; | 18970 | ZigValue *field_val = struct_val->data.x_struct.fields[i]; |
| 18933 | field_val->special = ConstValSpecialUndef; | 18971 | field_val->special = ConstValSpecialUndef; |
| 18934 | field_val->type = resolve_struct_field_type(ira->codegen, | 18972 | field_val->type = resolve_struct_field_type(ira->codegen, |
| 18935 | struct_type->data.structure.fields[i]); | 18973 | struct_type->data.structure.fields[i]); |
| ... | @@ -18942,12 +18980,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18942,12 +18980,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18942 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 18980 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 18943 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, | 18981 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, |
| 18944 | source_instr->source_node, struct_ptr, field); | 18982 | source_instr->source_node, struct_ptr, field); |
| 18945 | result->value.type = ptr_type; | 18983 | result->value->type = ptr_type; |
| 18946 | result->value.special = ConstValSpecialStatic; | 18984 | result->value->special = ConstValSpecialStatic; |
| 18947 | } else { | 18985 | } else { |
| 18948 | result = ir_const(ira, source_instr, ptr_type); | 18986 | result = ir_const(ira, source_instr, ptr_type); |
| 18949 | } | 18987 | } |
| 18950 | ConstExprValue *const_val = &result->value; | 18988 | ZigValue *const_val = result->value; |
| 18951 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; | 18989 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; |
| 18952 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 18990 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 18953 | const_val->data.x_ptr.data.base_struct.struct_val = struct_val; | 18991 | const_val->data.x_ptr.data.base_struct.struct_val = struct_val; |
| ... | @@ -18957,7 +18995,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18957,7 +18995,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18957 | } | 18995 | } |
| 18958 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, | 18996 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 18959 | struct_ptr, field); | 18997 | struct_ptr, field); |
| 18960 | result->value.type = ptr_type; | 18998 | result->value->type = ptr_type; |
| 18961 | return result; | 18999 | return result; |
| 18962 | } | 19000 | } |
| 18963 | | 19001 | |
| ... | @@ -18970,7 +19008,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -18970,7 +19008,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 18970 | // the field type will then be available, and the field will be added to the inferred | 19008 | // the field type will then be available, and the field will be added to the inferred |
| 18971 | // struct. | 19009 | // struct. |
| 18972 | | 19010 | |
| 18973 | ZigType *container_ptr_type = container_ptr->value.type; | 19011 | ZigType *container_ptr_type = container_ptr->value->type; |
| 18974 | ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr); | 19012 | ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr); |
| 18975 | | 19013 | |
| 18976 | InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField"); | 19014 | InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField"); |
| ... | @@ -18984,14 +19022,14 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -18984,14 +19022,14 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 18984 | | 19022 | |
| 18985 | if (instr_is_comptime(container_ptr)) { | 19023 | if (instr_is_comptime(container_ptr)) { |
| 18986 | IrInstruction *result = ir_const(ira, source_instr, field_ptr_type); | 19024 | IrInstruction *result = ir_const(ira, source_instr, field_ptr_type); |
| 18987 | copy_const_val(&result->value, &container_ptr->value, false); | 19025 | copy_const_val(result->value, container_ptr->value, false); |
| 18988 | result->value.type = field_ptr_type; | 19026 | result->value->type = field_ptr_type; |
| 18989 | return result; | 19027 | return result; |
| 18990 | } | 19028 | } |
| 18991 | | 19029 | |
| 18992 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, | 19030 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, |
| 18993 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); | 19031 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); |
| 18994 | result->value.type = field_ptr_type; | 19032 | result->value->type = field_ptr_type; |
| 18995 | return result; | 19033 | return result; |
| 18996 | } | 19034 | } |
| 18997 | | 19035 | |
| ... | @@ -19011,7 +19049,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19011,7 +19049,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19011 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) | 19049 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) |
| 19012 | return ira->codegen->invalid_instruction; | 19050 | return ira->codegen->invalid_instruction; |
| 19013 | | 19051 | |
| 19014 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19052 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19015 | if (bare_type->id == ZigTypeIdStruct) { | 19053 | if (bare_type->id == ZigTypeIdStruct) { |
| 19016 | TypeStructField *field = find_struct_type_field(bare_type, field_name); | 19054 | TypeStructField *field = find_struct_type_field(bare_type, field_name); |
| 19017 | if (field != nullptr) { | 19055 | if (field != nullptr) { |
| ... | @@ -19028,8 +19066,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19028,8 +19066,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19028 | } | 19066 | } |
| 19029 | | 19067 | |
| 19030 | if (bare_type->id == ZigTypeIdUnion) { | 19068 | if (bare_type->id == ZigTypeIdUnion) { |
| 19031 | bool is_const = container_ptr->value.type->data.pointer.is_const; | 19069 | bool is_const = container_ptr->value->type->data.pointer.is_const; |
| 19032 | bool is_volatile = container_ptr->value.type->data.pointer.is_volatile; | 19070 | bool is_volatile = container_ptr->value->type->data.pointer.is_volatile; |
| 19033 | | 19071 | |
| 19034 | TypeUnionField *field = find_union_type_field(bare_type, field_name); | 19072 | TypeUnionField *field = find_union_type_field(bare_type, field_name); |
| 19035 | if (field == nullptr) { | 19073 | if (field == nullptr) { |
| ... | @@ -19044,20 +19082,20 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19044,20 +19082,20 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19044 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 19082 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| 19045 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 19083 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 19046 | if (instr_is_comptime(container_ptr)) { | 19084 | if (instr_is_comptime(container_ptr)) { |
| 19047 | ConstExprValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19085 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19048 | if (!ptr_val) | 19086 | if (!ptr_val) |
| 19049 | return ira->codegen->invalid_instruction; | 19087 | return ira->codegen->invalid_instruction; |
| 19050 | | 19088 | |
| 19051 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 19089 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 19052 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 19090 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 19053 | ConstExprValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 19091 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 19054 | if (union_val == nullptr) | 19092 | if (union_val == nullptr) |
| 19055 | return ira->codegen->invalid_instruction; | 19093 | return ira->codegen->invalid_instruction; |
| 19056 | if (type_is_invalid(union_val->type)) | 19094 | if (type_is_invalid(union_val->type)) |
| 19057 | return ira->codegen->invalid_instruction; | 19095 | return ira->codegen->invalid_instruction; |
| 19058 | | 19096 | |
| 19059 | if (initializing) { | 19097 | if (initializing) { |
| 19060 | ConstExprValue *payload_val = create_const_vals(1); | 19098 | ZigValue *payload_val = create_const_vals(1); |
| 19061 | payload_val->special = ConstValSpecialUndef; | 19099 | payload_val->special = ConstValSpecialUndef; |
| 19062 | payload_val->type = field_type; | 19100 | payload_val->type = field_type; |
| 19063 | payload_val->parent.id = ConstParentIdUnion; | 19101 | payload_val->parent.id = ConstParentIdUnion; |
| ... | @@ -19079,20 +19117,20 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19079,20 +19117,20 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19079 | } | 19117 | } |
| 19080 | } | 19118 | } |
| 19081 | | 19119 | |
| 19082 | ConstExprValue *payload_val = union_val->data.x_union.payload; | 19120 | ZigValue *payload_val = union_val->data.x_union.payload; |
| 19083 | | 19121 | |
| 19084 | IrInstruction *result; | 19122 | IrInstruction *result; |
| 19085 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 19123 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 19086 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 19124 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, |
| 19087 | source_instr->source_node, container_ptr, field, true, initializing); | 19125 | source_instr->source_node, container_ptr, field, true, initializing); |
| 19088 | result->value.type = ptr_type; | 19126 | result->value->type = ptr_type; |
| 19089 | result->value.special = ConstValSpecialStatic; | 19127 | result->value->special = ConstValSpecialStatic; |
| 19090 | } else { | 19128 | } else { |
| 19091 | result = ir_const(ira, source_instr, ptr_type); | 19129 | result = ir_const(ira, source_instr, ptr_type); |
| 19092 | } | 19130 | } |
| 19093 | ConstExprValue *const_val = &result->value; | 19131 | ZigValue *const_val = result->value; |
| 19094 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 19132 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 19095 | const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut; | 19133 | const_val->data.x_ptr.mut = container_ptr->value->data.x_ptr.mut; |
| 19096 | const_val->data.x_ptr.data.ref.pointee = payload_val; | 19134 | const_val->data.x_ptr.data.ref.pointee = payload_val; |
| 19097 | return result; | 19135 | return result; |
| 19098 | } | 19136 | } |
| ... | @@ -19100,7 +19138,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19100,7 +19138,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19100 | | 19138 | |
| 19101 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 19139 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, |
| 19102 | source_instr->source_node, container_ptr, field, true, initializing); | 19140 | source_instr->source_node, container_ptr, field, true, initializing); |
| 19103 | result->value.type = ptr_type; | 19141 | result->value->type = ptr_type; |
| 19104 | return result; | 19142 | return result; |
| 19105 | } | 19143 | } |
| 19106 | | 19144 | |
| ... | @@ -19205,10 +19243,10 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n | ... | @@ -19205,10 +19243,10 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n |
| 19205 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { | 19243 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { |
| 19206 | Error err; | 19244 | Error err; |
| 19207 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; | 19245 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; |
| 19208 | if (type_is_invalid(container_ptr->value.type)) | 19246 | if (type_is_invalid(container_ptr->value->type)) |
| 19209 | return ira->codegen->invalid_instruction; | 19247 | return ira->codegen->invalid_instruction; |
| 19210 | | 19248 | |
| 19211 | ZigType *container_type = container_ptr->value.type->data.pointer.child_type; | 19249 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; |
| 19212 | | 19250 | |
| 19213 | Buf *field_name = field_ptr_instruction->field_name_buffer; | 19251 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 19214 | if (!field_name) { | 19252 | if (!field_name) { |
| ... | @@ -19224,7 +19262,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19224,7 +19262,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19224 | if (type_is_invalid(container_type)) { | 19262 | if (type_is_invalid(container_type)) { |
| 19225 | return ira->codegen->invalid_instruction; | 19263 | return ira->codegen->invalid_instruction; |
| 19226 | } else if (is_slice(container_type) || is_container_ref(container_type)) { | 19264 | } else if (is_slice(container_type) || is_container_ref(container_type)) { |
| 19227 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19265 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19228 | if (container_type->id == ZigTypeIdPointer) { | 19266 | if (container_type->id == ZigTypeIdPointer) { |
| 19229 | ZigType *bare_type = container_ref_type(container_type); | 19267 | ZigType *bare_type = container_ref_type(container_type); |
| 19230 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); | 19268 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); |
| ... | @@ -19236,7 +19274,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19236,7 +19274,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19236 | } | 19274 | } |
| 19237 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { | 19275 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| 19238 | if (buf_eql_str(field_name, "len")) { | 19276 | if (buf_eql_str(field_name, "len")) { |
| 19239 | ConstExprValue *len_val = create_const_vals(1); | 19277 | ZigValue *len_val = create_const_vals(1); |
| 19240 | if (container_type->id == ZigTypeIdPointer) { | 19278 | if (container_type->id == ZigTypeIdPointer) { |
| 19241 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); | 19279 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); |
| 19242 | } else { | 19280 | } else { |
| ... | @@ -19255,17 +19293,17 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19255,17 +19293,17 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19255 | return ira->codegen->invalid_instruction; | 19293 | return ira->codegen->invalid_instruction; |
| 19256 | } | 19294 | } |
| 19257 | } else if (container_type->id == ZigTypeIdArgTuple) { | 19295 | } else if (container_type->id == ZigTypeIdArgTuple) { |
| 19258 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19296 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19259 | if (!container_ptr_val) | 19297 | if (!container_ptr_val) |
| 19260 | return ira->codegen->invalid_instruction; | 19298 | return ira->codegen->invalid_instruction; |
| 19261 | | 19299 | |
| 19262 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19300 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19263 | ConstExprValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19301 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19264 | if (child_val == nullptr) | 19302 | if (child_val == nullptr) |
| 19265 | return ira->codegen->invalid_instruction; | 19303 | return ira->codegen->invalid_instruction; |
| 19266 | | 19304 | |
| 19267 | if (buf_eql_str(field_name, "len")) { | 19305 | if (buf_eql_str(field_name, "len")) { |
| 19268 | ConstExprValue *len_val = create_const_vals(1); | 19306 | ZigValue *len_val = create_const_vals(1); |
| 19269 | size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index; | 19307 | size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index; |
| 19270 | init_const_usize(ira->codegen, len_val, len); | 19308 | init_const_usize(ira->codegen, len_val, len); |
| 19271 | | 19309 | |
| ... | @@ -19281,12 +19319,12 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19281,12 +19319,12 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19281 | return ira->codegen->invalid_instruction; | 19319 | return ira->codegen->invalid_instruction; |
| 19282 | } | 19320 | } |
| 19283 | } else if (container_type->id == ZigTypeIdMetaType) { | 19321 | } else if (container_type->id == ZigTypeIdMetaType) { |
| 19284 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19322 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19285 | if (!container_ptr_val) | 19323 | if (!container_ptr_val) |
| 19286 | return ira->codegen->invalid_instruction; | 19324 | return ira->codegen->invalid_instruction; |
| 19287 | | 19325 | |
| 19288 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19326 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19289 | ConstExprValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19327 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19290 | if (child_val == nullptr) | 19328 | if (child_val == nullptr) |
| 19291 | return ira->codegen->invalid_instruction; | 19329 | return ira->codegen->invalid_instruction; |
| 19292 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 19330 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| ... | @@ -19382,7 +19420,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19382,7 +19420,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19382 | } | 19420 | } |
| 19383 | err_set_type = child_type; | 19421 | err_set_type = child_type; |
| 19384 | } | 19422 | } |
| 19385 | ConstExprValue *const_val = create_const_vals(1); | 19423 | ZigValue *const_val = create_const_vals(1); |
| 19386 | const_val->special = ConstValSpecialStatic; | 19424 | const_val->special = ConstValSpecialStatic; |
| 19387 | const_val->type = err_set_type; | 19425 | const_val->type = err_set_type; |
| 19388 | const_val->data.x_err_set = err_entry; | 19426 | const_val->data.x_err_set = err_entry; |
| ... | @@ -19567,11 +19605,11 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19567,11 +19605,11 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19567 | | 19605 | |
| 19568 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { | 19606 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { |
| 19569 | IrInstruction *ptr = instruction->ptr->child; | 19607 | IrInstruction *ptr = instruction->ptr->child; |
| 19570 | if (type_is_invalid(ptr->value.type)) | 19608 | if (type_is_invalid(ptr->value->type)) |
| 19571 | return ira->codegen->invalid_instruction; | 19609 | return ira->codegen->invalid_instruction; |
| 19572 | | 19610 | |
| 19573 | IrInstruction *value = instruction->value->child; | 19611 | IrInstruction *value = instruction->value->child; |
| 19574 | if (type_is_invalid(value->value.type)) | 19612 | if (type_is_invalid(value->value->type)) |
| 19575 | return ira->codegen->invalid_instruction; | 19613 | return ira->codegen->invalid_instruction; |
| 19576 | | 19614 | |
| 19577 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); | 19615 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); |
| ... | @@ -19579,14 +19617,14 @@ static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19579,14 +19617,14 @@ static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstruc |
| 19579 | | 19617 | |
| 19580 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { | 19618 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { |
| 19581 | IrInstruction *ptr = instruction->ptr->child; | 19619 | IrInstruction *ptr = instruction->ptr->child; |
| 19582 | if (type_is_invalid(ptr->value.type)) | 19620 | if (type_is_invalid(ptr->value->type)) |
| 19583 | return ira->codegen->invalid_instruction; | 19621 | return ira->codegen->invalid_instruction; |
| 19584 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); | 19622 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); |
| 19585 | } | 19623 | } |
| 19586 | | 19624 | |
| 19587 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { | 19625 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { |
| 19588 | IrInstruction *expr_value = typeof_instruction->value->child; | 19626 | IrInstruction *expr_value = typeof_instruction->value->child; |
| 19589 | ZigType *type_entry = expr_value->value.type; | 19627 | ZigType *type_entry = expr_value->value->type; |
| 19590 | if (type_is_invalid(type_entry)) | 19628 | if (type_is_invalid(type_entry)) |
| 19591 | return ira->codegen->invalid_instruction; | 19629 | return ira->codegen->invalid_instruction; |
| 19592 | return ir_const_type(ira, &typeof_instruction->base, type_entry); | 19630 | return ir_const_type(ira, &typeof_instruction->base, type_entry); |
| ... | @@ -19749,11 +19787,11 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -19749,11 +19787,11 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 19749 | IrInstructionSliceType *slice_type_instruction) | 19787 | IrInstructionSliceType *slice_type_instruction) |
| 19750 | { | 19788 | { |
| 19751 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); | 19789 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); |
| 19752 | result->value.special = ConstValSpecialLazy; | 19790 | result->value->special = ConstValSpecialLazy; |
| 19753 | | 19791 | |
| 19754 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); | 19792 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); |
| 19755 | lazy_slice_type->ira = ira; | 19793 | lazy_slice_type->ira = ira; |
| 19756 | result->value.data.x_lazy = &lazy_slice_type->base; | 19794 | result->value->data.x_lazy = &lazy_slice_type->base; |
| 19757 | lazy_slice_type->base.id = LazyValueIdSliceType; | 19795 | lazy_slice_type->base.id = LazyValueIdSliceType; |
| 19758 | | 19796 | |
| 19759 | if (slice_type_instruction->align_value != nullptr) { | 19797 | if (slice_type_instruction->align_value != nullptr) { |
| ... | @@ -19812,14 +19850,14 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -19812,14 +19850,14 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 19812 | | 19850 | |
| 19813 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 19851 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 19814 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; | 19852 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; |
| 19815 | if (type_is_invalid(input_value->value.type)) | 19853 | if (type_is_invalid(input_value->value->type)) |
| 19816 | return ira->codegen->invalid_instruction; | 19854 | return ira->codegen->invalid_instruction; |
| 19817 | | 19855 | |
| 19818 | if (instr_is_comptime(input_value) && | 19856 | if (instr_is_comptime(input_value) && |
| 19819 | (input_value->value.type->id == ZigTypeIdComptimeInt || | 19857 | (input_value->value->type->id == ZigTypeIdComptimeInt || |
| 19820 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { | 19858 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { |
| 19821 | ir_add_error_node(ira, input_value->source_node, | 19859 | 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))); | 19860 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); |
| 19823 | return ira->codegen->invalid_instruction; | 19861 | return ira->codegen->invalid_instruction; |
| 19824 | } | 19862 | } |
| 19825 | | 19863 | |
| ... | @@ -19831,7 +19869,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -19831,7 +19869,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 19831 | asm_instruction->asm_template, asm_instruction->token_list, asm_instruction->token_list_len, | 19869 | asm_instruction->asm_template, asm_instruction->token_list, asm_instruction->token_list_len, |
| 19832 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, | 19870 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, |
| 19833 | asm_instruction->has_side_effects); | 19871 | asm_instruction->has_side_effects); |
| 19834 | result->value.type = return_type; | 19872 | result->value->type = return_type; |
| 19835 | return result; | 19873 | return result; |
| 19836 | } | 19874 | } |
| 19837 | | 19875 | |
| ... | @@ -19850,13 +19888,13 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -19850,13 +19888,13 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19850 | if (type_is_invalid(child_type)) | 19888 | if (type_is_invalid(child_type)) |
| 19851 | return ira->codegen->invalid_instruction; | 19889 | return ira->codegen->invalid_instruction; |
| 19852 | | 19890 | |
| 19853 | ConstExprValue *sentinel_val; | 19891 | ZigValue *sentinel_val; |
| 19854 | if (array_type_instruction->sentinel != nullptr) { | 19892 | if (array_type_instruction->sentinel != nullptr) { |
| 19855 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; | 19893 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; |
| 19856 | if (type_is_invalid(uncasted_sentinel->value.type)) | 19894 | if (type_is_invalid(uncasted_sentinel->value->type)) |
| 19857 | return ira->codegen->invalid_instruction; | 19895 | return ira->codegen->invalid_instruction; |
| 19858 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type); | 19896 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type); |
| 19859 | if (type_is_invalid(sentinel->value.type)) | 19897 | if (type_is_invalid(sentinel->value->type)) |
| 19860 | return ira->codegen->invalid_instruction; | 19898 | return ira->codegen->invalid_instruction; |
| 19861 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 19899 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 19862 | if (sentinel_val == nullptr) | 19900 | if (sentinel_val == nullptr) |
| ... | @@ -19909,11 +19947,11 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -19909,11 +19947,11 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19909 | | 19947 | |
| 19910 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { | 19948 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { |
| 19911 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 19949 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 19912 | result->value.special = ConstValSpecialLazy; | 19950 | result->value->special = ConstValSpecialLazy; |
| 19913 | | 19951 | |
| 19914 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1); | 19952 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1); |
| 19915 | lazy_size_of->ira = ira; | 19953 | lazy_size_of->ira = ira; |
| 19916 | result->value.data.x_lazy = &lazy_size_of->base; | 19954 | result->value->data.x_lazy = &lazy_size_of->base; |
| 19917 | lazy_size_of->base.id = LazyValueIdSizeOf; | 19955 | lazy_size_of->base.id = LazyValueIdSizeOf; |
| 19918 | | 19956 | |
| 19919 | lazy_size_of->target_type = instruction->type_value->child; | 19957 | lazy_size_of->target_type = instruction->type_value->child; |
| ... | @@ -19924,11 +19962,11 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi | ... | @@ -19924,11 +19962,11 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi |
| 19924 | } | 19962 | } |
| 19925 | | 19963 | |
| 19926 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { | 19964 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { |
| 19927 | ZigType *type_entry = value->value.type; | 19965 | ZigType *type_entry = value->value->type; |
| 19928 | | 19966 | |
| 19929 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { | 19967 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| 19930 | if (instr_is_comptime(value)) { | 19968 | if (instr_is_comptime(value)) { |
| 19931 | ConstExprValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); | 19969 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); |
| 19932 | if (c_ptr_val == nullptr) | 19970 | if (c_ptr_val == nullptr) |
| 19933 | return ira->codegen->invalid_instruction; | 19971 | return ira->codegen->invalid_instruction; |
| 19934 | if (c_ptr_val->special == ConstValSpecialUndef) | 19972 | if (c_ptr_val->special == ConstValSpecialUndef) |
| ... | @@ -19941,11 +19979,11 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19941,11 +19979,11 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19941 | | 19979 | |
| 19942 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 19980 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, |
| 19943 | source_inst->scope, source_inst->source_node, value); | 19981 | source_inst->scope, source_inst->source_node, value); |
| 19944 | result->value.type = ira->codegen->builtin_types.entry_bool; | 19982 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 19945 | return result; | 19983 | return result; |
| 19946 | } else if (type_entry->id == ZigTypeIdOptional) { | 19984 | } else if (type_entry->id == ZigTypeIdOptional) { |
| 19947 | if (instr_is_comptime(value)) { | 19985 | if (instr_is_comptime(value)) { |
| 19948 | ConstExprValue *maybe_val = ir_resolve_const(ira, value, UndefOk); | 19986 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); |
| 19949 | if (maybe_val == nullptr) | 19987 | if (maybe_val == nullptr) |
| 19950 | return ira->codegen->invalid_instruction; | 19988 | return ira->codegen->invalid_instruction; |
| 19951 | if (maybe_val->special == ConstValSpecialUndef) | 19989 | if (maybe_val->special == ConstValSpecialUndef) |
| ... | @@ -19956,7 +19994,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19956,7 +19994,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19956 | | 19994 | |
| 19957 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 19995 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, |
| 19958 | source_inst->scope, source_inst->source_node, value); | 19996 | source_inst->scope, source_inst->source_node, value); |
| 19959 | result->value.type = ira->codegen->builtin_types.entry_bool; | 19997 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 19960 | return result; | 19998 | return result; |
| 19961 | } else if (type_entry->id == ZigTypeIdNull) { | 19999 | } else if (type_entry->id == ZigTypeIdNull) { |
| 19962 | return ir_const_bool(ira, source_inst, false); | 20000 | return ir_const_bool(ira, source_inst, false); |
| ... | @@ -19967,23 +20005,23 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19967,23 +20005,23 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19967 | | 20005 | |
| 19968 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { | 20006 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { |
| 19969 | IrInstruction *value = instruction->value->child; | 20007 | IrInstruction *value = instruction->value->child; |
| 19970 | if (type_is_invalid(value->value.type)) | 20008 | if (type_is_invalid(value->value->type)) |
| 19971 | return ira->codegen->invalid_instruction; | 20009 | return ira->codegen->invalid_instruction; |
| 19972 | | 20010 | |
| 19973 | return ir_analyze_test_non_null(ira, &instruction->base, value); | 20011 | return ir_analyze_test_non_null(ira, &instruction->base, value); |
| 19974 | } | 20012 | } |
| 19975 | | 20013 | |
| 19976 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | 20014 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { |
| 19977 | ir_assert(ptr->value.type->id == ZigTypeIdPointer, ptr); | 20015 | ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 19978 | ZigType *elem_type = ptr->value.type->data.pointer.child_type; | 20016 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 19979 | if (elem_type != g->builtin_types.entry_var) | 20017 | if (elem_type != g->builtin_types.entry_var) |
| 19980 | return elem_type; | 20018 | return elem_type; |
| 19981 | | 20019 | |
| 19982 | if (ir_resolve_lazy(g, ptr->source_node, &ptr->value)) | 20020 | if (ir_resolve_lazy(g, ptr->source_node, ptr->value)) |
| 19983 | return g->builtin_types.entry_invalid; | 20021 | return g->builtin_types.entry_invalid; |
| 19984 | | 20022 | |
| 19985 | assert(value_is_comptime(&ptr->value)); | 20023 | assert(value_is_comptime(ptr->value)); |
| 19986 | ConstExprValue *pointee = const_ptr_pointee_unchecked(g, &ptr->value); | 20024 | ZigValue *pointee = const_ptr_pointee_unchecked(g, ptr->value); |
| 19987 | return pointee->type; | 20025 | return pointee->type; |
| 19988 | } | 20026 | } |
| 19989 | | 20027 | |
| ... | @@ -19996,11 +20034,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -19996,11 +20034,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 19996 | | 20034 | |
| 19997 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { | 20035 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { |
| 19998 | if (instr_is_comptime(base_ptr)) { | 20036 | if (instr_is_comptime(base_ptr)) { |
| 19999 | ConstExprValue *val = ir_resolve_const(ira, base_ptr, UndefBad); | 20037 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 20000 | if (!val) | 20038 | if (!val) |
| 20001 | return ira->codegen->invalid_instruction; | 20039 | return ira->codegen->invalid_instruction; |
| 20002 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20040 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20003 | ConstExprValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 20041 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 20004 | if (c_ptr_val == nullptr) | 20042 | if (c_ptr_val == nullptr) |
| 20005 | return ira->codegen->invalid_instruction; | 20043 | return ira->codegen->invalid_instruction; |
| 20006 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 20044 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -20028,17 +20066,17 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20028,17 +20066,17 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20028 | | 20066 | |
| 20029 | ZigType *child_type = type_entry->data.maybe.child_type; | 20067 | ZigType *child_type = type_entry->data.maybe.child_type; |
| 20030 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type, | 20068 | 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, | 20069 | base_ptr->value->type->data.pointer.is_const, base_ptr->value->type->data.pointer.is_volatile, |
| 20032 | PtrLenSingle, 0, 0, 0, false); | 20070 | PtrLenSingle, 0, 0, 0, false); |
| 20033 | | 20071 | |
| 20034 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); | 20072 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); |
| 20035 | | 20073 | |
| 20036 | if (instr_is_comptime(base_ptr)) { | 20074 | if (instr_is_comptime(base_ptr)) { |
| 20037 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 20075 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 20038 | if (!ptr_val) | 20076 | if (!ptr_val) |
| 20039 | return ira->codegen->invalid_instruction; | 20077 | return ira->codegen->invalid_instruction; |
| 20040 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20078 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20041 | ConstExprValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 20079 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20042 | if (optional_val == nullptr) | 20080 | if (optional_val == nullptr) |
| 20043 | return ira->codegen->invalid_instruction; | 20081 | return ira->codegen->invalid_instruction; |
| 20044 | | 20082 | |
| ... | @@ -20048,7 +20086,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20048,7 +20086,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20048 | return ira->codegen->invalid_instruction; | 20086 | return ira->codegen->invalid_instruction; |
| 20049 | case OnePossibleValueNo: | 20087 | case OnePossibleValueNo: |
| 20050 | if (!same_comptime_repr) { | 20088 | if (!same_comptime_repr) { |
| 20051 | ConstExprValue *payload_val = create_const_vals(1); | 20089 | ZigValue *payload_val = create_const_vals(1); |
| 20052 | payload_val->type = child_type; | 20090 | payload_val->type = child_type; |
| 20053 | payload_val->special = ConstValSpecialUndef; | 20091 | payload_val->special = ConstValSpecialUndef; |
| 20054 | payload_val->parent.id = ConstParentIdOptionalPayload; | 20092 | payload_val->parent.id = ConstParentIdOptionalPayload; |
| ... | @@ -20059,7 +20097,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20059,7 +20097,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20059 | } | 20097 | } |
| 20060 | break; | 20098 | break; |
| 20061 | case OnePossibleValueYes: { | 20099 | case OnePossibleValueYes: { |
| 20062 | ConstExprValue *pointee = create_const_vals(1); | 20100 | ZigValue *pointee = create_const_vals(1); |
| 20063 | pointee->special = ConstValSpecialStatic; | 20101 | pointee->special = ConstValSpecialStatic; |
| 20064 | pointee->type = child_type; | 20102 | pointee->type = child_type; |
| 20065 | pointee->parent.id = ConstParentIdOptionalPayload; | 20103 | pointee->parent.id = ConstParentIdOptionalPayload; |
| ... | @@ -20079,12 +20117,12 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20079,12 +20117,12 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20079 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 20117 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20080 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 20118 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, |
| 20081 | source_instr->source_node, base_ptr, false, initializing); | 20119 | source_instr->source_node, base_ptr, false, initializing); |
| 20082 | result->value.type = result_type; | 20120 | result->value->type = result_type; |
| 20083 | result->value.special = ConstValSpecialStatic; | 20121 | result->value->special = ConstValSpecialStatic; |
| 20084 | } else { | 20122 | } else { |
| 20085 | result = ir_const(ira, source_instr, result_type); | 20123 | result = ir_const(ira, source_instr, result_type); |
| 20086 | } | 20124 | } |
| 20087 | ConstExprValue *result_val = &result->value; | 20125 | ZigValue *result_val = result->value; |
| 20088 | result_val->data.x_ptr.special = ConstPtrSpecialRef; | 20126 | result_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20089 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 20127 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 20090 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 20128 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| ... | @@ -20109,7 +20147,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20109,7 +20147,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20109 | | 20147 | |
| 20110 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 20148 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, |
| 20111 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 20149 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 20112 | result->value.type = result_type; | 20150 | result->value->type = result_type; |
| 20113 | return result; | 20151 | return result; |
| 20114 | } | 20152 | } |
| 20115 | | 20153 | |
| ... | @@ -20117,7 +20155,7 @@ static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | ... | @@ -20117,7 +20155,7 @@ static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, |
| 20117 | IrInstructionOptionalUnwrapPtr *instruction) | 20155 | IrInstructionOptionalUnwrapPtr *instruction) |
| 20118 | { | 20156 | { |
| 20119 | IrInstruction *base_ptr = instruction->base_ptr->child; | 20157 | IrInstruction *base_ptr = instruction->base_ptr->child; |
| 20120 | if (type_is_invalid(base_ptr->value.type)) | 20158 | if (type_is_invalid(base_ptr->value->type)) |
| 20121 | return ira->codegen->invalid_instruction; | 20159 | return ira->codegen->invalid_instruction; |
| 20122 | | 20160 | |
| 20123 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, | 20161 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, |
| ... | @@ -20130,26 +20168,26 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt | ... | @@ -20130,26 +20168,26 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt |
| 20130 | return ira->codegen->invalid_instruction; | 20168 | return ira->codegen->invalid_instruction; |
| 20131 | | 20169 | |
| 20132 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20170 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20133 | if (type_is_invalid(op->value.type)) | 20171 | if (type_is_invalid(op->value->type)) |
| 20134 | return ira->codegen->invalid_instruction; | 20172 | return ira->codegen->invalid_instruction; |
| 20135 | | 20173 | |
| 20136 | if (int_type->data.integral.bit_count == 0) | 20174 | if (int_type->data.integral.bit_count == 0) |
| 20137 | return ir_const_unsigned(ira, &instruction->base, 0); | 20175 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20138 | | 20176 | |
| 20139 | if (instr_is_comptime(op)) { | 20177 | if (instr_is_comptime(op)) { |
| 20140 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20178 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20141 | if (val == nullptr) | 20179 | if (val == nullptr) |
| 20142 | return ira->codegen->invalid_instruction; | 20180 | return ira->codegen->invalid_instruction; |
| 20143 | if (val->special == ConstValSpecialUndef) | 20181 | if (val->special == ConstValSpecialUndef) |
| 20144 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 20182 | 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); | 20183 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 20146 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 20184 | return ir_const_unsigned(ira, &instruction->base, result_usize); |
| 20147 | } | 20185 | } |
| 20148 | | 20186 | |
| 20149 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20187 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20150 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, | 20188 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, |
| 20151 | instruction->base.source_node, nullptr, op); | 20189 | instruction->base.source_node, nullptr, op); |
| 20152 | result->value.type = return_type; | 20190 | result->value->type = return_type; |
| 20153 | return result; | 20191 | return result; |
| 20154 | } | 20192 | } |
| 20155 | | 20193 | |
| ... | @@ -20159,26 +20197,26 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl | ... | @@ -20159,26 +20197,26 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl |
| 20159 | return ira->codegen->invalid_instruction; | 20197 | return ira->codegen->invalid_instruction; |
| 20160 | | 20198 | |
| 20161 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20199 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20162 | if (type_is_invalid(op->value.type)) | 20200 | if (type_is_invalid(op->value->type)) |
| 20163 | return ira->codegen->invalid_instruction; | 20201 | return ira->codegen->invalid_instruction; |
| 20164 | | 20202 | |
| 20165 | if (int_type->data.integral.bit_count == 0) | 20203 | if (int_type->data.integral.bit_count == 0) |
| 20166 | return ir_const_unsigned(ira, &instruction->base, 0); | 20204 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20167 | | 20205 | |
| 20168 | if (instr_is_comptime(op)) { | 20206 | if (instr_is_comptime(op)) { |
| 20169 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20207 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20170 | if (val == nullptr) | 20208 | if (val == nullptr) |
| 20171 | return ira->codegen->invalid_instruction; | 20209 | return ira->codegen->invalid_instruction; |
| 20172 | if (val->special == ConstValSpecialUndef) | 20210 | if (val->special == ConstValSpecialUndef) |
| 20173 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 20211 | 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); | 20212 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 20175 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 20213 | return ir_const_unsigned(ira, &instruction->base, result_usize); |
| 20176 | } | 20214 | } |
| 20177 | | 20215 | |
| 20178 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20216 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20179 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, | 20217 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, |
| 20180 | instruction->base.source_node, nullptr, op); | 20218 | instruction->base.source_node, nullptr, op); |
| 20181 | result->value.type = return_type; | 20219 | result->value->type = return_type; |
| 20182 | return result; | 20220 | return result; |
| 20183 | } | 20221 | } |
| 20184 | | 20222 | |
| ... | @@ -20188,14 +20226,14 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc | ... | @@ -20188,14 +20226,14 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20188 | return ira->codegen->invalid_instruction; | 20226 | return ira->codegen->invalid_instruction; |
| 20189 | | 20227 | |
| 20190 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20228 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20191 | if (type_is_invalid(op->value.type)) | 20229 | if (type_is_invalid(op->value->type)) |
| 20192 | return ira->codegen->invalid_instruction; | 20230 | return ira->codegen->invalid_instruction; |
| 20193 | | 20231 | |
| 20194 | if (int_type->data.integral.bit_count == 0) | 20232 | if (int_type->data.integral.bit_count == 0) |
| 20195 | return ir_const_unsigned(ira, &instruction->base, 0); | 20233 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20196 | | 20234 | |
| 20197 | if (instr_is_comptime(op)) { | 20235 | if (instr_is_comptime(op)) { |
| 20198 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20236 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20199 | if (val == nullptr) | 20237 | if (val == nullptr) |
| 20200 | return ira->codegen->invalid_instruction; | 20238 | return ira->codegen->invalid_instruction; |
| 20201 | if (val->special == ConstValSpecialUndef) | 20239 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -20212,50 +20250,50 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc | ... | @@ -20212,50 +20250,50 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20212 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20250 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20213 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, | 20251 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, |
| 20214 | instruction->base.source_node, nullptr, op); | 20252 | instruction->base.source_node, nullptr, op); |
| 20215 | result->value.type = return_type; | 20253 | result->value->type = return_type; |
| 20216 | return result; | 20254 | return result; |
| 20217 | } | 20255 | } |
| 20218 | | 20256 | |
| 20219 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { | 20257 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { |
| 20220 | if (type_is_invalid(value->value.type)) | 20258 | if (type_is_invalid(value->value->type)) |
| 20221 | return ira->codegen->invalid_instruction; | 20259 | return ira->codegen->invalid_instruction; |
| 20222 | | 20260 | |
| 20223 | if (value->value.type->id == ZigTypeIdEnum) { | 20261 | if (value->value->type->id == ZigTypeIdEnum) { |
| 20224 | return value; | 20262 | return value; |
| 20225 | } | 20263 | } |
| 20226 | | 20264 | |
| 20227 | if (value->value.type->id != ZigTypeIdUnion) { | 20265 | if (value->value->type->id != ZigTypeIdUnion) { |
| 20228 | ir_add_error(ira, value, | 20266 | ir_add_error(ira, value, |
| 20229 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name))); | 20267 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); |
| 20230 | return ira->codegen->invalid_instruction; | 20268 | return ira->codegen->invalid_instruction; |
| 20231 | } | 20269 | } |
| 20232 | if (!value->value.type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { | 20270 | if (!value->value->type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { |
| 20233 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); | 20271 | 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) { | 20272 | if (value->value->type->data.unionation.decl_node != nullptr) { |
| 20235 | add_error_note(ira->codegen, msg, value->value.type->data.unionation.decl_node, | 20273 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, |
| 20236 | buf_sprintf("declared here")); | 20274 | buf_sprintf("declared here")); |
| 20237 | } | 20275 | } |
| 20238 | return ira->codegen->invalid_instruction; | 20276 | return ira->codegen->invalid_instruction; |
| 20239 | } | 20277 | } |
| 20240 | | 20278 | |
| 20241 | ZigType *tag_type = value->value.type->data.unionation.tag_type; | 20279 | ZigType *tag_type = value->value->type->data.unionation.tag_type; |
| 20242 | assert(tag_type->id == ZigTypeIdEnum); | 20280 | assert(tag_type->id == ZigTypeIdEnum); |
| 20243 | | 20281 | |
| 20244 | if (instr_is_comptime(value)) { | 20282 | if (instr_is_comptime(value)) { |
| 20245 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 20283 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 20246 | if (!val) | 20284 | if (!val) |
| 20247 | return ira->codegen->invalid_instruction; | 20285 | return ira->codegen->invalid_instruction; |
| 20248 | | 20286 | |
| 20249 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 20287 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 20250 | source_instr->scope, source_instr->source_node); | 20288 | source_instr->scope, source_instr->source_node); |
| 20251 | const_instruction->base.value.type = tag_type; | 20289 | const_instruction->base.value->type = tag_type; |
| 20252 | const_instruction->base.value.special = ConstValSpecialStatic; | 20290 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 20253 | bigint_init_bigint(&const_instruction->base.value.data.x_enum_tag, &val->data.x_union.tag); | 20291 | bigint_init_bigint(&const_instruction->base.value->data.x_enum_tag, &val->data.x_union.tag); |
| 20254 | return &const_instruction->base; | 20292 | return &const_instruction->base; |
| 20255 | } | 20293 | } |
| 20256 | | 20294 | |
| 20257 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); | 20295 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); |
| 20258 | result->value.type = tag_type; | 20296 | result->value->type = tag_type; |
| 20259 | return result; | 20297 | return result; |
| 20260 | } | 20298 | } |
| 20261 | | 20299 | |
| ... | @@ -20263,11 +20301,11 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20263,11 +20301,11 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20263 | IrInstructionSwitchBr *switch_br_instruction) | 20301 | IrInstructionSwitchBr *switch_br_instruction) |
| 20264 | { | 20302 | { |
| 20265 | IrInstruction *target_value = switch_br_instruction->target_value->child; | 20303 | IrInstruction *target_value = switch_br_instruction->target_value->child; |
| 20266 | if (type_is_invalid(target_value->value.type)) | 20304 | if (type_is_invalid(target_value->value->type)) |
| 20267 | return ir_unreach_error(ira); | 20305 | return ir_unreach_error(ira); |
| 20268 | | 20306 | |
| 20269 | if (switch_br_instruction->switch_prongs_void != nullptr) { | 20307 | if (switch_br_instruction->switch_prongs_void != nullptr) { |
| 20270 | if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value.type)) { | 20308 | if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value->type)) { |
| 20271 | return ir_unreach_error(ira); | 20309 | return ir_unreach_error(ira); |
| 20272 | } | 20310 | } |
| 20273 | } | 20311 | } |
| ... | @@ -20280,7 +20318,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20280,7 +20318,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20280 | return ira->codegen->invalid_instruction; | 20318 | return ira->codegen->invalid_instruction; |
| 20281 | | 20319 | |
| 20282 | if (is_comptime || instr_is_comptime(target_value)) { | 20320 | if (is_comptime || instr_is_comptime(target_value)) { |
| 20283 | ConstExprValue *target_val = ir_resolve_const(ira, target_value, UndefBad); | 20321 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); |
| 20284 | if (!target_val) | 20322 | if (!target_val) |
| 20285 | return ir_unreach_error(ira); | 20323 | return ir_unreach_error(ira); |
| 20286 | | 20324 | |
| ... | @@ -20288,20 +20326,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20288,20 +20326,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20288 | for (size_t i = 0; i < case_count; i += 1) { | 20326 | for (size_t i = 0; i < case_count; i += 1) { |
| 20289 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 20327 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 20290 | IrInstruction *case_value = old_case->value->child; | 20328 | IrInstruction *case_value = old_case->value->child; |
| 20291 | if (type_is_invalid(case_value->value.type)) | 20329 | if (type_is_invalid(case_value->value->type)) |
| 20292 | return ir_unreach_error(ira); | 20330 | return ir_unreach_error(ira); |
| 20293 | | 20331 | |
| 20294 | if (case_value->value.type->id == ZigTypeIdEnum) { | 20332 | if (case_value->value->type->id == ZigTypeIdEnum) { |
| 20295 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); | 20333 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); |
| 20296 | if (type_is_invalid(case_value->value.type)) | 20334 | if (type_is_invalid(case_value->value->type)) |
| 20297 | return ir_unreach_error(ira); | 20335 | return ir_unreach_error(ira); |
| 20298 | } | 20336 | } |
| 20299 | | 20337 | |
| 20300 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type); | 20338 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); |
| 20301 | if (type_is_invalid(casted_case_value->value.type)) | 20339 | if (type_is_invalid(casted_case_value->value->type)) |
| 20302 | return ir_unreach_error(ira); | 20340 | return ir_unreach_error(ira); |
| 20303 | | 20341 | |
| 20304 | ConstExprValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); | 20342 | ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); |
| 20305 | if (!case_val) | 20343 | if (!case_val) |
| 20306 | return ir_unreach_error(ira); | 20344 | return ir_unreach_error(ira); |
| 20307 | | 20345 | |
| ... | @@ -20318,7 +20356,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20318,7 +20356,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20318 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20356 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 20319 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 20357 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, |
| 20320 | new_dest_block, nullptr); | 20358 | new_dest_block, nullptr); |
| 20321 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 20359 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 20322 | return ir_finish_anal(ira, result); | 20360 | return ir_finish_anal(ira, result); |
| 20323 | } | 20361 | } |
| 20324 | } | 20362 | } |
| ... | @@ -20338,17 +20376,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20338,17 +20376,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20338 | | 20376 | |
| 20339 | IrInstruction *old_value = old_case->value; | 20377 | IrInstruction *old_value = old_case->value; |
| 20340 | IrInstruction *new_value = old_value->child; | 20378 | IrInstruction *new_value = old_value->child; |
| 20341 | if (type_is_invalid(new_value->value.type)) | 20379 | if (type_is_invalid(new_value->value->type)) |
| 20342 | continue; | 20380 | continue; |
| 20343 | | 20381 | |
| 20344 | if (new_value->value.type->id == ZigTypeIdEnum) { | 20382 | if (new_value->value->type->id == ZigTypeIdEnum) { |
| 20345 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); | 20383 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); |
| 20346 | if (type_is_invalid(new_value->value.type)) | 20384 | if (type_is_invalid(new_value->value->type)) |
| 20347 | continue; | 20385 | continue; |
| 20348 | } | 20386 | } |
| 20349 | | 20387 | |
| 20350 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type); | 20388 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); |
| 20351 | if (type_is_invalid(casted_new_value->value.type)) | 20389 | if (type_is_invalid(casted_new_value->value->type)) |
| 20352 | continue; | 20390 | continue; |
| 20353 | | 20391 | |
| 20354 | if (!ir_resolve_const(ira, casted_new_value, UndefBad)) | 20392 | if (!ir_resolve_const(ira, casted_new_value, UndefBad)) |
| ... | @@ -20368,7 +20406,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20368,7 +20406,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20368 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, | 20406 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, |
| 20369 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 20407 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, |
| 20370 | target_value, new_else_block, case_count, cases, nullptr, nullptr); | 20408 | target_value, new_else_block, case_count, cases, nullptr, nullptr); |
| 20371 | switch_br->base.value.type = ira->codegen->builtin_types.entry_unreachable; | 20409 | switch_br->base.value->type = ira->codegen->builtin_types.entry_unreachable; |
| 20372 | return ir_finish_anal(ira, &switch_br->base); | 20410 | return ir_finish_anal(ira, &switch_br->base); |
| 20373 | } | 20411 | } |
| 20374 | | 20412 | |
| ... | @@ -20377,20 +20415,20 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20377,20 +20415,20 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20377 | { | 20415 | { |
| 20378 | Error err; | 20416 | Error err; |
| 20379 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; | 20417 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; |
| 20380 | if (type_is_invalid(target_value_ptr->value.type)) | 20418 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20381 | return ira->codegen->invalid_instruction; | 20419 | return ira->codegen->invalid_instruction; |
| 20382 | | 20420 | |
| 20383 | if (target_value_ptr->value.type->id == ZigTypeIdMetaType) { | 20421 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { |
| 20384 | assert(instr_is_comptime(target_value_ptr)); | 20422 | assert(instr_is_comptime(target_value_ptr)); |
| 20385 | ZigType *ptr_type = target_value_ptr->value.data.x_type; | 20423 | ZigType *ptr_type = target_value_ptr->value->data.x_type; |
| 20386 | assert(ptr_type->id == ZigTypeIdPointer); | 20424 | assert(ptr_type->id == ZigTypeIdPointer); |
| 20387 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); | 20425 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); |
| 20388 | } | 20426 | } |
| 20389 | | 20427 | |
| 20390 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20428 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20391 | ConstExprValue *pointee_val = nullptr; | 20429 | ZigValue *pointee_val = nullptr; |
| 20392 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20430 | 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); | 20431 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->source_node); |
| 20394 | if (pointee_val == nullptr) | 20432 | if (pointee_val == nullptr) |
| 20395 | return ira->codegen->invalid_instruction; | 20433 | return ira->codegen->invalid_instruction; |
| 20396 | | 20434 | |
| ... | @@ -20416,13 +20454,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20416,13 +20454,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20416 | case ZigTypeIdErrorSet: { | 20454 | case ZigTypeIdErrorSet: { |
| 20417 | if (pointee_val) { | 20455 | if (pointee_val) { |
| 20418 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); | 20456 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); |
| 20419 | copy_const_val(&result->value, pointee_val, true); | 20457 | copy_const_val(result->value, pointee_val, true); |
| 20420 | result->value.type = target_type; | 20458 | result->value->type = target_type; |
| 20421 | return result; | 20459 | return result; |
| 20422 | } | 20460 | } |
| 20423 | | 20461 | |
| 20424 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20462 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20425 | result->value.type = target_type; | 20463 | result->value->type = target_type; |
| 20426 | return result; | 20464 | return result; |
| 20427 | } | 20465 | } |
| 20428 | case ZigTypeIdUnion: { | 20466 | case ZigTypeIdUnion: { |
| ... | @@ -20441,22 +20479,22 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20441,22 +20479,22 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20441 | assert(tag_type->id == ZigTypeIdEnum); | 20479 | assert(tag_type->id == ZigTypeIdEnum); |
| 20442 | if (pointee_val) { | 20480 | if (pointee_val) { |
| 20443 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 20481 | 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); | 20482 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| 20445 | return result; | 20483 | return result; |
| 20446 | } | 20484 | } |
| 20447 | if (tag_type->data.enumeration.src_field_count == 1) { | 20485 | if (tag_type->data.enumeration.src_field_count == 1) { |
| 20448 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 20486 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); |
| 20449 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; | 20487 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; |
| 20450 | bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value); | 20488 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 20451 | return result; | 20489 | return result; |
| 20452 | } | 20490 | } |
| 20453 | | 20491 | |
| 20454 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20492 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20455 | union_value->value.type = target_type; | 20493 | union_value->value->type = target_type; |
| 20456 | | 20494 | |
| 20457 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, | 20495 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, |
| 20458 | switch_target_instruction->base.source_node, union_value); | 20496 | switch_target_instruction->base.source_node, union_value); |
| 20459 | union_tag_inst->value.type = tag_type; | 20497 | union_tag_inst->value->type = tag_type; |
| 20460 | return union_tag_inst; | 20498 | return union_tag_inst; |
| 20461 | } | 20499 | } |
| 20462 | case ZigTypeIdEnum: { | 20500 | case ZigTypeIdEnum: { |
| ... | @@ -20465,18 +20503,18 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20465,18 +20503,18 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20465 | if (target_type->data.enumeration.src_field_count < 2) { | 20503 | if (target_type->data.enumeration.src_field_count < 2) { |
| 20466 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; | 20504 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 20467 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 20505 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); |
| 20468 | bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value); | 20506 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 20469 | return result; | 20507 | return result; |
| 20470 | } | 20508 | } |
| 20471 | | 20509 | |
| 20472 | if (pointee_val) { | 20510 | if (pointee_val) { |
| 20473 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 20511 | 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); | 20512 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); |
| 20475 | return result; | 20513 | return result; |
| 20476 | } | 20514 | } |
| 20477 | | 20515 | |
| 20478 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20516 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20479 | enum_value->value.type = target_type; | 20517 | enum_value->value->type = target_type; |
| 20480 | return enum_value; | 20518 | return enum_value; |
| 20481 | } | 20519 | } |
| 20482 | case ZigTypeIdErrorUnion: | 20520 | case ZigTypeIdErrorUnion: |
| ... | @@ -20501,12 +20539,12 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20501,12 +20539,12 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20501 | | 20539 | |
| 20502 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { | 20540 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { |
| 20503 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 20541 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; |
| 20504 | if (type_is_invalid(target_value_ptr->value.type)) | 20542 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20505 | return ira->codegen->invalid_instruction; | 20543 | return ira->codegen->invalid_instruction; |
| 20506 | | 20544 | |
| 20507 | ZigType *ref_type = target_value_ptr->value.type; | 20545 | ZigType *ref_type = target_value_ptr->value->type; |
| 20508 | assert(ref_type->id == ZigTypeIdPointer); | 20546 | assert(ref_type->id == ZigTypeIdPointer); |
| 20509 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20547 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20510 | if (target_type->id == ZigTypeIdUnion) { | 20548 | if (target_type->id == ZigTypeIdUnion) { |
| 20511 | ZigType *enum_type = target_type->data.unionation.tag_type; | 20549 | ZigType *enum_type = target_type->data.unionation.tag_type; |
| 20512 | assert(enum_type != nullptr); | 20550 | assert(enum_type != nullptr); |
| ... | @@ -20514,14 +20552,14 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20514,14 +20552,14 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20514 | assert(instruction->prongs_len > 0); | 20552 | assert(instruction->prongs_len > 0); |
| 20515 | | 20553 | |
| 20516 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; | 20554 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; |
| 20517 | if (type_is_invalid(first_prong_value->value.type)) | 20555 | if (type_is_invalid(first_prong_value->value->type)) |
| 20518 | return ira->codegen->invalid_instruction; | 20556 | return ira->codegen->invalid_instruction; |
| 20519 | | 20557 | |
| 20520 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | 20558 | 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)) | 20559 | if (type_is_invalid(first_casted_prong_value->value->type)) |
| 20522 | return ira->codegen->invalid_instruction; | 20560 | return ira->codegen->invalid_instruction; |
| 20523 | | 20561 | |
| 20524 | ConstExprValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); | 20562 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); |
| 20525 | if (first_prong_val == nullptr) | 20563 | if (first_prong_val == nullptr) |
| 20526 | return ira->codegen->invalid_instruction; | 20564 | return ira->codegen->invalid_instruction; |
| 20527 | | 20565 | |
| ... | @@ -20530,14 +20568,14 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20530,14 +20568,14 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20530 | ErrorMsg *invalid_payload_msg = nullptr; | 20568 | ErrorMsg *invalid_payload_msg = nullptr; |
| 20531 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { | 20569 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { |
| 20532 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | 20570 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; |
| 20533 | if (type_is_invalid(this_prong_inst->value.type)) | 20571 | if (type_is_invalid(this_prong_inst->value->type)) |
| 20534 | return ira->codegen->invalid_instruction; | 20572 | return ira->codegen->invalid_instruction; |
| 20535 | | 20573 | |
| 20536 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | 20574 | 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)) | 20575 | if (type_is_invalid(this_casted_prong_value->value->type)) |
| 20538 | return ira->codegen->invalid_instruction; | 20576 | return ira->codegen->invalid_instruction; |
| 20539 | | 20577 | |
| 20540 | ConstExprValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); | 20578 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); |
| 20541 | if (this_prong == nullptr) | 20579 | if (this_prong == nullptr) |
| 20542 | return ira->codegen->invalid_instruction; | 20580 | return ira->codegen->invalid_instruction; |
| 20543 | | 20581 | |
| ... | @@ -20560,18 +20598,18 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20560,18 +20598,18 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20560 | } | 20598 | } |
| 20561 | | 20599 | |
| 20562 | if (instr_is_comptime(target_value_ptr)) { | 20600 | if (instr_is_comptime(target_value_ptr)) { |
| 20563 | ConstExprValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); | 20601 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); |
| 20564 | if (!target_value_ptr) | 20602 | if (!target_value_ptr) |
| 20565 | return ira->codegen->invalid_instruction; | 20603 | return ira->codegen->invalid_instruction; |
| 20566 | | 20604 | |
| 20567 | ConstExprValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); | 20605 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); |
| 20568 | if (pointee_val == nullptr) | 20606 | if (pointee_val == nullptr) |
| 20569 | return ira->codegen->invalid_instruction; | 20607 | return ira->codegen->invalid_instruction; |
| 20570 | | 20608 | |
| 20571 | IrInstruction *result = ir_const(ira, &instruction->base, | 20609 | IrInstruction *result = ir_const(ira, &instruction->base, |
| 20572 | get_pointer_to_type(ira->codegen, first_field->type_entry, | 20610 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 20573 | target_val_ptr->type->data.pointer.is_const)); | 20611 | target_val_ptr->type->data.pointer.is_const)); |
| 20574 | ConstExprValue *out_val = &result->value; | 20612 | ZigValue *out_val = result->value; |
| 20575 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 20613 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20576 | out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut; | 20614 | out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut; |
| 20577 | out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload; | 20615 | out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload; |
| ... | @@ -20580,8 +20618,8 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20580,8 +20618,8 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20580 | | 20618 | |
| 20581 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, | 20619 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, |
| 20582 | instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false); | 20620 | 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, | 20621 | result->value->type = get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 20584 | target_value_ptr->value.type->data.pointer.is_const); | 20622 | target_value_ptr->value->type->data.pointer.is_const); |
| 20585 | return result; | 20623 | return result; |
| 20586 | } else if (target_type->id == ZigTypeIdErrorSet) { | 20624 | } else if (target_type->id == ZigTypeIdErrorSet) { |
| 20587 | // construct an error set from the prong values | 20625 | // construct an error set from the prong values |
| ... | @@ -20624,12 +20662,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -20624,12 +20662,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 20624 | IrInstructionSwitchElseVar *instruction) | 20662 | IrInstructionSwitchElseVar *instruction) |
| 20625 | { | 20663 | { |
| 20626 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 20664 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; |
| 20627 | if (type_is_invalid(target_value_ptr->value.type)) | 20665 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20628 | return ira->codegen->invalid_instruction; | 20666 | return ira->codegen->invalid_instruction; |
| 20629 | | 20667 | |
| 20630 | ZigType *ref_type = target_value_ptr->value.type; | 20668 | ZigType *ref_type = target_value_ptr->value->type; |
| 20631 | assert(ref_type->id == ZigTypeIdPointer); | 20669 | assert(ref_type->id == ZigTypeIdPointer); |
| 20632 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20670 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20633 | if (target_type->id == ZigTypeIdErrorSet) { | 20671 | if (target_type->id == ZigTypeIdErrorSet) { |
| 20634 | // make a new set that has the other cases removed | 20672 | // make a new set that has the other cases removed |
| 20635 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { | 20673 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { |
| ... | @@ -20645,12 +20683,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -20645,12 +20683,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 20645 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { | 20683 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { |
| 20646 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | 20684 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; |
| 20647 | IrInstruction *case_expr = br_case->value->child; | 20685 | IrInstruction *case_expr = br_case->value->child; |
| 20648 | if (case_expr->value.type->id == ZigTypeIdErrorSet) { | 20686 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { |
| 20649 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); | 20687 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); |
| 20650 | if (err == nullptr) | 20688 | if (err == nullptr) |
| 20651 | return ira->codegen->invalid_instruction; | 20689 | return ira->codegen->invalid_instruction; |
| 20652 | errors[err->value] = err; | 20690 | errors[err->value] = err; |
| 20653 | } else if (case_expr->value.type->id == ZigTypeIdMetaType) { | 20691 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { |
| 20654 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); | 20692 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); |
| 20655 | if (type_is_invalid(err_set_type)) | 20693 | if (type_is_invalid(err_set_type)) |
| 20656 | return ira->codegen->invalid_instruction; | 20694 | return ira->codegen->invalid_instruction; |
| ... | @@ -20742,7 +20780,7 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio | ... | @@ -20742,7 +20780,7 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio |
| 20742 | | 20780 | |
| 20743 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { | 20781 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { |
| 20744 | IrInstruction *value = ref_instruction->value->child; | 20782 | IrInstruction *value = ref_instruction->value->child; |
| 20745 | if (type_is_invalid(value->value.type)) | 20783 | if (type_is_invalid(value->value->type)) |
| 20746 | return ira->codegen->invalid_instruction; | 20784 | return ira->codegen->invalid_instruction; |
| 20747 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); | 20785 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); |
| 20748 | } | 20786 | } |
| ... | @@ -20768,13 +20806,13 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -20768,13 +20806,13 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc |
| 20768 | if (type_is_invalid(type_field->type_entry)) | 20806 | if (type_is_invalid(type_field->type_entry)) |
| 20769 | return ira->codegen->invalid_instruction; | 20807 | return ira->codegen->invalid_instruction; |
| 20770 | | 20808 | |
| 20771 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 20809 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20772 | if (instr_is_comptime(field_result_loc) && | 20810 | if (instr_is_comptime(field_result_loc) && |
| 20773 | field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 20811 | field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 20774 | { | 20812 | { |
| 20775 | // nothing | 20813 | // nothing |
| 20776 | } else { | 20814 | } else { |
| 20777 | result_loc->value.special = ConstValSpecialRuntime; | 20815 | result_loc->value->special = ConstValSpecialRuntime; |
| 20778 | } | 20816 | } |
| 20779 | } | 20817 | } |
| 20780 | | 20818 | |
| ... | @@ -20803,7 +20841,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20803,7 +20841,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20803 | } | 20841 | } |
| 20804 | IrInstructionContainerInitFieldsField *field = &fields[0]; | 20842 | IrInstructionContainerInitFieldsField *field = &fields[0]; |
| 20805 | IrInstruction *field_result_loc = field->result_loc->child; | 20843 | IrInstruction *field_result_loc = field->result_loc->child; |
| 20806 | if (type_is_invalid(field_result_loc->value.type)) | 20844 | if (type_is_invalid(field_result_loc->value->type)) |
| 20807 | return ira->codegen->invalid_instruction; | 20845 | return ira->codegen->invalid_instruction; |
| 20808 | | 20846 | |
| 20809 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, | 20847 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, |
| ... | @@ -20850,7 +20888,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20850,7 +20888,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20850 | IrInstructionContainerInitFieldsField *field = &fields[i]; | 20888 | IrInstructionContainerInitFieldsField *field = &fields[i]; |
| 20851 | | 20889 | |
| 20852 | IrInstruction *field_result_loc = field->result_loc->child; | 20890 | IrInstruction *field_result_loc = field->result_loc->child; |
| 20853 | if (type_is_invalid(field_result_loc->value.type)) | 20891 | if (type_is_invalid(field_result_loc->value->type)) |
| 20854 | return ira->codegen->invalid_instruction; | 20892 | return ira->codegen->invalid_instruction; |
| 20855 | | 20893 | |
| 20856 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); | 20894 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); |
| ... | @@ -20874,7 +20912,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20874,7 +20912,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20874 | field_assign_nodes[field_index] = field->source_node; | 20912 | field_assign_nodes[field_index] = field->source_node; |
| 20875 | | 20913 | |
| 20876 | if (instr_is_comptime(field_result_loc) && | 20914 | if (instr_is_comptime(field_result_loc) && |
| 20877 | field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 20915 | field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 20878 | { | 20916 | { |
| 20879 | const_ptrs.append(field_result_loc); | 20917 | const_ptrs.append(field_result_loc); |
| 20880 | } else { | 20918 | } else { |
| ... | @@ -20912,12 +20950,12 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20912,12 +20950,12 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20912 | return ira->codegen->invalid_instruction; | 20950 | return ira->codegen->invalid_instruction; |
| 20913 | | 20951 | |
| 20914 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); | 20952 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); |
| 20915 | copy_const_val(&runtime_inst->value, field->init_val, true); | 20953 | copy_const_val(runtime_inst->value, field->init_val, true); |
| 20916 | | 20954 | |
| 20917 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, | 20955 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, |
| 20918 | container_type, true); | 20956 | container_type, true); |
| 20919 | ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false); | 20957 | 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) { | 20958 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20921 | const_ptrs.append(field_ptr); | 20959 | const_ptrs.append(field_ptr); |
| 20922 | } else { | 20960 | } else { |
| 20923 | first_non_const_instruction = result_loc; | 20961 | first_non_const_instruction = result_loc; |
| ... | @@ -20926,13 +20964,13 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20926,13 +20964,13 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20926 | if (any_missing) | 20964 | if (any_missing) |
| 20927 | return ira->codegen->invalid_instruction; | 20965 | return ira->codegen->invalid_instruction; |
| 20928 | | 20966 | |
| 20929 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 20967 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20930 | if (const_ptrs.length != actual_field_count) { | 20968 | if (const_ptrs.length != actual_field_count) { |
| 20931 | result_loc->value.special = ConstValSpecialRuntime; | 20969 | result_loc->value->special = ConstValSpecialRuntime; |
| 20932 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 20970 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 20933 | IrInstruction *field_result_loc = const_ptrs.at(i); | 20971 | IrInstruction *field_result_loc = const_ptrs.at(i); |
| 20934 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); | 20972 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); |
| 20935 | field_result_loc->value.special = ConstValSpecialRuntime; | 20973 | field_result_loc->value->special = ConstValSpecialRuntime; |
| 20936 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); | 20974 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); |
| 20937 | } | 20975 | } |
| 20938 | } | 20976 | } |
| ... | @@ -20954,11 +20992,11 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -20954,11 +20992,11 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 20954 | { | 20992 | { |
| 20955 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 20993 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 20956 | IrInstruction *result_loc = instruction->result_loc->child; | 20994 | IrInstruction *result_loc = instruction->result_loc->child; |
| 20957 | if (type_is_invalid(result_loc->value.type)) | 20995 | if (type_is_invalid(result_loc->value->type)) |
| 20958 | return result_loc; | 20996 | return result_loc; |
| 20959 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base); | 20997 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); |
| 20960 | | 20998 | |
| 20961 | ZigType *container_type = result_loc->value.type->data.pointer.child_type; | 20999 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 20962 | | 21000 | |
| 20963 | size_t elem_count = instruction->item_count; | 21001 | size_t elem_count = instruction->item_count; |
| 20964 | | 21002 | |
| ... | @@ -20980,7 +21018,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -20980,7 +21018,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 20980 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { | 21018 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { |
| 20981 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 21019 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 20982 | IrInstruction *result_loc = instruction->result_loc->child; | 21020 | IrInstruction *result_loc = instruction->result_loc->child; |
| 20983 | if (type_is_invalid(result_loc->value.type)) | 21021 | if (type_is_invalid(result_loc->value->type)) |
| 20984 | return result_loc; | 21022 | return result_loc; |
| 20985 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); | 21023 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); |
| 20986 | } | 21024 | } |
| ... | @@ -21041,13 +21079,13 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21041,13 +21079,13 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21041 | | 21079 | |
| 21042 | for (size_t i = 0; i < elem_count; i += 1) { | 21080 | for (size_t i = 0; i < elem_count; i += 1) { |
| 21043 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; | 21081 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; |
| 21044 | if (type_is_invalid(elem_result_loc->value.type)) | 21082 | if (type_is_invalid(elem_result_loc->value->type)) |
| 21045 | return ira->codegen->invalid_instruction; | 21083 | return ira->codegen->invalid_instruction; |
| 21046 | | 21084 | |
| 21047 | assert(elem_result_loc->value.type->id == ZigTypeIdPointer); | 21085 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); |
| 21048 | | 21086 | |
| 21049 | if (instr_is_comptime(elem_result_loc) && | 21087 | if (instr_is_comptime(elem_result_loc) && |
| 21050 | elem_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 21088 | elem_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 21051 | { | 21089 | { |
| 21052 | const_ptrs.append(elem_result_loc); | 21090 | const_ptrs.append(elem_result_loc); |
| 21053 | } else { | 21091 | } else { |
| ... | @@ -21055,14 +21093,14 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21055,14 +21093,14 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21055 | } | 21093 | } |
| 21056 | } | 21094 | } |
| 21057 | | 21095 | |
| 21058 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 21096 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21059 | if (const_ptrs.length != elem_count) { | 21097 | if (const_ptrs.length != elem_count) { |
| 21060 | result_loc->value.special = ConstValSpecialRuntime; | 21098 | result_loc->value->special = ConstValSpecialRuntime; |
| 21061 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 21099 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 21062 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 21100 | IrInstruction *elem_result_loc = const_ptrs.at(i); |
| 21063 | assert(elem_result_loc->value.special == ConstValSpecialStatic); | 21101 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 21064 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 21102 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); |
| 21065 | elem_result_loc->value.special = ConstValSpecialRuntime; | 21103 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 21066 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 21104 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); |
| 21067 | } | 21105 | } |
| 21068 | } | 21106 | } |
| ... | @@ -21078,7 +21116,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21078,7 +21116,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21078 | return ira->codegen->invalid_instruction; | 21116 | return ira->codegen->invalid_instruction; |
| 21079 | } | 21117 | } |
| 21080 | | 21118 | |
| 21081 | ZigType *result_elem_type = result_loc->value.type->data.pointer.child_type; | 21119 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; |
| 21082 | if (is_slice(result_elem_type)) { | 21120 | if (is_slice(result_elem_type)) { |
| 21083 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 21121 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 21084 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", | 21122 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", |
| ... | @@ -21095,11 +21133,11 @@ static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ir | ... | @@ -21095,11 +21133,11 @@ static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ir |
| 21095 | { | 21133 | { |
| 21096 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 21134 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 21097 | IrInstruction *result_loc = instruction->result_loc->child; | 21135 | IrInstruction *result_loc = instruction->result_loc->child; |
| 21098 | if (type_is_invalid(result_loc->value.type)) | 21136 | if (type_is_invalid(result_loc->value->type)) |
| 21099 | return result_loc; | 21137 | return result_loc; |
| 21100 | | 21138 | |
| 21101 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base); | 21139 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); |
| 21102 | ZigType *container_type = result_loc->value.type->data.pointer.child_type; | 21140 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 21103 | | 21141 | |
| 21104 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 21142 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 21105 | instruction->field_count, instruction->fields, result_loc); | 21143 | instruction->field_count, instruction->fields, result_loc); |
| ... | @@ -21123,15 +21161,15 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -21123,15 +21161,15 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 21123 | fprintf(stderr, "| "); | 21161 | fprintf(stderr, "| "); |
| 21124 | for (size_t i = 0; i < instruction->msg_count; i += 1) { | 21162 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 21125 | IrInstruction *msg = instruction->msg_list[i]->child; | 21163 | IrInstruction *msg = instruction->msg_list[i]->child; |
| 21126 | if (type_is_invalid(msg->value.type)) | 21164 | if (type_is_invalid(msg->value->type)) |
| 21127 | return ira->codegen->invalid_instruction; | 21165 | return ira->codegen->invalid_instruction; |
| 21128 | buf_resize(&buf, 0); | 21166 | buf_resize(&buf, 0); |
| 21129 | if (msg->value.special == ConstValSpecialLazy) { | 21167 | if (msg->value->special == ConstValSpecialLazy) { |
| 21130 | // Resolve any lazy value that's passed, we need its value | 21168 | // Resolve any lazy value that's passed, we need its value |
| 21131 | if (ir_resolve_lazy(ira->codegen, msg->source_node, &msg->value)) | 21169 | if (ir_resolve_lazy(ira->codegen, msg->source_node, msg->value)) |
| 21132 | return ira->codegen->invalid_instruction; | 21170 | return ira->codegen->invalid_instruction; |
| 21133 | } | 21171 | } |
| 21134 | render_const_value(ira->codegen, &buf, &msg->value); | 21172 | render_const_value(ira->codegen, &buf, msg->value); |
| 21135 | const char *comma_str = (i != 0) ? ", " : ""; | 21173 | const char *comma_str = (i != 0) ? ", " : ""; |
| 21136 | fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf)); | 21174 | fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf)); |
| 21137 | } | 21175 | } |
| ... | @@ -21150,28 +21188,28 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -21150,28 +21188,28 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 21150 | | 21188 | |
| 21151 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { | 21189 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { |
| 21152 | IrInstruction *value = instruction->value->child; | 21190 | IrInstruction *value = instruction->value->child; |
| 21153 | if (type_is_invalid(value->value.type)) | 21191 | if (type_is_invalid(value->value->type)) |
| 21154 | return ira->codegen->invalid_instruction; | 21192 | return ira->codegen->invalid_instruction; |
| 21155 | | 21193 | |
| 21156 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | 21194 | 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)) | 21195 | if (type_is_invalid(casted_value->value->type)) |
| 21158 | return ira->codegen->invalid_instruction; | 21196 | return ira->codegen->invalid_instruction; |
| 21159 | | 21197 | |
| 21160 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 21198 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 21161 | true, false, PtrLenUnknown, 0, 0, 0, false); | 21199 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 21162 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 21200 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 21163 | if (instr_is_comptime(casted_value)) { | 21201 | if (instr_is_comptime(casted_value)) { |
| 21164 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 21202 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 21165 | if (val == nullptr) | 21203 | if (val == nullptr) |
| 21166 | return ira->codegen->invalid_instruction; | 21204 | return ira->codegen->invalid_instruction; |
| 21167 | ErrorTableEntry *err = casted_value->value.data.x_err_set; | 21205 | ErrorTableEntry *err = casted_value->value->data.x_err_set; |
| 21168 | if (!err->cached_error_name_val) { | 21206 | if (!err->cached_error_name_val) { |
| 21169 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 21207 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; |
| 21170 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 21208 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 21171 | } | 21209 | } |
| 21172 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 21210 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 21173 | copy_const_val(&result->value, err->cached_error_name_val, true); | 21211 | copy_const_val(result->value, err->cached_error_name_val, true); |
| 21174 | result->value.type = str_type; | 21212 | result->value->type = str_type; |
| 21175 | return result; | 21213 | return result; |
| 21176 | } | 21214 | } |
| 21177 | | 21215 | |
| ... | @@ -21179,25 +21217,25 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -21179,25 +21217,25 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 21179 | | 21217 | |
| 21180 | IrInstruction *result = ir_build_err_name(&ira->new_irb, | 21218 | IrInstruction *result = ir_build_err_name(&ira->new_irb, |
| 21181 | instruction->base.scope, instruction->base.source_node, value); | 21219 | instruction->base.scope, instruction->base.source_node, value); |
| 21182 | result->value.type = str_type; | 21220 | result->value->type = str_type; |
| 21183 | return result; | 21221 | return result; |
| 21184 | } | 21222 | } |
| 21185 | | 21223 | |
| 21186 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { | 21224 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { |
| 21187 | Error err; | 21225 | Error err; |
| 21188 | IrInstruction *target = instruction->target->child; | 21226 | IrInstruction *target = instruction->target->child; |
| 21189 | if (type_is_invalid(target->value.type)) | 21227 | if (type_is_invalid(target->value->type)) |
| 21190 | return ira->codegen->invalid_instruction; | 21228 | return ira->codegen->invalid_instruction; |
| 21191 | | 21229 | |
| 21192 | assert(target->value.type->id == ZigTypeIdEnum); | 21230 | assert(target->value->type->id == ZigTypeIdEnum); |
| 21193 | | 21231 | |
| 21194 | if (instr_is_comptime(target)) { | 21232 | if (instr_is_comptime(target)) { |
| 21195 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) | 21233 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 21196 | return ira->codegen->invalid_instruction; | 21234 | return ira->codegen->invalid_instruction; |
| 21197 | TypeEnumField *field = find_enum_field_by_tag(target->value.type, &target->value.data.x_bigint); | 21235 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); |
| 21198 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; | 21236 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; |
| 21199 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 21237 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 21200 | init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true); | 21238 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); |
| 21201 | return result; | 21239 | return result; |
| 21202 | } | 21240 | } |
| 21203 | | 21241 | |
| ... | @@ -21207,7 +21245,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -21207,7 +21245,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 21207 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 21245 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 21208 | true, false, PtrLenUnknown, | 21246 | true, false, PtrLenUnknown, |
| 21209 | 0, 0, 0, false); | 21247 | 0, 0, 0, false); |
| 21210 | result->value.type = get_slice_type(ira->codegen, u8_ptr_type); | 21248 | result->value->type = get_slice_type(ira->codegen, u8_ptr_type); |
| 21211 | return result; | 21249 | return result; |
| 21212 | } | 21250 | } |
| 21213 | | 21251 | |
| ... | @@ -21226,7 +21264,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21226,7 +21264,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21226 | return ira->codegen->invalid_instruction; | 21264 | return ira->codegen->invalid_instruction; |
| 21227 | | 21265 | |
| 21228 | IrInstruction *field_ptr = instruction->field_ptr->child; | 21266 | IrInstruction *field_ptr = instruction->field_ptr->child; |
| 21229 | if (type_is_invalid(field_ptr->value.type)) | 21267 | if (type_is_invalid(field_ptr->value->type)) |
| 21230 | return ira->codegen->invalid_instruction; | 21268 | return ira->codegen->invalid_instruction; |
| 21231 | | 21269 | |
| 21232 | if (container_type->id != ZigTypeIdStruct) { | 21270 | if (container_type->id != ZigTypeIdStruct) { |
| ... | @@ -21246,9 +21284,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21246,9 +21284,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21246 | return ira->codegen->invalid_instruction; | 21284 | return ira->codegen->invalid_instruction; |
| 21247 | } | 21285 | } |
| 21248 | | 21286 | |
| 21249 | if (field_ptr->value.type->id != ZigTypeIdPointer) { | 21287 | if (field_ptr->value->type->id != ZigTypeIdPointer) { |
| 21250 | ir_add_error(ira, field_ptr, | 21288 | ir_add_error(ira, field_ptr, |
| 21251 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); | 21289 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); |
| 21252 | return ira->codegen->invalid_instruction; | 21290 | return ira->codegen->invalid_instruction; |
| 21253 | } | 21291 | } |
| 21254 | | 21292 | |
| ... | @@ -21257,22 +21295,22 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21257,22 +21295,22 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21257 | uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type); | 21295 | uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type); |
| 21258 | | 21296 | |
| 21259 | ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry, | 21297 | ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry, |
| 21260 | field_ptr->value.type->data.pointer.is_const, | 21298 | field_ptr->value->type->data.pointer.is_const, |
| 21261 | field_ptr->value.type->data.pointer.is_volatile, | 21299 | field_ptr->value->type->data.pointer.is_volatile, |
| 21262 | PtrLenSingle, | 21300 | PtrLenSingle, |
| 21263 | field_ptr_align, 0, 0, false); | 21301 | field_ptr_align, 0, 0, false); |
| 21264 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | 21302 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); |
| 21265 | if (type_is_invalid(casted_field_ptr->value.type)) | 21303 | if (type_is_invalid(casted_field_ptr->value->type)) |
| 21266 | return ira->codegen->invalid_instruction; | 21304 | return ira->codegen->invalid_instruction; |
| 21267 | | 21305 | |
| 21268 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, | 21306 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, |
| 21269 | casted_field_ptr->value.type->data.pointer.is_const, | 21307 | casted_field_ptr->value->type->data.pointer.is_const, |
| 21270 | casted_field_ptr->value.type->data.pointer.is_volatile, | 21308 | casted_field_ptr->value->type->data.pointer.is_volatile, |
| 21271 | PtrLenSingle, | 21309 | PtrLenSingle, |
| 21272 | parent_ptr_align, 0, 0, false); | 21310 | parent_ptr_align, 0, 0, false); |
| 21273 | | 21311 | |
| 21274 | if (instr_is_comptime(casted_field_ptr)) { | 21312 | if (instr_is_comptime(casted_field_ptr)) { |
| 21275 | ConstExprValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); | 21313 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); |
| 21276 | if (!field_ptr_val) | 21314 | if (!field_ptr_val) |
| 21277 | return ira->codegen->invalid_instruction; | 21315 | return ira->codegen->invalid_instruction; |
| 21278 | | 21316 | |
| ... | @@ -21291,7 +21329,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21291,7 +21329,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21291 | } | 21329 | } |
| 21292 | | 21330 | |
| 21293 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 21331 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 21294 | ConstExprValue *out_val = &result->value; | 21332 | ZigValue *out_val = result->value; |
| 21295 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 21333 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 21296 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; | 21334 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; |
| 21297 | out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut; | 21335 | out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut; |
| ... | @@ -21300,7 +21338,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21300,7 +21338,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21300 | | 21338 | |
| 21301 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, | 21339 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, |
| 21302 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); | 21340 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); |
| 21303 | result->value.type = result_type; | 21341 | result->value->type = result_type; |
| 21304 | return result; | 21342 | return result; |
| 21305 | } | 21343 | } |
| 21306 | | 21344 | |
| ... | @@ -21350,7 +21388,7 @@ static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, | ... | @@ -21350,7 +21388,7 @@ static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, |
| 21350 | IrInstructionByteOffsetOf *instruction) | 21388 | IrInstructionByteOffsetOf *instruction) |
| 21351 | { | 21389 | { |
| 21352 | IrInstruction *type_value = instruction->type_value->child; | 21390 | IrInstruction *type_value = instruction->type_value->child; |
| 21353 | if (type_is_invalid(type_value->value.type)) | 21391 | if (type_is_invalid(type_value->value->type)) |
| 21354 | return ira->codegen->invalid_instruction; | 21392 | return ira->codegen->invalid_instruction; |
| 21355 | | 21393 | |
| 21356 | IrInstruction *field_name_value = instruction->field_name->child; | 21394 | IrInstruction *field_name_value = instruction->field_name->child; |
| ... | @@ -21366,7 +21404,7 @@ static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, | ... | @@ -21366,7 +21404,7 @@ static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, |
| 21366 | IrInstructionBitOffsetOf *instruction) | 21404 | IrInstructionBitOffsetOf *instruction) |
| 21367 | { | 21405 | { |
| 21368 | IrInstruction *type_value = instruction->type_value->child; | 21406 | IrInstruction *type_value = instruction->type_value->child; |
| 21369 | if (type_is_invalid(type_value->value.type)) | 21407 | if (type_is_invalid(type_value->value->type)) |
| 21370 | return ira->codegen->invalid_instruction; | 21408 | return ira->codegen->invalid_instruction; |
| 21371 | IrInstruction *field_name_value = instruction->field_name->child; | 21409 | IrInstruction *field_name_value = instruction->field_name->child; |
| 21372 | size_t byte_offset = 0; | 21410 | size_t byte_offset = 0; |
| ... | @@ -21390,7 +21428,7 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind | ... | @@ -21390,7 +21428,7 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind |
| 21390 | | 21428 | |
| 21391 | static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) { | 21429 | static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) { |
| 21392 | Error err; | 21430 | Error err; |
| 21393 | ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); | 21431 | ZigValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); |
| 21394 | assert(type_info_var->type->id == ZigTypeIdMetaType); | 21432 | assert(type_info_var->type->id == ZigTypeIdMetaType); |
| 21395 | ZigType *type_info_type = type_info_var->data.x_type; | 21433 | ZigType *type_info_type = type_info_var->data.x_type; |
| 21396 | assert(type_info_type->id == ZigTypeIdUnion); | 21434 | assert(type_info_type->id == ZigTypeIdUnion); |
| ... | @@ -21423,7 +21461,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -21423,7 +21461,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig |
| 21423 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); | 21461 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); |
| 21424 | } | 21462 | } |
| 21425 | | 21463 | |
| 21426 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *out_val, | 21464 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *out_val, |
| 21427 | ScopeDecls *decls_scope) | 21465 | ScopeDecls *decls_scope) |
| 21428 | { | 21466 | { |
| 21429 | Error err; | 21467 | Error err; |
| ... | @@ -21473,7 +21511,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21473,7 +21511,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21473 | } | 21511 | } |
| 21474 | } | 21512 | } |
| 21475 | | 21513 | |
| 21476 | ConstExprValue *declaration_array = create_const_vals(1); | 21514 | ZigValue *declaration_array = create_const_vals(1); |
| 21477 | declaration_array->special = ConstValSpecialStatic; | 21515 | declaration_array->special = ConstValSpecialStatic; |
| 21478 | declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); | 21516 | declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); |
| 21479 | declaration_array->data.x_array.special = ConstArraySpecialNone; | 21517 | declaration_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -21494,13 +21532,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21494,13 +21532,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21494 | continue; | 21532 | continue; |
| 21495 | } | 21533 | } |
| 21496 | | 21534 | |
| 21497 | ConstExprValue *declaration_val = &declaration_array->data.x_array.data.s_none.elements[declaration_index]; | 21535 | ZigValue *declaration_val = &declaration_array->data.x_array.data.s_none.elements[declaration_index]; |
| 21498 | | 21536 | |
| 21499 | declaration_val->special = ConstValSpecialStatic; | 21537 | declaration_val->special = ConstValSpecialStatic; |
| 21500 | declaration_val->type = type_info_declaration_type; | 21538 | declaration_val->type = type_info_declaration_type; |
| 21501 | | 21539 | |
| 21502 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 21540 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 21503 | ConstExprValue *name = create_const_str_lit(ira->codegen, curr_entry->key)->data.x_ptr.data.ref.pointee; | 21541 | ZigValue *name = create_const_str_lit(ira->codegen, curr_entry->key)->data.x_ptr.data.ref.pointee; |
| 21504 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); | 21542 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); |
| 21505 | inner_fields[1]->special = ConstValSpecialStatic; | 21543 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21506 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; | 21544 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| ... | @@ -21528,7 +21566,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21528,7 +21566,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21528 | // 1: Data.Var: type | 21566 | // 1: Data.Var: type |
| 21529 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); | 21567 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); |
| 21530 | | 21568 | |
| 21531 | ConstExprValue *payload = create_const_vals(1); | 21569 | ZigValue *payload = create_const_vals(1); |
| 21532 | payload->special = ConstValSpecialStatic; | 21570 | payload->special = ConstValSpecialStatic; |
| 21533 | payload->type = ira->codegen->builtin_types.entry_type; | 21571 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21534 | payload->data.x_type = var->const_value->type; | 21572 | payload->data.x_type = var->const_value->type; |
| ... | @@ -21553,13 +21591,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21553,13 +21591,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21553 | | 21591 | |
| 21554 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; | 21592 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; |
| 21555 | | 21593 | |
| 21556 | ConstExprValue *fn_decl_val = create_const_vals(1); | 21594 | ZigValue *fn_decl_val = create_const_vals(1); |
| 21557 | fn_decl_val->special = ConstValSpecialStatic; | 21595 | fn_decl_val->special = ConstValSpecialStatic; |
| 21558 | fn_decl_val->type = type_info_fn_decl_type; | 21596 | fn_decl_val->type = type_info_fn_decl_type; |
| 21559 | fn_decl_val->parent.id = ConstParentIdUnion; | 21597 | fn_decl_val->parent.id = ConstParentIdUnion; |
| 21560 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; | 21598 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; |
| 21561 | | 21599 | |
| 21562 | ConstExprValue **fn_decl_fields = alloc_const_vals_ptrs(9); | 21600 | ZigValue **fn_decl_fields = alloc_const_vals_ptrs(9); |
| 21563 | fn_decl_val->data.x_struct.fields = fn_decl_fields; | 21601 | fn_decl_val->data.x_struct.fields = fn_decl_fields; |
| 21564 | | 21602 | |
| 21565 | // fn_type: type | 21603 | // fn_type: type |
| ... | @@ -21603,7 +21641,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21603,7 +21641,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21603 | fn_decl_fields[6]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr)); | 21641 | fn_decl_fields[6]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr)); |
| 21604 | if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { | 21642 | if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { |
| 21605 | fn_decl_fields[6]->data.x_optional = create_const_vals(1); | 21643 | fn_decl_fields[6]->data.x_optional = create_const_vals(1); |
| 21606 | ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name)->data.x_ptr.data.ref.pointee; | 21644 | ZigValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name)->data.x_ptr.data.ref.pointee; |
| 21607 | init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0, | 21645 | init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0, |
| 21608 | buf_len(fn_node->lib_name), true); | 21646 | buf_len(fn_node->lib_name), true); |
| 21609 | } else { | 21647 | } else { |
| ... | @@ -21617,7 +21655,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21617,7 +21655,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21617 | // arg_names: [][] const u8 | 21655 | // arg_names: [][] const u8 |
| 21618 | ensure_field_index(fn_decl_val->type, "arg_names", 8); | 21656 | ensure_field_index(fn_decl_val->type, "arg_names", 8); |
| 21619 | size_t fn_arg_count = fn_entry->variable_list.length; | 21657 | size_t fn_arg_count = fn_entry->variable_list.length; |
| 21620 | ConstExprValue *fn_arg_name_array = create_const_vals(1); | 21658 | ZigValue *fn_arg_name_array = create_const_vals(1); |
| 21621 | fn_arg_name_array->special = ConstValSpecialStatic; | 21659 | fn_arg_name_array->special = ConstValSpecialStatic; |
| 21622 | fn_arg_name_array->type = get_array_type(ira->codegen, | 21660 | fn_arg_name_array->type = get_array_type(ira->codegen, |
| 21623 | get_slice_type(ira->codegen, u8_ptr), fn_arg_count, nullptr); | 21661 | get_slice_type(ira->codegen, u8_ptr), fn_arg_count, nullptr); |
| ... | @@ -21628,8 +21666,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21628,8 +21666,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21628 | | 21666 | |
| 21629 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 21667 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { |
| 21630 | ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index); | 21668 | ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index); |
| 21631 | ConstExprValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index]; | 21669 | ZigValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index]; |
| 21632 | ConstExprValue *arg_name = create_const_str_lit(ira->codegen, | 21670 | ZigValue *arg_name = create_const_str_lit(ira->codegen, |
| 21633 | buf_create_from_str(arg_var->name))->data.x_ptr.data.ref.pointee; | 21671 | buf_create_from_str(arg_var->name))->data.x_ptr.data.ref.pointee; |
| 21634 | init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true); | 21672 | init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true); |
| 21635 | fn_arg_name_val->parent.id = ConstParentIdArray; | 21673 | fn_arg_name_val->parent.id = ConstParentIdArray; |
| ... | @@ -21649,7 +21687,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21649,7 +21687,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21649 | // This is a type. | 21687 | // This is a type. |
| 21650 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); | 21688 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); |
| 21651 | | 21689 | |
| 21652 | ConstExprValue *payload = create_const_vals(1); | 21690 | ZigValue *payload = create_const_vals(1); |
| 21653 | payload->special = ConstValSpecialStatic; | 21691 | payload->special = ConstValSpecialStatic; |
| 21654 | payload->type = ira->codegen->builtin_types.entry_type; | 21692 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21655 | payload->data.x_type = type_entry; | 21693 | payload->data.x_type = type_entry; |
| ... | @@ -21695,7 +21733,7 @@ static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) { | ... | @@ -21695,7 +21733,7 @@ static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) { |
| 21695 | zig_unreachable(); | 21733 | zig_unreachable(); |
| 21696 | } | 21734 | } |
| 21697 | | 21735 | |
| 21698 | static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) { | 21736 | static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) { |
| 21699 | Error err; | 21737 | Error err; |
| 21700 | ZigType *attrs_type; | 21738 | ZigType *attrs_type; |
| 21701 | BuiltinPtrSize size_enum_index; | 21739 | BuiltinPtrSize size_enum_index; |
| ... | @@ -21715,11 +21753,11 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -21715,11 +21753,11 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty |
| 21715 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); | 21753 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 21716 | assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown)); | 21754 | assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown)); |
| 21717 | | 21755 | |
| 21718 | ConstExprValue *result = create_const_vals(1); | 21756 | ZigValue *result = create_const_vals(1); |
| 21719 | result->special = ConstValSpecialStatic; | 21757 | result->special = ConstValSpecialStatic; |
| 21720 | result->type = type_info_pointer_type; | 21758 | result->type = type_info_pointer_type; |
| 21721 | | 21759 | |
| 21722 | ConstExprValue **fields = alloc_const_vals_ptrs(7); | 21760 | ZigValue **fields = alloc_const_vals_ptrs(7); |
| 21723 | result->data.x_struct.fields = fields; | 21761 | result->data.x_struct.fields = fields; |
| 21724 | | 21762 | |
| 21725 | // size: Size | 21763 | // size: Size |
| ... | @@ -21769,17 +21807,17 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -21769,17 +21807,17 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty |
| 21769 | return result; | 21807 | return result; |
| 21770 | }; | 21808 | }; |
| 21771 | | 21809 | |
| 21772 | static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field, | 21810 | static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEnumField *enum_field, |
| 21773 | ZigType *type_info_enum_field_type) | 21811 | ZigType *type_info_enum_field_type) |
| 21774 | { | 21812 | { |
| 21775 | enum_field_val->special = ConstValSpecialStatic; | 21813 | enum_field_val->special = ConstValSpecialStatic; |
| 21776 | enum_field_val->type = type_info_enum_field_type; | 21814 | enum_field_val->type = type_info_enum_field_type; |
| 21777 | | 21815 | |
| 21778 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); | 21816 | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 21779 | inner_fields[1]->special = ConstValSpecialStatic; | 21817 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21780 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; | 21818 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21781 | | 21819 | |
| 21782 | ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name)->data.x_ptr.data.ref.pointee; | 21820 | ZigValue *name = create_const_str_lit(ira->codegen, enum_field->name)->data.x_ptr.data.ref.pointee; |
| 21783 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true); | 21821 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true); |
| 21784 | | 21822 | |
| 21785 | bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); | 21823 | bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); |
| ... | @@ -21788,7 +21826,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, | ... | @@ -21788,7 +21826,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, |
| 21788 | } | 21826 | } |
| 21789 | | 21827 | |
| 21790 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 21828 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, |
| 21791 | ConstExprValue **out) | 21829 | ZigValue **out) |
| 21792 | { | 21830 | { |
| 21793 | Error err; | 21831 | Error err; |
| 21794 | assert(type_entry != nullptr); | 21832 | assert(type_entry != nullptr); |
| ... | @@ -21803,7 +21841,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21803,7 +21841,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21803 | return ErrorNone; | 21841 | return ErrorNone; |
| 21804 | } | 21842 | } |
| 21805 | | 21843 | |
| 21806 | ConstExprValue *result = nullptr; | 21844 | ZigValue *result = nullptr; |
| 21807 | switch (type_entry->id) { | 21845 | switch (type_entry->id) { |
| 21808 | case ZigTypeIdInvalid: | 21846 | case ZigTypeIdInvalid: |
| 21809 | zig_unreachable(); | 21847 | zig_unreachable(); |
| ... | @@ -21826,7 +21864,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21826,7 +21864,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21826 | result->special = ConstValSpecialStatic; | 21864 | result->special = ConstValSpecialStatic; |
| 21827 | result->type = ir_type_info_get_type(ira, "Int", nullptr); | 21865 | result->type = ir_type_info_get_type(ira, "Int", nullptr); |
| 21828 | | 21866 | |
| 21829 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 21867 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 21830 | result->data.x_struct.fields = fields; | 21868 | result->data.x_struct.fields = fields; |
| 21831 | | 21869 | |
| 21832 | // is_signed: bool | 21870 | // is_signed: bool |
| ... | @@ -21848,7 +21886,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21848,7 +21886,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21848 | result->special = ConstValSpecialStatic; | 21886 | result->special = ConstValSpecialStatic; |
| 21849 | result->type = ir_type_info_get_type(ira, "Float", nullptr); | 21887 | result->type = ir_type_info_get_type(ira, "Float", nullptr); |
| 21850 | | 21888 | |
| 21851 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21889 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21852 | result->data.x_struct.fields = fields; | 21890 | result->data.x_struct.fields = fields; |
| 21853 | | 21891 | |
| 21854 | // bits: u8 | 21892 | // bits: u8 |
| ... | @@ -21872,7 +21910,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21872,7 +21910,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21872 | result->special = ConstValSpecialStatic; | 21910 | result->special = ConstValSpecialStatic; |
| 21873 | result->type = ir_type_info_get_type(ira, "Array", nullptr); | 21911 | result->type = ir_type_info_get_type(ira, "Array", nullptr); |
| 21874 | | 21912 | |
| 21875 | ConstExprValue **fields = alloc_const_vals_ptrs(3); | 21913 | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 21876 | result->data.x_struct.fields = fields; | 21914 | result->data.x_struct.fields = fields; |
| 21877 | | 21915 | |
| 21878 | // len: usize | 21916 | // len: usize |
| ... | @@ -21896,7 +21934,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21896,7 +21934,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21896 | result->special = ConstValSpecialStatic; | 21934 | result->special = ConstValSpecialStatic; |
| 21897 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); | 21935 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); |
| 21898 | | 21936 | |
| 21899 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 21937 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 21900 | result->data.x_struct.fields = fields; | 21938 | result->data.x_struct.fields = fields; |
| 21901 | | 21939 | |
| 21902 | // len: usize | 21940 | // len: usize |
| ... | @@ -21918,7 +21956,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21918,7 +21956,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21918 | result->special = ConstValSpecialStatic; | 21956 | result->special = ConstValSpecialStatic; |
| 21919 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); | 21957 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); |
| 21920 | | 21958 | |
| 21921 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21959 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21922 | result->data.x_struct.fields = fields; | 21960 | result->data.x_struct.fields = fields; |
| 21923 | | 21961 | |
| 21924 | // child: type | 21962 | // child: type |
| ... | @@ -21934,7 +21972,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21934,7 +21972,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21934 | result->special = ConstValSpecialStatic; | 21972 | result->special = ConstValSpecialStatic; |
| 21935 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); | 21973 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); |
| 21936 | | 21974 | |
| 21937 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21975 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21938 | result->data.x_struct.fields = fields; | 21976 | result->data.x_struct.fields = fields; |
| 21939 | | 21977 | |
| 21940 | // child: ?type | 21978 | // child: ?type |
| ... | @@ -21951,7 +21989,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21951,7 +21989,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21951 | result->special = ConstValSpecialStatic; | 21989 | result->special = ConstValSpecialStatic; |
| 21952 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); | 21990 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); |
| 21953 | | 21991 | |
| 21954 | ConstExprValue **fields = alloc_const_vals_ptrs(4); | 21992 | ZigValue **fields = alloc_const_vals_ptrs(4); |
| 21955 | result->data.x_struct.fields = fields; | 21993 | result->data.x_struct.fields = fields; |
| 21956 | | 21994 | |
| 21957 | // layout: ContainerLayout | 21995 | // layout: ContainerLayout |
| ... | @@ -21973,7 +22011,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21973,7 +22011,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21973 | } | 22011 | } |
| 21974 | uint32_t enum_field_count = type_entry->data.enumeration.src_field_count; | 22012 | uint32_t enum_field_count = type_entry->data.enumeration.src_field_count; |
| 21975 | | 22013 | |
| 21976 | ConstExprValue *enum_field_array = create_const_vals(1); | 22014 | ZigValue *enum_field_array = create_const_vals(1); |
| 21977 | enum_field_array->special = ConstValSpecialStatic; | 22015 | enum_field_array->special = ConstValSpecialStatic; |
| 21978 | enum_field_array->type = get_array_type(ira->codegen, type_info_enum_field_type, enum_field_count, nullptr); | 22016 | enum_field_array->type = get_array_type(ira->codegen, type_info_enum_field_type, enum_field_count, nullptr); |
| 21979 | enum_field_array->data.x_array.special = ConstArraySpecialNone; | 22017 | enum_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -21984,7 +22022,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21984,7 +22022,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21984 | for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) | 22022 | for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) |
| 21985 | { | 22023 | { |
| 21986 | TypeEnumField *enum_field = &type_entry->data.enumeration.fields[enum_field_index]; | 22024 | TypeEnumField *enum_field = &type_entry->data.enumeration.fields[enum_field_index]; |
| 21987 | ConstExprValue *enum_field_val = &enum_field_array->data.x_array.data.s_none.elements[enum_field_index]; | 22025 | ZigValue *enum_field_val = &enum_field_array->data.x_array.data.s_none.elements[enum_field_index]; |
| 21988 | make_enum_field_val(ira, enum_field_val, enum_field, type_info_enum_field_type); | 22026 | make_enum_field_val(ira, enum_field_val, enum_field, type_info_enum_field_type); |
| 21989 | enum_field_val->parent.id = ConstParentIdArray; | 22027 | enum_field_val->parent.id = ConstParentIdArray; |
| 21990 | enum_field_val->parent.data.p_array.array_val = enum_field_array; | 22028 | enum_field_val->parent.data.p_array.array_val = enum_field_array; |
| ... | @@ -22017,11 +22055,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22017,11 +22055,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22017 | if ((err = type_resolve(ira->codegen, type_info_error_type, ResolveStatusSizeKnown))) { | 22055 | if ((err = type_resolve(ira->codegen, type_info_error_type, ResolveStatusSizeKnown))) { |
| 22018 | zig_unreachable(); | 22056 | zig_unreachable(); |
| 22019 | } | 22057 | } |
| 22020 | ConstExprValue *slice_val = create_const_vals(1); | 22058 | ZigValue *slice_val = create_const_vals(1); |
| 22021 | result->data.x_optional = slice_val; | 22059 | result->data.x_optional = slice_val; |
| 22022 | | 22060 | |
| 22023 | uint32_t error_count = type_entry->data.error_set.err_count; | 22061 | uint32_t error_count = type_entry->data.error_set.err_count; |
| 22024 | ConstExprValue *error_array = create_const_vals(1); | 22062 | ZigValue *error_array = create_const_vals(1); |
| 22025 | error_array->special = ConstValSpecialStatic; | 22063 | error_array->special = ConstValSpecialStatic; |
| 22026 | error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr); | 22064 | error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr); |
| 22027 | error_array->data.x_array.special = ConstArraySpecialNone; | 22065 | error_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22030,16 +22068,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22030,16 +22068,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22030 | init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false); | 22068 | init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false); |
| 22031 | for (uint32_t error_index = 0; error_index < error_count; error_index++) { | 22069 | for (uint32_t error_index = 0; error_index < error_count; error_index++) { |
| 22032 | ErrorTableEntry *error = type_entry->data.error_set.errors[error_index]; | 22070 | ErrorTableEntry *error = type_entry->data.error_set.errors[error_index]; |
| 22033 | ConstExprValue *error_val = &error_array->data.x_array.data.s_none.elements[error_index]; | 22071 | ZigValue *error_val = &error_array->data.x_array.data.s_none.elements[error_index]; |
| 22034 | | 22072 | |
| 22035 | error_val->special = ConstValSpecialStatic; | 22073 | error_val->special = ConstValSpecialStatic; |
| 22036 | error_val->type = type_info_error_type; | 22074 | error_val->type = type_info_error_type; |
| 22037 | | 22075 | |
| 22038 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); | 22076 | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 22039 | inner_fields[1]->special = ConstValSpecialStatic; | 22077 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22040 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; | 22078 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 22041 | | 22079 | |
| 22042 | ConstExprValue *name = nullptr; | 22080 | ZigValue *name = nullptr; |
| 22043 | if (error->cached_error_name_val != nullptr) | 22081 | if (error->cached_error_name_val != nullptr) |
| 22044 | name = error->cached_error_name_val; | 22082 | name = error->cached_error_name_val; |
| 22045 | if (name == nullptr) | 22083 | if (name == nullptr) |
| ... | @@ -22061,7 +22099,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22061,7 +22099,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22061 | result->special = ConstValSpecialStatic; | 22099 | result->special = ConstValSpecialStatic; |
| 22062 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); | 22100 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); |
| 22063 | | 22101 | |
| 22064 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 22102 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 22065 | result->data.x_struct.fields = fields; | 22103 | result->data.x_struct.fields = fields; |
| 22066 | | 22104 | |
| 22067 | // error_set: type | 22105 | // error_set: type |
| ... | @@ -22084,7 +22122,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22084,7 +22122,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22084 | result->special = ConstValSpecialStatic; | 22122 | result->special = ConstValSpecialStatic; |
| 22085 | result->type = ir_type_info_get_type(ira, "Union", nullptr); | 22123 | result->type = ir_type_info_get_type(ira, "Union", nullptr); |
| 22086 | | 22124 | |
| 22087 | ConstExprValue **fields = alloc_const_vals_ptrs(4); | 22125 | ZigValue **fields = alloc_const_vals_ptrs(4); |
| 22088 | result->data.x_struct.fields = fields; | 22126 | result->data.x_struct.fields = fields; |
| 22089 | | 22127 | |
| 22090 | // layout: ContainerLayout | 22128 | // layout: ContainerLayout |
| ... | @@ -22101,7 +22139,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22101,7 +22139,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22101 | if (union_decl_node->data.container_decl.auto_enum || | 22139 | if (union_decl_node->data.container_decl.auto_enum || |
| 22102 | union_decl_node->data.container_decl.init_arg_expr != nullptr) | 22140 | union_decl_node->data.container_decl.init_arg_expr != nullptr) |
| 22103 | { | 22141 | { |
| 22104 | ConstExprValue *tag_type = create_const_vals(1); | 22142 | ZigValue *tag_type = create_const_vals(1); |
| 22105 | tag_type->special = ConstValSpecialStatic; | 22143 | tag_type->special = ConstValSpecialStatic; |
| 22106 | tag_type->type = ira->codegen->builtin_types.entry_type; | 22144 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| 22107 | tag_type->data.x_type = type_entry->data.unionation.tag_type; | 22145 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| ... | @@ -22117,7 +22155,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22117,7 +22155,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22117 | zig_unreachable(); | 22155 | zig_unreachable(); |
| 22118 | uint32_t union_field_count = type_entry->data.unionation.src_field_count; | 22156 | uint32_t union_field_count = type_entry->data.unionation.src_field_count; |
| 22119 | | 22157 | |
| 22120 | ConstExprValue *union_field_array = create_const_vals(1); | 22158 | ZigValue *union_field_array = create_const_vals(1); |
| 22121 | union_field_array->special = ConstValSpecialStatic; | 22159 | union_field_array->special = ConstValSpecialStatic; |
| 22122 | union_field_array->type = get_array_type(ira->codegen, type_info_union_field_type, union_field_count, nullptr); | 22160 | union_field_array->type = get_array_type(ira->codegen, type_info_union_field_type, union_field_count, nullptr); |
| 22123 | union_field_array->data.x_array.special = ConstArraySpecialNone; | 22161 | union_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22129,12 +22167,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22129,12 +22167,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22129 | | 22167 | |
| 22130 | for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) { | 22168 | for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) { |
| 22131 | TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index]; | 22169 | TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index]; |
| 22132 | ConstExprValue *union_field_val = &union_field_array->data.x_array.data.s_none.elements[union_field_index]; | 22170 | ZigValue *union_field_val = &union_field_array->data.x_array.data.s_none.elements[union_field_index]; |
| 22133 | | 22171 | |
| 22134 | union_field_val->special = ConstValSpecialStatic; | 22172 | union_field_val->special = ConstValSpecialStatic; |
| 22135 | union_field_val->type = type_info_union_field_type; | 22173 | union_field_val->type = type_info_union_field_type; |
| 22136 | | 22174 | |
| 22137 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22175 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22138 | inner_fields[1]->special = ConstValSpecialStatic; | 22176 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22139 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); | 22177 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); |
| 22140 | | 22178 | |
| ... | @@ -22149,7 +22187,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22149,7 +22187,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22149 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; | 22187 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 22150 | inner_fields[2]->data.x_type = union_field->type_entry; | 22188 | inner_fields[2]->data.x_type = union_field->type_entry; |
| 22151 | | 22189 | |
| 22152 | ConstExprValue *name = create_const_str_lit(ira->codegen, union_field->name)->data.x_ptr.data.ref.pointee; | 22190 | ZigValue *name = create_const_str_lit(ira->codegen, union_field->name)->data.x_ptr.data.ref.pointee; |
| 22153 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true); | 22191 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true); |
| 22154 | | 22192 | |
| 22155 | union_field_val->data.x_struct.fields = inner_fields; | 22193 | union_field_val->data.x_struct.fields = inner_fields; |
| ... | @@ -22180,7 +22218,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22180,7 +22218,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22180 | result->special = ConstValSpecialStatic; | 22218 | result->special = ConstValSpecialStatic; |
| 22181 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); | 22219 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); |
| 22182 | | 22220 | |
| 22183 | ConstExprValue **fields = alloc_const_vals_ptrs(3); | 22221 | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 22184 | result->data.x_struct.fields = fields; | 22222 | result->data.x_struct.fields = fields; |
| 22185 | | 22223 | |
| 22186 | // layout: ContainerLayout | 22224 | // layout: ContainerLayout |
| ... | @@ -22197,7 +22235,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22197,7 +22235,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22197 | } | 22235 | } |
| 22198 | uint32_t struct_field_count = type_entry->data.structure.src_field_count; | 22236 | uint32_t struct_field_count = type_entry->data.structure.src_field_count; |
| 22199 | | 22237 | |
| 22200 | ConstExprValue *struct_field_array = create_const_vals(1); | 22238 | ZigValue *struct_field_array = create_const_vals(1); |
| 22201 | struct_field_array->special = ConstValSpecialStatic; | 22239 | struct_field_array->special = ConstValSpecialStatic; |
| 22202 | struct_field_array->type = get_array_type(ira->codegen, type_info_struct_field_type, struct_field_count, nullptr); | 22240 | struct_field_array->type = get_array_type(ira->codegen, type_info_struct_field_type, struct_field_count, nullptr); |
| 22203 | struct_field_array->data.x_array.special = ConstArraySpecialNone; | 22241 | struct_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22207,12 +22245,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22207,12 +22245,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22207 | | 22245 | |
| 22208 | for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { | 22246 | for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { |
| 22209 | TypeStructField *struct_field = type_entry->data.structure.fields[struct_field_index]; | 22247 | TypeStructField *struct_field = type_entry->data.structure.fields[struct_field_index]; |
| 22210 | ConstExprValue *struct_field_val = &struct_field_array->data.x_array.data.s_none.elements[struct_field_index]; | 22248 | ZigValue *struct_field_val = &struct_field_array->data.x_array.data.s_none.elements[struct_field_index]; |
| 22211 | | 22249 | |
| 22212 | struct_field_val->special = ConstValSpecialStatic; | 22250 | struct_field_val->special = ConstValSpecialStatic; |
| 22213 | struct_field_val->type = type_info_struct_field_type; | 22251 | struct_field_val->type = type_info_struct_field_type; |
| 22214 | | 22252 | |
| 22215 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22253 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22216 | inner_fields[1]->special = ConstValSpecialStatic; | 22254 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22217 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); | 22255 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); |
| 22218 | | 22256 | |
| ... | @@ -22235,7 +22273,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22235,7 +22273,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22235 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; | 22273 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 22236 | inner_fields[2]->data.x_type = struct_field->type_entry; | 22274 | inner_fields[2]->data.x_type = struct_field->type_entry; |
| 22237 | | 22275 | |
| 22238 | ConstExprValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee; | 22276 | ZigValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee; |
| 22239 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true); | 22277 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true); |
| 22240 | | 22278 | |
| 22241 | struct_field_val->data.x_struct.fields = inner_fields; | 22279 | struct_field_val->data.x_struct.fields = inner_fields; |
| ... | @@ -22259,7 +22297,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22259,7 +22297,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22259 | result->special = ConstValSpecialStatic; | 22297 | result->special = ConstValSpecialStatic; |
| 22260 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); | 22298 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); |
| 22261 | | 22299 | |
| 22262 | ConstExprValue **fields = alloc_const_vals_ptrs(5); | 22300 | ZigValue **fields = alloc_const_vals_ptrs(5); |
| 22263 | result->data.x_struct.fields = fields; | 22301 | result->data.x_struct.fields = fields; |
| 22264 | | 22302 | |
| 22265 | // calling_convention: TypeInfo.CallingConvention | 22303 | // calling_convention: TypeInfo.CallingConvention |
| ... | @@ -22286,7 +22324,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22286,7 +22324,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22286 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) | 22324 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 22287 | fields[3]->data.x_optional = nullptr; | 22325 | fields[3]->data.x_optional = nullptr; |
| 22288 | else { | 22326 | else { |
| 22289 | ConstExprValue *return_type = create_const_vals(1); | 22327 | ZigValue *return_type = create_const_vals(1); |
| 22290 | return_type->special = ConstValSpecialStatic; | 22328 | return_type->special = ConstValSpecialStatic; |
| 22291 | return_type->type = ira->codegen->builtin_types.entry_type; | 22329 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 22292 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; | 22330 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| ... | @@ -22300,7 +22338,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22300,7 +22338,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22300 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - | 22338 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - |
| 22301 | (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC); | 22339 | (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC); |
| 22302 | | 22340 | |
| 22303 | ConstExprValue *fn_arg_array = create_const_vals(1); | 22341 | ZigValue *fn_arg_array = create_const_vals(1); |
| 22304 | fn_arg_array->special = ConstValSpecialStatic; | 22342 | fn_arg_array->special = ConstValSpecialStatic; |
| 22305 | fn_arg_array->type = get_array_type(ira->codegen, type_info_fn_arg_type, fn_arg_count, nullptr); | 22343 | fn_arg_array->type = get_array_type(ira->codegen, type_info_fn_arg_type, fn_arg_count, nullptr); |
| 22306 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; | 22344 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22310,7 +22348,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22310,7 +22348,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22310 | | 22348 | |
| 22311 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 22349 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { |
| 22312 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; | 22350 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; |
| 22313 | ConstExprValue *fn_arg_val = &fn_arg_array->data.x_array.data.s_none.elements[fn_arg_index]; | 22351 | ZigValue *fn_arg_val = &fn_arg_array->data.x_array.data.s_none.elements[fn_arg_index]; |
| 22314 | | 22352 | |
| 22315 | fn_arg_val->special = ConstValSpecialStatic; | 22353 | fn_arg_val->special = ConstValSpecialStatic; |
| 22316 | fn_arg_val->type = type_info_fn_arg_type; | 22354 | fn_arg_val->type = type_info_fn_arg_type; |
| ... | @@ -22318,7 +22356,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22318,7 +22356,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22318 | bool arg_is_generic = fn_param_info->type == nullptr; | 22356 | bool arg_is_generic = fn_param_info->type == nullptr; |
| 22319 | if (arg_is_generic) assert(is_generic); | 22357 | if (arg_is_generic) assert(is_generic); |
| 22320 | | 22358 | |
| 22321 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22359 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22322 | inner_fields[0]->special = ConstValSpecialStatic; | 22360 | inner_fields[0]->special = ConstValSpecialStatic; |
| 22323 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; | 22361 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; |
| 22324 | inner_fields[0]->data.x_bool = arg_is_generic; | 22362 | inner_fields[0]->data.x_bool = arg_is_generic; |
| ... | @@ -22331,7 +22369,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22331,7 +22369,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22331 | if (arg_is_generic) | 22369 | if (arg_is_generic) |
| 22332 | inner_fields[2]->data.x_optional = nullptr; | 22370 | inner_fields[2]->data.x_optional = nullptr; |
| 22333 | else { | 22371 | else { |
| 22334 | ConstExprValue *arg_type = create_const_vals(1); | 22372 | ZigValue *arg_type = create_const_vals(1); |
| 22335 | arg_type->special = ConstValSpecialStatic; | 22373 | arg_type->special = ConstValSpecialStatic; |
| 22336 | arg_type->type = ira->codegen->builtin_types.entry_type; | 22374 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| 22337 | arg_type->data.x_type = fn_param_info->type; | 22375 | arg_type->data.x_type = fn_param_info->type; |
| ... | @@ -22376,12 +22414,12 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -22376,12 +22414,12 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22376 | | 22414 | |
| 22377 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); | 22415 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); |
| 22378 | | 22416 | |
| 22379 | ConstExprValue *payload; | 22417 | ZigValue *payload; |
| 22380 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) | 22418 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) |
| 22381 | return ira->codegen->invalid_instruction; | 22419 | return ira->codegen->invalid_instruction; |
| 22382 | | 22420 | |
| 22383 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22421 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22384 | ConstExprValue *out_val = &result->value; | 22422 | ZigValue *out_val = result->value; |
| 22385 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); | 22423 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 22386 | out_val->data.x_union.payload = payload; | 22424 | out_val->data.x_union.payload = payload; |
| 22387 | | 22425 | |
| ... | @@ -22393,49 +22431,49 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -22393,49 +22431,49 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22393 | return result; | 22431 | return result; |
| 22394 | } | 22432 | } |
| 22395 | | 22433 | |
| 22396 | static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22434 | static ZigValue *get_const_field(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22397 | { | 22435 | { |
| 22398 | ensure_field_index(struct_value->type, name, field_index); | 22436 | ensure_field_index(struct_value->type, name, field_index); |
| 22399 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); | 22437 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); |
| 22400 | return struct_value->data.x_struct.fields[field_index]; | 22438 | return struct_value->data.x_struct.fields[field_index]; |
| 22401 | } | 22439 | } |
| 22402 | | 22440 | |
| 22403 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *struct_value, | 22441 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *struct_value, |
| 22404 | const char *name, size_t field_index, ZigType *elem_type, ConstExprValue **result) | 22442 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) |
| 22405 | { | 22443 | { |
| 22406 | ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index); | 22444 | ZigValue *field_val = get_const_field(ira, struct_value, name, field_index); |
| 22407 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); | 22445 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); |
| 22408 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, | 22446 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 22409 | get_optional_type(ira->codegen, elem_type)); | 22447 | get_optional_type(ira->codegen, elem_type)); |
| 22410 | if (type_is_invalid(casted_field_inst->value.type)) | 22448 | if (type_is_invalid(casted_field_inst->value->type)) |
| 22411 | return ErrorSemanticAnalyzeFail; | 22449 | return ErrorSemanticAnalyzeFail; |
| 22412 | | 22450 | |
| 22413 | *result = casted_field_inst->value.data.x_optional; | 22451 | *result = casted_field_inst->value->data.x_optional; |
| 22414 | return ErrorNone; | 22452 | return ErrorNone; |
| 22415 | } | 22453 | } |
| 22416 | | 22454 | |
| 22417 | static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22455 | static bool get_const_field_bool(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22418 | { | 22456 | { |
| 22419 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22457 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22420 | assert(value->type == ira->codegen->builtin_types.entry_bool); | 22458 | assert(value->type == ira->codegen->builtin_types.entry_bool); |
| 22421 | return value->data.x_bool; | 22459 | return value->data.x_bool; |
| 22422 | } | 22460 | } |
| 22423 | | 22461 | |
| 22424 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22462 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22425 | { | 22463 | { |
| 22426 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22464 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22427 | assert(value->type == ira->codegen->builtin_types.entry_num_lit_int); | 22465 | assert(value->type == ira->codegen->builtin_types.entry_num_lit_int); |
| 22428 | return &value->data.x_bigint; | 22466 | return &value->data.x_bigint; |
| 22429 | } | 22467 | } |
| 22430 | | 22468 | |
| 22431 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22469 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22432 | { | 22470 | { |
| 22433 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22471 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22434 | assert(value->type == ira->codegen->builtin_types.entry_type); | 22472 | assert(value->type == ira->codegen->builtin_types.entry_type); |
| 22435 | return value->data.x_type; | 22473 | return value->data.x_type; |
| 22436 | } | 22474 | } |
| 22437 | | 22475 | |
| 22438 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ConstExprValue *payload) { | 22476 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ZigValue *payload) { |
| 22439 | Error err; | 22477 | Error err; |
| 22440 | switch (tagTypeId) { | 22478 | switch (tagTypeId) { |
| 22441 | case ZigTypeIdInvalid: | 22479 | case ZigTypeIdInvalid: |
| ... | @@ -22474,12 +22512,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22474,12 +22512,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22474 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); | 22512 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 22475 | assert(payload->special == ConstValSpecialStatic); | 22513 | assert(payload->special == ConstValSpecialStatic); |
| 22476 | assert(payload->type == type_info_pointer_type); | 22514 | assert(payload->type == type_info_pointer_type); |
| 22477 | ConstExprValue *size_value = get_const_field(ira, payload, "size", 0); | 22515 | ZigValue *size_value = get_const_field(ira, payload, "size", 0); |
| 22478 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); | 22516 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); |
| 22479 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); | 22517 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); |
| 22480 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); | 22518 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); |
| 22481 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 4); | 22519 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 4); |
| 22482 | ConstExprValue *sentinel; | 22520 | ZigValue *sentinel; |
| 22483 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, | 22521 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, |
| 22484 | elem_type, &sentinel))) | 22522 | elem_type, &sentinel))) |
| 22485 | { | 22523 | { |
| ... | @@ -22504,7 +22542,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22504,7 +22542,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22504 | assert(payload->special == ConstValSpecialStatic); | 22542 | assert(payload->special == ConstValSpecialStatic); |
| 22505 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); | 22543 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); |
| 22506 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1); | 22544 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1); |
| 22507 | ConstExprValue *sentinel; | 22545 | ZigValue *sentinel; |
| 22508 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, | 22546 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, |
| 22509 | elem_type, &sentinel))) | 22547 | elem_type, &sentinel))) |
| 22510 | { | 22548 | { |
| ... | @@ -22549,14 +22587,14 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22549,14 +22587,14 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22549 | | 22587 | |
| 22550 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { | 22588 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { |
| 22551 | IrInstruction *type_info_ir = instruction->type_info->child; | 22589 | IrInstruction *type_info_ir = instruction->type_info->child; |
| 22552 | if (type_is_invalid(type_info_ir->value.type)) | 22590 | if (type_is_invalid(type_info_ir->value->type)) |
| 22553 | return ira->codegen->invalid_instruction; | 22591 | return ira->codegen->invalid_instruction; |
| 22554 | | 22592 | |
| 22555 | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); | 22593 | 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)) | 22594 | if (type_is_invalid(casted_ir->value->type)) |
| 22557 | return ira->codegen->invalid_instruction; | 22595 | return ira->codegen->invalid_instruction; |
| 22558 | | 22596 | |
| 22559 | ConstExprValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); | 22597 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); |
| 22560 | if (!type_info_value) | 22598 | if (!type_info_value) |
| 22561 | return ira->codegen->invalid_instruction; | 22599 | return ira->codegen->invalid_instruction; |
| 22562 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); | 22600 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); |
| ... | @@ -22574,12 +22612,12 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -22574,12 +22612,12 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 22574 | if (type_is_invalid(type_entry)) | 22612 | if (type_is_invalid(type_entry)) |
| 22575 | return ira->codegen->invalid_instruction; | 22613 | return ira->codegen->invalid_instruction; |
| 22576 | | 22614 | |
| 22577 | ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId"); | 22615 | ZigValue *var_value = get_builtin_value(ira->codegen, "TypeId"); |
| 22578 | assert(var_value->type->id == ZigTypeIdMetaType); | 22616 | assert(var_value->type->id == ZigTypeIdMetaType); |
| 22579 | ZigType *result_type = var_value->data.x_type; | 22617 | ZigType *result_type = var_value->data.x_type; |
| 22580 | | 22618 | |
| 22581 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22619 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22582 | bigint_init_unsigned(&result->value.data.x_enum_tag, type_id_index(type_entry)); | 22620 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); |
| 22583 | return result; | 22621 | return result; |
| 22584 | } | 22622 | } |
| 22585 | | 22623 | |
| ... | @@ -22607,7 +22645,7 @@ static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstruc | ... | @@ -22607,7 +22645,7 @@ static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstruc |
| 22607 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); | 22645 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 22608 | } | 22646 | } |
| 22609 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 22647 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 22610 | copy_const_val(&result->value, type_entry->cached_const_name_val, true); | 22648 | copy_const_val(result->value, type_entry->cached_const_name_val, true); |
| 22611 | return result; | 22649 | return result; |
| 22612 | } | 22650 | } |
| 22613 | | 22651 | |
| ... | @@ -22628,7 +22666,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -22628,7 +22666,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 22628 | | 22666 | |
| 22629 | // Execute the C import block like an inline function | 22667 | // Execute the C import block like an inline function |
| 22630 | ZigType *void_type = ira->codegen->builtin_types.entry_void; | 22668 | ZigType *void_type = ira->codegen->builtin_types.entry_void; |
| 22631 | ConstExprValue *cimport_result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type, | 22669 | ZigValue *cimport_result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type, |
| 22632 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, | 22670 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, |
| 22633 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad); | 22671 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad); |
| 22634 | if (type_is_invalid(cimport_result->type)) | 22672 | if (type_is_invalid(cimport_result->type)) |
| ... | @@ -22796,7 +22834,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -22796,7 +22834,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 22796 | | 22834 | |
| 22797 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { | 22835 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { |
| 22798 | IrInstruction *name_value = instruction->name->child; | 22836 | IrInstruction *name_value = instruction->name->child; |
| 22799 | if (type_is_invalid(name_value->value.type)) | 22837 | if (type_is_invalid(name_value->value->type)) |
| 22800 | return ira->codegen->invalid_instruction; | 22838 | return ira->codegen->invalid_instruction; |
| 22801 | | 22839 | |
| 22802 | Buf *include_name = ir_resolve_str(ira, name_value); | 22840 | Buf *include_name = ir_resolve_str(ira, name_value); |
| ... | @@ -22814,7 +22852,7 @@ static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstruc | ... | @@ -22814,7 +22852,7 @@ static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstruc |
| 22814 | | 22852 | |
| 22815 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { | 22853 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { |
| 22816 | IrInstruction *name = instruction->name->child; | 22854 | IrInstruction *name = instruction->name->child; |
| 22817 | if (type_is_invalid(name->value.type)) | 22855 | if (type_is_invalid(name->value->type)) |
| 22818 | return ira->codegen->invalid_instruction; | 22856 | return ira->codegen->invalid_instruction; |
| 22819 | | 22857 | |
| 22820 | Buf *define_name = ir_resolve_str(ira, name); | 22858 | Buf *define_name = ir_resolve_str(ira, name); |
| ... | @@ -22822,12 +22860,12 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct | ... | @@ -22822,12 +22860,12 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct |
| 22822 | return ira->codegen->invalid_instruction; | 22860 | return ira->codegen->invalid_instruction; |
| 22823 | | 22861 | |
| 22824 | IrInstruction *value = instruction->value->child; | 22862 | IrInstruction *value = instruction->value->child; |
| 22825 | if (type_is_invalid(value->value.type)) | 22863 | if (type_is_invalid(value->value->type)) |
| 22826 | return ira->codegen->invalid_instruction; | 22864 | return ira->codegen->invalid_instruction; |
| 22827 | | 22865 | |
| 22828 | Buf *define_value = nullptr; | 22866 | Buf *define_value = nullptr; |
| 22829 | // The second parameter is either a string or void (equivalent to "") | 22867 | // The second parameter is either a string or void (equivalent to "") |
| 22830 | if (value->value.type->id != ZigTypeIdVoid) { | 22868 | if (value->value->type->id != ZigTypeIdVoid) { |
| 22831 | define_value = ir_resolve_str(ira, value); | 22869 | define_value = ir_resolve_str(ira, value); |
| 22832 | if (!define_value) | 22870 | if (!define_value) |
| 22833 | return ira->codegen->invalid_instruction; | 22871 | return ira->codegen->invalid_instruction; |
| ... | @@ -22845,7 +22883,7 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct | ... | @@ -22845,7 +22883,7 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct |
| 22845 | | 22883 | |
| 22846 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { | 22884 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { |
| 22847 | IrInstruction *name = instruction->name->child; | 22885 | IrInstruction *name = instruction->name->child; |
| 22848 | if (type_is_invalid(name->value.type)) | 22886 | if (type_is_invalid(name->value->type)) |
| 22849 | return ira->codegen->invalid_instruction; | 22887 | return ira->codegen->invalid_instruction; |
| 22850 | | 22888 | |
| 22851 | Buf *undef_name = ir_resolve_str(ira, name); | 22889 | Buf *undef_name = ir_resolve_str(ira, name); |
| ... | @@ -22863,7 +22901,7 @@ static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructi | ... | @@ -22863,7 +22901,7 @@ static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructi |
| 22863 | | 22901 | |
| 22864 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { | 22902 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { |
| 22865 | IrInstruction *name = instruction->name->child; | 22903 | IrInstruction *name = instruction->name->child; |
| 22866 | if (type_is_invalid(name->value.type)) | 22904 | if (type_is_invalid(name->value->type)) |
| 22867 | return ira->codegen->invalid_instruction; | 22905 | return ira->codegen->invalid_instruction; |
| 22868 | | 22906 | |
| 22869 | Buf *rel_file_path = ir_resolve_str(ira, name); | 22907 | Buf *rel_file_path = ir_resolve_str(ira, name); |
| ... | @@ -22898,7 +22936,7 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru | ... | @@ -22898,7 +22936,7 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru |
| 22898 | ZigType *result_type = get_array_type(ira->codegen, | 22936 | ZigType *result_type = get_array_type(ira->codegen, |
| 22899 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); | 22937 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); |
| 22900 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22938 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22901 | init_const_str_lit(ira->codegen, &result->value, file_contents); | 22939 | init_const_str_lit(ira->codegen, result->value, file_contents); |
| 22902 | return result; | 22940 | return result; |
| 22903 | } | 22941 | } |
| 22904 | | 22942 | |
| ... | @@ -22908,25 +22946,25 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22908,25 +22946,25 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22908 | return ira->codegen->invalid_instruction; | 22946 | return ira->codegen->invalid_instruction; |
| 22909 | | 22947 | |
| 22910 | IrInstruction *ptr = instruction->ptr->child; | 22948 | IrInstruction *ptr = instruction->ptr->child; |
| 22911 | if (type_is_invalid(ptr->value.type)) | 22949 | if (type_is_invalid(ptr->value->type)) |
| 22912 | return ira->codegen->invalid_instruction; | 22950 | return ira->codegen->invalid_instruction; |
| 22913 | | 22951 | |
| 22914 | // TODO let this be volatile | 22952 | // TODO let this be volatile |
| 22915 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 22953 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 22916 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); | 22954 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); |
| 22917 | if (type_is_invalid(casted_ptr->value.type)) | 22955 | if (type_is_invalid(casted_ptr->value->type)) |
| 22918 | return ira->codegen->invalid_instruction; | 22956 | return ira->codegen->invalid_instruction; |
| 22919 | | 22957 | |
| 22920 | IrInstruction *cmp_value = instruction->cmp_value->child; | 22958 | IrInstruction *cmp_value = instruction->cmp_value->child; |
| 22921 | if (type_is_invalid(cmp_value->value.type)) | 22959 | if (type_is_invalid(cmp_value->value->type)) |
| 22922 | return ira->codegen->invalid_instruction; | 22960 | return ira->codegen->invalid_instruction; |
| 22923 | | 22961 | |
| 22924 | IrInstruction *new_value = instruction->new_value->child; | 22962 | IrInstruction *new_value = instruction->new_value->child; |
| 22925 | if (type_is_invalid(new_value->value.type)) | 22963 | if (type_is_invalid(new_value->value->type)) |
| 22926 | return ira->codegen->invalid_instruction; | 22964 | return ira->codegen->invalid_instruction; |
| 22927 | | 22965 | |
| 22928 | IrInstruction *success_order_value = instruction->success_order_value->child; | 22966 | IrInstruction *success_order_value = instruction->success_order_value->child; |
| 22929 | if (type_is_invalid(success_order_value->value.type)) | 22967 | if (type_is_invalid(success_order_value->value->type)) |
| 22930 | return ira->codegen->invalid_instruction; | 22968 | return ira->codegen->invalid_instruction; |
| 22931 | | 22969 | |
| 22932 | AtomicOrder success_order; | 22970 | AtomicOrder success_order; |
| ... | @@ -22934,7 +22972,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22934,7 +22972,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22934 | return ira->codegen->invalid_instruction; | 22972 | return ira->codegen->invalid_instruction; |
| 22935 | | 22973 | |
| 22936 | IrInstruction *failure_order_value = instruction->failure_order_value->child; | 22974 | IrInstruction *failure_order_value = instruction->failure_order_value->child; |
| 22937 | if (type_is_invalid(failure_order_value->value.type)) | 22975 | if (type_is_invalid(failure_order_value->value->type)) |
| 22938 | return ira->codegen->invalid_instruction; | 22976 | return ira->codegen->invalid_instruction; |
| 22939 | | 22977 | |
| 22940 | AtomicOrder failure_order; | 22978 | AtomicOrder failure_order; |
| ... | @@ -22942,11 +22980,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22942,11 +22980,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22942 | return ira->codegen->invalid_instruction; | 22980 | return ira->codegen->invalid_instruction; |
| 22943 | | 22981 | |
| 22944 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); | 22982 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); |
| 22945 | if (type_is_invalid(casted_cmp_value->value.type)) | 22983 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 22946 | return ira->codegen->invalid_instruction; | 22984 | return ira->codegen->invalid_instruction; |
| 22947 | | 22985 | |
| 22948 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); | 22986 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); |
| 22949 | if (type_is_invalid(casted_new_value->value.type)) | 22987 | if (type_is_invalid(casted_new_value->value->type)) |
| 22950 | return ira->codegen->invalid_instruction; | 22988 | return ira->codegen->invalid_instruction; |
| 22951 | | 22989 | |
| 22952 | if (success_order < AtomicOrderMonotonic) { | 22990 | if (success_order < AtomicOrderMonotonic) { |
| ... | @@ -22970,7 +23008,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22970,7 +23008,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22970 | return ira->codegen->invalid_instruction; | 23008 | return ira->codegen->invalid_instruction; |
| 22971 | } | 23009 | } |
| 22972 | | 23010 | |
| 22973 | if (instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar && | 23011 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 22974 | instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { | 23012 | instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { |
| 22975 | zig_panic("TODO compile-time execution of cmpxchg"); | 23013 | zig_panic("TODO compile-time execution of cmpxchg"); |
| 22976 | } | 23014 | } |
| ... | @@ -22980,7 +23018,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22980,7 +23018,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22980 | if (handle_is_ptr(result_type)) { | 23018 | if (handle_is_ptr(result_type)) { |
| 22981 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 23019 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 22982 | result_type, nullptr, true, false, true); | 23020 | result_type, nullptr, true, false, true); |
| 22983 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 23021 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 22984 | return result_loc; | 23022 | return result_loc; |
| 22985 | } | 23023 | } |
| 22986 | } else { | 23024 | } else { |
| ... | @@ -22994,7 +23032,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22994,7 +23032,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22994 | | 23032 | |
| 22995 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { | 23033 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { |
| 22996 | IrInstruction *order_value = instruction->order_value->child; | 23034 | IrInstruction *order_value = instruction->order_value->child; |
| 22997 | if (type_is_invalid(order_value->value.type)) | 23035 | if (type_is_invalid(order_value->value->type)) |
| 22998 | return ira->codegen->invalid_instruction; | 23036 | return ira->codegen->invalid_instruction; |
| 22999 | | 23037 | |
| 23000 | AtomicOrder order; | 23038 | AtomicOrder order; |
| ... | @@ -23009,7 +23047,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction | ... | @@ -23009,7 +23047,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction |
| 23009 | | 23047 | |
| 23010 | IrInstruction *result = ir_build_fence(&ira->new_irb, | 23048 | IrInstruction *result = ir_build_fence(&ira->new_irb, |
| 23011 | instruction->base.scope, instruction->base.source_node, order_value, order); | 23049 | instruction->base.scope, instruction->base.source_node, order_value, order); |
| 23012 | result->value.type = ira->codegen->builtin_types.entry_void; | 23050 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 23013 | return result; | 23051 | return result; |
| 23014 | } | 23052 | } |
| 23015 | | 23053 | |
| ... | @@ -23027,7 +23065,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23027,7 +23065,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23027 | } | 23065 | } |
| 23028 | | 23066 | |
| 23029 | IrInstruction *target = instruction->target->child; | 23067 | IrInstruction *target = instruction->target->child; |
| 23030 | ZigType *src_type = target->value.type; | 23068 | ZigType *src_type = target->value->type; |
| 23031 | if (type_is_invalid(src_type)) | 23069 | if (type_is_invalid(src_type)) |
| 23032 | return ira->codegen->invalid_instruction; | 23070 | return ira->codegen->invalid_instruction; |
| 23033 | | 23071 | |
| ... | @@ -23043,19 +23081,19 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23043,19 +23081,19 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23043 | } | 23081 | } |
| 23044 | | 23082 | |
| 23045 | if (instr_is_comptime(target)) { | 23083 | if (instr_is_comptime(target)) { |
| 23046 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 23084 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 23047 | if (val == nullptr) | 23085 | if (val == nullptr) |
| 23048 | return ira->codegen->invalid_instruction; | 23086 | return ira->codegen->invalid_instruction; |
| 23049 | | 23087 | |
| 23050 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 23088 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); |
| 23051 | bigint_truncate(&result->value.data.x_bigint, &val->data.x_bigint, | 23089 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, |
| 23052 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); | 23090 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); |
| 23053 | return result; | 23091 | return result; |
| 23054 | } | 23092 | } |
| 23055 | | 23093 | |
| 23056 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { | 23094 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { |
| 23057 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 23095 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); |
| 23058 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 23096 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 23059 | return result; | 23097 | return result; |
| 23060 | } | 23098 | } |
| 23061 | | 23099 | |
| ... | @@ -23071,7 +23109,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23071,7 +23109,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23071 | | 23109 | |
| 23072 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, | 23110 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, |
| 23073 | instruction->base.source_node, dest_type_value, target); | 23111 | instruction->base.source_node, dest_type_value, target); |
| 23074 | new_instruction->value.type = dest_type; | 23112 | new_instruction->value->type = dest_type; |
| 23075 | return new_instruction; | 23113 | return new_instruction; |
| 23076 | } | 23114 | } |
| 23077 | | 23115 | |
| ... | @@ -23086,12 +23124,12 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -23086,12 +23124,12 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 23086 | } | 23124 | } |
| 23087 | | 23125 | |
| 23088 | IrInstruction *target = instruction->target->child; | 23126 | IrInstruction *target = instruction->target->child; |
| 23089 | if (type_is_invalid(target->value.type)) | 23127 | if (type_is_invalid(target->value->type)) |
| 23090 | return ira->codegen->invalid_instruction; | 23128 | return ira->codegen->invalid_instruction; |
| 23091 | | 23129 | |
| 23092 | if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) { | 23130 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 23093 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", | 23131 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", |
| 23094 | buf_ptr(&target->value.type->name))); | 23132 | buf_ptr(&target->value->type->name))); |
| 23095 | return ira->codegen->invalid_instruction; | 23133 | return ira->codegen->invalid_instruction; |
| 23096 | } | 23134 | } |
| 23097 | | 23135 | |
| ... | @@ -23120,15 +23158,15 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -23120,15 +23158,15 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 23120 | } | 23158 | } |
| 23121 | | 23159 | |
| 23122 | IrInstruction *target = instruction->target->child; | 23160 | IrInstruction *target = instruction->target->child; |
| 23123 | if (type_is_invalid(target->value.type)) | 23161 | if (type_is_invalid(target->value->type)) |
| 23124 | return ira->codegen->invalid_instruction; | 23162 | return ira->codegen->invalid_instruction; |
| 23125 | | 23163 | |
| 23126 | if (target->value.type->id == ZigTypeIdComptimeInt || | 23164 | if (target->value->type->id == ZigTypeIdComptimeInt || |
| 23127 | target->value.type->id == ZigTypeIdComptimeFloat) | 23165 | target->value->type->id == ZigTypeIdComptimeFloat) |
| 23128 | { | 23166 | { |
| 23129 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { | 23167 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { |
| 23130 | CastOp op; | 23168 | CastOp op; |
| 23131 | if (target->value.type->id == ZigTypeIdComptimeInt) { | 23169 | if (target->value->type->id == ZigTypeIdComptimeInt) { |
| 23132 | op = CastOpIntToFloat; | 23170 | op = CastOpIntToFloat; |
| 23133 | } else { | 23171 | } else { |
| 23134 | op = CastOpNumLitToConcrete; | 23172 | op = CastOpNumLitToConcrete; |
| ... | @@ -23139,9 +23177,9 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -23139,9 +23177,9 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 23139 | } | 23177 | } |
| 23140 | } | 23178 | } |
| 23141 | | 23179 | |
| 23142 | if (target->value.type->id != ZigTypeIdFloat) { | 23180 | if (target->value->type->id != ZigTypeIdFloat) { |
| 23143 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 23181 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 23144 | buf_ptr(&target->value.type->name))); | 23182 | buf_ptr(&target->value->type->name))); |
| 23145 | return ira->codegen->invalid_instruction; | 23183 | return ira->codegen->invalid_instruction; |
| 23146 | } | 23184 | } |
| 23147 | | 23185 | |
| ... | @@ -23160,12 +23198,12 @@ static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInst | ... | @@ -23160,12 +23198,12 @@ static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInst |
| 23160 | } | 23198 | } |
| 23161 | | 23199 | |
| 23162 | IrInstruction *target = instruction->target->child; | 23200 | IrInstruction *target = instruction->target->child; |
| 23163 | if (type_is_invalid(target->value.type)) | 23201 | if (type_is_invalid(target->value->type)) |
| 23164 | return ira->codegen->invalid_instruction; | 23202 | return ira->codegen->invalid_instruction; |
| 23165 | | 23203 | |
| 23166 | if (target->value.type->id != ZigTypeIdErrorSet) { | 23204 | if (target->value->type->id != ZigTypeIdErrorSet) { |
| 23167 | ir_add_error(ira, instruction->target, | 23205 | ir_add_error(ira, instruction->target, |
| 23168 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value.type->name))); | 23206 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); |
| 23169 | return ira->codegen->invalid_instruction; | 23207 | return ira->codegen->invalid_instruction; |
| 23170 | } | 23208 | } |
| 23171 | | 23209 | |
| ... | @@ -23180,20 +23218,20 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23180,20 +23218,20 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23180 | return ira->codegen->invalid_instruction; | 23218 | return ira->codegen->invalid_instruction; |
| 23181 | | 23219 | |
| 23182 | IrInstruction *target = instruction->target->child; | 23220 | IrInstruction *target = instruction->target->child; |
| 23183 | if (type_is_invalid(target->value.type)) | 23221 | if (type_is_invalid(target->value->type)) |
| 23184 | return ira->codegen->invalid_instruction; | 23222 | return ira->codegen->invalid_instruction; |
| 23185 | | 23223 | |
| 23186 | bool src_ptr_const; | 23224 | bool src_ptr_const; |
| 23187 | bool src_ptr_volatile; | 23225 | bool src_ptr_volatile; |
| 23188 | uint32_t src_ptr_align; | 23226 | uint32_t src_ptr_align; |
| 23189 | if (target->value.type->id == ZigTypeIdPointer) { | 23227 | if (target->value->type->id == ZigTypeIdPointer) { |
| 23190 | src_ptr_const = target->value.type->data.pointer.is_const; | 23228 | src_ptr_const = target->value->type->data.pointer.is_const; |
| 23191 | src_ptr_volatile = target->value.type->data.pointer.is_volatile; | 23229 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; |
| 23192 | | 23230 | |
| 23193 | if ((err = resolve_ptr_align(ira, target->value.type, &src_ptr_align))) | 23231 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) |
| 23194 | return ira->codegen->invalid_instruction; | 23232 | return ira->codegen->invalid_instruction; |
| 23195 | } else if (is_slice(target->value.type)) { | 23233 | } else if (is_slice(target->value->type)) { |
| 23196 | ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 23234 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 23197 | src_ptr_const = src_ptr_type->data.pointer.is_const; | 23235 | src_ptr_const = src_ptr_type->data.pointer.is_const; |
| 23198 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; | 23236 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; |
| 23199 | | 23237 | |
| ... | @@ -23203,10 +23241,10 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23203,10 +23241,10 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23203 | src_ptr_const = true; | 23241 | src_ptr_const = true; |
| 23204 | src_ptr_volatile = false; | 23242 | src_ptr_volatile = false; |
| 23205 | | 23243 | |
| 23206 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusAlignmentKnown))) | 23244 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) |
| 23207 | return ira->codegen->invalid_instruction; | 23245 | return ira->codegen->invalid_instruction; |
| 23208 | | 23246 | |
| 23209 | src_ptr_align = get_abi_alignment(ira->codegen, target->value.type); | 23247 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); |
| 23210 | } | 23248 | } |
| 23211 | | 23249 | |
| 23212 | if (src_ptr_align != 0) { | 23250 | if (src_ptr_align != 0) { |
| ... | @@ -23225,18 +23263,18 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23225,18 +23263,18 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23225 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); | 23263 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 23226 | | 23264 | |
| 23227 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); | 23265 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); |
| 23228 | if (type_is_invalid(casted_value->value.type)) | 23266 | if (type_is_invalid(casted_value->value->type)) |
| 23229 | return ira->codegen->invalid_instruction; | 23267 | return ira->codegen->invalid_instruction; |
| 23230 | | 23268 | |
| 23231 | bool have_known_len = false; | 23269 | bool have_known_len = false; |
| 23232 | uint64_t known_len; | 23270 | uint64_t known_len; |
| 23233 | | 23271 | |
| 23234 | if (instr_is_comptime(casted_value)) { | 23272 | if (instr_is_comptime(casted_value)) { |
| 23235 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 23273 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 23236 | if (!val) | 23274 | if (!val) |
| 23237 | return ira->codegen->invalid_instruction; | 23275 | return ira->codegen->invalid_instruction; |
| 23238 | | 23276 | |
| 23239 | ConstExprValue *len_val = val->data.x_struct.fields[slice_len_index]; | 23277 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; |
| 23240 | if (value_is_comptime(len_val)) { | 23278 | if (value_is_comptime(len_val)) { |
| 23241 | known_len = bigint_as_u64(&len_val->data.x_bigint); | 23279 | known_len = bigint_as_u64(&len_val->data.x_bigint); |
| 23242 | have_known_len = true; | 23280 | have_known_len = true; |
| ... | @@ -23245,12 +23283,12 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23245,12 +23283,12 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23245 | | 23283 | |
| 23246 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 23284 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 23247 | dest_slice_type, nullptr, true, false, true); | 23285 | dest_slice_type, nullptr, true, false, true); |
| 23248 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) { | 23286 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) { |
| 23249 | return result_loc; | 23287 | return result_loc; |
| 23250 | } | 23288 | } |
| 23251 | | 23289 | |
| 23252 | if (casted_value->value.data.rh_slice.id == RuntimeHintSliceIdLen) { | 23290 | if (casted_value->value->data.rh_slice.id == RuntimeHintSliceIdLen) { |
| 23253 | known_len = casted_value->value.data.rh_slice.len; | 23291 | known_len = casted_value->value->data.rh_slice.len; |
| 23254 | have_known_len = true; | 23292 | have_known_len = true; |
| 23255 | } | 23293 | } |
| 23256 | | 23294 | |
| ... | @@ -23277,16 +23315,16 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23277,16 +23315,16 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23277 | Error err; | 23315 | Error err; |
| 23278 | | 23316 | |
| 23279 | IrInstruction *target = instruction->target->child; | 23317 | IrInstruction *target = instruction->target->child; |
| 23280 | if (type_is_invalid(target->value.type)) | 23318 | if (type_is_invalid(target->value->type)) |
| 23281 | return ira->codegen->invalid_instruction; | 23319 | return ira->codegen->invalid_instruction; |
| 23282 | | 23320 | |
| 23283 | if (!is_slice(target->value.type)) { | 23321 | if (!is_slice(target->value->type)) { |
| 23284 | ir_add_error(ira, instruction->target, | 23322 | ir_add_error(ira, instruction->target, |
| 23285 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name))); | 23323 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); |
| 23286 | return ira->codegen->invalid_instruction; | 23324 | return ira->codegen->invalid_instruction; |
| 23287 | } | 23325 | } |
| 23288 | | 23326 | |
| 23289 | ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 23327 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 23290 | | 23328 | |
| 23291 | uint32_t alignment; | 23329 | uint32_t alignment; |
| 23292 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) | 23330 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) |
| ... | @@ -23298,22 +23336,22 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23298,22 +23336,22 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23298 | ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type); | 23336 | ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type); |
| 23299 | | 23337 | |
| 23300 | if (instr_is_comptime(target)) { | 23338 | if (instr_is_comptime(target)) { |
| 23301 | ConstExprValue *target_val = ir_resolve_const(ira, target, UndefBad); | 23339 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); |
| 23302 | if (target_val == nullptr) | 23340 | if (target_val == nullptr) |
| 23303 | return ira->codegen->invalid_instruction; | 23341 | return ira->codegen->invalid_instruction; |
| 23304 | | 23342 | |
| 23305 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 23343 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); |
| 23306 | result->value.data.x_struct.fields = alloc_const_vals_ptrs(2); | 23344 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 23307 | | 23345 | |
| 23308 | ConstExprValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index]; | 23346 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; |
| 23309 | ConstExprValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; | 23347 | ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; |
| 23310 | copy_const_val(ptr_val, target_ptr_val, false); | 23348 | copy_const_val(ptr_val, target_ptr_val, false); |
| 23311 | ptr_val->type = dest_ptr_type; | 23349 | ptr_val->type = dest_ptr_type; |
| 23312 | | 23350 | |
| 23313 | ConstExprValue *len_val = result->value.data.x_struct.fields[slice_len_index]; | 23351 | ZigValue *len_val = result->value->data.x_struct.fields[slice_len_index]; |
| 23314 | len_val->special = ConstValSpecialStatic; | 23352 | len_val->special = ConstValSpecialStatic; |
| 23315 | len_val->type = ira->codegen->builtin_types.entry_usize; | 23353 | len_val->type = ira->codegen->builtin_types.entry_usize; |
| 23316 | ConstExprValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; | 23354 | ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; |
| 23317 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; | 23355 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; |
| 23318 | BigInt elem_size_bigint; | 23356 | BigInt elem_size_bigint; |
| 23319 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); | 23357 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); |
| ... | @@ -23324,7 +23362,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23324,7 +23362,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23324 | | 23362 | |
| 23325 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 23363 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 23326 | dest_slice_type, nullptr, true, false, true); | 23364 | dest_slice_type, nullptr, true, false, true); |
| 23327 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 23365 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 23328 | return result_loc; | 23366 | return result_loc; |
| 23329 | } | 23367 | } |
| 23330 | | 23368 | |
| ... | @@ -23351,12 +23389,12 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst | ... | @@ -23351,12 +23389,12 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst |
| 23351 | return ira->codegen->invalid_instruction; | 23389 | return ira->codegen->invalid_instruction; |
| 23352 | | 23390 | |
| 23353 | IrInstruction *target = instruction->target->child; | 23391 | IrInstruction *target = instruction->target->child; |
| 23354 | if (type_is_invalid(target->value.type)) | 23392 | if (type_is_invalid(target->value->type)) |
| 23355 | return ira->codegen->invalid_instruction; | 23393 | return ira->codegen->invalid_instruction; |
| 23356 | | 23394 | |
| 23357 | if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) { | 23395 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 23358 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", | 23396 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", |
| 23359 | buf_ptr(&target->value.type->name))); | 23397 | buf_ptr(&target->value->type->name))); |
| 23360 | return ira->codegen->invalid_instruction; | 23398 | return ira->codegen->invalid_instruction; |
| 23361 | } | 23399 | } |
| 23362 | | 23400 | |
| ... | @@ -23369,16 +23407,16 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst | ... | @@ -23369,16 +23407,16 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 23369 | return ira->codegen->invalid_instruction; | 23407 | return ira->codegen->invalid_instruction; |
| 23370 | | 23408 | |
| 23371 | IrInstruction *target = instruction->target->child; | 23409 | IrInstruction *target = instruction->target->child; |
| 23372 | if (type_is_invalid(target->value.type)) | 23410 | if (type_is_invalid(target->value->type)) |
| 23373 | return ira->codegen->invalid_instruction; | 23411 | return ira->codegen->invalid_instruction; |
| 23374 | | 23412 | |
| 23375 | if (target->value.type->id == ZigTypeIdComptimeInt) { | 23413 | if (target->value->type->id == ZigTypeIdComptimeInt) { |
| 23376 | return ir_implicit_cast(ira, target, dest_type); | 23414 | return ir_implicit_cast(ira, target, dest_type); |
| 23377 | } | 23415 | } |
| 23378 | | 23416 | |
| 23379 | if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) { | 23417 | if (target->value->type->id != ZigTypeIdFloat && target->value->type->id != ZigTypeIdComptimeFloat) { |
| 23380 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 23418 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 23381 | buf_ptr(&target->value.type->name))); | 23419 | buf_ptr(&target->value->type->name))); |
| 23382 | return ira->codegen->invalid_instruction; | 23420 | return ira->codegen->invalid_instruction; |
| 23383 | } | 23421 | } |
| 23384 | | 23422 | |
| ... | @@ -23387,15 +23425,15 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst | ... | @@ -23387,15 +23425,15 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 23387 | | 23425 | |
| 23388 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { | 23426 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { |
| 23389 | IrInstruction *target = instruction->target->child; | 23427 | IrInstruction *target = instruction->target->child; |
| 23390 | if (type_is_invalid(target->value.type)) | 23428 | if (type_is_invalid(target->value->type)) |
| 23391 | return ira->codegen->invalid_instruction; | 23429 | return ira->codegen->invalid_instruction; |
| 23392 | | 23430 | |
| 23393 | IrInstruction *casted_target; | 23431 | IrInstruction *casted_target; |
| 23394 | if (target->value.type->id == ZigTypeIdErrorSet) { | 23432 | if (target->value->type->id == ZigTypeIdErrorSet) { |
| 23395 | casted_target = target; | 23433 | casted_target = target; |
| 23396 | } else { | 23434 | } else { |
| 23397 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); | 23435 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| 23398 | if (type_is_invalid(casted_target->value.type)) | 23436 | if (type_is_invalid(casted_target->value->type)) |
| 23399 | return ira->codegen->invalid_instruction; | 23437 | return ira->codegen->invalid_instruction; |
| 23400 | } | 23438 | } |
| 23401 | | 23439 | |
| ... | @@ -23404,11 +23442,11 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru | ... | @@ -23404,11 +23442,11 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru |
| 23404 | | 23442 | |
| 23405 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { | 23443 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { |
| 23406 | IrInstruction *target = instruction->target->child; | 23444 | IrInstruction *target = instruction->target->child; |
| 23407 | if (type_is_invalid(target->value.type)) | 23445 | if (type_is_invalid(target->value->type)) |
| 23408 | return ira->codegen->invalid_instruction; | 23446 | return ira->codegen->invalid_instruction; |
| 23409 | | 23447 | |
| 23410 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | 23448 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); |
| 23411 | if (type_is_invalid(casted_target->value.type)) | 23449 | if (type_is_invalid(casted_target->value->type)) |
| 23412 | return ira->codegen->invalid_instruction; | 23450 | return ira->codegen->invalid_instruction; |
| 23413 | | 23451 | |
| 23414 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); | 23452 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); |
| ... | @@ -23416,12 +23454,12 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru | ... | @@ -23416,12 +23454,12 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru |
| 23416 | | 23454 | |
| 23417 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { | 23455 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { |
| 23418 | IrInstruction *target = instruction->target->child; | 23456 | IrInstruction *target = instruction->target->child; |
| 23419 | if (type_is_invalid(target->value.type)) | 23457 | if (type_is_invalid(target->value->type)) |
| 23420 | return ira->codegen->invalid_instruction; | 23458 | return ira->codegen->invalid_instruction; |
| 23421 | | 23459 | |
| 23422 | if (target->value.type->id != ZigTypeIdBool) { | 23460 | if (target->value->type->id != ZigTypeIdBool) { |
| 23423 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 23461 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", |
| 23424 | buf_ptr(&target->value.type->name))); | 23462 | buf_ptr(&target->value->type->name))); |
| 23425 | return ira->codegen->invalid_instruction; | 23463 | return ira->codegen->invalid_instruction; |
| 23426 | } | 23464 | } |
| 23427 | | 23465 | |
| ... | @@ -23472,48 +23510,48 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23472,48 +23510,48 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23472 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); | 23510 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); |
| 23473 | | 23511 | |
| 23474 | uint32_t len_mask; | 23512 | uint32_t len_mask; |
| 23475 | if (mask->value.type->id == ZigTypeIdVector) { | 23513 | if (mask->value->type->id == ZigTypeIdVector) { |
| 23476 | len_mask = mask->value.type->data.vector.len; | 23514 | len_mask = mask->value->type->data.vector.len; |
| 23477 | } else if (mask->value.type->id == ZigTypeIdArray) { | 23515 | } else if (mask->value->type->id == ZigTypeIdArray) { |
| 23478 | len_mask = mask->value.type->data.array.len; | 23516 | len_mask = mask->value->type->data.array.len; |
| 23479 | } else { | 23517 | } else { |
| 23480 | ir_add_error(ira, mask, | 23518 | ir_add_error(ira, mask, |
| 23481 | buf_sprintf("expected vector or array, found '%s'", | 23519 | buf_sprintf("expected vector or array, found '%s'", |
| 23482 | buf_ptr(&mask->value.type->name))); | 23520 | buf_ptr(&mask->value->type->name))); |
| 23483 | return ira->codegen->invalid_instruction; | 23521 | return ira->codegen->invalid_instruction; |
| 23484 | } | 23522 | } |
| 23485 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, | 23523 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, |
| 23486 | ira->codegen->builtin_types.entry_i32)); | 23524 | ira->codegen->builtin_types.entry_i32)); |
| 23487 | if (type_is_invalid(mask->value.type)) | 23525 | if (type_is_invalid(mask->value->type)) |
| 23488 | return ira->codegen->invalid_instruction; | 23526 | return ira->codegen->invalid_instruction; |
| 23489 | | 23527 | |
| 23490 | uint32_t len_a; | 23528 | uint32_t len_a; |
| 23491 | if (a->value.type->id == ZigTypeIdVector) { | 23529 | if (a->value->type->id == ZigTypeIdVector) { |
| 23492 | len_a = a->value.type->data.vector.len; | 23530 | len_a = a->value->type->data.vector.len; |
| 23493 | } else if (a->value.type->id == ZigTypeIdArray) { | 23531 | } else if (a->value->type->id == ZigTypeIdArray) { |
| 23494 | len_a = a->value.type->data.array.len; | 23532 | len_a = a->value->type->data.array.len; |
| 23495 | } else if (a->value.type->id == ZigTypeIdUndefined) { | 23533 | } else if (a->value->type->id == ZigTypeIdUndefined) { |
| 23496 | len_a = UINT32_MAX; | 23534 | len_a = UINT32_MAX; |
| 23497 | } else { | 23535 | } else { |
| 23498 | ir_add_error(ira, a, | 23536 | ir_add_error(ira, a, |
| 23499 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 23537 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 23500 | buf_ptr(&scalar_type->name), | 23538 | buf_ptr(&scalar_type->name), |
| 23501 | buf_ptr(&a->value.type->name))); | 23539 | buf_ptr(&a->value->type->name))); |
| 23502 | return ira->codegen->invalid_instruction; | 23540 | return ira->codegen->invalid_instruction; |
| 23503 | } | 23541 | } |
| 23504 | | 23542 | |
| 23505 | uint32_t len_b; | 23543 | uint32_t len_b; |
| 23506 | if (b->value.type->id == ZigTypeIdVector) { | 23544 | if (b->value->type->id == ZigTypeIdVector) { |
| 23507 | len_b = b->value.type->data.vector.len; | 23545 | len_b = b->value->type->data.vector.len; |
| 23508 | } else if (b->value.type->id == ZigTypeIdArray) { | 23546 | } else if (b->value->type->id == ZigTypeIdArray) { |
| 23509 | len_b = b->value.type->data.array.len; | 23547 | len_b = b->value->type->data.array.len; |
| 23510 | } else if (b->value.type->id == ZigTypeIdUndefined) { | 23548 | } else if (b->value->type->id == ZigTypeIdUndefined) { |
| 23511 | len_b = UINT32_MAX; | 23549 | len_b = UINT32_MAX; |
| 23512 | } else { | 23550 | } else { |
| 23513 | ir_add_error(ira, b, | 23551 | ir_add_error(ira, b, |
| 23514 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 23552 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 23515 | buf_ptr(&scalar_type->name), | 23553 | buf_ptr(&scalar_type->name), |
| 23516 | buf_ptr(&b->value.type->name))); | 23554 | buf_ptr(&b->value->type->name))); |
| 23517 | return ira->codegen->invalid_instruction; | 23555 | return ira->codegen->invalid_instruction; |
| 23518 | } | 23556 | } |
| 23519 | | 23557 | |
| ... | @@ -23526,7 +23564,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23526,7 +23564,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23526 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 23564 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23527 | } else { | 23565 | } else { |
| 23528 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 23566 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23529 | if (type_is_invalid(a->value.type)) | 23567 | if (type_is_invalid(a->value->type)) |
| 23530 | return ira->codegen->invalid_instruction; | 23568 | return ira->codegen->invalid_instruction; |
| 23531 | } | 23569 | } |
| 23532 | | 23570 | |
| ... | @@ -23535,18 +23573,18 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23535,18 +23573,18 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23535 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 23573 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23536 | } else { | 23574 | } else { |
| 23537 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 23575 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23538 | if (type_is_invalid(b->value.type)) | 23576 | if (type_is_invalid(b->value->type)) |
| 23539 | return ira->codegen->invalid_instruction; | 23577 | return ira->codegen->invalid_instruction; |
| 23540 | } | 23578 | } |
| 23541 | | 23579 | |
| 23542 | ConstExprValue *mask_val = ir_resolve_const(ira, mask, UndefOk); | 23580 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); |
| 23543 | if (mask_val == nullptr) | 23581 | if (mask_val == nullptr) |
| 23544 | return ira->codegen->invalid_instruction; | 23582 | return ira->codegen->invalid_instruction; |
| 23545 | | 23583 | |
| 23546 | expand_undef_array(ira->codegen, mask_val); | 23584 | expand_undef_array(ira->codegen, mask_val); |
| 23547 | | 23585 | |
| 23548 | for (uint32_t i = 0; i < len_mask; i += 1) { | 23586 | for (uint32_t i = 0; i < len_mask; i += 1) { |
| 23549 | ConstExprValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; | 23587 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| 23550 | if (mask_elem_val->special == ConstValSpecialUndef) | 23588 | if (mask_elem_val->special == ConstValSpecialUndef) |
| 23551 | continue; | 23589 | continue; |
| 23552 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); | 23590 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| ... | @@ -23559,12 +23597,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23559,12 +23597,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23559 | v = (uint32_t)~v_i32; | 23597 | v = (uint32_t)~v_i32; |
| 23560 | chosen_operand = b; | 23598 | chosen_operand = b; |
| 23561 | } | 23599 | } |
| 23562 | if (v >= chosen_operand->value.type->data.vector.len) { | 23600 | if (v >= chosen_operand->value->type->data.vector.len) { |
| 23563 | ErrorMsg *msg = ir_add_error(ira, mask, | 23601 | ErrorMsg *msg = ir_add_error(ira, mask, |
| 23564 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); | 23602 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); |
| 23565 | add_error_note(ira->codegen, msg, chosen_operand->source_node, | 23603 | add_error_note(ira->codegen, msg, chosen_operand->source_node, |
| 23566 | buf_sprintf("selected index '%u' out of bounds of %s", v, | 23604 | buf_sprintf("selected index '%u' out of bounds of %s", v, |
| 23567 | buf_ptr(&chosen_operand->value.type->name))); | 23605 | buf_ptr(&chosen_operand->value->type->name))); |
| 23568 | if (chosen_operand == a && v < len_a + len_b) { | 23606 | if (chosen_operand == a && v < len_a + len_b) { |
| 23569 | add_error_note(ira->codegen, msg, b->source_node, | 23607 | add_error_note(ira->codegen, msg, b->source_node, |
| 23570 | buf_create_from_str("selections from the second vector are specified with negative numbers")); | 23608 | buf_create_from_str("selections from the second vector are specified with negative numbers")); |
| ... | @@ -23575,11 +23613,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23575,11 +23613,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23575 | | 23613 | |
| 23576 | ZigType *result_type = get_vector_type(ira->codegen, len_mask, scalar_type); | 23614 | ZigType *result_type = get_vector_type(ira->codegen, len_mask, scalar_type); |
| 23577 | if (instr_is_comptime(a) && instr_is_comptime(b)) { | 23615 | if (instr_is_comptime(a) && instr_is_comptime(b)) { |
| 23578 | ConstExprValue *a_val = ir_resolve_const(ira, a, UndefOk); | 23616 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); |
| 23579 | if (a_val == nullptr) | 23617 | if (a_val == nullptr) |
| 23580 | return ira->codegen->invalid_instruction; | 23618 | return ira->codegen->invalid_instruction; |
| 23581 | | 23619 | |
| 23582 | ConstExprValue *b_val = ir_resolve_const(ira, b, UndefOk); | 23620 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); |
| 23583 | if (b_val == nullptr) | 23621 | if (b_val == nullptr) |
| 23584 | return ira->codegen->invalid_instruction; | 23622 | return ira->codegen->invalid_instruction; |
| 23585 | | 23623 | |
| ... | @@ -23587,24 +23625,24 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23587,24 +23625,24 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23587 | expand_undef_array(ira->codegen, b_val); | 23625 | expand_undef_array(ira->codegen, b_val); |
| 23588 | | 23626 | |
| 23589 | IrInstruction *result = ir_const(ira, source_instr, result_type); | 23627 | IrInstruction *result = ir_const(ira, source_instr, result_type); |
| 23590 | result->value.data.x_array.data.s_none.elements = create_const_vals(len_mask); | 23628 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); |
| 23591 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { | 23629 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 23592 | ConstExprValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; | 23630 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| 23593 | ConstExprValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; | 23631 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 23594 | if (mask_elem_val->special == ConstValSpecialUndef) { | 23632 | if (mask_elem_val->special == ConstValSpecialUndef) { |
| 23595 | result_elem_val->special = ConstValSpecialUndef; | 23633 | result_elem_val->special = ConstValSpecialUndef; |
| 23596 | continue; | 23634 | continue; |
| 23597 | } | 23635 | } |
| 23598 | int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint); | 23636 | int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| 23599 | // We've already checked for and emitted compile errors for index out of bounds here. | 23637 | // We've already checked for and emitted compile errors for index out of bounds here. |
| 23600 | ConstExprValue *src_elem_val = (v >= 0) ? | 23638 | ZigValue *src_elem_val = (v >= 0) ? |
| 23601 | &a->value.data.x_array.data.s_none.elements[v] : | 23639 | &a->value->data.x_array.data.s_none.elements[v] : |
| 23602 | &b->value.data.x_array.data.s_none.elements[~v]; | 23640 | &b->value->data.x_array.data.s_none.elements[~v]; |
| 23603 | copy_const_val(result_elem_val, src_elem_val, false); | 23641 | copy_const_val(result_elem_val, src_elem_val, false); |
| 23604 | | 23642 | |
| 23605 | ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr); | 23643 | ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr); |
| 23606 | } | 23644 | } |
| 23607 | result->value.special = ConstValSpecialStatic; | 23645 | result->value->special = ConstValSpecialStatic; |
| 23608 | return result; | 23646 | return result; |
| 23609 | } | 23647 | } |
| 23610 | | 23648 | |
| ... | @@ -23620,12 +23658,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23620,12 +23658,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23620 | | 23658 | |
| 23621 | IrInstruction *expand_mask = ir_const(ira, mask, | 23659 | IrInstruction *expand_mask = ir_const(ira, mask, |
| 23622 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); | 23660 | 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); | 23661 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); |
| 23624 | uint32_t i = 0; | 23662 | uint32_t i = 0; |
| 23625 | for (; i < len_min; i += 1) | 23663 | 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); | 23664 | bigint_init_unsigned(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, i); |
| 23627 | for (; i < len_max; i += 1) | 23665 | 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); | 23666 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); |
| 23629 | | 23667 | |
| 23630 | IrInstruction *undef = ir_const_undef(ira, source_instr, | 23668 | IrInstruction *undef = ir_const_undef(ira, source_instr, |
| 23631 | get_vector_type(ira->codegen, len_min, scalar_type)); | 23669 | get_vector_type(ira->codegen, len_min, scalar_type)); |
| ... | @@ -23640,7 +23678,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23640,7 +23678,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23640 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, | 23678 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, |
| 23641 | source_instr->scope, source_instr->source_node, | 23679 | source_instr->scope, source_instr->source_node, |
| 23642 | nullptr, a, b, mask); | 23680 | nullptr, a, b, mask); |
| 23643 | result->value.type = result_type; | 23681 | result->value->type = result_type; |
| 23644 | return result; | 23682 | return result; |
| 23645 | } | 23683 | } |
| 23646 | | 23684 | |
| ... | @@ -23650,15 +23688,15 @@ static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrIn | ... | @@ -23650,15 +23688,15 @@ static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrIn |
| 23650 | return ira->codegen->invalid_instruction; | 23688 | return ira->codegen->invalid_instruction; |
| 23651 | | 23689 | |
| 23652 | IrInstruction *a = instruction->a->child; | 23690 | IrInstruction *a = instruction->a->child; |
| 23653 | if (type_is_invalid(a->value.type)) | 23691 | if (type_is_invalid(a->value->type)) |
| 23654 | return ira->codegen->invalid_instruction; | 23692 | return ira->codegen->invalid_instruction; |
| 23655 | | 23693 | |
| 23656 | IrInstruction *b = instruction->b->child; | 23694 | IrInstruction *b = instruction->b->child; |
| 23657 | if (type_is_invalid(b->value.type)) | 23695 | if (type_is_invalid(b->value->type)) |
| 23658 | return ira->codegen->invalid_instruction; | 23696 | return ira->codegen->invalid_instruction; |
| 23659 | | 23697 | |
| 23660 | IrInstruction *mask = instruction->mask->child; | 23698 | IrInstruction *mask = instruction->mask->child; |
| 23661 | if (type_is_invalid(mask->value.type)) | 23699 | if (type_is_invalid(mask->value->type)) |
| 23662 | return ira->codegen->invalid_instruction; | 23700 | return ira->codegen->invalid_instruction; |
| 23663 | | 23701 | |
| 23664 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); | 23702 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); |
| ... | @@ -23668,11 +23706,11 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23668,11 +23706,11 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23668 | Error err; | 23706 | Error err; |
| 23669 | | 23707 | |
| 23670 | IrInstruction *len = instruction->len->child; | 23708 | IrInstruction *len = instruction->len->child; |
| 23671 | if (type_is_invalid(len->value.type)) | 23709 | if (type_is_invalid(len->value->type)) |
| 23672 | return ira->codegen->invalid_instruction; | 23710 | return ira->codegen->invalid_instruction; |
| 23673 | | 23711 | |
| 23674 | IrInstruction *scalar = instruction->scalar->child; | 23712 | IrInstruction *scalar = instruction->scalar->child; |
| 23675 | if (type_is_invalid(scalar->value.type)) | 23713 | if (type_is_invalid(scalar->value->type)) |
| 23676 | return ira->codegen->invalid_instruction; | 23714 | return ira->codegen->invalid_instruction; |
| 23677 | | 23715 | |
| 23678 | uint64_t len_u64; | 23716 | uint64_t len_u64; |
| ... | @@ -23680,22 +23718,22 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23680,22 +23718,22 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23680 | return ira->codegen->invalid_instruction; | 23718 | return ira->codegen->invalid_instruction; |
| 23681 | uint32_t len_int = len_u64; | 23719 | uint32_t len_int = len_u64; |
| 23682 | | 23720 | |
| 23683 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value.type))) | 23721 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value->type))) |
| 23684 | return ira->codegen->invalid_instruction; | 23722 | return ira->codegen->invalid_instruction; |
| 23685 | | 23723 | |
| 23686 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type); | 23724 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); |
| 23687 | | 23725 | |
| 23688 | if (instr_is_comptime(scalar)) { | 23726 | if (instr_is_comptime(scalar)) { |
| 23689 | ConstExprValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); | 23727 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); |
| 23690 | if (scalar_val == nullptr) | 23728 | if (scalar_val == nullptr) |
| 23691 | return ira->codegen->invalid_instruction; | 23729 | return ira->codegen->invalid_instruction; |
| 23692 | if (scalar_val->special == ConstValSpecialUndef) | 23730 | if (scalar_val->special == ConstValSpecialUndef) |
| 23693 | return ir_const_undef(ira, &instruction->base, return_type); | 23731 | return ir_const_undef(ira, &instruction->base, return_type); |
| 23694 | | 23732 | |
| 23695 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 23733 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 23696 | result->value.data.x_array.data.s_none.elements = create_const_vals(len_int); | 23734 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); |
| 23697 | for (uint32_t i = 0; i < len_int; i += 1) { | 23735 | 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); | 23736 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val, false); |
| 23699 | } | 23737 | } |
| 23700 | return result; | 23738 | return result; |
| 23701 | } | 23739 | } |
| ... | @@ -23705,17 +23743,17 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23705,17 +23743,17 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23705 | | 23743 | |
| 23706 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { | 23744 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { |
| 23707 | IrInstruction *value = instruction->value->child; | 23745 | IrInstruction *value = instruction->value->child; |
| 23708 | if (type_is_invalid(value->value.type)) | 23746 | if (type_is_invalid(value->value->type)) |
| 23709 | return ira->codegen->invalid_instruction; | 23747 | return ira->codegen->invalid_instruction; |
| 23710 | | 23748 | |
| 23711 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 23749 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 23712 | | 23750 | |
| 23713 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); | 23751 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 23714 | if (type_is_invalid(casted_value->value.type)) | 23752 | if (type_is_invalid(casted_value->value->type)) |
| 23715 | return ira->codegen->invalid_instruction; | 23753 | return ira->codegen->invalid_instruction; |
| 23716 | | 23754 | |
| 23717 | if (instr_is_comptime(casted_value)) { | 23755 | if (instr_is_comptime(casted_value)) { |
| 23718 | ConstExprValue *value = ir_resolve_const(ira, casted_value, UndefBad); | 23756 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); |
| 23719 | if (value == nullptr) | 23757 | if (value == nullptr) |
| 23720 | return ira->codegen->invalid_instruction; | 23758 | return ira->codegen->invalid_instruction; |
| 23721 | | 23759 | |
| ... | @@ -23724,7 +23762,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct | ... | @@ -23724,7 +23762,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct |
| 23724 | | 23762 | |
| 23725 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, | 23763 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, |
| 23726 | instruction->base.source_node, casted_value); | 23764 | instruction->base.source_node, casted_value); |
| 23727 | result->value.type = bool_type; | 23765 | result->value->type = bool_type; |
| 23728 | return result; | 23766 | return result; |
| 23729 | } | 23767 | } |
| 23730 | | 23768 | |
| ... | @@ -23732,18 +23770,18 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23732,18 +23770,18 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23732 | Error err; | 23770 | Error err; |
| 23733 | | 23771 | |
| 23734 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 23772 | IrInstruction *dest_ptr = instruction->dest_ptr->child; |
| 23735 | if (type_is_invalid(dest_ptr->value.type)) | 23773 | if (type_is_invalid(dest_ptr->value->type)) |
| 23736 | return ira->codegen->invalid_instruction; | 23774 | return ira->codegen->invalid_instruction; |
| 23737 | | 23775 | |
| 23738 | IrInstruction *byte_value = instruction->byte->child; | 23776 | IrInstruction *byte_value = instruction->byte->child; |
| 23739 | if (type_is_invalid(byte_value->value.type)) | 23777 | if (type_is_invalid(byte_value->value->type)) |
| 23740 | return ira->codegen->invalid_instruction; | 23778 | return ira->codegen->invalid_instruction; |
| 23741 | | 23779 | |
| 23742 | IrInstruction *count_value = instruction->count->child; | 23780 | IrInstruction *count_value = instruction->count->child; |
| 23743 | if (type_is_invalid(count_value->value.type)) | 23781 | if (type_is_invalid(count_value->value->type)) |
| 23744 | return ira->codegen->invalid_instruction; | 23782 | return ira->codegen->invalid_instruction; |
| 23745 | | 23783 | |
| 23746 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 23784 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 23747 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 23785 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 23748 | dest_uncasted_type->data.pointer.is_volatile; | 23786 | dest_uncasted_type->data.pointer.is_volatile; |
| 23749 | | 23787 | |
| ... | @@ -23760,15 +23798,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23760,15 +23798,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23760 | PtrLenUnknown, dest_align, 0, 0, false); | 23798 | PtrLenUnknown, dest_align, 0, 0, false); |
| 23761 | | 23799 | |
| 23762 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | 23800 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 23763 | if (type_is_invalid(casted_dest_ptr->value.type)) | 23801 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 23764 | return ira->codegen->invalid_instruction; | 23802 | return ira->codegen->invalid_instruction; |
| 23765 | | 23803 | |
| 23766 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); | 23804 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 23767 | if (type_is_invalid(casted_byte->value.type)) | 23805 | if (type_is_invalid(casted_byte->value->type)) |
| 23768 | return ira->codegen->invalid_instruction; | 23806 | return ira->codegen->invalid_instruction; |
| 23769 | | 23807 | |
| 23770 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 23808 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23771 | if (type_is_invalid(casted_count->value.type)) | 23809 | if (type_is_invalid(casted_count->value->type)) |
| 23772 | return ira->codegen->invalid_instruction; | 23810 | return ira->codegen->invalid_instruction; |
| 23773 | | 23811 | |
| 23774 | // TODO test this at comptime with u8 and non-u8 types | 23812 | // TODO test this at comptime with u8 and non-u8 types |
| ... | @@ -23776,22 +23814,22 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23776,22 +23814,22 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23776 | instr_is_comptime(casted_byte) && | 23814 | instr_is_comptime(casted_byte) && |
| 23777 | instr_is_comptime(casted_count)) | 23815 | instr_is_comptime(casted_count)) |
| 23778 | { | 23816 | { |
| 23779 | ConstExprValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 23817 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 23780 | if (dest_ptr_val == nullptr) | 23818 | if (dest_ptr_val == nullptr) |
| 23781 | return ira->codegen->invalid_instruction; | 23819 | return ira->codegen->invalid_instruction; |
| 23782 | | 23820 | |
| 23783 | ConstExprValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); | 23821 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); |
| 23784 | if (byte_val == nullptr) | 23822 | if (byte_val == nullptr) |
| 23785 | return ira->codegen->invalid_instruction; | 23823 | return ira->codegen->invalid_instruction; |
| 23786 | | 23824 | |
| 23787 | ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 23825 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 23788 | if (count_val == nullptr) | 23826 | if (count_val == nullptr) |
| 23789 | return ira->codegen->invalid_instruction; | 23827 | return ira->codegen->invalid_instruction; |
| 23790 | | 23828 | |
| 23791 | if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr && | 23829 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 23792 | casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 23830 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 23793 | { | 23831 | { |
| 23794 | ConstExprValue *dest_elements; | 23832 | ZigValue *dest_elements; |
| 23795 | size_t start; | 23833 | size_t start; |
| 23796 | size_t bound_end; | 23834 | size_t bound_end; |
| 23797 | switch (dest_ptr_val->data.x_ptr.special) { | 23835 | switch (dest_ptr_val->data.x_ptr.special) { |
| ... | @@ -23805,7 +23843,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23805,7 +23843,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23805 | break; | 23843 | break; |
| 23806 | case ConstPtrSpecialBaseArray: | 23844 | case ConstPtrSpecialBaseArray: |
| 23807 | { | 23845 | { |
| 23808 | ConstExprValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; | 23846 | ZigValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23809 | expand_undef_array(ira->codegen, array_val); | 23847 | expand_undef_array(ira->codegen, array_val); |
| 23810 | dest_elements = array_val->data.x_array.data.s_none.elements; | 23848 | dest_elements = array_val->data.x_array.data.s_none.elements; |
| 23811 | start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; | 23849 | start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -23845,7 +23883,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23845,7 +23883,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23845 | | 23883 | |
| 23846 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 23884 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 23847 | casted_dest_ptr, casted_byte, casted_count); | 23885 | casted_dest_ptr, casted_byte, casted_count); |
| 23848 | result->value.type = ira->codegen->builtin_types.entry_void; | 23886 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 23849 | return result; | 23887 | return result; |
| 23850 | } | 23888 | } |
| 23851 | | 23889 | |
| ... | @@ -23853,20 +23891,20 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23853,20 +23891,20 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23853 | Error err; | 23891 | Error err; |
| 23854 | | 23892 | |
| 23855 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 23893 | IrInstruction *dest_ptr = instruction->dest_ptr->child; |
| 23856 | if (type_is_invalid(dest_ptr->value.type)) | 23894 | if (type_is_invalid(dest_ptr->value->type)) |
| 23857 | return ira->codegen->invalid_instruction; | 23895 | return ira->codegen->invalid_instruction; |
| 23858 | | 23896 | |
| 23859 | IrInstruction *src_ptr = instruction->src_ptr->child; | 23897 | IrInstruction *src_ptr = instruction->src_ptr->child; |
| 23860 | if (type_is_invalid(src_ptr->value.type)) | 23898 | if (type_is_invalid(src_ptr->value->type)) |
| 23861 | return ira->codegen->invalid_instruction; | 23899 | return ira->codegen->invalid_instruction; |
| 23862 | | 23900 | |
| 23863 | IrInstruction *count_value = instruction->count->child; | 23901 | IrInstruction *count_value = instruction->count->child; |
| 23864 | if (type_is_invalid(count_value->value.type)) | 23902 | if (type_is_invalid(count_value->value->type)) |
| 23865 | return ira->codegen->invalid_instruction; | 23903 | return ira->codegen->invalid_instruction; |
| 23866 | | 23904 | |
| 23867 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 23905 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 23868 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 23906 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 23869 | ZigType *src_uncasted_type = src_ptr->value.type; | 23907 | ZigType *src_uncasted_type = src_ptr->value->type; |
| 23870 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 23908 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 23871 | dest_uncasted_type->data.pointer.is_volatile; | 23909 | dest_uncasted_type->data.pointer.is_volatile; |
| 23872 | bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) && | 23910 | bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) && |
| ... | @@ -23895,15 +23933,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23895,15 +23933,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23895 | PtrLenUnknown, src_align, 0, 0, false); | 23933 | PtrLenUnknown, src_align, 0, 0, false); |
| 23896 | | 23934 | |
| 23897 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | 23935 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 23898 | if (type_is_invalid(casted_dest_ptr->value.type)) | 23936 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 23899 | return ira->codegen->invalid_instruction; | 23937 | return ira->codegen->invalid_instruction; |
| 23900 | | 23938 | |
| 23901 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | 23939 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 23902 | if (type_is_invalid(casted_src_ptr->value.type)) | 23940 | if (type_is_invalid(casted_src_ptr->value->type)) |
| 23903 | return ira->codegen->invalid_instruction; | 23941 | return ira->codegen->invalid_instruction; |
| 23904 | | 23942 | |
| 23905 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 23943 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23906 | if (type_is_invalid(casted_count->value.type)) | 23944 | if (type_is_invalid(casted_count->value->type)) |
| 23907 | return ira->codegen->invalid_instruction; | 23945 | return ira->codegen->invalid_instruction; |
| 23908 | | 23946 | |
| 23909 | // TODO test this at comptime with u8 and non-u8 types | 23947 | // TODO test this at comptime with u8 and non-u8 types |
| ... | @@ -23912,22 +23950,22 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23912,22 +23950,22 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23912 | instr_is_comptime(casted_src_ptr) && | 23950 | instr_is_comptime(casted_src_ptr) && |
| 23913 | instr_is_comptime(casted_count)) | 23951 | instr_is_comptime(casted_count)) |
| 23914 | { | 23952 | { |
| 23915 | ConstExprValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 23953 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 23916 | if (dest_ptr_val == nullptr) | 23954 | if (dest_ptr_val == nullptr) |
| 23917 | return ira->codegen->invalid_instruction; | 23955 | return ira->codegen->invalid_instruction; |
| 23918 | | 23956 | |
| 23919 | ConstExprValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); | 23957 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); |
| 23920 | if (src_ptr_val == nullptr) | 23958 | if (src_ptr_val == nullptr) |
| 23921 | return ira->codegen->invalid_instruction; | 23959 | return ira->codegen->invalid_instruction; |
| 23922 | | 23960 | |
| 23923 | ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 23961 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 23924 | if (count_val == nullptr) | 23962 | if (count_val == nullptr) |
| 23925 | return ira->codegen->invalid_instruction; | 23963 | return ira->codegen->invalid_instruction; |
| 23926 | | 23964 | |
| 23927 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 23965 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 23928 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 23966 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| 23929 | | 23967 | |
| 23930 | ConstExprValue *dest_elements; | 23968 | ZigValue *dest_elements; |
| 23931 | size_t dest_start; | 23969 | size_t dest_start; |
| 23932 | size_t dest_end; | 23970 | size_t dest_end; |
| 23933 | switch (dest_ptr_val->data.x_ptr.special) { | 23971 | switch (dest_ptr_val->data.x_ptr.special) { |
| ... | @@ -23941,7 +23979,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23941,7 +23979,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23941 | break; | 23979 | break; |
| 23942 | case ConstPtrSpecialBaseArray: | 23980 | case ConstPtrSpecialBaseArray: |
| 23943 | { | 23981 | { |
| 23944 | ConstExprValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; | 23982 | ZigValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23945 | expand_undef_array(ira->codegen, array_val); | 23983 | expand_undef_array(ira->codegen, array_val); |
| 23946 | dest_elements = array_val->data.x_array.data.s_none.elements; | 23984 | dest_elements = array_val->data.x_array.data.s_none.elements; |
| 23947 | dest_start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; | 23985 | dest_start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -23969,7 +24007,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23969,7 +24007,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23969 | return ira->codegen->invalid_instruction; | 24007 | return ira->codegen->invalid_instruction; |
| 23970 | } | 24008 | } |
| 23971 | | 24009 | |
| 23972 | ConstExprValue *src_elements; | 24010 | ZigValue *src_elements; |
| 23973 | size_t src_start; | 24011 | size_t src_start; |
| 23974 | size_t src_end; | 24012 | size_t src_end; |
| 23975 | | 24013 | |
| ... | @@ -23984,7 +24022,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23984,7 +24022,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23984 | break; | 24022 | break; |
| 23985 | case ConstPtrSpecialBaseArray: | 24023 | case ConstPtrSpecialBaseArray: |
| 23986 | { | 24024 | { |
| 23987 | ConstExprValue *array_val = src_ptr_val->data.x_ptr.data.base_array.array_val; | 24025 | ZigValue *array_val = src_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23988 | expand_undef_array(ira->codegen, array_val); | 24026 | expand_undef_array(ira->codegen, array_val); |
| 23989 | src_elements = array_val->data.x_array.data.s_none.elements; | 24027 | src_elements = array_val->data.x_array.data.s_none.elements; |
| 23990 | src_start = src_ptr_val->data.x_ptr.data.base_array.elem_index; | 24028 | src_start = src_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -24024,35 +24062,35 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -24024,35 +24062,35 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 24024 | | 24062 | |
| 24025 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 24063 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 24026 | casted_dest_ptr, casted_src_ptr, casted_count); | 24064 | casted_dest_ptr, casted_src_ptr, casted_count); |
| 24027 | result->value.type = ira->codegen->builtin_types.entry_void; | 24065 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 24028 | return result; | 24066 | return result; |
| 24029 | } | 24067 | } |
| 24030 | | 24068 | |
| 24031 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { | 24069 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { |
| 24032 | IrInstruction *ptr_ptr = instruction->ptr->child; | 24070 | IrInstruction *ptr_ptr = instruction->ptr->child; |
| 24033 | if (type_is_invalid(ptr_ptr->value.type)) | 24071 | if (type_is_invalid(ptr_ptr->value->type)) |
| 24034 | return ira->codegen->invalid_instruction; | 24072 | return ira->codegen->invalid_instruction; |
| 24035 | | 24073 | |
| 24036 | ZigType *ptr_ptr_type = ptr_ptr->value.type; | 24074 | ZigType *ptr_ptr_type = ptr_ptr->value->type; |
| 24037 | assert(ptr_ptr_type->id == ZigTypeIdPointer); | 24075 | assert(ptr_ptr_type->id == ZigTypeIdPointer); |
| 24038 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; | 24076 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; |
| 24039 | | 24077 | |
| 24040 | IrInstruction *start = instruction->start->child; | 24078 | IrInstruction *start = instruction->start->child; |
| 24041 | if (type_is_invalid(start->value.type)) | 24079 | if (type_is_invalid(start->value->type)) |
| 24042 | return ira->codegen->invalid_instruction; | 24080 | return ira->codegen->invalid_instruction; |
| 24043 | | 24081 | |
| 24044 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 24082 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 24045 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); | 24083 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); |
| 24046 | if (type_is_invalid(casted_start->value.type)) | 24084 | if (type_is_invalid(casted_start->value->type)) |
| 24047 | return ira->codegen->invalid_instruction; | 24085 | return ira->codegen->invalid_instruction; |
| 24048 | | 24086 | |
| 24049 | IrInstruction *end; | 24087 | IrInstruction *end; |
| 24050 | if (instruction->end) { | 24088 | if (instruction->end) { |
| 24051 | end = instruction->end->child; | 24089 | end = instruction->end->child; |
| 24052 | if (type_is_invalid(end->value.type)) | 24090 | if (type_is_invalid(end->value->type)) |
| 24053 | return ira->codegen->invalid_instruction; | 24091 | return ira->codegen->invalid_instruction; |
| 24054 | end = ir_implicit_cast(ira, end, usize); | 24092 | end = ir_implicit_cast(ira, end, usize); |
| 24055 | if (type_is_invalid(end->value.type)) | 24093 | if (type_is_invalid(end->value->type)) |
| 24056 | return ira->codegen->invalid_instruction; | 24094 | return ira->codegen->invalid_instruction; |
| 24057 | } else { | 24095 | } else { |
| 24058 | end = nullptr; | 24096 | end = nullptr; |
| ... | @@ -24061,8 +24099,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24061,8 +24099,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24061 | ZigType *return_type; | 24099 | ZigType *return_type; |
| 24062 | | 24100 | |
| 24063 | if (array_type->id == ZigTypeIdArray) { | 24101 | if (array_type->id == ZigTypeIdArray) { |
| 24064 | bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic && | 24102 | bool is_comptime_const = ptr_ptr->value->special == ConstValSpecialStatic && |
| 24065 | ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst; | 24103 | ptr_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst; |
| 24066 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type, | 24104 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type, |
| 24067 | ptr_ptr_type->data.pointer.is_const || is_comptime_const, | 24105 | ptr_ptr_type->data.pointer.is_const || is_comptime_const, |
| 24068 | ptr_ptr_type->data.pointer.is_volatile, | 24106 | ptr_ptr_type->data.pointer.is_volatile, |
| ... | @@ -24103,11 +24141,11 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24103,11 +24141,11 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24103 | } | 24141 | } |
| 24104 | | 24142 | |
| 24105 | if (instr_is_comptime(ptr_ptr) && | 24143 | if (instr_is_comptime(ptr_ptr) && |
| 24106 | value_is_comptime(&casted_start->value) && | 24144 | value_is_comptime(casted_start->value) && |
| 24107 | (!end || value_is_comptime(&end->value))) | 24145 | (!end || value_is_comptime(end->value))) |
| 24108 | { | 24146 | { |
| 24109 | ConstExprValue *array_val; | 24147 | ZigValue *array_val; |
| 24110 | ConstExprValue *parent_ptr; | 24148 | ZigValue *parent_ptr; |
| 24111 | size_t abs_offset; | 24149 | size_t abs_offset; |
| 24112 | size_t rel_end; | 24150 | size_t rel_end; |
| 24113 | bool ptr_is_undef = false; | 24151 | bool ptr_is_undef = false; |
| ... | @@ -24117,7 +24155,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24117,7 +24155,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24117 | if (array_type->id == ZigTypeIdPointer) { | 24155 | if (array_type->id == ZigTypeIdPointer) { |
| 24118 | ZigType *child_array_type = array_type->data.pointer.child_type; | 24156 | ZigType *child_array_type = array_type->data.pointer.child_type; |
| 24119 | assert(child_array_type->id == ZigTypeIdArray); | 24157 | assert(child_array_type->id == ZigTypeIdArray); |
| 24120 | parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24158 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24121 | if (parent_ptr == nullptr) | 24159 | if (parent_ptr == nullptr) |
| 24122 | return ira->codegen->invalid_instruction; | 24160 | return ira->codegen->invalid_instruction; |
| 24123 | | 24161 | |
| ... | @@ -24136,7 +24174,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24136,7 +24174,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24136 | abs_offset = 0; | 24174 | abs_offset = 0; |
| 24137 | } | 24175 | } |
| 24138 | } else { | 24176 | } else { |
| 24139 | array_val = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24177 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24140 | if (array_val == nullptr) | 24178 | if (array_val == nullptr) |
| 24141 | return ira->codegen->invalid_instruction; | 24179 | return ira->codegen->invalid_instruction; |
| 24142 | rel_end = array_type->data.array.len; | 24180 | rel_end = array_type->data.array.len; |
| ... | @@ -24145,7 +24183,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24145,7 +24183,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24145 | } | 24183 | } |
| 24146 | } else if (array_type->id == ZigTypeIdPointer) { | 24184 | } else if (array_type->id == ZigTypeIdPointer) { |
| 24147 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); | 24185 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); |
| 24148 | parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24186 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24149 | if (parent_ptr == nullptr) | 24187 | if (parent_ptr == nullptr) |
| 24150 | return ira->codegen->invalid_instruction; | 24188 | return ira->codegen->invalid_instruction; |
| 24151 | | 24189 | |
| ... | @@ -24193,7 +24231,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24193,7 +24231,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24193 | zig_panic("TODO slice of null ptr"); | 24231 | zig_panic("TODO slice of null ptr"); |
| 24194 | } | 24232 | } |
| 24195 | } else if (is_slice(array_type)) { | 24233 | } else if (is_slice(array_type)) { |
| 24196 | ConstExprValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24234 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24197 | if (slice_ptr == nullptr) | 24235 | if (slice_ptr == nullptr) |
| 24198 | return ira->codegen->invalid_instruction; | 24236 | return ira->codegen->invalid_instruction; |
| 24199 | | 24237 | |
| ... | @@ -24208,7 +24246,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24208,7 +24246,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24208 | return ira->codegen->invalid_instruction; | 24246 | return ira->codegen->invalid_instruction; |
| 24209 | } | 24247 | } |
| 24210 | | 24248 | |
| 24211 | ConstExprValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; | 24249 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; |
| 24212 | | 24250 | |
| 24213 | switch (parent_ptr->data.x_ptr.special) { | 24251 | switch (parent_ptr->data.x_ptr.special) { |
| 24214 | case ConstPtrSpecialInvalid: | 24252 | case ConstPtrSpecialInvalid: |
| ... | @@ -24246,7 +24284,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24246,7 +24284,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24246 | zig_unreachable(); | 24284 | zig_unreachable(); |
| 24247 | } | 24285 | } |
| 24248 | | 24286 | |
| 24249 | ConstExprValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); | 24287 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); |
| 24250 | if (!start_val) | 24288 | if (!start_val) |
| 24251 | return ira->codegen->invalid_instruction; | 24289 | return ira->codegen->invalid_instruction; |
| 24252 | | 24290 | |
| ... | @@ -24258,7 +24296,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24258,7 +24296,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24258 | | 24296 | |
| 24259 | uint64_t end_scalar = rel_end; | 24297 | uint64_t end_scalar = rel_end; |
| 24260 | if (end) { | 24298 | if (end) { |
| 24261 | ConstExprValue *end_val = ir_resolve_const(ira, end, UndefBad); | 24299 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); |
| 24262 | if (!end_val) | 24300 | if (!end_val) |
| 24263 | return ira->codegen->invalid_instruction; | 24301 | return ira->codegen->invalid_instruction; |
| 24264 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); | 24302 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); |
| ... | @@ -24279,17 +24317,17 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24279,17 +24317,17 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24279 | } | 24317 | } |
| 24280 | | 24318 | |
| 24281 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 24319 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 24282 | ConstExprValue *out_val = &result->value; | 24320 | ZigValue *out_val = result->value; |
| 24283 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); | 24321 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 24284 | | 24322 | |
| 24285 | ConstExprValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; | 24323 | ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; |
| 24286 | | 24324 | |
| 24287 | if (array_val) { | 24325 | if (array_val) { |
| 24288 | size_t index = abs_offset + start_scalar; | 24326 | size_t index = abs_offset + start_scalar; |
| 24289 | bool is_const = slice_is_const(return_type); | 24327 | bool is_const = slice_is_const(return_type); |
| 24290 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); | 24328 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); |
| 24291 | if (array_type->id == ZigTypeIdArray) { | 24329 | if (array_type->id == ZigTypeIdArray) { |
| 24292 | ptr_val->data.x_ptr.mut = ptr_ptr->value.data.x_ptr.mut; | 24330 | ptr_val->data.x_ptr.mut = ptr_ptr->value->data.x_ptr.mut; |
| 24293 | } else if (is_slice(array_type)) { | 24331 | } else if (is_slice(array_type)) { |
| 24294 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; | 24332 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; |
| 24295 | } else if (array_type->id == ZigTypeIdPointer) { | 24333 | } else if (array_type->id == ZigTypeIdPointer) { |
| ... | @@ -24329,7 +24367,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24329,7 +24367,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24329 | zig_panic("TODO"); | 24367 | zig_panic("TODO"); |
| 24330 | } | 24368 | } |
| 24331 | | 24369 | |
| 24332 | ConstExprValue *len_val = out_val->data.x_struct.fields[slice_len_index]; | 24370 | ZigValue *len_val = out_val->data.x_struct.fields[slice_len_index]; |
| 24333 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); | 24371 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); |
| 24334 | | 24372 | |
| 24335 | return result; | 24373 | return result; |
| ... | @@ -24337,7 +24375,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24337,7 +24375,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24337 | | 24375 | |
| 24338 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 24376 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 24339 | return_type, nullptr, true, false, true); | 24377 | return_type, nullptr, true, false, true); |
| 24340 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 24378 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 24341 | return result_loc; | 24379 | return result_loc; |
| 24342 | } | 24380 | } |
| 24343 | return ir_build_slice_gen(ira, &instruction->base, return_type, | 24381 | return ir_build_slice_gen(ira, &instruction->base, return_type, |
| ... | @@ -24347,7 +24385,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24347,7 +24385,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24347 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { | 24385 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { |
| 24348 | Error err; | 24386 | Error err; |
| 24349 | IrInstruction *container = instruction->container->child; | 24387 | IrInstruction *container = instruction->container->child; |
| 24350 | if (type_is_invalid(container->value.type)) | 24388 | if (type_is_invalid(container->value->type)) |
| 24351 | return ira->codegen->invalid_instruction; | 24389 | return ira->codegen->invalid_instruction; |
| 24352 | ZigType *container_type = ir_resolve_type(ira, container); | 24390 | ZigType *container_type = ir_resolve_type(ira, container); |
| 24353 | | 24391 | |
| ... | @@ -24448,7 +24486,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24448,7 +24486,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24448 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 24486 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 24449 | | 24487 | |
| 24450 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24488 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24451 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24489 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24452 | return result; | 24490 | return result; |
| 24453 | } else if (container_type->id == ZigTypeIdEnum) { | 24491 | } else if (container_type->id == ZigTypeIdEnum) { |
| 24454 | if (member_index >= container_type->data.enumeration.src_field_count) { | 24492 | if (member_index >= container_type->data.enumeration.src_field_count) { |
| ... | @@ -24460,7 +24498,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24460,7 +24498,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24460 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; | 24498 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; |
| 24461 | | 24499 | |
| 24462 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24500 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24463 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24501 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24464 | return result; | 24502 | return result; |
| 24465 | } else if (container_type->id == ZigTypeIdUnion) { | 24503 | } else if (container_type->id == ZigTypeIdUnion) { |
| 24466 | if (member_index >= container_type->data.unionation.src_field_count) { | 24504 | if (member_index >= container_type->data.unionation.src_field_count) { |
| ... | @@ -24472,7 +24510,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24472,7 +24510,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24472 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 24510 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 24473 | | 24511 | |
| 24474 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24512 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24475 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24513 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24476 | return result; | 24514 | return result; |
| 24477 | } else { | 24515 | } else { |
| 24478 | ir_add_error(ira, container_type_value, | 24516 | ir_add_error(ira, container_type_value, |
| ... | @@ -24512,21 +24550,21 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc | ... | @@ -24512,21 +24550,21 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc |
| 24512 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { | 24550 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { |
| 24513 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, | 24551 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, |
| 24514 | instruction->base.scope, instruction->base.source_node); | 24552 | instruction->base.scope, instruction->base.source_node); |
| 24515 | result->value.type = ira->codegen->builtin_types.entry_void; | 24553 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 24516 | return result; | 24554 | return result; |
| 24517 | } | 24555 | } |
| 24518 | | 24556 | |
| 24519 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { | 24557 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { |
| 24520 | IrInstruction *result = ir_build_return_address(&ira->new_irb, | 24558 | IrInstruction *result = ir_build_return_address(&ira->new_irb, |
| 24521 | instruction->base.scope, instruction->base.source_node); | 24559 | instruction->base.scope, instruction->base.source_node); |
| 24522 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24560 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24523 | return result; | 24561 | return result; |
| 24524 | } | 24562 | } |
| 24525 | | 24563 | |
| 24526 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { | 24564 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { |
| 24527 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, | 24565 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, |
| 24528 | instruction->base.scope, instruction->base.source_node); | 24566 | instruction->base.scope, instruction->base.source_node); |
| 24529 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24567 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24530 | return result; | 24568 | return result; |
| 24531 | } | 24569 | } |
| 24532 | | 24570 | |
| ... | @@ -24542,7 +24580,7 @@ static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInst | ... | @@ -24542,7 +24580,7 @@ static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInst |
| 24542 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); | 24580 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); |
| 24543 | | 24581 | |
| 24544 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); | 24582 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); |
| 24545 | result->value.type = ptr_frame_type; | 24583 | result->value->type = ptr_frame_type; |
| 24546 | return result; | 24584 | return result; |
| 24547 | } | 24585 | } |
| 24548 | | 24586 | |
| ... | @@ -24563,12 +24601,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru | ... | @@ -24563,12 +24601,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru |
| 24563 | | 24601 | |
| 24564 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { | 24602 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { |
| 24565 | IrInstruction *fn = instruction->fn->child; | 24603 | IrInstruction *fn = instruction->fn->child; |
| 24566 | if (type_is_invalid(fn->value.type)) | 24604 | if (type_is_invalid(fn->value->type)) |
| 24567 | return ira->codegen->invalid_instruction; | 24605 | return ira->codegen->invalid_instruction; |
| 24568 | | 24606 | |
| 24569 | if (fn->value.type->id != ZigTypeIdFn) { | 24607 | if (fn->value->type->id != ZigTypeIdFn) { |
| 24570 | ir_add_error(ira, fn, | 24608 | ir_add_error(ira, fn, |
| 24571 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value.type->name))); | 24609 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); |
| 24572 | return ira->codegen->invalid_instruction; | 24610 | return ira->codegen->invalid_instruction; |
| 24573 | } | 24611 | } |
| 24574 | | 24612 | |
| ... | @@ -24576,7 +24614,7 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru | ... | @@ -24576,7 +24614,7 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru |
| 24576 | | 24614 | |
| 24577 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, | 24615 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, |
| 24578 | instruction->base.source_node, fn); | 24616 | instruction->base.source_node, fn); |
| 24579 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24617 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24580 | return result; | 24618 | return result; |
| 24581 | } | 24619 | } |
| 24582 | | 24620 | |
| ... | @@ -24587,11 +24625,11 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -24587,11 +24625,11 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 24587 | // field: []align(@alignOf(Node)) Node, | 24625 | // field: []align(@alignOf(Node)) Node, |
| 24588 | // }; | 24626 | // }; |
| 24589 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 24627 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 24590 | result->value.special = ConstValSpecialLazy; | 24628 | result->value->special = ConstValSpecialLazy; |
| 24591 | | 24629 | |
| 24592 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); | 24630 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); |
| 24593 | lazy_align_of->ira = ira; | 24631 | lazy_align_of->ira = ira; |
| 24594 | result->value.data.x_lazy = &lazy_align_of->base; | 24632 | result->value->data.x_lazy = &lazy_align_of->base; |
| 24595 | lazy_align_of->base.id = LazyValueIdAlignOf; | 24633 | lazy_align_of->base.id = LazyValueIdAlignOf; |
| 24596 | | 24634 | |
| 24597 | lazy_align_of->target_type = instruction->type_value->child; | 24635 | lazy_align_of->target_type = instruction->type_value->child; |
| ... | @@ -24605,7 +24643,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24605,7 +24643,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24605 | Error err; | 24643 | Error err; |
| 24606 | | 24644 | |
| 24607 | IrInstruction *type_value = instruction->type_value->child; | 24645 | IrInstruction *type_value = instruction->type_value->child; |
| 24608 | if (type_is_invalid(type_value->value.type)) | 24646 | if (type_is_invalid(type_value->value->type)) |
| 24609 | return ira->codegen->invalid_instruction; | 24647 | return ira->codegen->invalid_instruction; |
| 24610 | | 24648 | |
| 24611 | ZigType *dest_type = ir_resolve_type(ira, type_value); | 24649 | ZigType *dest_type = ir_resolve_type(ira, type_value); |
| ... | @@ -24619,15 +24657,15 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24619,15 +24657,15 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24619 | } | 24657 | } |
| 24620 | | 24658 | |
| 24621 | IrInstruction *op1 = instruction->op1->child; | 24659 | IrInstruction *op1 = instruction->op1->child; |
| 24622 | if (type_is_invalid(op1->value.type)) | 24660 | if (type_is_invalid(op1->value->type)) |
| 24623 | return ira->codegen->invalid_instruction; | 24661 | return ira->codegen->invalid_instruction; |
| 24624 | | 24662 | |
| 24625 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 24663 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 24626 | if (type_is_invalid(casted_op1->value.type)) | 24664 | if (type_is_invalid(casted_op1->value->type)) |
| 24627 | return ira->codegen->invalid_instruction; | 24665 | return ira->codegen->invalid_instruction; |
| 24628 | | 24666 | |
| 24629 | IrInstruction *op2 = instruction->op2->child; | 24667 | IrInstruction *op2 = instruction->op2->child; |
| 24630 | if (type_is_invalid(op2->value.type)) | 24668 | if (type_is_invalid(op2->value->type)) |
| 24631 | return ira->codegen->invalid_instruction; | 24669 | return ira->codegen->invalid_instruction; |
| 24632 | | 24670 | |
| 24633 | IrInstruction *casted_op2; | 24671 | IrInstruction *casted_op2; |
| ... | @@ -24638,20 +24676,20 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24638,20 +24676,20 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24638 | } else { | 24676 | } else { |
| 24639 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 24677 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 24640 | } | 24678 | } |
| 24641 | if (type_is_invalid(casted_op2->value.type)) | 24679 | if (type_is_invalid(casted_op2->value->type)) |
| 24642 | return ira->codegen->invalid_instruction; | 24680 | return ira->codegen->invalid_instruction; |
| 24643 | | 24681 | |
| 24644 | IrInstruction *result_ptr = instruction->result_ptr->child; | 24682 | IrInstruction *result_ptr = instruction->result_ptr->child; |
| 24645 | if (type_is_invalid(result_ptr->value.type)) | 24683 | if (type_is_invalid(result_ptr->value->type)) |
| 24646 | return ira->codegen->invalid_instruction; | 24684 | return ira->codegen->invalid_instruction; |
| 24647 | | 24685 | |
| 24648 | ZigType *expected_ptr_type; | 24686 | ZigType *expected_ptr_type; |
| 24649 | if (result_ptr->value.type->id == ZigTypeIdPointer) { | 24687 | if (result_ptr->value->type->id == ZigTypeIdPointer) { |
| 24650 | uint32_t alignment; | 24688 | uint32_t alignment; |
| 24651 | if ((err = resolve_ptr_align(ira, result_ptr->value.type, &alignment))) | 24689 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) |
| 24652 | return ira->codegen->invalid_instruction; | 24690 | return ira->codegen->invalid_instruction; |
| 24653 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, | 24691 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, |
| 24654 | false, result_ptr->value.type->data.pointer.is_volatile, | 24692 | false, result_ptr->value->type->data.pointer.is_volatile, |
| 24655 | PtrLenSingle, | 24693 | PtrLenSingle, |
| 24656 | alignment, 0, 0, false); | 24694 | alignment, 0, 0, false); |
| 24657 | } else { | 24695 | } else { |
| ... | @@ -24659,28 +24697,28 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24659,28 +24697,28 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24659 | } | 24697 | } |
| 24660 | | 24698 | |
| 24661 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | 24699 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 24662 | if (type_is_invalid(casted_result_ptr->value.type)) | 24700 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 24663 | return ira->codegen->invalid_instruction; | 24701 | return ira->codegen->invalid_instruction; |
| 24664 | | 24702 | |
| 24665 | if (instr_is_comptime(casted_op1) && | 24703 | if (instr_is_comptime(casted_op1) && |
| 24666 | instr_is_comptime(casted_op2) && | 24704 | instr_is_comptime(casted_op2) && |
| 24667 | instr_is_comptime(casted_result_ptr)) | 24705 | instr_is_comptime(casted_result_ptr)) |
| 24668 | { | 24706 | { |
| 24669 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 24707 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 24670 | if (op1_val == nullptr) | 24708 | if (op1_val == nullptr) |
| 24671 | return ira->codegen->invalid_instruction; | 24709 | return ira->codegen->invalid_instruction; |
| 24672 | | 24710 | |
| 24673 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 24711 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 24674 | if (op2_val == nullptr) | 24712 | if (op2_val == nullptr) |
| 24675 | return ira->codegen->invalid_instruction; | 24713 | return ira->codegen->invalid_instruction; |
| 24676 | | 24714 | |
| 24677 | ConstExprValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); | 24715 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); |
| 24678 | if (result_val == nullptr) | 24716 | if (result_val == nullptr) |
| 24679 | return ira->codegen->invalid_instruction; | 24717 | return ira->codegen->invalid_instruction; |
| 24680 | | 24718 | |
| 24681 | BigInt *op1_bigint = &op1_val->data.x_bigint; | 24719 | BigInt *op1_bigint = &op1_val->data.x_bigint; |
| 24682 | BigInt *op2_bigint = &op2_val->data.x_bigint; | 24720 | BigInt *op2_bigint = &op2_val->data.x_bigint; |
| 24683 | ConstExprValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, | 24721 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, |
| 24684 | casted_result_ptr->source_node); | 24722 | casted_result_ptr->source_node); |
| 24685 | if (pointee_val == nullptr) | 24723 | if (pointee_val == nullptr) |
| 24686 | return ira->codegen->invalid_instruction; | 24724 | return ira->codegen->invalid_instruction; |
| ... | @@ -24716,12 +24754,12 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24716,12 +24754,12 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24716 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, | 24754 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, |
| 24717 | instruction->base.scope, instruction->base.source_node, | 24755 | instruction->base.scope, instruction->base.source_node, |
| 24718 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); | 24756 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); |
| 24719 | result->value.type = ira->codegen->builtin_types.entry_bool; | 24757 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 24720 | return result; | 24758 | return result; |
| 24721 | } | 24759 | } |
| 24722 | | 24760 | |
| 24723 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, | 24761 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, |
| 24724 | ConstExprValue *op1, ConstExprValue *op2, ConstExprValue *op3, ConstExprValue *out_val) { | 24762 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { |
| 24725 | if (float_type->id == ZigTypeIdComptimeFloat) { | 24763 | if (float_type->id == ZigTypeIdComptimeFloat) { |
| 24726 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, | 24764 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, |
| 24727 | &op3->data.x_bigfloat.value); | 24765 | &op3->data.x_bigfloat.value); |
| ... | @@ -24749,7 +24787,7 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z | ... | @@ -24749,7 +24787,7 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z |
| 24749 | | 24787 | |
| 24750 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { | 24788 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { |
| 24751 | IrInstruction *type_value = instruction->type_value->child; | 24789 | IrInstruction *type_value = instruction->type_value->child; |
| 24752 | if (type_is_invalid(type_value->value.type)) | 24790 | if (type_is_invalid(type_value->value->type)) |
| 24753 | return ira->codegen->invalid_instruction; | 24791 | return ira->codegen->invalid_instruction; |
| 24754 | | 24792 | |
| 24755 | ZigType *expr_type = ir_resolve_type(ira, type_value); | 24793 | ZigType *expr_type = ir_resolve_type(ira, type_value); |
| ... | @@ -24765,44 +24803,44 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24765,44 +24803,44 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24765 | } | 24803 | } |
| 24766 | | 24804 | |
| 24767 | IrInstruction *op1 = instruction->op1->child; | 24805 | IrInstruction *op1 = instruction->op1->child; |
| 24768 | if (type_is_invalid(op1->value.type)) | 24806 | if (type_is_invalid(op1->value->type)) |
| 24769 | return ira->codegen->invalid_instruction; | 24807 | return ira->codegen->invalid_instruction; |
| 24770 | | 24808 | |
| 24771 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | 24809 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); |
| 24772 | if (type_is_invalid(casted_op1->value.type)) | 24810 | if (type_is_invalid(casted_op1->value->type)) |
| 24773 | return ira->codegen->invalid_instruction; | 24811 | return ira->codegen->invalid_instruction; |
| 24774 | | 24812 | |
| 24775 | IrInstruction *op2 = instruction->op2->child; | 24813 | IrInstruction *op2 = instruction->op2->child; |
| 24776 | if (type_is_invalid(op2->value.type)) | 24814 | if (type_is_invalid(op2->value->type)) |
| 24777 | return ira->codegen->invalid_instruction; | 24815 | return ira->codegen->invalid_instruction; |
| 24778 | | 24816 | |
| 24779 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | 24817 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); |
| 24780 | if (type_is_invalid(casted_op2->value.type)) | 24818 | if (type_is_invalid(casted_op2->value->type)) |
| 24781 | return ira->codegen->invalid_instruction; | 24819 | return ira->codegen->invalid_instruction; |
| 24782 | | 24820 | |
| 24783 | IrInstruction *op3 = instruction->op3->child; | 24821 | IrInstruction *op3 = instruction->op3->child; |
| 24784 | if (type_is_invalid(op3->value.type)) | 24822 | if (type_is_invalid(op3->value->type)) |
| 24785 | return ira->codegen->invalid_instruction; | 24823 | return ira->codegen->invalid_instruction; |
| 24786 | | 24824 | |
| 24787 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | 24825 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); |
| 24788 | if (type_is_invalid(casted_op3->value.type)) | 24826 | if (type_is_invalid(casted_op3->value->type)) |
| 24789 | return ira->codegen->invalid_instruction; | 24827 | return ira->codegen->invalid_instruction; |
| 24790 | | 24828 | |
| 24791 | if (instr_is_comptime(casted_op1) && | 24829 | if (instr_is_comptime(casted_op1) && |
| 24792 | instr_is_comptime(casted_op2) && | 24830 | instr_is_comptime(casted_op2) && |
| 24793 | instr_is_comptime(casted_op3)) { | 24831 | instr_is_comptime(casted_op3)) { |
| 24794 | ConstExprValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 24832 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 24795 | if (!op1_const) | 24833 | if (!op1_const) |
| 24796 | return ira->codegen->invalid_instruction; | 24834 | return ira->codegen->invalid_instruction; |
| 24797 | ConstExprValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); | 24835 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); |
| 24798 | if (!op2_const) | 24836 | if (!op2_const) |
| 24799 | return ira->codegen->invalid_instruction; | 24837 | return ira->codegen->invalid_instruction; |
| 24800 | ConstExprValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); | 24838 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); |
| 24801 | if (!op3_const) | 24839 | if (!op3_const) |
| 24802 | return ira->codegen->invalid_instruction; | 24840 | return ira->codegen->invalid_instruction; |
| 24803 | | 24841 | |
| 24804 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 24842 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 24805 | ConstExprValue *out_val = &result->value; | 24843 | ZigValue *out_val = result->value; |
| 24806 | | 24844 | |
| 24807 | if (expr_type->id == ZigTypeIdVector) { | 24845 | if (expr_type->id == ZigTypeIdVector) { |
| 24808 | expand_undef_array(ira->codegen, op1_const); | 24846 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -24812,10 +24850,10 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24812,10 +24850,10 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24812 | expand_undef_array(ira->codegen, out_val); | 24850 | expand_undef_array(ira->codegen, out_val); |
| 24813 | size_t len = expr_type->data.vector.len; | 24851 | size_t len = expr_type->data.vector.len; |
| 24814 | for (size_t i = 0; i < len; i += 1) { | 24852 | for (size_t i = 0; i < len; i += 1) { |
| 24815 | ConstExprValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; | 24853 | ZigValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; |
| 24816 | ConstExprValue *float_operand_op2 = &op2_const->data.x_array.data.s_none.elements[i]; | 24854 | ZigValue *float_operand_op2 = &op2_const->data.x_array.data.s_none.elements[i]; |
| 24817 | ConstExprValue *float_operand_op3 = &op3_const->data.x_array.data.s_none.elements[i]; | 24855 | ZigValue *float_operand_op3 = &op3_const->data.x_array.data.s_none.elements[i]; |
| 24818 | ConstExprValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 24856 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 24819 | assert(float_operand_op1->type == float_type); | 24857 | assert(float_operand_op1->type == float_type); |
| 24820 | assert(float_operand_op2->type == float_type); | 24858 | assert(float_operand_op2->type == float_type); |
| 24821 | assert(float_operand_op3->type == float_type); | 24859 | assert(float_operand_op3->type == float_type); |
| ... | @@ -24835,13 +24873,13 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24835,13 +24873,13 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24835 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, | 24873 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, |
| 24836 | instruction->base.scope, instruction->base.source_node, | 24874 | instruction->base.scope, instruction->base.source_node, |
| 24837 | type_value, casted_op1, casted_op2, casted_op3); | 24875 | type_value, casted_op1, casted_op2, casted_op3); |
| 24838 | result->value.type = expr_type; | 24876 | result->value->type = expr_type; |
| 24839 | return result; | 24877 | return result; |
| 24840 | } | 24878 | } |
| 24841 | | 24879 | |
| 24842 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { | 24880 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { |
| 24843 | IrInstruction *base_ptr = instruction->base_ptr->child; | 24881 | IrInstruction *base_ptr = instruction->base_ptr->child; |
| 24844 | if (type_is_invalid(base_ptr->value.type)) | 24882 | if (type_is_invalid(base_ptr->value->type)) |
| 24845 | return ira->codegen->invalid_instruction; | 24883 | return ira->codegen->invalid_instruction; |
| 24846 | | 24884 | |
| 24847 | IrInstruction *value; | 24885 | IrInstruction *value; |
| ... | @@ -24851,12 +24889,12 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct | ... | @@ -24851,12 +24889,12 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 24851 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); | 24889 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); |
| 24852 | } | 24890 | } |
| 24853 | | 24891 | |
| 24854 | ZigType *type_entry = value->value.type; | 24892 | ZigType *type_entry = value->value->type; |
| 24855 | if (type_is_invalid(type_entry)) | 24893 | if (type_is_invalid(type_entry)) |
| 24856 | return ira->codegen->invalid_instruction; | 24894 | return ira->codegen->invalid_instruction; |
| 24857 | if (type_entry->id == ZigTypeIdErrorUnion) { | 24895 | if (type_entry->id == ZigTypeIdErrorUnion) { |
| 24858 | if (instr_is_comptime(value)) { | 24896 | if (instr_is_comptime(value)) { |
| 24859 | ConstExprValue *err_union_val = ir_resolve_const(ira, value, UndefBad); | 24897 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); |
| 24860 | if (!err_union_val) | 24898 | if (!err_union_val) |
| 24861 | return ira->codegen->invalid_instruction; | 24899 | return ira->codegen->invalid_instruction; |
| 24862 | | 24900 | |
| ... | @@ -24890,7 +24928,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct | ... | @@ -24890,7 +24928,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 24890 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 24928 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, |
| 24891 | IrInstruction *base_ptr, bool initializing) | 24929 | IrInstruction *base_ptr, bool initializing) |
| 24892 | { | 24930 | { |
| 24893 | ZigType *ptr_type = base_ptr->value.type; | 24931 | ZigType *ptr_type = base_ptr->value->type; |
| 24894 | | 24932 | |
| 24895 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 24933 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 24896 | assert(ptr_type->id == ZigTypeIdPointer); | 24934 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -24911,20 +24949,20 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24911,20 +24949,20 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24911 | ptr_type->data.pointer.explicit_alignment, 0, 0, false); | 24949 | ptr_type->data.pointer.explicit_alignment, 0, 0, false); |
| 24912 | | 24950 | |
| 24913 | if (instr_is_comptime(base_ptr)) { | 24951 | if (instr_is_comptime(base_ptr)) { |
| 24914 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 24952 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 24915 | if (!ptr_val) | 24953 | if (!ptr_val) |
| 24916 | return ira->codegen->invalid_instruction; | 24954 | return ira->codegen->invalid_instruction; |
| 24917 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 24955 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 24918 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) | 24956 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) |
| 24919 | { | 24957 | { |
| 24920 | ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 24958 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 24921 | if (err_union_val == nullptr) | 24959 | if (err_union_val == nullptr) |
| 24922 | return ira->codegen->invalid_instruction; | 24960 | return ira->codegen->invalid_instruction; |
| 24923 | | 24961 | |
| 24924 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 24962 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 24925 | ConstExprValue *vals = create_const_vals(2); | 24963 | ZigValue *vals = create_const_vals(2); |
| 24926 | ConstExprValue *err_set_val = &vals[0]; | 24964 | ZigValue *err_set_val = &vals[0]; |
| 24927 | ConstExprValue *payload_val = &vals[1]; | 24965 | ZigValue *payload_val = &vals[1]; |
| 24928 | | 24966 | |
| 24929 | err_set_val->special = ConstValSpecialUndef; | 24967 | err_set_val->special = ConstValSpecialUndef; |
| 24930 | err_set_val->type = err_set_type; | 24968 | err_set_val->type = err_set_type; |
| ... | @@ -24946,12 +24984,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24946,12 +24984,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24946 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 24984 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 24947 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, | 24985 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, |
| 24948 | source_instr->source_node, base_ptr); | 24986 | source_instr->source_node, base_ptr); |
| 24949 | result->value.type = result_type; | 24987 | result->value->type = result_type; |
| 24950 | result->value.special = ConstValSpecialStatic; | 24988 | result->value->special = ConstValSpecialStatic; |
| 24951 | } else { | 24989 | } else { |
| 24952 | result = ir_const(ira, source_instr, result_type); | 24990 | result = ir_const(ira, source_instr, result_type); |
| 24953 | } | 24991 | } |
| 24954 | ConstExprValue *const_val = &result->value; | 24992 | ZigValue *const_val = result->value; |
| 24955 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; | 24993 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; |
| 24956 | const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val; | 24994 | const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val; |
| 24957 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 24995 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| ... | @@ -24961,7 +24999,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24961,7 +24999,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24961 | | 24999 | |
| 24962 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, | 25000 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, |
| 24963 | source_instr->scope, source_instr->source_node, base_ptr); | 25001 | source_instr->scope, source_instr->source_node, base_ptr); |
| 24964 | result->value.type = result_type; | 25002 | result->value->type = result_type; |
| 24965 | return result; | 25003 | return result; |
| 24966 | } | 25004 | } |
| 24967 | | 25005 | |
| ... | @@ -24969,7 +25007,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | ... | @@ -24969,7 +25007,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 24969 | IrInstructionUnwrapErrCode *instruction) | 25007 | IrInstructionUnwrapErrCode *instruction) |
| 24970 | { | 25008 | { |
| 24971 | IrInstruction *base_ptr = instruction->err_union_ptr->child; | 25009 | IrInstruction *base_ptr = instruction->err_union_ptr->child; |
| 24972 | if (type_is_invalid(base_ptr->value.type)) | 25010 | if (type_is_invalid(base_ptr->value->type)) |
| 24973 | return ira->codegen->invalid_instruction; | 25011 | return ira->codegen->invalid_instruction; |
| 24974 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); | 25012 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); |
| 24975 | } | 25013 | } |
| ... | @@ -24977,7 +25015,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | ... | @@ -24977,7 +25015,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 24977 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 25015 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, |
| 24978 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 25016 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) |
| 24979 | { | 25017 | { |
| 24980 | ZigType *ptr_type = base_ptr->value.type; | 25018 | ZigType *ptr_type = base_ptr->value->type; |
| 24981 | | 25019 | |
| 24982 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 25020 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 24983 | assert(ptr_type->id == ZigTypeIdPointer); | 25021 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -25000,17 +25038,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25000,17 +25038,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25000 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 25038 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| 25001 | PtrLenSingle, 0, 0, 0, false); | 25039 | PtrLenSingle, 0, 0, 0, false); |
| 25002 | if (instr_is_comptime(base_ptr)) { | 25040 | if (instr_is_comptime(base_ptr)) { |
| 25003 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 25041 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 25004 | if (!ptr_val) | 25042 | if (!ptr_val) |
| 25005 | return ira->codegen->invalid_instruction; | 25043 | return ira->codegen->invalid_instruction; |
| 25006 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 25044 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 25007 | ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 25045 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 25008 | if (err_union_val == nullptr) | 25046 | if (err_union_val == nullptr) |
| 25009 | return ira->codegen->invalid_instruction; | 25047 | return ira->codegen->invalid_instruction; |
| 25010 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 25048 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 25011 | ConstExprValue *vals = create_const_vals(2); | 25049 | ZigValue *vals = create_const_vals(2); |
| 25012 | ConstExprValue *err_set_val = &vals[0]; | 25050 | ZigValue *err_set_val = &vals[0]; |
| 25013 | ConstExprValue *payload_val = &vals[1]; | 25051 | ZigValue *payload_val = &vals[1]; |
| 25014 | | 25052 | |
| 25015 | err_set_val->special = ConstValSpecialStatic; | 25053 | err_set_val->special = ConstValSpecialStatic; |
| 25016 | err_set_val->type = type_entry->data.error_union.err_set_type; | 25054 | err_set_val->type = type_entry->data.error_union.err_set_type; |
| ... | @@ -25036,14 +25074,14 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25036,14 +25074,14 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25036 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 25074 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 25037 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 25075 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, |
| 25038 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 25076 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 25039 | result->value.type = result_type; | 25077 | result->value->type = result_type; |
| 25040 | result->value.special = ConstValSpecialStatic; | 25078 | result->value->special = ConstValSpecialStatic; |
| 25041 | } else { | 25079 | } else { |
| 25042 | result = ir_const(ira, source_instr, result_type); | 25080 | result = ir_const(ira, source_instr, result_type); |
| 25043 | } | 25081 | } |
| 25044 | result->value.data.x_ptr.special = ConstPtrSpecialRef; | 25082 | result->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 25045 | result->value.data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload; | 25083 | 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; | 25084 | result->value->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 25047 | return result; | 25085 | return result; |
| 25048 | } | 25086 | } |
| 25049 | } | 25087 | } |
| ... | @@ -25051,7 +25089,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25051,7 +25089,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25051 | | 25089 | |
| 25052 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 25090 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, |
| 25053 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 25091 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 25054 | result->value.type = result_type; | 25092 | result->value->type = result_type; |
| 25055 | return result; | 25093 | return result; |
| 25056 | } | 25094 | } |
| 25057 | | 25095 | |
| ... | @@ -25060,7 +25098,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | ... | @@ -25060,7 +25098,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 25060 | { | 25098 | { |
| 25061 | assert(instruction->value->child); | 25099 | assert(instruction->value->child); |
| 25062 | IrInstruction *value = instruction->value->child; | 25100 | IrInstruction *value = instruction->value->child; |
| 25063 | if (type_is_invalid(value->value.type)) | 25101 | if (type_is_invalid(value->value->type)) |
| 25064 | return ira->codegen->invalid_instruction; | 25102 | return ira->codegen->invalid_instruction; |
| 25065 | | 25103 | |
| 25066 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); | 25104 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); |
| ... | @@ -25071,11 +25109,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25071,11 +25109,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25071 | assert(proto_node->type == NodeTypeFnProto); | 25109 | assert(proto_node->type == NodeTypeFnProto); |
| 25072 | | 25110 | |
| 25073 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 25111 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 25074 | result->value.special = ConstValSpecialLazy; | 25112 | result->value->special = ConstValSpecialLazy; |
| 25075 | | 25113 | |
| 25076 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); | 25114 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); |
| 25077 | lazy_fn_type->ira = ira; | 25115 | lazy_fn_type->ira = ira; |
| 25078 | result->value.data.x_lazy = &lazy_fn_type->base; | 25116 | result->value->data.x_lazy = &lazy_fn_type->base; |
| 25079 | lazy_fn_type->base.id = LazyValueIdFnType; | 25117 | lazy_fn_type->base.id = LazyValueIdFnType; |
| 25080 | | 25118 | |
| 25081 | if (proto_node->data.fn_proto.auto_err_set) { | 25119 | if (proto_node->data.fn_proto.auto_err_set) { |
| ... | @@ -25110,7 +25148,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25110,7 +25148,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25110 | } | 25148 | } |
| 25111 | | 25149 | |
| 25112 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; | 25150 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; |
| 25113 | if (type_is_invalid(param_type_value->value.type)) | 25151 | if (type_is_invalid(param_type_value->value->type)) |
| 25114 | return ira->codegen->invalid_instruction; | 25152 | return ira->codegen->invalid_instruction; |
| 25115 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) | 25153 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| 25116 | return ira->codegen->invalid_instruction; | 25154 | return ira->codegen->invalid_instruction; |
| ... | @@ -25132,7 +25170,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25132,7 +25170,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25132 | | 25170 | |
| 25133 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { | 25171 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { |
| 25134 | IrInstruction *value = instruction->value->child; | 25172 | IrInstruction *value = instruction->value->child; |
| 25135 | if (type_is_invalid(value->value.type)) | 25173 | if (type_is_invalid(value->value->type)) |
| 25136 | return ira->codegen->invalid_instruction; | 25174 | return ira->codegen->invalid_instruction; |
| 25137 | | 25175 | |
| 25138 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); | 25176 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); |
| ... | @@ -25142,7 +25180,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25142,7 +25180,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25142 | IrInstructionCheckSwitchProngs *instruction) | 25180 | IrInstructionCheckSwitchProngs *instruction) |
| 25143 | { | 25181 | { |
| 25144 | IrInstruction *target_value = instruction->target_value->child; | 25182 | IrInstruction *target_value = instruction->target_value->child; |
| 25145 | ZigType *switch_type = target_value->value.type; | 25183 | ZigType *switch_type = target_value->value->type; |
| 25146 | if (type_is_invalid(switch_type)) | 25184 | if (type_is_invalid(switch_type)) |
| 25147 | return ira->codegen->invalid_instruction; | 25185 | return ira->codegen->invalid_instruction; |
| 25148 | | 25186 | |
| ... | @@ -25154,25 +25192,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25154,25 +25192,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25154 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25192 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25155 | | 25193 | |
| 25156 | IrInstruction *start_value_uncasted = range->start->child; | 25194 | IrInstruction *start_value_uncasted = range->start->child; |
| 25157 | if (type_is_invalid(start_value_uncasted->value.type)) | 25195 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 25158 | return ira->codegen->invalid_instruction; | 25196 | return ira->codegen->invalid_instruction; |
| 25159 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 25197 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25160 | if (type_is_invalid(start_value->value.type)) | 25198 | if (type_is_invalid(start_value->value->type)) |
| 25161 | return ira->codegen->invalid_instruction; | 25199 | return ira->codegen->invalid_instruction; |
| 25162 | | 25200 | |
| 25163 | IrInstruction *end_value_uncasted = range->end->child; | 25201 | IrInstruction *end_value_uncasted = range->end->child; |
| 25164 | if (type_is_invalid(end_value_uncasted->value.type)) | 25202 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 25165 | return ira->codegen->invalid_instruction; | 25203 | return ira->codegen->invalid_instruction; |
| 25166 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 25204 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25167 | if (type_is_invalid(end_value->value.type)) | 25205 | if (type_is_invalid(end_value->value->type)) |
| 25168 | return ira->codegen->invalid_instruction; | 25206 | return ira->codegen->invalid_instruction; |
| 25169 | | 25207 | |
| 25170 | BigInt start_index; | 25208 | BigInt start_index; |
| 25171 | bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag); | 25209 | bigint_init_bigint(&start_index, &start_value->value->data.x_enum_tag); |
| 25172 | | 25210 | |
| 25173 | assert(end_value->value.type->id == ZigTypeIdEnum); | 25211 | assert(end_value->value->type->id == ZigTypeIdEnum); |
| 25174 | BigInt end_index; | 25212 | BigInt end_index; |
| 25175 | bigint_init_bigint(&end_index, &end_value->value.data.x_enum_tag); | 25213 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); |
| 25176 | | 25214 | |
| 25177 | BigInt field_index; | 25215 | BigInt field_index; |
| 25178 | bigint_init_bigint(&field_index, &start_index); | 25216 | bigint_init_bigint(&field_index, &start_index); |
| ... | @@ -25218,24 +25256,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25218,24 +25256,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25218 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25256 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25219 | | 25257 | |
| 25220 | IrInstruction *start_value_uncasted = range->start->child; | 25258 | IrInstruction *start_value_uncasted = range->start->child; |
| 25221 | if (type_is_invalid(start_value_uncasted->value.type)) | 25259 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 25222 | return ira->codegen->invalid_instruction; | 25260 | return ira->codegen->invalid_instruction; |
| 25223 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 25261 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25224 | if (type_is_invalid(start_value->value.type)) | 25262 | if (type_is_invalid(start_value->value->type)) |
| 25225 | return ira->codegen->invalid_instruction; | 25263 | return ira->codegen->invalid_instruction; |
| 25226 | | 25264 | |
| 25227 | IrInstruction *end_value_uncasted = range->end->child; | 25265 | IrInstruction *end_value_uncasted = range->end->child; |
| 25228 | if (type_is_invalid(end_value_uncasted->value.type)) | 25266 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 25229 | return ira->codegen->invalid_instruction; | 25267 | return ira->codegen->invalid_instruction; |
| 25230 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 25268 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25231 | if (type_is_invalid(end_value->value.type)) | 25269 | if (type_is_invalid(end_value->value->type)) |
| 25232 | return ira->codegen->invalid_instruction; | 25270 | return ira->codegen->invalid_instruction; |
| 25233 | | 25271 | |
| 25234 | ir_assert(start_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); | 25272 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); |
| 25235 | uint32_t start_index = start_value->value.data.x_err_set->value; | 25273 | uint32_t start_index = start_value->value->data.x_err_set->value; |
| 25236 | | 25274 | |
| 25237 | ir_assert(end_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); | 25275 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); |
| 25238 | uint32_t end_index = end_value->value.data.x_err_set->value; | 25276 | uint32_t end_index = end_value->value->data.x_err_set->value; |
| 25239 | | 25277 | |
| 25240 | if (start_index != end_index) { | 25278 | if (start_index != end_index) { |
| 25241 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); | 25279 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); |
| ... | @@ -25276,24 +25314,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25276,24 +25314,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25276 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25314 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25277 | | 25315 | |
| 25278 | IrInstruction *start_value = range->start->child; | 25316 | IrInstruction *start_value = range->start->child; |
| 25279 | if (type_is_invalid(start_value->value.type)) | 25317 | if (type_is_invalid(start_value->value->type)) |
| 25280 | return ira->codegen->invalid_instruction; | 25318 | return ira->codegen->invalid_instruction; |
| 25281 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | 25319 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); |
| 25282 | if (type_is_invalid(casted_start_value->value.type)) | 25320 | if (type_is_invalid(casted_start_value->value->type)) |
| 25283 | return ira->codegen->invalid_instruction; | 25321 | return ira->codegen->invalid_instruction; |
| 25284 | | 25322 | |
| 25285 | IrInstruction *end_value = range->end->child; | 25323 | IrInstruction *end_value = range->end->child; |
| 25286 | if (type_is_invalid(end_value->value.type)) | 25324 | if (type_is_invalid(end_value->value->type)) |
| 25287 | return ira->codegen->invalid_instruction; | 25325 | return ira->codegen->invalid_instruction; |
| 25288 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | 25326 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); |
| 25289 | if (type_is_invalid(casted_end_value->value.type)) | 25327 | if (type_is_invalid(casted_end_value->value->type)) |
| 25290 | return ira->codegen->invalid_instruction; | 25328 | return ira->codegen->invalid_instruction; |
| 25291 | | 25329 | |
| 25292 | ConstExprValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); | 25330 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); |
| 25293 | if (!start_val) | 25331 | if (!start_val) |
| 25294 | return ira->codegen->invalid_instruction; | 25332 | return ira->codegen->invalid_instruction; |
| 25295 | | 25333 | |
| 25296 | ConstExprValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); | 25334 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); |
| 25297 | if (!end_val) | 25335 | if (!end_val) |
| 25298 | return ira->codegen->invalid_instruction; | 25336 | return ira->codegen->invalid_instruction; |
| 25299 | | 25337 | |
| ... | @@ -25326,10 +25364,10 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25326,10 +25364,10 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25326 | IrInstruction *value = range->start->child; | 25364 | IrInstruction *value = range->start->child; |
| 25327 | | 25365 | |
| 25328 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); | 25366 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); |
| 25329 | if (type_is_invalid(casted_value->value.type)) | 25367 | if (type_is_invalid(casted_value->value->type)) |
| 25330 | return ira->codegen->invalid_instruction; | 25368 | return ira->codegen->invalid_instruction; |
| 25331 | | 25369 | |
| 25332 | ConstExprValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); | 25370 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 25333 | if (!const_expr_val) | 25371 | if (!const_expr_val) |
| 25334 | return ira->codegen->invalid_instruction; | 25372 | return ira->codegen->invalid_instruction; |
| 25335 | | 25373 | |
| ... | @@ -25362,7 +25400,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * | ... | @@ -25362,7 +25400,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * |
| 25362 | IrInstructionCheckStatementIsVoid *instruction) | 25400 | IrInstructionCheckStatementIsVoid *instruction) |
| 25363 | { | 25401 | { |
| 25364 | IrInstruction *statement_value = instruction->statement_value->child; | 25402 | IrInstruction *statement_value = instruction->statement_value->child; |
| 25365 | ZigType *statement_type = statement_value->value.type; | 25403 | ZigType *statement_type = statement_value->value->type; |
| 25366 | if (type_is_invalid(statement_type)) | 25404 | if (type_is_invalid(statement_type)) |
| 25367 | return ira->codegen->invalid_instruction; | 25405 | return ira->codegen->invalid_instruction; |
| 25368 | | 25406 | |
| ... | @@ -25375,7 +25413,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * | ... | @@ -25375,7 +25413,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * |
| 25375 | | 25413 | |
| 25376 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { | 25414 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { |
| 25377 | IrInstruction *msg = instruction->msg->child; | 25415 | IrInstruction *msg = instruction->msg->child; |
| 25378 | if (type_is_invalid(msg->value.type)) | 25416 | if (type_is_invalid(msg->value->type)) |
| 25379 | return ir_unreach_error(ira); | 25417 | return ir_unreach_error(ira); |
| 25380 | | 25418 | |
| 25381 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { | 25419 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { |
| ... | @@ -25387,7 +25425,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction | ... | @@ -25387,7 +25425,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction |
| 25387 | true, false, PtrLenUnknown, 0, 0, 0, false); | 25425 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 25388 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 25426 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 25389 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); | 25427 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); |
| 25390 | if (type_is_invalid(casted_msg->value.type)) | 25428 | if (type_is_invalid(casted_msg->value->type)) |
| 25391 | return ir_unreach_error(ira); | 25429 | return ir_unreach_error(ira); |
| 25392 | | 25430 | |
| 25393 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, | 25431 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, |
| ... | @@ -25398,7 +25436,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction | ... | @@ -25398,7 +25436,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction |
| 25398 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { | 25436 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { |
| 25399 | Error err; | 25437 | Error err; |
| 25400 | | 25438 | |
| 25401 | ZigType *target_type = target->value.type; | 25439 | ZigType *target_type = target->value->type; |
| 25402 | assert(!type_is_invalid(target_type)); | 25440 | assert(!type_is_invalid(target_type)); |
| 25403 | | 25441 | |
| 25404 | ZigType *result_type; | 25442 | ZigType *result_type; |
| ... | @@ -25443,7 +25481,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25443,7 +25481,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25443 | } | 25481 | } |
| 25444 | | 25482 | |
| 25445 | if (instr_is_comptime(target)) { | 25483 | if (instr_is_comptime(target)) { |
| 25446 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 25484 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 25447 | if (!val) | 25485 | if (!val) |
| 25448 | return ira->codegen->invalid_instruction; | 25486 | return ira->codegen->invalid_instruction; |
| 25449 | | 25487 | |
| ... | @@ -25457,8 +25495,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25457,8 +25495,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25457 | } | 25495 | } |
| 25458 | | 25496 | |
| 25459 | IrInstruction *result = ir_const(ira, target, result_type); | 25497 | IrInstruction *result = ir_const(ira, target, result_type); |
| 25460 | copy_const_val(&result->value, val, true); | 25498 | copy_const_val(result->value, val, true); |
| 25461 | result->value.type = result_type; | 25499 | result->value->type = result_type; |
| 25462 | return result; | 25500 | return result; |
| 25463 | } | 25501 | } |
| 25464 | | 25502 | |
| ... | @@ -25468,7 +25506,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25468,7 +25506,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25468 | } else { | 25506 | } else { |
| 25469 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); | 25507 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); |
| 25470 | } | 25508 | } |
| 25471 | result->value.type = result_type; | 25509 | result->value->type = result_type; |
| 25472 | return result; | 25510 | return result; |
| 25473 | } | 25511 | } |
| 25474 | | 25512 | |
| ... | @@ -25477,7 +25515,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25477,7 +25515,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25477 | { | 25515 | { |
| 25478 | Error err; | 25516 | Error err; |
| 25479 | | 25517 | |
| 25480 | ZigType *src_type = ptr->value.type; | 25518 | ZigType *src_type = ptr->value->type; |
| 25481 | assert(!type_is_invalid(src_type)); | 25519 | assert(!type_is_invalid(src_type)); |
| 25482 | | 25520 | |
| 25483 | if (src_type == dest_type) { | 25521 | if (src_type == dest_type) { |
| ... | @@ -25515,7 +25553,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25515,7 +25553,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25515 | if (instr_is_comptime(ptr)) { | 25553 | if (instr_is_comptime(ptr)) { |
| 25516 | bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type); | 25554 | bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type); |
| 25517 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; | 25555 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; |
| 25518 | ConstExprValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); | 25556 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); |
| 25519 | if (!val) | 25557 | if (!val) |
| 25520 | return ira->codegen->invalid_instruction; | 25558 | return ira->codegen->invalid_instruction; |
| 25521 | | 25559 | |
| ... | @@ -25531,7 +25569,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25531,7 +25569,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25531 | } | 25569 | } |
| 25532 | | 25570 | |
| 25533 | IrInstruction *result; | 25571 | IrInstruction *result; |
| 25534 | if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) { | 25572 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 25535 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 25573 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 25536 | | 25574 | |
| 25537 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 25575 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| ... | @@ -25539,8 +25577,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25539,8 +25577,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25539 | } else { | 25577 | } else { |
| 25540 | result = ir_const(ira, source_instr, dest_type); | 25578 | result = ir_const(ira, source_instr, dest_type); |
| 25541 | } | 25579 | } |
| 25542 | copy_const_val(&result->value, val, true); | 25580 | copy_const_val(result->value, val, true); |
| 25543 | result->value.type = dest_type; | 25581 | result->value->type = dest_type; |
| 25544 | | 25582 | |
| 25545 | // Keep the bigger alignment, it can only help- | 25583 | // Keep the bigger alignment, it can only help- |
| 25546 | // unless the target is zero bits. | 25584 | // unless the target is zero bits. |
| ... | @@ -25584,7 +25622,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25584,7 +25622,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25584 | IrInstruction *result; | 25622 | IrInstruction *result; |
| 25585 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { | 25623 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { |
| 25586 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); | 25624 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); |
| 25587 | if (type_is_invalid(result->value.type)) | 25625 | if (type_is_invalid(result->value->type)) |
| 25588 | return ira->codegen->invalid_instruction; | 25626 | return ira->codegen->invalid_instruction; |
| 25589 | } else { | 25627 | } else { |
| 25590 | result = casted_ptr; | 25628 | result = casted_ptr; |
| ... | @@ -25599,7 +25637,7 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct | ... | @@ -25599,7 +25637,7 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct |
| 25599 | return ira->codegen->invalid_instruction; | 25637 | return ira->codegen->invalid_instruction; |
| 25600 | | 25638 | |
| 25601 | IrInstruction *ptr = instruction->ptr->child; | 25639 | IrInstruction *ptr = instruction->ptr->child; |
| 25602 | ZigType *src_type = ptr->value.type; | 25640 | ZigType *src_type = ptr->value->type; |
| 25603 | if (type_is_invalid(src_type)) | 25641 | if (type_is_invalid(src_type)) |
| 25604 | return ira->codegen->invalid_instruction; | 25642 | return ira->codegen->invalid_instruction; |
| 25605 | | 25643 | |
| ... | @@ -25607,18 +25645,18 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct | ... | @@ -25607,18 +25645,18 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct |
| 25607 | instruction->safety_check_on); | 25645 | instruction->safety_check_on); |
| 25608 | } | 25646 | } |
| 25609 | | 25647 | |
| 25610 | static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ConstExprValue *val, size_t len) { | 25648 | static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ZigValue *val, size_t len) { |
| 25611 | size_t buf_i = 0; | 25649 | size_t buf_i = 0; |
| 25612 | // TODO optimize the buf case | 25650 | // TODO optimize the buf case |
| 25613 | expand_undef_array(codegen, val); | 25651 | expand_undef_array(codegen, val); |
| 25614 | for (size_t elem_i = 0; elem_i < val->type->data.array.len; elem_i += 1) { | 25652 | for (size_t elem_i = 0; elem_i < val->type->data.array.len; elem_i += 1) { |
| 25615 | ConstExprValue *elem = &val->data.x_array.data.s_none.elements[elem_i]; | 25653 | ZigValue *elem = &val->data.x_array.data.s_none.elements[elem_i]; |
| 25616 | buf_write_value_bytes(codegen, &buf[buf_i], elem); | 25654 | buf_write_value_bytes(codegen, &buf[buf_i], elem); |
| 25617 | buf_i += type_size(codegen, elem->type); | 25655 | buf_i += type_size(codegen, elem->type); |
| 25618 | } | 25656 | } |
| 25619 | } | 25657 | } |
| 25620 | | 25658 | |
| 25621 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { | 25659 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val) { |
| 25622 | if (val->special == ConstValSpecialUndef) { | 25660 | if (val->special == ConstValSpecialUndef) { |
| 25623 | expand_undef_struct(codegen, val); | 25661 | expand_undef_struct(codegen, val); |
| 25624 | val->special = ConstValSpecialStatic; | 25662 | val->special = ConstValSpecialStatic; |
| ... | @@ -25679,7 +25717,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25679,7 +25717,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25679 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; | 25717 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; |
| 25680 | if (struct_field->gen_index == SIZE_MAX) | 25718 | if (struct_field->gen_index == SIZE_MAX) |
| 25681 | continue; | 25719 | continue; |
| 25682 | ConstExprValue *field_val = val->data.x_struct.fields[field_i]; | 25720 | ZigValue *field_val = val->data.x_struct.fields[field_i]; |
| 25683 | size_t offset = struct_field->offset; | 25721 | size_t offset = struct_field->offset; |
| 25684 | buf_write_value_bytes(codegen, buf + offset, field_val); | 25722 | buf_write_value_bytes(codegen, buf + offset, field_val); |
| 25685 | } | 25723 | } |
| ... | @@ -25754,7 +25792,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25754,7 +25792,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25754 | } | 25792 | } |
| 25755 | | 25793 | |
| 25756 | static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, | 25794 | static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, |
| 25757 | ConstExprValue *val, ZigType *elem_type, size_t len) | 25795 | ZigValue *val, ZigType *elem_type, size_t len) |
| 25758 | { | 25796 | { |
| 25759 | Error err; | 25797 | Error err; |
| 25760 | uint64_t elem_size = type_size(codegen, elem_type); | 25798 | uint64_t elem_size = type_size(codegen, elem_type); |
| ... | @@ -25763,7 +25801,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod | ... | @@ -25763,7 +25801,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 25763 | case ConstArraySpecialNone: | 25801 | case ConstArraySpecialNone: |
| 25764 | val->data.x_array.data.s_none.elements = create_const_vals(len); | 25802 | val->data.x_array.data.s_none.elements = create_const_vals(len); |
| 25765 | for (size_t i = 0; i < len; i++) { | 25803 | for (size_t i = 0; i < len; i++) { |
| 25766 | ConstExprValue *elem = &val->data.x_array.data.s_none.elements[i]; | 25804 | ZigValue *elem = &val->data.x_array.data.s_none.elements[i]; |
| 25767 | elem->special = ConstValSpecialStatic; | 25805 | elem->special = ConstValSpecialStatic; |
| 25768 | elem->type = elem_type; | 25806 | elem->type = elem_type; |
| 25769 | if ((err = buf_read_value_bytes(ira, codegen, source_node, buf + (elem_size * i), elem))) | 25807 | if ((err = buf_read_value_bytes(ira, codegen, source_node, buf + (elem_size * i), elem))) |
| ... | @@ -25778,7 +25816,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod | ... | @@ -25778,7 +25816,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 25778 | zig_unreachable(); | 25816 | zig_unreachable(); |
| 25779 | } | 25817 | } |
| 25780 | | 25818 | |
| 25781 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val) { | 25819 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val) { |
| 25782 | Error err; | 25820 | Error err; |
| 25783 | src_assert(val->special == ConstValSpecialStatic, source_node); | 25821 | src_assert(val->special == ConstValSpecialStatic, source_node); |
| 25784 | switch (val->type->id) { | 25822 | switch (val->type->id) { |
| ... | @@ -25850,7 +25888,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25850,7 +25888,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25850 | size_t src_field_count = val->type->data.structure.src_field_count; | 25888 | size_t src_field_count = val->type->data.structure.src_field_count; |
| 25851 | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); | 25889 | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); |
| 25852 | for (size_t field_i = 0; field_i < src_field_count; field_i += 1) { | 25890 | for (size_t field_i = 0; field_i < src_field_count; field_i += 1) { |
| 25853 | ConstExprValue *field_val = val->data.x_struct.fields[field_i]; | 25891 | ZigValue *field_val = val->data.x_struct.fields[field_i]; |
| 25854 | field_val->special = ConstValSpecialStatic; | 25892 | field_val->special = ConstValSpecialStatic; |
| 25855 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; | 25893 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; |
| 25856 | field_val->type = struct_field->type_entry; | 25894 | field_val->type = struct_field->type_entry; |
| ... | @@ -25887,7 +25925,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25887,7 +25925,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25887 | src_assert(field->gen_index != SIZE_MAX, source_node); | 25925 | src_assert(field->gen_index != SIZE_MAX, source_node); |
| 25888 | if (field->gen_index != gen_i) | 25926 | if (field->gen_index != gen_i) |
| 25889 | break; | 25927 | break; |
| 25890 | ConstExprValue *field_val = val->data.x_struct.fields[src_i]; | 25928 | ZigValue *field_val = val->data.x_struct.fields[src_i]; |
| 25891 | field_val->special = ConstValSpecialStatic; | 25929 | field_val->special = ConstValSpecialStatic; |
| 25892 | field_val->type = field->type_entry; | 25930 | field_val->type = field->type_entry; |
| 25893 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); | 25931 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); |
| ... | @@ -25941,7 +25979,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25941,7 +25979,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25941 | { | 25979 | { |
| 25942 | Error err; | 25980 | Error err; |
| 25943 | | 25981 | |
| 25944 | ZigType *src_type = value->value.type; | 25982 | ZigType *src_type = value->value->type; |
| 25945 | ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr); | 25983 | ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr); |
| 25946 | ir_assert(type_can_bit_cast(src_type), source_instr); | 25984 | ir_assert(type_can_bit_cast(src_type), source_instr); |
| 25947 | ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr); | 25985 | ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr); |
| ... | @@ -25975,14 +26013,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25975,14 +26013,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25975 | } | 26013 | } |
| 25976 | | 26014 | |
| 25977 | if (instr_is_comptime(value)) { | 26015 | if (instr_is_comptime(value)) { |
| 25978 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 26016 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 25979 | if (!val) | 26017 | if (!val) |
| 25980 | return ira->codegen->invalid_instruction; | 26018 | return ira->codegen->invalid_instruction; |
| 25981 | | 26019 | |
| 25982 | IrInstruction *result = ir_const(ira, source_instr, dest_type); | 26020 | IrInstruction *result = ir_const(ira, source_instr, dest_type); |
| 25983 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); | 26021 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); |
| 25984 | buf_write_value_bytes(ira->codegen, buf, val); | 26022 | 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))) | 26023 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) |
| 25986 | return ira->codegen->invalid_instruction; | 26024 | return ira->codegen->invalid_instruction; |
| 25987 | return result; | 26025 | return result; |
| 25988 | } | 26026 | } |
| ... | @@ -25997,11 +26035,11 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -25997,11 +26035,11 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 25997 | ir_assert(type_has_bits(ptr_type), source_instr); | 26035 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 25998 | | 26036 | |
| 25999 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | 26037 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 26000 | if (type_is_invalid(casted_int->value.type)) | 26038 | if (type_is_invalid(casted_int->value->type)) |
| 26001 | return ira->codegen->invalid_instruction; | 26039 | return ira->codegen->invalid_instruction; |
| 26002 | | 26040 | |
| 26003 | if (instr_is_comptime(casted_int)) { | 26041 | if (instr_is_comptime(casted_int)) { |
| 26004 | ConstExprValue *val = ir_resolve_const(ira, casted_int, UndefBad); | 26042 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); |
| 26005 | if (!val) | 26043 | if (!val) |
| 26006 | return ira->codegen->invalid_instruction; | 26044 | return ira->codegen->invalid_instruction; |
| 26007 | | 26045 | |
| ... | @@ -26013,15 +26051,15 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -26013,15 +26051,15 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 26013 | } | 26051 | } |
| 26014 | | 26052 | |
| 26015 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); | 26053 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); |
| 26016 | result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 26054 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 26017 | result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar; | 26055 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 26018 | result->value.data.x_ptr.data.hard_coded_addr.addr = addr; | 26056 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; |
| 26019 | return result; | 26057 | return result; |
| 26020 | } | 26058 | } |
| 26021 | | 26059 | |
| 26022 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, | 26060 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, |
| 26023 | source_instr->source_node, nullptr, casted_int); | 26061 | source_instr->source_node, nullptr, casted_int); |
| 26024 | result->value.type = ptr_type; | 26062 | result->value->type = ptr_type; |
| 26025 | return result; | 26063 | return result; |
| 26026 | } | 26064 | } |
| 26027 | | 26065 | |
| ... | @@ -26048,7 +26086,7 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru | ... | @@ -26048,7 +26086,7 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru |
| 26048 | | 26086 | |
| 26049 | | 26087 | |
| 26050 | IrInstruction *target = instruction->target->child; | 26088 | IrInstruction *target = instruction->target->child; |
| 26051 | if (type_is_invalid(target->value.type)) | 26089 | if (type_is_invalid(target->value->type)) |
| 26052 | return ira->codegen->invalid_instruction; | 26090 | return ira->codegen->invalid_instruction; |
| 26053 | | 26091 | |
| 26054 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); | 26092 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); |
| ... | @@ -26058,7 +26096,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | ... | @@ -26058,7 +26096,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 26058 | IrInstructionDeclRef *instruction) | 26096 | IrInstructionDeclRef *instruction) |
| 26059 | { | 26097 | { |
| 26060 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); | 26098 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); |
| 26061 | if (type_is_invalid(ref_instruction->value.type)) { | 26099 | if (type_is_invalid(ref_instruction->value->type)) { |
| 26062 | return ira->codegen->invalid_instruction; | 26100 | return ira->codegen->invalid_instruction; |
| 26063 | } | 26101 | } |
| 26064 | | 26102 | |
| ... | @@ -26072,51 +26110,51 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | ... | @@ -26072,51 +26110,51 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 26072 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { | 26110 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { |
| 26073 | Error err; | 26111 | Error err; |
| 26074 | IrInstruction *target = instruction->target->child; | 26112 | IrInstruction *target = instruction->target->child; |
| 26075 | if (type_is_invalid(target->value.type)) | 26113 | if (type_is_invalid(target->value->type)) |
| 26076 | return ira->codegen->invalid_instruction; | 26114 | return ira->codegen->invalid_instruction; |
| 26077 | | 26115 | |
| 26078 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 26116 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 26079 | | 26117 | |
| 26080 | // We check size explicitly so we can use get_src_ptr_type here. | 26118 | // We check size explicitly so we can use get_src_ptr_type here. |
| 26081 | if (get_src_ptr_type(target->value.type) == nullptr) { | 26119 | if (get_src_ptr_type(target->value->type) == nullptr) { |
| 26082 | ir_add_error(ira, target, | 26120 | ir_add_error(ira, target, |
| 26083 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name))); | 26121 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); |
| 26084 | return ira->codegen->invalid_instruction; | 26122 | return ira->codegen->invalid_instruction; |
| 26085 | } | 26123 | } |
| 26086 | | 26124 | |
| 26087 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) | 26125 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 26088 | return ira->codegen->invalid_instruction; | 26126 | return ira->codegen->invalid_instruction; |
| 26089 | if (!type_has_bits(target->value.type)) { | 26127 | if (!type_has_bits(target->value->type)) { |
| 26090 | ir_add_error(ira, target, | 26128 | ir_add_error(ira, target, |
| 26091 | buf_sprintf("pointer to size 0 type has no address")); | 26129 | buf_sprintf("pointer to size 0 type has no address")); |
| 26092 | return ira->codegen->invalid_instruction; | 26130 | return ira->codegen->invalid_instruction; |
| 26093 | } | 26131 | } |
| 26094 | | 26132 | |
| 26095 | if (instr_is_comptime(target)) { | 26133 | if (instr_is_comptime(target)) { |
| 26096 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 26134 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 26097 | if (!val) | 26135 | if (!val) |
| 26098 | return ira->codegen->invalid_instruction; | 26136 | return ira->codegen->invalid_instruction; |
| 26099 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 26137 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 26100 | IrInstruction *result = ir_const(ira, &instruction->base, usize); | 26138 | 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); | 26139 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| 26102 | result->value.type = usize; | 26140 | result->value->type = usize; |
| 26103 | return result; | 26141 | return result; |
| 26104 | } | 26142 | } |
| 26105 | } | 26143 | } |
| 26106 | | 26144 | |
| 26107 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, | 26145 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, |
| 26108 | instruction->base.source_node, target); | 26146 | instruction->base.source_node, target); |
| 26109 | result->value.type = usize; | 26147 | result->value->type = usize; |
| 26110 | return result; | 26148 | return result; |
| 26111 | } | 26149 | } |
| 26112 | | 26150 | |
| 26113 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 26151 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { |
| 26114 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 26152 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 26115 | result->value.special = ConstValSpecialLazy; | 26153 | result->value->special = ConstValSpecialLazy; |
| 26116 | | 26154 | |
| 26117 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); | 26155 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); |
| 26118 | lazy_ptr_type->ira = ira; | 26156 | lazy_ptr_type->ira = ira; |
| 26119 | result->value.data.x_lazy = &lazy_ptr_type->base; | 26157 | result->value->data.x_lazy = &lazy_ptr_type->base; |
| 26120 | lazy_ptr_type->base.id = LazyValueIdPtrType; | 26158 | lazy_ptr_type->base.id = LazyValueIdPtrType; |
| 26121 | | 26159 | |
| 26122 | if (instruction->sentinel != nullptr) { | 26160 | if (instruction->sentinel != nullptr) { |
| ... | @@ -26147,15 +26185,15 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -26147,15 +26185,15 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 26147 | | 26185 | |
| 26148 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { | 26186 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { |
| 26149 | IrInstruction *target = instruction->target->child; | 26187 | IrInstruction *target = instruction->target->child; |
| 26150 | if (type_is_invalid(target->value.type)) | 26188 | if (type_is_invalid(target->value->type)) |
| 26151 | return ira->codegen->invalid_instruction; | 26189 | return ira->codegen->invalid_instruction; |
| 26152 | | 26190 | |
| 26153 | ZigType *elem_type = nullptr; | 26191 | ZigType *elem_type = nullptr; |
| 26154 | if (is_slice(target->value.type)) { | 26192 | if (is_slice(target->value->type)) { |
| 26155 | ZigType *slice_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 26193 | ZigType *slice_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 26156 | elem_type = slice_ptr_type->data.pointer.child_type; | 26194 | elem_type = slice_ptr_type->data.pointer.child_type; |
| 26157 | } else if (target->value.type->id == ZigTypeIdPointer) { | 26195 | } else if (target->value->type->id == ZigTypeIdPointer) { |
| 26158 | elem_type = target->value.type->data.pointer.child_type; | 26196 | elem_type = target->value->type->data.pointer.child_type; |
| 26159 | } | 26197 | } |
| 26160 | | 26198 | |
| 26161 | uint32_t align_bytes; | 26199 | uint32_t align_bytes; |
| ... | @@ -26164,7 +26202,7 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru | ... | @@ -26164,7 +26202,7 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru |
| 26164 | return ira->codegen->invalid_instruction; | 26202 | return ira->codegen->invalid_instruction; |
| 26165 | | 26203 | |
| 26166 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); | 26204 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); |
| 26167 | if (type_is_invalid(result->value.type)) | 26205 | if (type_is_invalid(result->value->type)) |
| 26168 | return ira->codegen->invalid_instruction; | 26206 | return ira->codegen->invalid_instruction; |
| 26169 | | 26207 | |
| 26170 | return result; | 26208 | return result; |
| ... | @@ -26350,13 +26388,13 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26350,13 +26388,13 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26350 | return ira->codegen->invalid_instruction; | 26388 | return ira->codegen->invalid_instruction; |
| 26351 | | 26389 | |
| 26352 | IrInstruction *ptr_inst = instruction->ptr->child; | 26390 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26353 | if (type_is_invalid(ptr_inst->value.type)) | 26391 | if (type_is_invalid(ptr_inst->value->type)) |
| 26354 | return ira->codegen->invalid_instruction; | 26392 | return ira->codegen->invalid_instruction; |
| 26355 | | 26393 | |
| 26356 | // TODO let this be volatile | 26394 | // TODO let this be volatile |
| 26357 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 26395 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26358 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26396 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26359 | if (type_is_invalid(casted_ptr->value.type)) | 26397 | if (type_is_invalid(casted_ptr->value->type)) |
| 26360 | return ira->codegen->invalid_instruction; | 26398 | return ira->codegen->invalid_instruction; |
| 26361 | | 26399 | |
| 26362 | AtomicRmwOp op; | 26400 | AtomicRmwOp op; |
| ... | @@ -26375,11 +26413,11 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26375,11 +26413,11 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26375 | } | 26413 | } |
| 26376 | | 26414 | |
| 26377 | IrInstruction *operand = instruction->operand->child; | 26415 | IrInstruction *operand = instruction->operand->child; |
| 26378 | if (type_is_invalid(operand->value.type)) | 26416 | if (type_is_invalid(operand->value->type)) |
| 26379 | return ira->codegen->invalid_instruction; | 26417 | return ira->codegen->invalid_instruction; |
| 26380 | | 26418 | |
| 26381 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); | 26419 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); |
| 26382 | if (type_is_invalid(casted_operand->value.type)) | 26420 | if (type_is_invalid(casted_operand->value->type)) |
| 26383 | return ira->codegen->invalid_instruction; | 26421 | return ira->codegen->invalid_instruction; |
| 26384 | | 26422 | |
| 26385 | AtomicOrder ordering; | 26423 | AtomicOrder ordering; |
| ... | @@ -26395,7 +26433,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26395,7 +26433,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26395 | } | 26433 | } |
| 26396 | } | 26434 | } |
| 26397 | | 26435 | |
| 26398 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar) | 26436 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) |
| 26399 | { | 26437 | { |
| 26400 | zig_panic("TODO compile-time execution of atomicRmw"); | 26438 | zig_panic("TODO compile-time execution of atomicRmw"); |
| 26401 | } | 26439 | } |
| ... | @@ -26403,7 +26441,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26403,7 +26441,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26403 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, | 26441 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, |
| 26404 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, | 26442 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, |
| 26405 | op, ordering); | 26443 | op, ordering); |
| 26406 | result->value.type = operand_type; | 26444 | result->value->type = operand_type; |
| 26407 | return result; | 26445 | return result; |
| 26408 | } | 26446 | } |
| 26409 | | 26447 | |
| ... | @@ -26413,12 +26451,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -26413,12 +26451,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 26413 | return ira->codegen->invalid_instruction; | 26451 | return ira->codegen->invalid_instruction; |
| 26414 | | 26452 | |
| 26415 | IrInstruction *ptr_inst = instruction->ptr->child; | 26453 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26416 | if (type_is_invalid(ptr_inst->value.type)) | 26454 | if (type_is_invalid(ptr_inst->value->type)) |
| 26417 | return ira->codegen->invalid_instruction; | 26455 | return ira->codegen->invalid_instruction; |
| 26418 | | 26456 | |
| 26419 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); | 26457 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 26420 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26458 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26421 | if (type_is_invalid(casted_ptr->value.type)) | 26459 | if (type_is_invalid(casted_ptr->value->type)) |
| 26422 | return ira->codegen->invalid_instruction; | 26460 | return ira->codegen->invalid_instruction; |
| 26423 | | 26461 | |
| 26424 | AtomicOrder ordering; | 26462 | AtomicOrder ordering; |
| ... | @@ -26438,13 +26476,13 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -26438,13 +26476,13 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 26438 | | 26476 | |
| 26439 | if (instr_is_comptime(casted_ptr)) { | 26477 | if (instr_is_comptime(casted_ptr)) { |
| 26440 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); | 26478 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); |
| 26441 | ir_assert(result->value.type != nullptr, &instruction->base); | 26479 | ir_assert(result->value->type != nullptr, &instruction->base); |
| 26442 | return result; | 26480 | return result; |
| 26443 | } | 26481 | } |
| 26444 | | 26482 | |
| 26445 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, | 26483 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, |
| 26446 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); | 26484 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); |
| 26447 | result->value.type = operand_type; | 26485 | result->value->type = operand_type; |
| 26448 | return result; | 26486 | return result; |
| 26449 | } | 26487 | } |
| 26450 | | 26488 | |
| ... | @@ -26454,20 +26492,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst | ... | @@ -26454,20 +26492,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26454 | return ira->codegen->invalid_instruction; | 26492 | return ira->codegen->invalid_instruction; |
| 26455 | | 26493 | |
| 26456 | IrInstruction *ptr_inst = instruction->ptr->child; | 26494 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26457 | if (type_is_invalid(ptr_inst->value.type)) | 26495 | if (type_is_invalid(ptr_inst->value->type)) |
| 26458 | return ira->codegen->invalid_instruction; | 26496 | return ira->codegen->invalid_instruction; |
| 26459 | | 26497 | |
| 26460 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 26498 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26461 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26499 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26462 | if (type_is_invalid(casted_ptr->value.type)) | 26500 | if (type_is_invalid(casted_ptr->value->type)) |
| 26463 | return ira->codegen->invalid_instruction; | 26501 | return ira->codegen->invalid_instruction; |
| 26464 | | 26502 | |
| 26465 | IrInstruction *value = instruction->value->child; | 26503 | IrInstruction *value = instruction->value->child; |
| 26466 | if (type_is_invalid(value->value.type)) | 26504 | if (type_is_invalid(value->value->type)) |
| 26467 | return ira->codegen->invalid_instruction; | 26505 | return ira->codegen->invalid_instruction; |
| 26468 | | 26506 | |
| 26469 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); | 26507 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); |
| 26470 | if (type_is_invalid(casted_value->value.type)) | 26508 | if (type_is_invalid(casted_value->value->type)) |
| 26471 | return ira->codegen->invalid_instruction; | 26509 | return ira->codegen->invalid_instruction; |
| 26472 | | 26510 | |
| 26473 | | 26511 | |
| ... | @@ -26488,25 +26526,25 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst | ... | @@ -26488,25 +26526,25 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26488 | | 26526 | |
| 26489 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { | 26527 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |
| 26490 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); | 26528 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); |
| 26491 | result->value.type = ira->codegen->builtin_types.entry_void; | 26529 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26492 | return result; | 26530 | return result; |
| 26493 | } | 26531 | } |
| 26494 | | 26532 | |
| 26495 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, | 26533 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, |
| 26496 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); | 26534 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); |
| 26497 | result->value.type = ira->codegen->builtin_types.entry_void; | 26535 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26498 | return result; | 26536 | return result; |
| 26499 | } | 26537 | } |
| 26500 | | 26538 | |
| 26501 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { | 26539 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { |
| 26502 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, | 26540 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, |
| 26503 | instruction->base.source_node); | 26541 | instruction->base.source_node); |
| 26504 | result->value.type = ira->codegen->builtin_types.entry_void; | 26542 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26505 | return result; | 26543 | return result; |
| 26506 | } | 26544 | } |
| 26507 | | 26545 | |
| 26508 | static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, ZigType *float_type, | 26546 | static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, ZigType *float_type, |
| 26509 | ConstExprValue *op, ConstExprValue *out_val) { | 26547 | ZigValue *op, ZigValue *out_val) { |
| 26510 | assert(ira && source_instr && float_type && out_val && op); | 26548 | assert(ira && source_instr && float_type && out_val && op); |
| 26511 | assert(float_type->id == ZigTypeIdFloat || | 26549 | assert(float_type->id == ZigTypeIdFloat || |
| 26512 | float_type->id == ZigTypeIdComptimeFloat); | 26550 | float_type->id == ZigTypeIdComptimeFloat); |
| ... | @@ -26687,7 +26725,7 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, | ... | @@ -26687,7 +26725,7 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, |
| 26687 | | 26725 | |
| 26688 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { | 26726 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { |
| 26689 | IrInstruction *type = instruction->type->child; | 26727 | IrInstruction *type = instruction->type->child; |
| 26690 | if (type_is_invalid(type->value.type)) | 26728 | if (type_is_invalid(type->value->type)) |
| 26691 | return ira->codegen->invalid_instruction; | 26729 | return ira->codegen->invalid_instruction; |
| 26692 | | 26730 | |
| 26693 | ZigType *expr_type = ir_resolve_type(ira, type); | 26731 | ZigType *expr_type = ir_resolve_type(ira, type); |
| ... | @@ -26702,11 +26740,11 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26702,11 +26740,11 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26702 | } | 26740 | } |
| 26703 | | 26741 | |
| 26704 | IrInstruction *op1 = instruction->op1->child; | 26742 | IrInstruction *op1 = instruction->op1->child; |
| 26705 | if (type_is_invalid(op1->value.type)) | 26743 | if (type_is_invalid(op1->value->type)) |
| 26706 | return ira->codegen->invalid_instruction; | 26744 | return ira->codegen->invalid_instruction; |
| 26707 | | 26745 | |
| 26708 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type); | 26746 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type); |
| 26709 | if (type_is_invalid(casted_op1->value.type)) | 26747 | if (type_is_invalid(casted_op1->value->type)) |
| 26710 | return ira->codegen->invalid_instruction; | 26748 | return ira->codegen->invalid_instruction; |
| 26711 | | 26749 | |
| 26712 | if (instr_is_comptime(casted_op1)) { | 26750 | if (instr_is_comptime(casted_op1)) { |
| ... | @@ -26719,12 +26757,12 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26719,12 +26757,12 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26719 | return ira->codegen->invalid_instruction; | 26757 | return ira->codegen->invalid_instruction; |
| 26720 | } | 26758 | } |
| 26721 | | 26759 | |
| 26722 | ConstExprValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 26760 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 26723 | if (!op1_const) | 26761 | if (!op1_const) |
| 26724 | return ira->codegen->invalid_instruction; | 26762 | return ira->codegen->invalid_instruction; |
| 26725 | | 26763 | |
| 26726 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 26764 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 26727 | ConstExprValue *out_val = &result->value; | 26765 | ZigValue *out_val = result->value; |
| 26728 | | 26766 | |
| 26729 | if (expr_type->id == ZigTypeIdVector) { | 26767 | if (expr_type->id == ZigTypeIdVector) { |
| 26730 | expand_undef_array(ira->codegen, op1_const); | 26768 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -26732,8 +26770,8 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26732,8 +26770,8 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26732 | expand_undef_array(ira->codegen, out_val); | 26770 | expand_undef_array(ira->codegen, out_val); |
| 26733 | size_t len = expr_type->data.vector.len; | 26771 | size_t len = expr_type->data.vector.len; |
| 26734 | for (size_t i = 0; i < len; i += 1) { | 26772 | for (size_t i = 0; i < len; i += 1) { |
| 26735 | ConstExprValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; | 26773 | ZigValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; |
| 26736 | ConstExprValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 26774 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 26737 | assert(float_operand_op1->type == float_type); | 26775 | assert(float_operand_op1->type == float_type); |
| 26738 | assert(float_out_val->type == float_type); | 26776 | assert(float_out_val->type == float_type); |
| 26739 | ir_eval_float_op(ira, instruction, float_type, | 26777 | ir_eval_float_op(ira, instruction, float_type, |
| ... | @@ -26752,7 +26790,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26752,7 +26790,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26752 | | 26790 | |
| 26753 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, | 26791 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, |
| 26754 | instruction->base.source_node, nullptr, casted_op1, instruction->op); | 26792 | instruction->base.source_node, nullptr, casted_op1, instruction->op); |
| 26755 | result->value.type = expr_type; | 26793 | result->value->type = expr_type; |
| 26756 | return result; | 26794 | return result; |
| 26757 | } | 26795 | } |
| 26758 | | 26796 | |
| ... | @@ -26764,16 +26802,16 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26764,16 +26802,16 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26764 | return ira->codegen->invalid_instruction; | 26802 | return ira->codegen->invalid_instruction; |
| 26765 | | 26803 | |
| 26766 | IrInstruction *uncasted_op = instruction->op->child; | 26804 | IrInstruction *uncasted_op = instruction->op->child; |
| 26767 | if (type_is_invalid(uncasted_op->value.type)) | 26805 | if (type_is_invalid(uncasted_op->value->type)) |
| 26768 | return ira->codegen->invalid_instruction; | 26806 | return ira->codegen->invalid_instruction; |
| 26769 | | 26807 | |
| 26770 | uint32_t vector_len; // UINT32_MAX means not a vector | 26808 | uint32_t vector_len; // UINT32_MAX means not a vector |
| 26771 | if (uncasted_op->value.type->id == ZigTypeIdArray && | 26809 | if (uncasted_op->value->type->id == ZigTypeIdArray && |
| 26772 | is_valid_vector_elem_type(uncasted_op->value.type->data.array.child_type)) | 26810 | is_valid_vector_elem_type(uncasted_op->value->type->data.array.child_type)) |
| 26773 | { | 26811 | { |
| 26774 | vector_len = uncasted_op->value.type->data.array.len; | 26812 | vector_len = uncasted_op->value->type->data.array.len; |
| 26775 | } else if (uncasted_op->value.type->id == ZigTypeIdVector) { | 26813 | } else if (uncasted_op->value->type->id == ZigTypeIdVector) { |
| 26776 | vector_len = uncasted_op->value.type->data.vector.len; | 26814 | vector_len = uncasted_op->value->type->data.vector.len; |
| 26777 | } else { | 26815 | } else { |
| 26778 | vector_len = UINT32_MAX; | 26816 | vector_len = UINT32_MAX; |
| 26779 | } | 26817 | } |
| ... | @@ -26782,7 +26820,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26782,7 +26820,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26782 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; | 26820 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 26783 | | 26821 | |
| 26784 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); | 26822 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); |
| 26785 | if (type_is_invalid(op->value.type)) | 26823 | if (type_is_invalid(op->value->type)) |
| 26786 | return ira->codegen->invalid_instruction; | 26824 | return ira->codegen->invalid_instruction; |
| 26787 | | 26825 | |
| 26788 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) | 26826 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) |
| ... | @@ -26796,7 +26834,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26796,7 +26834,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26796 | } | 26834 | } |
| 26797 | | 26835 | |
| 26798 | if (instr_is_comptime(op)) { | 26836 | if (instr_is_comptime(op)) { |
| 26799 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 26837 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 26800 | if (val == nullptr) | 26838 | if (val == nullptr) |
| 26801 | return ira->codegen->invalid_instruction; | 26839 | return ira->codegen->invalid_instruction; |
| 26802 | if (val->special == ConstValSpecialUndef) | 26840 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -26807,28 +26845,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26807,28 +26845,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26807 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); | 26845 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); |
| 26808 | if (is_vector) { | 26846 | if (is_vector) { |
| 26809 | expand_undef_array(ira->codegen, val); | 26847 | expand_undef_array(ira->codegen, val); |
| 26810 | result->value.data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); | 26848 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); |
| 26811 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { | 26849 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { |
| 26812 | ConstExprValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; | 26850 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; |
| 26813 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, | 26851 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, |
| 26814 | op_elem_val, UndefOk))) | 26852 | op_elem_val, UndefOk))) |
| 26815 | { | 26853 | { |
| 26816 | return ira->codegen->invalid_instruction; | 26854 | return ira->codegen->invalid_instruction; |
| 26817 | } | 26855 | } |
| 26818 | ConstExprValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; | 26856 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 26819 | result_elem_val->type = int_type; | 26857 | result_elem_val->type = int_type; |
| 26820 | result_elem_val->special = op_elem_val->special; | 26858 | result_elem_val->special = op_elem_val->special; |
| 26821 | if (op_elem_val->special == ConstValSpecialUndef) | 26859 | if (op_elem_val->special == ConstValSpecialUndef) |
| 26822 | continue; | 26860 | continue; |
| 26823 | | 26861 | |
| 26824 | bigint_write_twos_complement(&op_elem_val->data.x_bigint, buf, int_type->data.integral.bit_count, true); | 26862 | 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, | 26863 | bigint_read_twos_complement(&result->value->data.x_array.data.s_none.elements[i].data.x_bigint, |
| 26826 | buf, int_type->data.integral.bit_count, false, | 26864 | buf, int_type->data.integral.bit_count, false, |
| 26827 | int_type->data.integral.is_signed); | 26865 | int_type->data.integral.is_signed); |
| 26828 | } | 26866 | } |
| 26829 | } else { | 26867 | } else { |
| 26830 | bigint_write_twos_complement(&val->data.x_bigint, buf, int_type->data.integral.bit_count, true); | 26868 | 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, | 26869 | bigint_read_twos_complement(&result->value->data.x_bigint, buf, int_type->data.integral.bit_count, false, |
| 26832 | int_type->data.integral.is_signed); | 26870 | int_type->data.integral.is_signed); |
| 26833 | } | 26871 | } |
| 26834 | free(buf); | 26872 | free(buf); |
| ... | @@ -26837,7 +26875,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26837,7 +26875,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26837 | | 26875 | |
| 26838 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, | 26876 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, |
| 26839 | instruction->base.source_node, nullptr, op); | 26877 | instruction->base.source_node, nullptr, op); |
| 26840 | result->value.type = op_type; | 26878 | result->value->type = op_type; |
| 26841 | return result; | 26879 | return result; |
| 26842 | } | 26880 | } |
| 26843 | | 26881 | |
| ... | @@ -26847,17 +26885,17 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26847,17 +26885,17 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26847 | return ira->codegen->invalid_instruction; | 26885 | return ira->codegen->invalid_instruction; |
| 26848 | | 26886 | |
| 26849 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 26887 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 26850 | if (type_is_invalid(op->value.type)) | 26888 | if (type_is_invalid(op->value->type)) |
| 26851 | return ira->codegen->invalid_instruction; | 26889 | return ira->codegen->invalid_instruction; |
| 26852 | | 26890 | |
| 26853 | if (int_type->data.integral.bit_count == 0) { | 26891 | if (int_type->data.integral.bit_count == 0) { |
| 26854 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 26892 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); |
| 26855 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 26893 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 26856 | return result; | 26894 | return result; |
| 26857 | } | 26895 | } |
| 26858 | | 26896 | |
| 26859 | if (instr_is_comptime(op)) { | 26897 | if (instr_is_comptime(op)) { |
| 26860 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 26898 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 26861 | if (val == nullptr) | 26899 | if (val == nullptr) |
| 26862 | return ira->codegen->invalid_instruction; | 26900 | return ira->codegen->invalid_instruction; |
| 26863 | if (val->special == ConstValSpecialUndef) | 26901 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -26881,7 +26919,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26881,7 +26919,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26881 | } | 26919 | } |
| 26882 | } | 26920 | } |
| 26883 | | 26921 | |
| 26884 | bigint_read_twos_complement(&result->value.data.x_bigint, | 26922 | bigint_read_twos_complement(&result->value->data.x_bigint, |
| 26885 | result_buf, | 26923 | result_buf, |
| 26886 | int_type->data.integral.bit_count, | 26924 | int_type->data.integral.bit_count, |
| 26887 | ira->codegen->is_big_endian, | 26925 | ira->codegen->is_big_endian, |
| ... | @@ -26892,14 +26930,14 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26892,14 +26930,14 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26892 | | 26930 | |
| 26893 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, | 26931 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, |
| 26894 | instruction->base.source_node, nullptr, op); | 26932 | instruction->base.source_node, nullptr, op); |
| 26895 | result->value.type = int_type; | 26933 | result->value->type = int_type; |
| 26896 | return result; | 26934 | return result; |
| 26897 | } | 26935 | } |
| 26898 | | 26936 | |
| 26899 | | 26937 | |
| 26900 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { | 26938 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { |
| 26901 | IrInstruction *target = instruction->target->child; | 26939 | IrInstruction *target = instruction->target->child; |
| 26902 | if (type_is_invalid(target->value.type)) | 26940 | if (type_is_invalid(target->value->type)) |
| 26903 | return ira->codegen->invalid_instruction; | 26941 | return ira->codegen->invalid_instruction; |
| 26904 | | 26942 | |
| 26905 | return ir_analyze_enum_to_int(ira, &instruction->base, target); | 26943 | return ir_analyze_enum_to_int(ira, &instruction->base, target); |
| ... | @@ -26924,11 +26962,11 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr | ... | @@ -26924,11 +26962,11 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr |
| 26924 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; | 26962 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; |
| 26925 | | 26963 | |
| 26926 | IrInstruction *target = instruction->target->child; | 26964 | IrInstruction *target = instruction->target->child; |
| 26927 | if (type_is_invalid(target->value.type)) | 26965 | if (type_is_invalid(target->value->type)) |
| 26928 | return ira->codegen->invalid_instruction; | 26966 | return ira->codegen->invalid_instruction; |
| 26929 | | 26967 | |
| 26930 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); | 26968 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); |
| 26931 | if (type_is_invalid(casted_target->value.type)) | 26969 | if (type_is_invalid(casted_target->value->type)) |
| 26932 | return ira->codegen->invalid_instruction; | 26970 | return ira->codegen->invalid_instruction; |
| 26933 | | 26971 | |
| 26934 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); | 26972 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); |
| ... | @@ -26995,33 +27033,33 @@ static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Ir | ... | @@ -26995,33 +27033,33 @@ static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Ir |
| 26995 | | 27033 | |
| 26996 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { | 27034 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { |
| 26997 | IrInstruction *value = instruction->value->child; | 27035 | IrInstruction *value = instruction->value->child; |
| 26998 | if (type_is_invalid(value->value.type)) | 27036 | if (type_is_invalid(value->value->type)) |
| 26999 | return ira->codegen->invalid_instruction; | 27037 | return ira->codegen->invalid_instruction; |
| 27000 | | 27038 | |
| 27001 | bool was_written = instruction->result_loc->written; | 27039 | bool was_written = instruction->result_loc->written; |
| 27002 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 27040 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 27003 | value->value.type, value, false, false, true); | 27041 | value->value->type, value, false, false, true); |
| 27004 | if (result_loc != nullptr) { | 27042 | if (result_loc != nullptr) { |
| 27005 | if (type_is_invalid(result_loc->value.type)) | 27043 | if (type_is_invalid(result_loc->value->type)) |
| 27006 | return ira->codegen->invalid_instruction; | 27044 | return ira->codegen->invalid_instruction; |
| 27007 | if (result_loc->value.type->id == ZigTypeIdUnreachable) | 27045 | if (result_loc->value->type->id == ZigTypeIdUnreachable) |
| 27008 | return result_loc; | 27046 | return result_loc; |
| 27009 | | 27047 | |
| 27010 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { | 27048 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { |
| 27011 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, | 27049 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, |
| 27012 | instruction->result_loc->allow_write_through_const); | 27050 | instruction->result_loc->allow_write_through_const); |
| 27013 | if (type_is_invalid(store_ptr->value.type)) { | 27051 | if (type_is_invalid(store_ptr->value->type)) { |
| 27014 | return ira->codegen->invalid_instruction; | 27052 | return ira->codegen->invalid_instruction; |
| 27015 | } | 27053 | } |
| 27016 | } | 27054 | } |
| 27017 | | 27055 | |
| 27018 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer && | 27056 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer && |
| 27019 | instruction->result_loc->id != ResultLocIdPeer) | 27057 | instruction->result_loc->id != ResultLocIdPeer) |
| 27020 | { | 27058 | { |
| 27021 | if (instr_is_comptime(value)) { | 27059 | if (instr_is_comptime(value)) { |
| 27022 | result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 27060 | result_loc->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 27023 | } else { | 27061 | } else { |
| 27024 | result_loc->value.special = ConstValSpecialRuntime; | 27062 | result_loc->value->special = ConstValSpecialRuntime; |
| 27025 | } | 27063 | } |
| 27026 | } | 27064 | } |
| 27027 | } | 27065 | } |
| ... | @@ -27031,12 +27069,12 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct | ... | @@ -27031,12 +27069,12 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct |
| 27031 | | 27069 | |
| 27032 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { | 27070 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { |
| 27033 | IrInstruction *operand = instruction->operand->child; | 27071 | IrInstruction *operand = instruction->operand->child; |
| 27034 | if (type_is_invalid(operand->value.type)) | 27072 | if (type_is_invalid(operand->value->type)) |
| 27035 | return operand; | 27073 | return operand; |
| 27036 | | 27074 | |
| 27037 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 27075 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, |
| 27038 | &instruction->result_loc_cast->base, operand->value.type, operand, false, false, true); | 27076 | &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))) | 27077 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27040 | return result_loc; | 27078 | return result_loc; |
| 27041 | | 27079 | |
| 27042 | if (instruction->result_loc_cast->parent->gen_instruction != nullptr) { | 27080 | if (instruction->result_loc_cast->parent->gen_instruction != nullptr) { |
| ... | @@ -27051,12 +27089,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns | ... | @@ -27051,12 +27089,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns |
| 27051 | | 27089 | |
| 27052 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { | 27090 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { |
| 27053 | IrInstruction *operand = instruction->operand->child; | 27091 | IrInstruction *operand = instruction->operand->child; |
| 27054 | if (type_is_invalid(operand->value.type)) | 27092 | if (type_is_invalid(operand->value->type)) |
| 27055 | return operand; | 27093 | return operand; |
| 27056 | | 27094 | |
| 27057 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 27095 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, |
| 27058 | &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true); | 27096 | &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))) | 27097 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27060 | return result_loc; | 27098 | return result_loc; |
| 27061 | | 27099 | |
| 27062 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { | 27100 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { |
| ... | @@ -27084,11 +27122,11 @@ static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *i | ... | @@ -27084,11 +27122,11 @@ static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *i |
| 27084 | return ira->codegen->invalid_instruction; | 27122 | return ira->codegen->invalid_instruction; |
| 27085 | | 27123 | |
| 27086 | IrInstruction *field_result_loc = instruction->field_result_loc->child; | 27124 | IrInstruction *field_result_loc = instruction->field_result_loc->child; |
| 27087 | if (type_is_invalid(field_result_loc->value.type)) | 27125 | if (type_is_invalid(field_result_loc->value->type)) |
| 27088 | return ira->codegen->invalid_instruction; | 27126 | return ira->codegen->invalid_instruction; |
| 27089 | | 27127 | |
| 27090 | IrInstruction *result_loc = instruction->result_loc->child; | 27128 | IrInstruction *result_loc = instruction->result_loc->child; |
| 27091 | if (type_is_invalid(result_loc->value.type)) | 27129 | if (type_is_invalid(result_loc->value->type)) |
| 27092 | return ira->codegen->invalid_instruction; | 27130 | return ira->codegen->invalid_instruction; |
| 27093 | | 27131 | |
| 27094 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, | 27132 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, |
| ... | @@ -27105,7 +27143,7 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | ... | @@ -27105,7 +27143,7 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, |
| 27105 | IrInstructionSuspendFinish *instruction) | 27143 | IrInstructionSuspendFinish *instruction) |
| 27106 | { | 27144 | { |
| 27107 | IrInstruction *begin_base = instruction->begin->base.child; | 27145 | IrInstruction *begin_base = instruction->begin->base.child; |
| 27108 | if (type_is_invalid(begin_base->value.type)) | 27146 | if (type_is_invalid(begin_base->value->type)) |
| 27109 | return ira->codegen->invalid_instruction; | 27147 | return ira->codegen->invalid_instruction; |
| 27110 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); | 27148 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); |
| 27111 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); | 27149 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); |
| ... | @@ -27123,44 +27161,44 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | ... | @@ -27123,44 +27161,44 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, |
| 27123 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, | 27161 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, |
| 27124 | IrInstruction *frame_ptr, ZigFn **target_fn) | 27162 | IrInstruction *frame_ptr, ZigFn **target_fn) |
| 27125 | { | 27163 | { |
| 27126 | if (type_is_invalid(frame_ptr->value.type)) | 27164 | if (type_is_invalid(frame_ptr->value->type)) |
| 27127 | return ira->codegen->invalid_instruction; | 27165 | return ira->codegen->invalid_instruction; |
| 27128 | | 27166 | |
| 27129 | *target_fn = nullptr; | 27167 | *target_fn = nullptr; |
| 27130 | | 27168 | |
| 27131 | ZigType *result_type; | 27169 | ZigType *result_type; |
| 27132 | IrInstruction *frame; | 27170 | IrInstruction *frame; |
| 27133 | if (frame_ptr->value.type->id == ZigTypeIdPointer && | 27171 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 27134 | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && | 27172 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27135 | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27173 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27136 | { | 27174 | { |
| 27137 | ZigFn *func = frame_ptr->value.type->data.pointer.child_type->data.frame.fn; | 27175 | ZigFn *func = frame_ptr->value->type->data.pointer.child_type->data.frame.fn; |
| 27138 | result_type = func->type_entry->data.fn.fn_type_id.return_type; | 27176 | result_type = func->type_entry->data.fn.fn_type_id.return_type; |
| 27139 | *target_fn = func; | 27177 | *target_fn = func; |
| 27140 | frame = frame_ptr; | 27178 | frame = frame_ptr; |
| 27141 | } else { | 27179 | } else { |
| 27142 | frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr); | 27180 | frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr); |
| 27143 | if (frame->value.type->id == ZigTypeIdPointer && | 27181 | if (frame->value->type->id == ZigTypeIdPointer && |
| 27144 | frame->value.type->data.pointer.ptr_len == PtrLenSingle && | 27182 | frame->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27145 | frame->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27183 | frame->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27146 | { | 27184 | { |
| 27147 | ZigFn *func = frame->value.type->data.pointer.child_type->data.frame.fn; | 27185 | ZigFn *func = frame->value->type->data.pointer.child_type->data.frame.fn; |
| 27148 | result_type = func->type_entry->data.fn.fn_type_id.return_type; | 27186 | result_type = func->type_entry->data.fn.fn_type_id.return_type; |
| 27149 | *target_fn = func; | 27187 | *target_fn = func; |
| 27150 | } else if (frame->value.type->id != ZigTypeIdAnyFrame || | 27188 | } else if (frame->value->type->id != ZigTypeIdAnyFrame || |
| 27151 | frame->value.type->data.any_frame.result_type == nullptr) | 27189 | frame->value->type->data.any_frame.result_type == nullptr) |
| 27152 | { | 27190 | { |
| 27153 | ir_add_error(ira, source_instr, | 27191 | ir_add_error(ira, source_instr, |
| 27154 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value.type->name))); | 27192 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); |
| 27155 | return ira->codegen->invalid_instruction; | 27193 | return ira->codegen->invalid_instruction; |
| 27156 | } else { | 27194 | } else { |
| 27157 | result_type = frame->value.type->data.any_frame.result_type; | 27195 | result_type = frame->value->type->data.any_frame.result_type; |
| 27158 | } | 27196 | } |
| 27159 | } | 27197 | } |
| 27160 | | 27198 | |
| 27161 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); | 27199 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 27162 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 27200 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27163 | if (type_is_invalid(casted_frame->value.type)) | 27201 | if (type_is_invalid(casted_frame->value->type)) |
| 27164 | return ira->codegen->invalid_instruction; | 27202 | return ira->codegen->invalid_instruction; |
| 27165 | | 27203 | |
| 27166 | return casted_frame; | 27204 | return casted_frame; |
| ... | @@ -27168,14 +27206,14 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct | ... | @@ -27168,14 +27206,14 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct |
| 27168 | | 27206 | |
| 27169 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { | 27207 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { |
| 27170 | IrInstruction *operand = instruction->frame->child; | 27208 | IrInstruction *operand = instruction->frame->child; |
| 27171 | if (type_is_invalid(operand->value.type)) | 27209 | if (type_is_invalid(operand->value->type)) |
| 27172 | return ira->codegen->invalid_instruction; | 27210 | return ira->codegen->invalid_instruction; |
| 27173 | ZigFn *target_fn; | 27211 | ZigFn *target_fn; |
| 27174 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); | 27212 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); |
| 27175 | if (type_is_invalid(frame->value.type)) | 27213 | if (type_is_invalid(frame->value->type)) |
| 27176 | return ira->codegen->invalid_instruction; | 27214 | return ira->codegen->invalid_instruction; |
| 27177 | | 27215 | |
| 27178 | ZigType *result_type = frame->value.type->data.any_frame.result_type; | 27216 | ZigType *result_type = frame->value->type->data.any_frame.result_type; |
| 27179 | | 27217 | |
| 27180 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 27218 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 27181 | ir_assert(fn_entry != nullptr, &instruction->base); | 27219 | ir_assert(fn_entry != nullptr, &instruction->base); |
| ... | @@ -27195,7 +27233,7 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -27195,7 +27233,7 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 27195 | if (type_has_bits(result_type)) { | 27233 | if (type_has_bits(result_type)) { |
| 27196 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 27234 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 27197 | result_type, nullptr, true, true, true); | 27235 | result_type, nullptr, true, true, true); |
| 27198 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 27236 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27199 | return result_loc; | 27237 | return result_loc; |
| 27200 | } else { | 27238 | } else { |
| 27201 | result_loc = nullptr; | 27239 | result_loc = nullptr; |
| ... | @@ -27209,13 +27247,13 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -27209,13 +27247,13 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 27209 | | 27247 | |
| 27210 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { | 27248 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { |
| 27211 | IrInstruction *frame_ptr = instruction->frame->child; | 27249 | IrInstruction *frame_ptr = instruction->frame->child; |
| 27212 | if (type_is_invalid(frame_ptr->value.type)) | 27250 | if (type_is_invalid(frame_ptr->value->type)) |
| 27213 | return ira->codegen->invalid_instruction; | 27251 | return ira->codegen->invalid_instruction; |
| 27214 | | 27252 | |
| 27215 | IrInstruction *frame; | 27253 | IrInstruction *frame; |
| 27216 | if (frame_ptr->value.type->id == ZigTypeIdPointer && | 27254 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 27217 | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && | 27255 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27218 | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27256 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27219 | { | 27257 | { |
| 27220 | frame = frame_ptr; | 27258 | frame = frame_ptr; |
| 27221 | } else { | 27259 | } else { |
| ... | @@ -27224,7 +27262,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio | ... | @@ -27224,7 +27262,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio |
| 27224 | | 27262 | |
| 27225 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); | 27263 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 27226 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 27264 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27227 | if (type_is_invalid(casted_frame->value.type)) | 27265 | if (type_is_invalid(casted_frame->value->type)) |
| 27228 | return ira->codegen->invalid_instruction; | 27266 | return ira->codegen->invalid_instruction; |
| 27229 | | 27267 | |
| 27230 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); | 27268 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); |
| ... | @@ -27235,10 +27273,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr | ... | @@ -27235,10 +27273,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr |
| 27235 | return ir_const_void(ira, &instruction->base); | 27273 | return ir_const_void(ira, &instruction->base); |
| 27236 | | 27274 | |
| 27237 | IrInstruction *operand = instruction->operand->child; | 27275 | IrInstruction *operand = instruction->operand->child; |
| 27238 | if (type_is_invalid(operand->value.type)) | 27276 | if (type_is_invalid(operand->value->type)) |
| 27239 | return ira->codegen->invalid_instruction; | 27277 | return ira->codegen->invalid_instruction; |
| 27240 | | 27278 | |
| 27241 | if (!type_has_bits(operand->value.type)) | 27279 | if (!type_has_bits(operand->value->type)) |
| 27242 | return ir_const_void(ira, &instruction->base); | 27280 | return ir_const_void(ira, &instruction->base); |
| 27243 | | 27281 | |
| 27244 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); | 27282 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); |
| ... | @@ -27251,10 +27289,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr | ... | @@ -27251,10 +27289,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr |
| 27251 | | 27289 | |
| 27252 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { | 27290 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { |
| 27253 | IrInstruction *operand = instruction->begin->operand->child; | 27291 | IrInstruction *operand = instruction->begin->operand->child; |
| 27254 | if (type_is_invalid(operand->value.type)) | 27292 | if (type_is_invalid(operand->value->type)) |
| 27255 | return ira->codegen->invalid_instruction; | 27293 | return ira->codegen->invalid_instruction; |
| 27256 | | 27294 | |
| 27257 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value.type)) | 27295 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value->type)) |
| 27258 | return operand; | 27296 | return operand; |
| 27259 | | 27297 | |
| 27260 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); | 27298 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); |
| ... | @@ -27262,7 +27300,7 @@ static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstruc | ... | @@ -27262,7 +27300,7 @@ static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstruc |
| 27262 | | 27300 | |
| 27263 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, | 27301 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, |
| 27264 | instruction->base.source_node, begin); | 27302 | instruction->base.source_node, begin); |
| 27265 | result->value.type = operand->value.type; | 27303 | result->value->type = operand->value->type; |
| 27266 | return result; | 27304 | return result; |
| 27267 | } | 27305 | } |
| 27268 | | 27306 | |
| ... | @@ -27601,7 +27639,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27601,7 +27639,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27601 | ira->new_irb.codegen = codegen; | 27639 | ira->new_irb.codegen = codegen; |
| 27602 | ira->new_irb.exec = new_exec; | 27640 | ira->new_irb.exec = new_exec; |
| 27603 | | 27641 | |
| 27604 | ConstExprValue *vals = create_const_vals(ira->old_irb.exec->mem_slot_count); | 27642 | ZigValue *vals = create_const_vals(ira->old_irb.exec->mem_slot_count); |
| 27605 | ira->exec_context.mem_slot_list.resize(ira->old_irb.exec->mem_slot_count); | 27643 | ira->exec_context.mem_slot_list.resize(ira->old_irb.exec->mem_slot_count); |
| 27606 | for (size_t i = 0; i < ira->exec_context.mem_slot_list.length; i += 1) { | 27644 | for (size_t i = 0; i < ira->exec_context.mem_slot_list.length; i += 1) { |
| 27607 | ira->exec_context.mem_slot_list.items[i] = &vals[i]; | 27645 | ira->exec_context.mem_slot_list.items[i] = &vals[i]; |
| ... | @@ -27628,10 +27666,10 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27628,10 +27666,10 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27628 | } | 27666 | } |
| 27629 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | 27667 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); |
| 27630 | if (new_instruction != nullptr) { | 27668 | if (new_instruction != nullptr) { |
| 27631 | ir_assert(new_instruction->value.type != nullptr || new_instruction->value.type != nullptr, old_instruction); | 27669 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction); |
| 27632 | old_instruction->child = new_instruction; | 27670 | old_instruction->child = new_instruction; |
| 27633 | | 27671 | |
| 27634 | if (type_is_invalid(new_instruction->value.type)) { | 27672 | if (type_is_invalid(new_instruction->value->type)) { |
| 27635 | if (new_exec->first_err_trace_msg != nullptr) { | 27673 | if (new_exec->first_err_trace_msg != nullptr) { |
| 27636 | ira->codegen->trace_err = new_exec->first_err_trace_msg; | 27674 | ira->codegen->trace_err = new_exec->first_err_trace_msg; |
| 27637 | } else { | 27675 | } else { |
| ... | @@ -27648,7 +27686,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27648,7 +27686,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27648 | } | 27686 | } |
| 27649 | | 27687 | |
| 27650 | // unreachable instructions do their own control flow. | 27688 | // unreachable instructions do their own control flow. |
| 27651 | if (new_instruction->value.type->id == ZigTypeIdUnreachable) | 27689 | if (new_instruction->value->type->id == ZigTypeIdUnreachable) |
| 27652 | continue; | 27690 | continue; |
| 27653 | } | 27691 | } |
| 27654 | | 27692 | |
| ... | @@ -27947,7 +27985,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -27947,7 +27985,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 27947 | return get_fn_type(ira->codegen, &fn_type_id); | 27985 | return get_fn_type(ira->codegen, &fn_type_id); |
| 27948 | } | 27986 | } |
| 27949 | | 27987 | |
| 27950 | static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | 27988 | static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 27951 | Error err; | 27989 | Error err; |
| 27952 | if (val->special != ConstValSpecialLazy) | 27990 | if (val->special != ConstValSpecialLazy) |
| 27953 | return ErrorNone; | 27991 | return ErrorNone; |
| ... | @@ -27958,8 +27996,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -27958,8 +27996,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 27958 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); | 27996 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); |
| 27959 | IrAnalyze *ira = lazy_align_of->ira; | 27997 | IrAnalyze *ira = lazy_align_of->ira; |
| 27960 | | 27998 | |
| 27961 | if (lazy_align_of->target_type->value.special == ConstValSpecialStatic) { | 27999 | if (lazy_align_of->target_type->value->special == ConstValSpecialStatic) { |
| 27962 | switch (lazy_align_of->target_type->value.data.x_type->id) { | 28000 | switch (lazy_align_of->target_type->value->data.x_type->id) { |
| 27963 | case ZigTypeIdInvalid: | 28001 | case ZigTypeIdInvalid: |
| 27964 | zig_unreachable(); | 28002 | zig_unreachable(); |
| 27965 | case ZigTypeIdMetaType: | 28003 | case ZigTypeIdMetaType: |
| ... | @@ -27975,7 +28013,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -27975,7 +28013,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 27975 | case ZigTypeIdOpaque: | 28013 | case ZigTypeIdOpaque: |
| 27976 | ir_add_error(ira, lazy_align_of->target_type, | 28014 | ir_add_error(ira, lazy_align_of->target_type, |
| 27977 | buf_sprintf("no align available for type '%s'", | 28015 | buf_sprintf("no align available for type '%s'", |
| 27978 | buf_ptr(&lazy_align_of->target_type->value.data.x_type->name))); | 28016 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); |
| 27979 | return ErrorSemanticAnalyzeFail; | 28017 | return ErrorSemanticAnalyzeFail; |
| 27980 | case ZigTypeIdBool: | 28018 | case ZigTypeIdBool: |
| 27981 | case ZigTypeIdInt: | 28019 | case ZigTypeIdInt: |
| ... | @@ -27997,7 +28035,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -27997,7 +28035,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 27997 | } | 28035 | } |
| 27998 | | 28036 | |
| 27999 | uint32_t align_in_bytes; | 28037 | uint32_t align_in_bytes; |
| 28000 | if ((err = type_val_resolve_abi_align(ira->codegen, &lazy_align_of->target_type->value, | 28038 | if ((err = type_val_resolve_abi_align(ira->codegen, lazy_align_of->target_type->value, |
| 28001 | &align_in_bytes))) | 28039 | &align_in_bytes))) |
| 28002 | { | 28040 | { |
| 28003 | return err; | 28041 | return err; |
| ... | @@ -28012,8 +28050,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28012,8 +28050,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28012 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); | 28050 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); |
| 28013 | IrAnalyze *ira = lazy_size_of->ira; | 28051 | IrAnalyze *ira = lazy_size_of->ira; |
| 28014 | | 28052 | |
| 28015 | if (lazy_size_of->target_type->value.special == ConstValSpecialStatic) { | 28053 | if (lazy_size_of->target_type->value->special == ConstValSpecialStatic) { |
| 28016 | switch (lazy_size_of->target_type->value.data.x_type->id) { | 28054 | switch (lazy_size_of->target_type->value->data.x_type->id) { |
| 28017 | case ZigTypeIdInvalid: // handled above | 28055 | case ZigTypeIdInvalid: // handled above |
| 28018 | zig_unreachable(); | 28056 | zig_unreachable(); |
| 28019 | case ZigTypeIdUnreachable: | 28057 | case ZigTypeIdUnreachable: |
| ... | @@ -28024,7 +28062,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28024,7 +28062,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28024 | case ZigTypeIdOpaque: | 28062 | case ZigTypeIdOpaque: |
| 28025 | ir_add_error(ira, lazy_size_of->target_type, | 28063 | ir_add_error(ira, lazy_size_of->target_type, |
| 28026 | buf_sprintf("no size available for type '%s'", | 28064 | buf_sprintf("no size available for type '%s'", |
| 28027 | buf_ptr(&lazy_size_of->target_type->value.data.x_type->name))); | 28065 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); |
| 28028 | return ErrorSemanticAnalyzeFail; | 28066 | return ErrorSemanticAnalyzeFail; |
| 28029 | case ZigTypeIdMetaType: | 28067 | case ZigTypeIdMetaType: |
| 28030 | case ZigTypeIdEnumLiteral: | 28068 | case ZigTypeIdEnumLiteral: |
| ... | @@ -28052,7 +28090,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28052,7 +28090,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28052 | | 28090 | |
| 28053 | size_t abi_size; | 28091 | size_t abi_size; |
| 28054 | size_t size_in_bits; | 28092 | size_t size_in_bits; |
| 28055 | if ((err = type_val_resolve_abi_size(ira->codegen, source_node, &lazy_size_of->target_type->value, | 28093 | if ((err = type_val_resolve_abi_size(ira->codegen, source_node, lazy_size_of->target_type->value, |
| 28056 | &abi_size, &size_in_bits))) | 28094 | &abi_size, &size_in_bits))) |
| 28057 | { | 28095 | { |
| 28058 | return err; | 28096 | return err; |
| ... | @@ -28071,12 +28109,12 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28071,12 +28109,12 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28071 | if (type_is_invalid(elem_type)) | 28109 | if (type_is_invalid(elem_type)) |
| 28072 | return ErrorSemanticAnalyzeFail; | 28110 | return ErrorSemanticAnalyzeFail; |
| 28073 | | 28111 | |
| 28074 | ConstExprValue *sentinel_val; | 28112 | ZigValue *sentinel_val; |
| 28075 | if (lazy_slice_type->sentinel != nullptr) { | 28113 | if (lazy_slice_type->sentinel != nullptr) { |
| 28076 | if (type_is_invalid(lazy_slice_type->sentinel->value.type)) | 28114 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) |
| 28077 | return ErrorSemanticAnalyzeFail; | 28115 | return ErrorSemanticAnalyzeFail; |
| 28078 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | 28116 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); |
| 28079 | if (type_is_invalid(sentinel->value.type)) | 28117 | if (type_is_invalid(sentinel->value->type)) |
| 28080 | return ErrorSemanticAnalyzeFail; | 28118 | return ErrorSemanticAnalyzeFail; |
| 28081 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 28119 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 28082 | if (sentinel_val == nullptr) | 28120 | if (sentinel_val == nullptr) |
| ... | @@ -28149,12 +28187,12 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28149,12 +28187,12 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28149 | if (type_is_invalid(elem_type)) | 28187 | if (type_is_invalid(elem_type)) |
| 28150 | return ErrorSemanticAnalyzeFail; | 28188 | return ErrorSemanticAnalyzeFail; |
| 28151 | | 28189 | |
| 28152 | ConstExprValue *sentinel_val; | 28190 | ZigValue *sentinel_val; |
| 28153 | if (lazy_ptr_type->sentinel != nullptr) { | 28191 | if (lazy_ptr_type->sentinel != nullptr) { |
| 28154 | if (type_is_invalid(lazy_ptr_type->sentinel->value.type)) | 28192 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) |
| 28155 | return ErrorSemanticAnalyzeFail; | 28193 | return ErrorSemanticAnalyzeFail; |
| 28156 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | 28194 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); |
| 28157 | if (type_is_invalid(sentinel->value.type)) | 28195 | if (type_is_invalid(sentinel->value->type)) |
| 28158 | return ErrorSemanticAnalyzeFail; | 28196 | return ErrorSemanticAnalyzeFail; |
| 28159 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 28197 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 28160 | if (sentinel_val == nullptr) | 28198 | if (sentinel_val == nullptr) |
| ... | @@ -28276,7 +28314,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28276,7 +28314,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28276 | zig_unreachable(); | 28314 | zig_unreachable(); |
| 28277 | } | 28315 | } |
| 28278 | | 28316 | |
| 28279 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) { | 28317 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 28280 | Error err; | 28318 | Error err; |
| 28281 | if ((err = ir_resolve_lazy_raw(source_node, val))) { | 28319 | if ((err = ir_resolve_lazy_raw(source_node, val))) { |
| 28282 | if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) { | 28320 | if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) { |