| ... | @@ -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,7 +416,7 @@ static Buf *exec_c_import_buf(IrExecutable *exec) { | ... | @@ -416,7 +416,7 @@ 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 | |
| ... | @@ -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 | |
| ... | @@ -8698,26 +8698,26 @@ static void ir_assert(bool ok, IrInstruction *source_instruction) { | ... | @@ -8698,26 +8698,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 | 8698 | // This function takes a comptime ptr and makes the child const value conform to the type |
| 8699 | // described by the pointer. | 8699 | // described by the pointer. |
| 8700 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 8700 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 8701 | ConstExprValue *ptr_val) | 8701 | ZigValue *ptr_val) |
| 8702 | { | 8702 | { |
| 8703 | Error err; | 8703 | Error err; |
| 8704 | assert(ptr_val->type->id == ZigTypeIdPointer); | 8704 | assert(ptr_val->type->id == ZigTypeIdPointer); |
| 8705 | assert(ptr_val->special == ConstValSpecialStatic); | 8705 | assert(ptr_val->special == ConstValSpecialStatic); |
| 8706 | ConstExprValue tmp = {}; | 8706 | ZigValue tmp = {}; |
| 8707 | tmp.special = ConstValSpecialStatic; | 8707 | tmp.special = ConstValSpecialStatic; |
| 8708 | tmp.type = ptr_val->type->data.pointer.child_type; | 8708 | tmp.type = ptr_val->type->data.pointer.child_type; |
| 8709 | if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val))) | 8709 | if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val))) |
| 8710 | return err; | 8710 | return err; |
| 8711 | ConstExprValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val); | 8711 | ZigValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val); |
| 8712 | copy_const_val(child_val, &tmp, false); | 8712 | copy_const_val(child_val, &tmp, false); |
| 8713 | return ErrorNone; | 8713 | return ErrorNone; |
| 8714 | } | 8714 | } |
| 8715 | | 8715 | |
| 8716 | ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprValue *const_val, | 8716 | ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_val, |
| 8717 | AstNode *source_node) | 8717 | AstNode *source_node) |
| 8718 | { | 8718 | { |
| 8719 | Error err; | 8719 | Error err; |
| 8720 | ConstExprValue *val = const_ptr_pointee_unchecked(codegen, const_val); | 8720 | ZigValue *val = const_ptr_pointee_unchecked(codegen, const_val); |
| 8721 | assert(val != nullptr); | 8721 | assert(val != nullptr); |
| 8722 | assert(const_val->type->id == ZigTypeIdPointer); | 8722 | assert(const_val->type->id == ZigTypeIdPointer); |
| 8723 | ZigType *expected_type = const_val->type->data.pointer.child_type; | 8723 | ZigType *expected_type = const_val->type->data.pointer.child_type; |
| ... | @@ -8740,7 +8740,7 @@ ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprVal | ... | @@ -8740,7 +8740,7 @@ ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprVal |
| 8740 | return val; | 8740 | return val; |
| 8741 | } | 8741 | } |
| 8742 | | 8742 | |
| 8743 | static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { | 8743 | static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { |
| 8744 | IrBasicBlock *bb = exec->basic_block_list.at(0); | 8744 | IrBasicBlock *bb = exec->basic_block_list.at(0); |
| 8745 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { | 8745 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 8746 | IrInstruction *instruction = bb->instruction_list.at(i); | 8746 | IrInstruction *instruction = bb->instruction_list.at(i); |
| ... | @@ -8783,14 +8783,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so | ... | @@ -8783,14 +8783,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so |
| 8783 | return true; | 8783 | return true; |
| 8784 | } | 8784 | } |
| 8785 | | 8785 | |
| 8786 | static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) { | 8786 | static bool const_val_fits_in_num_lit(ZigValue *const_val, ZigType *num_lit_type) { |
| 8787 | return ((num_lit_type->id == ZigTypeIdComptimeFloat && | 8787 | return ((num_lit_type->id == ZigTypeIdComptimeFloat && |
| 8788 | (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) || | 8788 | (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) || |
| 8789 | (num_lit_type->id == ZigTypeIdComptimeInt && | 8789 | (num_lit_type->id == ZigTypeIdComptimeInt && |
| 8790 | (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt))); | 8790 | (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt))); |
| 8791 | } | 8791 | } |
| 8792 | | 8792 | |
| 8793 | static bool float_has_fraction(ConstExprValue *const_val) { | 8793 | static bool float_has_fraction(ZigValue *const_val) { |
| 8794 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8794 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8795 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); | 8795 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); |
| 8796 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8796 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8818,7 +8818,7 @@ static bool float_has_fraction(ConstExprValue *const_val) { | ... | @@ -8818,7 +8818,7 @@ static bool float_has_fraction(ConstExprValue *const_val) { |
| 8818 | } | 8818 | } |
| 8819 | } | 8819 | } |
| 8820 | | 8820 | |
| 8821 | static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | 8821 | static void float_append_buf(Buf *buf, ZigValue *const_val) { |
| 8822 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8822 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8823 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); | 8823 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); |
| 8824 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8824 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8856,7 +8856,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | ... | @@ -8856,7 +8856,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 8856 | } | 8856 | } |
| 8857 | } | 8857 | } |
| 8858 | | 8858 | |
| 8859 | static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | 8859 | static void float_init_bigint(BigInt *bigint, ZigValue *const_val) { |
| 8860 | if (const_val->type->id == ZigTypeIdComptimeFloat) { | 8860 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 8861 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); | 8861 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); |
| 8862 | } else if (const_val->type->id == ZigTypeIdFloat) { | 8862 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8903,7 +8903,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | ... | @@ -8903,7 +8903,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 8903 | } | 8903 | } |
| 8904 | } | 8904 | } |
| 8905 | | 8905 | |
| 8906 | static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | 8906 | static void float_init_bigfloat(ZigValue *dest_val, BigFloat *bigfloat) { |
| 8907 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8907 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8908 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); | 8908 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); |
| 8909 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8909 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8930,7 +8930,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | ... | @@ -8930,7 +8930,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 8930 | } | 8930 | } |
| 8931 | } | 8931 | } |
| 8932 | | 8932 | |
| 8933 | static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | 8933 | static void float_init_f16(ZigValue *dest_val, float16_t x) { |
| 8934 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8934 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8935 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); | 8935 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); |
| 8936 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8936 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8955,7 +8955,7 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | ... | @@ -8955,7 +8955,7 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { |
| 8955 | } | 8955 | } |
| 8956 | } | 8956 | } |
| 8957 | | 8957 | |
| 8958 | static void float_init_f32(ConstExprValue *dest_val, float x) { | 8958 | static void float_init_f32(ZigValue *dest_val, float x) { |
| 8959 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8959 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8960 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); | 8960 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); |
| 8961 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8961 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -8984,7 +8984,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { | ... | @@ -8984,7 +8984,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 8984 | } | 8984 | } |
| 8985 | } | 8985 | } |
| 8986 | | 8986 | |
| 8987 | static void float_init_f64(ConstExprValue *dest_val, double x) { | 8987 | static void float_init_f64(ZigValue *dest_val, double x) { |
| 8988 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 8988 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 8989 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); | 8989 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); |
| 8990 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 8990 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9013,7 +9013,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { | ... | @@ -9013,7 +9013,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 9013 | } | 9013 | } |
| 9014 | } | 9014 | } |
| 9015 | | 9015 | |
| 9016 | static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | 9016 | static void float_init_f128(ZigValue *dest_val, float128_t x) { |
| 9017 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { | 9017 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 9018 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); | 9018 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); |
| 9019 | } else if (dest_val->type->id == ZigTypeIdFloat) { | 9019 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9046,7 +9046,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | ... | @@ -9046,7 +9046,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 9046 | } | 9046 | } |
| 9047 | } | 9047 | } |
| 9048 | | 9048 | |
| 9049 | static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) { | 9049 | static void float_init_float(ZigValue *dest_val, ZigValue *src_val) { |
| 9050 | if (src_val->type->id == ZigTypeIdComptimeFloat) { | 9050 | if (src_val->type->id == ZigTypeIdComptimeFloat) { |
| 9051 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); | 9051 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); |
| 9052 | } else if (src_val->type->id == ZigTypeIdFloat) { | 9052 | } else if (src_val->type->id == ZigTypeIdFloat) { |
| ... | @@ -9071,7 +9071,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) | ... | @@ -9071,7 +9071,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) |
| 9071 | } | 9071 | } |
| 9072 | } | 9072 | } |
| 9073 | | 9073 | |
| 9074 | static bool float_is_nan(ConstExprValue *op) { | 9074 | static bool float_is_nan(ZigValue *op) { |
| 9075 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9075 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9076 | return bigfloat_is_nan(&op->data.x_bigfloat); | 9076 | return bigfloat_is_nan(&op->data.x_bigfloat); |
| 9077 | } else if (op->type->id == ZigTypeIdFloat) { | 9077 | } else if (op->type->id == ZigTypeIdFloat) { |
| ... | @@ -9092,7 +9092,7 @@ static bool float_is_nan(ConstExprValue *op) { | ... | @@ -9092,7 +9092,7 @@ static bool float_is_nan(ConstExprValue *op) { |
| 9092 | } | 9092 | } |
| 9093 | } | 9093 | } |
| 9094 | | 9094 | |
| 9095 | static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | 9095 | static Cmp float_cmp(ZigValue *op1, ZigValue *op2) { |
| 9096 | assert(op1->type == op2->type); | 9096 | assert(op1->type == op2->type); |
| 9097 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9097 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 9098 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); | 9098 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| ... | @@ -9138,7 +9138,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | ... | @@ -9138,7 +9138,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 9138 | } | 9138 | } |
| 9139 | } | 9139 | } |
| 9140 | | 9140 | |
| 9141 | static Cmp float_cmp_zero(ConstExprValue *op) { | 9141 | static Cmp float_cmp_zero(ZigValue *op) { |
| 9142 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9142 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9143 | return bigfloat_cmp_zero(&op->data.x_bigfloat); | 9143 | return bigfloat_cmp_zero(&op->data.x_bigfloat); |
| 9144 | } else if (op->type->id == ZigTypeIdFloat) { | 9144 | } else if (op->type->id == ZigTypeIdFloat) { |
| ... | @@ -9188,7 +9188,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) { | ... | @@ -9188,7 +9188,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) { |
| 9188 | } | 9188 | } |
| 9189 | } | 9189 | } |
| 9190 | | 9190 | |
| 9191 | static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9191 | static void float_add(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9192 | assert(op1->type == op2->type); | 9192 | assert(op1->type == op2->type); |
| 9193 | out_val->type = op1->type; | 9193 | out_val->type = op1->type; |
| 9194 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9194 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9215,7 +9215,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9215,7 +9215,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9215 | } | 9215 | } |
| 9216 | } | 9216 | } |
| 9217 | | 9217 | |
| 9218 | static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9218 | static void float_sub(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9219 | assert(op1->type == op2->type); | 9219 | assert(op1->type == op2->type); |
| 9220 | out_val->type = op1->type; | 9220 | out_val->type = op1->type; |
| 9221 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9221 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9242,7 +9242,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9242,7 +9242,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9242 | } | 9242 | } |
| 9243 | } | 9243 | } |
| 9244 | | 9244 | |
| 9245 | static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9245 | static void float_mul(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9246 | assert(op1->type == op2->type); | 9246 | assert(op1->type == op2->type); |
| 9247 | out_val->type = op1->type; | 9247 | out_val->type = op1->type; |
| 9248 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9248 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9269,7 +9269,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9269,7 +9269,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9269 | } | 9269 | } |
| 9270 | } | 9270 | } |
| 9271 | | 9271 | |
| 9272 | static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9272 | static void float_div(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9273 | assert(op1->type == op2->type); | 9273 | assert(op1->type == op2->type); |
| 9274 | out_val->type = op1->type; | 9274 | out_val->type = op1->type; |
| 9275 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9275 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9296,7 +9296,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9296,7 +9296,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9296 | } | 9296 | } |
| 9297 | } | 9297 | } |
| 9298 | | 9298 | |
| 9299 | static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9299 | static void float_div_trunc(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9300 | assert(op1->type == op2->type); | 9300 | assert(op1->type == op2->type); |
| 9301 | out_val->type = op1->type; | 9301 | out_val->type = op1->type; |
| 9302 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9302 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9325,7 +9325,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -9325,7 +9325,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 9325 | } | 9325 | } |
| 9326 | } | 9326 | } |
| 9327 | | 9327 | |
| 9328 | static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9328 | static void float_div_floor(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9329 | assert(op1->type == op2->type); | 9329 | assert(op1->type == op2->type); |
| 9330 | out_val->type = op1->type; | 9330 | out_val->type = op1->type; |
| 9331 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9331 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9354,7 +9354,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -9354,7 +9354,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 9354 | } | 9354 | } |
| 9355 | } | 9355 | } |
| 9356 | | 9356 | |
| 9357 | static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9357 | static void float_rem(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9358 | assert(op1->type == op2->type); | 9358 | assert(op1->type == op2->type); |
| 9359 | out_val->type = op1->type; | 9359 | out_val->type = op1->type; |
| 9360 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9360 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9399,7 +9399,7 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* | ... | @@ -9399,7 +9399,7 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* |
| 9399 | f128M_sub(a, c, c); | 9399 | f128M_sub(a, c, c); |
| 9400 | } | 9400 | } |
| 9401 | | 9401 | |
| 9402 | static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 9402 | static void float_mod(ZigValue *out_val, ZigValue *op1, ZigValue *op2) { |
| 9403 | assert(op1->type == op2->type); | 9403 | assert(op1->type == op2->type); |
| 9404 | out_val->type = op1->type; | 9404 | out_val->type = op1->type; |
| 9405 | if (op1->type->id == ZigTypeIdComptimeFloat) { | 9405 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| ... | @@ -9426,7 +9426,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -9426,7 +9426,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 9426 | } | 9426 | } |
| 9427 | } | 9427 | } |
| 9428 | | 9428 | |
| 9429 | static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | 9429 | static void float_negate(ZigValue *out_val, ZigValue *op) { |
| 9430 | out_val->type = op->type; | 9430 | out_val->type = op->type; |
| 9431 | if (op->type->id == ZigTypeIdComptimeFloat) { | 9431 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 9432 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); | 9432 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); |
| ... | @@ -9457,7 +9457,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | ... | @@ -9457,7 +9457,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { |
| 9457 | } | 9457 | } |
| 9458 | } | 9458 | } |
| 9459 | | 9459 | |
| 9460 | void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | 9460 | void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) { |
| 9461 | if (op->type->id == ZigTypeIdFloat) { | 9461 | if (op->type->id == ZigTypeIdFloat) { |
| 9462 | switch (op->type->data.floating.bit_count) { | 9462 | switch (op->type->data.floating.bit_count) { |
| 9463 | case 16: | 9463 | case 16: |
| ... | @@ -9480,7 +9480,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | ... | @@ -9480,7 +9480,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { |
| 9480 | } | 9480 | } |
| 9481 | } | 9481 | } |
| 9482 | | 9482 | |
| 9483 | void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) { | 9483 | void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { |
| 9484 | if (val->type->id == ZigTypeIdFloat) { | 9484 | if (val->type->id == ZigTypeIdFloat) { |
| 9485 | switch (val->type->data.floating.bit_count) { | 9485 | switch (val->type->data.floating.bit_count) { |
| 9486 | case 16: | 9486 | case 16: |
| ... | @@ -9510,7 +9510,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -9510,7 +9510,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 9510 | return false; | 9510 | return false; |
| 9511 | } | 9511 | } |
| 9512 | | 9512 | |
| 9513 | ConstExprValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef); | 9513 | ZigValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef); |
| 9514 | if (const_val == nullptr) | 9514 | if (const_val == nullptr) |
| 9515 | return false; | 9515 | return false; |
| 9516 | | 9516 | |
| ... | @@ -10984,9 +10984,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10984,9 +10984,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10984 | } | 10984 | } |
| 10985 | } | 10985 | } |
| 10986 | | 10986 | |
| 10987 | static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs) { | 10987 | static void copy_const_val(ZigValue *dest, ZigValue *src, bool same_global_refs) { |
| 10988 | ConstGlobalRefs *global_refs = dest->global_refs; | 10988 | ConstGlobalRefs *global_refs = dest->global_refs; |
| 10989 | memcpy(dest, src, sizeof(ConstExprValue)); | 10989 | memcpy(dest, src, sizeof(ZigValue)); |
| 10990 | if (!same_global_refs) { | 10990 | if (!same_global_refs) { |
| 10991 | dest->global_refs = global_refs; | 10991 | dest->global_refs = global_refs; |
| 10992 | if (src->special != ConstValSpecialStatic) | 10992 | if (src->special != ConstValSpecialStatic) |
| ... | @@ -11002,8 +11002,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ | ... | @@ -11002,8 +11002,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ |
| 11002 | | 11002 | |
| 11003 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, | 11003 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, |
| 11004 | CastOp cast_op, | 11004 | CastOp cast_op, |
| 11005 | ConstExprValue *other_val, ZigType *other_type, | 11005 | ZigValue *other_val, ZigType *other_type, |
| 11006 | ConstExprValue *const_val, ZigType *new_type) | 11006 | ZigValue *const_val, ZigType *new_type) |
| 11007 | { | 11007 | { |
| 11008 | const_val->special = other_val->special; | 11008 | const_val->special = other_val->special; |
| 11009 | | 11009 | |
| ... | @@ -11145,7 +11145,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | ... | @@ -11145,7 +11145,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 11145 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type)); | 11145 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type)); |
| 11146 | | 11146 | |
| 11147 | if (instr_is_comptime(value)) { | 11147 | if (instr_is_comptime(value)) { |
| 11148 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, &value->value, source_instr->source_node); | 11148 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &value->value, source_instr->source_node); |
| 11149 | if (pointee == nullptr) | 11149 | if (pointee == nullptr) |
| 11150 | return ira->codegen->invalid_instruction; | 11150 | return ira->codegen->invalid_instruction; |
| 11151 | if (pointee->special != ConstValSpecialRuntime) { | 11151 | if (pointee->special != ConstValSpecialRuntime) { |
| ... | @@ -11178,7 +11178,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11178,7 +11178,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11178 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type)); | 11178 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type)); |
| 11179 | | 11179 | |
| 11180 | if (instr_is_comptime(array_ptr)) { | 11180 | if (instr_is_comptime(array_ptr)) { |
| 11181 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, &array_ptr->value, source_instr->source_node); | 11181 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &array_ptr->value, source_instr->source_node); |
| 11182 | if (pointee == nullptr) | 11182 | if (pointee == nullptr) |
| 11183 | return ira->codegen->invalid_instruction; | 11183 | return ira->codegen->invalid_instruction; |
| 11184 | if (pointee->special != ConstValSpecialRuntime) { | 11184 | if (pointee->special != ConstValSpecialRuntime) { |
| ... | @@ -11443,13 +11443,13 @@ static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -11443,13 +11443,13 @@ static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_in |
| 11443 | } | 11443 | } |
| 11444 | | 11444 | |
| 11445 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, | 11445 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 11446 | ConstExprValue *pointee, ZigType *pointee_type, | 11446 | ZigValue *pointee, ZigType *pointee_type, |
| 11447 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) | 11447 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) |
| 11448 | { | 11448 | { |
| 11449 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, | 11449 | 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); | 11450 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 11451 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); | 11451 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); |
| 11452 | ConstExprValue *const_val = &const_instr->value; | 11452 | ZigValue *const_val = &const_instr->value; |
| 11453 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 11453 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 11454 | const_val->data.x_ptr.mut = ptr_mut; | 11454 | const_val->data.x_ptr.mut = ptr_mut; |
| 11455 | const_val->data.x_ptr.data.ref.pointee = pointee; | 11455 | const_val->data.x_ptr.data.ref.pointee = pointee; |
| ... | @@ -11457,7 +11457,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -11457,7 +11457,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio |
| 11457 | } | 11457 | } |
| 11458 | | 11458 | |
| 11459 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 11459 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 11460 | ConstExprValue *val, UndefAllowed undef_allowed) | 11460 | ZigValue *val, UndefAllowed undef_allowed) |
| 11461 | { | 11461 | { |
| 11462 | Error err; | 11462 | Error err; |
| 11463 | for (;;) { | 11463 | for (;;) { |
| ... | @@ -11490,7 +11490,7 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -11490,7 +11490,7 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 11490 | } | 11490 | } |
| 11491 | } | 11491 | } |
| 11492 | | 11492 | |
| 11493 | static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { | 11493 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { |
| 11494 | Error err; | 11494 | Error err; |
| 11495 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, | 11495 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, |
| 11496 | &value->value, undef_allowed))) | 11496 | &value->value, undef_allowed))) |
| ... | @@ -11500,7 +11500,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un | ... | @@ -11500,7 +11500,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un |
| 11500 | return &value->value; | 11500 | return &value->value; |
| 11501 | } | 11501 | } |
| 11502 | | 11502 | |
| 11503 | ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 11503 | 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, | 11504 | 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, | 11505 | 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) | 11506 | IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) |
| ... | @@ -11554,7 +11554,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod | ... | @@ -11554,7 +11554,7 @@ ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *nod |
| 11554 | fprintf(stderr, "}\n"); | 11554 | fprintf(stderr, "}\n"); |
| 11555 | } | 11555 | } |
| 11556 | | 11556 | |
| 11557 | ConstExprValue *result = ir_exec_const_result(codegen, analyzed_executable); | 11557 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); |
| 11558 | if (type_is_invalid(result->type)) | 11558 | if (type_is_invalid(result->type)) |
| 11559 | return &codegen->invalid_instruction->value; | 11559 | return &codegen->invalid_instruction->value; |
| 11560 | | 11560 | |
| ... | @@ -11574,7 +11574,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu | ... | @@ -11574,7 +11574,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu |
| 11574 | return nullptr; | 11574 | return nullptr; |
| 11575 | } | 11575 | } |
| 11576 | | 11576 | |
| 11577 | ConstExprValue *const_val = ir_resolve_const(ira, err_value, UndefBad); | 11577 | ZigValue *const_val = ir_resolve_const(ira, err_value, UndefBad); |
| 11578 | if (!const_val) | 11578 | if (!const_val) |
| 11579 | return nullptr; | 11579 | return nullptr; |
| 11580 | | 11580 | |
| ... | @@ -11583,7 +11583,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu | ... | @@ -11583,7 +11583,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu |
| 11583 | } | 11583 | } |
| 11584 | | 11584 | |
| 11585 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 11585 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 11586 | ConstExprValue *val) | 11586 | ZigValue *val) |
| 11587 | { | 11587 | { |
| 11588 | Error err; | 11588 | Error err; |
| 11589 | if ((err = ir_resolve_const_val(codegen, exec, source_node, val, UndefBad))) | 11589 | if ((err = ir_resolve_const_val(codegen, exec, source_node, val, UndefBad))) |
| ... | @@ -11593,7 +11593,7 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN | ... | @@ -11593,7 +11593,7 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN |
| 11593 | return val->data.x_type; | 11593 | return val->data.x_type; |
| 11594 | } | 11594 | } |
| 11595 | | 11595 | |
| 11596 | static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { | 11596 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { |
| 11597 | if (type_is_invalid(type_value->value.type)) | 11597 | if (type_is_invalid(type_value->value.type)) |
| 11598 | return nullptr; | 11598 | return nullptr; |
| 11599 | | 11599 | |
| ... | @@ -11614,7 +11614,7 @@ static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_ | ... | @@ -11614,7 +11614,7 @@ static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_ |
| 11614 | } | 11614 | } |
| 11615 | | 11615 | |
| 11616 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 11616 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 11617 | ConstExprValue *val = ir_resolve_type_lazy(ira, type_value); | 11617 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); |
| 11618 | if (val == nullptr) | 11618 | if (val == nullptr) |
| 11619 | return ira->codegen->builtin_types.entry_invalid; | 11619 | return ira->codegen->builtin_types.entry_invalid; |
| 11620 | | 11620 | |
| ... | @@ -11674,7 +11674,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour | ... | @@ -11674,7 +11674,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour |
| 11674 | return ira->codegen->builtin_types.entry_invalid; | 11674 | return ira->codegen->builtin_types.entry_invalid; |
| 11675 | } | 11675 | } |
| 11676 | | 11676 | |
| 11677 | ConstExprValue *const_val = ir_resolve_const(ira, type_value, UndefBad); | 11677 | ZigValue *const_val = ir_resolve_const(ira, type_value, UndefBad); |
| 11678 | if (!const_val) | 11678 | if (!const_val) |
| 11679 | return ira->codegen->builtin_types.entry_invalid; | 11679 | return ira->codegen->builtin_types.entry_invalid; |
| 11680 | | 11680 | |
| ... | @@ -11703,7 +11703,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -11703,7 +11703,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 11703 | return nullptr; | 11703 | return nullptr; |
| 11704 | } | 11704 | } |
| 11705 | | 11705 | |
| 11706 | ConstExprValue *const_val = ir_resolve_const(ira, fn_value, UndefBad); | 11706 | ZigValue *const_val = ir_resolve_const(ira, fn_value, UndefBad); |
| 11707 | if (!const_val) | 11707 | if (!const_val) |
| 11708 | return nullptr; | 11708 | return nullptr; |
| 11709 | | 11709 | |
| ... | @@ -11725,7 +11725,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11725,7 +11725,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11725 | if (type_is_invalid(casted_payload->value.type)) | 11725 | if (type_is_invalid(casted_payload->value.type)) |
| 11726 | return ira->codegen->invalid_instruction; | 11726 | return ira->codegen->invalid_instruction; |
| 11727 | | 11727 | |
| 11728 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 11728 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| 11729 | if (!val) | 11729 | if (!val) |
| 11730 | return ira->codegen->invalid_instruction; | 11730 | return ira->codegen->invalid_instruction; |
| 11731 | | 11731 | |
| ... | @@ -11768,11 +11768,11 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11768,11 +11768,11 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11768 | if (type_is_invalid(casted_payload->value.type)) | 11768 | if (type_is_invalid(casted_payload->value.type)) |
| 11769 | return ira->codegen->invalid_instruction; | 11769 | return ira->codegen->invalid_instruction; |
| 11770 | | 11770 | |
| 11771 | ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefBad); | 11771 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| 11772 | if (!val) | 11772 | if (!val) |
| 11773 | return ira->codegen->invalid_instruction; | 11773 | return ira->codegen->invalid_instruction; |
| 11774 | | 11774 | |
| 11775 | ConstExprValue *err_set_val = create_const_vals(1); | 11775 | ZigValue *err_set_val = create_const_vals(1); |
| 11776 | err_set_val->type = err_set_type; | 11776 | err_set_val->type = err_set_type; |
| 11777 | err_set_val->special = ConstValSpecialStatic; | 11777 | err_set_val->special = ConstValSpecialStatic; |
| 11778 | err_set_val->data.x_err_set = nullptr; | 11778 | err_set_val->data.x_err_set = nullptr; |
| ... | @@ -11809,7 +11809,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -11809,7 +11809,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 11809 | assert(wanted_type->id == ZigTypeIdErrorSet); | 11809 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 11810 | | 11810 | |
| 11811 | if (instr_is_comptime(value)) { | 11811 | if (instr_is_comptime(value)) { |
| 11812 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11812 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11813 | if (!val) | 11813 | if (!val) |
| 11814 | return ira->codegen->invalid_instruction; | 11814 | return ira->codegen->invalid_instruction; |
| 11815 | | 11815 | |
| ... | @@ -11849,7 +11849,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -11849,7 +11849,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 11849 | IrInstruction *frame_ptr, ZigType *wanted_type) | 11849 | IrInstruction *frame_ptr, ZigType *wanted_type) |
| 11850 | { | 11850 | { |
| 11851 | if (instr_is_comptime(frame_ptr)) { | 11851 | if (instr_is_comptime(frame_ptr)) { |
| 11852 | ConstExprValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); | 11852 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); |
| 11853 | if (ptr_val == nullptr) | 11853 | if (ptr_val == nullptr) |
| 11854 | return ira->codegen->invalid_instruction; | 11854 | return ira->codegen->invalid_instruction; |
| 11855 | | 11855 | |
| ... | @@ -11887,11 +11887,11 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11887,11 +11887,11 @@ 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); | 11887 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 11888 | | 11888 | |
| 11889 | if (instr_is_comptime(casted_value)) { | 11889 | if (instr_is_comptime(casted_value)) { |
| 11890 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 11890 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 11891 | if (!val) | 11891 | if (!val) |
| 11892 | return ira->codegen->invalid_instruction; | 11892 | return ira->codegen->invalid_instruction; |
| 11893 | | 11893 | |
| 11894 | ConstExprValue *err_set_val = create_const_vals(1); | 11894 | ZigValue *err_set_val = create_const_vals(1); |
| 11895 | err_set_val->special = ConstValSpecialStatic; | 11895 | err_set_val->special = ConstValSpecialStatic; |
| 11896 | err_set_val->type = wanted_type->data.error_union.err_set_type; | 11896 | 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; | 11897 | err_set_val->data.x_err_set = val->data.x_err_set; |
| ... | @@ -11926,7 +11926,7 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -11926,7 +11926,7 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 11926 | assert(wanted_type->id == ZigTypeIdOptional); | 11926 | assert(wanted_type->id == ZigTypeIdOptional); |
| 11927 | assert(instr_is_comptime(value)); | 11927 | assert(instr_is_comptime(value)); |
| 11928 | | 11928 | |
| 11929 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11929 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11930 | assert(val != nullptr); | 11930 | assert(val != nullptr); |
| 11931 | | 11931 | |
| 11932 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11932 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| ... | @@ -11948,7 +11948,7 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction | ... | @@ -11948,7 +11948,7 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction |
| 11948 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); | 11948 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); |
| 11949 | assert(instr_is_comptime(value)); | 11949 | assert(instr_is_comptime(value)); |
| 11950 | | 11950 | |
| 11951 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 11951 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 11952 | assert(val != nullptr); | 11952 | assert(val != nullptr); |
| 11953 | | 11953 | |
| 11954 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11954 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| ... | @@ -11969,7 +11969,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -11969,7 +11969,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 11969 | return ira->codegen->invalid_instruction; | 11969 | return ira->codegen->invalid_instruction; |
| 11970 | | 11970 | |
| 11971 | if (instr_is_comptime(value)) { | 11971 | if (instr_is_comptime(value)) { |
| 11972 | ConstExprValue *val = ir_resolve_const(ira, value, LazyOk); | 11972 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); |
| 11973 | if (!val) | 11973 | if (!val) |
| 11974 | return ira->codegen->invalid_instruction; | 11974 | return ira->codegen->invalid_instruction; |
| 11975 | return ir_get_const_ptr(ira, source_instruction, val, value->value.type, | 11975 | return ir_get_const_ptr(ira, source_instruction, val, value->value.type, |
| ... | @@ -12098,7 +12098,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12098,7 +12098,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12098 | } | 12098 | } |
| 12099 | | 12099 | |
| 12100 | if (instr_is_comptime(enum_target)) { | 12100 | if (instr_is_comptime(enum_target)) { |
| 12101 | ConstExprValue *val = ir_resolve_const(ira, enum_target, UndefBad); | 12101 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); |
| 12102 | if (!val) | 12102 | if (!val) |
| 12103 | return ira->codegen->invalid_instruction; | 12103 | return ira->codegen->invalid_instruction; |
| 12104 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 12104 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| ... | @@ -12120,7 +12120,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12120,7 +12120,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12120 | assert(wanted_type == target->value.type->data.unionation.tag_type); | 12120 | assert(wanted_type == target->value.type->data.unionation.tag_type); |
| 12121 | | 12121 | |
| 12122 | if (instr_is_comptime(target)) { | 12122 | if (instr_is_comptime(target)) { |
| 12123 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12123 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12124 | if (!val) | 12124 | if (!val) |
| 12125 | return ira->codegen->invalid_instruction; | 12125 | return ira->codegen->invalid_instruction; |
| 12126 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12126 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| ... | @@ -12170,7 +12170,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12170,7 +12170,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12170 | return ira->codegen->invalid_instruction; | 12170 | return ira->codegen->invalid_instruction; |
| 12171 | | 12171 | |
| 12172 | if (instr_is_comptime(target)) { | 12172 | if (instr_is_comptime(target)) { |
| 12173 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12173 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12174 | if (!val) | 12174 | if (!val) |
| 12175 | return ira->codegen->invalid_instruction; | 12175 | return ira->codegen->invalid_instruction; |
| 12176 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); | 12176 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); |
| ... | @@ -12245,7 +12245,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12245,7 +12245,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12245 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); | 12245 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); |
| 12246 | | 12246 | |
| 12247 | if (instr_is_comptime(target)) { | 12247 | if (instr_is_comptime(target)) { |
| 12248 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12248 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12249 | if (!val) | 12249 | if (!val) |
| 12250 | return ira->codegen->invalid_instruction; | 12250 | return ira->codegen->invalid_instruction; |
| 12251 | if (wanted_type->id == ZigTypeIdInt) { | 12251 | if (wanted_type->id == ZigTypeIdInt) { |
| ... | @@ -12313,7 +12313,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12313,7 +12313,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12313 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); | 12313 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); |
| 12314 | | 12314 | |
| 12315 | if (instr_is_comptime(target)) { | 12315 | if (instr_is_comptime(target)) { |
| 12316 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12316 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12317 | if (!val) | 12317 | if (!val) |
| 12318 | return ira->codegen->invalid_instruction; | 12318 | return ira->codegen->invalid_instruction; |
| 12319 | | 12319 | |
| ... | @@ -12343,7 +12343,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12343,7 +12343,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12343 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, | 12343 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, |
| 12344 | IrInstruction *target, ZigType *wanted_type) | 12344 | IrInstruction *target, ZigType *wanted_type) |
| 12345 | { | 12345 | { |
| 12346 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12346 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12347 | if (!val) | 12347 | if (!val) |
| 12348 | return ira->codegen->invalid_instruction; | 12348 | return ira->codegen->invalid_instruction; |
| 12349 | | 12349 | |
| ... | @@ -12366,7 +12366,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12366,7 +12366,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12366 | assert(wanted_type->id == ZigTypeIdErrorSet); | 12366 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 12367 | | 12367 | |
| 12368 | if (instr_is_comptime(target)) { | 12368 | if (instr_is_comptime(target)) { |
| 12369 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12369 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12370 | if (!val) | 12370 | if (!val) |
| 12371 | return ira->codegen->invalid_instruction; | 12371 | return ira->codegen->invalid_instruction; |
| 12372 | | 12372 | |
| ... | @@ -12430,7 +12430,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12430,7 +12430,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12430 | ZigType *err_type = target->value.type; | 12430 | ZigType *err_type = target->value.type; |
| 12431 | | 12431 | |
| 12432 | if (instr_is_comptime(target)) { | 12432 | if (instr_is_comptime(target)) { |
| 12433 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12433 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12434 | if (!val) | 12434 | if (!val) |
| 12435 | return ira->codegen->invalid_instruction; | 12435 | return ira->codegen->invalid_instruction; |
| 12436 | | 12436 | |
| ... | @@ -12511,16 +12511,16 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12511,16 +12511,16 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12511 | assert(array_type->data.array.len == 1); | 12511 | assert(array_type->data.array.len == 1); |
| 12512 | | 12512 | |
| 12513 | if (instr_is_comptime(target)) { | 12513 | if (instr_is_comptime(target)) { |
| 12514 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 12514 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12515 | if (!val) | 12515 | if (!val) |
| 12516 | return ira->codegen->invalid_instruction; | 12516 | return ira->codegen->invalid_instruction; |
| 12517 | | 12517 | |
| 12518 | assert(val->type->id == ZigTypeIdPointer); | 12518 | assert(val->type->id == ZigTypeIdPointer); |
| 12519 | ConstExprValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 12519 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 12520 | if (pointee == nullptr) | 12520 | if (pointee == nullptr) |
| 12521 | return ira->codegen->invalid_instruction; | 12521 | return ira->codegen->invalid_instruction; |
| 12522 | if (pointee->special != ConstValSpecialRuntime) { | 12522 | if (pointee->special != ConstValSpecialRuntime) { |
| 12523 | ConstExprValue *array_val = create_const_vals(1); | 12523 | ZigValue *array_val = create_const_vals(1); |
| 12524 | array_val->special = ConstValSpecialStatic; | 12524 | array_val->special = ConstValSpecialStatic; |
| 12525 | array_val->type = array_type; | 12525 | array_val->type = array_type; |
| 12526 | array_val->data.x_array.special = ConstArraySpecialNone; | 12526 | array_val->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -12724,7 +12724,7 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * | ... | @@ -12724,7 +12724,7 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * |
| 12724 | IrInstruction *array, ZigType *vector_type) | 12724 | IrInstruction *array, ZigType *vector_type) |
| 12725 | { | 12725 | { |
| 12726 | if (instr_is_comptime(array)) { | 12726 | if (instr_is_comptime(array)) { |
| 12727 | // arrays and vectors have the same ConstExprValue representation | 12727 | // arrays and vectors have the same ZigValue representation |
| 12728 | IrInstruction *result = ir_const(ira, source_instr, vector_type); | 12728 | IrInstruction *result = ir_const(ira, source_instr, vector_type); |
| 12729 | copy_const_val(&result->value, &array->value, false); | 12729 | copy_const_val(&result->value, &array->value, false); |
| 12730 | result->value.type = vector_type; | 12730 | result->value.type = vector_type; |
| ... | @@ -12737,7 +12737,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -12737,7 +12737,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 12737 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) | 12737 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) |
| 12738 | { | 12738 | { |
| 12739 | if (instr_is_comptime(vector)) { | 12739 | if (instr_is_comptime(vector)) { |
| 12740 | // arrays and vectors have the same ConstExprValue representation | 12740 | // arrays and vectors have the same ZigValue representation |
| 12741 | IrInstruction *result = ir_const(ira, source_instr, array_type); | 12741 | IrInstruction *result = ir_const(ira, source_instr, array_type); |
| 12742 | copy_const_val(&result->value, &vector->value, false); | 12742 | copy_const_val(&result->value, &vector->value, false); |
| 12743 | result->value.type = array_type; | 12743 | result->value.type = array_type; |
| ... | @@ -13576,7 +13576,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13576,7 +13576,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13576 | return ira->codegen->invalid_instruction; | 13576 | return ira->codegen->invalid_instruction; |
| 13577 | } | 13577 | } |
| 13578 | if (ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 13578 | if (ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 13579 | ConstExprValue *pointee = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 13579 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); |
| 13580 | if (child_type == ira->codegen->builtin_types.entry_var) { | 13580 | if (child_type == ira->codegen->builtin_types.entry_var) { |
| 13581 | child_type = pointee->type; | 13581 | child_type = pointee->type; |
| 13582 | } | 13582 | } |
| ... | @@ -13637,7 +13637,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13637,7 +13637,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13637 | } | 13637 | } |
| 13638 | | 13638 | |
| 13639 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13639 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, |
| 13640 | ConstExprValue *const_val, uint32_t *out) | 13640 | ZigValue *const_val, uint32_t *out) |
| 13641 | { | 13641 | { |
| 13642 | Error err; | 13642 | Error err; |
| 13643 | if ((err = ir_resolve_const_val(codegen, exec, source_node, const_val, UndefBad))) | 13643 | if ((err = ir_resolve_const_val(codegen, exec, source_node, const_val, UndefBad))) |
| ... | @@ -13696,7 +13696,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i | ... | @@ -13696,7 +13696,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i |
| 13696 | if (type_is_invalid(casted_value->value.type)) | 13696 | if (type_is_invalid(casted_value->value.type)) |
| 13697 | return false; | 13697 | return false; |
| 13698 | | 13698 | |
| 13699 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13699 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13700 | if (!const_val) | 13700 | if (!const_val) |
| 13701 | return false; | 13701 | return false; |
| 13702 | | 13702 | |
| ... | @@ -13716,7 +13716,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | ... | @@ -13716,7 +13716,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 13716 | if (type_is_invalid(casted_value->value.type)) | 13716 | if (type_is_invalid(casted_value->value.type)) |
| 13717 | return false; | 13717 | return false; |
| 13718 | | 13718 | |
| 13719 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13719 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13720 | if (!const_val) | 13720 | if (!const_val) |
| 13721 | return false; | 13721 | return false; |
| 13722 | | 13722 | |
| ... | @@ -13736,7 +13736,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -13736,7 +13736,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13736 | if (type_is_invalid(value->value.type)) | 13736 | if (type_is_invalid(value->value.type)) |
| 13737 | return false; | 13737 | return false; |
| 13738 | | 13738 | |
| 13739 | ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); | 13739 | ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); |
| 13740 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); | 13740 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); |
| 13741 | ZigType *atomic_order_type = atomic_order_val->data.x_type; | 13741 | ZigType *atomic_order_type = atomic_order_val->data.x_type; |
| 13742 | | 13742 | |
| ... | @@ -13744,7 +13744,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -13744,7 +13744,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13744 | if (type_is_invalid(casted_value->value.type)) | 13744 | if (type_is_invalid(casted_value->value.type)) |
| 13745 | return false; | 13745 | return false; |
| 13746 | | 13746 | |
| 13747 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13747 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13748 | if (!const_val) | 13748 | if (!const_val) |
| 13749 | return false; | 13749 | return false; |
| 13750 | | 13750 | |
| ... | @@ -13756,7 +13756,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -13756,7 +13756,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13756 | if (type_is_invalid(value->value.type)) | 13756 | if (type_is_invalid(value->value.type)) |
| 13757 | return false; | 13757 | return false; |
| 13758 | | 13758 | |
| 13759 | ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); | 13759 | ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); |
| 13760 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); | 13760 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); |
| 13761 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; | 13761 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; |
| 13762 | | 13762 | |
| ... | @@ -13764,7 +13764,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -13764,7 +13764,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13764 | if (type_is_invalid(casted_value->value.type)) | 13764 | if (type_is_invalid(casted_value->value.type)) |
| 13765 | return false; | 13765 | return false; |
| 13766 | | 13766 | |
| 13767 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13767 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13768 | if (!const_val) | 13768 | if (!const_val) |
| 13769 | return false; | 13769 | return false; |
| 13770 | | 13770 | |
| ... | @@ -13776,7 +13776,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -13776,7 +13776,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13776 | if (type_is_invalid(value->value.type)) | 13776 | if (type_is_invalid(value->value.type)) |
| 13777 | return false; | 13777 | return false; |
| 13778 | | 13778 | |
| 13779 | ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); | 13779 | ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); |
| 13780 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); | 13780 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); |
| 13781 | ZigType *global_linkage_type = global_linkage_val->data.x_type; | 13781 | ZigType *global_linkage_type = global_linkage_val->data.x_type; |
| 13782 | | 13782 | |
| ... | @@ -13784,7 +13784,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -13784,7 +13784,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13784 | if (type_is_invalid(casted_value->value.type)) | 13784 | if (type_is_invalid(casted_value->value.type)) |
| 13785 | return false; | 13785 | return false; |
| 13786 | | 13786 | |
| 13787 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13787 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13788 | if (!const_val) | 13788 | if (!const_val) |
| 13789 | return false; | 13789 | return false; |
| 13790 | | 13790 | |
| ... | @@ -13796,7 +13796,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -13796,7 +13796,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13796 | if (type_is_invalid(value->value.type)) | 13796 | if (type_is_invalid(value->value.type)) |
| 13797 | return false; | 13797 | return false; |
| 13798 | | 13798 | |
| 13799 | ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); | 13799 | ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); |
| 13800 | assert(float_mode_val->type->id == ZigTypeIdMetaType); | 13800 | assert(float_mode_val->type->id == ZigTypeIdMetaType); |
| 13801 | ZigType *float_mode_type = float_mode_val->data.x_type; | 13801 | ZigType *float_mode_type = float_mode_val->data.x_type; |
| 13802 | | 13802 | |
| ... | @@ -13804,7 +13804,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -13804,7 +13804,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13804 | if (type_is_invalid(casted_value->value.type)) | 13804 | if (type_is_invalid(casted_value->value.type)) |
| 13805 | return false; | 13805 | return false; |
| 13806 | | 13806 | |
| 13807 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13807 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13808 | if (!const_val) | 13808 | if (!const_val) |
| 13809 | return false; | 13809 | return false; |
| 13810 | | 13810 | |
| ... | @@ -13823,15 +13823,15 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -13823,15 +13823,15 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13823 | if (type_is_invalid(casted_value->value.type)) | 13823 | if (type_is_invalid(casted_value->value.type)) |
| 13824 | return nullptr; | 13824 | return nullptr; |
| 13825 | | 13825 | |
| 13826 | ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13826 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 13827 | if (!const_val) | 13827 | if (!const_val) |
| 13828 | return nullptr; | 13828 | return nullptr; |
| 13829 | | 13829 | |
| 13830 | ConstExprValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index]; | 13830 | 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]; | 13831 | ZigValue *len_field = const_val->data.x_struct.fields[slice_len_index]; |
| 13832 | | 13832 | |
| 13833 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); | 13833 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 13834 | ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; | 13834 | ZigValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; |
| 13835 | expand_undef_array(ira->codegen, array_val); | 13835 | expand_undef_array(ira->codegen, array_val); |
| 13836 | size_t len = bigint_as_usize(&len_field->data.x_bigint); | 13836 | 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)) { | 13837 | if (array_val->data.x_array.special == ConstArraySpecialBuf && len == buf_len(array_val->data.x_array.data.s_buf)) { |
| ... | @@ -13841,7 +13841,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -13841,7 +13841,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13841 | buf_resize(result, len); | 13841 | buf_resize(result, len); |
| 13842 | for (size_t i = 0; i < len; i += 1) { | 13842 | 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; | 13843 | 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]; | 13844 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; |
| 13845 | if (char_val->special == ConstValSpecialUndef) { | 13845 | if (char_val->special == ConstValSpecialUndef) { |
| 13846 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); | 13846 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); |
| 13847 | return nullptr; | 13847 | return nullptr; |
| ... | @@ -13934,11 +13934,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -13934,11 +13934,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13934 | return ira->codegen->invalid_instruction; | 13934 | return ira->codegen->invalid_instruction; |
| 13935 | | 13935 | |
| 13936 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 13936 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 13937 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 13937 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 13938 | if (op1_val == nullptr) | 13938 | if (op1_val == nullptr) |
| 13939 | return ira->codegen->invalid_instruction; | 13939 | return ira->codegen->invalid_instruction; |
| 13940 | | 13940 | |
| 13941 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 13941 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 13942 | if (op2_val == nullptr) | 13942 | if (op2_val == nullptr) |
| 13943 | return ira->codegen->invalid_instruction; | 13943 | return ira->codegen->invalid_instruction; |
| 13944 | | 13944 | |
| ... | @@ -13981,7 +13981,7 @@ static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { | ... | @@ -13981,7 +13981,7 @@ static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { |
| 13981 | } | 13981 | } |
| 13982 | } | 13982 | } |
| 13983 | | 13983 | |
| 13984 | static bool optional_value_is_null(ConstExprValue *val) { | 13984 | static bool optional_value_is_null(ZigValue *val) { |
| 13985 | assert(val->special == ConstValSpecialStatic); | 13985 | assert(val->special == ConstValSpecialStatic); |
| 13986 | if (get_codegen_ptr_type(val->type) != nullptr) { | 13986 | if (get_codegen_ptr_type(val->type) != nullptr) { |
| 13987 | if (val->data.x_ptr.special == ConstPtrSpecialNull) { | 13987 | if (val->data.x_ptr.special == ConstPtrSpecialNull) { |
| ... | @@ -13999,7 +13999,7 @@ static bool optional_value_is_null(ConstExprValue *val) { | ... | @@ -13999,7 +13999,7 @@ static bool optional_value_is_null(ConstExprValue *val) { |
| 13999 | } | 13999 | } |
| 14000 | | 14000 | |
| 14001 | static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | 14001 | 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, | 14002 | ZigValue *op1_val, ZigValue *op2_val, IrInstructionBinOp *bin_op_instruction, IrBinOp op_id, |
| 14003 | bool one_possible_value) { | 14003 | bool one_possible_value) { |
| 14004 | if (op1_val->special == ConstValSpecialUndef || | 14004 | if (op1_val->special == ConstValSpecialUndef || |
| 14005 | op2_val->special == ConstValSpecialUndef) | 14005 | op2_val->special == ConstValSpecialUndef) |
| ... | @@ -14052,7 +14052,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14052,7 +14052,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14052 | } | 14052 | } |
| 14053 | | 14053 | |
| 14054 | // Returns ErrorNotLazy when the value cannot be determined | 14054 | // Returns ErrorNotLazy when the value cannot be determined |
| 14055 | static Error lazy_cmp_zero(AstNode *source_node, ConstExprValue *val, Cmp *result) { | 14055 | static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { |
| 14056 | Error err; | 14056 | Error err; |
| 14057 | | 14057 | |
| 14058 | switch (val->special) { | 14058 | switch (val->special) { |
| ... | @@ -14124,7 +14124,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14124,7 +14124,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14124 | zig_unreachable(); | 14124 | zig_unreachable(); |
| 14125 | } | 14125 | } |
| 14126 | if (instr_is_comptime(maybe_op)) { | 14126 | if (instr_is_comptime(maybe_op)) { |
| 14127 | ConstExprValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); | 14127 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); |
| 14128 | if (!maybe_val) | 14128 | if (!maybe_val) |
| 14129 | return ira->codegen->invalid_instruction; | 14129 | return ira->codegen->invalid_instruction; |
| 14130 | bool is_null = optional_value_is_null(maybe_val); | 14130 | bool is_null = optional_value_is_null(maybe_val); |
| ... | @@ -14159,7 +14159,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14159,7 +14159,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14159 | zig_unreachable(); | 14159 | zig_unreachable(); |
| 14160 | } | 14160 | } |
| 14161 | if (instr_is_comptime(c_ptr_op)) { | 14161 | if (instr_is_comptime(c_ptr_op)) { |
| 14162 | ConstExprValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); | 14162 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); |
| 14163 | if (!c_ptr_val) | 14163 | if (!c_ptr_val) |
| 14164 | return ira->codegen->invalid_instruction; | 14164 | return ira->codegen->invalid_instruction; |
| 14165 | if (c_ptr_val->special == ConstValSpecialUndef) | 14165 | if (c_ptr_val->special == ConstValSpecialUndef) |
| ... | @@ -14207,11 +14207,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14207,11 +14207,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14207 | return ira->codegen->invalid_instruction; | 14207 | return ira->codegen->invalid_instruction; |
| 14208 | | 14208 | |
| 14209 | if (instr_is_comptime(casted_union)) { | 14209 | if (instr_is_comptime(casted_union)) { |
| 14210 | ConstExprValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); | 14210 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); |
| 14211 | if (!const_union_val) | 14211 | if (!const_union_val) |
| 14212 | return ira->codegen->invalid_instruction; | 14212 | return ira->codegen->invalid_instruction; |
| 14213 | | 14213 | |
| 14214 | ConstExprValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); | 14214 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); |
| 14215 | if (!const_enum_val) | 14215 | if (!const_enum_val) |
| 14216 | return ira->codegen->invalid_instruction; | 14216 | return ira->codegen->invalid_instruction; |
| 14217 | | 14217 | |
| ... | @@ -14282,10 +14282,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14282,10 +14282,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14282 | } | 14282 | } |
| 14283 | | 14283 | |
| 14284 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 14284 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 14285 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 14285 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14286 | if (op1_val == nullptr) | 14286 | if (op1_val == nullptr) |
| 14287 | return ira->codegen->invalid_instruction; | 14287 | return ira->codegen->invalid_instruction; |
| 14288 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 14288 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 14289 | if (op2_val == nullptr) | 14289 | if (op2_val == nullptr) |
| 14290 | return ira->codegen->invalid_instruction; | 14290 | return ira->codegen->invalid_instruction; |
| 14291 | | 14291 | |
| ... | @@ -14430,10 +14430,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14430,10 +14430,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14430 | } | 14430 | } |
| 14431 | never_mind_just_calculate_it_normally: | 14431 | never_mind_just_calculate_it_normally: |
| 14432 | | 14432 | |
| 14433 | ConstExprValue *op1_val = one_possible_value ? &casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); | 14433 | ZigValue *op1_val = one_possible_value ? &casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); |
| 14434 | if (op1_val == nullptr) | 14434 | if (op1_val == nullptr) |
| 14435 | return ira->codegen->invalid_instruction; | 14435 | return ira->codegen->invalid_instruction; |
| 14436 | ConstExprValue *op2_val = one_possible_value ? &casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); | 14436 | ZigValue *op2_val = one_possible_value ? &casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); |
| 14437 | if (op2_val == nullptr) | 14437 | if (op2_val == nullptr) |
| 14438 | return ira->codegen->invalid_instruction; | 14438 | return ira->codegen->invalid_instruction; |
| 14439 | if (resolved_type->id != ZigTypeIdVector) | 14439 | if (resolved_type->id != ZigTypeIdVector) |
| ... | @@ -14456,7 +14456,7 @@ never_mind_just_calculate_it_normally: | ... | @@ -14456,7 +14456,7 @@ never_mind_just_calculate_it_normally: |
| 14456 | | 14456 | |
| 14457 | // some comparisons with unsigned numbers can be evaluated | 14457 | // some comparisons with unsigned numbers can be evaluated |
| 14458 | if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) { | 14458 | if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) { |
| 14459 | ConstExprValue *known_left_val; | 14459 | ZigValue *known_left_val; |
| 14460 | IrBinOp flipped_op_id; | 14460 | IrBinOp flipped_op_id; |
| 14461 | if (instr_is_comptime(casted_op1)) { | 14461 | if (instr_is_comptime(casted_op1)) { |
| 14462 | known_left_val = ir_resolve_const(ira, casted_op1, UndefBad); | 14462 | known_left_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| ... | @@ -14504,7 +14504,7 @@ never_mind_just_calculate_it_normally: | ... | @@ -14504,7 +14504,7 @@ never_mind_just_calculate_it_normally: |
| 14504 | } | 14504 | } |
| 14505 | | 14505 | |
| 14506 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 14506 | 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) | 14507 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 14508 | { | 14508 | { |
| 14509 | bool is_int; | 14509 | bool is_int; |
| 14510 | bool is_float; | 14510 | bool is_float; |
| ... | @@ -14646,7 +14646,7 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -14646,7 +14646,7 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 14646 | } | 14646 | } |
| 14647 | } else { | 14647 | } else { |
| 14648 | float_div_trunc(out_val, op1_val, op2_val); | 14648 | float_div_trunc(out_val, op1_val, op2_val); |
| 14649 | ConstExprValue remainder = {}; | 14649 | ZigValue remainder = {}; |
| 14650 | float_rem(&remainder, op1_val, op2_val); | 14650 | float_rem(&remainder, op1_val, op2_val); |
| 14651 | if (float_cmp_zero(&remainder) != CmpEQ) { | 14651 | if (float_cmp_zero(&remainder) != CmpEQ) { |
| 14652 | return ir_add_error(ira, source_instr, buf_sprintf("exact division had a remainder")); | 14652 | return ir_add_error(ira, source_instr, buf_sprintf("exact division had a remainder")); |
| ... | @@ -14684,10 +14684,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -14684,10 +14684,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 14684 | | 14684 | |
| 14685 | // This works on operands that have already been checked to be comptime known. | 14685 | // 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, | 14686 | static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_instr, |
| 14687 | ZigType *type_entry, ConstExprValue *op1_val, IrBinOp op_id, ConstExprValue *op2_val) | 14687 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 14688 | { | 14688 | { |
| 14689 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); | 14689 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); |
| 14690 | ConstExprValue *out_val = &result_instruction->value; | 14690 | ZigValue *out_val = &result_instruction->value; |
| 14691 | if (type_entry->id == ZigTypeIdVector) { | 14691 | if (type_entry->id == ZigTypeIdVector) { |
| 14692 | expand_undef_array(ira->codegen, op1_val); | 14692 | expand_undef_array(ira->codegen, op1_val); |
| 14693 | expand_undef_array(ira->codegen, op2_val); | 14693 | expand_undef_array(ira->codegen, op2_val); |
| ... | @@ -14696,9 +14696,9 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -14696,9 +14696,9 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14696 | size_t len = type_entry->data.vector.len; | 14696 | size_t len = type_entry->data.vector.len; |
| 14697 | ZigType *scalar_type = type_entry->data.vector.elem_type; | 14697 | ZigType *scalar_type = type_entry->data.vector.elem_type; |
| 14698 | for (size_t i = 0; i < len; i += 1) { | 14698 | for (size_t i = 0; i < len; i += 1) { |
| 14699 | ConstExprValue *scalar_op1_val = &op1_val->data.x_array.data.s_none.elements[i]; | 14699 | 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]; | 14700 | 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]; | 14701 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 14702 | assert(scalar_op1_val->type == scalar_type); | 14702 | assert(scalar_op1_val->type == scalar_type); |
| 14703 | assert(scalar_op2_val->type == scalar_type); | 14703 | assert(scalar_op2_val->type == scalar_type); |
| 14704 | assert(scalar_out_val->type == scalar_type); | 14704 | assert(scalar_out_val->type == scalar_type); |
| ... | @@ -14788,11 +14788,11 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -14788,11 +14788,11 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 14788 | } | 14788 | } |
| 14789 | | 14789 | |
| 14790 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { | 14790 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { |
| 14791 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 14791 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14792 | if (op1_val == nullptr) | 14792 | if (op1_val == nullptr) |
| 14793 | return ira->codegen->invalid_instruction; | 14793 | return ira->codegen->invalid_instruction; |
| 14794 | | 14794 | |
| 14795 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 14795 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 14796 | if (op2_val == nullptr) | 14796 | if (op2_val == nullptr) |
| 14797 | return ira->codegen->invalid_instruction; | 14797 | return ira->codegen->invalid_instruction; |
| 14798 | | 14798 | |
| ... | @@ -14896,8 +14896,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14896,8 +14896,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14896 | return ira->codegen->invalid_instruction; | 14896 | return ira->codegen->invalid_instruction; |
| 14897 | | 14897 | |
| 14898 | // If either operand is undef, result is undef. | 14898 | // If either operand is undef, result is undef. |
| 14899 | ConstExprValue *op1_val = nullptr; | 14899 | ZigValue *op1_val = nullptr; |
| 14900 | ConstExprValue *op2_val = nullptr; | 14900 | ZigValue *op2_val = nullptr; |
| 14901 | if (instr_is_comptime(op1)) { | 14901 | if (instr_is_comptime(op1)) { |
| 14902 | op1_val = ir_resolve_const(ira, op1, UndefOk); | 14902 | op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 14903 | if (op1_val == nullptr) | 14903 | if (op1_val == nullptr) |
| ... | @@ -14968,11 +14968,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14968,11 +14968,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14968 | if (is_signed_div) { | 14968 | if (is_signed_div) { |
| 14969 | bool ok = false; | 14969 | bool ok = false; |
| 14970 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 14970 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 14971 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 14971 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 14972 | if (op1_val == nullptr) | 14972 | if (op1_val == nullptr) |
| 14973 | return ira->codegen->invalid_instruction; | 14973 | return ira->codegen->invalid_instruction; |
| 14974 | | 14974 | |
| 14975 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 14975 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 14976 | if (op2_val == nullptr) | 14976 | if (op2_val == nullptr) |
| 14977 | return ira->codegen->invalid_instruction; | 14977 | return ira->codegen->invalid_instruction; |
| 14978 | | 14978 | |
| ... | @@ -15006,12 +15006,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15006,12 +15006,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15006 | if (is_signed_div && (is_int || is_float)) { | 15006 | if (is_signed_div && (is_int || is_float)) { |
| 15007 | bool ok = false; | 15007 | bool ok = false; |
| 15008 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 15008 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15009 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 15009 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15010 | if (op1_val == nullptr) | 15010 | if (op1_val == nullptr) |
| 15011 | return ira->codegen->invalid_instruction; | 15011 | return ira->codegen->invalid_instruction; |
| 15012 | | 15012 | |
| 15013 | if (is_int) { | 15013 | if (is_int) { |
| 15014 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 15014 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15015 | if (op2_val == nullptr) | 15015 | if (op2_val == nullptr) |
| 15016 | return ira->codegen->invalid_instruction; | 15016 | return ira->codegen->invalid_instruction; |
| 15017 | | 15017 | |
| ... | @@ -15031,7 +15031,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15031,7 +15031,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15031 | if (casted_op2 == ira->codegen->invalid_instruction) | 15031 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 15032 | return ira->codegen->invalid_instruction; | 15032 | return ira->codegen->invalid_instruction; |
| 15033 | | 15033 | |
| 15034 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15034 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15035 | if (op2_val == nullptr) | 15035 | if (op2_val == nullptr) |
| 15036 | return ira->codegen->invalid_instruction; | 15036 | return ira->codegen->invalid_instruction; |
| 15037 | | 15037 | |
| ... | @@ -15040,8 +15040,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15040,8 +15040,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15040 | // have a remainder function ambiguity problem | 15040 | // have a remainder function ambiguity problem |
| 15041 | ok = true; | 15041 | ok = true; |
| 15042 | } else { | 15042 | } else { |
| 15043 | ConstExprValue rem_result = {}; | 15043 | ZigValue rem_result = {}; |
| 15044 | ConstExprValue mod_result = {}; | 15044 | ZigValue mod_result = {}; |
| 15045 | float_rem(&rem_result, op1_val, op2_val); | 15045 | float_rem(&rem_result, op1_val, op2_val); |
| 15046 | float_mod(&mod_result, op1_val, op2_val); | 15046 | float_mod(&mod_result, op1_val, op2_val); |
| 15047 | ok = float_cmp(&rem_result, &mod_result) == CmpEQ; | 15047 | ok = float_cmp(&rem_result, &mod_result) == CmpEQ; |
| ... | @@ -15100,10 +15100,10 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15100,10 +15100,10 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15100 | return ira->codegen->invalid_instruction; | 15100 | return ira->codegen->invalid_instruction; |
| 15101 | | 15101 | |
| 15102 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 15102 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 15103 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 15103 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 15104 | if (op1_val == nullptr) | 15104 | if (op1_val == nullptr) |
| 15105 | return ira->codegen->invalid_instruction; | 15105 | return ira->codegen->invalid_instruction; |
| 15106 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15106 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15107 | if (op2_val == nullptr) | 15107 | if (op2_val == nullptr) |
| 15108 | return ira->codegen->invalid_instruction; | 15108 | return ira->codegen->invalid_instruction; |
| 15109 | | 15109 | |
| ... | @@ -15127,16 +15127,16 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15127,16 +15127,16 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15127 | if (type_is_invalid(op2_type)) | 15127 | if (type_is_invalid(op2_type)) |
| 15128 | return ira->codegen->invalid_instruction; | 15128 | return ira->codegen->invalid_instruction; |
| 15129 | | 15129 | |
| 15130 | ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 15130 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15131 | if (!op1_val) | 15131 | if (!op1_val) |
| 15132 | return ira->codegen->invalid_instruction; | 15132 | return ira->codegen->invalid_instruction; |
| 15133 | | 15133 | |
| 15134 | ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 15134 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15135 | if (!op2_val) | 15135 | if (!op2_val) |
| 15136 | return ira->codegen->invalid_instruction; | 15136 | return ira->codegen->invalid_instruction; |
| 15137 | | 15137 | |
| 15138 | ConstExprValue *sentinel1 = nullptr; | 15138 | ZigValue *sentinel1 = nullptr; |
| 15139 | ConstExprValue *op1_array_val; | 15139 | ZigValue *op1_array_val; |
| 15140 | size_t op1_array_index; | 15140 | size_t op1_array_index; |
| 15141 | size_t op1_array_end; | 15141 | size_t op1_array_end; |
| 15142 | ZigType *child_type; | 15142 | ZigType *child_type; |
| ... | @@ -15159,11 +15159,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15159,11 +15159,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15159 | } else if (is_slice(op1_type)) { | 15159 | } else if (is_slice(op1_type)) { |
| 15160 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index]->type_entry; | 15160 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 15161 | child_type = ptr_type->data.pointer.child_type; | 15161 | child_type = ptr_type->data.pointer.child_type; |
| 15162 | ConstExprValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index]; | 15162 | ZigValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index]; |
| 15163 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 15163 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 15164 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 15164 | 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; | 15165 | 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]; | 15166 | 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); | 15167 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 15168 | sentinel1 = ptr_type->data.pointer.sentinel; | 15168 | sentinel1 = ptr_type->data.pointer.sentinel; |
| 15169 | } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle && | 15169 | } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle && |
| ... | @@ -15183,8 +15183,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15183,8 +15183,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15183 | return ira->codegen->invalid_instruction; | 15183 | return ira->codegen->invalid_instruction; |
| 15184 | } | 15184 | } |
| 15185 | | 15185 | |
| 15186 | ConstExprValue *sentinel2 = nullptr; | 15186 | ZigValue *sentinel2 = nullptr; |
| 15187 | ConstExprValue *op2_array_val; | 15187 | ZigValue *op2_array_val; |
| 15188 | size_t op2_array_index; | 15188 | size_t op2_array_index; |
| 15189 | size_t op2_array_end; | 15189 | size_t op2_array_end; |
| 15190 | bool op2_type_valid; | 15190 | bool op2_type_valid; |
| ... | @@ -15207,11 +15207,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15207,11 +15207,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15207 | } else if (is_slice(op2_type)) { | 15207 | } else if (is_slice(op2_type)) { |
| 15208 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index]->type_entry; | 15208 | 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; | 15209 | op2_type_valid = ptr_type->data.pointer.child_type == child_type; |
| 15210 | ConstExprValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index]; | 15210 | ZigValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index]; |
| 15211 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 15211 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 15212 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 15212 | 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; | 15213 | 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]; | 15214 | 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); | 15215 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 15216 | | 15216 | |
| 15217 | sentinel2 = ptr_type->data.pointer.sentinel; | 15217 | sentinel2 = ptr_type->data.pointer.sentinel; |
| ... | @@ -15239,7 +15239,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15239,7 +15239,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15239 | return ira->codegen->invalid_instruction; | 15239 | return ira->codegen->invalid_instruction; |
| 15240 | } | 15240 | } |
| 15241 | | 15241 | |
| 15242 | ConstExprValue *sentinel; | 15242 | ZigValue *sentinel; |
| 15243 | if (sentinel1 != nullptr && sentinel2 != nullptr) { | 15243 | if (sentinel1 != nullptr && sentinel2 != nullptr) { |
| 15244 | // When there is a sentinel mismatch, no sentinel on the result. The type system | 15244 | // When there is a sentinel mismatch, no sentinel on the result. The type system |
| 15245 | // will catch this if it is a problem. | 15245 | // will catch this if it is a problem. |
| ... | @@ -15254,9 +15254,9 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15254,9 +15254,9 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15254 | | 15254 | |
| 15255 | // The type of result is populated in the following if blocks | 15255 | // The type of result is populated in the following if blocks |
| 15256 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 15256 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 15257 | ConstExprValue *out_val = &result->value; | 15257 | ZigValue *out_val = &result->value; |
| 15258 | | 15258 | |
| 15259 | ConstExprValue *out_array_val; | 15259 | ZigValue *out_array_val; |
| 15260 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); | 15260 | 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) { | 15261 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { |
| 15262 | result->value.type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15262 | result->value.type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | @@ -15317,21 +15317,21 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15317,21 +15317,21 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15317 | | 15317 | |
| 15318 | size_t next_index = 0; | 15318 | size_t next_index = 0; |
| 15319 | for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) { | 15319 | 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]; | 15320 | 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); | 15321 | 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; | 15322 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15323 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15323 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 15324 | elem_dest_val->parent.data.p_array.elem_index = next_index; | 15324 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 15325 | } | 15325 | } |
| 15326 | for (size_t i = op2_array_index; i < op2_array_end; i += 1, next_index += 1) { | 15326 | 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]; | 15327 | 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); | 15328 | 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; | 15329 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15330 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15330 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| 15331 | elem_dest_val->parent.data.p_array.elem_index = next_index; | 15331 | elem_dest_val->parent.data.p_array.elem_index = next_index; |
| 15332 | } | 15332 | } |
| 15333 | if (next_index < full_len) { | 15333 | if (next_index < full_len) { |
| 15334 | ConstExprValue *elem_dest_val = &out_array_val->data.x_array.data.s_none.elements[next_index]; | 15334 | 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); | 15335 | copy_const_val(elem_dest_val, sentinel, false); |
| 15336 | elem_dest_val->parent.id = ConstParentIdArray; | 15336 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15337 | elem_dest_val->parent.data.p_array.array_val = out_array_val; | 15337 | elem_dest_val->parent.data.p_array.array_val = out_array_val; |
| ... | @@ -15354,7 +15354,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15354,7 +15354,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15354 | | 15354 | |
| 15355 | bool want_ptr_to_array = false; | 15355 | bool want_ptr_to_array = false; |
| 15356 | ZigType *array_type; | 15356 | ZigType *array_type; |
| 15357 | ConstExprValue *array_val; | 15357 | ZigValue *array_val; |
| 15358 | if (op1->value.type->id == ZigTypeIdArray) { | 15358 | if (op1->value.type->id == ZigTypeIdArray) { |
| 15359 | array_type = op1->value.type; | 15359 | array_type = op1->value.type; |
| 15360 | array_val = ir_resolve_const(ira, op1, UndefOk); | 15360 | array_val = ir_resolve_const(ira, op1, UndefOk); |
| ... | @@ -15397,7 +15397,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15397,7 +15397,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15397 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); | 15397 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); |
| 15398 | } else { | 15398 | } else { |
| 15399 | array_result = ir_const(ira, &instruction->base, result_array_type); | 15399 | array_result = ir_const(ira, &instruction->base, result_array_type); |
| 15400 | ConstExprValue *out_val = &array_result->value; | 15400 | ZigValue *out_val = &array_result->value; |
| 15401 | | 15401 | |
| 15402 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { | 15402 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { |
| 15403 | case OnePossibleValueInvalid: | 15403 | case OnePossibleValueInvalid: |
| ... | @@ -15416,7 +15416,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15416,7 +15416,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15416 | uint64_t i = 0; | 15416 | uint64_t i = 0; |
| 15417 | for (uint64_t x = 0; x < mult_amt; x += 1) { | 15417 | for (uint64_t x = 0; x < mult_amt; x += 1) { |
| 15418 | for (uint64_t y = 0; y < old_array_len; y += 1) { | 15418 | 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]; | 15419 | 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); | 15420 | copy_const_val(elem_dest_val, &array_val->data.x_array.data.s_none.elements[y], false); |
| 15421 | elem_dest_val->parent.id = ConstParentIdArray; | 15421 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15422 | elem_dest_val->parent.data.p_array.array_val = out_val; | 15422 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| ... | @@ -15427,7 +15427,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15427,7 +15427,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15427 | assert(i == new_array_len); | 15427 | assert(i == new_array_len); |
| 15428 | | 15428 | |
| 15429 | if (array_type->data.array.sentinel != nullptr) { | 15429 | if (array_type->data.array.sentinel != nullptr) { |
| 15430 | ConstExprValue *elem_dest_val = &out_val->data.x_array.data.s_none.elements[i]; | 15430 | 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); | 15431 | copy_const_val(elem_dest_val, array_type->data.array.sentinel, false); |
| 15432 | elem_dest_val->parent.id = ConstParentIdArray; | 15432 | elem_dest_val->parent.id = ConstParentIdArray; |
| 15433 | elem_dest_val->parent.data.p_array.array_val = out_val; | 15433 | elem_dest_val->parent.data.p_array.array_val = out_val; |
| ... | @@ -15570,7 +15570,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15570,7 +15570,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15570 | zig_unreachable(); | 15570 | zig_unreachable(); |
| 15571 | } | 15571 | } |
| 15572 | | 15572 | |
| 15573 | ConstExprValue *init_val = nullptr; | 15573 | ZigValue *init_val = nullptr; |
| 15574 | if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15574 | if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 15575 | init_val = const_ptr_pointee(ira, ira->codegen, &var_ptr->value, decl_var_instruction->base.source_node); | 15575 | init_val = const_ptr_pointee(ira, ira->codegen, &var_ptr->value, decl_var_instruction->base.source_node); |
| 15576 | if (is_comptime_var) { | 15576 | if (is_comptime_var) { |
| ... | @@ -15631,7 +15631,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15631,7 +15631,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15631 | new_var->owner_exec = var->owner_exec; | 15631 | new_var->owner_exec = var->owner_exec; |
| 15632 | new_var->align_bytes = var->align_bytes; | 15632 | new_var->align_bytes = var->align_bytes; |
| 15633 | if (var->mem_slot_index != SIZE_MAX) { | 15633 | if (var->mem_slot_index != SIZE_MAX) { |
| 15634 | ConstExprValue *vals = create_const_vals(1); | 15634 | ZigValue *vals = create_const_vals(1); |
| 15635 | new_var->mem_slot_index = ira->exec_context.mem_slot_list.length; | 15635 | new_var->mem_slot_index = ira->exec_context.mem_slot_list.length; |
| 15636 | ira->exec_context.mem_slot_list.append(vals); | 15636 | ira->exec_context.mem_slot_list.append(vals); |
| 15637 | } | 15637 | } |
| ... | @@ -15687,7 +15687,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15687,7 +15687,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15687 | | 15687 | |
| 15688 | if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) { | 15688 | 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); | 15689 | 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); | 15690 | 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); | 15691 | copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const); |
| 15692 | | 15692 | |
| 15693 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { | 15693 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { |
| ... | @@ -15936,7 +15936,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | ... | @@ -15936,7 +15936,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); | 15936 | 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)) { | 15937 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { |
| 15938 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); | 15938 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); |
| 15939 | ConstExprValue *out_val = &result->value; | 15939 | ZigValue *out_val = &result->value; |
| 15940 | assert(get_codegen_ptr_type(optional_type) != nullptr); | 15940 | assert(get_codegen_ptr_type(optional_type) != nullptr); |
| 15941 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 15941 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 15942 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; | 15942 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; |
| ... | @@ -15982,7 +15982,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -15982,7 +15982,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 15982 | { | 15982 | { |
| 15983 | Error err; | 15983 | Error err; |
| 15984 | | 15984 | |
| 15985 | ConstExprValue *pointee = create_const_vals(1); | 15985 | ZigValue *pointee = create_const_vals(1); |
| 15986 | pointee->special = ConstValSpecialUndef; | 15986 | pointee->special = ConstValSpecialUndef; |
| 15987 | | 15987 | |
| 15988 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); | 15988 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); |
| ... | @@ -16063,7 +16063,7 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -16063,7 +16063,7 @@ static bool type_can_bit_cast(ZigType *t) { |
| 16063 | } | 16063 | } |
| 16064 | | 16064 | |
| 16065 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { | 16065 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { |
| 16066 | ConstExprValue *undef_child = create_const_vals(1); | 16066 | ZigValue *undef_child = create_const_vals(1); |
| 16067 | undef_child->type = ptr->value.type->data.pointer.child_type; | 16067 | undef_child->type = ptr->value.type->data.pointer.child_type; |
| 16068 | undef_child->special = ConstValSpecialUndef; | 16068 | undef_child->special = ConstValSpecialUndef; |
| 16069 | ptr->value.special = ConstValSpecialStatic; | 16069 | ptr->value.special = ConstValSpecialStatic; |
| ... | @@ -16676,7 +16676,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -16676,7 +16676,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 16676 | casted_arg = arg; | 16676 | casted_arg = arg; |
| 16677 | } | 16677 | } |
| 16678 | | 16678 | |
| 16679 | ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk); | 16679 | ZigValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk); |
| 16680 | if (!arg_val) | 16680 | if (!arg_val) |
| 16681 | return false; | 16681 | return false; |
| 16682 | | 16682 | |
| ... | @@ -16721,7 +16721,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16721,7 +16721,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16721 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || | 16721 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || |
| 16722 | casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat; | 16722 | casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat; |
| 16723 | | 16723 | |
| 16724 | ConstExprValue *arg_val; | 16724 | ZigValue *arg_val; |
| 16725 | | 16725 | |
| 16726 | if (comptime_arg) { | 16726 | if (comptime_arg) { |
| 16727 | arg_part_of_generic_id = true; | 16727 | arg_part_of_generic_id = true; |
| ... | @@ -16805,7 +16805,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16805,7 +16805,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16805 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) | 16805 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) |
| 16806 | return ira->codegen->invalid_instruction; | 16806 | return ira->codegen->invalid_instruction; |
| 16807 | | 16807 | |
| 16808 | ConstExprValue *mem_slot = nullptr; | 16808 | ZigValue *mem_slot = nullptr; |
| 16809 | | 16809 | |
| 16810 | bool comptime_var_mem = ir_get_var_is_comptime(var); | 16810 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| 16811 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; | 16811 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| ... | @@ -16865,7 +16865,7 @@ no_mem_slot: | ... | @@ -16865,7 +16865,7 @@ no_mem_slot: |
| 16865 | } | 16865 | } |
| 16866 | | 16866 | |
| 16867 | // This function is called when a comptime value becomes accessible at runtime. | 16867 | // 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) { | 16868 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *val) { |
| 16869 | ir_assert(value_is_comptime(val), source_instr); | 16869 | ir_assert(value_is_comptime(val), source_instr); |
| 16870 | if (val->special == ConstValSpecialUndef) | 16870 | if (val->special == ConstValSpecialUndef) |
| 16871 | return; | 16871 | return; |
| ... | @@ -16921,17 +16921,17 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16921,17 +16921,17 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16921 | casted_ptr->value.type = struct_ptr_type; | 16921 | casted_ptr->value.type = struct_ptr_type; |
| 16922 | } | 16922 | } |
| 16923 | if (instr_is_comptime(casted_ptr)) { | 16923 | if (instr_is_comptime(casted_ptr)) { |
| 16924 | ConstExprValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); | 16924 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); |
| 16925 | if (!ptr_val) | 16925 | if (!ptr_val) |
| 16926 | return ira->codegen->invalid_instruction; | 16926 | return ira->codegen->invalid_instruction; |
| 16927 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 16927 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 16928 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, | 16928 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 16929 | source_instr->source_node); | 16929 | source_instr->source_node); |
| 16930 | struct_val->special = ConstValSpecialStatic; | 16930 | struct_val->special = ConstValSpecialStatic; |
| 16931 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, | 16931 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, |
| 16932 | old_field_count, new_field_count); | 16932 | old_field_count, new_field_count); |
| 16933 | | 16933 | |
| 16934 | ConstExprValue *field_val = struct_val->data.x_struct.fields[old_field_count]; | 16934 | ZigValue *field_val = struct_val->data.x_struct.fields[old_field_count]; |
| 16935 | field_val->special = ConstValSpecialUndef; | 16935 | field_val->special = ConstValSpecialUndef; |
| 16936 | field_val->type = field->type_entry; | 16936 | field_val->type = field->type_entry; |
| 16937 | field_val->parent.id = ConstParentIdStruct; | 16937 | field_val->parent.id = ConstParentIdStruct; |
| ... | @@ -16972,7 +16972,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16972,7 +16972,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16972 | ptr->value.data.x_ptr.mut == ConstPtrMutInfer) | 16972 | ptr->value.data.x_ptr.mut == ConstPtrMutInfer) |
| 16973 | { | 16973 | { |
| 16974 | if (instr_is_comptime(value)) { | 16974 | if (instr_is_comptime(value)) { |
| 16975 | ConstExprValue *dest_val = const_ptr_pointee(ira, ira->codegen, &ptr->value, source_instr->source_node); | 16975 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, &ptr->value, source_instr->source_node); |
| 16976 | if (dest_val == nullptr) | 16976 | if (dest_val == nullptr) |
| 16977 | return ira->codegen->invalid_instruction; | 16977 | return ira->codegen->invalid_instruction; |
| 16978 | if (dest_val->special != ConstValSpecialRuntime) { | 16978 | if (dest_val->special != ConstValSpecialRuntime) { |
| ... | @@ -16997,7 +16997,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16997,7 +16997,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16997 | } else { | 16997 | } else { |
| 16998 | ir_add_error(ira, source_instr, | 16998 | ir_add_error(ira, source_instr, |
| 16999 | buf_sprintf("cannot store runtime value in compile time variable")); | 16999 | buf_sprintf("cannot store runtime value in compile time variable")); |
| 17000 | ConstExprValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 17000 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); |
| 17001 | dest_val->type = ira->codegen->builtin_types.entry_invalid; | 17001 | dest_val->type = ira->codegen->builtin_types.entry_invalid; |
| 17002 | | 17002 | |
| 17003 | return ira->codegen->invalid_instruction; | 17003 | return ira->codegen->invalid_instruction; |
| ... | @@ -17097,7 +17097,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17097,7 +17097,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17097 | | 17097 | |
| 17098 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; | 17098 | 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) { | 17099 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 17100 | ConstExprValue *arg_tuple_value = &call_instruction->args[i]->child->value; | 17100 | ZigValue *arg_tuple_value = &call_instruction->args[i]->child->value; |
| 17101 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { | 17101 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { |
| 17102 | call_param_count -= 1; | 17102 | call_param_count -= 1; |
| 17103 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - | 17103 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - |
| ... | @@ -17207,7 +17207,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17207,7 +17207,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17207 | } | 17207 | } |
| 17208 | | 17208 | |
| 17209 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); | 17209 | bool cacheable = fn_eval_cacheable(exec_scope, return_type); |
| 17210 | ConstExprValue *result = nullptr; | 17210 | ZigValue *result = nullptr; |
| 17211 | if (cacheable) { | 17211 | if (cacheable) { |
| 17212 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); | 17212 | auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope); |
| 17213 | if (entry) | 17213 | if (entry) |
| ... | @@ -17392,7 +17392,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17392,7 +17392,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17392 | first_var_arg = inst_fn_type_id.param_count; | 17392 | first_var_arg = inst_fn_type_id.param_count; |
| 17393 | } | 17393 | } |
| 17394 | | 17394 | |
| 17395 | ConstExprValue *var_args_val = create_const_arg_tuple(ira->codegen, | 17395 | ZigValue *var_args_val = create_const_arg_tuple(ira->codegen, |
| 17396 | first_var_arg, inst_fn_type_id.param_count); | 17396 | first_var_arg, inst_fn_type_id.param_count); |
| 17397 | ZigVar *var = add_variable(ira->codegen, param_decl_node, | 17397 | 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); | 17398 | impl_fn->child_scope, param_name, true, var_args_val, nullptr, var_args_val->type); |
| ... | @@ -17400,7 +17400,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17400,7 +17400,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17400 | } | 17400 | } |
| 17401 | | 17401 | |
| 17402 | if (fn_proto_node->data.fn_proto.align_expr != nullptr) { | 17402 | if (fn_proto_node->data.fn_proto.align_expr != nullptr) { |
| 17403 | ConstExprValue *align_result = ir_eval_const_value(ira->codegen, impl_fn->child_scope, | 17403 | 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), | 17404 | 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, | 17405 | 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, | 17406 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, |
| ... | @@ -17719,12 +17719,12 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -17719,12 +17719,12 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 17719 | // out_val->type must be the type to read the pointer as | 17719 | // 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 | 17720 | // 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, | 17721 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 17722 | ConstExprValue *out_val, ConstExprValue *ptr_val) | 17722 | ZigValue *out_val, ZigValue *ptr_val) |
| 17723 | { | 17723 | { |
| 17724 | Error err; | 17724 | Error err; |
| 17725 | assert(out_val->type != nullptr); | 17725 | assert(out_val->type != nullptr); |
| 17726 | | 17726 | |
| 17727 | ConstExprValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val); | 17727 | ZigValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val); |
| 17728 | src_assert(pointee->type != nullptr, source_node); | 17728 | src_assert(pointee->type != nullptr, source_node); |
| 17729 | | 17729 | |
| 17730 | if ((err = type_resolve(codegen, pointee->type, ResolveStatusSizeKnown))) | 17730 | if ((err = type_resolve(codegen, pointee->type, ResolveStatusSizeKnown))) |
| ... | @@ -17765,7 +17765,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17765,7 +17765,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17765 | return ErrorSemanticAnalyzeFail; | 17765 | return ErrorSemanticAnalyzeFail; |
| 17766 | } | 17766 | } |
| 17767 | case ConstPtrSpecialBaseArray: { | 17767 | case ConstPtrSpecialBaseArray: { |
| 17768 | ConstExprValue *array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 17768 | ZigValue *array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 17769 | assert(array_val->type->id == ZigTypeIdArray); | 17769 | assert(array_val->type->id == ZigTypeIdArray); |
| 17770 | if (array_val->data.x_array.special != ConstArraySpecialNone) | 17770 | if (array_val->data.x_array.special != ConstArraySpecialNone) |
| 17771 | zig_panic("TODO"); | 17771 | zig_panic("TODO"); |
| ... | @@ -17782,7 +17782,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17782,7 +17782,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17782 | Buf buf = BUF_INIT; | 17782 | Buf buf = BUF_INIT; |
| 17783 | buf_resize(&buf, elem_count * elem_size); | 17783 | buf_resize(&buf, elem_count * elem_size); |
| 17784 | for (size_t i = 0; i < elem_count; i += 1) { | 17784 | 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]; | 17785 | 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); | 17786 | buf_write_value_bytes(codegen, (uint8_t*)buf_ptr(&buf) + (i * elem_size), elem_val); |
| 17787 | } | 17787 | } |
| 17788 | if ((err = buf_read_value_bytes(ira, codegen, source_node, (uint8_t*)buf_ptr(&buf), out_val))) | 17788 | if ((err = buf_read_value_bytes(ira, codegen, source_node, (uint8_t*)buf_ptr(&buf), out_val))) |
| ... | @@ -17818,7 +17818,7 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -17818,7 +17818,7 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp |
| 17818 | } | 17818 | } |
| 17819 | | 17819 | |
| 17820 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *scalar_type, | 17820 | 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) | 17821 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) |
| 17822 | { | 17822 | { |
| 17823 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); | 17823 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); |
| 17824 | | 17824 | |
| ... | @@ -17872,20 +17872,20 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -17872,20 +17872,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; | 17872 | ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; |
| 17873 | | 17873 | |
| 17874 | if (instr_is_comptime(value)) { | 17874 | if (instr_is_comptime(value)) { |
| 17875 | ConstExprValue *operand_val = ir_resolve_const(ira, value, UndefBad); | 17875 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); |
| 17876 | if (!operand_val) | 17876 | if (!operand_val) |
| 17877 | return ira->codegen->invalid_instruction; | 17877 | return ira->codegen->invalid_instruction; |
| 17878 | | 17878 | |
| 17879 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); | 17879 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); |
| 17880 | ConstExprValue *out_val = &result_instruction->value; | 17880 | ZigValue *out_val = &result_instruction->value; |
| 17881 | if (expr_type->id == ZigTypeIdVector) { | 17881 | if (expr_type->id == ZigTypeIdVector) { |
| 17882 | expand_undef_array(ira->codegen, operand_val); | 17882 | expand_undef_array(ira->codegen, operand_val); |
| 17883 | out_val->special = ConstValSpecialUndef; | 17883 | out_val->special = ConstValSpecialUndef; |
| 17884 | expand_undef_array(ira->codegen, out_val); | 17884 | expand_undef_array(ira->codegen, out_val); |
| 17885 | size_t len = expr_type->data.vector.len; | 17885 | size_t len = expr_type->data.vector.len; |
| 17886 | for (size_t i = 0; i < len; i += 1) { | 17886 | for (size_t i = 0; i < len; i += 1) { |
| 17887 | ConstExprValue *scalar_operand_val = &operand_val->data.x_array.data.s_none.elements[i]; | 17887 | 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]; | 17888 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 17889 | assert(scalar_operand_val->type == scalar_type); | 17889 | assert(scalar_operand_val->type == scalar_type); |
| 17890 | assert(scalar_out_val->type == scalar_type); | 17890 | assert(scalar_out_val->type == scalar_type); |
| 17891 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, | 17891 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, |
| ... | @@ -17923,7 +17923,7 @@ static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *inst | ... | @@ -17923,7 +17923,7 @@ static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *inst |
| 17923 | | 17923 | |
| 17924 | if (expr_type->id == ZigTypeIdInt) { | 17924 | if (expr_type->id == ZigTypeIdInt) { |
| 17925 | if (instr_is_comptime(value)) { | 17925 | if (instr_is_comptime(value)) { |
| 17926 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 17926 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 17927 | if (target_const_val == nullptr) | 17927 | if (target_const_val == nullptr) |
| 17928 | return ira->codegen->invalid_instruction; | 17928 | return ira->codegen->invalid_instruction; |
| 17929 | | 17929 | |
| ... | @@ -18361,7 +18361,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18361,7 +18361,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18361 | if (type_is_invalid(array_ptr->value.type)) | 18361 | if (type_is_invalid(array_ptr->value.type)) |
| 18362 | return ira->codegen->invalid_instruction; | 18362 | return ira->codegen->invalid_instruction; |
| 18363 | | 18363 | |
| 18364 | ConstExprValue *orig_array_ptr_val = &array_ptr->value; | 18364 | ZigValue *orig_array_ptr_val = &array_ptr->value; |
| 18365 | | 18365 | |
| 18366 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; | 18366 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; |
| 18367 | if (type_is_invalid(elem_index->value.type)) | 18367 | if (type_is_invalid(elem_index->value.type)) |
| ... | @@ -18428,10 +18428,10 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18428,10 +18428,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, | 18428 | return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index]->type_entry, |
| 18429 | elem_ptr_instruction->ptr_len); | 18429 | elem_ptr_instruction->ptr_len); |
| 18430 | } else if (array_type->id == ZigTypeIdArgTuple) { | 18430 | } else if (array_type->id == ZigTypeIdArgTuple) { |
| 18431 | ConstExprValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); | 18431 | ZigValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); |
| 18432 | if (!ptr_val) | 18432 | if (!ptr_val) |
| 18433 | return ira->codegen->invalid_instruction; | 18433 | return ira->codegen->invalid_instruction; |
| 18434 | ConstExprValue *args_val = const_ptr_pointee(ira, ira->codegen, ptr_val, elem_ptr_instruction->base.source_node); | 18434 | ZigValue *args_val = const_ptr_pointee(ira, ira->codegen, ptr_val, elem_ptr_instruction->base.source_node); |
| 18435 | if (args_val == nullptr) | 18435 | if (args_val == nullptr) |
| 18436 | return ira->codegen->invalid_instruction; | 18436 | return ira->codegen->invalid_instruction; |
| 18437 | size_t start = args_val->data.x_arg_tuple.start_index; | 18437 | size_t start = args_val->data.x_arg_tuple.start_index; |
| ... | @@ -18544,7 +18544,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18544,7 +18544,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18544 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || | 18544 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || |
| 18545 | array_type->id == ZigTypeIdArray)) | 18545 | array_type->id == ZigTypeIdArray)) |
| 18546 | { | 18546 | { |
| 18547 | ConstExprValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 18547 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 18548 | elem_ptr_instruction->base.source_node); | 18548 | elem_ptr_instruction->base.source_node); |
| 18549 | if (array_ptr_val == nullptr) | 18549 | if (array_ptr_val == nullptr) |
| 18550 | return ira->codegen->invalid_instruction; | 18550 | return ira->codegen->invalid_instruction; |
| ... | @@ -18557,7 +18557,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18557,7 +18557,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); | 18557 | array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len); |
| 18558 | array_ptr_val->special = ConstValSpecialStatic; | 18558 | array_ptr_val->special = ConstValSpecialStatic; |
| 18559 | for (size_t i = 0; i < array_type->data.array.len; i += 1) { | 18559 | 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]; | 18560 | ZigValue *elem_val = &array_ptr_val->data.x_array.data.s_none.elements[i]; |
| 18561 | elem_val->special = ConstValSpecialUndef; | 18561 | elem_val->special = ConstValSpecialUndef; |
| 18562 | elem_val->type = array_type->data.array.child_type; | 18562 | elem_val->type = array_type->data.array.child_type; |
| 18563 | elem_val->parent.id = ConstParentIdArray; | 18563 | elem_val->parent.id = ConstParentIdArray; |
| ... | @@ -18576,14 +18576,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18576,14 +18576,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18576 | return ira->codegen->invalid_instruction; | 18576 | return ira->codegen->invalid_instruction; |
| 18577 | } | 18577 | } |
| 18578 | | 18578 | |
| 18579 | ConstExprValue *array_init_val = create_const_vals(1); | 18579 | ZigValue *array_init_val = create_const_vals(1); |
| 18580 | array_init_val->special = ConstValSpecialStatic; | 18580 | array_init_val->special = ConstValSpecialStatic; |
| 18581 | array_init_val->type = actual_array_type; | 18581 | array_init_val->type = actual_array_type; |
| 18582 | array_init_val->data.x_array.special = ConstArraySpecialNone; | 18582 | 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); | 18583 | 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; | 18584 | array_init_val->special = ConstValSpecialStatic; |
| 18585 | for (size_t i = 0; i < actual_array_type->data.array.len; i += 1) { | 18585 | 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]; | 18586 | ZigValue *elem_val = &array_init_val->data.x_array.data.s_none.elements[i]; |
| 18587 | elem_val->special = ConstValSpecialUndef; | 18587 | elem_val->special = ConstValSpecialUndef; |
| 18588 | elem_val->type = actual_array_type->data.array.child_type; | 18588 | elem_val->type = actual_array_type->data.array.child_type; |
| 18589 | elem_val->parent.id = ConstParentIdArray; | 18589 | elem_val->parent.id = ConstParentIdArray; |
| ... | @@ -18608,7 +18608,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18608,7 +18608,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18608 | { | 18608 | { |
| 18609 | if (array_type->id == ZigTypeIdPointer) { | 18609 | if (array_type->id == ZigTypeIdPointer) { |
| 18610 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18610 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18611 | ConstExprValue *out_val = &result->value; | 18611 | ZigValue *out_val = &result->value; |
| 18612 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 18612 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 18613 | size_t new_index; | 18613 | size_t new_index; |
| 18614 | size_t mem_size; | 18614 | size_t mem_size; |
| ... | @@ -18619,7 +18619,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18619,7 +18619,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18619 | zig_unreachable(); | 18619 | zig_unreachable(); |
| 18620 | case ConstPtrSpecialRef: | 18620 | case ConstPtrSpecialRef: |
| 18621 | if (array_ptr_val->data.x_ptr.data.ref.pointee->type->id == ZigTypeIdArray) { | 18621 | 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; | 18622 | ZigValue *array_val = array_ptr_val->data.x_ptr.data.ref.pointee; |
| 18623 | new_index = index; | 18623 | new_index = index; |
| 18624 | ZigType *array_type = array_val->type; | 18624 | ZigType *array_type = array_val->type; |
| 18625 | mem_size = array_type->data.array.len; | 18625 | mem_size = array_type->data.array.len; |
| ... | @@ -18682,7 +18682,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18682,7 +18682,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18682 | } | 18682 | } |
| 18683 | return result; | 18683 | return result; |
| 18684 | } else if (is_slice(array_type)) { | 18684 | } else if (is_slice(array_type)) { |
| 18685 | ConstExprValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; | 18685 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 18686 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); | 18686 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); |
| 18687 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 18687 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 18688 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18688 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| ... | @@ -18691,9 +18691,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18691,9 +18691,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18691 | result->value.type = return_type; | 18691 | result->value.type = return_type; |
| 18692 | return result; | 18692 | return result; |
| 18693 | } | 18693 | } |
| 18694 | ConstExprValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; | 18694 | 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); | 18695 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18696 | ConstExprValue *out_val = &result->value; | 18696 | ZigValue *out_val = &result->value; |
| 18697 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; | 18697 | 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); | 18698 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 18699 | uint64_t full_slice_len = slice_len + | 18699 | uint64_t full_slice_len = slice_len + |
| ... | @@ -18757,7 +18757,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18757,7 +18757,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18757 | } else { | 18757 | } else { |
| 18758 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18758 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18759 | } | 18759 | } |
| 18760 | ConstExprValue *out_val = &result->value; | 18760 | ZigValue *out_val = &result->value; |
| 18761 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 18761 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 18762 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; | 18762 | 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; | 18763 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; |
| ... | @@ -18915,12 +18915,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18915,12 +18915,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18915 | (uint32_t)host_int_bytes_for_result_type, false); | 18915 | (uint32_t)host_int_bytes_for_result_type, false); |
| 18916 | } | 18916 | } |
| 18917 | if (instr_is_comptime(struct_ptr)) { | 18917 | if (instr_is_comptime(struct_ptr)) { |
| 18918 | ConstExprValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); | 18918 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); |
| 18919 | if (!ptr_val) | 18919 | if (!ptr_val) |
| 18920 | return ira->codegen->invalid_instruction; | 18920 | return ira->codegen->invalid_instruction; |
| 18921 | | 18921 | |
| 18922 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 18922 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 18923 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 18923 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 18924 | if (struct_val == nullptr) | 18924 | if (struct_val == nullptr) |
| 18925 | return ira->codegen->invalid_instruction; | 18925 | return ira->codegen->invalid_instruction; |
| 18926 | if (type_is_invalid(struct_val->type)) | 18926 | if (type_is_invalid(struct_val->type)) |
| ... | @@ -18929,7 +18929,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18929,7 +18929,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); | 18929 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 18930 | struct_val->special = ConstValSpecialStatic; | 18930 | struct_val->special = ConstValSpecialStatic; |
| 18931 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { | 18931 | 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]; | 18932 | ZigValue *field_val = struct_val->data.x_struct.fields[i]; |
| 18933 | field_val->special = ConstValSpecialUndef; | 18933 | field_val->special = ConstValSpecialUndef; |
| 18934 | field_val->type = resolve_struct_field_type(ira->codegen, | 18934 | field_val->type = resolve_struct_field_type(ira->codegen, |
| 18935 | struct_type->data.structure.fields[i]); | 18935 | struct_type->data.structure.fields[i]); |
| ... | @@ -18947,7 +18947,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18947,7 +18947,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18947 | } else { | 18947 | } else { |
| 18948 | result = ir_const(ira, source_instr, ptr_type); | 18948 | result = ir_const(ira, source_instr, ptr_type); |
| 18949 | } | 18949 | } |
| 18950 | ConstExprValue *const_val = &result->value; | 18950 | ZigValue *const_val = &result->value; |
| 18951 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; | 18951 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; |
| 18952 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 18952 | 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; | 18953 | const_val->data.x_ptr.data.base_struct.struct_val = struct_val; |
| ... | @@ -19044,20 +19044,20 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19044,20 +19044,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, | 19044 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| 19045 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 19045 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 19046 | if (instr_is_comptime(container_ptr)) { | 19046 | if (instr_is_comptime(container_ptr)) { |
| 19047 | ConstExprValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19047 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19048 | if (!ptr_val) | 19048 | if (!ptr_val) |
| 19049 | return ira->codegen->invalid_instruction; | 19049 | return ira->codegen->invalid_instruction; |
| 19050 | | 19050 | |
| 19051 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 19051 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 19052 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 19052 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 19053 | ConstExprValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 19053 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 19054 | if (union_val == nullptr) | 19054 | if (union_val == nullptr) |
| 19055 | return ira->codegen->invalid_instruction; | 19055 | return ira->codegen->invalid_instruction; |
| 19056 | if (type_is_invalid(union_val->type)) | 19056 | if (type_is_invalid(union_val->type)) |
| 19057 | return ira->codegen->invalid_instruction; | 19057 | return ira->codegen->invalid_instruction; |
| 19058 | | 19058 | |
| 19059 | if (initializing) { | 19059 | if (initializing) { |
| 19060 | ConstExprValue *payload_val = create_const_vals(1); | 19060 | ZigValue *payload_val = create_const_vals(1); |
| 19061 | payload_val->special = ConstValSpecialUndef; | 19061 | payload_val->special = ConstValSpecialUndef; |
| 19062 | payload_val->type = field_type; | 19062 | payload_val->type = field_type; |
| 19063 | payload_val->parent.id = ConstParentIdUnion; | 19063 | payload_val->parent.id = ConstParentIdUnion; |
| ... | @@ -19079,7 +19079,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19079,7 +19079,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19079 | } | 19079 | } |
| 19080 | } | 19080 | } |
| 19081 | | 19081 | |
| 19082 | ConstExprValue *payload_val = union_val->data.x_union.payload; | 19082 | ZigValue *payload_val = union_val->data.x_union.payload; |
| 19083 | | 19083 | |
| 19084 | IrInstruction *result; | 19084 | IrInstruction *result; |
| 19085 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 19085 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| ... | @@ -19090,7 +19090,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19090,7 +19090,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19090 | } else { | 19090 | } else { |
| 19091 | result = ir_const(ira, source_instr, ptr_type); | 19091 | result = ir_const(ira, source_instr, ptr_type); |
| 19092 | } | 19092 | } |
| 19093 | ConstExprValue *const_val = &result->value; | 19093 | ZigValue *const_val = &result->value; |
| 19094 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 19094 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 19095 | const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut; | 19095 | const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut; |
| 19096 | const_val->data.x_ptr.data.ref.pointee = payload_val; | 19096 | const_val->data.x_ptr.data.ref.pointee = payload_val; |
| ... | @@ -19236,7 +19236,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19236,7 +19236,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19236 | } | 19236 | } |
| 19237 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { | 19237 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| 19238 | if (buf_eql_str(field_name, "len")) { | 19238 | if (buf_eql_str(field_name, "len")) { |
| 19239 | ConstExprValue *len_val = create_const_vals(1); | 19239 | ZigValue *len_val = create_const_vals(1); |
| 19240 | if (container_type->id == ZigTypeIdPointer) { | 19240 | if (container_type->id == ZigTypeIdPointer) { |
| 19241 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); | 19241 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); |
| 19242 | } else { | 19242 | } else { |
| ... | @@ -19255,17 +19255,17 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19255,17 +19255,17 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19255 | return ira->codegen->invalid_instruction; | 19255 | return ira->codegen->invalid_instruction; |
| 19256 | } | 19256 | } |
| 19257 | } else if (container_type->id == ZigTypeIdArgTuple) { | 19257 | } else if (container_type->id == ZigTypeIdArgTuple) { |
| 19258 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19258 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19259 | if (!container_ptr_val) | 19259 | if (!container_ptr_val) |
| 19260 | return ira->codegen->invalid_instruction; | 19260 | return ira->codegen->invalid_instruction; |
| 19261 | | 19261 | |
| 19262 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19262 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 19263 | ConstExprValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19263 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19264 | if (child_val == nullptr) | 19264 | if (child_val == nullptr) |
| 19265 | return ira->codegen->invalid_instruction; | 19265 | return ira->codegen->invalid_instruction; |
| 19266 | | 19266 | |
| 19267 | if (buf_eql_str(field_name, "len")) { | 19267 | if (buf_eql_str(field_name, "len")) { |
| 19268 | ConstExprValue *len_val = create_const_vals(1); | 19268 | 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; | 19269 | 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); | 19270 | init_const_usize(ira->codegen, len_val, len); |
| 19271 | | 19271 | |
| ... | @@ -19281,12 +19281,12 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19281,12 +19281,12 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19281 | return ira->codegen->invalid_instruction; | 19281 | return ira->codegen->invalid_instruction; |
| 19282 | } | 19282 | } |
| 19283 | } else if (container_type->id == ZigTypeIdMetaType) { | 19283 | } else if (container_type->id == ZigTypeIdMetaType) { |
| 19284 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 19284 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 19285 | if (!container_ptr_val) | 19285 | if (!container_ptr_val) |
| 19286 | return ira->codegen->invalid_instruction; | 19286 | return ira->codegen->invalid_instruction; |
| 19287 | | 19287 | |
| 19288 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19288 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 19289 | ConstExprValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19289 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19290 | if (child_val == nullptr) | 19290 | if (child_val == nullptr) |
| 19291 | return ira->codegen->invalid_instruction; | 19291 | return ira->codegen->invalid_instruction; |
| 19292 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 19292 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| ... | @@ -19382,7 +19382,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19382,7 +19382,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19382 | } | 19382 | } |
| 19383 | err_set_type = child_type; | 19383 | err_set_type = child_type; |
| 19384 | } | 19384 | } |
| 19385 | ConstExprValue *const_val = create_const_vals(1); | 19385 | ZigValue *const_val = create_const_vals(1); |
| 19386 | const_val->special = ConstValSpecialStatic; | 19386 | const_val->special = ConstValSpecialStatic; |
| 19387 | const_val->type = err_set_type; | 19387 | const_val->type = err_set_type; |
| 19388 | const_val->data.x_err_set = err_entry; | 19388 | const_val->data.x_err_set = err_entry; |
| ... | @@ -19850,7 +19850,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -19850,7 +19850,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19850 | if (type_is_invalid(child_type)) | 19850 | if (type_is_invalid(child_type)) |
| 19851 | return ira->codegen->invalid_instruction; | 19851 | return ira->codegen->invalid_instruction; |
| 19852 | | 19852 | |
| 19853 | ConstExprValue *sentinel_val; | 19853 | ZigValue *sentinel_val; |
| 19854 | if (array_type_instruction->sentinel != nullptr) { | 19854 | if (array_type_instruction->sentinel != nullptr) { |
| 19855 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; | 19855 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; |
| 19856 | if (type_is_invalid(uncasted_sentinel->value.type)) | 19856 | if (type_is_invalid(uncasted_sentinel->value.type)) |
| ... | @@ -19928,7 +19928,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19928,7 +19928,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19928 | | 19928 | |
| 19929 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { | 19929 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| 19930 | if (instr_is_comptime(value)) { | 19930 | if (instr_is_comptime(value)) { |
| 19931 | ConstExprValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); | 19931 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); |
| 19932 | if (c_ptr_val == nullptr) | 19932 | if (c_ptr_val == nullptr) |
| 19933 | return ira->codegen->invalid_instruction; | 19933 | return ira->codegen->invalid_instruction; |
| 19934 | if (c_ptr_val->special == ConstValSpecialUndef) | 19934 | if (c_ptr_val->special == ConstValSpecialUndef) |
| ... | @@ -19945,7 +19945,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19945,7 +19945,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19945 | return result; | 19945 | return result; |
| 19946 | } else if (type_entry->id == ZigTypeIdOptional) { | 19946 | } else if (type_entry->id == ZigTypeIdOptional) { |
| 19947 | if (instr_is_comptime(value)) { | 19947 | if (instr_is_comptime(value)) { |
| 19948 | ConstExprValue *maybe_val = ir_resolve_const(ira, value, UndefOk); | 19948 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); |
| 19949 | if (maybe_val == nullptr) | 19949 | if (maybe_val == nullptr) |
| 19950 | return ira->codegen->invalid_instruction; | 19950 | return ira->codegen->invalid_instruction; |
| 19951 | if (maybe_val->special == ConstValSpecialUndef) | 19951 | if (maybe_val->special == ConstValSpecialUndef) |
| ... | @@ -19983,7 +19983,7 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | ... | @@ -19983,7 +19983,7 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { |
| 19983 | return g->builtin_types.entry_invalid; | 19983 | return g->builtin_types.entry_invalid; |
| 19984 | | 19984 | |
| 19985 | assert(value_is_comptime(&ptr->value)); | 19985 | assert(value_is_comptime(&ptr->value)); |
| 19986 | ConstExprValue *pointee = const_ptr_pointee_unchecked(g, &ptr->value); | 19986 | ZigValue *pointee = const_ptr_pointee_unchecked(g, &ptr->value); |
| 19987 | return pointee->type; | 19987 | return pointee->type; |
| 19988 | } | 19988 | } |
| 19989 | | 19989 | |
| ... | @@ -19996,11 +19996,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -19996,11 +19996,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 19996 | | 19996 | |
| 19997 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { | 19997 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { |
| 19998 | if (instr_is_comptime(base_ptr)) { | 19998 | if (instr_is_comptime(base_ptr)) { |
| 19999 | ConstExprValue *val = ir_resolve_const(ira, base_ptr, UndefBad); | 19999 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 20000 | if (!val) | 20000 | if (!val) |
| 20001 | return ira->codegen->invalid_instruction; | 20001 | return ira->codegen->invalid_instruction; |
| 20002 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20002 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20003 | ConstExprValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 20003 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 20004 | if (c_ptr_val == nullptr) | 20004 | if (c_ptr_val == nullptr) |
| 20005 | return ira->codegen->invalid_instruction; | 20005 | return ira->codegen->invalid_instruction; |
| 20006 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 20006 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -20034,11 +20034,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20034,11 +20034,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20034 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); | 20034 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); |
| 20035 | | 20035 | |
| 20036 | if (instr_is_comptime(base_ptr)) { | 20036 | if (instr_is_comptime(base_ptr)) { |
| 20037 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 20037 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 20038 | if (!ptr_val) | 20038 | if (!ptr_val) |
| 20039 | return ira->codegen->invalid_instruction; | 20039 | return ira->codegen->invalid_instruction; |
| 20040 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20040 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20041 | ConstExprValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 20041 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20042 | if (optional_val == nullptr) | 20042 | if (optional_val == nullptr) |
| 20043 | return ira->codegen->invalid_instruction; | 20043 | return ira->codegen->invalid_instruction; |
| 20044 | | 20044 | |
| ... | @@ -20048,7 +20048,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20048,7 +20048,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20048 | return ira->codegen->invalid_instruction; | 20048 | return ira->codegen->invalid_instruction; |
| 20049 | case OnePossibleValueNo: | 20049 | case OnePossibleValueNo: |
| 20050 | if (!same_comptime_repr) { | 20050 | if (!same_comptime_repr) { |
| 20051 | ConstExprValue *payload_val = create_const_vals(1); | 20051 | ZigValue *payload_val = create_const_vals(1); |
| 20052 | payload_val->type = child_type; | 20052 | payload_val->type = child_type; |
| 20053 | payload_val->special = ConstValSpecialUndef; | 20053 | payload_val->special = ConstValSpecialUndef; |
| 20054 | payload_val->parent.id = ConstParentIdOptionalPayload; | 20054 | payload_val->parent.id = ConstParentIdOptionalPayload; |
| ... | @@ -20059,7 +20059,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20059,7 +20059,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20059 | } | 20059 | } |
| 20060 | break; | 20060 | break; |
| 20061 | case OnePossibleValueYes: { | 20061 | case OnePossibleValueYes: { |
| 20062 | ConstExprValue *pointee = create_const_vals(1); | 20062 | ZigValue *pointee = create_const_vals(1); |
| 20063 | pointee->special = ConstValSpecialStatic; | 20063 | pointee->special = ConstValSpecialStatic; |
| 20064 | pointee->type = child_type; | 20064 | pointee->type = child_type; |
| 20065 | pointee->parent.id = ConstParentIdOptionalPayload; | 20065 | pointee->parent.id = ConstParentIdOptionalPayload; |
| ... | @@ -20084,7 +20084,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20084,7 +20084,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20084 | } else { | 20084 | } else { |
| 20085 | result = ir_const(ira, source_instr, result_type); | 20085 | result = ir_const(ira, source_instr, result_type); |
| 20086 | } | 20086 | } |
| 20087 | ConstExprValue *result_val = &result->value; | 20087 | ZigValue *result_val = &result->value; |
| 20088 | result_val->data.x_ptr.special = ConstPtrSpecialRef; | 20088 | result_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20089 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 20089 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 20090 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 20090 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| ... | @@ -20137,7 +20137,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt | ... | @@ -20137,7 +20137,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt |
| 20137 | return ir_const_unsigned(ira, &instruction->base, 0); | 20137 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20138 | | 20138 | |
| 20139 | if (instr_is_comptime(op)) { | 20139 | if (instr_is_comptime(op)) { |
| 20140 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20140 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20141 | if (val == nullptr) | 20141 | if (val == nullptr) |
| 20142 | return ira->codegen->invalid_instruction; | 20142 | return ira->codegen->invalid_instruction; |
| 20143 | if (val->special == ConstValSpecialUndef) | 20143 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -20166,7 +20166,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl | ... | @@ -20166,7 +20166,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl |
| 20166 | return ir_const_unsigned(ira, &instruction->base, 0); | 20166 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20167 | | 20167 | |
| 20168 | if (instr_is_comptime(op)) { | 20168 | if (instr_is_comptime(op)) { |
| 20169 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20169 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20170 | if (val == nullptr) | 20170 | if (val == nullptr) |
| 20171 | return ira->codegen->invalid_instruction; | 20171 | return ira->codegen->invalid_instruction; |
| 20172 | if (val->special == ConstValSpecialUndef) | 20172 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -20195,7 +20195,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc | ... | @@ -20195,7 +20195,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20195 | return ir_const_unsigned(ira, &instruction->base, 0); | 20195 | return ir_const_unsigned(ira, &instruction->base, 0); |
| 20196 | | 20196 | |
| 20197 | if (instr_is_comptime(op)) { | 20197 | if (instr_is_comptime(op)) { |
| 20198 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 20198 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 20199 | if (val == nullptr) | 20199 | if (val == nullptr) |
| 20200 | return ira->codegen->invalid_instruction; | 20200 | return ira->codegen->invalid_instruction; |
| 20201 | if (val->special == ConstValSpecialUndef) | 20201 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -20242,7 +20242,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -20242,7 +20242,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 20242 | assert(tag_type->id == ZigTypeIdEnum); | 20242 | assert(tag_type->id == ZigTypeIdEnum); |
| 20243 | | 20243 | |
| 20244 | if (instr_is_comptime(value)) { | 20244 | if (instr_is_comptime(value)) { |
| 20245 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 20245 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 20246 | if (!val) | 20246 | if (!val) |
| 20247 | return ira->codegen->invalid_instruction; | 20247 | return ira->codegen->invalid_instruction; |
| 20248 | | 20248 | |
| ... | @@ -20280,7 +20280,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20280,7 +20280,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20280 | return ira->codegen->invalid_instruction; | 20280 | return ira->codegen->invalid_instruction; |
| 20281 | | 20281 | |
| 20282 | if (is_comptime || instr_is_comptime(target_value)) { | 20282 | if (is_comptime || instr_is_comptime(target_value)) { |
| 20283 | ConstExprValue *target_val = ir_resolve_const(ira, target_value, UndefBad); | 20283 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); |
| 20284 | if (!target_val) | 20284 | if (!target_val) |
| 20285 | return ir_unreach_error(ira); | 20285 | return ir_unreach_error(ira); |
| 20286 | | 20286 | |
| ... | @@ -20301,7 +20301,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20301,7 +20301,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20301 | if (type_is_invalid(casted_case_value->value.type)) | 20301 | if (type_is_invalid(casted_case_value->value.type)) |
| 20302 | return ir_unreach_error(ira); | 20302 | return ir_unreach_error(ira); |
| 20303 | | 20303 | |
| 20304 | ConstExprValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); | 20304 | ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); |
| 20305 | if (!case_val) | 20305 | if (!case_val) |
| 20306 | return ir_unreach_error(ira); | 20306 | return ir_unreach_error(ira); |
| 20307 | | 20307 | |
| ... | @@ -20388,7 +20388,7 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20388,7 +20388,7 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20388 | } | 20388 | } |
| 20389 | | 20389 | |
| 20390 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20390 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; |
| 20391 | ConstExprValue *pointee_val = nullptr; | 20391 | ZigValue *pointee_val = nullptr; |
| 20392 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20392 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20393 | pointee_val = const_ptr_pointee(ira, ira->codegen, &target_value_ptr->value, target_value_ptr->source_node); | 20393 | pointee_val = const_ptr_pointee(ira, ira->codegen, &target_value_ptr->value, target_value_ptr->source_node); |
| 20394 | if (pointee_val == nullptr) | 20394 | if (pointee_val == nullptr) |
| ... | @@ -20521,7 +20521,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20521,7 +20521,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20521 | if (type_is_invalid(first_casted_prong_value->value.type)) | 20521 | if (type_is_invalid(first_casted_prong_value->value.type)) |
| 20522 | return ira->codegen->invalid_instruction; | 20522 | return ira->codegen->invalid_instruction; |
| 20523 | | 20523 | |
| 20524 | ConstExprValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); | 20524 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); |
| 20525 | if (first_prong_val == nullptr) | 20525 | if (first_prong_val == nullptr) |
| 20526 | return ira->codegen->invalid_instruction; | 20526 | return ira->codegen->invalid_instruction; |
| 20527 | | 20527 | |
| ... | @@ -20537,7 +20537,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20537,7 +20537,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20537 | if (type_is_invalid(this_casted_prong_value->value.type)) | 20537 | if (type_is_invalid(this_casted_prong_value->value.type)) |
| 20538 | return ira->codegen->invalid_instruction; | 20538 | return ira->codegen->invalid_instruction; |
| 20539 | | 20539 | |
| 20540 | ConstExprValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); | 20540 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); |
| 20541 | if (this_prong == nullptr) | 20541 | if (this_prong == nullptr) |
| 20542 | return ira->codegen->invalid_instruction; | 20542 | return ira->codegen->invalid_instruction; |
| 20543 | | 20543 | |
| ... | @@ -20560,18 +20560,18 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20560,18 +20560,18 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20560 | } | 20560 | } |
| 20561 | | 20561 | |
| 20562 | if (instr_is_comptime(target_value_ptr)) { | 20562 | if (instr_is_comptime(target_value_ptr)) { |
| 20563 | ConstExprValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); | 20563 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); |
| 20564 | if (!target_value_ptr) | 20564 | if (!target_value_ptr) |
| 20565 | return ira->codegen->invalid_instruction; | 20565 | return ira->codegen->invalid_instruction; |
| 20566 | | 20566 | |
| 20567 | ConstExprValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); | 20567 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); |
| 20568 | if (pointee_val == nullptr) | 20568 | if (pointee_val == nullptr) |
| 20569 | return ira->codegen->invalid_instruction; | 20569 | return ira->codegen->invalid_instruction; |
| 20570 | | 20570 | |
| 20571 | IrInstruction *result = ir_const(ira, &instruction->base, | 20571 | IrInstruction *result = ir_const(ira, &instruction->base, |
| 20572 | get_pointer_to_type(ira->codegen, first_field->type_entry, | 20572 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 20573 | target_val_ptr->type->data.pointer.is_const)); | 20573 | target_val_ptr->type->data.pointer.is_const)); |
| 20574 | ConstExprValue *out_val = &result->value; | 20574 | ZigValue *out_val = &result->value; |
| 20575 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 20575 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20576 | out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut; | 20576 | 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; | 20577 | out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload; |
| ... | @@ -21161,12 +21161,12 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -21161,12 +21161,12 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 21161 | true, false, PtrLenUnknown, 0, 0, 0, false); | 21161 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 21162 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 21162 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 21163 | if (instr_is_comptime(casted_value)) { | 21163 | if (instr_is_comptime(casted_value)) { |
| 21164 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 21164 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 21165 | if (val == nullptr) | 21165 | if (val == nullptr) |
| 21166 | return ira->codegen->invalid_instruction; | 21166 | return ira->codegen->invalid_instruction; |
| 21167 | ErrorTableEntry *err = casted_value->value.data.x_err_set; | 21167 | ErrorTableEntry *err = casted_value->value.data.x_err_set; |
| 21168 | if (!err->cached_error_name_val) { | 21168 | if (!err->cached_error_name_val) { |
| 21169 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 21169 | 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); | 21170 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 21171 | } | 21171 | } |
| 21172 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 21172 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| ... | @@ -21195,7 +21195,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -21195,7 +21195,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 21195 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) | 21195 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) |
| 21196 | return ira->codegen->invalid_instruction; | 21196 | return ira->codegen->invalid_instruction; |
| 21197 | TypeEnumField *field = find_enum_field_by_tag(target->value.type, &target->value.data.x_bigint); | 21197 | 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; | 21198 | 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); | 21199 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 21200 | init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true); | 21200 | init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true); |
| 21201 | return result; | 21201 | return result; |
| ... | @@ -21272,7 +21272,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21272,7 +21272,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21272 | parent_ptr_align, 0, 0, false); | 21272 | parent_ptr_align, 0, 0, false); |
| 21273 | | 21273 | |
| 21274 | if (instr_is_comptime(casted_field_ptr)) { | 21274 | if (instr_is_comptime(casted_field_ptr)) { |
| 21275 | ConstExprValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); | 21275 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); |
| 21276 | if (!field_ptr_val) | 21276 | if (!field_ptr_val) |
| 21277 | return ira->codegen->invalid_instruction; | 21277 | return ira->codegen->invalid_instruction; |
| 21278 | | 21278 | |
| ... | @@ -21291,7 +21291,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21291,7 +21291,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21291 | } | 21291 | } |
| 21292 | | 21292 | |
| 21293 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 21293 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 21294 | ConstExprValue *out_val = &result->value; | 21294 | ZigValue *out_val = &result->value; |
| 21295 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 21295 | 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; | 21296 | 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; | 21297 | out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut; |
| ... | @@ -21390,7 +21390,7 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind | ... | @@ -21390,7 +21390,7 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind |
| 21390 | | 21390 | |
| 21391 | static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) { | 21391 | static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) { |
| 21392 | Error err; | 21392 | Error err; |
| 21393 | ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); | 21393 | ZigValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); |
| 21394 | assert(type_info_var->type->id == ZigTypeIdMetaType); | 21394 | assert(type_info_var->type->id == ZigTypeIdMetaType); |
| 21395 | ZigType *type_info_type = type_info_var->data.x_type; | 21395 | ZigType *type_info_type = type_info_var->data.x_type; |
| 21396 | assert(type_info_type->id == ZigTypeIdUnion); | 21396 | assert(type_info_type->id == ZigTypeIdUnion); |
| ... | @@ -21423,7 +21423,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -21423,7 +21423,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); | 21423 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); |
| 21424 | } | 21424 | } |
| 21425 | | 21425 | |
| 21426 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *out_val, | 21426 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *out_val, |
| 21427 | ScopeDecls *decls_scope) | 21427 | ScopeDecls *decls_scope) |
| 21428 | { | 21428 | { |
| 21429 | Error err; | 21429 | Error err; |
| ... | @@ -21473,7 +21473,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21473,7 +21473,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21473 | } | 21473 | } |
| 21474 | } | 21474 | } |
| 21475 | | 21475 | |
| 21476 | ConstExprValue *declaration_array = create_const_vals(1); | 21476 | ZigValue *declaration_array = create_const_vals(1); |
| 21477 | declaration_array->special = ConstValSpecialStatic; | 21477 | declaration_array->special = ConstValSpecialStatic; |
| 21478 | declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); | 21478 | declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr); |
| 21479 | declaration_array->data.x_array.special = ConstArraySpecialNone; | 21479 | declaration_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -21494,13 +21494,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21494,13 +21494,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21494 | continue; | 21494 | continue; |
| 21495 | } | 21495 | } |
| 21496 | | 21496 | |
| 21497 | ConstExprValue *declaration_val = &declaration_array->data.x_array.data.s_none.elements[declaration_index]; | 21497 | ZigValue *declaration_val = &declaration_array->data.x_array.data.s_none.elements[declaration_index]; |
| 21498 | | 21498 | |
| 21499 | declaration_val->special = ConstValSpecialStatic; | 21499 | declaration_val->special = ConstValSpecialStatic; |
| 21500 | declaration_val->type = type_info_declaration_type; | 21500 | declaration_val->type = type_info_declaration_type; |
| 21501 | | 21501 | |
| 21502 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 21502 | 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; | 21503 | 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); | 21504 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); |
| 21505 | inner_fields[1]->special = ConstValSpecialStatic; | 21505 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21506 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; | 21506 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| ... | @@ -21528,7 +21528,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21528,7 +21528,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21528 | // 1: Data.Var: type | 21528 | // 1: Data.Var: type |
| 21529 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); | 21529 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); |
| 21530 | | 21530 | |
| 21531 | ConstExprValue *payload = create_const_vals(1); | 21531 | ZigValue *payload = create_const_vals(1); |
| 21532 | payload->special = ConstValSpecialStatic; | 21532 | payload->special = ConstValSpecialStatic; |
| 21533 | payload->type = ira->codegen->builtin_types.entry_type; | 21533 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21534 | payload->data.x_type = var->const_value->type; | 21534 | payload->data.x_type = var->const_value->type; |
| ... | @@ -21553,13 +21553,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21553,13 +21553,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21553 | | 21553 | |
| 21554 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; | 21554 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; |
| 21555 | | 21555 | |
| 21556 | ConstExprValue *fn_decl_val = create_const_vals(1); | 21556 | ZigValue *fn_decl_val = create_const_vals(1); |
| 21557 | fn_decl_val->special = ConstValSpecialStatic; | 21557 | fn_decl_val->special = ConstValSpecialStatic; |
| 21558 | fn_decl_val->type = type_info_fn_decl_type; | 21558 | fn_decl_val->type = type_info_fn_decl_type; |
| 21559 | fn_decl_val->parent.id = ConstParentIdUnion; | 21559 | fn_decl_val->parent.id = ConstParentIdUnion; |
| 21560 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; | 21560 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; |
| 21561 | | 21561 | |
| 21562 | ConstExprValue **fn_decl_fields = alloc_const_vals_ptrs(9); | 21562 | ZigValue **fn_decl_fields = alloc_const_vals_ptrs(9); |
| 21563 | fn_decl_val->data.x_struct.fields = fn_decl_fields; | 21563 | fn_decl_val->data.x_struct.fields = fn_decl_fields; |
| 21564 | | 21564 | |
| 21565 | // fn_type: type | 21565 | // fn_type: type |
| ... | @@ -21603,7 +21603,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21603,7 +21603,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)); | 21603 | 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) { | 21604 | 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); | 21605 | 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; | 21606 | 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, | 21607 | init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0, |
| 21608 | buf_len(fn_node->lib_name), true); | 21608 | buf_len(fn_node->lib_name), true); |
| 21609 | } else { | 21609 | } else { |
| ... | @@ -21617,7 +21617,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21617,7 +21617,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21617 | // arg_names: [][] const u8 | 21617 | // arg_names: [][] const u8 |
| 21618 | ensure_field_index(fn_decl_val->type, "arg_names", 8); | 21618 | ensure_field_index(fn_decl_val->type, "arg_names", 8); |
| 21619 | size_t fn_arg_count = fn_entry->variable_list.length; | 21619 | size_t fn_arg_count = fn_entry->variable_list.length; |
| 21620 | ConstExprValue *fn_arg_name_array = create_const_vals(1); | 21620 | ZigValue *fn_arg_name_array = create_const_vals(1); |
| 21621 | fn_arg_name_array->special = ConstValSpecialStatic; | 21621 | fn_arg_name_array->special = ConstValSpecialStatic; |
| 21622 | fn_arg_name_array->type = get_array_type(ira->codegen, | 21622 | fn_arg_name_array->type = get_array_type(ira->codegen, |
| 21623 | get_slice_type(ira->codegen, u8_ptr), fn_arg_count, nullptr); | 21623 | get_slice_type(ira->codegen, u8_ptr), fn_arg_count, nullptr); |
| ... | @@ -21628,8 +21628,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21628,8 +21628,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21628 | | 21628 | |
| 21629 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 21629 | 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); | 21630 | 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]; | 21631 | 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, | 21632 | ZigValue *arg_name = create_const_str_lit(ira->codegen, |
| 21633 | buf_create_from_str(arg_var->name))->data.x_ptr.data.ref.pointee; | 21633 | 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); | 21634 | 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; | 21635 | fn_arg_name_val->parent.id = ConstParentIdArray; |
| ... | @@ -21649,7 +21649,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21649,7 +21649,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21649 | // This is a type. | 21649 | // This is a type. |
| 21650 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); | 21650 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); |
| 21651 | | 21651 | |
| 21652 | ConstExprValue *payload = create_const_vals(1); | 21652 | ZigValue *payload = create_const_vals(1); |
| 21653 | payload->special = ConstValSpecialStatic; | 21653 | payload->special = ConstValSpecialStatic; |
| 21654 | payload->type = ira->codegen->builtin_types.entry_type; | 21654 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21655 | payload->data.x_type = type_entry; | 21655 | payload->data.x_type = type_entry; |
| ... | @@ -21695,7 +21695,7 @@ static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) { | ... | @@ -21695,7 +21695,7 @@ static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) { |
| 21695 | zig_unreachable(); | 21695 | zig_unreachable(); |
| 21696 | } | 21696 | } |
| 21697 | | 21697 | |
| 21698 | static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) { | 21698 | static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) { |
| 21699 | Error err; | 21699 | Error err; |
| 21700 | ZigType *attrs_type; | 21700 | ZigType *attrs_type; |
| 21701 | BuiltinPtrSize size_enum_index; | 21701 | BuiltinPtrSize size_enum_index; |
| ... | @@ -21715,11 +21715,11 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -21715,11 +21715,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); | 21715 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 21716 | assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown)); | 21716 | assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown)); |
| 21717 | | 21717 | |
| 21718 | ConstExprValue *result = create_const_vals(1); | 21718 | ZigValue *result = create_const_vals(1); |
| 21719 | result->special = ConstValSpecialStatic; | 21719 | result->special = ConstValSpecialStatic; |
| 21720 | result->type = type_info_pointer_type; | 21720 | result->type = type_info_pointer_type; |
| 21721 | | 21721 | |
| 21722 | ConstExprValue **fields = alloc_const_vals_ptrs(7); | 21722 | ZigValue **fields = alloc_const_vals_ptrs(7); |
| 21723 | result->data.x_struct.fields = fields; | 21723 | result->data.x_struct.fields = fields; |
| 21724 | | 21724 | |
| 21725 | // size: Size | 21725 | // size: Size |
| ... | @@ -21769,17 +21769,17 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -21769,17 +21769,17 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty |
| 21769 | return result; | 21769 | return result; |
| 21770 | }; | 21770 | }; |
| 21771 | | 21771 | |
| 21772 | static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field, | 21772 | static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEnumField *enum_field, |
| 21773 | ZigType *type_info_enum_field_type) | 21773 | ZigType *type_info_enum_field_type) |
| 21774 | { | 21774 | { |
| 21775 | enum_field_val->special = ConstValSpecialStatic; | 21775 | enum_field_val->special = ConstValSpecialStatic; |
| 21776 | enum_field_val->type = type_info_enum_field_type; | 21776 | enum_field_val->type = type_info_enum_field_type; |
| 21777 | | 21777 | |
| 21778 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); | 21778 | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 21779 | inner_fields[1]->special = ConstValSpecialStatic; | 21779 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21780 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; | 21780 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21781 | | 21781 | |
| 21782 | ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name)->data.x_ptr.data.ref.pointee; | 21782 | 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); | 21783 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true); |
| 21784 | | 21784 | |
| 21785 | bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); | 21785 | bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); |
| ... | @@ -21788,7 +21788,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, | ... | @@ -21788,7 +21788,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, |
| 21788 | } | 21788 | } |
| 21789 | | 21789 | |
| 21790 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 21790 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, |
| 21791 | ConstExprValue **out) | 21791 | ZigValue **out) |
| 21792 | { | 21792 | { |
| 21793 | Error err; | 21793 | Error err; |
| 21794 | assert(type_entry != nullptr); | 21794 | assert(type_entry != nullptr); |
| ... | @@ -21803,7 +21803,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21803,7 +21803,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21803 | return ErrorNone; | 21803 | return ErrorNone; |
| 21804 | } | 21804 | } |
| 21805 | | 21805 | |
| 21806 | ConstExprValue *result = nullptr; | 21806 | ZigValue *result = nullptr; |
| 21807 | switch (type_entry->id) { | 21807 | switch (type_entry->id) { |
| 21808 | case ZigTypeIdInvalid: | 21808 | case ZigTypeIdInvalid: |
| 21809 | zig_unreachable(); | 21809 | zig_unreachable(); |
| ... | @@ -21826,7 +21826,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21826,7 +21826,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21826 | result->special = ConstValSpecialStatic; | 21826 | result->special = ConstValSpecialStatic; |
| 21827 | result->type = ir_type_info_get_type(ira, "Int", nullptr); | 21827 | result->type = ir_type_info_get_type(ira, "Int", nullptr); |
| 21828 | | 21828 | |
| 21829 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 21829 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 21830 | result->data.x_struct.fields = fields; | 21830 | result->data.x_struct.fields = fields; |
| 21831 | | 21831 | |
| 21832 | // is_signed: bool | 21832 | // is_signed: bool |
| ... | @@ -21848,7 +21848,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21848,7 +21848,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21848 | result->special = ConstValSpecialStatic; | 21848 | result->special = ConstValSpecialStatic; |
| 21849 | result->type = ir_type_info_get_type(ira, "Float", nullptr); | 21849 | result->type = ir_type_info_get_type(ira, "Float", nullptr); |
| 21850 | | 21850 | |
| 21851 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21851 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21852 | result->data.x_struct.fields = fields; | 21852 | result->data.x_struct.fields = fields; |
| 21853 | | 21853 | |
| 21854 | // bits: u8 | 21854 | // bits: u8 |
| ... | @@ -21872,7 +21872,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21872,7 +21872,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21872 | result->special = ConstValSpecialStatic; | 21872 | result->special = ConstValSpecialStatic; |
| 21873 | result->type = ir_type_info_get_type(ira, "Array", nullptr); | 21873 | result->type = ir_type_info_get_type(ira, "Array", nullptr); |
| 21874 | | 21874 | |
| 21875 | ConstExprValue **fields = alloc_const_vals_ptrs(3); | 21875 | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 21876 | result->data.x_struct.fields = fields; | 21876 | result->data.x_struct.fields = fields; |
| 21877 | | 21877 | |
| 21878 | // len: usize | 21878 | // len: usize |
| ... | @@ -21896,7 +21896,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21896,7 +21896,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21896 | result->special = ConstValSpecialStatic; | 21896 | result->special = ConstValSpecialStatic; |
| 21897 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); | 21897 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); |
| 21898 | | 21898 | |
| 21899 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 21899 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 21900 | result->data.x_struct.fields = fields; | 21900 | result->data.x_struct.fields = fields; |
| 21901 | | 21901 | |
| 21902 | // len: usize | 21902 | // len: usize |
| ... | @@ -21918,7 +21918,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21918,7 +21918,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21918 | result->special = ConstValSpecialStatic; | 21918 | result->special = ConstValSpecialStatic; |
| 21919 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); | 21919 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); |
| 21920 | | 21920 | |
| 21921 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21921 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21922 | result->data.x_struct.fields = fields; | 21922 | result->data.x_struct.fields = fields; |
| 21923 | | 21923 | |
| 21924 | // child: type | 21924 | // child: type |
| ... | @@ -21934,7 +21934,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21934,7 +21934,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21934 | result->special = ConstValSpecialStatic; | 21934 | result->special = ConstValSpecialStatic; |
| 21935 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); | 21935 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); |
| 21936 | | 21936 | |
| 21937 | ConstExprValue **fields = alloc_const_vals_ptrs(1); | 21937 | ZigValue **fields = alloc_const_vals_ptrs(1); |
| 21938 | result->data.x_struct.fields = fields; | 21938 | result->data.x_struct.fields = fields; |
| 21939 | | 21939 | |
| 21940 | // child: ?type | 21940 | // child: ?type |
| ... | @@ -21951,7 +21951,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21951,7 +21951,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21951 | result->special = ConstValSpecialStatic; | 21951 | result->special = ConstValSpecialStatic; |
| 21952 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); | 21952 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); |
| 21953 | | 21953 | |
| 21954 | ConstExprValue **fields = alloc_const_vals_ptrs(4); | 21954 | ZigValue **fields = alloc_const_vals_ptrs(4); |
| 21955 | result->data.x_struct.fields = fields; | 21955 | result->data.x_struct.fields = fields; |
| 21956 | | 21956 | |
| 21957 | // layout: ContainerLayout | 21957 | // layout: ContainerLayout |
| ... | @@ -21973,7 +21973,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21973,7 +21973,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21973 | } | 21973 | } |
| 21974 | uint32_t enum_field_count = type_entry->data.enumeration.src_field_count; | 21974 | uint32_t enum_field_count = type_entry->data.enumeration.src_field_count; |
| 21975 | | 21975 | |
| 21976 | ConstExprValue *enum_field_array = create_const_vals(1); | 21976 | ZigValue *enum_field_array = create_const_vals(1); |
| 21977 | enum_field_array->special = ConstValSpecialStatic; | 21977 | enum_field_array->special = ConstValSpecialStatic; |
| 21978 | enum_field_array->type = get_array_type(ira->codegen, type_info_enum_field_type, enum_field_count, nullptr); | 21978 | 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; | 21979 | enum_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -21984,7 +21984,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21984,7 +21984,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++) | 21984 | for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) |
| 21985 | { | 21985 | { |
| 21986 | TypeEnumField *enum_field = &type_entry->data.enumeration.fields[enum_field_index]; | 21986 | 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]; | 21987 | 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); | 21988 | make_enum_field_val(ira, enum_field_val, enum_field, type_info_enum_field_type); |
| 21989 | enum_field_val->parent.id = ConstParentIdArray; | 21989 | enum_field_val->parent.id = ConstParentIdArray; |
| 21990 | enum_field_val->parent.data.p_array.array_val = enum_field_array; | 21990 | enum_field_val->parent.data.p_array.array_val = enum_field_array; |
| ... | @@ -22017,11 +22017,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22017,11 +22017,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))) { | 22017 | if ((err = type_resolve(ira->codegen, type_info_error_type, ResolveStatusSizeKnown))) { |
| 22018 | zig_unreachable(); | 22018 | zig_unreachable(); |
| 22019 | } | 22019 | } |
| 22020 | ConstExprValue *slice_val = create_const_vals(1); | 22020 | ZigValue *slice_val = create_const_vals(1); |
| 22021 | result->data.x_optional = slice_val; | 22021 | result->data.x_optional = slice_val; |
| 22022 | | 22022 | |
| 22023 | uint32_t error_count = type_entry->data.error_set.err_count; | 22023 | uint32_t error_count = type_entry->data.error_set.err_count; |
| 22024 | ConstExprValue *error_array = create_const_vals(1); | 22024 | ZigValue *error_array = create_const_vals(1); |
| 22025 | error_array->special = ConstValSpecialStatic; | 22025 | error_array->special = ConstValSpecialStatic; |
| 22026 | error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr); | 22026 | error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr); |
| 22027 | error_array->data.x_array.special = ConstArraySpecialNone; | 22027 | error_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22030,16 +22030,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22030,16 +22030,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); | 22030 | 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++) { | 22031 | for (uint32_t error_index = 0; error_index < error_count; error_index++) { |
| 22032 | ErrorTableEntry *error = type_entry->data.error_set.errors[error_index]; | 22032 | 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]; | 22033 | ZigValue *error_val = &error_array->data.x_array.data.s_none.elements[error_index]; |
| 22034 | | 22034 | |
| 22035 | error_val->special = ConstValSpecialStatic; | 22035 | error_val->special = ConstValSpecialStatic; |
| 22036 | error_val->type = type_info_error_type; | 22036 | error_val->type = type_info_error_type; |
| 22037 | | 22037 | |
| 22038 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); | 22038 | ZigValue **inner_fields = alloc_const_vals_ptrs(2); |
| 22039 | inner_fields[1]->special = ConstValSpecialStatic; | 22039 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22040 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; | 22040 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 22041 | | 22041 | |
| 22042 | ConstExprValue *name = nullptr; | 22042 | ZigValue *name = nullptr; |
| 22043 | if (error->cached_error_name_val != nullptr) | 22043 | if (error->cached_error_name_val != nullptr) |
| 22044 | name = error->cached_error_name_val; | 22044 | name = error->cached_error_name_val; |
| 22045 | if (name == nullptr) | 22045 | if (name == nullptr) |
| ... | @@ -22061,7 +22061,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22061,7 +22061,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22061 | result->special = ConstValSpecialStatic; | 22061 | result->special = ConstValSpecialStatic; |
| 22062 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); | 22062 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); |
| 22063 | | 22063 | |
| 22064 | ConstExprValue **fields = alloc_const_vals_ptrs(2); | 22064 | ZigValue **fields = alloc_const_vals_ptrs(2); |
| 22065 | result->data.x_struct.fields = fields; | 22065 | result->data.x_struct.fields = fields; |
| 22066 | | 22066 | |
| 22067 | // error_set: type | 22067 | // error_set: type |
| ... | @@ -22084,7 +22084,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22084,7 +22084,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22084 | result->special = ConstValSpecialStatic; | 22084 | result->special = ConstValSpecialStatic; |
| 22085 | result->type = ir_type_info_get_type(ira, "Union", nullptr); | 22085 | result->type = ir_type_info_get_type(ira, "Union", nullptr); |
| 22086 | | 22086 | |
| 22087 | ConstExprValue **fields = alloc_const_vals_ptrs(4); | 22087 | ZigValue **fields = alloc_const_vals_ptrs(4); |
| 22088 | result->data.x_struct.fields = fields; | 22088 | result->data.x_struct.fields = fields; |
| 22089 | | 22089 | |
| 22090 | // layout: ContainerLayout | 22090 | // layout: ContainerLayout |
| ... | @@ -22101,7 +22101,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22101,7 +22101,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22101 | if (union_decl_node->data.container_decl.auto_enum || | 22101 | if (union_decl_node->data.container_decl.auto_enum || |
| 22102 | union_decl_node->data.container_decl.init_arg_expr != nullptr) | 22102 | union_decl_node->data.container_decl.init_arg_expr != nullptr) |
| 22103 | { | 22103 | { |
| 22104 | ConstExprValue *tag_type = create_const_vals(1); | 22104 | ZigValue *tag_type = create_const_vals(1); |
| 22105 | tag_type->special = ConstValSpecialStatic; | 22105 | tag_type->special = ConstValSpecialStatic; |
| 22106 | tag_type->type = ira->codegen->builtin_types.entry_type; | 22106 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| 22107 | tag_type->data.x_type = type_entry->data.unionation.tag_type; | 22107 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| ... | @@ -22117,7 +22117,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22117,7 +22117,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22117 | zig_unreachable(); | 22117 | zig_unreachable(); |
| 22118 | uint32_t union_field_count = type_entry->data.unionation.src_field_count; | 22118 | uint32_t union_field_count = type_entry->data.unionation.src_field_count; |
| 22119 | | 22119 | |
| 22120 | ConstExprValue *union_field_array = create_const_vals(1); | 22120 | ZigValue *union_field_array = create_const_vals(1); |
| 22121 | union_field_array->special = ConstValSpecialStatic; | 22121 | union_field_array->special = ConstValSpecialStatic; |
| 22122 | union_field_array->type = get_array_type(ira->codegen, type_info_union_field_type, union_field_count, nullptr); | 22122 | 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; | 22123 | union_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22129,12 +22129,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22129,12 +22129,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22129 | | 22129 | |
| 22130 | for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) { | 22130 | 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]; | 22131 | 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]; | 22132 | ZigValue *union_field_val = &union_field_array->data.x_array.data.s_none.elements[union_field_index]; |
| 22133 | | 22133 | |
| 22134 | union_field_val->special = ConstValSpecialStatic; | 22134 | union_field_val->special = ConstValSpecialStatic; |
| 22135 | union_field_val->type = type_info_union_field_type; | 22135 | union_field_val->type = type_info_union_field_type; |
| 22136 | | 22136 | |
| 22137 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22137 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22138 | inner_fields[1]->special = ConstValSpecialStatic; | 22138 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22139 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); | 22139 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); |
| 22140 | | 22140 | |
| ... | @@ -22149,7 +22149,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22149,7 +22149,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22149 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; | 22149 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 22150 | inner_fields[2]->data.x_type = union_field->type_entry; | 22150 | inner_fields[2]->data.x_type = union_field->type_entry; |
| 22151 | | 22151 | |
| 22152 | ConstExprValue *name = create_const_str_lit(ira->codegen, union_field->name)->data.x_ptr.data.ref.pointee; | 22152 | 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); | 22153 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true); |
| 22154 | | 22154 | |
| 22155 | union_field_val->data.x_struct.fields = inner_fields; | 22155 | union_field_val->data.x_struct.fields = inner_fields; |
| ... | @@ -22180,7 +22180,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22180,7 +22180,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22180 | result->special = ConstValSpecialStatic; | 22180 | result->special = ConstValSpecialStatic; |
| 22181 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); | 22181 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); |
| 22182 | | 22182 | |
| 22183 | ConstExprValue **fields = alloc_const_vals_ptrs(3); | 22183 | ZigValue **fields = alloc_const_vals_ptrs(3); |
| 22184 | result->data.x_struct.fields = fields; | 22184 | result->data.x_struct.fields = fields; |
| 22185 | | 22185 | |
| 22186 | // layout: ContainerLayout | 22186 | // layout: ContainerLayout |
| ... | @@ -22197,7 +22197,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22197,7 +22197,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22197 | } | 22197 | } |
| 22198 | uint32_t struct_field_count = type_entry->data.structure.src_field_count; | 22198 | uint32_t struct_field_count = type_entry->data.structure.src_field_count; |
| 22199 | | 22199 | |
| 22200 | ConstExprValue *struct_field_array = create_const_vals(1); | 22200 | ZigValue *struct_field_array = create_const_vals(1); |
| 22201 | struct_field_array->special = ConstValSpecialStatic; | 22201 | struct_field_array->special = ConstValSpecialStatic; |
| 22202 | struct_field_array->type = get_array_type(ira->codegen, type_info_struct_field_type, struct_field_count, nullptr); | 22202 | 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; | 22203 | struct_field_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22207,12 +22207,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22207,12 +22207,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22207 | | 22207 | |
| 22208 | for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { | 22208 | 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]; | 22209 | 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]; | 22210 | ZigValue *struct_field_val = &struct_field_array->data.x_array.data.s_none.elements[struct_field_index]; |
| 22211 | | 22211 | |
| 22212 | struct_field_val->special = ConstValSpecialStatic; | 22212 | struct_field_val->special = ConstValSpecialStatic; |
| 22213 | struct_field_val->type = type_info_struct_field_type; | 22213 | struct_field_val->type = type_info_struct_field_type; |
| 22214 | | 22214 | |
| 22215 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22215 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22216 | inner_fields[1]->special = ConstValSpecialStatic; | 22216 | inner_fields[1]->special = ConstValSpecialStatic; |
| 22217 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); | 22217 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); |
| 22218 | | 22218 | |
| ... | @@ -22235,7 +22235,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22235,7 +22235,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22235 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; | 22235 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 22236 | inner_fields[2]->data.x_type = struct_field->type_entry; | 22236 | inner_fields[2]->data.x_type = struct_field->type_entry; |
| 22237 | | 22237 | |
| 22238 | ConstExprValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee; | 22238 | 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); | 22239 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true); |
| 22240 | | 22240 | |
| 22241 | struct_field_val->data.x_struct.fields = inner_fields; | 22241 | struct_field_val->data.x_struct.fields = inner_fields; |
| ... | @@ -22259,7 +22259,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22259,7 +22259,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22259 | result->special = ConstValSpecialStatic; | 22259 | result->special = ConstValSpecialStatic; |
| 22260 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); | 22260 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); |
| 22261 | | 22261 | |
| 22262 | ConstExprValue **fields = alloc_const_vals_ptrs(5); | 22262 | ZigValue **fields = alloc_const_vals_ptrs(5); |
| 22263 | result->data.x_struct.fields = fields; | 22263 | result->data.x_struct.fields = fields; |
| 22264 | | 22264 | |
| 22265 | // calling_convention: TypeInfo.CallingConvention | 22265 | // calling_convention: TypeInfo.CallingConvention |
| ... | @@ -22286,7 +22286,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22286,7 +22286,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) | 22286 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 22287 | fields[3]->data.x_optional = nullptr; | 22287 | fields[3]->data.x_optional = nullptr; |
| 22288 | else { | 22288 | else { |
| 22289 | ConstExprValue *return_type = create_const_vals(1); | 22289 | ZigValue *return_type = create_const_vals(1); |
| 22290 | return_type->special = ConstValSpecialStatic; | 22290 | return_type->special = ConstValSpecialStatic; |
| 22291 | return_type->type = ira->codegen->builtin_types.entry_type; | 22291 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 22292 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; | 22292 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| ... | @@ -22300,7 +22300,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22300,7 +22300,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 - | 22300 | 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); | 22301 | (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC); |
| 22302 | | 22302 | |
| 22303 | ConstExprValue *fn_arg_array = create_const_vals(1); | 22303 | ZigValue *fn_arg_array = create_const_vals(1); |
| 22304 | fn_arg_array->special = ConstValSpecialStatic; | 22304 | fn_arg_array->special = ConstValSpecialStatic; |
| 22305 | fn_arg_array->type = get_array_type(ira->codegen, type_info_fn_arg_type, fn_arg_count, nullptr); | 22305 | 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; | 22306 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; |
| ... | @@ -22310,7 +22310,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22310,7 +22310,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22310 | | 22310 | |
| 22311 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 22311 | 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]; | 22312 | 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]; | 22313 | ZigValue *fn_arg_val = &fn_arg_array->data.x_array.data.s_none.elements[fn_arg_index]; |
| 22314 | | 22314 | |
| 22315 | fn_arg_val->special = ConstValSpecialStatic; | 22315 | fn_arg_val->special = ConstValSpecialStatic; |
| 22316 | fn_arg_val->type = type_info_fn_arg_type; | 22316 | fn_arg_val->type = type_info_fn_arg_type; |
| ... | @@ -22318,7 +22318,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22318,7 +22318,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22318 | bool arg_is_generic = fn_param_info->type == nullptr; | 22318 | bool arg_is_generic = fn_param_info->type == nullptr; |
| 22319 | if (arg_is_generic) assert(is_generic); | 22319 | if (arg_is_generic) assert(is_generic); |
| 22320 | | 22320 | |
| 22321 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); | 22321 | ZigValue **inner_fields = alloc_const_vals_ptrs(3); |
| 22322 | inner_fields[0]->special = ConstValSpecialStatic; | 22322 | inner_fields[0]->special = ConstValSpecialStatic; |
| 22323 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; | 22323 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; |
| 22324 | inner_fields[0]->data.x_bool = arg_is_generic; | 22324 | inner_fields[0]->data.x_bool = arg_is_generic; |
| ... | @@ -22331,7 +22331,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22331,7 +22331,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 22331 | if (arg_is_generic) | 22331 | if (arg_is_generic) |
| 22332 | inner_fields[2]->data.x_optional = nullptr; | 22332 | inner_fields[2]->data.x_optional = nullptr; |
| 22333 | else { | 22333 | else { |
| 22334 | ConstExprValue *arg_type = create_const_vals(1); | 22334 | ZigValue *arg_type = create_const_vals(1); |
| 22335 | arg_type->special = ConstValSpecialStatic; | 22335 | arg_type->special = ConstValSpecialStatic; |
| 22336 | arg_type->type = ira->codegen->builtin_types.entry_type; | 22336 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| 22337 | arg_type->data.x_type = fn_param_info->type; | 22337 | arg_type->data.x_type = fn_param_info->type; |
| ... | @@ -22376,12 +22376,12 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -22376,12 +22376,12 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22376 | | 22376 | |
| 22377 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); | 22377 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); |
| 22378 | | 22378 | |
| 22379 | ConstExprValue *payload; | 22379 | ZigValue *payload; |
| 22380 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) | 22380 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) |
| 22381 | return ira->codegen->invalid_instruction; | 22381 | return ira->codegen->invalid_instruction; |
| 22382 | | 22382 | |
| 22383 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22383 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22384 | ConstExprValue *out_val = &result->value; | 22384 | ZigValue *out_val = &result->value; |
| 22385 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); | 22385 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 22386 | out_val->data.x_union.payload = payload; | 22386 | out_val->data.x_union.payload = payload; |
| 22387 | | 22387 | |
| ... | @@ -22393,17 +22393,17 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -22393,17 +22393,17 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22393 | return result; | 22393 | return result; |
| 22394 | } | 22394 | } |
| 22395 | | 22395 | |
| 22396 | static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22396 | static ZigValue *get_const_field(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22397 | { | 22397 | { |
| 22398 | ensure_field_index(struct_value->type, name, field_index); | 22398 | ensure_field_index(struct_value->type, name, field_index); |
| 22399 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); | 22399 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); |
| 22400 | return struct_value->data.x_struct.fields[field_index]; | 22400 | return struct_value->data.x_struct.fields[field_index]; |
| 22401 | } | 22401 | } |
| 22402 | | 22402 | |
| 22403 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *struct_value, | 22403 | 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) | 22404 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) |
| 22405 | { | 22405 | { |
| 22406 | ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index); | 22406 | ZigValue *field_val = get_const_field(ira, struct_value, name, field_index); |
| 22407 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); | 22407 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); |
| 22408 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, | 22408 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 22409 | get_optional_type(ira->codegen, elem_type)); | 22409 | get_optional_type(ira->codegen, elem_type)); |
| ... | @@ -22414,28 +22414,28 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -22414,28 +22414,28 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst |
| 22414 | return ErrorNone; | 22414 | return ErrorNone; |
| 22415 | } | 22415 | } |
| 22416 | | 22416 | |
| 22417 | static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22417 | static bool get_const_field_bool(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22418 | { | 22418 | { |
| 22419 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22419 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22420 | assert(value->type == ira->codegen->builtin_types.entry_bool); | 22420 | assert(value->type == ira->codegen->builtin_types.entry_bool); |
| 22421 | return value->data.x_bool; | 22421 | return value->data.x_bool; |
| 22422 | } | 22422 | } |
| 22423 | | 22423 | |
| 22424 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22424 | static BigInt *get_const_field_lit_int(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22425 | { | 22425 | { |
| 22426 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22426 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22427 | assert(value->type == ira->codegen->builtin_types.entry_num_lit_int); | 22427 | assert(value->type == ira->codegen->builtin_types.entry_num_lit_int); |
| 22428 | return &value->data.x_bigint; | 22428 | return &value->data.x_bigint; |
| 22429 | } | 22429 | } |
| 22430 | | 22430 | |
| 22431 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 22431 | static ZigType *get_const_field_meta_type(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index) |
| 22432 | { | 22432 | { |
| 22433 | ConstExprValue *value = get_const_field(ira, struct_value, name, field_index); | 22433 | ZigValue *value = get_const_field(ira, struct_value, name, field_index); |
| 22434 | assert(value->type == ira->codegen->builtin_types.entry_type); | 22434 | assert(value->type == ira->codegen->builtin_types.entry_type); |
| 22435 | return value->data.x_type; | 22435 | return value->data.x_type; |
| 22436 | } | 22436 | } |
| 22437 | | 22437 | |
| 22438 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ConstExprValue *payload) { | 22438 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ZigValue *payload) { |
| 22439 | Error err; | 22439 | Error err; |
| 22440 | switch (tagTypeId) { | 22440 | switch (tagTypeId) { |
| 22441 | case ZigTypeIdInvalid: | 22441 | case ZigTypeIdInvalid: |
| ... | @@ -22474,12 +22474,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22474,12 +22474,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); | 22474 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 22475 | assert(payload->special == ConstValSpecialStatic); | 22475 | assert(payload->special == ConstValSpecialStatic); |
| 22476 | assert(payload->type == type_info_pointer_type); | 22476 | assert(payload->type == type_info_pointer_type); |
| 22477 | ConstExprValue *size_value = get_const_field(ira, payload, "size", 0); | 22477 | 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)); | 22478 | 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); | 22479 | 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); | 22480 | 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); | 22481 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 4); |
| 22482 | ConstExprValue *sentinel; | 22482 | ZigValue *sentinel; |
| 22483 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, | 22483 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, |
| 22484 | elem_type, &sentinel))) | 22484 | elem_type, &sentinel))) |
| 22485 | { | 22485 | { |
| ... | @@ -22504,7 +22504,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22504,7 +22504,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22504 | assert(payload->special == ConstValSpecialStatic); | 22504 | assert(payload->special == ConstValSpecialStatic); |
| 22505 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); | 22505 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); |
| 22506 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1); | 22506 | ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1); |
| 22507 | ConstExprValue *sentinel; | 22507 | ZigValue *sentinel; |
| 22508 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, | 22508 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, |
| 22509 | elem_type, &sentinel))) | 22509 | elem_type, &sentinel))) |
| 22510 | { | 22510 | { |
| ... | @@ -22556,7 +22556,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT | ... | @@ -22556,7 +22556,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT |
| 22556 | if (type_is_invalid(casted_ir->value.type)) | 22556 | if (type_is_invalid(casted_ir->value.type)) |
| 22557 | return ira->codegen->invalid_instruction; | 22557 | return ira->codegen->invalid_instruction; |
| 22558 | | 22558 | |
| 22559 | ConstExprValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); | 22559 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); |
| 22560 | if (!type_info_value) | 22560 | if (!type_info_value) |
| 22561 | return ira->codegen->invalid_instruction; | 22561 | return ira->codegen->invalid_instruction; |
| 22562 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); | 22562 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); |
| ... | @@ -22574,7 +22574,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -22574,7 +22574,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 22574 | if (type_is_invalid(type_entry)) | 22574 | if (type_is_invalid(type_entry)) |
| 22575 | return ira->codegen->invalid_instruction; | 22575 | return ira->codegen->invalid_instruction; |
| 22576 | | 22576 | |
| 22577 | ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId"); | 22577 | ZigValue *var_value = get_builtin_value(ira->codegen, "TypeId"); |
| 22578 | assert(var_value->type->id == ZigTypeIdMetaType); | 22578 | assert(var_value->type->id == ZigTypeIdMetaType); |
| 22579 | ZigType *result_type = var_value->data.x_type; | 22579 | ZigType *result_type = var_value->data.x_type; |
| 22580 | | 22580 | |
| ... | @@ -22628,7 +22628,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -22628,7 +22628,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 22628 | | 22628 | |
| 22629 | // Execute the C import block like an inline function | 22629 | // Execute the C import block like an inline function |
| 22630 | ZigType *void_type = ira->codegen->builtin_types.entry_void; | 22630 | 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, | 22631 | 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, | 22632 | 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); | 22633 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad); |
| 22634 | if (type_is_invalid(cimport_result->type)) | 22634 | if (type_is_invalid(cimport_result->type)) |
| ... | @@ -23043,7 +23043,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23043,7 +23043,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23043 | } | 23043 | } |
| 23044 | | 23044 | |
| 23045 | if (instr_is_comptime(target)) { | 23045 | if (instr_is_comptime(target)) { |
| 23046 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 23046 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 23047 | if (val == nullptr) | 23047 | if (val == nullptr) |
| 23048 | return ira->codegen->invalid_instruction; | 23048 | return ira->codegen->invalid_instruction; |
| 23049 | | 23049 | |
| ... | @@ -23232,11 +23232,11 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23232,11 +23232,11 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23232 | uint64_t known_len; | 23232 | uint64_t known_len; |
| 23233 | | 23233 | |
| 23234 | if (instr_is_comptime(casted_value)) { | 23234 | if (instr_is_comptime(casted_value)) { |
| 23235 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 23235 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 23236 | if (!val) | 23236 | if (!val) |
| 23237 | return ira->codegen->invalid_instruction; | 23237 | return ira->codegen->invalid_instruction; |
| 23238 | | 23238 | |
| 23239 | ConstExprValue *len_val = val->data.x_struct.fields[slice_len_index]; | 23239 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; |
| 23240 | if (value_is_comptime(len_val)) { | 23240 | if (value_is_comptime(len_val)) { |
| 23241 | known_len = bigint_as_u64(&len_val->data.x_bigint); | 23241 | known_len = bigint_as_u64(&len_val->data.x_bigint); |
| 23242 | have_known_len = true; | 23242 | have_known_len = true; |
| ... | @@ -23298,22 +23298,22 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23298,22 +23298,22 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23298 | ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type); | 23298 | ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type); |
| 23299 | | 23299 | |
| 23300 | if (instr_is_comptime(target)) { | 23300 | if (instr_is_comptime(target)) { |
| 23301 | ConstExprValue *target_val = ir_resolve_const(ira, target, UndefBad); | 23301 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); |
| 23302 | if (target_val == nullptr) | 23302 | if (target_val == nullptr) |
| 23303 | return ira->codegen->invalid_instruction; | 23303 | return ira->codegen->invalid_instruction; |
| 23304 | | 23304 | |
| 23305 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 23305 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); |
| 23306 | result->value.data.x_struct.fields = alloc_const_vals_ptrs(2); | 23306 | result->value.data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 23307 | | 23307 | |
| 23308 | ConstExprValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index]; | 23308 | 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]; | 23309 | ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; |
| 23310 | copy_const_val(ptr_val, target_ptr_val, false); | 23310 | copy_const_val(ptr_val, target_ptr_val, false); |
| 23311 | ptr_val->type = dest_ptr_type; | 23311 | ptr_val->type = dest_ptr_type; |
| 23312 | | 23312 | |
| 23313 | ConstExprValue *len_val = result->value.data.x_struct.fields[slice_len_index]; | 23313 | ZigValue *len_val = result->value.data.x_struct.fields[slice_len_index]; |
| 23314 | len_val->special = ConstValSpecialStatic; | 23314 | len_val->special = ConstValSpecialStatic; |
| 23315 | len_val->type = ira->codegen->builtin_types.entry_usize; | 23315 | len_val->type = ira->codegen->builtin_types.entry_usize; |
| 23316 | ConstExprValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; | 23316 | ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; |
| 23317 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; | 23317 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; |
| 23318 | BigInt elem_size_bigint; | 23318 | BigInt elem_size_bigint; |
| 23319 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); | 23319 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); |
| ... | @@ -23539,14 +23539,14 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23539,14 +23539,14 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23539 | return ira->codegen->invalid_instruction; | 23539 | return ira->codegen->invalid_instruction; |
| 23540 | } | 23540 | } |
| 23541 | | 23541 | |
| 23542 | ConstExprValue *mask_val = ir_resolve_const(ira, mask, UndefOk); | 23542 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); |
| 23543 | if (mask_val == nullptr) | 23543 | if (mask_val == nullptr) |
| 23544 | return ira->codegen->invalid_instruction; | 23544 | return ira->codegen->invalid_instruction; |
| 23545 | | 23545 | |
| 23546 | expand_undef_array(ira->codegen, mask_val); | 23546 | expand_undef_array(ira->codegen, mask_val); |
| 23547 | | 23547 | |
| 23548 | for (uint32_t i = 0; i < len_mask; i += 1) { | 23548 | 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]; | 23549 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| 23550 | if (mask_elem_val->special == ConstValSpecialUndef) | 23550 | if (mask_elem_val->special == ConstValSpecialUndef) |
| 23551 | continue; | 23551 | continue; |
| 23552 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); | 23552 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| ... | @@ -23575,11 +23575,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23575,11 +23575,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23575 | | 23575 | |
| 23576 | ZigType *result_type = get_vector_type(ira->codegen, len_mask, scalar_type); | 23576 | ZigType *result_type = get_vector_type(ira->codegen, len_mask, scalar_type); |
| 23577 | if (instr_is_comptime(a) && instr_is_comptime(b)) { | 23577 | if (instr_is_comptime(a) && instr_is_comptime(b)) { |
| 23578 | ConstExprValue *a_val = ir_resolve_const(ira, a, UndefOk); | 23578 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); |
| 23579 | if (a_val == nullptr) | 23579 | if (a_val == nullptr) |
| 23580 | return ira->codegen->invalid_instruction; | 23580 | return ira->codegen->invalid_instruction; |
| 23581 | | 23581 | |
| 23582 | ConstExprValue *b_val = ir_resolve_const(ira, b, UndefOk); | 23582 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); |
| 23583 | if (b_val == nullptr) | 23583 | if (b_val == nullptr) |
| 23584 | return ira->codegen->invalid_instruction; | 23584 | return ira->codegen->invalid_instruction; |
| 23585 | | 23585 | |
| ... | @@ -23589,15 +23589,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23589,15 +23589,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23589 | IrInstruction *result = ir_const(ira, source_instr, result_type); | 23589 | IrInstruction *result = ir_const(ira, source_instr, result_type); |
| 23590 | result->value.data.x_array.data.s_none.elements = create_const_vals(len_mask); | 23590 | 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) { | 23591 | 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]; | 23592 | 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]; | 23593 | ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; |
| 23594 | if (mask_elem_val->special == ConstValSpecialUndef) { | 23594 | if (mask_elem_val->special == ConstValSpecialUndef) { |
| 23595 | result_elem_val->special = ConstValSpecialUndef; | 23595 | result_elem_val->special = ConstValSpecialUndef; |
| 23596 | continue; | 23596 | continue; |
| 23597 | } | 23597 | } |
| 23598 | int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint); | 23598 | 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. | 23599 | // We've already checked for and emitted compile errors for index out of bounds here. |
| 23600 | ConstExprValue *src_elem_val = (v >= 0) ? | 23600 | ZigValue *src_elem_val = (v >= 0) ? |
| 23601 | &a->value.data.x_array.data.s_none.elements[v] : | 23601 | &a->value.data.x_array.data.s_none.elements[v] : |
| 23602 | &b->value.data.x_array.data.s_none.elements[~v]; | 23602 | &b->value.data.x_array.data.s_none.elements[~v]; |
| 23603 | copy_const_val(result_elem_val, src_elem_val, false); | 23603 | copy_const_val(result_elem_val, src_elem_val, false); |
| ... | @@ -23686,7 +23686,7 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23686,7 +23686,7 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23686 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type); | 23686 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type); |
| 23687 | | 23687 | |
| 23688 | if (instr_is_comptime(scalar)) { | 23688 | if (instr_is_comptime(scalar)) { |
| 23689 | ConstExprValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); | 23689 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); |
| 23690 | if (scalar_val == nullptr) | 23690 | if (scalar_val == nullptr) |
| 23691 | return ira->codegen->invalid_instruction; | 23691 | return ira->codegen->invalid_instruction; |
| 23692 | if (scalar_val->special == ConstValSpecialUndef) | 23692 | if (scalar_val->special == ConstValSpecialUndef) |
| ... | @@ -23715,7 +23715,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct | ... | @@ -23715,7 +23715,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct |
| 23715 | return ira->codegen->invalid_instruction; | 23715 | return ira->codegen->invalid_instruction; |
| 23716 | | 23716 | |
| 23717 | if (instr_is_comptime(casted_value)) { | 23717 | if (instr_is_comptime(casted_value)) { |
| 23718 | ConstExprValue *value = ir_resolve_const(ira, casted_value, UndefBad); | 23718 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); |
| 23719 | if (value == nullptr) | 23719 | if (value == nullptr) |
| 23720 | return ira->codegen->invalid_instruction; | 23720 | return ira->codegen->invalid_instruction; |
| 23721 | | 23721 | |
| ... | @@ -23776,22 +23776,22 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23776,22 +23776,22 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23776 | instr_is_comptime(casted_byte) && | 23776 | instr_is_comptime(casted_byte) && |
| 23777 | instr_is_comptime(casted_count)) | 23777 | instr_is_comptime(casted_count)) |
| 23778 | { | 23778 | { |
| 23779 | ConstExprValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 23779 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 23780 | if (dest_ptr_val == nullptr) | 23780 | if (dest_ptr_val == nullptr) |
| 23781 | return ira->codegen->invalid_instruction; | 23781 | return ira->codegen->invalid_instruction; |
| 23782 | | 23782 | |
| 23783 | ConstExprValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); | 23783 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); |
| 23784 | if (byte_val == nullptr) | 23784 | if (byte_val == nullptr) |
| 23785 | return ira->codegen->invalid_instruction; | 23785 | return ira->codegen->invalid_instruction; |
| 23786 | | 23786 | |
| 23787 | ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 23787 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 23788 | if (count_val == nullptr) | 23788 | if (count_val == nullptr) |
| 23789 | return ira->codegen->invalid_instruction; | 23789 | return ira->codegen->invalid_instruction; |
| 23790 | | 23790 | |
| 23791 | if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr && | 23791 | if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 23792 | casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 23792 | casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 23793 | { | 23793 | { |
| 23794 | ConstExprValue *dest_elements; | 23794 | ZigValue *dest_elements; |
| 23795 | size_t start; | 23795 | size_t start; |
| 23796 | size_t bound_end; | 23796 | size_t bound_end; |
| 23797 | switch (dest_ptr_val->data.x_ptr.special) { | 23797 | switch (dest_ptr_val->data.x_ptr.special) { |
| ... | @@ -23805,7 +23805,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23805,7 +23805,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23805 | break; | 23805 | break; |
| 23806 | case ConstPtrSpecialBaseArray: | 23806 | case ConstPtrSpecialBaseArray: |
| 23807 | { | 23807 | { |
| 23808 | ConstExprValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; | 23808 | ZigValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23809 | expand_undef_array(ira->codegen, array_val); | 23809 | expand_undef_array(ira->codegen, array_val); |
| 23810 | dest_elements = array_val->data.x_array.data.s_none.elements; | 23810 | dest_elements = array_val->data.x_array.data.s_none.elements; |
| 23811 | start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; | 23811 | start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -23912,22 +23912,22 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23912,22 +23912,22 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23912 | instr_is_comptime(casted_src_ptr) && | 23912 | instr_is_comptime(casted_src_ptr) && |
| 23913 | instr_is_comptime(casted_count)) | 23913 | instr_is_comptime(casted_count)) |
| 23914 | { | 23914 | { |
| 23915 | ConstExprValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 23915 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 23916 | if (dest_ptr_val == nullptr) | 23916 | if (dest_ptr_val == nullptr) |
| 23917 | return ira->codegen->invalid_instruction; | 23917 | return ira->codegen->invalid_instruction; |
| 23918 | | 23918 | |
| 23919 | ConstExprValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); | 23919 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); |
| 23920 | if (src_ptr_val == nullptr) | 23920 | if (src_ptr_val == nullptr) |
| 23921 | return ira->codegen->invalid_instruction; | 23921 | return ira->codegen->invalid_instruction; |
| 23922 | | 23922 | |
| 23923 | ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 23923 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 23924 | if (count_val == nullptr) | 23924 | if (count_val == nullptr) |
| 23925 | return ira->codegen->invalid_instruction; | 23925 | return ira->codegen->invalid_instruction; |
| 23926 | | 23926 | |
| 23927 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 23927 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 23928 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 23928 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| 23929 | | 23929 | |
| 23930 | ConstExprValue *dest_elements; | 23930 | ZigValue *dest_elements; |
| 23931 | size_t dest_start; | 23931 | size_t dest_start; |
| 23932 | size_t dest_end; | 23932 | size_t dest_end; |
| 23933 | switch (dest_ptr_val->data.x_ptr.special) { | 23933 | switch (dest_ptr_val->data.x_ptr.special) { |
| ... | @@ -23941,7 +23941,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23941,7 +23941,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23941 | break; | 23941 | break; |
| 23942 | case ConstPtrSpecialBaseArray: | 23942 | case ConstPtrSpecialBaseArray: |
| 23943 | { | 23943 | { |
| 23944 | ConstExprValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; | 23944 | ZigValue *array_val = dest_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23945 | expand_undef_array(ira->codegen, array_val); | 23945 | expand_undef_array(ira->codegen, array_val); |
| 23946 | dest_elements = array_val->data.x_array.data.s_none.elements; | 23946 | 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; | 23947 | dest_start = dest_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -23969,7 +23969,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23969,7 +23969,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23969 | return ira->codegen->invalid_instruction; | 23969 | return ira->codegen->invalid_instruction; |
| 23970 | } | 23970 | } |
| 23971 | | 23971 | |
| 23972 | ConstExprValue *src_elements; | 23972 | ZigValue *src_elements; |
| 23973 | size_t src_start; | 23973 | size_t src_start; |
| 23974 | size_t src_end; | 23974 | size_t src_end; |
| 23975 | | 23975 | |
| ... | @@ -23984,7 +23984,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23984,7 +23984,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23984 | break; | 23984 | break; |
| 23985 | case ConstPtrSpecialBaseArray: | 23985 | case ConstPtrSpecialBaseArray: |
| 23986 | { | 23986 | { |
| 23987 | ConstExprValue *array_val = src_ptr_val->data.x_ptr.data.base_array.array_val; | 23987 | ZigValue *array_val = src_ptr_val->data.x_ptr.data.base_array.array_val; |
| 23988 | expand_undef_array(ira->codegen, array_val); | 23988 | expand_undef_array(ira->codegen, array_val); |
| 23989 | src_elements = array_val->data.x_array.data.s_none.elements; | 23989 | 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; | 23990 | src_start = src_ptr_val->data.x_ptr.data.base_array.elem_index; |
| ... | @@ -24106,8 +24106,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24106,8 +24106,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24106 | value_is_comptime(&casted_start->value) && | 24106 | value_is_comptime(&casted_start->value) && |
| 24107 | (!end || value_is_comptime(&end->value))) | 24107 | (!end || value_is_comptime(&end->value))) |
| 24108 | { | 24108 | { |
| 24109 | ConstExprValue *array_val; | 24109 | ZigValue *array_val; |
| 24110 | ConstExprValue *parent_ptr; | 24110 | ZigValue *parent_ptr; |
| 24111 | size_t abs_offset; | 24111 | size_t abs_offset; |
| 24112 | size_t rel_end; | 24112 | size_t rel_end; |
| 24113 | bool ptr_is_undef = false; | 24113 | bool ptr_is_undef = false; |
| ... | @@ -24193,7 +24193,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24193,7 +24193,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24193 | zig_panic("TODO slice of null ptr"); | 24193 | zig_panic("TODO slice of null ptr"); |
| 24194 | } | 24194 | } |
| 24195 | } else if (is_slice(array_type)) { | 24195 | } else if (is_slice(array_type)) { |
| 24196 | ConstExprValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24196 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); |
| 24197 | if (slice_ptr == nullptr) | 24197 | if (slice_ptr == nullptr) |
| 24198 | return ira->codegen->invalid_instruction; | 24198 | return ira->codegen->invalid_instruction; |
| 24199 | | 24199 | |
| ... | @@ -24208,7 +24208,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24208,7 +24208,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24208 | return ira->codegen->invalid_instruction; | 24208 | return ira->codegen->invalid_instruction; |
| 24209 | } | 24209 | } |
| 24210 | | 24210 | |
| 24211 | ConstExprValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; | 24211 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; |
| 24212 | | 24212 | |
| 24213 | switch (parent_ptr->data.x_ptr.special) { | 24213 | switch (parent_ptr->data.x_ptr.special) { |
| 24214 | case ConstPtrSpecialInvalid: | 24214 | case ConstPtrSpecialInvalid: |
| ... | @@ -24246,7 +24246,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24246,7 +24246,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24246 | zig_unreachable(); | 24246 | zig_unreachable(); |
| 24247 | } | 24247 | } |
| 24248 | | 24248 | |
| 24249 | ConstExprValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); | 24249 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); |
| 24250 | if (!start_val) | 24250 | if (!start_val) |
| 24251 | return ira->codegen->invalid_instruction; | 24251 | return ira->codegen->invalid_instruction; |
| 24252 | | 24252 | |
| ... | @@ -24258,7 +24258,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24258,7 +24258,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24258 | | 24258 | |
| 24259 | uint64_t end_scalar = rel_end; | 24259 | uint64_t end_scalar = rel_end; |
| 24260 | if (end) { | 24260 | if (end) { |
| 24261 | ConstExprValue *end_val = ir_resolve_const(ira, end, UndefBad); | 24261 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); |
| 24262 | if (!end_val) | 24262 | if (!end_val) |
| 24263 | return ira->codegen->invalid_instruction; | 24263 | return ira->codegen->invalid_instruction; |
| 24264 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); | 24264 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); |
| ... | @@ -24279,10 +24279,10 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24279,10 +24279,10 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24279 | } | 24279 | } |
| 24280 | | 24280 | |
| 24281 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 24281 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 24282 | ConstExprValue *out_val = &result->value; | 24282 | ZigValue *out_val = &result->value; |
| 24283 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); | 24283 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 24284 | | 24284 | |
| 24285 | ConstExprValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; | 24285 | ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; |
| 24286 | | 24286 | |
| 24287 | if (array_val) { | 24287 | if (array_val) { |
| 24288 | size_t index = abs_offset + start_scalar; | 24288 | size_t index = abs_offset + start_scalar; |
| ... | @@ -24329,7 +24329,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24329,7 +24329,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24329 | zig_panic("TODO"); | 24329 | zig_panic("TODO"); |
| 24330 | } | 24330 | } |
| 24331 | | 24331 | |
| 24332 | ConstExprValue *len_val = out_val->data.x_struct.fields[slice_len_index]; | 24332 | ZigValue *len_val = out_val->data.x_struct.fields[slice_len_index]; |
| 24333 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); | 24333 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); |
| 24334 | | 24334 | |
| 24335 | return result; | 24335 | return result; |
| ... | @@ -24666,21 +24666,21 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24666,21 +24666,21 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24666 | instr_is_comptime(casted_op2) && | 24666 | instr_is_comptime(casted_op2) && |
| 24667 | instr_is_comptime(casted_result_ptr)) | 24667 | instr_is_comptime(casted_result_ptr)) |
| 24668 | { | 24668 | { |
| 24669 | ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 24669 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 24670 | if (op1_val == nullptr) | 24670 | if (op1_val == nullptr) |
| 24671 | return ira->codegen->invalid_instruction; | 24671 | return ira->codegen->invalid_instruction; |
| 24672 | | 24672 | |
| 24673 | ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 24673 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 24674 | if (op2_val == nullptr) | 24674 | if (op2_val == nullptr) |
| 24675 | return ira->codegen->invalid_instruction; | 24675 | return ira->codegen->invalid_instruction; |
| 24676 | | 24676 | |
| 24677 | ConstExprValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); | 24677 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); |
| 24678 | if (result_val == nullptr) | 24678 | if (result_val == nullptr) |
| 24679 | return ira->codegen->invalid_instruction; | 24679 | return ira->codegen->invalid_instruction; |
| 24680 | | 24680 | |
| 24681 | BigInt *op1_bigint = &op1_val->data.x_bigint; | 24681 | BigInt *op1_bigint = &op1_val->data.x_bigint; |
| 24682 | BigInt *op2_bigint = &op2_val->data.x_bigint; | 24682 | BigInt *op2_bigint = &op2_val->data.x_bigint; |
| 24683 | ConstExprValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, | 24683 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, |
| 24684 | casted_result_ptr->source_node); | 24684 | casted_result_ptr->source_node); |
| 24685 | if (pointee_val == nullptr) | 24685 | if (pointee_val == nullptr) |
| 24686 | return ira->codegen->invalid_instruction; | 24686 | return ira->codegen->invalid_instruction; |
| ... | @@ -24721,7 +24721,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24721,7 +24721,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24721 | } | 24721 | } |
| 24722 | | 24722 | |
| 24723 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, | 24723 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, |
| 24724 | ConstExprValue *op1, ConstExprValue *op2, ConstExprValue *op3, ConstExprValue *out_val) { | 24724 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { |
| 24725 | if (float_type->id == ZigTypeIdComptimeFloat) { | 24725 | if (float_type->id == ZigTypeIdComptimeFloat) { |
| 24726 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, | 24726 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, |
| 24727 | &op3->data.x_bigfloat.value); | 24727 | &op3->data.x_bigfloat.value); |
| ... | @@ -24791,18 +24791,18 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24791,18 +24791,18 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24791 | if (instr_is_comptime(casted_op1) && | 24791 | if (instr_is_comptime(casted_op1) && |
| 24792 | instr_is_comptime(casted_op2) && | 24792 | instr_is_comptime(casted_op2) && |
| 24793 | instr_is_comptime(casted_op3)) { | 24793 | instr_is_comptime(casted_op3)) { |
| 24794 | ConstExprValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 24794 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 24795 | if (!op1_const) | 24795 | if (!op1_const) |
| 24796 | return ira->codegen->invalid_instruction; | 24796 | return ira->codegen->invalid_instruction; |
| 24797 | ConstExprValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); | 24797 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); |
| 24798 | if (!op2_const) | 24798 | if (!op2_const) |
| 24799 | return ira->codegen->invalid_instruction; | 24799 | return ira->codegen->invalid_instruction; |
| 24800 | ConstExprValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); | 24800 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); |
| 24801 | if (!op3_const) | 24801 | if (!op3_const) |
| 24802 | return ira->codegen->invalid_instruction; | 24802 | return ira->codegen->invalid_instruction; |
| 24803 | | 24803 | |
| 24804 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 24804 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 24805 | ConstExprValue *out_val = &result->value; | 24805 | ZigValue *out_val = &result->value; |
| 24806 | | 24806 | |
| 24807 | if (expr_type->id == ZigTypeIdVector) { | 24807 | if (expr_type->id == ZigTypeIdVector) { |
| 24808 | expand_undef_array(ira->codegen, op1_const); | 24808 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -24812,10 +24812,10 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24812,10 +24812,10 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24812 | expand_undef_array(ira->codegen, out_val); | 24812 | expand_undef_array(ira->codegen, out_val); |
| 24813 | size_t len = expr_type->data.vector.len; | 24813 | size_t len = expr_type->data.vector.len; |
| 24814 | for (size_t i = 0; i < len; i += 1) { | 24814 | for (size_t i = 0; i < len; i += 1) { |
| 24815 | ConstExprValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; | 24815 | 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]; | 24816 | 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]; | 24817 | 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]; | 24818 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 24819 | assert(float_operand_op1->type == float_type); | 24819 | assert(float_operand_op1->type == float_type); |
| 24820 | assert(float_operand_op2->type == float_type); | 24820 | assert(float_operand_op2->type == float_type); |
| 24821 | assert(float_operand_op3->type == float_type); | 24821 | assert(float_operand_op3->type == float_type); |
| ... | @@ -24856,7 +24856,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct | ... | @@ -24856,7 +24856,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 24856 | return ira->codegen->invalid_instruction; | 24856 | return ira->codegen->invalid_instruction; |
| 24857 | if (type_entry->id == ZigTypeIdErrorUnion) { | 24857 | if (type_entry->id == ZigTypeIdErrorUnion) { |
| 24858 | if (instr_is_comptime(value)) { | 24858 | if (instr_is_comptime(value)) { |
| 24859 | ConstExprValue *err_union_val = ir_resolve_const(ira, value, UndefBad); | 24859 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); |
| 24860 | if (!err_union_val) | 24860 | if (!err_union_val) |
| 24861 | return ira->codegen->invalid_instruction; | 24861 | return ira->codegen->invalid_instruction; |
| 24862 | | 24862 | |
| ... | @@ -24911,20 +24911,20 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24911,20 +24911,20 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24911 | ptr_type->data.pointer.explicit_alignment, 0, 0, false); | 24911 | ptr_type->data.pointer.explicit_alignment, 0, 0, false); |
| 24912 | | 24912 | |
| 24913 | if (instr_is_comptime(base_ptr)) { | 24913 | if (instr_is_comptime(base_ptr)) { |
| 24914 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 24914 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 24915 | if (!ptr_val) | 24915 | if (!ptr_val) |
| 24916 | return ira->codegen->invalid_instruction; | 24916 | return ira->codegen->invalid_instruction; |
| 24917 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 24917 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 24918 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) | 24918 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) |
| 24919 | { | 24919 | { |
| 24920 | ConstExprValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 24920 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 24921 | if (err_union_val == nullptr) | 24921 | if (err_union_val == nullptr) |
| 24922 | return ira->codegen->invalid_instruction; | 24922 | return ira->codegen->invalid_instruction; |
| 24923 | | 24923 | |
| 24924 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 24924 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 24925 | ConstExprValue *vals = create_const_vals(2); | 24925 | ZigValue *vals = create_const_vals(2); |
| 24926 | ConstExprValue *err_set_val = &vals[0]; | 24926 | ZigValue *err_set_val = &vals[0]; |
| 24927 | ConstExprValue *payload_val = &vals[1]; | 24927 | ZigValue *payload_val = &vals[1]; |
| 24928 | | 24928 | |
| 24929 | err_set_val->special = ConstValSpecialUndef; | 24929 | err_set_val->special = ConstValSpecialUndef; |
| 24930 | err_set_val->type = err_set_type; | 24930 | err_set_val->type = err_set_type; |
| ... | @@ -24951,7 +24951,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24951,7 +24951,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24951 | } else { | 24951 | } else { |
| 24952 | result = ir_const(ira, source_instr, result_type); | 24952 | result = ir_const(ira, source_instr, result_type); |
| 24953 | } | 24953 | } |
| 24954 | ConstExprValue *const_val = &result->value; | 24954 | ZigValue *const_val = &result->value; |
| 24955 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; | 24955 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; |
| 24956 | const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val; | 24956 | 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; | 24957 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| ... | @@ -25000,17 +25000,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25000,17 +25000,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25000 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 25000 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| 25001 | PtrLenSingle, 0, 0, 0, false); | 25001 | PtrLenSingle, 0, 0, 0, false); |
| 25002 | if (instr_is_comptime(base_ptr)) { | 25002 | if (instr_is_comptime(base_ptr)) { |
| 25003 | ConstExprValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 25003 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 25004 | if (!ptr_val) | 25004 | if (!ptr_val) |
| 25005 | return ira->codegen->invalid_instruction; | 25005 | return ira->codegen->invalid_instruction; |
| 25006 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 25006 | 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); | 25007 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 25008 | if (err_union_val == nullptr) | 25008 | if (err_union_val == nullptr) |
| 25009 | return ira->codegen->invalid_instruction; | 25009 | return ira->codegen->invalid_instruction; |
| 25010 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 25010 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 25011 | ConstExprValue *vals = create_const_vals(2); | 25011 | ZigValue *vals = create_const_vals(2); |
| 25012 | ConstExprValue *err_set_val = &vals[0]; | 25012 | ZigValue *err_set_val = &vals[0]; |
| 25013 | ConstExprValue *payload_val = &vals[1]; | 25013 | ZigValue *payload_val = &vals[1]; |
| 25014 | | 25014 | |
| 25015 | err_set_val->special = ConstValSpecialStatic; | 25015 | err_set_val->special = ConstValSpecialStatic; |
| 25016 | err_set_val->type = type_entry->data.error_union.err_set_type; | 25016 | err_set_val->type = type_entry->data.error_union.err_set_type; |
| ... | @@ -25289,11 +25289,11 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25289,11 +25289,11 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25289 | if (type_is_invalid(casted_end_value->value.type)) | 25289 | if (type_is_invalid(casted_end_value->value.type)) |
| 25290 | return ira->codegen->invalid_instruction; | 25290 | return ira->codegen->invalid_instruction; |
| 25291 | | 25291 | |
| 25292 | ConstExprValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); | 25292 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); |
| 25293 | if (!start_val) | 25293 | if (!start_val) |
| 25294 | return ira->codegen->invalid_instruction; | 25294 | return ira->codegen->invalid_instruction; |
| 25295 | | 25295 | |
| 25296 | ConstExprValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); | 25296 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); |
| 25297 | if (!end_val) | 25297 | if (!end_val) |
| 25298 | return ira->codegen->invalid_instruction; | 25298 | return ira->codegen->invalid_instruction; |
| 25299 | | 25299 | |
| ... | @@ -25329,7 +25329,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25329,7 +25329,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25329 | if (type_is_invalid(casted_value->value.type)) | 25329 | if (type_is_invalid(casted_value->value.type)) |
| 25330 | return ira->codegen->invalid_instruction; | 25330 | return ira->codegen->invalid_instruction; |
| 25331 | | 25331 | |
| 25332 | ConstExprValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); | 25332 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 25333 | if (!const_expr_val) | 25333 | if (!const_expr_val) |
| 25334 | return ira->codegen->invalid_instruction; | 25334 | return ira->codegen->invalid_instruction; |
| 25335 | | 25335 | |
| ... | @@ -25443,7 +25443,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25443,7 +25443,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25443 | } | 25443 | } |
| 25444 | | 25444 | |
| 25445 | if (instr_is_comptime(target)) { | 25445 | if (instr_is_comptime(target)) { |
| 25446 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 25446 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 25447 | if (!val) | 25447 | if (!val) |
| 25448 | return ira->codegen->invalid_instruction; | 25448 | return ira->codegen->invalid_instruction; |
| 25449 | | 25449 | |
| ... | @@ -25515,7 +25515,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25515,7 +25515,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25515 | if (instr_is_comptime(ptr)) { | 25515 | if (instr_is_comptime(ptr)) { |
| 25516 | bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type); | 25516 | bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type); |
| 25517 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; | 25517 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; |
| 25518 | ConstExprValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); | 25518 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); |
| 25519 | if (!val) | 25519 | if (!val) |
| 25520 | return ira->codegen->invalid_instruction; | 25520 | return ira->codegen->invalid_instruction; |
| 25521 | | 25521 | |
| ... | @@ -25607,18 +25607,18 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct | ... | @@ -25607,18 +25607,18 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct |
| 25607 | instruction->safety_check_on); | 25607 | instruction->safety_check_on); |
| 25608 | } | 25608 | } |
| 25609 | | 25609 | |
| 25610 | static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ConstExprValue *val, size_t len) { | 25610 | static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ZigValue *val, size_t len) { |
| 25611 | size_t buf_i = 0; | 25611 | size_t buf_i = 0; |
| 25612 | // TODO optimize the buf case | 25612 | // TODO optimize the buf case |
| 25613 | expand_undef_array(codegen, val); | 25613 | expand_undef_array(codegen, val); |
| 25614 | for (size_t elem_i = 0; elem_i < val->type->data.array.len; elem_i += 1) { | 25614 | 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]; | 25615 | ZigValue *elem = &val->data.x_array.data.s_none.elements[elem_i]; |
| 25616 | buf_write_value_bytes(codegen, &buf[buf_i], elem); | 25616 | buf_write_value_bytes(codegen, &buf[buf_i], elem); |
| 25617 | buf_i += type_size(codegen, elem->type); | 25617 | buf_i += type_size(codegen, elem->type); |
| 25618 | } | 25618 | } |
| 25619 | } | 25619 | } |
| 25620 | | 25620 | |
| 25621 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { | 25621 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val) { |
| 25622 | if (val->special == ConstValSpecialUndef) { | 25622 | if (val->special == ConstValSpecialUndef) { |
| 25623 | expand_undef_struct(codegen, val); | 25623 | expand_undef_struct(codegen, val); |
| 25624 | val->special = ConstValSpecialStatic; | 25624 | val->special = ConstValSpecialStatic; |
| ... | @@ -25679,7 +25679,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25679,7 +25679,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25679 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; | 25679 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; |
| 25680 | if (struct_field->gen_index == SIZE_MAX) | 25680 | if (struct_field->gen_index == SIZE_MAX) |
| 25681 | continue; | 25681 | continue; |
| 25682 | ConstExprValue *field_val = val->data.x_struct.fields[field_i]; | 25682 | ZigValue *field_val = val->data.x_struct.fields[field_i]; |
| 25683 | size_t offset = struct_field->offset; | 25683 | size_t offset = struct_field->offset; |
| 25684 | buf_write_value_bytes(codegen, buf + offset, field_val); | 25684 | buf_write_value_bytes(codegen, buf + offset, field_val); |
| 25685 | } | 25685 | } |
| ... | @@ -25754,7 +25754,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25754,7 +25754,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25754 | } | 25754 | } |
| 25755 | | 25755 | |
| 25756 | static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, | 25756 | 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) | 25757 | ZigValue *val, ZigType *elem_type, size_t len) |
| 25758 | { | 25758 | { |
| 25759 | Error err; | 25759 | Error err; |
| 25760 | uint64_t elem_size = type_size(codegen, elem_type); | 25760 | uint64_t elem_size = type_size(codegen, elem_type); |
| ... | @@ -25763,7 +25763,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod | ... | @@ -25763,7 +25763,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 25763 | case ConstArraySpecialNone: | 25763 | case ConstArraySpecialNone: |
| 25764 | val->data.x_array.data.s_none.elements = create_const_vals(len); | 25764 | val->data.x_array.data.s_none.elements = create_const_vals(len); |
| 25765 | for (size_t i = 0; i < len; i++) { | 25765 | for (size_t i = 0; i < len; i++) { |
| 25766 | ConstExprValue *elem = &val->data.x_array.data.s_none.elements[i]; | 25766 | ZigValue *elem = &val->data.x_array.data.s_none.elements[i]; |
| 25767 | elem->special = ConstValSpecialStatic; | 25767 | elem->special = ConstValSpecialStatic; |
| 25768 | elem->type = elem_type; | 25768 | elem->type = elem_type; |
| 25769 | if ((err = buf_read_value_bytes(ira, codegen, source_node, buf + (elem_size * i), elem))) | 25769 | if ((err = buf_read_value_bytes(ira, codegen, source_node, buf + (elem_size * i), elem))) |
| ... | @@ -25778,7 +25778,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod | ... | @@ -25778,7 +25778,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 25778 | zig_unreachable(); | 25778 | zig_unreachable(); |
| 25779 | } | 25779 | } |
| 25780 | | 25780 | |
| 25781 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val) { | 25781 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val) { |
| 25782 | Error err; | 25782 | Error err; |
| 25783 | src_assert(val->special == ConstValSpecialStatic, source_node); | 25783 | src_assert(val->special == ConstValSpecialStatic, source_node); |
| 25784 | switch (val->type->id) { | 25784 | switch (val->type->id) { |
| ... | @@ -25850,7 +25850,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25850,7 +25850,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; | 25850 | 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); | 25851 | 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) { | 25852 | 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]; | 25853 | ZigValue *field_val = val->data.x_struct.fields[field_i]; |
| 25854 | field_val->special = ConstValSpecialStatic; | 25854 | field_val->special = ConstValSpecialStatic; |
| 25855 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; | 25855 | TypeStructField *struct_field = val->type->data.structure.fields[field_i]; |
| 25856 | field_val->type = struct_field->type_entry; | 25856 | field_val->type = struct_field->type_entry; |
| ... | @@ -25887,7 +25887,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25887,7 +25887,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25887 | src_assert(field->gen_index != SIZE_MAX, source_node); | 25887 | src_assert(field->gen_index != SIZE_MAX, source_node); |
| 25888 | if (field->gen_index != gen_i) | 25888 | if (field->gen_index != gen_i) |
| 25889 | break; | 25889 | break; |
| 25890 | ConstExprValue *field_val = val->data.x_struct.fields[src_i]; | 25890 | ZigValue *field_val = val->data.x_struct.fields[src_i]; |
| 25891 | field_val->special = ConstValSpecialStatic; | 25891 | field_val->special = ConstValSpecialStatic; |
| 25892 | field_val->type = field->type_entry; | 25892 | field_val->type = field->type_entry; |
| 25893 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); | 25893 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); |
| ... | @@ -25975,7 +25975,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25975,7 +25975,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25975 | } | 25975 | } |
| 25976 | | 25976 | |
| 25977 | if (instr_is_comptime(value)) { | 25977 | if (instr_is_comptime(value)) { |
| 25978 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 25978 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 25979 | if (!val) | 25979 | if (!val) |
| 25980 | return ira->codegen->invalid_instruction; | 25980 | return ira->codegen->invalid_instruction; |
| 25981 | | 25981 | |
| ... | @@ -26001,7 +26001,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -26001,7 +26001,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 26001 | return ira->codegen->invalid_instruction; | 26001 | return ira->codegen->invalid_instruction; |
| 26002 | | 26002 | |
| 26003 | if (instr_is_comptime(casted_int)) { | 26003 | if (instr_is_comptime(casted_int)) { |
| 26004 | ConstExprValue *val = ir_resolve_const(ira, casted_int, UndefBad); | 26004 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); |
| 26005 | if (!val) | 26005 | if (!val) |
| 26006 | return ira->codegen->invalid_instruction; | 26006 | return ira->codegen->invalid_instruction; |
| 26007 | | 26007 | |
| ... | @@ -26093,7 +26093,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -26093,7 +26093,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 26093 | } | 26093 | } |
| 26094 | | 26094 | |
| 26095 | if (instr_is_comptime(target)) { | 26095 | if (instr_is_comptime(target)) { |
| 26096 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 26096 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 26097 | if (!val) | 26097 | if (!val) |
| 26098 | return ira->codegen->invalid_instruction; | 26098 | return ira->codegen->invalid_instruction; |
| 26099 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 26099 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| ... | @@ -26506,7 +26506,7 @@ static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, I | ... | @@ -26506,7 +26506,7 @@ static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, I |
| 26506 | } | 26506 | } |
| 26507 | | 26507 | |
| 26508 | static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, ZigType *float_type, | 26508 | static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, ZigType *float_type, |
| 26509 | ConstExprValue *op, ConstExprValue *out_val) { | 26509 | ZigValue *op, ZigValue *out_val) { |
| 26510 | assert(ira && source_instr && float_type && out_val && op); | 26510 | assert(ira && source_instr && float_type && out_val && op); |
| 26511 | assert(float_type->id == ZigTypeIdFloat || | 26511 | assert(float_type->id == ZigTypeIdFloat || |
| 26512 | float_type->id == ZigTypeIdComptimeFloat); | 26512 | float_type->id == ZigTypeIdComptimeFloat); |
| ... | @@ -26719,12 +26719,12 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26719,12 +26719,12 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26719 | return ira->codegen->invalid_instruction; | 26719 | return ira->codegen->invalid_instruction; |
| 26720 | } | 26720 | } |
| 26721 | | 26721 | |
| 26722 | ConstExprValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 26722 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 26723 | if (!op1_const) | 26723 | if (!op1_const) |
| 26724 | return ira->codegen->invalid_instruction; | 26724 | return ira->codegen->invalid_instruction; |
| 26725 | | 26725 | |
| 26726 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 26726 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 26727 | ConstExprValue *out_val = &result->value; | 26727 | ZigValue *out_val = &result->value; |
| 26728 | | 26728 | |
| 26729 | if (expr_type->id == ZigTypeIdVector) { | 26729 | if (expr_type->id == ZigTypeIdVector) { |
| 26730 | expand_undef_array(ira->codegen, op1_const); | 26730 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -26732,8 +26732,8 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26732,8 +26732,8 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26732 | expand_undef_array(ira->codegen, out_val); | 26732 | expand_undef_array(ira->codegen, out_val); |
| 26733 | size_t len = expr_type->data.vector.len; | 26733 | size_t len = expr_type->data.vector.len; |
| 26734 | for (size_t i = 0; i < len; i += 1) { | 26734 | for (size_t i = 0; i < len; i += 1) { |
| 26735 | ConstExprValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i]; | 26735 | 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]; | 26736 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 26737 | assert(float_operand_op1->type == float_type); | 26737 | assert(float_operand_op1->type == float_type); |
| 26738 | assert(float_out_val->type == float_type); | 26738 | assert(float_out_val->type == float_type); |
| 26739 | ir_eval_float_op(ira, instruction, float_type, | 26739 | ir_eval_float_op(ira, instruction, float_type, |
| ... | @@ -26796,7 +26796,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26796,7 +26796,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26796 | } | 26796 | } |
| 26797 | | 26797 | |
| 26798 | if (instr_is_comptime(op)) { | 26798 | if (instr_is_comptime(op)) { |
| 26799 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 26799 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 26800 | if (val == nullptr) | 26800 | if (val == nullptr) |
| 26801 | return ira->codegen->invalid_instruction; | 26801 | return ira->codegen->invalid_instruction; |
| 26802 | if (val->special == ConstValSpecialUndef) | 26802 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -26809,13 +26809,13 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26809,13 +26809,13 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26809 | expand_undef_array(ira->codegen, val); | 26809 | expand_undef_array(ira->codegen, val); |
| 26810 | result->value.data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); | 26810 | 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) { | 26811 | 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]; | 26812 | 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, | 26813 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, |
| 26814 | op_elem_val, UndefOk))) | 26814 | op_elem_val, UndefOk))) |
| 26815 | { | 26815 | { |
| 26816 | return ira->codegen->invalid_instruction; | 26816 | return ira->codegen->invalid_instruction; |
| 26817 | } | 26817 | } |
| 26818 | ConstExprValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; | 26818 | ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; |
| 26819 | result_elem_val->type = int_type; | 26819 | result_elem_val->type = int_type; |
| 26820 | result_elem_val->special = op_elem_val->special; | 26820 | result_elem_val->special = op_elem_val->special; |
| 26821 | if (op_elem_val->special == ConstValSpecialUndef) | 26821 | if (op_elem_val->special == ConstValSpecialUndef) |
| ... | @@ -26857,7 +26857,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26857,7 +26857,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26857 | } | 26857 | } |
| 26858 | | 26858 | |
| 26859 | if (instr_is_comptime(op)) { | 26859 | if (instr_is_comptime(op)) { |
| 26860 | ConstExprValue *val = ir_resolve_const(ira, op, UndefOk); | 26860 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 26861 | if (val == nullptr) | 26861 | if (val == nullptr) |
| 26862 | return ira->codegen->invalid_instruction; | 26862 | return ira->codegen->invalid_instruction; |
| 26863 | if (val->special == ConstValSpecialUndef) | 26863 | if (val->special == ConstValSpecialUndef) |
| ... | @@ -27601,7 +27601,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27601,7 +27601,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27601 | ira->new_irb.codegen = codegen; | 27601 | ira->new_irb.codegen = codegen; |
| 27602 | ira->new_irb.exec = new_exec; | 27602 | ira->new_irb.exec = new_exec; |
| 27603 | | 27603 | |
| 27604 | ConstExprValue *vals = create_const_vals(ira->old_irb.exec->mem_slot_count); | 27604 | 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); | 27605 | 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) { | 27606 | 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]; | 27607 | ira->exec_context.mem_slot_list.items[i] = &vals[i]; |
| ... | @@ -27947,7 +27947,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -27947,7 +27947,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 27947 | return get_fn_type(ira->codegen, &fn_type_id); | 27947 | return get_fn_type(ira->codegen, &fn_type_id); |
| 27948 | } | 27948 | } |
| 27949 | | 27949 | |
| 27950 | static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | 27950 | static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 27951 | Error err; | 27951 | Error err; |
| 27952 | if (val->special != ConstValSpecialLazy) | 27952 | if (val->special != ConstValSpecialLazy) |
| 27953 | return ErrorNone; | 27953 | return ErrorNone; |
| ... | @@ -28071,7 +28071,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28071,7 +28071,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28071 | if (type_is_invalid(elem_type)) | 28071 | if (type_is_invalid(elem_type)) |
| 28072 | return ErrorSemanticAnalyzeFail; | 28072 | return ErrorSemanticAnalyzeFail; |
| 28073 | | 28073 | |
| 28074 | ConstExprValue *sentinel_val; | 28074 | ZigValue *sentinel_val; |
| 28075 | if (lazy_slice_type->sentinel != nullptr) { | 28075 | if (lazy_slice_type->sentinel != nullptr) { |
| 28076 | if (type_is_invalid(lazy_slice_type->sentinel->value.type)) | 28076 | if (type_is_invalid(lazy_slice_type->sentinel->value.type)) |
| 28077 | return ErrorSemanticAnalyzeFail; | 28077 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -28149,7 +28149,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28149,7 +28149,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28149 | if (type_is_invalid(elem_type)) | 28149 | if (type_is_invalid(elem_type)) |
| 28150 | return ErrorSemanticAnalyzeFail; | 28150 | return ErrorSemanticAnalyzeFail; |
| 28151 | | 28151 | |
| 28152 | ConstExprValue *sentinel_val; | 28152 | ZigValue *sentinel_val; |
| 28153 | if (lazy_ptr_type->sentinel != nullptr) { | 28153 | if (lazy_ptr_type->sentinel != nullptr) { |
| 28154 | if (type_is_invalid(lazy_ptr_type->sentinel->value.type)) | 28154 | if (type_is_invalid(lazy_ptr_type->sentinel->value.type)) |
| 28155 | return ErrorSemanticAnalyzeFail; | 28155 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -28276,7 +28276,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { | ... | @@ -28276,7 +28276,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28276 | zig_unreachable(); | 28276 | zig_unreachable(); |
| 28277 | } | 28277 | } |
| 28278 | | 28278 | |
| 28279 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) { | 28279 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 28280 | Error err; | 28280 | Error err; |
| 28281 | if ((err = ir_resolve_lazy_raw(source_node, val))) { | 28281 | if ((err = ir_resolve_lazy_raw(source_node, val))) { |
| 28282 | if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) { | 28282 | if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) { |