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

rename ConstExprValue → ZigValue


9 files changed, 686 insertions(+), 686 deletions(-)

src/all_types.hpp+43-43
......@@ -32,7 +32,7 @@ struct ErrorTableEntry;
3232struct BuiltinFnEntry;
3333struct TypeStructField;
3434struct CodeGen;
35struct ConstExprValue;
35struct ZigValue;
3636struct IrInstruction;
3737struct IrInstructionCast;
3838struct IrInstructionAllocaGen;
......@@ -130,38 +130,38 @@ struct ConstParent {
130130
131131 union {
132132 struct {
133 ConstExprValue *array_val;
133 ZigValue *array_val;
134134 size_t elem_index;
135135 } p_array;
136136 struct {
137 ConstExprValue *struct_val;
137 ZigValue *struct_val;
138138 size_t field_index;
139139 } p_struct;
140140 struct {
141 ConstExprValue *err_union_val;
141 ZigValue *err_union_val;
142142 } p_err_union_code;
143143 struct {
144 ConstExprValue *err_union_val;
144 ZigValue *err_union_val;
145145 } p_err_union_payload;
146146 struct {
147 ConstExprValue *optional_val;
147 ZigValue *optional_val;
148148 } p_optional_payload;
149149 struct {
150 ConstExprValue *union_val;
150 ZigValue *union_val;
151151 } p_union;
152152 struct {
153 ConstExprValue *scalar_val;
153 ZigValue *scalar_val;
154154 } p_scalar;
155155 } data;
156156};
157157
158158struct ConstStructValue {
159 ConstExprValue **fields;
159 ZigValue **fields;
160160};
161161
162162struct ConstUnionValue {
163163 BigInt tag;
164 ConstExprValue *payload;
164 ZigValue *payload;
165165};
166166
167167enum ConstArraySpecial {
......@@ -174,7 +174,7 @@ struct ConstArrayValue {
174174 ConstArraySpecial special;
175175 union {
176176 struct {
177 ConstExprValue *elements;
177 ZigValue *elements;
178178 } s_none;
179179 Buf *s_buf;
180180 } data;
......@@ -235,24 +235,24 @@ struct ConstPtrValue {
235235
236236 union {
237237 struct {
238 ConstExprValue *pointee;
238 ZigValue *pointee;
239239 } ref;
240240 struct {
241 ConstExprValue *array_val;
241 ZigValue *array_val;
242242 size_t elem_index;
243243 } base_array;
244244 struct {
245 ConstExprValue *struct_val;
245 ZigValue *struct_val;
246246 size_t field_index;
247247 } base_struct;
248248 struct {
249 ConstExprValue *err_union_val;
249 ZigValue *err_union_val;
250250 } base_err_union_code;
251251 struct {
252 ConstExprValue *err_union_val;
252 ZigValue *err_union_val;
253253 } base_err_union_payload;
254254 struct {
255 ConstExprValue *optional_val;
255 ZigValue *optional_val;
256256 } base_optional_payload;
257257 struct {
258258 uint64_t addr;
......@@ -264,8 +264,8 @@ struct ConstPtrValue {
264264};
265265
266266struct ConstErrValue {
267 ConstExprValue *error_set;
268 ConstExprValue *payload;
267 ZigValue *error_set;
268 ZigValue *payload;
269269};
270270
271271struct ConstBoundFnValue {
......@@ -406,7 +406,7 @@ struct LazyValueErrUnionType {
406406 Buf *type_name;
407407};
408408
409struct ConstExprValue {
409struct ZigValue {
410410 ZigType *type;
411411 ConstValSpecial special;
412412 ConstParent parent;
......@@ -423,7 +423,7 @@ struct ConstExprValue {
423423 bool x_bool;
424424 ConstBoundFnValue x_bound_fn;
425425 ZigType *x_type;
426 ConstExprValue *x_optional;
426 ZigValue *x_optional;
427427 ConstErrValue x_err_union;
428428 ErrorTableEntry *x_err_set;
429429 BigInt x_enum_tag;
......@@ -443,8 +443,8 @@ struct ConstExprValue {
443443 } data;
444444
445445 // uncomment these to find bugs. can't leave them uncommented because of a gcc-9 warning
446 //ConstExprValue(const ConstExprValue &other) = delete; // plz zero initialize with {}
447 //ConstExprValue& operator= (const ConstExprValue &other) = delete; // use copy_const_val
446 //ZigValue(const ZigValue &other) = delete; // plz zero initialize with {}
447 //ZigValue& operator= (const ZigValue &other) = delete; // use copy_const_val
448448};
449449
450450enum ReturnKnowledge {
......@@ -525,7 +525,7 @@ struct TldCompTime {
525525struct TldUsingNamespace {
526526 Tld base;
527527
528 ConstExprValue *using_namespace_value;
528 ZigValue *using_namespace_value;
529529};
530530
531531struct TypeEnumField {
......@@ -538,7 +538,7 @@ struct TypeEnumField {
538538struct TypeUnionField {
539539 Buf *name;
540540 ZigType *type_entry; // available after ResolveStatusSizeKnown
541 ConstExprValue *type_val; // available after ResolveStatusZeroBitsKnown
541 ZigValue *type_val; // available after ResolveStatusZeroBitsKnown
542542 TypeEnumField *enum_field;
543543 AstNode *decl_node;
544544 uint32_t gen_index;
......@@ -1171,7 +1171,7 @@ struct FnTypeParamInfo {
11711171struct GenericFnTypeId {
11721172 CodeGen *codegen;
11731173 ZigFn *fn_entry;
1174 ConstExprValue *params;
1174 ZigValue *params;
11751175 size_t param_count;
11761176};
11771177
......@@ -1213,7 +1213,7 @@ struct ZigTypePointer {
12131213 // This can be null. If it is non-null, it means the pointer is terminated by this
12141214 // sentinel value. This is most commonly used for C-style strings, with a 0 byte
12151215 // to specify the length of the memory pointed to.
1216 ConstExprValue *sentinel;
1216 ZigValue *sentinel;
12171217
12181218 PtrLen ptr_len;
12191219 uint32_t explicit_alignment; // 0 means use ABI alignment
......@@ -1242,18 +1242,18 @@ struct ZigTypeFloat {
12421242struct ZigTypeArray {
12431243 ZigType *child_type;
12441244 uint64_t len;
1245 ConstExprValue *sentinel;
1245 ZigValue *sentinel;
12461246};
12471247
12481248struct TypeStructField {
12491249 Buf *name;
12501250 ZigType *type_entry; // available after ResolveStatusSizeKnown
1251 ConstExprValue *type_val; // available after ResolveStatusZeroBitsKnown
1251 ZigValue *type_val; // available after ResolveStatusZeroBitsKnown
12521252 size_t src_index;
12531253 size_t gen_index;
12541254 size_t offset; // byte offset from beginning of struct
12551255 AstNode *decl_node;
1256 ConstExprValue *init_val; // null and then memoized
1256 ZigValue *init_val; // null and then memoized
12571257 uint32_t bit_offset_in_host; // offset from the memory at gen_index
12581258 uint32_t host_int_bytes; // size of host integer
12591259 uint32_t align;
......@@ -1515,7 +1515,7 @@ struct ZigType {
15151515 ZigType *any_frame_parent;
15161516 // If we generate a constant name value for this type, we memoize it here.
15171517 // The type of this is array
1518 ConstExprValue *cached_const_name_val;
1518 ZigValue *cached_const_name_val;
15191519
15201520 OnePossibleValue one_possible_value;
15211521 // Known after ResolveStatusAlignmentKnown.
......@@ -1771,7 +1771,7 @@ struct TypeId {
17711771 CodeGen *codegen;
17721772 ZigType *child_type;
17731773 InferredStructField *inferred_struct_field;
1774 ConstExprValue *sentinel;
1774 ZigValue *sentinel;
17751775 PtrLen ptr_len;
17761776 uint32_t alignment;
17771777
......@@ -1787,7 +1787,7 @@ struct TypeId {
17871787 CodeGen *codegen;
17881788 ZigType *child_type;
17891789 uint64_t size;
1790 ConstExprValue *sentinel;
1790 ZigValue *sentinel;
17911791 } array;
17921792 struct {
17931793 bool is_signed;
......@@ -1960,13 +1960,13 @@ struct CodeGen {
19601960 HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table;
19611961 HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table;
19621962 HashMap<GenericFnTypeId *, ZigFn *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;
1963 HashMap<Scope *, ConstExprValue *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
1963 HashMap<Scope *, ZigValue *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
19641964 HashMap<ZigLLVMFnKey, LLVMValueRef, zig_llvm_fn_key_hash, zig_llvm_fn_key_eql> llvm_fn_table;
19651965 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> exported_symbol_names;
19661966 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_prototypes;
1967 HashMap<Buf *, ConstExprValue *, buf_hash, buf_eql_buf> string_literals_table;
1968 HashMap<const ZigType *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
1969 HashMap<const ZigType *, ConstExprValue *, type_ptr_hash, type_ptr_eql> one_possible_values;
1967 HashMap<Buf *, ZigValue *, buf_hash, buf_eql_buf> string_literals_table;
1968 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
1969 HashMap<const ZigType *, ZigValue *, type_ptr_hash, type_ptr_eql> one_possible_values;
19701970
19711971 ZigList<Tld *> resolve_queue;
19721972 size_t resolve_queue_index;
......@@ -2043,9 +2043,9 @@ struct CodeGen {
20432043 IrInstruction *invalid_instruction;
20442044 IrInstruction *unreach_instruction;
20452045
2046 ConstExprValue const_zero_byte;
2047 ConstExprValue const_void_val;
2048 ConstExprValue panic_msg_vals[PanicMsgIdCount];
2046 ZigValue const_zero_byte;
2047 ZigValue const_void_val;
2048 ZigValue panic_msg_vals[PanicMsgIdCount];
20492049
20502050 // The function definitions this module includes.
20512051 ZigList<ZigFn *> fn_defs;
......@@ -2163,7 +2163,7 @@ struct CodeGen {
21632163
21642164struct ZigVar {
21652165 const char *name;
2166 ConstExprValue *const_value;
2166 ZigValue *const_value;
21672167 ZigType *var_type;
21682168 LLVMValueRef value_ref;
21692169 IrInstruction *is_comptime;
......@@ -2202,7 +2202,7 @@ struct ErrorTableEntry {
22022202 ZigType *set_with_only_this_in_it;
22032203 // If we generate a constant error name value for this error, we memoize it here.
22042204 // The type of this is array
2205 ConstExprValue *cached_error_name_val;
2205 ZigValue *cached_error_name_val;
22062206};
22072207
22082208enum ScopeId {
......@@ -2621,7 +2621,7 @@ struct IrInstruction {
26212621 Scope *scope;
26222622 AstNode *source_node;
26232623 LLVMValueRef llvm_value;
2624 ConstExprValue value;
2624 ZigValue value;
26252625 uint32_t debug_id;
26262626 // if ref_count is zero and the instruction has no side effects,
26272627 // the instruction can be omitted in codegen
src/analyze.cpp+118-118
......@@ -511,7 +511,7 @@ static void append_ptr_type_attrs(Buf *type_name, ZigType *ptr_type) {
511511ZigType *get_pointer_to_type_extra2(CodeGen *g, ZigType *child_type, bool is_const,
512512 bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment,
513513 uint32_t bit_offset_in_host, uint32_t host_int_bytes, bool allow_zero,
514 uint32_t vector_index, InferredStructField *inferred_struct_field, ConstExprValue *sentinel)
514 uint32_t vector_index, InferredStructField *inferred_struct_field, ZigValue *sentinel)
515515{
516516 assert(ptr_len != PtrLenC || allow_zero);
517517 assert(!type_is_invalid(child_type));
......@@ -760,7 +760,7 @@ ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payloa
760760 return entry;
761761}
762762
763ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, ConstExprValue *sentinel) {
763ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, ZigValue *sentinel) {
764764 TypeId type_id = {};
765765 type_id.id = ZigTypeIdArray;
766766 type_id.data.array.codegen = g;
......@@ -956,7 +956,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) {
956956
957957ZigType *get_stack_trace_type(CodeGen *g) {
958958 if (g->stack_trace_type == nullptr) {
959 ConstExprValue *stack_trace_type_val = get_builtin_value(g, "StackTrace");
959 ZigValue *stack_trace_type_val = get_builtin_value(g, "StackTrace");
960960 assert(stack_trace_type_val->type->id == ZigTypeIdMetaType);
961961
962962 g->stack_trace_type = stack_trace_type_val->data.x_type;
......@@ -1095,7 +1095,7 @@ ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind
10951095 return entry;
10961096}
10971097
1098ConstExprValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry,
1098ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry,
10991099 Buf *type_name, UndefAllowed undef)
11001100{
11011101 size_t backward_branch_count = 0;
......@@ -1105,8 +1105,8 @@ ConstExprValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, Zig
11051105 nullptr, nullptr, node, type_name, nullptr, nullptr, undef);
11061106}
11071107
1108Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, ZigType *parent_type,
1109 ConstExprValue *parent_type_val, bool *is_zero_bits)
1108Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent_type,
1109 ZigValue *parent_type_val, bool *is_zero_bits)
11101110{
11111111 Error err;
11121112 if (type_val->special != ConstValSpecialLazy) {
......@@ -1160,7 +1160,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, ZigType *
11601160 zig_unreachable();
11611161}
11621162
1163Error type_val_resolve_is_opaque_type(CodeGen *g, ConstExprValue *type_val, bool *is_opaque_type) {
1163Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) {
11641164 if (type_val->special != ConstValSpecialLazy) {
11651165 assert(type_val->special == ConstValSpecialStatic);
11661166 if (type_val->data.x_type == g->builtin_types.entry_var) {
......@@ -1186,7 +1186,7 @@ Error type_val_resolve_is_opaque_type(CodeGen *g, ConstExprValue *type_val, bool
11861186 zig_unreachable();
11871187}
11881188
1189static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ConstExprValue *type_val) {
1189static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ZigValue *type_val) {
11901190 if (type_val->special != ConstValSpecialLazy) {
11911191 return type_requires_comptime(g, type_val->data.x_type);
11921192 }
......@@ -1244,7 +1244,7 @@ static ReqCompTime type_val_resolve_requires_comptime(CodeGen *g, ConstExprValue
12441244 zig_unreachable();
12451245}
12461246
1247Error type_val_resolve_abi_size(CodeGen *g, AstNode *source_node, ConstExprValue *type_val,
1247Error type_val_resolve_abi_size(CodeGen *g, AstNode *source_node, ZigValue *type_val,
12481248 size_t *abi_size, size_t *size_in_bits)
12491249{
12501250 Error err;
......@@ -1311,7 +1311,7 @@ start_over:
13111311 zig_unreachable();
13121312}
13131313
1314Error type_val_resolve_abi_align(CodeGen *g, ConstExprValue *type_val, uint32_t *abi_align) {
1314Error type_val_resolve_abi_align(CodeGen *g, ZigValue *type_val, uint32_t *abi_align) {
13151315 Error err;
13161316 if (type_val->special != ConstValSpecialLazy) {
13171317 assert(type_val->special == ConstValSpecialStatic);
......@@ -1356,7 +1356,7 @@ Error type_val_resolve_abi_align(CodeGen *g, ConstExprValue *type_val, uint32_t
13561356 zig_unreachable();
13571357}
13581358
1359static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ConstExprValue *type_val) {
1359static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigValue *type_val) {
13601360 if (type_val->special != ConstValSpecialLazy) {
13611361 return type_has_one_possible_value(g, type_val->data.x_type);
13621362 }
......@@ -1398,7 +1398,7 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, Cons
13981398}
13991399
14001400ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
1401 ConstExprValue *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type,
1401 ZigValue *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type,
14021402 nullptr, UndefBad);
14031403 if (type_is_invalid(result->type))
14041404 return g->builtin_types.entry_invalid;
......@@ -1451,7 +1451,7 @@ void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_cou
14511451}
14521452
14531453static bool analyze_const_align(CodeGen *g, Scope *scope, AstNode *node, uint32_t *result) {
1454 ConstExprValue *align_result = analyze_const_value(g, scope, node, get_align_amt_type(g),
1454 ZigValue *align_result = analyze_const_value(g, scope, node, get_align_amt_type(g),
14551455 nullptr, UndefBad);
14561456 if (type_is_invalid(align_result->type))
14571457 return false;
......@@ -1474,15 +1474,15 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **
14741474 ZigType *ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
14751475 PtrLenUnknown, 0, 0, 0, false);
14761476 ZigType *str_type = get_slice_type(g, ptr_type);
1477 ConstExprValue *result_val = analyze_const_value(g, scope, node, str_type, nullptr, UndefBad);
1477 ZigValue *result_val = analyze_const_value(g, scope, node, str_type, nullptr, UndefBad);
14781478 if (type_is_invalid(result_val->type))
14791479 return false;
14801480
1481 ConstExprValue *ptr_field = result_val->data.x_struct.fields[slice_ptr_index];
1482 ConstExprValue *len_field = result_val->data.x_struct.fields[slice_len_index];
1481 ZigValue *ptr_field = result_val->data.x_struct.fields[slice_ptr_index];
1482 ZigValue *len_field = result_val->data.x_struct.fields[slice_len_index];
14831483
14841484 assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray);
1485 ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val;
1485 ZigValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val;
14861486 if (array_val->data.x_array.special == ConstArraySpecialBuf) {
14871487 *out_buffer = array_val->data.x_array.data.s_buf;
14881488 return true;
......@@ -1493,7 +1493,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **
14931493 buf_resize(result, len);
14941494 for (size_t i = 0; i < len; i += 1) {
14951495 size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i;
1496 ConstExprValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index];
1496 ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index];
14971497 if (char_val->special == ConstValSpecialUndef) {
14981498 add_node_error(g, node, buf_sprintf("use of undefined value"));
14991499 return false;
......@@ -2621,7 +2621,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {
26212621
26222622 if (tag_value != nullptr) {
26232623 // A user-specified value is available
2624 ConstExprValue *result = analyze_const_value(g, scope, tag_value, tag_int_type,
2624 ZigValue *result = analyze_const_value(g, scope, tag_value, tag_int_type,
26252625 nullptr, UndefBad);
26262626 if (type_is_invalid(result->type)) {
26272627 enum_type->data.enumeration.resolve_status = ResolveStatusInvalid;
......@@ -2756,7 +2756,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
27562756 return ErrorSemanticAnalyzeFail;
27572757 }
27582758
2759 ConstExprValue *field_type_val;
2759 ZigValue *field_type_val;
27602760 if (decl_node->type == NodeTypeContainerDecl) {
27612761 field_type_val = analyze_const_value(g, scope,
27622762 field_node->data.struct_field.type, g->builtin_types.entry_type, nullptr, LazyOkNoUndef);
......@@ -3051,7 +3051,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
30513051 return ErrorSemanticAnalyzeFail;
30523052 }
30533053 } else {
3054 ConstExprValue *field_type_val = analyze_const_value(g, scope,
3054 ZigValue *field_type_val = analyze_const_value(g, scope,
30553055 field_node->data.struct_field.type, g->builtin_types.entry_type, nullptr, LazyOkNoUndef);
30563056 if (type_is_invalid(field_type_val->type)) {
30573057 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
......@@ -3117,7 +3117,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
31173117 // In a second pass we will fill in the unspecified ones.
31183118 if (tag_value != nullptr) {
31193119 ZigType *tag_int_type = tag_type->data.enumeration.tag_int_type;
3120 ConstExprValue *result = analyze_const_value(g, scope, tag_value, tag_int_type,
3120 ZigValue *result = analyze_const_value(g, scope, tag_value, tag_int_type,
31213121 nullptr, UndefBad);
31223122 if (type_is_invalid(result->type)) {
31233123 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
......@@ -3545,7 +3545,7 @@ void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source
35453545 tld->parent_scope = parent_scope;
35463546}
35473547
3548void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value) {
3548void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) {
35493549 Tld *tld = get_container_scope(g->compile_var_import)->decl_table.get(name);
35503550 resolve_top_level_decl(g, tld, tld->source_node, false);
35513551 assert(tld->id == TldIdVar);
......@@ -3717,7 +3717,7 @@ ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry
37173717// Set name to nullptr to make the variable anonymous (not visible to programmer).
37183718// TODO merge with definition of add_local_var in ir.cpp
37193719ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,
3720 bool is_const, ConstExprValue *const_value, Tld *src_tld, ZigType *var_type)
3720 bool is_const, ZigValue *const_value, Tld *src_tld, ZigType *var_type)
37213721{
37223722 Error err;
37233723 assert(const_value != nullptr);
......@@ -3815,7 +3815,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
38153815
38163816 assert(!is_export || !is_extern);
38173817
3818 ConstExprValue *init_value = nullptr;
3818 ZigValue *init_value = nullptr;
38193819
38203820 // TODO more validation for types that can't be used for export/extern variables
38213821 ZigType *implicit_type = nullptr;
......@@ -3853,7 +3853,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
38533853 ZigType *type = explicit_type ? explicit_type : implicit_type;
38543854 assert(type != nullptr); // should have been caught by the parser
38553855
3856 ConstExprValue *init_val = (init_value != nullptr) ? init_value : create_const_runtime(type);
3856 ZigValue *init_val = (init_value != nullptr) ? init_value : create_const_runtime(type);
38573857
38583858 tld_var->var = add_variable(g, source_node, tld_var->base.parent_scope, var_decl->symbol,
38593859 is_const, init_val, &tld_var->base, type);
......@@ -3900,7 +3900,7 @@ static void add_symbols_from_container(CodeGen *g, TldUsingNamespace *src_using_
39003900 }
39013901 }
39023902
3903 ConstExprValue *use_expr = src_using_namespace->using_namespace_value;
3903 ZigValue *use_expr = src_using_namespace->using_namespace_value;
39043904 if (type_is_invalid(use_expr->type)) {
39053905 dest_decls_scope->any_imports_failed = true;
39063906 return;
......@@ -3977,7 +3977,7 @@ static void preview_use_decl(CodeGen *g, TldUsingNamespace *using_namespace, Sco
39773977
39783978 using_namespace->base.resolution = TldResolutionResolving;
39793979 assert(using_namespace->base.source_node->type == NodeTypeUsingNamespace);
3980 ConstExprValue *result = analyze_const_value(g, &dest_decls_scope->base,
3980 ZigValue *result = analyze_const_value(g, &dest_decls_scope->base,
39813981 using_namespace->base.source_node->data.using_namespace.expr, g->builtin_types.entry_type,
39823982 nullptr, UndefBad);
39833983 using_namespace->using_namespace_value = result;
......@@ -5029,12 +5029,12 @@ bool fn_type_id_eql(FnTypeId *a, FnTypeId *b) {
50295029 return true;
50305030}
50315031
5032static uint32_t hash_const_val_error_set(ConstExprValue *const_val) {
5032static uint32_t hash_const_val_error_set(ZigValue *const_val) {
50335033 assert(const_val->data.x_err_set != nullptr);
50345034 return const_val->data.x_err_set->value ^ 2630160122;
50355035}
50365036
5037static uint32_t hash_const_val_ptr(ConstExprValue *const_val) {
5037static uint32_t hash_const_val_ptr(ZigValue *const_val) {
50385038 uint32_t hash_val = 0;
50395039 switch (const_val->data.x_ptr.mut) {
50405040 case ConstPtrMutRuntimeVar:
......@@ -5095,7 +5095,7 @@ static uint32_t hash_const_val_ptr(ConstExprValue *const_val) {
50955095 zig_unreachable();
50965096}
50975097
5098static uint32_t hash_const_val(ConstExprValue *const_val) {
5098static uint32_t hash_const_val(ZigValue *const_val) {
50995099 assert(const_val->special == ConstValSpecialStatic);
51005100 switch (const_val->type->id) {
51015101 case ZigTypeIdOpaque:
......@@ -5224,7 +5224,7 @@ uint32_t generic_fn_type_id_hash(GenericFnTypeId *id) {
52245224 uint32_t result = 0;
52255225 result += hash_ptr(id->fn_entry);
52265226 for (size_t i = 0; i < id->param_count; i += 1) {
5227 ConstExprValue *generic_param = &id->params[i];
5227 ZigValue *generic_param = &id->params[i];
52285228 if (generic_param->special != ConstValSpecialRuntime) {
52295229 result += hash_const_val(generic_param);
52305230 result += hash_ptr(generic_param->type);
......@@ -5238,8 +5238,8 @@ bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b) {
52385238 if (a->fn_entry != b->fn_entry) return false;
52395239 if (a->param_count != b->param_count) return false;
52405240 for (size_t i = 0; i < a->param_count; i += 1) {
5241 ConstExprValue *a_val = &a->params[i];
5242 ConstExprValue *b_val = &b->params[i];
5241 ZigValue *a_val = &a->params[i];
5242 ZigValue *b_val = &b->params[i];
52435243 if (a_val->type != b_val->type) return false;
52445244 if (a_val->special != ConstValSpecialRuntime && b_val->special != ConstValSpecialRuntime) {
52455245 assert(a_val->special == ConstValSpecialStatic);
......@@ -5254,7 +5254,7 @@ bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b) {
52545254 return true;
52555255}
52565256
5257static bool can_mutate_comptime_var_state(ConstExprValue *value) {
5257static bool can_mutate_comptime_var_state(ZigValue *value) {
52585258 assert(value != nullptr);
52595259 switch (value->type->id) {
52605260 case ZigTypeIdInvalid:
......@@ -5562,12 +5562,12 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) {
55625562 zig_unreachable();
55635563}
55645564
5565ConstExprValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
5565ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
55665566 auto entry = g->one_possible_values.maybe_get(type_entry);
55675567 if (entry != nullptr) {
55685568 return entry->value;
55695569 }
5570 ConstExprValue *result = create_const_vals(1);
5570 ZigValue *result = create_const_vals(1);
55715571 result->type = type_entry;
55725572 result->special = ConstValSpecialStatic;
55735573 g->one_possible_values.put(type_entry, result);
......@@ -5637,15 +5637,15 @@ ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) {
56375637 zig_unreachable();
56385638}
56395639
5640void init_const_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *str) {
5640void init_const_str_lit(CodeGen *g, ZigValue *const_val, Buf *str) {
56415641 auto entry = g->string_literals_table.maybe_get(str);
56425642 if (entry != nullptr) {
5643 memcpy(const_val, entry->value, sizeof(ConstExprValue));
5643 memcpy(const_val, entry->value, sizeof(ZigValue));
56445644 return;
56455645 }
56465646
56475647 // first we build the underlying array
5648 ConstExprValue *array_val = create_const_vals(1);
5648 ZigValue *array_val = create_const_vals(1);
56495649 array_val->special = ConstValSpecialStatic;
56505650 array_val->type = get_array_type(g, g->builtin_types.entry_u8, buf_len(str), &g->const_zero_byte);
56515651 array_val->data.x_array.special = ConstArraySpecialBuf;
......@@ -5661,71 +5661,71 @@ void init_const_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *str) {
56615661 g->string_literals_table.put(str, const_val);
56625662}
56635663
5664ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str) {
5665 ConstExprValue *const_val = create_const_vals(1);
5664ZigValue *create_const_str_lit(CodeGen *g, Buf *str) {
5665 ZigValue *const_val = create_const_vals(1);
56665666 init_const_str_lit(g, const_val, str);
56675667 return const_val;
56685668}
56695669
5670void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint) {
5670void init_const_bigint(ZigValue *const_val, ZigType *type, const BigInt *bigint) {
56715671 const_val->special = ConstValSpecialStatic;
56725672 const_val->type = type;
56735673 bigint_init_bigint(&const_val->data.x_bigint, bigint);
56745674}
56755675
5676ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint) {
5677 ConstExprValue *const_val = create_const_vals(1);
5676ZigValue *create_const_bigint(ZigType *type, const BigInt *bigint) {
5677 ZigValue *const_val = create_const_vals(1);
56785678 init_const_bigint(const_val, type, bigint);
56795679 return const_val;
56805680}
56815681
56825682
5683void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative) {
5683void init_const_unsigned_negative(ZigValue *const_val, ZigType *type, uint64_t x, bool negative) {
56845684 const_val->special = ConstValSpecialStatic;
56855685 const_val->type = type;
56865686 bigint_init_unsigned(&const_val->data.x_bigint, x);
56875687 const_val->data.x_bigint.is_negative = negative;
56885688}
56895689
5690ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative) {
5691 ConstExprValue *const_val = create_const_vals(1);
5690ZigValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative) {
5691 ZigValue *const_val = create_const_vals(1);
56925692 init_const_unsigned_negative(const_val, type, x, negative);
56935693 return const_val;
56945694}
56955695
5696void init_const_usize(CodeGen *g, ConstExprValue *const_val, uint64_t x) {
5696void init_const_usize(CodeGen *g, ZigValue *const_val, uint64_t x) {
56975697 return init_const_unsigned_negative(const_val, g->builtin_types.entry_usize, x, false);
56985698}
56995699
5700ConstExprValue *create_const_usize(CodeGen *g, uint64_t x) {
5700ZigValue *create_const_usize(CodeGen *g, uint64_t x) {
57015701 return create_const_unsigned_negative(g->builtin_types.entry_usize, x, false);
57025702}
57035703
5704void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x) {
5704void init_const_signed(ZigValue *const_val, ZigType *type, int64_t x) {
57055705 const_val->special = ConstValSpecialStatic;
57065706 const_val->type = type;
57075707 bigint_init_signed(&const_val->data.x_bigint, x);
57085708}
57095709
5710ConstExprValue *create_const_signed(ZigType *type, int64_t x) {
5711 ConstExprValue *const_val = create_const_vals(1);
5710ZigValue *create_const_signed(ZigType *type, int64_t x) {
5711 ZigValue *const_val = create_const_vals(1);
57125712 init_const_signed(const_val, type, x);
57135713 return const_val;
57145714}
57155715
5716void init_const_null(ConstExprValue *const_val, ZigType *type) {
5716void init_const_null(ZigValue *const_val, ZigType *type) {
57175717 const_val->special = ConstValSpecialStatic;
57185718 const_val->type = type;
57195719 const_val->data.x_optional = nullptr;
57205720}
57215721
5722ConstExprValue *create_const_null(ZigType *type) {
5723 ConstExprValue *const_val = create_const_vals(1);
5722ZigValue *create_const_null(ZigType *type) {
5723 ZigValue *const_val = create_const_vals(1);
57245724 init_const_null(const_val, type);
57255725 return const_val;
57265726}
57275727
5728void init_const_float(ConstExprValue *const_val, ZigType *type, double value) {
5728void init_const_float(ZigValue *const_val, ZigType *type, double value) {
57295729 const_val->special = ConstValSpecialStatic;
57305730 const_val->type = type;
57315731 if (type->id == ZigTypeIdComptimeFloat) {
......@@ -5752,61 +5752,61 @@ void init_const_float(ConstExprValue *const_val, ZigType *type, double value) {
57525752 }
57535753}
57545754
5755ConstExprValue *create_const_float(ZigType *type, double value) {
5756 ConstExprValue *const_val = create_const_vals(1);
5755ZigValue *create_const_float(ZigType *type, double value) {
5756 ZigValue *const_val = create_const_vals(1);
57575757 init_const_float(const_val, type, value);
57585758 return const_val;
57595759}
57605760
5761void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag) {
5761void init_const_enum(ZigValue *const_val, ZigType *type, const BigInt *tag) {
57625762 const_val->special = ConstValSpecialStatic;
57635763 const_val->type = type;
57645764 bigint_init_bigint(&const_val->data.x_enum_tag, tag);
57655765}
57665766
5767ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag) {
5768 ConstExprValue *const_val = create_const_vals(1);
5767ZigValue *create_const_enum(ZigType *type, const BigInt *tag) {
5768 ZigValue *const_val = create_const_vals(1);
57695769 init_const_enum(const_val, type, tag);
57705770 return const_val;
57715771}
57725772
57735773
5774void init_const_bool(CodeGen *g, ConstExprValue *const_val, bool value) {
5774void init_const_bool(CodeGen *g, ZigValue *const_val, bool value) {
57755775 const_val->special = ConstValSpecialStatic;
57765776 const_val->type = g->builtin_types.entry_bool;
57775777 const_val->data.x_bool = value;
57785778}
57795779
5780ConstExprValue *create_const_bool(CodeGen *g, bool value) {
5781 ConstExprValue *const_val = create_const_vals(1);
5780ZigValue *create_const_bool(CodeGen *g, bool value) {
5781 ZigValue *const_val = create_const_vals(1);
57825782 init_const_bool(g, const_val, value);
57835783 return const_val;
57845784}
57855785
5786void init_const_runtime(ConstExprValue *const_val, ZigType *type) {
5786void init_const_runtime(ZigValue *const_val, ZigType *type) {
57875787 const_val->special = ConstValSpecialRuntime;
57885788 const_val->type = type;
57895789}
57905790
5791ConstExprValue *create_const_runtime(ZigType *type) {
5792 ConstExprValue *const_val = create_const_vals(1);
5791ZigValue *create_const_runtime(ZigType *type) {
5792 ZigValue *const_val = create_const_vals(1);
57935793 init_const_runtime(const_val, type);
57945794 return const_val;
57955795}
57965796
5797void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value) {
5797void init_const_type(CodeGen *g, ZigValue *const_val, ZigType *type_value) {
57985798 const_val->special = ConstValSpecialStatic;
57995799 const_val->type = g->builtin_types.entry_type;
58005800 const_val->data.x_type = type_value;
58015801}
58025802
5803ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value) {
5804 ConstExprValue *const_val = create_const_vals(1);
5803ZigValue *create_const_type(CodeGen *g, ZigType *type_value) {
5804 ZigValue *const_val = create_const_vals(1);
58055805 init_const_type(g, const_val, type_value);
58065806 return const_val;
58075807}
58085808
5809void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
5809void init_const_slice(CodeGen *g, ZigValue *const_val, ZigValue *array_val,
58105810 size_t start, size_t len, bool is_const)
58115811{
58125812 assert(array_val->type->id == ZigTypeIdArray);
......@@ -5823,13 +5823,13 @@ void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *arr
58235823 init_const_usize(g, const_val->data.x_struct.fields[slice_len_index], len);
58245824}
58255825
5826ConstExprValue *create_const_slice(CodeGen *g, ConstExprValue *array_val, size_t start, size_t len, bool is_const) {
5827 ConstExprValue *const_val = create_const_vals(1);
5826ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const) {
5827 ZigValue *const_val = create_const_vals(1);
58285828 init_const_slice(g, const_val, array_val, start, len, is_const);
58295829 return const_val;
58305830}
58315831
5832void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
5832void init_const_ptr_array(CodeGen *g, ZigValue *const_val, ZigValue *array_val,
58335833 size_t elem_index, bool is_const, PtrLen ptr_len)
58345834{
58355835 assert(array_val->type->id == ZigTypeIdArray);
......@@ -5843,28 +5843,28 @@ void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue
58435843 const_val->data.x_ptr.data.base_array.elem_index = elem_index;
58445844}
58455845
5846ConstExprValue *create_const_ptr_array(CodeGen *g, ConstExprValue *array_val, size_t elem_index, bool is_const,
5846ZigValue *create_const_ptr_array(CodeGen *g, ZigValue *array_val, size_t elem_index, bool is_const,
58475847 PtrLen ptr_len)
58485848{
5849 ConstExprValue *const_val = create_const_vals(1);
5849 ZigValue *const_val = create_const_vals(1);
58505850 init_const_ptr_array(g, const_val, array_val, elem_index, is_const, ptr_len);
58515851 return const_val;
58525852}
58535853
5854void init_const_ptr_ref(CodeGen *g, ConstExprValue *const_val, ConstExprValue *pointee_val, bool is_const) {
5854void init_const_ptr_ref(CodeGen *g, ZigValue *const_val, ZigValue *pointee_val, bool is_const) {
58555855 const_val->special = ConstValSpecialStatic;
58565856 const_val->type = get_pointer_to_type(g, pointee_val->type, is_const);
58575857 const_val->data.x_ptr.special = ConstPtrSpecialRef;
58585858 const_val->data.x_ptr.data.ref.pointee = pointee_val;
58595859}
58605860
5861ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bool is_const) {
5862 ConstExprValue *const_val = create_const_vals(1);
5861ZigValue *create_const_ptr_ref(CodeGen *g, ZigValue *pointee_val, bool is_const) {
5862 ZigValue *const_val = create_const_vals(1);
58635863 init_const_ptr_ref(g, const_val, pointee_val, is_const);
58645864 return const_val;
58655865}
58665866
5867void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
5867void init_const_ptr_hard_coded_addr(CodeGen *g, ZigValue *const_val, ZigType *pointee_type,
58685868 size_t addr, bool is_const)
58695869{
58705870 const_val->special = ConstValSpecialStatic;
......@@ -5873,47 +5873,47 @@ void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigTy
58735873 const_val->data.x_ptr.data.hard_coded_addr.addr = addr;
58745874}
58755875
5876ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
5876ZigValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
58775877 size_t addr, bool is_const)
58785878{
5879 ConstExprValue *const_val = create_const_vals(1);
5879 ZigValue *const_val = create_const_vals(1);
58805880 init_const_ptr_hard_coded_addr(g, const_val, pointee_type, addr, is_const);
58815881 return const_val;
58825882}
58835883
5884void init_const_arg_tuple(CodeGen *g, ConstExprValue *const_val, size_t arg_index_start, size_t arg_index_end) {
5884void init_const_arg_tuple(CodeGen *g, ZigValue *const_val, size_t arg_index_start, size_t arg_index_end) {
58855885 const_val->special = ConstValSpecialStatic;
58865886 const_val->type = g->builtin_types.entry_arg_tuple;
58875887 const_val->data.x_arg_tuple.start_index = arg_index_start;
58885888 const_val->data.x_arg_tuple.end_index = arg_index_end;
58895889}
58905890
5891ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_index_end) {
5892 ConstExprValue *const_val = create_const_vals(1);
5891ZigValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_index_end) {
5892 ZigValue *const_val = create_const_vals(1);
58935893 init_const_arg_tuple(g, const_val, arg_index_start, arg_index_end);
58945894 return const_val;
58955895}
58965896
58975897
5898ConstExprValue *create_const_vals(size_t count) {
5898ZigValue *create_const_vals(size_t count) {
58995899 ConstGlobalRefs *global_refs = allocate<ConstGlobalRefs>(count, "ConstGlobalRefs");
5900 ConstExprValue *vals = allocate<ConstExprValue>(count, "ConstExprValue");
5900 ZigValue *vals = allocate<ZigValue>(count, "ZigValue");
59015901 for (size_t i = 0; i < count; i += 1) {
59025902 vals[i].global_refs = &global_refs[i];
59035903 }
59045904 return vals;
59055905}
59065906
5907ConstExprValue **alloc_const_vals_ptrs(size_t count) {
5907ZigValue **alloc_const_vals_ptrs(size_t count) {
59085908 return realloc_const_vals_ptrs(nullptr, 0, count);
59095909}
59105910
5911ConstExprValue **realloc_const_vals_ptrs(ConstExprValue **ptr, size_t old_count, size_t new_count) {
5911ZigValue **realloc_const_vals_ptrs(ZigValue **ptr, size_t old_count, size_t new_count) {
59125912 assert(new_count >= old_count);
59135913
59145914 size_t new_item_count = new_count - old_count;
5915 ConstExprValue **result = reallocate(ptr, old_count, new_count, "ConstExprValue*");
5916 ConstExprValue *vals = create_const_vals(new_item_count);
5915 ZigValue **result = reallocate(ptr, old_count, new_count, "ZigValue*");
5916 ZigValue *vals = create_const_vals(new_item_count);
59175917 for (size_t i = old_count; i < new_count; i += 1) {
59185918 result[i] = &vals[i - old_count];
59195919 }
......@@ -6456,7 +6456,7 @@ bool ir_get_var_is_comptime(ZigVar *var) {
64566456 return var->is_comptime->value.data.x_bool;
64576457}
64586458
6459bool const_values_equal_ptr(ConstExprValue *a, ConstExprValue *b) {
6459bool const_values_equal_ptr(ZigValue *a, ZigValue *b) {
64606460 if (a->data.x_ptr.special != b->data.x_ptr.special)
64616461 return false;
64626462 switch (a->data.x_ptr.special) {
......@@ -6527,7 +6527,7 @@ bool const_values_equal_ptr(ConstExprValue *a, ConstExprValue *b) {
65276527 zig_unreachable();
65286528}
65296529
6530static bool const_values_equal_array(CodeGen *g, ConstExprValue *a, ConstExprValue *b, size_t len) {
6530static bool const_values_equal_array(CodeGen *g, ZigValue *a, ZigValue *b, size_t len) {
65316531 assert(a->data.x_array.special != ConstArraySpecialUndef);
65326532 assert(b->data.x_array.special != ConstArraySpecialUndef);
65336533 if (a->data.x_array.special == ConstArraySpecialBuf &&
......@@ -6538,8 +6538,8 @@ static bool const_values_equal_array(CodeGen *g, ConstExprValue *a, ConstExprVal
65386538 expand_undef_array(g, a);
65396539 expand_undef_array(g, b);
65406540
6541 ConstExprValue *a_elems = a->data.x_array.data.s_none.elements;
6542 ConstExprValue *b_elems = b->data.x_array.data.s_none.elements;
6541 ZigValue *a_elems = a->data.x_array.data.s_none.elements;
6542 ZigValue *b_elems = b->data.x_array.data.s_none.elements;
65436543
65446544 for (size_t i = 0; i < len; i += 1) {
65456545 if (!const_values_equal(g, &a_elems[i], &b_elems[i]))
......@@ -6549,7 +6549,7 @@ static bool const_values_equal_array(CodeGen *g, ConstExprValue *a, ConstExprVal
65496549 return true;
65506550}
65516551
6552bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) {
6552bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b) {
65536553 if (a->type->id != b->type->id) return false;
65546554 assert(a->special == ConstValSpecialStatic);
65556555 assert(b->special == ConstValSpecialStatic);
......@@ -6623,8 +6623,8 @@ bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) {
66236623 }
66246624 case ZigTypeIdStruct:
66256625 for (size_t i = 0; i < a->type->data.structure.src_field_count; i += 1) {
6626 ConstExprValue *field_a = a->data.x_struct.fields[i];
6627 ConstExprValue *field_b = b->data.x_struct.fields[i];
6626 ZigValue *field_a = a->data.x_struct.fields[i];
6627 ZigValue *field_b = b->data.x_struct.fields[i];
66286628 if (!const_values_equal(g, field_a, field_b))
66296629 return false;
66306630 }
......@@ -6695,7 +6695,7 @@ void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool
66956695 }
66966696}
66976697
6698void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max) {
6698void eval_min_max_value(CodeGen *g, ZigType *type_entry, ZigValue *const_val, bool is_max) {
66996699 if (type_entry->id == ZigTypeIdInt) {
67006700 const_val->special = ConstValSpecialStatic;
67016701 eval_min_max_value_int(g, type_entry, &const_val->data.x_bigint, is_max);
......@@ -6709,7 +6709,7 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v
67096709 }
67106710}
67116711
6712static void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {
6712static void render_const_val_ptr(CodeGen *g, Buf *buf, ZigValue *const_val, ZigType *type_entry) {
67136713 if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.child_type->id == ZigTypeIdOpaque) {
67146714 buf_append_buf(buf, &type_entry->name);
67156715 return;
......@@ -6752,7 +6752,7 @@ static void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val
67526752 zig_unreachable();
67536753}
67546754
6755static void render_const_val_err_set(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {
6755static void render_const_val_err_set(CodeGen *g, Buf *buf, ZigValue *const_val, ZigType *type_entry) {
67566756 if (const_val->data.x_err_set == nullptr) {
67576757 buf_append_str(buf, "null");
67586758 } else {
......@@ -6760,7 +6760,7 @@ static void render_const_val_err_set(CodeGen *g, Buf *buf, ConstExprValue *const
67606760 }
67616761}
67626762
6763static void render_const_val_array(CodeGen *g, Buf *buf, Buf *type_name, ConstExprValue *const_val, uint64_t start, uint64_t len) {
6763static void render_const_val_array(CodeGen *g, Buf *buf, Buf *type_name, ZigValue *const_val, uint64_t start, uint64_t len) {
67646764 ConstArrayValue *array = &const_val->data.x_array;
67656765 switch (array->special) {
67666766 case ConstArraySpecialUndef:
......@@ -6784,7 +6784,7 @@ static void render_const_val_array(CodeGen *g, Buf *buf, Buf *type_name, ConstEx
67846784 return;
67856785 }
67866786 case ConstArraySpecialNone: {
6787 ConstExprValue *base = &array->data.s_none.elements[start];
6787 ZigValue *base = &array->data.s_none.elements[start];
67886788 assert(start + len <= const_val->type->data.array.len);
67896789
67906790 buf_appendf(buf, "%s{", buf_ptr(type_name));
......@@ -6799,7 +6799,7 @@ static void render_const_val_array(CodeGen *g, Buf *buf, Buf *type_name, ConstEx
67996799 zig_unreachable();
68006800}
68016801
6802void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
6802void render_const_value(CodeGen *g, Buf *buf, ZigValue *const_val) {
68036803 switch (const_val->special) {
68046804 case ConstValSpecialRuntime:
68056805 buf_appendf(buf, "(runtime value)");
......@@ -6927,17 +6927,17 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
69276927 case ZigTypeIdStruct:
69286928 {
69296929 if (is_slice(type_entry)) {
6930 ConstExprValue *len_val = const_val->data.x_struct.fields[slice_len_index];
6930 ZigValue *len_val = const_val->data.x_struct.fields[slice_len_index];
69316931 size_t len = bigint_as_usize(&len_val->data.x_bigint);
69326932
6933 ConstExprValue *ptr_val = const_val->data.x_struct.fields[slice_ptr_index];
6933 ZigValue *ptr_val = const_val->data.x_struct.fields[slice_ptr_index];
69346934 if (ptr_val->special == ConstValSpecialUndef) {
69356935 assert(len == 0);
69366936 buf_appendf(buf, "((%s)(undefined))[0..0]", buf_ptr(&type_entry->name));
69376937 return;
69386938 }
69396939 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
6940 ConstExprValue *array = ptr_val->data.x_ptr.data.base_array.array_val;
6940 ZigValue *array = ptr_val->data.x_ptr.data.base_array.array_val;
69416941 size_t start = ptr_val->data.x_ptr.data.base_array.elem_index;
69426942
69436943 render_const_val_array(g, buf, &type_entry->name, array, start, len);
......@@ -7206,7 +7206,7 @@ bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b) {
72067206 zig_unreachable();
72077207}
72087208
7209static void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
7209static void init_const_undefined(CodeGen *g, ZigValue *const_val) {
72107210 Error err;
72117211 ZigType *wanted_type = const_val->type;
72127212 if (wanted_type->id == ZigTypeIdArray) {
......@@ -7221,7 +7221,7 @@ static void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
72217221 size_t field_count = wanted_type->data.structure.src_field_count;
72227222 const_val->data.x_struct.fields = alloc_const_vals_ptrs(field_count);
72237223 for (size_t i = 0; i < field_count; i += 1) {
7224 ConstExprValue *field_val = const_val->data.x_struct.fields[i];
7224 ZigValue *field_val = const_val->data.x_struct.fields[i];
72257225 field_val->type = resolve_struct_field_type(g, wanted_type->data.structure.fields[i]);
72267226 assert(field_val->type);
72277227 init_const_undefined(g, field_val);
......@@ -7234,14 +7234,14 @@ static void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
72347234 }
72357235}
72367236
7237void expand_undef_struct(CodeGen *g, ConstExprValue *const_val) {
7237void expand_undef_struct(CodeGen *g, ZigValue *const_val) {
72387238 if (const_val->special == ConstValSpecialUndef) {
72397239 init_const_undefined(g, const_val);
72407240 }
72417241}
72427242
72437243// Canonicalize the array value as ConstArraySpecialNone
7244void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {
7244void expand_undef_array(CodeGen *g, ZigValue *const_val) {
72457245 size_t elem_count;
72467246 ZigType *elem_type;
72477247 if (const_val->type->id == ZigTypeIdArray) {
......@@ -7264,7 +7264,7 @@ void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {
72647264 const_val->data.x_array.special = ConstArraySpecialNone;
72657265 const_val->data.x_array.data.s_none.elements = create_const_vals(elem_count);
72667266 for (size_t i = 0; i < elem_count; i += 1) {
7267 ConstExprValue *element_val = &const_val->data.x_array.data.s_none.elements[i];
7267 ZigValue *element_val = &const_val->data.x_array.data.s_none.elements[i];
72687268 element_val->type = elem_type;
72697269 init_const_undefined(g, element_val);
72707270 element_val->parent.id = ConstParentIdArray;
......@@ -7283,7 +7283,7 @@ void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {
72837283 assert(elem_count == buf_len(buf));
72847284 const_val->data.x_array.data.s_none.elements = create_const_vals(elem_count);
72857285 for (size_t i = 0; i < elem_count; i += 1) {
7286 ConstExprValue *this_char = &const_val->data.x_array.data.s_none.elements[i];
7286 ZigValue *this_char = &const_val->data.x_array.data.s_none.elements[i];
72877287 this_char->special = ConstValSpecialStatic;
72887288 this_char->type = g->builtin_types.entry_u8;
72897289 bigint_init_unsigned(&this_char->data.x_bigint, (uint8_t)buf_ptr(buf)[i]);
......@@ -7541,12 +7541,12 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {
75417541 return a == b;
75427542}
75437543
7544ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) {
7544ZigValue *get_builtin_value(CodeGen *codegen, const char *name) {
75457545 Tld *tld = get_container_scope(codegen->compile_var_import)->decl_table.get(buf_create_from_str(name));
75467546 resolve_top_level_decl(codegen, tld, nullptr, false);
75477547 assert(tld->id == TldIdVar);
75487548 TldVar *tld_var = (TldVar *)tld;
7549 ConstExprValue *var_value = tld_var->var->const_value;
7549 ZigValue *var_value = tld_var->var->const_value;
75507550 assert(var_value != nullptr);
75517551 return var_value;
75527552}
......@@ -7733,9 +7733,9 @@ uint32_t get_host_int_bytes(CodeGen *g, ZigType *struct_type, TypeStructField *f
77337733}
77347734
77357735Error ensure_const_val_repr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node,
7736 ConstExprValue *const_val, ZigType *wanted_type)
7736 ZigValue *const_val, ZigType *wanted_type)
77377737{
7738 ConstExprValue ptr_val = {};
7738 ZigValue ptr_val = {};
77397739 ptr_val.special = ConstValSpecialStatic;
77407740 ptr_val.type = get_pointer_to_type(codegen, wanted_type, true);
77417741 ptr_val.data.x_ptr.mut = ConstPtrMutComptimeConst;
src/analyze.hpp+53-53
......@@ -25,7 +25,7 @@ ZigType *get_pointer_to_type_extra2(CodeGen *g, ZigType *child_type,
2525 bool is_const, bool is_volatile, PtrLen ptr_len,
2626 uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count,
2727 bool allow_zero, uint32_t vector_index, InferredStructField *inferred_struct_field,
28 ConstExprValue *sentinel);
28 ZigValue *sentinel);
2929uint64_t type_size(CodeGen *g, ZigType *type_entry);
3030uint64_t type_size_bits(CodeGen *g, ZigType *type_entry);
3131ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
......@@ -34,7 +34,7 @@ ZigType **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
3434ZigType *get_c_int_type(CodeGen *g, CIntType c_int_type);
3535ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);
3636ZigType *get_optional_type(CodeGen *g, ZigType *child_type);
37ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, ConstExprValue *sentinel);
37ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size, ZigValue *sentinel);
3838ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type);
3939ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
4040 AstNode *decl_node, const char *full_name, Buf *bare_name, ContainerLayout layout);
......@@ -95,7 +95,7 @@ ZigType *get_scope_import(Scope *scope);
9595ScopeTypeOf *get_scope_typeof(Scope *scope);
9696void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope);
9797ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,
98 bool is_const, ConstExprValue *init_value, Tld *src_tld, ZigType *var_type);
98 bool is_const, ZigValue *init_value, Tld *src_tld, ZigType *var_type);
9999ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
100100void append_namespace_qualification(CodeGen *g, Buf *buf, ZigType *container_type);
101101ZigFn *create_fn(CodeGen *g, AstNode *proto_node);
......@@ -105,11 +105,11 @@ AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index);
105105Error ATTRIBUTE_MUST_USE type_resolve(CodeGen *g, ZigType *type_entry, ResolveStatus status);
106106void complete_enum(CodeGen *g, ZigType *enum_type);
107107bool ir_get_var_is_comptime(ZigVar *var);
108bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b);
109void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max);
108bool const_values_equal(CodeGen *g, ZigValue *a, ZigValue *b);
109void eval_min_max_value(CodeGen *g, ZigType *type_entry, ZigValue *const_val, bool is_max);
110110void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max);
111111
112void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val);
112void render_const_value(CodeGen *g, Buf *buf, ZigValue *const_val);
113113
114114ScopeBlock *create_block_scope(CodeGen *g, AstNode *node, Scope *parent);
115115ScopeDefer *create_defer_scope(CodeGen *g, AstNode *node, Scope *parent);
......@@ -124,70 +124,70 @@ Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstruct
124124Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent);
125125ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent);
126126
127void init_const_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *str);
128ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);
127void init_const_str_lit(CodeGen *g, ZigValue *const_val, Buf *str);
128ZigValue *create_const_str_lit(CodeGen *g, Buf *str);
129129
130void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint);
131ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint);
130void init_const_bigint(ZigValue *const_val, ZigType *type, const BigInt *bigint);
131ZigValue *create_const_bigint(ZigType *type, const BigInt *bigint);
132132
133void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative);
134ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative);
133void init_const_unsigned_negative(ZigValue *const_val, ZigType *type, uint64_t x, bool negative);
134ZigValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative);
135135
136void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x);
137ConstExprValue *create_const_signed(ZigType *type, int64_t x);
136void init_const_signed(ZigValue *const_val, ZigType *type, int64_t x);
137ZigValue *create_const_signed(ZigType *type, int64_t x);
138138
139void init_const_usize(CodeGen *g, ConstExprValue *const_val, uint64_t x);
140ConstExprValue *create_const_usize(CodeGen *g, uint64_t x);
139void init_const_usize(CodeGen *g, ZigValue *const_val, uint64_t x);
140ZigValue *create_const_usize(CodeGen *g, uint64_t x);
141141
142void init_const_float(ConstExprValue *const_val, ZigType *type, double value);
143ConstExprValue *create_const_float(ZigType *type, double value);
142void init_const_float(ZigValue *const_val, ZigType *type, double value);
143ZigValue *create_const_float(ZigType *type, double value);
144144
145void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag);
146ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag);
145void init_const_enum(ZigValue *const_val, ZigType *type, const BigInt *tag);
146ZigValue *create_const_enum(ZigType *type, const BigInt *tag);
147147
148void init_const_bool(CodeGen *g, ConstExprValue *const_val, bool value);
149ConstExprValue *create_const_bool(CodeGen *g, bool value);
148void init_const_bool(CodeGen *g, ZigValue *const_val, bool value);
149ZigValue *create_const_bool(CodeGen *g, bool value);
150150
151void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value);
152ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value);
151void init_const_type(CodeGen *g, ZigValue *const_val, ZigType *type_value);
152ZigValue *create_const_type(CodeGen *g, ZigType *type_value);
153153
154void init_const_runtime(ConstExprValue *const_val, ZigType *type);
155ConstExprValue *create_const_runtime(ZigType *type);
154void init_const_runtime(ZigValue *const_val, ZigType *type);
155ZigValue *create_const_runtime(ZigType *type);
156156
157void init_const_ptr_ref(CodeGen *g, ConstExprValue *const_val, ConstExprValue *pointee_val, bool is_const);
158ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bool is_const);
157void init_const_ptr_ref(CodeGen *g, ZigValue *const_val, ZigValue *pointee_val, bool is_const);
158ZigValue *create_const_ptr_ref(CodeGen *g, ZigValue *pointee_val, bool is_const);
159159
160void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
160void init_const_ptr_hard_coded_addr(CodeGen *g, ZigValue *const_val, ZigType *pointee_type,
161161 size_t addr, bool is_const);
162ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
162ZigValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
163163 size_t addr, bool is_const);
164164
165void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
165void init_const_ptr_array(CodeGen *g, ZigValue *const_val, ZigValue *array_val,
166166 size_t elem_index, bool is_const, PtrLen ptr_len);
167ConstExprValue *create_const_ptr_array(CodeGen *g, ConstExprValue *array_val, size_t elem_index,
167ZigValue *create_const_ptr_array(CodeGen *g, ZigValue *array_val, size_t elem_index,
168168 bool is_const, PtrLen ptr_len);
169169
170void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
170void init_const_slice(CodeGen *g, ZigValue *const_val, ZigValue *array_val,
171171 size_t start, size_t len, bool is_const);
172ConstExprValue *create_const_slice(CodeGen *g, ConstExprValue *array_val, size_t start, size_t len, bool is_const);
172ZigValue *create_const_slice(CodeGen *g, ZigValue *array_val, size_t start, size_t len, bool is_const);
173173
174void init_const_arg_tuple(CodeGen *g, ConstExprValue *const_val, size_t arg_index_start, size_t arg_index_end);
175ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_index_end);
174void init_const_arg_tuple(CodeGen *g, ZigValue *const_val, size_t arg_index_start, size_t arg_index_end);
175ZigValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_index_end);
176176
177void init_const_null(ConstExprValue *const_val, ZigType *type);
178ConstExprValue *create_const_null(ZigType *type);
177void init_const_null(ZigValue *const_val, ZigType *type);
178ZigValue *create_const_null(ZigType *type);
179179
180ConstExprValue *create_const_vals(size_t count);
181ConstExprValue **alloc_const_vals_ptrs(size_t count);
182ConstExprValue **realloc_const_vals_ptrs(ConstExprValue **ptr, size_t old_count, size_t new_count);
180ZigValue *create_const_vals(size_t count);
181ZigValue **alloc_const_vals_ptrs(size_t count);
182ZigValue **realloc_const_vals_ptrs(ZigValue **ptr, size_t old_count, size_t new_count);
183183
184184TypeStructField **alloc_type_struct_fields(size_t count);
185185TypeStructField **realloc_type_struct_fields(TypeStructField **ptr, size_t old_count, size_t new_count);
186186
187187ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
188void expand_undef_array(CodeGen *g, ConstExprValue *const_val);
189void expand_undef_struct(CodeGen *g, ConstExprValue *const_val);
190void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value);
188void expand_undef_array(CodeGen *g, ZigValue *const_val);
189void expand_undef_struct(CodeGen *g, ZigValue *const_val);
190void update_compile_var(CodeGen *g, Buf *name, ZigValue *value);
191191
192192const char *type_id_name(ZigTypeId id);
193193ZigTypeId type_id_at_index(size_t index);
......@@ -201,12 +201,12 @@ uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry);
201201ZigType *get_align_amt_type(CodeGen *g);
202202ZigPackage *new_anonymous_package(void);
203203
204Buf *const_value_to_buffer(ConstExprValue *const_val);
204Buf *const_value_to_buffer(ZigValue *const_val);
205205void add_fn_export(CodeGen *g, ZigFn *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage, bool ccc);
206206void add_var_export(CodeGen *g, ZigVar *fn_table_entry, const char *symbol_name, GlobalLinkageId linkage);
207207
208208
209ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
209ZigValue *get_builtin_value(CodeGen *codegen, const char *name);
210210ZigType *get_stack_trace_type(CodeGen *g);
211211bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node);
212212
......@@ -242,7 +242,7 @@ ReqCompTime type_requires_comptime(CodeGen *g, ZigType *type_entry);
242242OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry);
243243
244244Error ensure_const_val_repr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node,
245 ConstExprValue *const_val, ZigType *wanted_type);
245 ZigValue *const_val, ZigType *wanted_type);
246246
247247void typecheck_panic_fn(CodeGen *g, TldFn *tld_fn, ZigFn *panic_fn);
248248Buf *type_bare_name(ZigType *t);
......@@ -256,17 +256,17 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
256256
257257void src_assert(bool ok, AstNode *source_node);
258258bool is_container(ZigType *type_entry);
259ConstExprValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry,
259ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry,
260260 Buf *type_name, UndefAllowed undef);
261261
262262void resolve_llvm_types_fn(CodeGen *g, ZigFn *fn);
263263bool fn_is_async(ZigFn *fn);
264264
265Error type_val_resolve_abi_align(CodeGen *g, ConstExprValue *type_val, uint32_t *abi_align);
266Error type_val_resolve_abi_size(CodeGen *g, AstNode *source_node, ConstExprValue *type_val,
265Error type_val_resolve_abi_align(CodeGen *g, ZigValue *type_val, uint32_t *abi_align);
266Error type_val_resolve_abi_size(CodeGen *g, AstNode *source_node, ZigValue *type_val,
267267 size_t *abi_size, size_t *size_in_bits);
268Error type_val_resolve_zero_bits(CodeGen *g, ConstExprValue *type_val, ZigType *parent_type,
269 ConstExprValue *parent_type_val, bool *is_zero_bits);
268Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent_type,
269 ZigValue *parent_type_val, bool *is_zero_bits);
270270ZigType *resolve_union_field_type(CodeGen *g, TypeUnionField *union_field);
271271ZigType *resolve_struct_field_type(CodeGen *g, TypeStructField *struct_field);
272272
......@@ -276,5 +276,5 @@ IrInstruction *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node,
276276 ZigType *var_type, const char *name_hint);
277277Error analyze_import(CodeGen *codegen, ZigType *source_import, Buf *import_target_str,
278278 ZigType **out_import, Buf **out_import_target_path, Buf *out_full_path);
279ConstExprValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry);
279ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry);
280280#endif
src/codegen.cpp+53-53
......@@ -185,11 +185,11 @@ void codegen_set_linker_script(CodeGen *g, const char *linker_script) {
185185}
186186
187187
188static void render_const_val(CodeGen *g, ConstExprValue *const_val, const char *name);
189static void render_const_val_global(CodeGen *g, ConstExprValue *const_val, const char *name);
190static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name);
188static void render_const_val(CodeGen *g, ZigValue *const_val, const char *name);
189static void render_const_val_global(CodeGen *g, ZigValue *const_val, const char *name);
190static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *name);
191191static void generate_error_name_table(CodeGen *g);
192static bool value_is_all_undef(CodeGen *g, ConstExprValue *const_val);
192static bool value_is_all_undef(CodeGen *g, ZigValue *const_val);
193193static void gen_undef_init(CodeGen *g, uint32_t ptr_align_bytes, ZigType *value_type, LLVMValueRef ptr);
194194static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment);
195195static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstruction *source_instr,
......@@ -945,11 +945,11 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {
945945}
946946
947947static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) {
948 ConstExprValue *val = &g->panic_msg_vals[msg_id];
948 ZigValue *val = &g->panic_msg_vals[msg_id];
949949 if (!val->global_refs->llvm_global) {
950950
951951 Buf *buf_msg = panic_msg_buf(msg_id);
952 ConstExprValue *array_val = create_const_str_lit(g, buf_msg)->data.x_ptr.data.ref.pointee;
952 ZigValue *array_val = create_const_str_lit(g, buf_msg)->data.x_ptr.data.ref.pointee;
953953 init_const_slice(g, val, array_val, 0, buf_len(buf_msg), true);
954954
955955 render_const_val(g, val, "");
......@@ -3474,7 +3474,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable,
34743474 return LLVMBuildTrunc(g->builder, shifted_value, get_llvm_type(g, child_type), "");
34753475}
34763476
3477static bool value_is_all_undef_array(CodeGen *g, ConstExprValue *const_val, size_t len) {
3477static bool value_is_all_undef_array(CodeGen *g, ZigValue *const_val, size_t len) {
34783478 switch (const_val->data.x_array.special) {
34793479 case ConstArraySpecialUndef:
34803480 return true;
......@@ -3490,7 +3490,7 @@ static bool value_is_all_undef_array(CodeGen *g, ConstExprValue *const_val, size
34903490 zig_unreachable();
34913491}
34923492
3493static bool value_is_all_undef(CodeGen *g, ConstExprValue *const_val) {
3493static bool value_is_all_undef(CodeGen *g, ZigValue *const_val) {
34943494 Error err;
34953495 if (const_val->special == ConstValSpecialLazy &&
34963496 (err = ir_resolve_lazy(g, nullptr, const_val)))
......@@ -6362,14 +6362,14 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) {
63626362 }
63636363}
63646364
6365static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *struct_const_val, size_t field_index);
6366static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *array_const_val, size_t index);
6367static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *union_const_val);
6368static LLVMValueRef gen_const_ptr_err_union_code_recursive(CodeGen *g, ConstExprValue *err_union_const_val);
6369static LLVMValueRef gen_const_ptr_err_union_payload_recursive(CodeGen *g, ConstExprValue *err_union_const_val);
6370static LLVMValueRef gen_const_ptr_optional_payload_recursive(CodeGen *g, ConstExprValue *optional_const_val);
6365static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ZigValue *struct_const_val, size_t field_index);
6366static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ZigValue *array_const_val, size_t index);
6367static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ZigValue *union_const_val);
6368static LLVMValueRef gen_const_ptr_err_union_code_recursive(CodeGen *g, ZigValue *err_union_const_val);
6369static LLVMValueRef gen_const_ptr_err_union_payload_recursive(CodeGen *g, ZigValue *err_union_const_val);
6370static LLVMValueRef gen_const_ptr_optional_payload_recursive(CodeGen *g, ZigValue *optional_const_val);
63716371
6372static LLVMValueRef gen_parent_ptr(CodeGen *g, ConstExprValue *val, ConstParent *parent) {
6372static LLVMValueRef gen_parent_ptr(CodeGen *g, ZigValue *val, ConstParent *parent) {
63736373 switch (parent->id) {
63746374 case ConstParentIdNone:
63756375 render_const_val(g, val, "");
......@@ -6397,7 +6397,7 @@ static LLVMValueRef gen_parent_ptr(CodeGen *g, ConstExprValue *val, ConstParent
63976397 zig_unreachable();
63986398}
63996399
6400static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *array_const_val, size_t index) {
6400static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ZigValue *array_const_val, size_t index) {
64016401 expand_undef_array(g, array_const_val);
64026402 ConstParent *parent = &array_const_val->parent;
64036403 LLVMValueRef base_ptr = gen_parent_ptr(g, array_const_val, parent);
......@@ -6423,7 +6423,7 @@ static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *ar
64236423 }
64246424}
64256425
6426static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *struct_const_val, size_t field_index) {
6426static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ZigValue *struct_const_val, size_t field_index) {
64276427 ConstParent *parent = &struct_const_val->parent;
64286428 LLVMValueRef base_ptr = gen_parent_ptr(g, struct_const_val, parent);
64296429
......@@ -6435,7 +6435,7 @@ static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *s
64356435 return LLVMConstInBoundsGEP(base_ptr, indices, 2);
64366436}
64376437
6438static LLVMValueRef gen_const_ptr_err_union_code_recursive(CodeGen *g, ConstExprValue *err_union_const_val) {
6438static LLVMValueRef gen_const_ptr_err_union_code_recursive(CodeGen *g, ZigValue *err_union_const_val) {
64396439 ConstParent *parent = &err_union_const_val->parent;
64406440 LLVMValueRef base_ptr = gen_parent_ptr(g, err_union_const_val, parent);
64416441
......@@ -6447,7 +6447,7 @@ static LLVMValueRef gen_const_ptr_err_union_code_recursive(CodeGen *g, ConstExpr
64476447 return LLVMConstInBoundsGEP(base_ptr, indices, 2);
64486448}
64496449
6450static LLVMValueRef gen_const_ptr_err_union_payload_recursive(CodeGen *g, ConstExprValue *err_union_const_val) {
6450static LLVMValueRef gen_const_ptr_err_union_payload_recursive(CodeGen *g, ZigValue *err_union_const_val) {
64516451 ConstParent *parent = &err_union_const_val->parent;
64526452 LLVMValueRef base_ptr = gen_parent_ptr(g, err_union_const_val, parent);
64536453
......@@ -6459,7 +6459,7 @@ static LLVMValueRef gen_const_ptr_err_union_payload_recursive(CodeGen *g, ConstE
64596459 return LLVMConstInBoundsGEP(base_ptr, indices, 2);
64606460}
64616461
6462static LLVMValueRef gen_const_ptr_optional_payload_recursive(CodeGen *g, ConstExprValue *optional_const_val) {
6462static LLVMValueRef gen_const_ptr_optional_payload_recursive(CodeGen *g, ZigValue *optional_const_val) {
64636463 ConstParent *parent = &optional_const_val->parent;
64646464 LLVMValueRef base_ptr = gen_parent_ptr(g, optional_const_val, parent);
64656465
......@@ -6471,7 +6471,7 @@ static LLVMValueRef gen_const_ptr_optional_payload_recursive(CodeGen *g, ConstEx
64716471 return LLVMConstInBoundsGEP(base_ptr, indices, 2);
64726472}
64736473
6474static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *union_const_val) {
6474static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ZigValue *union_const_val) {
64756475 ConstParent *parent = &union_const_val->parent;
64766476 LLVMValueRef base_ptr = gen_parent_ptr(g, union_const_val, parent);
64776477
......@@ -6488,7 +6488,7 @@ static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *un
64886488 return LLVMConstInBoundsGEP(base_ptr, indices, (union_payload_index != SIZE_MAX) ? 2 : 1);
64896489}
64906490
6491static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, ConstExprValue *const_val) {
6491static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, ZigValue *const_val) {
64926492 switch (const_val->special) {
64936493 case ConstValSpecialLazy:
64946494 case ConstValSpecialRuntime:
......@@ -6555,7 +6555,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
65556555 uint32_t packed_bits_size = type_size_bits(g, type_entry->data.array.child_type);
65566556 size_t used_bits = 0;
65576557 for (size_t i = 0; i < type_entry->data.array.len; i += 1) {
6558 ConstExprValue *elem_val = &const_val->data.x_array.data.s_none.elements[i];
6558 ZigValue *elem_val = &const_val->data.x_array.data.s_none.elements[i];
65596559 LLVMValueRef child_val = pack_const_int(g, big_int_type_ref, elem_val);
65606560
65616561 if (is_big_endian) {
......@@ -6616,7 +6616,7 @@ static bool is_llvm_value_unnamed_type(CodeGen *g, ZigType *type_entry, LLVMValu
66166616 return LLVMTypeOf(val) != get_llvm_type(g, type_entry);
66176617}
66186618
6619static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, const char *name) {
6619static LLVMValueRef gen_const_val_ptr(CodeGen *g, ZigValue *const_val, const char *name) {
66206620 switch (const_val->data.x_ptr.special) {
66216621 case ConstPtrSpecialInvalid:
66226622 case ConstPtrSpecialDiscard:
......@@ -6624,7 +6624,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
66246624 case ConstPtrSpecialRef:
66256625 {
66266626 assert(const_val->global_refs != nullptr);
6627 ConstExprValue *pointee = const_val->data.x_ptr.data.ref.pointee;
6627 ZigValue *pointee = const_val->data.x_ptr.data.ref.pointee;
66286628 render_const_val(g, pointee, "");
66296629 render_const_val_global(g, pointee, "");
66306630 const_val->global_refs->llvm_value = LLVMConstBitCast(pointee->global_refs->llvm_global,
......@@ -6634,11 +6634,11 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
66346634 case ConstPtrSpecialBaseArray:
66356635 {
66366636 assert(const_val->global_refs != nullptr);
6637 ConstExprValue *array_const_val = const_val->data.x_ptr.data.base_array.array_val;
6637 ZigValue *array_const_val = const_val->data.x_ptr.data.base_array.array_val;
66386638 assert(array_const_val->type->id == ZigTypeIdArray);
66396639 if (!type_has_bits(array_const_val->type)) {
66406640 if (array_const_val->type->data.array.sentinel != nullptr) {
6641 ConstExprValue *pointee = array_const_val->type->data.array.sentinel;
6641 ZigValue *pointee = array_const_val->type->data.array.sentinel;
66426642 render_const_val(g, pointee, "");
66436643 render_const_val_global(g, pointee, "");
66446644 const_val->global_refs->llvm_value = LLVMConstBitCast(pointee->global_refs->llvm_global,
......@@ -6661,7 +6661,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
66616661 case ConstPtrSpecialBaseStruct:
66626662 {
66636663 assert(const_val->global_refs != nullptr);
6664 ConstExprValue *struct_const_val = const_val->data.x_ptr.data.base_struct.struct_val;
6664 ZigValue *struct_const_val = const_val->data.x_ptr.data.base_struct.struct_val;
66656665 assert(struct_const_val->type->id == ZigTypeIdStruct);
66666666 if (!type_has_bits(struct_const_val->type)) {
66676667 // make this a null pointer
......@@ -6681,7 +6681,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
66816681 case ConstPtrSpecialBaseErrorUnionCode:
66826682 {
66836683 assert(const_val->global_refs != nullptr);
6684 ConstExprValue *err_union_const_val = const_val->data.x_ptr.data.base_err_union_code.err_union_val;
6684 ZigValue *err_union_const_val = const_val->data.x_ptr.data.base_err_union_code.err_union_val;
66856685 assert(err_union_const_val->type->id == ZigTypeIdErrorUnion);
66866686 if (!type_has_bits(err_union_const_val->type)) {
66876687 // make this a null pointer
......@@ -6698,7 +6698,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
66986698 case ConstPtrSpecialBaseErrorUnionPayload:
66996699 {
67006700 assert(const_val->global_refs != nullptr);
6701 ConstExprValue *err_union_const_val = const_val->data.x_ptr.data.base_err_union_payload.err_union_val;
6701 ZigValue *err_union_const_val = const_val->data.x_ptr.data.base_err_union_payload.err_union_val;
67026702 assert(err_union_const_val->type->id == ZigTypeIdErrorUnion);
67036703 if (!type_has_bits(err_union_const_val->type)) {
67046704 // make this a null pointer
......@@ -6715,7 +6715,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
67156715 case ConstPtrSpecialBaseOptionalPayload:
67166716 {
67176717 assert(const_val->global_refs != nullptr);
6718 ConstExprValue *optional_const_val = const_val->data.x_ptr.data.base_optional_payload.optional_val;
6718 ZigValue *optional_const_val = const_val->data.x_ptr.data.base_optional_payload.optional_val;
67196719 assert(optional_const_val->type->id == ZigTypeIdOptional);
67206720 if (!type_has_bits(optional_const_val->type)) {
67216721 // make this a null pointer
......@@ -6747,12 +6747,12 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
67476747 zig_unreachable();
67486748}
67496749
6750static LLVMValueRef gen_const_val_err_set(CodeGen *g, ConstExprValue *const_val, const char *name) {
6750static LLVMValueRef gen_const_val_err_set(CodeGen *g, ZigValue *const_val, const char *name) {
67516751 uint64_t value = (const_val->data.x_err_set == nullptr) ? 0 : const_val->data.x_err_set->value;
67526752 return LLVMConstInt(get_llvm_type(g, g->builtin_types.entry_global_error_set), value, false);
67536753}
67546754
6755static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) {
6755static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *name) {
67566756 Error err;
67576757
67586758 ZigType *type_entry = const_val->type;
......@@ -6864,7 +6864,7 @@ check: switch (const_val->special) {
68646864 }
68656865
68666866 if (src_field_index + 1 == src_field_index_end) {
6867 ConstExprValue *field_val = const_val->data.x_struct.fields[src_field_index];
6867 ZigValue *field_val = const_val->data.x_struct.fields[src_field_index];
68686868 LLVMValueRef val = gen_const_val(g, field_val, "");
68696869 fields[type_struct_field->gen_index] = val;
68706870 make_unnamed_struct = make_unnamed_struct || is_llvm_value_unnamed_type(g, field_val->type, val);
......@@ -6921,7 +6921,7 @@ check: switch (const_val->special) {
69216921 if (type_struct_field->gen_index == SIZE_MAX) {
69226922 continue;
69236923 }
6924 ConstExprValue *field_val = const_val->data.x_struct.fields[i];
6924 ZigValue *field_val = const_val->data.x_struct.fields[i];
69256925 assert(field_val->type != nullptr);
69266926 if ((err = ensure_const_val_repr(nullptr, g, nullptr, field_val,
69276927 type_struct_field->type_entry)))
......@@ -6970,7 +6970,7 @@ check: switch (const_val->special) {
69706970 LLVMTypeRef element_type_ref = get_llvm_type(g, type_entry->data.array.child_type);
69716971 bool make_unnamed_struct = false;
69726972 for (uint64_t i = 0; i < len; i += 1) {
6973 ConstExprValue *elem_value = &const_val->data.x_array.data.s_none.elements[i];
6973 ZigValue *elem_value = &const_val->data.x_array.data.s_none.elements[i];
69746974 LLVMValueRef val = gen_const_val(g, elem_value, "");
69756975 values[i] = val;
69766976 make_unnamed_struct = make_unnamed_struct || is_llvm_value_unnamed_type(g, elem_value->type, val);
......@@ -7000,7 +7000,7 @@ check: switch (const_val->special) {
70007000 case ConstArraySpecialNone: {
70017001 LLVMValueRef *values = allocate<LLVMValueRef>(len);
70027002 for (uint64_t i = 0; i < len; i += 1) {
7003 ConstExprValue *elem_value = &const_val->data.x_array.data.s_none.elements[i];
7003 ZigValue *elem_value = &const_val->data.x_array.data.s_none.elements[i];
70047004 values[i] = gen_const_val(g, elem_value, "");
70057005 }
70067006 return LLVMConstVector(values, len);
......@@ -7036,7 +7036,7 @@ check: switch (const_val->special) {
70367036
70377037 LLVMValueRef union_value_ref;
70387038 bool make_unnamed_struct;
7039 ConstExprValue *payload_value = const_val->data.x_union.payload;
7039 ZigValue *payload_value = const_val->data.x_union.payload;
70407040 if (payload_value == nullptr || !type_has_bits(payload_value->type)) {
70417041 if (type_entry->data.unionation.gen_tag_index == SIZE_MAX)
70427042 return LLVMGetUndef(get_llvm_type(g, type_entry));
......@@ -7133,7 +7133,7 @@ check: switch (const_val->special) {
71337133 make_unnamed_struct = false;
71347134 } else {
71357135 err_tag_value = LLVMConstNull(get_llvm_type(g, g->err_tag_type));
7136 ConstExprValue *payload_val = const_val->data.x_err_union.payload;
7136 ZigValue *payload_val = const_val->data.x_err_union.payload;
71377137 err_payload_value = gen_const_val(g, payload_val, "");
71387138 make_unnamed_struct = is_llvm_value_unnamed_type(g, payload_val->type, err_payload_value);
71397139 }
......@@ -7174,7 +7174,7 @@ check: switch (const_val->special) {
71747174 zig_unreachable();
71757175}
71767176
7177static void render_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) {
7177static void render_const_val(CodeGen *g, ZigValue *const_val, const char *name) {
71787178 if (!const_val->global_refs)
71797179 const_val->global_refs = allocate<ConstGlobalRefs>(1);
71807180 if (!const_val->global_refs->llvm_value)
......@@ -7184,7 +7184,7 @@ static void render_const_val(CodeGen *g, ConstExprValue *const_val, const char *
71847184 LLVMSetInitializer(const_val->global_refs->llvm_global, const_val->global_refs->llvm_value);
71857185}
71867186
7187static void render_const_val_global(CodeGen *g, ConstExprValue *const_val, const char *name) {
7187static void render_const_val_global(CodeGen *g, ZigValue *const_val, const char *name) {
71887188 if (!const_val->global_refs)
71897189 const_val->global_refs = allocate<ConstGlobalRefs>(1);
71907190
......@@ -7324,7 +7324,7 @@ static void do_code_gen(CodeGen *g) {
73247324
73257325 if (var->var_type->id == ZigTypeIdComptimeFloat) {
73267326 // Generate debug info for it but that's it.
7327 ConstExprValue *const_val = var->const_value;
7327 ZigValue *const_val = var->const_value;
73287328 assert(const_val->special != ConstValSpecialRuntime);
73297329 if ((err = ir_resolve_lazy(g, var->decl_node, const_val)))
73307330 zig_unreachable();
......@@ -7332,7 +7332,7 @@ static void do_code_gen(CodeGen *g) {
73327332 zig_panic("TODO debug info for var with ptr casted value");
73337333 }
73347334 ZigType *var_type = g->builtin_types.entry_f128;
7335 ConstExprValue coerced_value = {};
7335 ZigValue coerced_value = {};
73367336 coerced_value.special = ConstValSpecialStatic;
73377337 coerced_value.type = var_type;
73387338 coerced_value.data.x_f128 = bigfloat_to_f128(&const_val->data.x_bigfloat);
......@@ -7343,7 +7343,7 @@ static void do_code_gen(CodeGen *g) {
73437343
73447344 if (var->var_type->id == ZigTypeIdComptimeInt) {
73457345 // Generate debug info for it but that's it.
7346 ConstExprValue *const_val = var->const_value;
7346 ZigValue *const_val = var->const_value;
73477347 assert(const_val->special != ConstValSpecialRuntime);
73487348 if ((err = ir_resolve_lazy(g, var->decl_node, const_val)))
73497349 zig_unreachable();
......@@ -9080,13 +9080,13 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
90809080
90819081 ZigType *fn_type = get_test_fn_type(g);
90829082
9083 ConstExprValue *test_fn_type_val = get_builtin_value(g, "TestFn");
9083 ZigValue *test_fn_type_val = get_builtin_value(g, "TestFn");
90849084 assert(test_fn_type_val->type->id == ZigTypeIdMetaType);
90859085 ZigType *struct_type = test_fn_type_val->data.x_type;
90869086 if ((err = type_resolve(g, struct_type, ResolveStatusSizeKnown)))
90879087 zig_unreachable();
90889088
9089 ConstExprValue *test_fn_array = create_const_vals(1);
9089 ZigValue *test_fn_array = create_const_vals(1);
90909090 test_fn_array->type = get_array_type(g, struct_type, g->test_fns.length, nullptr);
90919091 test_fn_array->special = ConstValSpecialStatic;
90929092 test_fn_array->data.x_array.data.s_none.elements = create_const_vals(g->test_fns.length);
......@@ -9103,7 +9103,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
91039103 continue;
91049104 }
91059105
9106 ConstExprValue *this_val = &test_fn_array->data.x_array.data.s_none.elements[i];
9106 ZigValue *this_val = &test_fn_array->data.x_array.data.s_none.elements[i];
91079107 this_val->special = ConstValSpecialStatic;
91089108 this_val->type = struct_type;
91099109 this_val->parent.id = ConstParentIdArray;
......@@ -9111,11 +9111,11 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
91119111 this_val->parent.data.p_array.elem_index = i;
91129112 this_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
91139113
9114 ConstExprValue *name_field = this_val->data.x_struct.fields[0];
9115 ConstExprValue *name_array_val = create_const_str_lit(g, &test_fn_entry->symbol_name)->data.x_ptr.data.ref.pointee;
9114 ZigValue *name_field = this_val->data.x_struct.fields[0];
9115 ZigValue *name_array_val = create_const_str_lit(g, &test_fn_entry->symbol_name)->data.x_ptr.data.ref.pointee;
91169116 init_const_slice(g, name_field, name_array_val, 0, buf_len(&test_fn_entry->symbol_name), true);
91179117
9118 ConstExprValue *fn_field = this_val->data.x_struct.fields[1];
9118 ZigValue *fn_field = this_val->data.x_struct.fields[1];
91199119 fn_field->type = fn_type;
91209120 fn_field->special = ConstValSpecialStatic;
91219121 fn_field->data.x_ptr.special = ConstPtrSpecialFunction;
......@@ -9124,7 +9124,7 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
91249124 }
91259125 report_errors_and_maybe_exit(g);
91269126
9127 ConstExprValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true);
9127 ZigValue *test_fn_slice = create_const_slice(g, test_fn_array, 0, g->test_fns.length, true);
91289128
91299129 update_compile_var(g, buf_create_from_str("test_functions"), test_fn_slice);
91309130 assert(g->test_runner_package != nullptr);
......@@ -9221,7 +9221,7 @@ static void gen_root_source(CodeGen *g) {
92219221 report_errors_and_maybe_exit(g);
92229222 assert(builtin_tld->id == TldIdVar);
92239223 TldVar *builtin_tld_var = (TldVar*)builtin_tld;
9224 ConstExprValue *builtin_val = builtin_tld_var->var->const_value;
9224 ZigValue *builtin_val = builtin_tld_var->var->const_value;
92259225 assert(builtin_val->type->id == ZigTypeIdMetaType);
92269226 ZigType *builtin_type = builtin_val->data.x_type;
92279227
......@@ -9232,7 +9232,7 @@ static void gen_root_source(CodeGen *g) {
92329232 report_errors_and_maybe_exit(g);
92339233 assert(panic_tld->id == TldIdVar);
92349234 TldVar *panic_tld_var = (TldVar*)panic_tld;
9235 ConstExprValue *panic_fn_val = panic_tld_var->var->const_value;
9235 ZigValue *panic_fn_val = panic_tld_var->var->const_value;
92369236 assert(panic_fn_val->type->id == ZigTypeIdFn);
92379237 assert(panic_fn_val->data.x_ptr.special == ConstPtrSpecialFunction);
92389238 g->panic_fn = panic_fn_val->data.x_ptr.data.fn.fn_entry;
src/dump_analysis.cpp+4-4
......@@ -361,9 +361,9 @@ struct AnalDumpCtx {
361361};
362362
363363static uint32_t anal_dump_get_type_id(AnalDumpCtx *ctx, ZigType *ty);
364static void anal_dump_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ConstExprValue *value);
364static void anal_dump_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ZigValue *value);
365365
366static void anal_dump_poke_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ConstExprValue *value) {
366static void anal_dump_poke_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ZigValue *value) {
367367 Error err;
368368 if (value->type != ty) {
369369 return;
......@@ -660,7 +660,7 @@ static void anal_dump_file(AnalDumpCtx *ctx, Buf *file) {
660660 jw_string(jw, buf_ptr(file));
661661}
662662
663static void anal_dump_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ConstExprValue *value) {
663static void anal_dump_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, ZigValue *value) {
664664 Error err;
665665
666666 if (value->type != ty) {
......@@ -1249,7 +1249,7 @@ void zig_print_analysis_dump(CodeGen *g, FILE *f, const char *one_indent, const
12491249 }
12501250 scope = scope->parent;
12511251 }
1252 ConstExprValue *result = entry->value;
1252 ZigValue *result = entry->value;
12531253
12541254 assert(fn != nullptr);
12551255
src/ir.cpp+409-409
......@@ -19,7 +19,7 @@
1919#include <errno.h>
2020
2121struct IrExecContext {
22 ZigList<ConstExprValue *> mem_slot_list;
22 ZigList<ZigValue *> mem_slot_list;
2323};
2424
2525struct IrBuilder {
......@@ -204,14 +204,14 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *
204204static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc);
205205static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align);
206206static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align);
207static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val);
208static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);
207static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val);
208static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val);
209209static 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);
211211static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr,
212212 ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on);
213static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed);
214static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs);
213static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed);
214static void copy_const_val(ZigValue *dest, ZigValue *src, bool same_global_refs);
215215static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align);
216216static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
217217 ZigType *ptr_type);
......@@ -244,10 +244,10 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n
244244 IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type);
245245static ResultLoc *no_result_loc(void);
246246
247static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *const_val) {
247static ZigValue *const_ptr_pointee_unchecked(CodeGen *g, ZigValue *const_val) {
248248 assert(get_src_ptr_type(const_val->type) != nullptr);
249249 assert(const_val->special == ConstValSpecialStatic);
250 ConstExprValue *result;
250 ZigValue *result;
251251
252252 switch (type_has_one_possible_value(g, const_val->type->data.pointer.child_type)) {
253253 case OnePossibleValueInvalid:
......@@ -265,7 +265,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
265265 result = const_val->data.x_ptr.data.ref.pointee;
266266 break;
267267 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;
269269 if (const_val->data.x_ptr.data.base_array.elem_index == array_val->type->data.array.len) {
270270 result = array_val->type->data.array.sentinel;
271271 } else {
......@@ -275,7 +275,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
275275 break;
276276 }
277277 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;
279279 expand_undef_struct(g, struct_val);
280280 result = struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index];
281281 break;
......@@ -317,7 +317,7 @@ static bool slice_is_const(ZigType *type) {
317317 return type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const;
318318}
319319
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
321321// value remains meaningful.
322322static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expected, ZigType *actual) {
323323 if (expected == actual)
......@@ -416,7 +416,7 @@ static Buf *exec_c_import_buf(IrExecutable *exec) {
416416 return exec->c_import_buf;
417417}
418418
419static bool value_is_comptime(ConstExprValue *const_val) {
419static bool value_is_comptime(ZigValue *const_val) {
420420 return const_val->special != ConstValSpecialRuntime;
421421}
422422
......@@ -449,7 +449,7 @@ static void ir_ref_var(ZigVar *var) {
449449}
450450
451451ZigType *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,
453453 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, nullptr,
454454 node, nullptr, ira->new_irb.exec, nullptr, UndefBad);
455455
......@@ -8698,26 +8698,26 @@ static void ir_assert(bool ok, IrInstruction *source_instruction) {
86988698// This function takes a comptime ptr and makes the child const value conform to the type
86998699// described by the pointer.
87008700static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node,
8701 ConstExprValue *ptr_val)
8701 ZigValue *ptr_val)
87028702{
87038703 Error err;
87048704 assert(ptr_val->type->id == ZigTypeIdPointer);
87058705 assert(ptr_val->special == ConstValSpecialStatic);
8706 ConstExprValue tmp = {};
8706 ZigValue tmp = {};
87078707 tmp.special = ConstValSpecialStatic;
87088708 tmp.type = ptr_val->type->data.pointer.child_type;
87098709 if ((err = ir_read_const_ptr(ira, codegen, source_node, &tmp, ptr_val)))
87108710 return err;
8711 ConstExprValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val);
8711 ZigValue *child_val = const_ptr_pointee_unchecked(codegen, ptr_val);
87128712 copy_const_val(child_val, &tmp, false);
87138713 return ErrorNone;
87148714}
87158715
8716ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprValue *const_val,
8716ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_val,
87178717 AstNode *source_node)
87188718{
87198719 Error err;
8720 ConstExprValue *val = const_ptr_pointee_unchecked(codegen, const_val);
8720 ZigValue *val = const_ptr_pointee_unchecked(codegen, const_val);
87218721 assert(val != nullptr);
87228722 assert(const_val->type->id == ZigTypeIdPointer);
87238723 ZigType *expected_type = const_val->type->data.pointer.child_type;
......@@ -8740,7 +8740,7 @@ ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprVal
87408740 return val;
87418741}
87428742
8743static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) {
8743static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) {
87448744 IrBasicBlock *bb = exec->basic_block_list.at(0);
87458745 for (size_t i = 0; i < bb->instruction_list.length; i += 1) {
87468746 IrInstruction *instruction = bb->instruction_list.at(i);
......@@ -8783,14 +8783,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so
87838783 return true;
87848784}
87858785
8786static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) {
8786static bool const_val_fits_in_num_lit(ZigValue *const_val, ZigType *num_lit_type) {
87878787 return ((num_lit_type->id == ZigTypeIdComptimeFloat &&
87888788 (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) ||
87898789 (num_lit_type->id == ZigTypeIdComptimeInt &&
87908790 (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt)));
87918791}
87928792
8793static bool float_has_fraction(ConstExprValue *const_val) {
8793static bool float_has_fraction(ZigValue *const_val) {
87948794 if (const_val->type->id == ZigTypeIdComptimeFloat) {
87958795 return bigfloat_has_fraction(&const_val->data.x_bigfloat);
87968796 } else if (const_val->type->id == ZigTypeIdFloat) {
......@@ -8818,7 +8818,7 @@ static bool float_has_fraction(ConstExprValue *const_val) {
88188818 }
88198819}
88208820
8821static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
8821static void float_append_buf(Buf *buf, ZigValue *const_val) {
88228822 if (const_val->type->id == ZigTypeIdComptimeFloat) {
88238823 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);
88248824 } else if (const_val->type->id == ZigTypeIdFloat) {
......@@ -8856,7 +8856,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
88568856 }
88578857}
88588858
8859static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
8859static void float_init_bigint(BigInt *bigint, ZigValue *const_val) {
88608860 if (const_val->type->id == ZigTypeIdComptimeFloat) {
88618861 bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat);
88628862 } else if (const_val->type->id == ZigTypeIdFloat) {
......@@ -8903,7 +8903,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
89038903 }
89048904}
89058905
8906static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
8906static void float_init_bigfloat(ZigValue *dest_val, BigFloat *bigfloat) {
89078907 if (dest_val->type->id == ZigTypeIdComptimeFloat) {
89088908 bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat);
89098909 } else if (dest_val->type->id == ZigTypeIdFloat) {
......@@ -8930,7 +8930,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
89308930 }
89318931}
89328932
8933static void float_init_f16(ConstExprValue *dest_val, float16_t x) {
8933static void float_init_f16(ZigValue *dest_val, float16_t x) {
89348934 if (dest_val->type->id == ZigTypeIdComptimeFloat) {
89358935 bigfloat_init_16(&dest_val->data.x_bigfloat, x);
89368936 } else if (dest_val->type->id == ZigTypeIdFloat) {
......@@ -8955,7 +8955,7 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) {
89558955 }
89568956}
89578957
8958static void float_init_f32(ConstExprValue *dest_val, float x) {
8958static void float_init_f32(ZigValue *dest_val, float x) {
89598959 if (dest_val->type->id == ZigTypeIdComptimeFloat) {
89608960 bigfloat_init_32(&dest_val->data.x_bigfloat, x);
89618961 } else if (dest_val->type->id == ZigTypeIdFloat) {
......@@ -8984,7 +8984,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) {
89848984 }
89858985}
89868986
8987static void float_init_f64(ConstExprValue *dest_val, double x) {
8987static void float_init_f64(ZigValue *dest_val, double x) {
89888988 if (dest_val->type->id == ZigTypeIdComptimeFloat) {
89898989 bigfloat_init_64(&dest_val->data.x_bigfloat, x);
89908990 } else if (dest_val->type->id == ZigTypeIdFloat) {
......@@ -9013,7 +9013,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) {
90139013 }
90149014}
90159015
9016static void float_init_f128(ConstExprValue *dest_val, float128_t x) {
9016static void float_init_f128(ZigValue *dest_val, float128_t x) {
90179017 if (dest_val->type->id == ZigTypeIdComptimeFloat) {
90189018 bigfloat_init_128(&dest_val->data.x_bigfloat, x);
90199019 } else if (dest_val->type->id == ZigTypeIdFloat) {
......@@ -9046,7 +9046,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) {
90469046 }
90479047}
90489048
9049static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) {
9049static void float_init_float(ZigValue *dest_val, ZigValue *src_val) {
90509050 if (src_val->type->id == ZigTypeIdComptimeFloat) {
90519051 float_init_bigfloat(dest_val, &src_val->data.x_bigfloat);
90529052 } else if (src_val->type->id == ZigTypeIdFloat) {
......@@ -9071,7 +9071,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val)
90719071 }
90729072}
90739073
9074static bool float_is_nan(ConstExprValue *op) {
9074static bool float_is_nan(ZigValue *op) {
90759075 if (op->type->id == ZigTypeIdComptimeFloat) {
90769076 return bigfloat_is_nan(&op->data.x_bigfloat);
90779077 } else if (op->type->id == ZigTypeIdFloat) {
......@@ -9092,7 +9092,7 @@ static bool float_is_nan(ConstExprValue *op) {
90929092 }
90939093}
90949094
9095static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
9095static Cmp float_cmp(ZigValue *op1, ZigValue *op2) {
90969096 assert(op1->type == op2->type);
90979097 if (op1->type->id == ZigTypeIdComptimeFloat) {
90989098 return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat);
......@@ -9138,7 +9138,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
91389138 }
91399139}
91409140
9141static Cmp float_cmp_zero(ConstExprValue *op) {
9141static Cmp float_cmp_zero(ZigValue *op) {
91429142 if (op->type->id == ZigTypeIdComptimeFloat) {
91439143 return bigfloat_cmp_zero(&op->data.x_bigfloat);
91449144 } else if (op->type->id == ZigTypeIdFloat) {
......@@ -9188,7 +9188,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) {
91889188 }
91899189}
91909190
9191static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9191static void float_add(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
91929192 assert(op1->type == op2->type);
91939193 out_val->type = op1->type;
91949194 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9215,7 +9215,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
92159215 }
92169216}
92179217
9218static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9218static void float_sub(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
92199219 assert(op1->type == op2->type);
92209220 out_val->type = op1->type;
92219221 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9242,7 +9242,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
92429242 }
92439243}
92449244
9245static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9245static void float_mul(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
92469246 assert(op1->type == op2->type);
92479247 out_val->type = op1->type;
92489248 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9269,7 +9269,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
92699269 }
92709270}
92719271
9272static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9272static void float_div(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
92739273 assert(op1->type == op2->type);
92749274 out_val->type = op1->type;
92759275 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9296,7 +9296,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
92969296 }
92979297}
92989298
9299static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9299static void float_div_trunc(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
93009300 assert(op1->type == op2->type);
93019301 out_val->type = op1->type;
93029302 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9325,7 +9325,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE
93259325 }
93269326}
93279327
9328static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9328static void float_div_floor(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
93299329 assert(op1->type == op2->type);
93309330 out_val->type = op1->type;
93319331 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9354,7 +9354,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE
93549354 }
93559355}
93569356
9357static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9357static void float_rem(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
93589358 assert(op1->type == op2->type);
93599359 out_val->type = op1->type;
93609360 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9399,7 +9399,7 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t*
93999399 f128M_sub(a, c, c);
94009400}
94019401
9402static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
9402static void float_mod(ZigValue *out_val, ZigValue *op1, ZigValue *op2) {
94039403 assert(op1->type == op2->type);
94049404 out_val->type = op1->type;
94059405 if (op1->type->id == ZigTypeIdComptimeFloat) {
......@@ -9426,7 +9426,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
94269426 }
94279427}
94289428
9429static void float_negate(ConstExprValue *out_val, ConstExprValue *op) {
9429static void float_negate(ZigValue *out_val, ZigValue *op) {
94309430 out_val->type = op->type;
94319431 if (op->type->id == ZigTypeIdComptimeFloat) {
94329432 bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat);
......@@ -9457,7 +9457,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) {
94579457 }
94589458}
94599459
9460void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) {
9460void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) {
94619461 if (op->type->id == ZigTypeIdFloat) {
94629462 switch (op->type->data.floating.bit_count) {
94639463 case 16:
......@@ -9480,7 +9480,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) {
94809480 }
94819481}
94829482
9483void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) {
9483void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) {
94849484 if (val->type->id == ZigTypeIdFloat) {
94859485 switch (val->type->data.floating.bit_count) {
94869486 case 16:
......@@ -9510,7 +9510,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
95109510 return false;
95119511 }
95129512
9513 ConstExprValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef);
9513 ZigValue *const_val = ir_resolve_const(ira, instruction, LazyOkNoUndef);
95149514 if (const_val == nullptr)
95159515 return false;
95169516
......@@ -10984,9 +10984,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
1098410984 }
1098510985}
1098610986
10987static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_global_refs) {
10987static void copy_const_val(ZigValue *dest, ZigValue *src, bool same_global_refs) {
1098810988 ConstGlobalRefs *global_refs = dest->global_refs;
10989 memcpy(dest, src, sizeof(ConstExprValue));
10989 memcpy(dest, src, sizeof(ZigValue));
1099010990 if (!same_global_refs) {
1099110991 dest->global_refs = global_refs;
1099210992 if (src->special != ConstValSpecialStatic)
......@@ -11002,8 +11002,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_
1100211002
1100311003static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
1100411004 CastOp cast_op,
11005 ConstExprValue *other_val, ZigType *other_type,
11006 ConstExprValue *const_val, ZigType *new_type)
11005 ZigValue *other_val, ZigType *other_type,
11006 ZigValue *const_val, ZigType *new_type)
1100711007{
1100811008 const_val->special = other_val->special;
1100911009
......@@ -11145,7 +11145,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira,
1114511145 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type));
1114611146
1114711147 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);
1114911149 if (pointee == nullptr)
1115011150 return ira->codegen->invalid_instruction;
1115111151 if (pointee->special != ConstValSpecialRuntime) {
......@@ -11178,7 +11178,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
1117811178 wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type));
1117911179
1118011180 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);
1118211182 if (pointee == nullptr)
1118311183 return ira->codegen->invalid_instruction;
1118411184 if (pointee->special != ConstValSpecialRuntime) {
......@@ -11443,13 +11443,13 @@ static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_in
1144311443}
1144411444
1144511445static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
11446 ConstExprValue *pointee, ZigType *pointee_type,
11446 ZigValue *pointee, ZigType *pointee_type,
1144711447 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align)
1144811448{
1144911449 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
1145011450 ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false);
1145111451 IrInstruction *const_instr = ir_const(ira, instruction, ptr_type);
11452 ConstExprValue *const_val = &const_instr->value;
11452 ZigValue *const_val = &const_instr->value;
1145311453 const_val->data.x_ptr.special = ConstPtrSpecialRef;
1145411454 const_val->data.x_ptr.mut = ptr_mut;
1145511455 const_val->data.x_ptr.data.ref.pointee = pointee;
......@@ -11457,7 +11457,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio
1145711457}
1145811458
1145911459static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node,
11460 ConstExprValue *val, UndefAllowed undef_allowed)
11460 ZigValue *val, UndefAllowed undef_allowed)
1146111461{
1146211462 Error err;
1146311463 for (;;) {
......@@ -11490,7 +11490,7 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode
1149011490 }
1149111491}
1149211492
11493static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) {
11493static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) {
1149411494 Error err;
1149511495 if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node,
1149611496 &value->value, undef_allowed)))
......@@ -11500,7 +11500,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
1150011500 return &value->value;
1150111501}
1150211502
11503ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
11503ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
1150411504 ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota,
1150511505 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
1150611506 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
1155411554 fprintf(stderr, "}\n");
1155511555 }
1155611556
11557 ConstExprValue *result = ir_exec_const_result(codegen, analyzed_executable);
11557 ZigValue *result = ir_exec_const_result(codegen, analyzed_executable);
1155811558 if (type_is_invalid(result->type))
1155911559 return &codegen->invalid_instruction->value;
1156011560
......@@ -11574,7 +11574,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu
1157411574 return nullptr;
1157511575 }
1157611576
11577 ConstExprValue *const_val = ir_resolve_const(ira, err_value, UndefBad);
11577 ZigValue *const_val = ir_resolve_const(ira, err_value, UndefBad);
1157811578 if (!const_val)
1157911579 return nullptr;
1158011580
......@@ -11583,7 +11583,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu
1158311583}
1158411584
1158511585static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node,
11586 ConstExprValue *val)
11586 ZigValue *val)
1158711587{
1158811588 Error err;
1158911589 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
1159311593 return val->data.x_type;
1159411594}
1159511595
11596static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) {
11596static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) {
1159711597 if (type_is_invalid(type_value->value.type))
1159811598 return nullptr;
1159911599
......@@ -11614,7 +11614,7 @@ static ConstExprValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_
1161411614}
1161511615
1161611616static 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);
1161811618 if (val == nullptr)
1161911619 return ira->codegen->builtin_types.entry_invalid;
1162011620
......@@ -11674,7 +11674,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour
1167411674 return ira->codegen->builtin_types.entry_invalid;
1167511675 }
1167611676
11677 ConstExprValue *const_val = ir_resolve_const(ira, type_value, UndefBad);
11677 ZigValue *const_val = ir_resolve_const(ira, type_value, UndefBad);
1167811678 if (!const_val)
1167911679 return ira->codegen->builtin_types.entry_invalid;
1168011680
......@@ -11703,7 +11703,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
1170311703 return nullptr;
1170411704 }
1170511705
11706 ConstExprValue *const_val = ir_resolve_const(ira, fn_value, UndefBad);
11706 ZigValue *const_val = ir_resolve_const(ira, fn_value, UndefBad);
1170711707 if (!const_val)
1170811708 return nullptr;
1170911709
......@@ -11725,7 +11725,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so
1172511725 if (type_is_invalid(casted_payload->value.type))
1172611726 return ira->codegen->invalid_instruction;
1172711727
11728 ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefOk);
11728 ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk);
1172911729 if (!val)
1173011730 return ira->codegen->invalid_instruction;
1173111731
......@@ -11768,11 +11768,11 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
1176811768 if (type_is_invalid(casted_payload->value.type))
1176911769 return ira->codegen->invalid_instruction;
1177011770
11771 ConstExprValue *val = ir_resolve_const(ira, casted_payload, UndefBad);
11771 ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad);
1177211772 if (!val)
1177311773 return ira->codegen->invalid_instruction;
1177411774
11775 ConstExprValue *err_set_val = create_const_vals(1);
11775 ZigValue *err_set_val = create_const_vals(1);
1177611776 err_set_val->type = err_set_type;
1177711777 err_set_val->special = ConstValSpecialStatic;
1177811778 err_set_val->data.x_err_set = nullptr;
......@@ -11809,7 +11809,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou
1180911809 assert(wanted_type->id == ZigTypeIdErrorSet);
1181011810
1181111811 if (instr_is_comptime(value)) {
11812 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
11812 ZigValue *val = ir_resolve_const(ira, value, UndefBad);
1181311813 if (!val)
1181411814 return ira->codegen->invalid_instruction;
1181511815
......@@ -11849,7 +11849,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc
1184911849 IrInstruction *frame_ptr, ZigType *wanted_type)
1185011850{
1185111851 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);
1185311853 if (ptr_val == nullptr)
1185411854 return ira->codegen->invalid_instruction;
1185511855
......@@ -11887,11 +11887,11 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
1188711887 IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type);
1188811888
1188911889 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);
1189111891 if (!val)
1189211892 return ira->codegen->invalid_instruction;
1189311893
11894 ConstExprValue *err_set_val = create_const_vals(1);
11894 ZigValue *err_set_val = create_const_vals(1);
1189511895 err_set_val->special = ConstValSpecialStatic;
1189611896 err_set_val->type = wanted_type->data.error_union.err_set_type;
1189711897 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
1192611926 assert(wanted_type->id == ZigTypeIdOptional);
1192711927 assert(instr_is_comptime(value));
1192811928
11929 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
11929 ZigValue *val = ir_resolve_const(ira, value, UndefBad);
1193011930 assert(val != nullptr);
1193111931
1193211932 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
......@@ -11948,7 +11948,7 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction
1194811948 assert(wanted_type->data.pointer.ptr_len == PtrLenC);
1194911949 assert(instr_is_comptime(value));
1195011950
11951 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
11951 ZigValue *val = ir_resolve_const(ira, value, UndefBad);
1195211952 assert(val != nullptr);
1195311953
1195411954 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
......@@ -11969,7 +11969,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
1196911969 return ira->codegen->invalid_instruction;
1197011970
1197111971 if (instr_is_comptime(value)) {
11972 ConstExprValue *val = ir_resolve_const(ira, value, LazyOk);
11972 ZigValue *val = ir_resolve_const(ira, value, LazyOk);
1197311973 if (!val)
1197411974 return ira->codegen->invalid_instruction;
1197511975 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
1209812098 }
1209912099
1210012100 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);
1210212102 if (!val)
1210312103 return ira->codegen->invalid_instruction;
1210412104 IrInstruction *result = ir_const(ira, source_instr, tag_type);
......@@ -12120,7 +12120,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou
1212012120 assert(wanted_type == target->value.type->data.unionation.tag_type);
1212112121
1212212122 if (instr_is_comptime(target)) {
12123 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12123 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1212412124 if (!val)
1212512125 return ira->codegen->invalid_instruction;
1212612126 IrInstruction *result = ir_const(ira, source_instr, wanted_type);
......@@ -12170,7 +12170,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
1217012170 return ira->codegen->invalid_instruction;
1217112171
1217212172 if (instr_is_comptime(target)) {
12173 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12173 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1217412174 if (!val)
1217512175 return ira->codegen->invalid_instruction;
1217612176 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
1224512245 assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat);
1224612246
1224712247 if (instr_is_comptime(target)) {
12248 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12248 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1224912249 if (!val)
1225012250 return ira->codegen->invalid_instruction;
1225112251 if (wanted_type->id == ZigTypeIdInt) {
......@@ -12313,7 +12313,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
1231312313 assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt);
1231412314
1231512315 if (instr_is_comptime(target)) {
12316 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12316 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1231712317 if (!val)
1231812318 return ira->codegen->invalid_instruction;
1231912319
......@@ -12343,7 +12343,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
1234312343static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr,
1234412344 IrInstruction *target, ZigType *wanted_type)
1234512345{
12346 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12346 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1234712347 if (!val)
1234812348 return ira->codegen->invalid_instruction;
1234912349
......@@ -12366,7 +12366,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
1236612366 assert(wanted_type->id == ZigTypeIdErrorSet);
1236712367
1236812368 if (instr_is_comptime(target)) {
12369 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12369 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1237012370 if (!val)
1237112371 return ira->codegen->invalid_instruction;
1237212372
......@@ -12430,7 +12430,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
1243012430 ZigType *err_type = target->value.type;
1243112431
1243212432 if (instr_is_comptime(target)) {
12433 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12433 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1243412434 if (!val)
1243512435 return ira->codegen->invalid_instruction;
1243612436
......@@ -12511,16 +12511,16 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou
1251112511 assert(array_type->data.array.len == 1);
1251212512
1251312513 if (instr_is_comptime(target)) {
12514 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
12514 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
1251512515 if (!val)
1251612516 return ira->codegen->invalid_instruction;
1251712517
1251812518 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);
1252012520 if (pointee == nullptr)
1252112521 return ira->codegen->invalid_instruction;
1252212522 if (pointee->special != ConstValSpecialRuntime) {
12523 ConstExprValue *array_val = create_const_vals(1);
12523 ZigValue *array_val = create_const_vals(1);
1252412524 array_val->special = ConstValSpecialStatic;
1252512525 array_val->type = array_type;
1252612526 array_val->data.x_array.special = ConstArraySpecialNone;
......@@ -12724,7 +12724,7 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction *
1272412724 IrInstruction *array, ZigType *vector_type)
1272512725{
1272612726 if (instr_is_comptime(array)) {
12727 // arrays and vectors have the same ConstExprValue representation
12727 // arrays and vectors have the same ZigValue representation
1272812728 IrInstruction *result = ir_const(ira, source_instr, vector_type);
1272912729 copy_const_val(&result->value, &array->value, false);
1273012730 result->value.type = vector_type;
......@@ -12737,7 +12737,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
1273712737 IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc)
1273812738{
1273912739 if (instr_is_comptime(vector)) {
12740 // arrays and vectors have the same ConstExprValue representation
12740 // arrays and vectors have the same ZigValue representation
1274112741 IrInstruction *result = ir_const(ira, source_instr, array_type);
1274212742 copy_const_val(&result->value, &vector->value, false);
1274312743 result->value.type = array_type;
......@@ -13576,7 +13576,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1357613576 return ira->codegen->invalid_instruction;
1357713577 }
1357813578 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);
1358013580 if (child_type == ira->codegen->builtin_types.entry_var) {
1358113581 child_type = pointee->type;
1358213582 }
......@@ -13637,7 +13637,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1363713637}
1363813638
1363913639static 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)
1364113641{
1364213642 Error err;
1364313643 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
1369613696 if (type_is_invalid(casted_value->value.type))
1369713697 return false;
1369813698
13699 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13699 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1370013700 if (!const_val)
1370113701 return false;
1370213702
......@@ -13716,7 +13716,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) {
1371613716 if (type_is_invalid(casted_value->value.type))
1371713717 return false;
1371813718
13719 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13719 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1372013720 if (!const_val)
1372113721 return false;
1372213722
......@@ -13736,7 +13736,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1373613736 if (type_is_invalid(value->value.type))
1373713737 return false;
1373813738
13739 ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");
13739 ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");
1374013740 assert(atomic_order_val->type->id == ZigTypeIdMetaType);
1374113741 ZigType *atomic_order_type = atomic_order_val->data.x_type;
1374213742
......@@ -13744,7 +13744,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1374413744 if (type_is_invalid(casted_value->value.type))
1374513745 return false;
1374613746
13747 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13747 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1374813748 if (!const_val)
1374913749 return false;
1375013750
......@@ -13756,7 +13756,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1375613756 if (type_is_invalid(value->value.type))
1375713757 return false;
1375813758
13759 ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");
13759 ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");
1376013760 assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType);
1376113761 ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
1376213762
......@@ -13764,7 +13764,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1376413764 if (type_is_invalid(casted_value->value.type))
1376513765 return false;
1376613766
13767 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13767 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1376813768 if (!const_val)
1376913769 return false;
1377013770
......@@ -13776,7 +13776,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1377613776 if (type_is_invalid(value->value.type))
1377713777 return false;
1377813778
13779 ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");
13779 ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");
1378013780 assert(global_linkage_val->type->id == ZigTypeIdMetaType);
1378113781 ZigType *global_linkage_type = global_linkage_val->data.x_type;
1378213782
......@@ -13784,7 +13784,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1378413784 if (type_is_invalid(casted_value->value.type))
1378513785 return false;
1378613786
13787 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13787 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1378813788 if (!const_val)
1378913789 return false;
1379013790
......@@ -13796,7 +13796,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1379613796 if (type_is_invalid(value->value.type))
1379713797 return false;
1379813798
13799 ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");
13799 ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");
1380013800 assert(float_mode_val->type->id == ZigTypeIdMetaType);
1380113801 ZigType *float_mode_type = float_mode_val->data.x_type;
1380213802
......@@ -13804,7 +13804,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1380413804 if (type_is_invalid(casted_value->value.type))
1380513805 return false;
1380613806
13807 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13807 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1380813808 if (!const_val)
1380913809 return false;
1381013810
......@@ -13823,15 +13823,15 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
1382313823 if (type_is_invalid(casted_value->value.type))
1382413824 return nullptr;
1382513825
13826 ConstExprValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
13826 ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad);
1382713827 if (!const_val)
1382813828 return nullptr;
1382913829
13830 ConstExprValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index];
13831 ConstExprValue *len_field = const_val->data.x_struct.fields[slice_len_index];
13830 ZigValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index];
13831 ZigValue *len_field = const_val->data.x_struct.fields[slice_len_index];
1383213832
1383313833 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;
1383513835 expand_undef_array(ira->codegen, array_val);
1383613836 size_t len = bigint_as_usize(&len_field->data.x_bigint);
1383713837 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) {
1384113841 buf_resize(result, len);
1384213842 for (size_t i = 0; i < len; i += 1) {
1384313843 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];
1384513845 if (char_val->special == ConstValSpecialUndef) {
1384613846 ir_add_error(ira, casted_value, buf_sprintf("use of undefined value"));
1384713847 return nullptr;
......@@ -13934,11 +13934,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
1393413934 return ira->codegen->invalid_instruction;
1393513935
1393613936 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);
1393813938 if (op1_val == nullptr)
1393913939 return ira->codegen->invalid_instruction;
1394013940
13941 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
13941 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
1394213942 if (op2_val == nullptr)
1394313943 return ira->codegen->invalid_instruction;
1394413944
......@@ -13981,7 +13981,7 @@ static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) {
1398113981 }
1398213982}
1398313983
13984static bool optional_value_is_null(ConstExprValue *val) {
13984static bool optional_value_is_null(ZigValue *val) {
1398513985 assert(val->special == ConstValSpecialStatic);
1398613986 if (get_codegen_ptr_type(val->type) != nullptr) {
1398713987 if (val->data.x_ptr.special == ConstPtrSpecialNull) {
......@@ -13999,7 +13999,7 @@ static bool optional_value_is_null(ConstExprValue *val) {
1399913999}
1400014000
1400114001static 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,
1400314003 bool one_possible_value) {
1400414004 if (op1_val->special == ConstValSpecialUndef ||
1400514005 op2_val->special == ConstValSpecialUndef)
......@@ -14052,7 +14052,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t
1405214052}
1405314053
1405414054// Returns ErrorNotLazy when the value cannot be determined
14055static Error lazy_cmp_zero(AstNode *source_node, ConstExprValue *val, Cmp *result) {
14055static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) {
1405614056 Error err;
1405714057
1405814058 switch (val->special) {
......@@ -14124,7 +14124,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1412414124 zig_unreachable();
1412514125 }
1412614126 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);
1412814128 if (!maybe_val)
1412914129 return ira->codegen->invalid_instruction;
1413014130 bool is_null = optional_value_is_null(maybe_val);
......@@ -14159,7 +14159,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1415914159 zig_unreachable();
1416014160 }
1416114161 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);
1416314163 if (!c_ptr_val)
1416414164 return ira->codegen->invalid_instruction;
1416514165 if (c_ptr_val->special == ConstValSpecialUndef)
......@@ -14207,11 +14207,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1420714207 return ira->codegen->invalid_instruction;
1420814208
1420914209 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);
1421114211 if (!const_union_val)
1421214212 return ira->codegen->invalid_instruction;
1421314213
14214 ConstExprValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad);
14214 ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad);
1421514215 if (!const_enum_val)
1421614216 return ira->codegen->invalid_instruction;
1421714217
......@@ -14282,10 +14282,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1428214282 }
1428314283
1428414284 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);
1428614286 if (op1_val == nullptr)
1428714287 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);
1428914289 if (op2_val == nullptr)
1429014290 return ira->codegen->invalid_instruction;
1429114291
......@@ -14430,10 +14430,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
1443014430 }
1443114431never_mind_just_calculate_it_normally:
1443214432
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);
1443414434 if (op1_val == nullptr)
1443514435 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);
1443714437 if (op2_val == nullptr)
1443814438 return ira->codegen->invalid_instruction;
1443914439 if (resolved_type->id != ZigTypeIdVector)
......@@ -14456,7 +14456,7 @@ never_mind_just_calculate_it_normally:
1445614456
1445714457 // some comparisons with unsigned numbers can be evaluated
1445814458 if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) {
14459 ConstExprValue *known_left_val;
14459 ZigValue *known_left_val;
1446014460 IrBinOp flipped_op_id;
1446114461 if (instr_is_comptime(casted_op1)) {
1446214462 known_left_val = ir_resolve_const(ira, casted_op1, UndefBad);
......@@ -14504,7 +14504,7 @@ never_mind_just_calculate_it_normally:
1450414504}
1450514505
1450614506static 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)
1450814508{
1450914509 bool is_int;
1451014510 bool is_float;
......@@ -14646,7 +14646,7 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in
1464614646 }
1464714647 } else {
1464814648 float_div_trunc(out_val, op1_val, op2_val);
14649 ConstExprValue remainder = {};
14649 ZigValue remainder = {};
1465014650 float_rem(&remainder, op1_val, op2_val);
1465114651 if (float_cmp_zero(&remainder) != CmpEQ) {
1465214652 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
1468414684
1468514685// This works on operands that have already been checked to be comptime known.
1468614686static 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)
1468814688{
1468914689 IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry);
14690 ConstExprValue *out_val = &result_instruction->value;
14690 ZigValue *out_val = &result_instruction->value;
1469114691 if (type_entry->id == ZigTypeIdVector) {
1469214692 expand_undef_array(ira->codegen, op1_val);
1469314693 expand_undef_array(ira->codegen, op2_val);
......@@ -14696,9 +14696,9 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i
1469614696 size_t len = type_entry->data.vector.len;
1469714697 ZigType *scalar_type = type_entry->data.vector.elem_type;
1469814698 for (size_t i = 0; i < len; i += 1) {
14699 ConstExprValue *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];
14701 ConstExprValue *scalar_out_val = &out_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 ZigValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i];
14701 ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i];
1470214702 assert(scalar_op1_val->type == scalar_type);
1470314703 assert(scalar_op2_val->type == scalar_type);
1470414704 assert(scalar_out_val->type == scalar_type);
......@@ -14788,11 +14788,11 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b
1478814788 }
1478914789
1479014790 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);
1479214792 if (op1_val == nullptr)
1479314793 return ira->codegen->invalid_instruction;
1479414794
14795 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
14795 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
1479614796 if (op2_val == nullptr)
1479714797 return ira->codegen->invalid_instruction;
1479814798
......@@ -14896,8 +14896,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1489614896 return ira->codegen->invalid_instruction;
1489714897
1489814898 // If either operand is undef, result is undef.
14899 ConstExprValue *op1_val = nullptr;
14900 ConstExprValue *op2_val = nullptr;
14899 ZigValue *op1_val = nullptr;
14900 ZigValue *op2_val = nullptr;
1490114901 if (instr_is_comptime(op1)) {
1490214902 op1_val = ir_resolve_const(ira, op1, UndefOk);
1490314903 if (op1_val == nullptr)
......@@ -14968,11 +14968,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1496814968 if (is_signed_div) {
1496914969 bool ok = false;
1497014970 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);
1497214972 if (op1_val == nullptr)
1497314973 return ira->codegen->invalid_instruction;
1497414974
14975 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
14975 ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
1497614976 if (op2_val == nullptr)
1497714977 return ira->codegen->invalid_instruction;
1497814978
......@@ -15006,12 +15006,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1500615006 if (is_signed_div && (is_int || is_float)) {
1500715007 bool ok = false;
1500815008 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);
1501015010 if (op1_val == nullptr)
1501115011 return ira->codegen->invalid_instruction;
1501215012
1501315013 if (is_int) {
15014 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
15014 ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
1501515015 if (op2_val == nullptr)
1501615016 return ira->codegen->invalid_instruction;
1501715017
......@@ -15031,7 +15031,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1503115031 if (casted_op2 == ira->codegen->invalid_instruction)
1503215032 return ira->codegen->invalid_instruction;
1503315033
15034 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
15034 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
1503515035 if (op2_val == nullptr)
1503615036 return ira->codegen->invalid_instruction;
1503715037
......@@ -15040,8 +15040,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1504015040 // have a remainder function ambiguity problem
1504115041 ok = true;
1504215042 } else {
15043 ConstExprValue rem_result = {};
15044 ConstExprValue mod_result = {};
15043 ZigValue rem_result = {};
15044 ZigValue mod_result = {};
1504515045 float_rem(&rem_result, op1_val, op2_val);
1504615046 float_mod(&mod_result, op1_val, op2_val);
1504715047 ok = float_cmp(&rem_result, &mod_result) == CmpEQ;
......@@ -15100,10 +15100,10 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1510015100 return ira->codegen->invalid_instruction;
1510115101
1510215102 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);
1510415104 if (op1_val == nullptr)
1510515105 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);
1510715107 if (op2_val == nullptr)
1510815108 return ira->codegen->invalid_instruction;
1510915109
......@@ -15127,16 +15127,16 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1512715127 if (type_is_invalid(op2_type))
1512815128 return ira->codegen->invalid_instruction;
1512915129
15130 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
15130 ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
1513115131 if (!op1_val)
1513215132 return ira->codegen->invalid_instruction;
1513315133
15134 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
15134 ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
1513515135 if (!op2_val)
1513615136 return ira->codegen->invalid_instruction;
1513715137
15138 ConstExprValue *sentinel1 = nullptr;
15139 ConstExprValue *op1_array_val;
15138 ZigValue *sentinel1 = nullptr;
15139 ZigValue *op1_array_val;
1514015140 size_t op1_array_index;
1514115141 size_t op1_array_end;
1514215142 ZigType *child_type;
......@@ -15159,11 +15159,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1515915159 } else if (is_slice(op1_type)) {
1516015160 ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index]->type_entry;
1516115161 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];
1516315163 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
1516415164 op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val;
1516515165 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];
1516715167 op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint);
1516815168 sentinel1 = ptr_type->data.pointer.sentinel;
1516915169 } 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
1518315183 return ira->codegen->invalid_instruction;
1518415184 }
1518515185
15186 ConstExprValue *sentinel2 = nullptr;
15187 ConstExprValue *op2_array_val;
15186 ZigValue *sentinel2 = nullptr;
15187 ZigValue *op2_array_val;
1518815188 size_t op2_array_index;
1518915189 size_t op2_array_end;
1519015190 bool op2_type_valid;
......@@ -15207,11 +15207,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1520715207 } else if (is_slice(op2_type)) {
1520815208 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index]->type_entry;
1520915209 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];
1521115211 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
1521215212 op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val;
1521315213 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];
1521515215 op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint);
1521615216
1521715217 sentinel2 = ptr_type->data.pointer.sentinel;
......@@ -15239,7 +15239,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1523915239 return ira->codegen->invalid_instruction;
1524015240 }
1524115241
15242 ConstExprValue *sentinel;
15242 ZigValue *sentinel;
1524315243 if (sentinel1 != nullptr && sentinel2 != nullptr) {
1524415244 // When there is a sentinel mismatch, no sentinel on the result. The type system
1524515245 // will catch this if it is a problem.
......@@ -15254,9 +15254,9 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1525415254
1525515255 // The type of result is populated in the following if blocks
1525615256 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
15257 ConstExprValue *out_val = &result->value;
15257 ZigValue *out_val = &result->value;
1525815258
15259 ConstExprValue *out_array_val;
15259 ZigValue *out_array_val;
1526015260 size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index);
1526115261 if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) {
1526215262 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
1531715317
1531815318 size_t next_index = 0;
1531915319 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];
1532115321 copy_const_val(elem_dest_val, &op1_array_val->data.x_array.data.s_none.elements[i], false);
1532215322 elem_dest_val->parent.id = ConstParentIdArray;
1532315323 elem_dest_val->parent.data.p_array.array_val = out_array_val;
1532415324 elem_dest_val->parent.data.p_array.elem_index = next_index;
1532515325 }
1532615326 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];
1532815328 copy_const_val(elem_dest_val, &op2_array_val->data.x_array.data.s_none.elements[i], false);
1532915329 elem_dest_val->parent.id = ConstParentIdArray;
1533015330 elem_dest_val->parent.data.p_array.array_val = out_array_val;
1533115331 elem_dest_val->parent.data.p_array.elem_index = next_index;
1533215332 }
1533315333 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];
1533515335 copy_const_val(elem_dest_val, sentinel, false);
1533615336 elem_dest_val->parent.id = ConstParentIdArray;
1533715337 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 *
1535415354
1535515355 bool want_ptr_to_array = false;
1535615356 ZigType *array_type;
15357 ConstExprValue *array_val;
15357 ZigValue *array_val;
1535815358 if (op1->value.type->id == ZigTypeIdArray) {
1535915359 array_type = op1->value.type;
1536015360 array_val = ir_resolve_const(ira, op1, UndefOk);
......@@ -15397,7 +15397,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1539715397 array_result = ir_const_undef(ira, &instruction->base, result_array_type);
1539815398 } else {
1539915399 array_result = ir_const(ira, &instruction->base, result_array_type);
15400 ConstExprValue *out_val = &array_result->value;
15400 ZigValue *out_val = &array_result->value;
1540115401
1540215402 switch (type_has_one_possible_value(ira->codegen, result_array_type)) {
1540315403 case OnePossibleValueInvalid:
......@@ -15416,7 +15416,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1541615416 uint64_t i = 0;
1541715417 for (uint64_t x = 0; x < mult_amt; x += 1) {
1541815418 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];
1542015420 copy_const_val(elem_dest_val, &array_val->data.x_array.data.s_none.elements[y], false);
1542115421 elem_dest_val->parent.id = ConstParentIdArray;
1542215422 elem_dest_val->parent.data.p_array.array_val = out_val;
......@@ -15427,7 +15427,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1542715427 assert(i == new_array_len);
1542815428
1542915429 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];
1543115431 copy_const_val(elem_dest_val, array_type->data.array.sentinel, false);
1543215432 elem_dest_val->parent.id = ConstParentIdArray;
1543315433 elem_dest_val->parent.data.p_array.array_val = out_val;
......@@ -15570,7 +15570,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1557015570 zig_unreachable();
1557115571 }
1557215572
15573 ConstExprValue *init_val = nullptr;
15573 ZigValue *init_val = nullptr;
1557415574 if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
1557515575 init_val = const_ptr_pointee(ira, ira->codegen, &var_ptr->value, decl_var_instruction->base.source_node);
1557615576 if (is_comptime_var) {
......@@ -15631,7 +15631,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1563115631 new_var->owner_exec = var->owner_exec;
1563215632 new_var->align_bytes = var->align_bytes;
1563315633 if (var->mem_slot_index != SIZE_MAX) {
15634 ConstExprValue *vals = create_const_vals(1);
15634 ZigValue *vals = create_const_vals(1);
1563515635 new_var->mem_slot_index = ira->exec_context.mem_slot_list.length;
1563615636 ira->exec_context.mem_slot_list.append(vals);
1563715637 }
......@@ -15687,7 +15687,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira,
1568715687
1568815688 if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) {
1568915689 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);
1569115691 copy_const_val(mem_slot, init_val, !is_comptime_var || var->gen_is_const);
1569215692
1569315693 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,
1593615936 ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
1593715937 if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {
1593815938 IrInstruction *result = ir_const(ira, &instruction->base, optional_type);
15939 ConstExprValue *out_val = &result->value;
15939 ZigValue *out_val = &result->value;
1594015940 assert(get_codegen_ptr_type(optional_type) != nullptr);
1594115941 out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr;
1594215942 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
1598215982{
1598315983 Error err;
1598415984
15985 ConstExprValue *pointee = create_const_vals(1);
15985 ZigValue *pointee = create_const_vals(1);
1598615986 pointee->special = ConstValSpecialUndef;
1598715987
1598815988 IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint);
......@@ -16063,7 +16063,7 @@ static bool type_can_bit_cast(ZigType *t) {
1606316063}
1606416064
1606516065static 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);
1606716067 undef_child->type = ptr->value.type->data.pointer.child_type;
1606816068 undef_child->special = ConstValSpecialUndef;
1606916069 ptr->value.special = ConstValSpecialStatic;
......@@ -16676,7 +16676,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
1667616676 casted_arg = arg;
1667716677 }
1667816678
16679 ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk);
16679 ZigValue *arg_val = ir_resolve_const(ira, casted_arg, UndefOk);
1668016680 if (!arg_val)
1668116681 return false;
1668216682
......@@ -16721,7 +16721,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1672116721 bool comptime_arg = param_decl_node->data.param_decl.is_comptime ||
1672216722 casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat;
1672316723
16724 ConstExprValue *arg_val;
16724 ZigValue *arg_val;
1672516725
1672616726 if (comptime_arg) {
1672716727 arg_part_of_generic_id = true;
......@@ -16805,7 +16805,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1680516805 if (var->var_type == nullptr || type_is_invalid(var->var_type))
1680616806 return ira->codegen->invalid_instruction;
1680716807
16808 ConstExprValue *mem_slot = nullptr;
16808 ZigValue *mem_slot = nullptr;
1680916809
1681016810 bool comptime_var_mem = ir_get_var_is_comptime(var);
1681116811 bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern;
......@@ -16865,7 +16865,7 @@ no_mem_slot:
1686516865}
1686616866
1686716867// This function is called when a comptime value becomes accessible at runtime.
16868static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *val) {
16868static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *val) {
1686916869 ir_assert(value_is_comptime(val), source_instr);
1687016870 if (val->special == ConstValSpecialUndef)
1687116871 return;
......@@ -16921,17 +16921,17 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1692116921 casted_ptr->value.type = struct_ptr_type;
1692216922 }
1692316923 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);
1692516925 if (!ptr_val)
1692616926 return ira->codegen->invalid_instruction;
1692716927 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,
1692916929 source_instr->source_node);
1693016930 struct_val->special = ConstValSpecialStatic;
1693116931 struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields,
1693216932 old_field_count, new_field_count);
1693316933
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];
1693516935 field_val->special = ConstValSpecialUndef;
1693616936 field_val->type = field->type_entry;
1693716937 field_val->parent.id = ConstParentIdStruct;
......@@ -16972,7 +16972,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1697216972 ptr->value.data.x_ptr.mut == ConstPtrMutInfer)
1697316973 {
1697416974 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);
1697616976 if (dest_val == nullptr)
1697716977 return ira->codegen->invalid_instruction;
1697816978 if (dest_val->special != ConstValSpecialRuntime) {
......@@ -16997,7 +16997,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source
1699716997 } else {
1699816998 ir_add_error(ira, source_instr,
1699916999 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);
1700117001 dest_val->type = ira->codegen->builtin_types.entry_invalid;
1700217002
1700317003 return ira->codegen->invalid_instruction;
......@@ -17097,7 +17097,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1709717097
1709817098 size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0;
1709917099 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;
1710117101 if (arg_tuple_value->type->id == ZigTypeIdArgTuple) {
1710217102 call_param_count -= 1;
1710317103 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
1720717207 }
1720817208
1720917209 bool cacheable = fn_eval_cacheable(exec_scope, return_type);
17210 ConstExprValue *result = nullptr;
17210 ZigValue *result = nullptr;
1721117211 if (cacheable) {
1721217212 auto entry = ira->codegen->memoized_fn_eval_table.maybe_get(exec_scope);
1721317213 if (entry)
......@@ -17392,7 +17392,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
1739217392 first_var_arg = inst_fn_type_id.param_count;
1739317393 }
1739417394
17395 ConstExprValue *var_args_val = create_const_arg_tuple(ira->codegen,
17395 ZigValue *var_args_val = create_const_arg_tuple(ira->codegen,
1739617396 first_var_arg, inst_fn_type_id.param_count);
1739717397 ZigVar *var = add_variable(ira->codegen, param_decl_node,
1739817398 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
1740017400 }
1740117401
1740217402 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,
1740417404 fn_proto_node->data.fn_proto.align_expr, get_align_amt_type(ira->codegen),
1740517405 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota,
1740617406 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
1771917719// out_val->type must be the type to read the pointer as
1772017720// if the type is different than the actual type then it does a comptime byte reinterpretation
1772117721static 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)
1772317723{
1772417724 Error err;
1772517725 assert(out_val->type != nullptr);
1772617726
17727 ConstExprValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val);
17727 ZigValue *pointee = const_ptr_pointee_unchecked(codegen, ptr_val);
1772817728 src_assert(pointee->type != nullptr, source_node);
1772917729
1773017730 if ((err = type_resolve(codegen, pointee->type, ResolveStatusSizeKnown)))
......@@ -17765,7 +17765,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
1776517765 return ErrorSemanticAnalyzeFail;
1776617766 }
1776717767 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;
1776917769 assert(array_val->type->id == ZigTypeIdArray);
1777017770 if (array_val->data.x_array.special != ConstArraySpecialNone)
1777117771 zig_panic("TODO");
......@@ -17782,7 +17782,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
1778217782 Buf buf = BUF_INIT;
1778317783 buf_resize(&buf, elem_count * elem_size);
1778417784 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];
1778617786 buf_write_value_bytes(codegen, (uint8_t*)buf_ptr(&buf) + (i * elem_size), elem_val);
1778717787 }
1778817788 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
1781817818}
1781917819
1782017820static 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)
1782217822{
1782317823 bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat);
1782417824
......@@ -17872,20 +17872,20 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins
1787217872 ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type;
1787317873
1787417874 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);
1787617876 if (!operand_val)
1787717877 return ira->codegen->invalid_instruction;
1787817878
1787917879 IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type);
17880 ConstExprValue *out_val = &result_instruction->value;
17880 ZigValue *out_val = &result_instruction->value;
1788117881 if (expr_type->id == ZigTypeIdVector) {
1788217882 expand_undef_array(ira->codegen, operand_val);
1788317883 out_val->special = ConstValSpecialUndef;
1788417884 expand_undef_array(ira->codegen, out_val);
1788517885 size_t len = expr_type->data.vector.len;
1788617886 for (size_t i = 0; i < len; i += 1) {
17887 ConstExprValue *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];
17887 ZigValue *scalar_operand_val = &operand_val->data.x_array.data.s_none.elements[i];
17888 ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i];
1788917889 assert(scalar_operand_val->type == scalar_type);
1789017890 assert(scalar_out_val->type == scalar_type);
1789117891 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
1792317923
1792417924 if (expr_type->id == ZigTypeIdInt) {
1792517925 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);
1792717927 if (target_const_val == nullptr)
1792817928 return ira->codegen->invalid_instruction;
1792917929
......@@ -18361,7 +18361,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1836118361 if (type_is_invalid(array_ptr->value.type))
1836218362 return ira->codegen->invalid_instruction;
1836318363
18364 ConstExprValue *orig_array_ptr_val = &array_ptr->value;
18364 ZigValue *orig_array_ptr_val = &array_ptr->value;
1836518365
1836618366 IrInstruction *elem_index = elem_ptr_instruction->elem_index->child;
1836718367 if (type_is_invalid(elem_index->value.type))
......@@ -18428,10 +18428,10 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1842818428 return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index]->type_entry,
1842918429 elem_ptr_instruction->ptr_len);
1843018430 } 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);
1843218432 if (!ptr_val)
1843318433 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);
1843518435 if (args_val == nullptr)
1843618436 return ira->codegen->invalid_instruction;
1843718437 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
1854418544 (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar ||
1854518545 array_type->id == ZigTypeIdArray))
1854618546 {
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,
1854818548 elem_ptr_instruction->base.source_node);
1854918549 if (array_ptr_val == nullptr)
1855018550 return ira->codegen->invalid_instruction;
......@@ -18557,7 +18557,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1855718557 array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len);
1855818558 array_ptr_val->special = ConstValSpecialStatic;
1855918559 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];
1856118561 elem_val->special = ConstValSpecialUndef;
1856218562 elem_val->type = array_type->data.array.child_type;
1856318563 elem_val->parent.id = ConstParentIdArray;
......@@ -18576,14 +18576,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1857618576 return ira->codegen->invalid_instruction;
1857718577 }
1857818578
18579 ConstExprValue *array_init_val = create_const_vals(1);
18579 ZigValue *array_init_val = create_const_vals(1);
1858018580 array_init_val->special = ConstValSpecialStatic;
1858118581 array_init_val->type = actual_array_type;
1858218582 array_init_val->data.x_array.special = ConstArraySpecialNone;
1858318583 array_init_val->data.x_array.data.s_none.elements = create_const_vals(actual_array_type->data.array.len);
1858418584 array_init_val->special = ConstValSpecialStatic;
1858518585 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];
1858718587 elem_val->special = ConstValSpecialUndef;
1858818588 elem_val->type = actual_array_type->data.array.child_type;
1858918589 elem_val->parent.id = ConstParentIdArray;
......@@ -18608,7 +18608,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1860818608 {
1860918609 if (array_type->id == ZigTypeIdPointer) {
1861018610 IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type);
18611 ConstExprValue *out_val = &result->value;
18611 ZigValue *out_val = &result->value;
1861218612 out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut;
1861318613 size_t new_index;
1861418614 size_t mem_size;
......@@ -18619,7 +18619,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1861918619 zig_unreachable();
1862018620 case ConstPtrSpecialRef:
1862118621 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;
1862318623 new_index = index;
1862418624 ZigType *array_type = array_val->type;
1862518625 mem_size = array_type->data.array.len;
......@@ -18682,7 +18682,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1868218682 }
1868318683 return result;
1868418684 } 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];
1868618686 ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base);
1868718687 if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) {
1868818688 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
1869118691 result->value.type = return_type;
1869218692 return result;
1869318693 }
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];
1869518695 IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type);
18696 ConstExprValue *out_val = &result->value;
18696 ZigValue *out_val = &result->value;
1869718697 ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry;
1869818698 uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint);
1869918699 uint64_t full_slice_len = slice_len +
......@@ -18757,7 +18757,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1875718757 } else {
1875818758 result = ir_const(ira, &elem_ptr_instruction->base, return_type);
1875918759 }
18760 ConstExprValue *out_val = &result->value;
18760 ZigValue *out_val = &result->value;
1876118761 out_val->data.x_ptr.special = ConstPtrSpecialBaseArray;
1876218762 out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut;
1876318763 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
1891518915 (uint32_t)host_int_bytes_for_result_type, false);
1891618916 }
1891718917 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);
1891918919 if (!ptr_val)
1892018920 return ira->codegen->invalid_instruction;
1892118921
1892218922 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);
1892418924 if (struct_val == nullptr)
1892518925 return ira->codegen->invalid_instruction;
1892618926 if (type_is_invalid(struct_val->type))
......@@ -18929,7 +18929,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1892918929 struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count);
1893018930 struct_val->special = ConstValSpecialStatic;
1893118931 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];
1893318933 field_val->special = ConstValSpecialUndef;
1893418934 field_val->type = resolve_struct_field_type(ira->codegen,
1893518935 struct_type->data.structure.fields[i]);
......@@ -18947,7 +18947,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction
1894718947 } else {
1894818948 result = ir_const(ira, source_instr, ptr_type);
1894918949 }
18950 ConstExprValue *const_val = &result->value;
18950 ZigValue *const_val = &result->value;
1895118951 const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct;
1895218952 const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
1895318953 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_
1904419044 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
1904519045 is_const, is_volatile, PtrLenSingle, 0, 0, 0, false);
1904619046 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);
1904819048 if (!ptr_val)
1904919049 return ira->codegen->invalid_instruction;
1905019050
1905119051 if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar &&
1905219052 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);
1905419054 if (union_val == nullptr)
1905519055 return ira->codegen->invalid_instruction;
1905619056 if (type_is_invalid(union_val->type))
1905719057 return ira->codegen->invalid_instruction;
1905819058
1905919059 if (initializing) {
19060 ConstExprValue *payload_val = create_const_vals(1);
19060 ZigValue *payload_val = create_const_vals(1);
1906119061 payload_val->special = ConstValSpecialUndef;
1906219062 payload_val->type = field_type;
1906319063 payload_val->parent.id = ConstParentIdUnion;
......@@ -19079,7 +19079,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1907919079 }
1908019080 }
1908119081
19082 ConstExprValue *payload_val = union_val->data.x_union.payload;
19082 ZigValue *payload_val = union_val->data.x_union.payload;
1908319083
1908419084 IrInstruction *result;
1908519085 if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) {
......@@ -19090,7 +19090,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1909019090 } else {
1909119091 result = ir_const(ira, source_instr, ptr_type);
1909219092 }
19093 ConstExprValue *const_val = &result->value;
19093 ZigValue *const_val = &result->value;
1909419094 const_val->data.x_ptr.special = ConstPtrSpecialRef;
1909519095 const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut;
1909619096 const_val->data.x_ptr.data.ref.pointee = payload_val;
......@@ -19236,7 +19236,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1923619236 }
1923719237 } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) {
1923819238 if (buf_eql_str(field_name, "len")) {
19239 ConstExprValue *len_val = create_const_vals(1);
19239 ZigValue *len_val = create_const_vals(1);
1924019240 if (container_type->id == ZigTypeIdPointer) {
1924119241 init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len);
1924219242 } else {
......@@ -19255,17 +19255,17 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1925519255 return ira->codegen->invalid_instruction;
1925619256 }
1925719257 } 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);
1925919259 if (!container_ptr_val)
1926019260 return ira->codegen->invalid_instruction;
1926119261
1926219262 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);
1926419264 if (child_val == nullptr)
1926519265 return ira->codegen->invalid_instruction;
1926619266
1926719267 if (buf_eql_str(field_name, "len")) {
19268 ConstExprValue *len_val = create_const_vals(1);
19268 ZigValue *len_val = create_const_vals(1);
1926919269 size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index;
1927019270 init_const_usize(ira->codegen, len_val, len);
1927119271
......@@ -19281,12 +19281,12 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc
1928119281 return ira->codegen->invalid_instruction;
1928219282 }
1928319283 } 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);
1928519285 if (!container_ptr_val)
1928619286 return ira->codegen->invalid_instruction;
1928719287
1928819288 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);
1929019290 if (child_val == nullptr)
1929119291 return ira->codegen->invalid_instruction;
1929219292 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
1938219382 }
1938319383 err_set_type = child_type;
1938419384 }
19385 ConstExprValue *const_val = create_const_vals(1);
19385 ZigValue *const_val = create_const_vals(1);
1938619386 const_val->special = ConstValSpecialStatic;
1938719387 const_val->type = err_set_type;
1938819388 const_val->data.x_err_set = err_entry;
......@@ -19850,7 +19850,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1985019850 if (type_is_invalid(child_type))
1985119851 return ira->codegen->invalid_instruction;
1985219852
19853 ConstExprValue *sentinel_val;
19853 ZigValue *sentinel_val;
1985419854 if (array_type_instruction->sentinel != nullptr) {
1985519855 IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child;
1985619856 if (type_is_invalid(uncasted_sentinel->value.type))
......@@ -19928,7 +19928,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so
1992819928
1992919929 if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) {
1993019930 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);
1993219932 if (c_ptr_val == nullptr)
1993319933 return ira->codegen->invalid_instruction;
1993419934 if (c_ptr_val->special == ConstValSpecialUndef)
......@@ -19945,7 +19945,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so
1994519945 return result;
1994619946 } else if (type_entry->id == ZigTypeIdOptional) {
1994719947 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);
1994919949 if (maybe_val == nullptr)
1995019950 return ira->codegen->invalid_instruction;
1995119951 if (maybe_val->special == ConstValSpecialUndef)
......@@ -19983,7 +19983,7 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) {
1998319983 return g->builtin_types.entry_invalid;
1998419984
1998519985 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);
1998719987 return pointee->type;
1998819988}
1998919989
......@@ -19996,11 +19996,11 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
1999619996
1999719997 if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) {
1999819998 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);
2000020000 if (!val)
2000120001 return ira->codegen->invalid_instruction;
2000220002 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);
2000420004 if (c_ptr_val == nullptr)
2000520005 return ira->codegen->invalid_instruction;
2000620006 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
2003420034 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry);
2003520035
2003620036 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);
2003820038 if (!ptr_val)
2003920039 return ira->codegen->invalid_instruction;
2004020040 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);
2004220042 if (optional_val == nullptr)
2004320043 return ira->codegen->invalid_instruction;
2004420044
......@@ -20048,7 +20048,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2004820048 return ira->codegen->invalid_instruction;
2004920049 case OnePossibleValueNo:
2005020050 if (!same_comptime_repr) {
20051 ConstExprValue *payload_val = create_const_vals(1);
20051 ZigValue *payload_val = create_const_vals(1);
2005220052 payload_val->type = child_type;
2005320053 payload_val->special = ConstValSpecialUndef;
2005420054 payload_val->parent.id = ConstParentIdOptionalPayload;
......@@ -20059,7 +20059,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2005920059 }
2006020060 break;
2006120061 case OnePossibleValueYes: {
20062 ConstExprValue *pointee = create_const_vals(1);
20062 ZigValue *pointee = create_const_vals(1);
2006320063 pointee->special = ConstValSpecialStatic;
2006420064 pointee->type = child_type;
2006520065 pointee->parent.id = ConstParentIdOptionalPayload;
......@@ -20084,7 +20084,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr
2008420084 } else {
2008520085 result = ir_const(ira, source_instr, result_type);
2008620086 }
20087 ConstExprValue *result_val = &result->value;
20087 ZigValue *result_val = &result->value;
2008820088 result_val->data.x_ptr.special = ConstPtrSpecialRef;
2008920089 result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut;
2009020090 switch (type_has_one_possible_value(ira->codegen, child_type)) {
......@@ -20137,7 +20137,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt
2013720137 return ir_const_unsigned(ira, &instruction->base, 0);
2013820138
2013920139 if (instr_is_comptime(op)) {
20140 ConstExprValue *val = ir_resolve_const(ira, op, UndefOk);
20140 ZigValue *val = ir_resolve_const(ira, op, UndefOk);
2014120141 if (val == nullptr)
2014220142 return ira->codegen->invalid_instruction;
2014320143 if (val->special == ConstValSpecialUndef)
......@@ -20166,7 +20166,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl
2016620166 return ir_const_unsigned(ira, &instruction->base, 0);
2016720167
2016820168 if (instr_is_comptime(op)) {
20169 ConstExprValue *val = ir_resolve_const(ira, op, UndefOk);
20169 ZigValue *val = ir_resolve_const(ira, op, UndefOk);
2017020170 if (val == nullptr)
2017120171 return ira->codegen->invalid_instruction;
2017220172 if (val->special == ConstValSpecialUndef)
......@@ -20195,7 +20195,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc
2019520195 return ir_const_unsigned(ira, &instruction->base, 0);
2019620196
2019720197 if (instr_is_comptime(op)) {
20198 ConstExprValue *val = ir_resolve_const(ira, op, UndefOk);
20198 ZigValue *val = ir_resolve_const(ira, op, UndefOk);
2019920199 if (val == nullptr)
2020020200 return ira->codegen->invalid_instruction;
2020120201 if (val->special == ConstValSpecialUndef)
......@@ -20242,7 +20242,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
2024220242 assert(tag_type->id == ZigTypeIdEnum);
2024320243
2024420244 if (instr_is_comptime(value)) {
20245 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
20245 ZigValue *val = ir_resolve_const(ira, value, UndefBad);
2024620246 if (!val)
2024720247 return ira->codegen->invalid_instruction;
2024820248
......@@ -20280,7 +20280,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2028020280 return ira->codegen->invalid_instruction;
2028120281
2028220282 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);
2028420284 if (!target_val)
2028520285 return ir_unreach_error(ira);
2028620286
......@@ -20301,7 +20301,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira,
2030120301 if (type_is_invalid(casted_case_value->value.type))
2030220302 return ir_unreach_error(ira);
2030320303
20304 ConstExprValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad);
20304 ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad);
2030520305 if (!case_val)
2030620306 return ir_unreach_error(ira);
2030720307
......@@ -20388,7 +20388,7 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira,
2038820388 }
2038920389
2039020390 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
20391 ConstExprValue *pointee_val = nullptr;
20391 ZigValue *pointee_val = nullptr;
2039220392 if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) {
2039320393 pointee_val = const_ptr_pointee(ira, ira->codegen, &target_value_ptr->value, target_value_ptr->source_node);
2039420394 if (pointee_val == nullptr)
......@@ -20521,7 +20521,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2052120521 if (type_is_invalid(first_casted_prong_value->value.type))
2052220522 return ira->codegen->invalid_instruction;
2052320523
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);
2052520525 if (first_prong_val == nullptr)
2052620526 return ira->codegen->invalid_instruction;
2052720527
......@@ -20537,7 +20537,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2053720537 if (type_is_invalid(this_casted_prong_value->value.type))
2053820538 return ira->codegen->invalid_instruction;
2053920539
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);
2054120541 if (this_prong == nullptr)
2054220542 return ira->codegen->invalid_instruction;
2054320543
......@@ -20560,18 +20560,18 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru
2056020560 }
2056120561
2056220562 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);
2056420564 if (!target_value_ptr)
2056520565 return ira->codegen->invalid_instruction;
2056620566
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);
2056820568 if (pointee_val == nullptr)
2056920569 return ira->codegen->invalid_instruction;
2057020570
2057120571 IrInstruction *result = ir_const(ira, &instruction->base,
2057220572 get_pointer_to_type(ira->codegen, first_field->type_entry,
2057320573 target_val_ptr->type->data.pointer.is_const));
20574 ConstExprValue *out_val = &result->value;
20574 ZigValue *out_val = &result->value;
2057520575 out_val->data.x_ptr.special = ConstPtrSpecialRef;
2057620576 out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut;
2057720577 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
2116121161 true, false, PtrLenUnknown, 0, 0, 0, false);
2116221162 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
2116321163 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);
2116521165 if (val == nullptr)
2116621166 return ira->codegen->invalid_instruction;
2116721167 ErrorTableEntry *err = casted_value->value.data.x_err_set;
2116821168 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;
2117021170 err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true);
2117121171 }
2117221172 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
......@@ -21195,7 +21195,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns
2119521195 if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown)))
2119621196 return ira->codegen->invalid_instruction;
2119721197 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;
2119921199 IrInstruction *result = ir_const(ira, &instruction->base, nullptr);
2120021200 init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true);
2120121201 return result;
......@@ -21272,7 +21272,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2127221272 parent_ptr_align, 0, 0, false);
2127321273
2127421274 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);
2127621276 if (!field_ptr_val)
2127721277 return ira->codegen->invalid_instruction;
2127821278
......@@ -21291,7 +21291,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
2129121291 }
2129221292
2129321293 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
21294 ConstExprValue *out_val = &result->value;
21294 ZigValue *out_val = &result->value;
2129521295 out_val->data.x_ptr.special = ConstPtrSpecialRef;
2129621296 out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val;
2129721297 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
2139021390
2139121391static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) {
2139221392 Error err;
21393 ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
21393 ZigValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
2139421394 assert(type_info_var->type->id == ZigTypeIdMetaType);
2139521395 ZigType *type_info_type = type_info_var->data.x_type;
2139621396 assert(type_info_type->id == ZigTypeIdUnion);
......@@ -21423,7 +21423,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig
2142321423 return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value);
2142421424}
2142521425
21426static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *out_val,
21426static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *out_val,
2142721427 ScopeDecls *decls_scope)
2142821428{
2142921429 Error err;
......@@ -21473,7 +21473,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2147321473 }
2147421474 }
2147521475
21476 ConstExprValue *declaration_array = create_const_vals(1);
21476 ZigValue *declaration_array = create_const_vals(1);
2147721477 declaration_array->special = ConstValSpecialStatic;
2147821478 declaration_array->type = get_array_type(ira->codegen, type_info_declaration_type, declaration_count, nullptr);
2147921479 declaration_array->data.x_array.special = ConstArraySpecialNone;
......@@ -21494,13 +21494,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2149421494 continue;
2149521495 }
2149621496
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];
2149821498
2149921499 declaration_val->special = ConstValSpecialStatic;
2150021500 declaration_val->type = type_info_declaration_type;
2150121501
21502 ConstExprValue **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;
21502 ZigValue **inner_fields = alloc_const_vals_ptrs(3);
21503 ZigValue *name = create_const_str_lit(ira->codegen, curr_entry->key)->data.x_ptr.data.ref.pointee;
2150421504 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true);
2150521505 inner_fields[1]->special = ConstValSpecialStatic;
2150621506 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
2152821528 // 1: Data.Var: type
2152921529 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1);
2153021530
21531 ConstExprValue *payload = create_const_vals(1);
21531 ZigValue *payload = create_const_vals(1);
2153221532 payload->special = ConstValSpecialStatic;
2153321533 payload->type = ira->codegen->builtin_types.entry_type;
2153421534 payload->data.x_type = var->const_value->type;
......@@ -21553,13 +21553,13 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2155321553
2155421554 AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto;
2155521555
21556 ConstExprValue *fn_decl_val = create_const_vals(1);
21556 ZigValue *fn_decl_val = create_const_vals(1);
2155721557 fn_decl_val->special = ConstValSpecialStatic;
2155821558 fn_decl_val->type = type_info_fn_decl_type;
2155921559 fn_decl_val->parent.id = ConstParentIdUnion;
2156021560 fn_decl_val->parent.data.p_union.union_val = inner_fields[2];
2156121561
21562 ConstExprValue **fn_decl_fields = alloc_const_vals_ptrs(9);
21562 ZigValue **fn_decl_fields = alloc_const_vals_ptrs(9);
2156321563 fn_decl_val->data.x_struct.fields = fn_decl_fields;
2156421564
2156521565 // fn_type: type
......@@ -21603,7 +21603,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2160321603 fn_decl_fields[6]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr));
2160421604 if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) {
2160521605 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;
2160721607 init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0,
2160821608 buf_len(fn_node->lib_name), true);
2160921609 } else {
......@@ -21617,7 +21617,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2161721617 // arg_names: [][] const u8
2161821618 ensure_field_index(fn_decl_val->type, "arg_names", 8);
2161921619 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);
2162121621 fn_arg_name_array->special = ConstValSpecialStatic;
2162221622 fn_arg_name_array->type = get_array_type(ira->codegen,
2162321623 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
2162821628
2162921629 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
2163021630 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];
21632 ConstExprValue *arg_name = create_const_str_lit(ira->codegen,
21631 ZigValue *fn_arg_name_val = &fn_arg_name_array->data.x_array.data.s_none.elements[fn_arg_index];
21632 ZigValue *arg_name = create_const_str_lit(ira->codegen,
2163321633 buf_create_from_str(arg_var->name))->data.x_ptr.data.ref.pointee;
2163421634 init_const_slice(ira->codegen, fn_arg_name_val, arg_name, 0, strlen(arg_var->name), true);
2163521635 fn_arg_name_val->parent.id = ConstParentIdArray;
......@@ -21649,7 +21649,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
2164921649 // This is a type.
2165021650 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0);
2165121651
21652 ConstExprValue *payload = create_const_vals(1);
21652 ZigValue *payload = create_const_vals(1);
2165321653 payload->special = ConstValSpecialStatic;
2165421654 payload->type = ira->codegen->builtin_types.entry_type;
2165521655 payload->data.x_type = type_entry;
......@@ -21695,7 +21695,7 @@ static PtrLen size_enum_index_to_ptr_len(BuiltinPtrSize size_enum_index) {
2169521695 zig_unreachable();
2169621696}
2169721697
21698static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {
21698static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {
2169921699 Error err;
2170021700 ZigType *attrs_type;
2170121701 BuiltinPtrSize size_enum_index;
......@@ -21715,11 +21715,11 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty
2171521715 ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
2171621716 assertNoError(type_resolve(ira->codegen, type_info_pointer_type, ResolveStatusSizeKnown));
2171721717
21718 ConstExprValue *result = create_const_vals(1);
21718 ZigValue *result = create_const_vals(1);
2171921719 result->special = ConstValSpecialStatic;
2172021720 result->type = type_info_pointer_type;
2172121721
21722 ConstExprValue **fields = alloc_const_vals_ptrs(7);
21722 ZigValue **fields = alloc_const_vals_ptrs(7);
2172321723 result->data.x_struct.fields = fields;
2172421724
2172521725 // size: Size
......@@ -21769,17 +21769,17 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty
2176921769 return result;
2177021770};
2177121771
21772static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field,
21772static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEnumField *enum_field,
2177321773 ZigType *type_info_enum_field_type)
2177421774{
2177521775 enum_field_val->special = ConstValSpecialStatic;
2177621776 enum_field_val->type = type_info_enum_field_type;
2177721777
21778 ConstExprValue **inner_fields = alloc_const_vals_ptrs(2);
21778 ZigValue **inner_fields = alloc_const_vals_ptrs(2);
2177921779 inner_fields[1]->special = ConstValSpecialStatic;
2178021780 inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
2178121781
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;
2178321783 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true);
2178421784
2178521785 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,
2178821788}
2178921789
2179021790static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry,
21791 ConstExprValue **out)
21791 ZigValue **out)
2179221792{
2179321793 Error err;
2179421794 assert(type_entry != nullptr);
......@@ -21803,7 +21803,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2180321803 return ErrorNone;
2180421804 }
2180521805
21806 ConstExprValue *result = nullptr;
21806 ZigValue *result = nullptr;
2180721807 switch (type_entry->id) {
2180821808 case ZigTypeIdInvalid:
2180921809 zig_unreachable();
......@@ -21826,7 +21826,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2182621826 result->special = ConstValSpecialStatic;
2182721827 result->type = ir_type_info_get_type(ira, "Int", nullptr);
2182821828
21829 ConstExprValue **fields = alloc_const_vals_ptrs(2);
21829 ZigValue **fields = alloc_const_vals_ptrs(2);
2183021830 result->data.x_struct.fields = fields;
2183121831
2183221832 // is_signed: bool
......@@ -21848,7 +21848,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2184821848 result->special = ConstValSpecialStatic;
2184921849 result->type = ir_type_info_get_type(ira, "Float", nullptr);
2185021850
21851 ConstExprValue **fields = alloc_const_vals_ptrs(1);
21851 ZigValue **fields = alloc_const_vals_ptrs(1);
2185221852 result->data.x_struct.fields = fields;
2185321853
2185421854 // bits: u8
......@@ -21872,7 +21872,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2187221872 result->special = ConstValSpecialStatic;
2187321873 result->type = ir_type_info_get_type(ira, "Array", nullptr);
2187421874
21875 ConstExprValue **fields = alloc_const_vals_ptrs(3);
21875 ZigValue **fields = alloc_const_vals_ptrs(3);
2187621876 result->data.x_struct.fields = fields;
2187721877
2187821878 // len: usize
......@@ -21896,7 +21896,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2189621896 result->special = ConstValSpecialStatic;
2189721897 result->type = ir_type_info_get_type(ira, "Vector", nullptr);
2189821898
21899 ConstExprValue **fields = alloc_const_vals_ptrs(2);
21899 ZigValue **fields = alloc_const_vals_ptrs(2);
2190021900 result->data.x_struct.fields = fields;
2190121901
2190221902 // len: usize
......@@ -21918,7 +21918,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2191821918 result->special = ConstValSpecialStatic;
2191921919 result->type = ir_type_info_get_type(ira, "Optional", nullptr);
2192021920
21921 ConstExprValue **fields = alloc_const_vals_ptrs(1);
21921 ZigValue **fields = alloc_const_vals_ptrs(1);
2192221922 result->data.x_struct.fields = fields;
2192321923
2192421924 // child: type
......@@ -21934,7 +21934,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2193421934 result->special = ConstValSpecialStatic;
2193521935 result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr);
2193621936
21937 ConstExprValue **fields = alloc_const_vals_ptrs(1);
21937 ZigValue **fields = alloc_const_vals_ptrs(1);
2193821938 result->data.x_struct.fields = fields;
2193921939
2194021940 // child: ?type
......@@ -21951,7 +21951,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2195121951 result->special = ConstValSpecialStatic;
2195221952 result->type = ir_type_info_get_type(ira, "Enum", nullptr);
2195321953
21954 ConstExprValue **fields = alloc_const_vals_ptrs(4);
21954 ZigValue **fields = alloc_const_vals_ptrs(4);
2195521955 result->data.x_struct.fields = fields;
2195621956
2195721957 // layout: ContainerLayout
......@@ -21973,7 +21973,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2197321973 }
2197421974 uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;
2197521975
21976 ConstExprValue *enum_field_array = create_const_vals(1);
21976 ZigValue *enum_field_array = create_const_vals(1);
2197721977 enum_field_array->special = ConstValSpecialStatic;
2197821978 enum_field_array->type = get_array_type(ira->codegen, type_info_enum_field_type, enum_field_count, nullptr);
2197921979 enum_field_array->data.x_array.special = ConstArraySpecialNone;
......@@ -21984,7 +21984,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2198421984 for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++)
2198521985 {
2198621986 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];
2198821988 make_enum_field_val(ira, enum_field_val, enum_field, type_info_enum_field_type);
2198921989 enum_field_val->parent.id = ConstParentIdArray;
2199021990 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
2201722017 if ((err = type_resolve(ira->codegen, type_info_error_type, ResolveStatusSizeKnown))) {
2201822018 zig_unreachable();
2201922019 }
22020 ConstExprValue *slice_val = create_const_vals(1);
22020 ZigValue *slice_val = create_const_vals(1);
2202122021 result->data.x_optional = slice_val;
2202222022
2202322023 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);
2202522025 error_array->special = ConstValSpecialStatic;
2202622026 error_array->type = get_array_type(ira->codegen, type_info_error_type, error_count, nullptr);
2202722027 error_array->data.x_array.special = ConstArraySpecialNone;
......@@ -22030,16 +22030,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2203022030 init_const_slice(ira->codegen, slice_val, error_array, 0, error_count, false);
2203122031 for (uint32_t error_index = 0; error_index < error_count; error_index++) {
2203222032 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];
2203422034
2203522035 error_val->special = ConstValSpecialStatic;
2203622036 error_val->type = type_info_error_type;
2203722037
22038 ConstExprValue **inner_fields = alloc_const_vals_ptrs(2);
22038 ZigValue **inner_fields = alloc_const_vals_ptrs(2);
2203922039 inner_fields[1]->special = ConstValSpecialStatic;
2204022040 inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
2204122041
22042 ConstExprValue *name = nullptr;
22042 ZigValue *name = nullptr;
2204322043 if (error->cached_error_name_val != nullptr)
2204422044 name = error->cached_error_name_val;
2204522045 if (name == nullptr)
......@@ -22061,7 +22061,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2206122061 result->special = ConstValSpecialStatic;
2206222062 result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr);
2206322063
22064 ConstExprValue **fields = alloc_const_vals_ptrs(2);
22064 ZigValue **fields = alloc_const_vals_ptrs(2);
2206522065 result->data.x_struct.fields = fields;
2206622066
2206722067 // error_set: type
......@@ -22084,7 +22084,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2208422084 result->special = ConstValSpecialStatic;
2208522085 result->type = ir_type_info_get_type(ira, "Union", nullptr);
2208622086
22087 ConstExprValue **fields = alloc_const_vals_ptrs(4);
22087 ZigValue **fields = alloc_const_vals_ptrs(4);
2208822088 result->data.x_struct.fields = fields;
2208922089
2209022090 // layout: ContainerLayout
......@@ -22101,7 +22101,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2210122101 if (union_decl_node->data.container_decl.auto_enum ||
2210222102 union_decl_node->data.container_decl.init_arg_expr != nullptr)
2210322103 {
22104 ConstExprValue *tag_type = create_const_vals(1);
22104 ZigValue *tag_type = create_const_vals(1);
2210522105 tag_type->special = ConstValSpecialStatic;
2210622106 tag_type->type = ira->codegen->builtin_types.entry_type;
2210722107 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
2211722117 zig_unreachable();
2211822118 uint32_t union_field_count = type_entry->data.unionation.src_field_count;
2211922119
22120 ConstExprValue *union_field_array = create_const_vals(1);
22120 ZigValue *union_field_array = create_const_vals(1);
2212122121 union_field_array->special = ConstValSpecialStatic;
2212222122 union_field_array->type = get_array_type(ira->codegen, type_info_union_field_type, union_field_count, nullptr);
2212322123 union_field_array->data.x_array.special = ConstArraySpecialNone;
......@@ -22129,12 +22129,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2212922129
2213022130 for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {
2213122131 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];
2213322133
2213422134 union_field_val->special = ConstValSpecialStatic;
2213522135 union_field_val->type = type_info_union_field_type;
2213622136
22137 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
22137 ZigValue **inner_fields = alloc_const_vals_ptrs(3);
2213822138 inner_fields[1]->special = ConstValSpecialStatic;
2213922139 inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type);
2214022140
......@@ -22149,7 +22149,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2214922149 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
2215022150 inner_fields[2]->data.x_type = union_field->type_entry;
2215122151
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;
2215322153 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true);
2215422154
2215522155 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
2218022180 result->special = ConstValSpecialStatic;
2218122181 result->type = ir_type_info_get_type(ira, "Struct", nullptr);
2218222182
22183 ConstExprValue **fields = alloc_const_vals_ptrs(3);
22183 ZigValue **fields = alloc_const_vals_ptrs(3);
2218422184 result->data.x_struct.fields = fields;
2218522185
2218622186 // layout: ContainerLayout
......@@ -22197,7 +22197,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2219722197 }
2219822198 uint32_t struct_field_count = type_entry->data.structure.src_field_count;
2219922199
22200 ConstExprValue *struct_field_array = create_const_vals(1);
22200 ZigValue *struct_field_array = create_const_vals(1);
2220122201 struct_field_array->special = ConstValSpecialStatic;
2220222202 struct_field_array->type = get_array_type(ira->codegen, type_info_struct_field_type, struct_field_count, nullptr);
2220322203 struct_field_array->data.x_array.special = ConstArraySpecialNone;
......@@ -22207,12 +22207,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2220722207
2220822208 for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) {
2220922209 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];
2221122211
2221222212 struct_field_val->special = ConstValSpecialStatic;
2221322213 struct_field_val->type = type_info_struct_field_type;
2221422214
22215 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
22215 ZigValue **inner_fields = alloc_const_vals_ptrs(3);
2221622216 inner_fields[1]->special = ConstValSpecialStatic;
2221722217 inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int);
2221822218
......@@ -22235,7 +22235,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2223522235 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
2223622236 inner_fields[2]->data.x_type = struct_field->type_entry;
2223722237
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;
2223922239 init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true);
2224022240
2224122241 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
2225922259 result->special = ConstValSpecialStatic;
2226022260 result->type = ir_type_info_get_type(ira, "Fn", nullptr);
2226122261
22262 ConstExprValue **fields = alloc_const_vals_ptrs(5);
22262 ZigValue **fields = alloc_const_vals_ptrs(5);
2226322263 result->data.x_struct.fields = fields;
2226422264
2226522265 // calling_convention: TypeInfo.CallingConvention
......@@ -22286,7 +22286,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2228622286 if (type_entry->data.fn.fn_type_id.return_type == nullptr)
2228722287 fields[3]->data.x_optional = nullptr;
2228822288 else {
22289 ConstExprValue *return_type = create_const_vals(1);
22289 ZigValue *return_type = create_const_vals(1);
2229022290 return_type->special = ConstValSpecialStatic;
2229122291 return_type->type = ira->codegen->builtin_types.entry_type;
2229222292 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
2230022300 size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -
2230122301 (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);
2230222302
22303 ConstExprValue *fn_arg_array = create_const_vals(1);
22303 ZigValue *fn_arg_array = create_const_vals(1);
2230422304 fn_arg_array->special = ConstValSpecialStatic;
2230522305 fn_arg_array->type = get_array_type(ira->codegen, type_info_fn_arg_type, fn_arg_count, nullptr);
2230622306 fn_arg_array->data.x_array.special = ConstArraySpecialNone;
......@@ -22310,7 +22310,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
2231022310
2231122311 for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) {
2231222312 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];
2231422314
2231522315 fn_arg_val->special = ConstValSpecialStatic;
2231622316 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
2231822318 bool arg_is_generic = fn_param_info->type == nullptr;
2231922319 if (arg_is_generic) assert(is_generic);
2232022320
22321 ConstExprValue **inner_fields = alloc_const_vals_ptrs(3);
22321 ZigValue **inner_fields = alloc_const_vals_ptrs(3);
2232222322 inner_fields[0]->special = ConstValSpecialStatic;
2232322323 inner_fields[0]->type = ira->codegen->builtin_types.entry_bool;
2232422324 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
2233122331 if (arg_is_generic)
2233222332 inner_fields[2]->data.x_optional = nullptr;
2233322333 else {
22334 ConstExprValue *arg_type = create_const_vals(1);
22334 ZigValue *arg_type = create_const_vals(1);
2233522335 arg_type->special = ConstValSpecialStatic;
2233622336 arg_type->type = ira->codegen->builtin_types.entry_type;
2233722337 arg_type->data.x_type = fn_param_info->type;
......@@ -22376,12 +22376,12 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
2237622376
2237722377 ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr);
2237822378
22379 ConstExprValue *payload;
22379 ZigValue *payload;
2238022380 if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload)))
2238122381 return ira->codegen->invalid_instruction;
2238222382
2238322383 IrInstruction *result = ir_const(ira, &instruction->base, result_type);
22384 ConstExprValue *out_val = &result->value;
22384 ZigValue *out_val = &result->value;
2238522385 bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry));
2238622386 out_val->data.x_union.payload = payload;
2238722387
......@@ -22393,17 +22393,17 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
2239322393 return result;
2239422394}
2239522395
22396static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
22396static ZigValue *get_const_field(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index)
2239722397{
2239822398 ensure_field_index(struct_value->type, name, field_index);
2239922399 assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic);
2240022400 return struct_value->data.x_struct.fields[field_index];
2240122401}
2240222402
22403static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ConstExprValue *struct_value,
22404 const char *name, size_t field_index, ZigType *elem_type, ConstExprValue **result)
22403static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *struct_value,
22404 const char *name, size_t field_index, ZigType *elem_type, ZigValue **result)
2240522405{
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);
2240722407 IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type);
2240822408 IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst,
2240922409 get_optional_type(ira->codegen, elem_type));
......@@ -22414,28 +22414,28 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst
2241422414 return ErrorNone;
2241522415}
2241622416
22417static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
22417static bool get_const_field_bool(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index)
2241822418{
22419 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
22419 ZigValue *value = get_const_field(ira, struct_value, name, field_index);
2242022420 assert(value->type == ira->codegen->builtin_types.entry_bool);
2242122421 return value->data.x_bool;
2242222422}
2242322423
22424static BigInt *get_const_field_lit_int(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
22424static BigInt *get_const_field_lit_int(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index)
2242522425{
22426 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
22426 ZigValue *value = get_const_field(ira, struct_value, name, field_index);
2242722427 assert(value->type == ira->codegen->builtin_types.entry_num_lit_int);
2242822428 return &value->data.x_bigint;
2242922429}
2243022430
22431static ZigType *get_const_field_meta_type(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index)
22431static ZigType *get_const_field_meta_type(IrAnalyze *ira, ZigValue *struct_value, const char *name, size_t field_index)
2243222432{
22433 ConstExprValue *value = get_const_field(ira, struct_value, name, field_index);
22433 ZigValue *value = get_const_field(ira, struct_value, name, field_index);
2243422434 assert(value->type == ira->codegen->builtin_types.entry_type);
2243522435 return value->data.x_type;
2243622436}
2243722437
22438static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ConstExprValue *payload) {
22438static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ZigValue *payload) {
2243922439 Error err;
2244022440 switch (tagTypeId) {
2244122441 case ZigTypeIdInvalid:
......@@ -22474,12 +22474,12 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi
2247422474 ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
2247522475 assert(payload->special == ConstValSpecialStatic);
2247622476 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);
2247822478 assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type));
2247922479 BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag);
2248022480 PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index);
2248122481 ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 4);
22482 ConstExprValue *sentinel;
22482 ZigValue *sentinel;
2248322483 if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6,
2248422484 elem_type, &sentinel)))
2248522485 {
......@@ -22504,7 +22504,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi
2250422504 assert(payload->special == ConstValSpecialStatic);
2250522505 assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr));
2250622506 ZigType *elem_type = get_const_field_meta_type(ira, payload, "child", 1);
22507 ConstExprValue *sentinel;
22507 ZigValue *sentinel;
2250822508 if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2,
2250922509 elem_type, &sentinel)))
2251022510 {
......@@ -22556,7 +22556,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT
2255622556 if (type_is_invalid(casted_ir->value.type))
2255722557 return ira->codegen->invalid_instruction;
2255822558
22559 ConstExprValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad);
22559 ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad);
2256022560 if (!type_info_value)
2256122561 return ira->codegen->invalid_instruction;
2256222562 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,
2257422574 if (type_is_invalid(type_entry))
2257522575 return ira->codegen->invalid_instruction;
2257622576
22577 ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId");
22577 ZigValue *var_value = get_builtin_value(ira->codegen, "TypeId");
2257822578 assert(var_value->type->id == ZigTypeIdMetaType);
2257922579 ZigType *result_type = var_value->data.x_type;
2258022580
......@@ -22628,7 +22628,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct
2262822628
2262922629 // Execute the C import block like an inline function
2263022630 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,
2263222632 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,
2263322633 &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad);
2263422634 if (type_is_invalid(cimport_result->type))
......@@ -23043,7 +23043,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
2304323043 }
2304423044
2304523045 if (instr_is_comptime(target)) {
23046 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
23046 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
2304723047 if (val == nullptr)
2304823048 return ira->codegen->invalid_instruction;
2304923049
......@@ -23232,11 +23232,11 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2323223232 uint64_t known_len;
2323323233
2323423234 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);
2323623236 if (!val)
2323723237 return ira->codegen->invalid_instruction;
2323823238
23239 ConstExprValue *len_val = val->data.x_struct.fields[slice_len_index];
23239 ZigValue *len_val = val->data.x_struct.fields[slice_len_index];
2324023240 if (value_is_comptime(len_val)) {
2324123241 known_len = bigint_as_u64(&len_val->data.x_bigint);
2324223242 have_known_len = true;
......@@ -23298,22 +23298,22 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
2329823298 ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
2329923299
2330023300 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);
2330223302 if (target_val == nullptr)
2330323303 return ira->codegen->invalid_instruction;
2330423304
2330523305 IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type);
2330623306 result->value.data.x_struct.fields = alloc_const_vals_ptrs(2);
2330723307
23308 ConstExprValue *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];
23308 ZigValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index];
23309 ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index];
2331023310 copy_const_val(ptr_val, target_ptr_val, false);
2331123311 ptr_val->type = dest_ptr_type;
2331223312
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];
2331423314 len_val->special = ConstValSpecialStatic;
2331523315 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];
2331723317 ZigType *elem_type = src_ptr_type->data.pointer.child_type;
2331823318 BigInt elem_size_bigint;
2331923319 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
2353923539 return ira->codegen->invalid_instruction;
2354023540 }
2354123541
23542 ConstExprValue *mask_val = ir_resolve_const(ira, mask, UndefOk);
23542 ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk);
2354323543 if (mask_val == nullptr)
2354423544 return ira->codegen->invalid_instruction;
2354523545
2354623546 expand_undef_array(ira->codegen, mask_val);
2354723547
2354823548 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];
2355023550 if (mask_elem_val->special == ConstValSpecialUndef)
2355123551 continue;
2355223552 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
2357523575
2357623576 ZigType *result_type = get_vector_type(ira->codegen, len_mask, scalar_type);
2357723577 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);
2357923579 if (a_val == nullptr)
2358023580 return ira->codegen->invalid_instruction;
2358123581
23582 ConstExprValue *b_val = ir_resolve_const(ira, b, UndefOk);
23582 ZigValue *b_val = ir_resolve_const(ira, b, UndefOk);
2358323583 if (b_val == nullptr)
2358423584 return ira->codegen->invalid_instruction;
2358523585
......@@ -23589,15 +23589,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s
2358923589 IrInstruction *result = ir_const(ira, source_instr, result_type);
2359023590 result->value.data.x_array.data.s_none.elements = create_const_vals(len_mask);
2359123591 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];
23593 ConstExprValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i];
23592 ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i];
23593 ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i];
2359423594 if (mask_elem_val->special == ConstValSpecialUndef) {
2359523595 result_elem_val->special = ConstValSpecialUndef;
2359623596 continue;
2359723597 }
2359823598 int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint);
2359923599 // 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) ?
2360123601 &a->value.data.x_array.data.s_none.elements[v] :
2360223602 &b->value.data.x_array.data.s_none.elements[~v];
2360323603 copy_const_val(result_elem_val, src_elem_val, false);
......@@ -23686,7 +23686,7 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction
2368623686 ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type);
2368723687
2368823688 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);
2369023690 if (scalar_val == nullptr)
2369123691 return ira->codegen->invalid_instruction;
2369223692 if (scalar_val->special == ConstValSpecialUndef)
......@@ -23715,7 +23715,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct
2371523715 return ira->codegen->invalid_instruction;
2371623716
2371723717 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);
2371923719 if (value == nullptr)
2372023720 return ira->codegen->invalid_instruction;
2372123721
......@@ -23776,22 +23776,22 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2377623776 instr_is_comptime(casted_byte) &&
2377723777 instr_is_comptime(casted_count))
2377823778 {
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);
2378023780 if (dest_ptr_val == nullptr)
2378123781 return ira->codegen->invalid_instruction;
2378223782
23783 ConstExprValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk);
23783 ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk);
2378423784 if (byte_val == nullptr)
2378523785 return ira->codegen->invalid_instruction;
2378623786
23787 ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad);
23787 ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad);
2378823788 if (count_val == nullptr)
2378923789 return ira->codegen->invalid_instruction;
2379023790
2379123791 if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr &&
2379223792 casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar)
2379323793 {
23794 ConstExprValue *dest_elements;
23794 ZigValue *dest_elements;
2379523795 size_t start;
2379623796 size_t bound_end;
2379723797 switch (dest_ptr_val->data.x_ptr.special) {
......@@ -23805,7 +23805,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio
2380523805 break;
2380623806 case ConstPtrSpecialBaseArray:
2380723807 {
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;
2380923809 expand_undef_array(ira->codegen, array_val);
2381023810 dest_elements = array_val->data.x_array.data.s_none.elements;
2381123811 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
2391223912 instr_is_comptime(casted_src_ptr) &&
2391323913 instr_is_comptime(casted_count))
2391423914 {
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);
2391623916 if (dest_ptr_val == nullptr)
2391723917 return ira->codegen->invalid_instruction;
2391823918
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);
2392023920 if (src_ptr_val == nullptr)
2392123921 return ira->codegen->invalid_instruction;
2392223922
23923 ConstExprValue *count_val = ir_resolve_const(ira, casted_count, UndefBad);
23923 ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad);
2392423924 if (count_val == nullptr)
2392523925 return ira->codegen->invalid_instruction;
2392623926
2392723927 if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) {
2392823928 size_t count = bigint_as_usize(&count_val->data.x_bigint);
2392923929
23930 ConstExprValue *dest_elements;
23930 ZigValue *dest_elements;
2393123931 size_t dest_start;
2393223932 size_t dest_end;
2393323933 switch (dest_ptr_val->data.x_ptr.special) {
......@@ -23941,7 +23941,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2394123941 break;
2394223942 case ConstPtrSpecialBaseArray:
2394323943 {
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;
2394523945 expand_undef_array(ira->codegen, array_val);
2394623946 dest_elements = array_val->data.x_array.data.s_none.elements;
2394723947 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
2396923969 return ira->codegen->invalid_instruction;
2397023970 }
2397123971
23972 ConstExprValue *src_elements;
23972 ZigValue *src_elements;
2397323973 size_t src_start;
2397423974 size_t src_end;
2397523975
......@@ -23984,7 +23984,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio
2398423984 break;
2398523985 case ConstPtrSpecialBaseArray:
2398623986 {
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;
2398823988 expand_undef_array(ira->codegen, array_val);
2398923989 src_elements = array_val->data.x_array.data.s_none.elements;
2399023990 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
2410624106 value_is_comptime(&casted_start->value) &&
2410724107 (!end || value_is_comptime(&end->value)))
2410824108 {
24109 ConstExprValue *array_val;
24110 ConstExprValue *parent_ptr;
24109 ZigValue *array_val;
24110 ZigValue *parent_ptr;
2411124111 size_t abs_offset;
2411224112 size_t rel_end;
2411324113 bool ptr_is_undef = false;
......@@ -24193,7 +24193,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2419324193 zig_panic("TODO slice of null ptr");
2419424194 }
2419524195 } 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);
2419724197 if (slice_ptr == nullptr)
2419824198 return ira->codegen->invalid_instruction;
2419924199
......@@ -24208,7 +24208,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2420824208 return ira->codegen->invalid_instruction;
2420924209 }
2421024210
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];
2421224212
2421324213 switch (parent_ptr->data.x_ptr.special) {
2421424214 case ConstPtrSpecialInvalid:
......@@ -24246,7 +24246,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2424624246 zig_unreachable();
2424724247 }
2424824248
24249 ConstExprValue *start_val = ir_resolve_const(ira, casted_start, UndefBad);
24249 ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad);
2425024250 if (!start_val)
2425124251 return ira->codegen->invalid_instruction;
2425224252
......@@ -24258,7 +24258,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2425824258
2425924259 uint64_t end_scalar = rel_end;
2426024260 if (end) {
24261 ConstExprValue *end_val = ir_resolve_const(ira, end, UndefBad);
24261 ZigValue *end_val = ir_resolve_const(ira, end, UndefBad);
2426224262 if (!end_val)
2426324263 return ira->codegen->invalid_instruction;
2426424264 end_scalar = bigint_as_u64(&end_val->data.x_bigint);
......@@ -24279,10 +24279,10 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2427924279 }
2428024280
2428124281 IrInstruction *result = ir_const(ira, &instruction->base, return_type);
24282 ConstExprValue *out_val = &result->value;
24282 ZigValue *out_val = &result->value;
2428324283 out_val->data.x_struct.fields = alloc_const_vals_ptrs(2);
2428424284
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];
2428624286
2428724287 if (array_val) {
2428824288 size_t index = abs_offset + start_scalar;
......@@ -24329,7 +24329,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction
2432924329 zig_panic("TODO");
2433024330 }
2433124331
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];
2433324333 init_const_usize(ira->codegen, len_val, end_scalar - start_scalar);
2433424334
2433524335 return result;
......@@ -24666,21 +24666,21 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2466624666 instr_is_comptime(casted_op2) &&
2466724667 instr_is_comptime(casted_result_ptr))
2466824668 {
24669 ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
24669 ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
2467024670 if (op1_val == nullptr)
2467124671 return ira->codegen->invalid_instruction;
2467224672
24673 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
24673 ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
2467424674 if (op2_val == nullptr)
2467524675 return ira->codegen->invalid_instruction;
2467624676
24677 ConstExprValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad);
24677 ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad);
2467824678 if (result_val == nullptr)
2467924679 return ira->codegen->invalid_instruction;
2468024680
2468124681 BigInt *op1_bigint = &op1_val->data.x_bigint;
2468224682 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,
2468424684 casted_result_ptr->source_node);
2468524685 if (pointee_val == nullptr)
2468624686 return ira->codegen->invalid_instruction;
......@@ -24721,7 +24721,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
2472124721}
2472224722
2472324723static 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) {
2472524725 if (float_type->id == ZigTypeIdComptimeFloat) {
2472624726 f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value,
2472724727 &op3->data.x_bigfloat.value);
......@@ -24791,18 +24791,18 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2479124791 if (instr_is_comptime(casted_op1) &&
2479224792 instr_is_comptime(casted_op2) &&
2479324793 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);
2479524795 if (!op1_const)
2479624796 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);
2479824798 if (!op2_const)
2479924799 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);
2480124801 if (!op3_const)
2480224802 return ira->codegen->invalid_instruction;
2480324803
2480424804 IrInstruction *result = ir_const(ira, &instruction->base, expr_type);
24805 ConstExprValue *out_val = &result->value;
24805 ZigValue *out_val = &result->value;
2480624806
2480724807 if (expr_type->id == ZigTypeIdVector) {
2480824808 expand_undef_array(ira->codegen, op1_const);
......@@ -24812,10 +24812,10 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi
2481224812 expand_undef_array(ira->codegen, out_val);
2481324813 size_t len = expr_type->data.vector.len;
2481424814 for (size_t i = 0; i < len; i += 1) {
24815 ConstExprValue *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];
24817 ConstExprValue *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];
24815 ZigValue *float_operand_op1 = &op1_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 ZigValue *float_operand_op3 = &op3_const->data.x_array.data.s_none.elements[i];
24818 ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i];
2481924819 assert(float_operand_op1->type == float_type);
2482024820 assert(float_operand_op2->type == float_type);
2482124821 assert(float_operand_op3->type == float_type);
......@@ -24856,7 +24856,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct
2485624856 return ira->codegen->invalid_instruction;
2485724857 if (type_entry->id == ZigTypeIdErrorUnion) {
2485824858 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);
2486024860 if (!err_union_val)
2486124861 return ira->codegen->invalid_instruction;
2486224862
......@@ -24911,20 +24911,20 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *
2491124911 ptr_type->data.pointer.explicit_alignment, 0, 0, false);
2491224912
2491324913 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);
2491524915 if (!ptr_val)
2491624916 return ira->codegen->invalid_instruction;
2491724917 if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar &&
2491824918 ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)
2491924919 {
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);
2492124921 if (err_union_val == nullptr)
2492224922 return ira->codegen->invalid_instruction;
2492324923
2492424924 if (initializing && err_union_val->special == ConstValSpecialUndef) {
24925 ConstExprValue *vals = create_const_vals(2);
24926 ConstExprValue *err_set_val = &vals[0];
24927 ConstExprValue *payload_val = &vals[1];
24925 ZigValue *vals = create_const_vals(2);
24926 ZigValue *err_set_val = &vals[0];
24927 ZigValue *payload_val = &vals[1];
2492824928
2492924929 err_set_val->special = ConstValSpecialUndef;
2493024930 err_set_val->type = err_set_type;
......@@ -24951,7 +24951,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *
2495124951 } else {
2495224952 result = ir_const(ira, source_instr, result_type);
2495324953 }
24954 ConstExprValue *const_val = &result->value;
24954 ZigValue *const_val = &result->value;
2495524955 const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode;
2495624956 const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val;
2495724957 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
2500025000 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
2500125001 PtrLenSingle, 0, 0, 0, false);
2500225002 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);
2500425004 if (!ptr_val)
2500525005 return ira->codegen->invalid_instruction;
2500625006 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);
2500825008 if (err_union_val == nullptr)
2500925009 return ira->codegen->invalid_instruction;
2501025010 if (initializing && err_union_val->special == ConstValSpecialUndef) {
25011 ConstExprValue *vals = create_const_vals(2);
25012 ConstExprValue *err_set_val = &vals[0];
25013 ConstExprValue *payload_val = &vals[1];
25011 ZigValue *vals = create_const_vals(2);
25012 ZigValue *err_set_val = &vals[0];
25013 ZigValue *payload_val = &vals[1];
2501425014
2501525015 err_set_val->special = ConstValSpecialStatic;
2501625016 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,
2528925289 if (type_is_invalid(casted_end_value->value.type))
2529025290 return ira->codegen->invalid_instruction;
2529125291
25292 ConstExprValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad);
25292 ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad);
2529325293 if (!start_val)
2529425294 return ira->codegen->invalid_instruction;
2529525295
25296 ConstExprValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad);
25296 ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad);
2529725297 if (!end_val)
2529825298 return ira->codegen->invalid_instruction;
2529925299
......@@ -25329,7 +25329,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
2532925329 if (type_is_invalid(casted_value->value.type))
2533025330 return ira->codegen->invalid_instruction;
2533125331
25332 ConstExprValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad);
25332 ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad);
2533325333 if (!const_expr_val)
2533425334 return ira->codegen->invalid_instruction;
2533525335
......@@ -25443,7 +25443,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
2544325443 }
2544425444
2544525445 if (instr_is_comptime(target)) {
25446 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
25446 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
2544725447 if (!val)
2544825448 return ira->codegen->invalid_instruction;
2544925449
......@@ -25515,7 +25515,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2551525515 if (instr_is_comptime(ptr)) {
2551625516 bool dest_allows_addr_zero = ptr_allows_addr_zero(dest_type);
2551725517 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);
2551925519 if (!val)
2552025520 return ira->codegen->invalid_instruction;
2552125521
......@@ -25607,18 +25607,18 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct
2560725607 instruction->safety_check_on);
2560825608}
2560925609
25610static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ConstExprValue *val, size_t len) {
25610static void buf_write_value_bytes_array(CodeGen *codegen, uint8_t *buf, ZigValue *val, size_t len) {
2561125611 size_t buf_i = 0;
2561225612 // TODO optimize the buf case
2561325613 expand_undef_array(codegen, val);
2561425614 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];
2561625616 buf_write_value_bytes(codegen, &buf[buf_i], elem);
2561725617 buf_i += type_size(codegen, elem->type);
2561825618 }
2561925619}
2562025620
25621static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) {
25621static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val) {
2562225622 if (val->special == ConstValSpecialUndef) {
2562325623 expand_undef_struct(codegen, val);
2562425624 val->special = ConstValSpecialStatic;
......@@ -25679,7 +25679,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
2567925679 TypeStructField *struct_field = val->type->data.structure.fields[field_i];
2568025680 if (struct_field->gen_index == SIZE_MAX)
2568125681 continue;
25682 ConstExprValue *field_val = val->data.x_struct.fields[field_i];
25682 ZigValue *field_val = val->data.x_struct.fields[field_i];
2568325683 size_t offset = struct_field->offset;
2568425684 buf_write_value_bytes(codegen, buf + offset, field_val);
2568525685 }
......@@ -25754,7 +25754,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
2575425754}
2575525755
2575625756static 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)
2575825758{
2575925759 Error err;
2576025760 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
2576325763 case ConstArraySpecialNone:
2576425764 val->data.x_array.data.s_none.elements = create_const_vals(len);
2576525765 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];
2576725767 elem->special = ConstValSpecialStatic;
2576825768 elem->type = elem_type;
2576925769 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
2577825778 zig_unreachable();
2577925779}
2578025780
25781static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val) {
25781static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val) {
2578225782 Error err;
2578325783 src_assert(val->special == ConstValSpecialStatic, source_node);
2578425784 switch (val->type->id) {
......@@ -25850,7 +25850,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2585025850 size_t src_field_count = val->type->data.structure.src_field_count;
2585125851 val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count);
2585225852 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];
2585425854 field_val->special = ConstValSpecialStatic;
2585525855 TypeStructField *struct_field = val->type->data.structure.fields[field_i];
2585625856 field_val->type = struct_field->type_entry;
......@@ -25887,7 +25887,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2588725887 src_assert(field->gen_index != SIZE_MAX, source_node);
2588825888 if (field->gen_index != gen_i)
2588925889 break;
25890 ConstExprValue *field_val = val->data.x_struct.fields[src_i];
25890 ZigValue *field_val = val->data.x_struct.fields[src_i];
2589125891 field_val->special = ConstValSpecialStatic;
2589225892 field_val->type = field->type_entry;
2589325893 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_
2597525975 }
2597625976
2597725977 if (instr_is_comptime(value)) {
25978 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
25978 ZigValue *val = ir_resolve_const(ira, value, UndefBad);
2597925979 if (!val)
2598025980 return ira->codegen->invalid_instruction;
2598125981
......@@ -26001,7 +26001,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc
2600126001 return ira->codegen->invalid_instruction;
2600226002
2600326003 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);
2600526005 if (!val)
2600626006 return ira->codegen->invalid_instruction;
2600726007
......@@ -26093,7 +26093,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2609326093 }
2609426094
2609526095 if (instr_is_comptime(target)) {
26096 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
26096 ZigValue *val = ir_resolve_const(ira, target, UndefBad);
2609726097 if (!val)
2609826098 return ira->codegen->invalid_instruction;
2609926099 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
2650626506}
2650726507
2650826508static 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) {
2651026510 assert(ira && source_instr && float_type && out_val && op);
2651126511 assert(float_type->id == ZigTypeIdFloat ||
2651226512 float_type->id == ZigTypeIdComptimeFloat);
......@@ -26719,12 +26719,12 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2671926719 return ira->codegen->invalid_instruction;
2672026720 }
2672126721
26722 ConstExprValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad);
26722 ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad);
2672326723 if (!op1_const)
2672426724 return ira->codegen->invalid_instruction;
2672526725
2672626726 IrInstruction *result = ir_const(ira, &instruction->base, expr_type);
26727 ConstExprValue *out_val = &result->value;
26727 ZigValue *out_val = &result->value;
2672826728
2672926729 if (expr_type->id == ZigTypeIdVector) {
2673026730 expand_undef_array(ira->codegen, op1_const);
......@@ -26732,8 +26732,8 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct
2673226732 expand_undef_array(ira->codegen, out_val);
2673326733 size_t len = expr_type->data.vector.len;
2673426734 for (size_t i = 0; i < len; i += 1) {
26735 ConstExprValue *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];
26735 ZigValue *float_operand_op1 = &op1_const->data.x_array.data.s_none.elements[i];
26736 ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i];
2673726737 assert(float_operand_op1->type == float_type);
2673826738 assert(float_out_val->type == float_type);
2673926739 ir_eval_float_op(ira, instruction, float_type,
......@@ -26796,7 +26796,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2679626796 }
2679726797
2679826798 if (instr_is_comptime(op)) {
26799 ConstExprValue *val = ir_resolve_const(ira, op, UndefOk);
26799 ZigValue *val = ir_resolve_const(ira, op, UndefOk);
2680026800 if (val == nullptr)
2680126801 return ira->codegen->invalid_instruction;
2680226802 if (val->special == ConstValSpecialUndef)
......@@ -26809,13 +26809,13 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2680926809 expand_undef_array(ira->codegen, val);
2681026810 result->value.data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len);
2681126811 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];
2681326813 if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node,
2681426814 op_elem_val, UndefOk)))
2681526815 {
2681626816 return ira->codegen->invalid_instruction;
2681726817 }
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];
2681926819 result_elem_val->type = int_type;
2682026820 result_elem_val->special = op_elem_val->special;
2682126821 if (op_elem_val->special == ConstValSpecialUndef)
......@@ -26857,7 +26857,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr
2685726857 }
2685826858
2685926859 if (instr_is_comptime(op)) {
26860 ConstExprValue *val = ir_resolve_const(ira, op, UndefOk);
26860 ZigValue *val = ir_resolve_const(ira, op, UndefOk);
2686126861 if (val == nullptr)
2686226862 return ira->codegen->invalid_instruction;
2686326863 if (val->special == ConstValSpecialUndef)
......@@ -27601,7 +27601,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_
2760127601 ira->new_irb.codegen = codegen;
2760227602 ira->new_irb.exec = new_exec;
2760327603
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);
2760527605 ira->exec_context.mem_slot_list.resize(ira->old_irb.exec->mem_slot_count);
2760627606 for (size_t i = 0; i < ira->exec_context.mem_slot_list.length; i += 1) {
2760727607 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
2794727947 return get_fn_type(ira->codegen, &fn_type_id);
2794827948}
2794927949
27950static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
27950static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) {
2795127951 Error err;
2795227952 if (val->special != ConstValSpecialLazy)
2795327953 return ErrorNone;
......@@ -28071,7 +28071,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
2807128071 if (type_is_invalid(elem_type))
2807228072 return ErrorSemanticAnalyzeFail;
2807328073
28074 ConstExprValue *sentinel_val;
28074 ZigValue *sentinel_val;
2807528075 if (lazy_slice_type->sentinel != nullptr) {
2807628076 if (type_is_invalid(lazy_slice_type->sentinel->value.type))
2807728077 return ErrorSemanticAnalyzeFail;
......@@ -28149,7 +28149,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
2814928149 if (type_is_invalid(elem_type))
2815028150 return ErrorSemanticAnalyzeFail;
2815128151
28152 ConstExprValue *sentinel_val;
28152 ZigValue *sentinel_val;
2815328153 if (lazy_ptr_type->sentinel != nullptr) {
2815428154 if (type_is_invalid(lazy_ptr_type->sentinel->value.type))
2815528155 return ErrorSemanticAnalyzeFail;
......@@ -28276,7 +28276,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) {
2827628276 zig_unreachable();
2827728277}
2827828278
28279Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) {
28279Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) {
2828028280 Error err;
2828128281 if ((err = ir_resolve_lazy_raw(source_node, val))) {
2828228282 if (codegen->trace_err != nullptr && source_node != nullptr && !source_node->already_traced_this_node) {
src/ir.hpp+3-3
......@@ -18,12 +18,12 @@ enum IrPass {
1818bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable);
1919bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);
2020
21ConstExprValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
21ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
2222 ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota,
2323 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
2424 IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef);
2525
26Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val);
26Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val);
2727
2828ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,
2929 ZigType *expected_type, AstNode *expected_type_source_node);
......@@ -31,7 +31,7 @@ ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_
3131bool ir_has_side_effects(IrInstruction *instruction);
3232
3333struct IrAnalyze;
34ConstExprValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ConstExprValue *const_val,
34ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_val,
3535 AstNode *source_node);
3636const char *float_op_to_name(BuiltinFnId op, bool llvm_name);
3737
src/ir_print.cpp+2-2
......@@ -396,7 +396,7 @@ static void ir_print_prefix(IrPrint *irp, IrInstruction *instruction, bool trail
396396 ir_instruction_type_str(instruction->id), type_name, ref_count);
397397}
398398
399static void ir_print_const_value(IrPrint *irp, ConstExprValue *const_val) {
399static void ir_print_const_value(IrPrint *irp, ZigValue *const_val) {
400400 Buf buf = BUF_INIT;
401401 buf_resize(&buf, 0);
402402 render_const_value(irp->codegen, &buf, const_val);
......@@ -2576,7 +2576,7 @@ void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction,
25762576 ir_print_instruction(irp, instruction, false);
25772577}
25782578
2579void ir_print_const_expr(CodeGen *codegen, FILE *f, ConstExprValue *value, int indent_size, IrPass pass) {
2579void ir_print_const_expr(CodeGen *codegen, FILE *f, ZigValue *value, int indent_size, IrPass pass) {
25802580 IrPrint ir_print = {};
25812581 IrPrint *irp = &ir_print;
25822582 irp->pass = pass;
src/ir_print.hpp+1-1
......@@ -14,7 +14,7 @@
1414
1515void ir_print(CodeGen *codegen, FILE *f, IrExecutable *executable, int indent_size, IrPass pass);
1616void ir_print_instruction(CodeGen *codegen, FILE *f, IrInstruction *instruction, int indent_size, IrPass pass);
17void ir_print_const_expr(CodeGen *codegen, FILE *f, ConstExprValue *value, int indent_size, IrPass pass);
17void ir_print_const_expr(CodeGen *codegen, FILE *f, ZigValue *value, int indent_size, IrPass pass);
1818
1919const char* ir_instruction_type_str(IrInstructionId id);
2020