authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-05 18:33:07-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-05 18:33:07-04:00
logdb882e5d63d2840b1410a2574fd12d973b7f3ee2
tree6316a85c4da5de1fd54b380c554d65daaf4d6700
parenta3d384e593e9128ed3b69cc77e6d6e048f0c6bb7
signaturelock-open Commit is signed but in an unrecognized format.

stage1: rename TypeTableEntry to ZigType


6 files changed, 1137 insertions(+), 1137 deletions(-)

src/all_types.hpp+87-87
...@@ -24,7 +24,7 @@ struct FnTableEntry;...@@ -24,7 +24,7 @@ struct FnTableEntry;
24struct Scope;24struct Scope;
25struct ScopeBlock;25struct ScopeBlock;
26struct ScopeFnDef;26struct ScopeFnDef;
27struct TypeTableEntry;27struct ZigType;
28struct VariableTableEntry;28struct VariableTableEntry;
29struct ErrorTableEntry;29struct ErrorTableEntry;
30struct BuiltinFnEntry;30struct BuiltinFnEntry;
...@@ -251,7 +251,7 @@ struct ConstGlobalRefs {...@@ -251,7 +251,7 @@ struct ConstGlobalRefs {
251};251};
252252
253struct ConstExprValue {253struct ConstExprValue {
254 TypeTableEntry *type;254 ZigType *type;
255 ConstValSpecial special;255 ConstValSpecial special;
256 ConstGlobalRefs *global_refs;256 ConstGlobalRefs *global_refs;
257257
...@@ -265,7 +265,7 @@ struct ConstExprValue {...@@ -265,7 +265,7 @@ struct ConstExprValue {
265 float128_t x_f128;265 float128_t x_f128;
266 bool x_bool;266 bool x_bool;
267 ConstBoundFnValue x_bound_fn;267 ConstBoundFnValue x_bound_fn;
268 TypeTableEntry *x_type;268 ZigType *x_type;
269 ConstExprValue *x_optional;269 ConstExprValue *x_optional;
270 ConstErrValue x_err_union;270 ConstErrValue x_err_union;
271 ErrorTableEntry *x_err_set;271 ErrorTableEntry *x_err_set;
...@@ -353,7 +353,7 @@ struct TldContainer {...@@ -353,7 +353,7 @@ struct TldContainer {
353 Tld base;353 Tld base;
354354
355 ScopeDecls *decls_scope;355 ScopeDecls *decls_scope;
356 TypeTableEntry *type_entry;356 ZigType *type_entry;
357};357};
358358
359struct TldCompTime {359struct TldCompTime {
...@@ -370,7 +370,7 @@ struct TypeEnumField {...@@ -370,7 +370,7 @@ struct TypeEnumField {
370struct TypeUnionField {370struct TypeUnionField {
371 Buf *name;371 Buf *name;
372 TypeEnumField *enum_field;372 TypeEnumField *enum_field;
373 TypeTableEntry *type_entry;373 ZigType *type_entry;
374 AstNode *decl_node;374 AstNode *decl_node;
375 uint32_t gen_index;375 uint32_t gen_index;
376};376};
...@@ -973,7 +973,7 @@ struct AstNode {...@@ -973,7 +973,7 @@ struct AstNode {
973// this struct is allocated with allocate_nonzero973// this struct is allocated with allocate_nonzero
974struct FnTypeParamInfo {974struct FnTypeParamInfo {
975 bool is_noalias;975 bool is_noalias;
976 TypeTableEntry *type;976 ZigType *type;
977};977};
978978
979struct GenericFnTypeId {979struct GenericFnTypeId {
...@@ -986,14 +986,14 @@ uint32_t generic_fn_type_id_hash(GenericFnTypeId *id);...@@ -986,14 +986,14 @@ uint32_t generic_fn_type_id_hash(GenericFnTypeId *id);
986bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b);986bool generic_fn_type_id_eql(GenericFnTypeId *a, GenericFnTypeId *b);
987987
988struct FnTypeId {988struct FnTypeId {
989 TypeTableEntry *return_type;989 ZigType *return_type;
990 FnTypeParamInfo *param_info;990 FnTypeParamInfo *param_info;
991 size_t param_count;991 size_t param_count;
992 size_t next_param_index;992 size_t next_param_index;
993 bool is_var_args;993 bool is_var_args;
994 CallingConvention cc;994 CallingConvention cc;
995 uint32_t alignment;995 uint32_t alignment;
996 TypeTableEntry *async_allocator_type;996 ZigType *async_allocator_type;
997};997};
998998
999uint32_t fn_type_id_hash(FnTypeId*);999uint32_t fn_type_id_hash(FnTypeId*);
...@@ -1005,14 +1005,14 @@ enum PtrLen {...@@ -1005,14 +1005,14 @@ enum PtrLen {
1005};1005};
10061006
1007struct TypeTableEntryPointer {1007struct TypeTableEntryPointer {
1008 TypeTableEntry *child_type;1008 ZigType *child_type;
1009 PtrLen ptr_len;1009 PtrLen ptr_len;
1010 bool is_const;1010 bool is_const;
1011 bool is_volatile;1011 bool is_volatile;
1012 uint32_t alignment;1012 uint32_t alignment;
1013 uint32_t bit_offset;1013 uint32_t bit_offset;
1014 uint32_t unaligned_bit_count;1014 uint32_t unaligned_bit_count;
1015 TypeTableEntry *slice_parent;1015 ZigType *slice_parent;
1016};1016};
10171017
1018struct TypeTableEntryInt {1018struct TypeTableEntryInt {
...@@ -1025,13 +1025,13 @@ struct TypeTableEntryFloat {...@@ -1025,13 +1025,13 @@ struct TypeTableEntryFloat {
1025};1025};
10261026
1027struct TypeTableEntryArray {1027struct TypeTableEntryArray {
1028 TypeTableEntry *child_type;1028 ZigType *child_type;
1029 uint64_t len;1029 uint64_t len;
1030};1030};
10311031
1032struct TypeStructField {1032struct TypeStructField {
1033 Buf *name;1033 Buf *name;
1034 TypeTableEntry *type_entry;1034 ZigType *type_entry;
1035 size_t src_index;1035 size_t src_index;
1036 size_t gen_index;1036 size_t gen_index;
1037 // offset from the memory at gen_index1037 // offset from the memory at gen_index
...@@ -1069,12 +1069,12 @@ struct TypeTableEntryStruct {...@@ -1069,12 +1069,12 @@ struct TypeTableEntryStruct {
1069};1069};
10701070
1071struct TypeTableEntryOptional {1071struct TypeTableEntryOptional {
1072 TypeTableEntry *child_type;1072 ZigType *child_type;
1073};1073};
10741074
1075struct TypeTableEntryErrorUnion {1075struct TypeTableEntryErrorUnion {
1076 TypeTableEntry *err_set_type;1076 ZigType *err_set_type;
1077 TypeTableEntry *payload_type;1077 ZigType *payload_type;
1078};1078};
10791079
1080struct TypeTableEntryErrorSet {1080struct TypeTableEntryErrorSet {
...@@ -1089,7 +1089,7 @@ struct TypeTableEntryEnum {...@@ -1089,7 +1089,7 @@ struct TypeTableEntryEnum {
1089 uint32_t src_field_count;1089 uint32_t src_field_count;
1090 TypeEnumField *fields;1090 TypeEnumField *fields;
1091 bool is_invalid; // true if any fields are invalid1091 bool is_invalid; // true if any fields are invalid
1092 TypeTableEntry *tag_int_type;1092 ZigType *tag_int_type;
10931093
1094 ScopeDecls *decls_scope;1094 ScopeDecls *decls_scope;
10951095
...@@ -1107,8 +1107,8 @@ struct TypeTableEntryEnum {...@@ -1107,8 +1107,8 @@ struct TypeTableEntryEnum {
1107 HashMap<Buf *, TypeEnumField *, buf_hash, buf_eql_buf> fields_by_name;1107 HashMap<Buf *, TypeEnumField *, buf_hash, buf_eql_buf> fields_by_name;
1108};1108};
11091109
1110uint32_t type_ptr_hash(const TypeTableEntry *ptr);1110uint32_t type_ptr_hash(const ZigType *ptr);
1111bool type_ptr_eql(const TypeTableEntry *a, const TypeTableEntry *b);1111bool type_ptr_eql(const ZigType *a, const ZigType *b);
11121112
1113struct TypeTableEntryUnion {1113struct TypeTableEntryUnion {
1114 AstNode *decl_node;1114 AstNode *decl_node;
...@@ -1117,7 +1117,7 @@ struct TypeTableEntryUnion {...@@ -1117,7 +1117,7 @@ struct TypeTableEntryUnion {
1117 uint32_t gen_field_count;1117 uint32_t gen_field_count;
1118 TypeUnionField *fields;1118 TypeUnionField *fields;
1119 bool is_invalid; // true if any fields are invalid1119 bool is_invalid; // true if any fields are invalid
1120 TypeTableEntry *tag_type; // always an enum or null1120 ZigType *tag_type; // always an enum or null
1121 LLVMTypeRef union_type_ref;1121 LLVMTypeRef union_type_ref;
11221122
1123 ScopeDecls *decls_scope;1123 ScopeDecls *decls_scope;
...@@ -1142,7 +1142,7 @@ struct TypeTableEntryUnion {...@@ -1142,7 +1142,7 @@ struct TypeTableEntryUnion {
1142 bool have_explicit_tag_type;1142 bool have_explicit_tag_type;
11431143
1144 uint32_t union_size_bytes;1144 uint32_t union_size_bytes;
1145 TypeTableEntry *most_aligned_union_member;1145 ZigType *most_aligned_union_member;
11461146
1147 HashMap<Buf *, TypeUnionField *, buf_hash, buf_eql_buf> fields_by_name;1147 HashMap<Buf *, TypeUnionField *, buf_hash, buf_eql_buf> fields_by_name;
1148};1148};
...@@ -1151,31 +1151,31 @@ struct FnGenParamInfo {...@@ -1151,31 +1151,31 @@ struct FnGenParamInfo {
1151 size_t src_index;1151 size_t src_index;
1152 size_t gen_index;1152 size_t gen_index;
1153 bool is_byval;1153 bool is_byval;
1154 TypeTableEntry *type;1154 ZigType *type;
1155};1155};
11561156
1157struct TypeTableEntryFn {1157struct TypeTableEntryFn {
1158 FnTypeId fn_type_id;1158 FnTypeId fn_type_id;
1159 bool is_generic;1159 bool is_generic;
1160 TypeTableEntry *gen_return_type;1160 ZigType *gen_return_type;
1161 size_t gen_param_count;1161 size_t gen_param_count;
1162 FnGenParamInfo *gen_param_info;1162 FnGenParamInfo *gen_param_info;
11631163
1164 LLVMTypeRef raw_type_ref;1164 LLVMTypeRef raw_type_ref;
11651165
1166 TypeTableEntry *bound_fn_parent;1166 ZigType *bound_fn_parent;
1167};1167};
11681168
1169struct TypeTableEntryBoundFn {1169struct TypeTableEntryBoundFn {
1170 TypeTableEntry *fn_type;1170 ZigType *fn_type;
1171};1171};
11721172
1173struct TypeTableEntryPromise {1173struct TypeTableEntryPromise {
1174 // null if `promise` instead of `promise->T`1174 // null if `promise` instead of `promise->T`
1175 TypeTableEntry *result_type;1175 ZigType *result_type;
1176};1176};
11771177
1178enum TypeTableEntryId {1178enum ZigTypeId {
1179 TypeTableEntryIdInvalid,1179 TypeTableEntryIdInvalid,
1180 TypeTableEntryIdMetaType,1180 TypeTableEntryIdMetaType,
1181 TypeTableEntryIdVoid,1181 TypeTableEntryIdVoid,
...@@ -1204,8 +1204,8 @@ enum TypeTableEntryId {...@@ -1204,8 +1204,8 @@ enum TypeTableEntryId {
1204 TypeTableEntryIdPromise,1204 TypeTableEntryIdPromise,
1205};1205};
12061206
1207struct TypeTableEntry {1207struct ZigType {
1208 TypeTableEntryId id;1208 ZigTypeId id;
1209 Buf name;1209 Buf name;
12101210
1211 LLVMTypeRef type_ref;1211 LLVMTypeRef type_ref;
...@@ -1232,10 +1232,10 @@ struct TypeTableEntry {...@@ -1232,10 +1232,10 @@ struct TypeTableEntry {
1232 } data;1232 } data;
12331233
1234 // use these fields to make sure we don't duplicate type table entries for the same type1234 // use these fields to make sure we don't duplicate type table entries for the same type
1235 TypeTableEntry *pointer_parent[2]; // [0 - mut, 1 - const]1235 ZigType *pointer_parent[2]; // [0 - mut, 1 - const]
1236 TypeTableEntry *optional_parent;1236 ZigType *optional_parent;
1237 TypeTableEntry *promise_parent;1237 ZigType *promise_parent;
1238 TypeTableEntry *promise_frame_parent;1238 ZigType *promise_frame_parent;
1239 // If we generate a constant name value for this type, we memoize it here.1239 // If we generate a constant name value for this type, we memoize it here.
1240 // The type of this is array1240 // The type of this is array
1241 ConstExprValue *cached_const_name_val;1241 ConstExprValue *cached_const_name_val;
...@@ -1291,11 +1291,11 @@ struct FnTableEntry {...@@ -1291,11 +1291,11 @@ struct FnTableEntry {
1291 Scope *child_scope; // parent is scope for last parameter1291 Scope *child_scope; // parent is scope for last parameter
1292 ScopeBlock *def_scope; // parent is child_scope1292 ScopeBlock *def_scope; // parent is child_scope
1293 Buf symbol_name;1293 Buf symbol_name;
1294 TypeTableEntry *type_entry; // function type1294 ZigType *type_entry; // function type
1295 // in the case of normal functions this is the implicit return type1295 // in the case of normal functions this is the implicit return type
1296 // in the case of async functions this is the implicit return type according to the1296 // in the case of async functions this is the implicit return type according to the
1297 // zig source code, not according to zig ir1297 // zig source code, not according to zig ir
1298 TypeTableEntry *src_implicit_return_type;1298 ZigType *src_implicit_return_type;
1299 bool is_test;1299 bool is_test;
1300 FnInline fn_inline;1300 FnInline fn_inline;
1301 FnAnalState anal_state;1301 FnAnalState anal_state;
...@@ -1445,11 +1445,11 @@ uint32_t fn_eval_hash(Scope*);...@@ -1445,11 +1445,11 @@ uint32_t fn_eval_hash(Scope*);
1445bool fn_eval_eql(Scope *a, Scope *b);1445bool fn_eval_eql(Scope *a, Scope *b);
14461446
1447struct TypeId {1447struct TypeId {
1448 TypeTableEntryId id;1448 ZigTypeId id;
14491449
1450 union {1450 union {
1451 struct {1451 struct {
1452 TypeTableEntry *child_type;1452 ZigType *child_type;
1453 PtrLen ptr_len;1453 PtrLen ptr_len;
1454 bool is_const;1454 bool is_const;
1455 bool is_volatile;1455 bool is_volatile;
...@@ -1458,7 +1458,7 @@ struct TypeId {...@@ -1458,7 +1458,7 @@ struct TypeId {
1458 uint32_t unaligned_bit_count;1458 uint32_t unaligned_bit_count;
1459 } pointer;1459 } pointer;
1460 struct {1460 struct {
1461 TypeTableEntry *child_type;1461 ZigType *child_type;
1462 uint64_t size;1462 uint64_t size;
1463 } array;1463 } array;
1464 struct {1464 struct {
...@@ -1466,8 +1466,8 @@ struct TypeId {...@@ -1466,8 +1466,8 @@ struct TypeId {
1466 uint32_t bit_count;1466 uint32_t bit_count;
1467 } integer;1467 } integer;
1468 struct {1468 struct {
1469 TypeTableEntry *err_set_type;1469 ZigType *err_set_type;
1470 TypeTableEntry *payload_type;1470 ZigType *payload_type;
1471 } error_union;1471 } error_union;
1472 } data;1472 } data;
1473};1473};
...@@ -1563,9 +1563,9 @@ struct CodeGen {...@@ -1563,9 +1563,9 @@ struct CodeGen {
1563 // reminder: hash tables must be initialized before use1563 // reminder: hash tables must be initialized before use
1564 HashMap<Buf *, ImportTableEntry *, buf_hash, buf_eql_buf> import_table;1564 HashMap<Buf *, ImportTableEntry *, buf_hash, buf_eql_buf> import_table;
1565 HashMap<Buf *, BuiltinFnEntry *, buf_hash, buf_eql_buf> builtin_fn_table;1565 HashMap<Buf *, BuiltinFnEntry *, buf_hash, buf_eql_buf> builtin_fn_table;
1566 HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> primitive_type_table;1566 HashMap<Buf *, ZigType *, buf_hash, buf_eql_buf> primitive_type_table;
1567 HashMap<TypeId, TypeTableEntry *, type_id_hash, type_id_eql> type_table;1567 HashMap<TypeId, ZigType *, type_id_hash, type_id_eql> type_table;
1568 HashMap<FnTypeId *, TypeTableEntry *, fn_type_id_hash, fn_type_id_eql> fn_type_table;1568 HashMap<FnTypeId *, ZigType *, fn_type_id_hash, fn_type_id_eql> fn_type_table;
1569 HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table;1569 HashMap<Buf *, ErrorTableEntry *, buf_hash, buf_eql_buf> error_table;
1570 HashMap<GenericFnTypeId *, FnTableEntry *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;1570 HashMap<GenericFnTypeId *, FnTableEntry *, generic_fn_type_id_hash, generic_fn_type_id_eql> generic_table;
1571 HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;1571 HashMap<Scope *, IrInstruction *, fn_eval_hash, fn_eval_eql> memoized_fn_eval_table;
...@@ -1573,7 +1573,7 @@ struct CodeGen {...@@ -1573,7 +1573,7 @@ struct CodeGen {
1573 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names;1573 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> exported_symbol_names;
1574 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_prototypes;1574 HashMap<Buf *, Tld *, buf_hash, buf_eql_buf> external_prototypes;
1575 HashMap<Buf *, ConstExprValue *, buf_hash, buf_eql_buf> string_literals_table;1575 HashMap<Buf *, ConstExprValue *, buf_hash, buf_eql_buf> string_literals_table;
1576 HashMap<const TypeTableEntry *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache;1576 HashMap<const ZigType *, ConstExprValue *, type_ptr_hash, type_ptr_eql> type_info_cache;
15771577
15781578
1579 ZigList<ImportTableEntry *> import_queue;1579 ZigList<ImportTableEntry *> import_queue;
...@@ -1586,38 +1586,38 @@ struct CodeGen {...@@ -1586,38 +1586,38 @@ struct CodeGen {
1586 uint32_t next_unresolved_index;1586 uint32_t next_unresolved_index;
15871587
1588 struct {1588 struct {
1589 TypeTableEntry *entry_bool;1589 ZigType *entry_bool;
1590 TypeTableEntry *entry_c_int[CIntTypeCount];1590 ZigType *entry_c_int[CIntTypeCount];
1591 TypeTableEntry *entry_c_longdouble;1591 ZigType *entry_c_longdouble;
1592 TypeTableEntry *entry_c_void;1592 ZigType *entry_c_void;
1593 TypeTableEntry *entry_u8;1593 ZigType *entry_u8;
1594 TypeTableEntry *entry_u16;1594 ZigType *entry_u16;
1595 TypeTableEntry *entry_u32;1595 ZigType *entry_u32;
1596 TypeTableEntry *entry_u29;1596 ZigType *entry_u29;
1597 TypeTableEntry *entry_u64;1597 ZigType *entry_u64;
1598 TypeTableEntry *entry_i8;1598 ZigType *entry_i8;
1599 TypeTableEntry *entry_i32;1599 ZigType *entry_i32;
1600 TypeTableEntry *entry_i64;1600 ZigType *entry_i64;
1601 TypeTableEntry *entry_isize;1601 ZigType *entry_isize;
1602 TypeTableEntry *entry_usize;1602 ZigType *entry_usize;
1603 TypeTableEntry *entry_f16;1603 ZigType *entry_f16;
1604 TypeTableEntry *entry_f32;1604 ZigType *entry_f32;
1605 TypeTableEntry *entry_f64;1605 ZigType *entry_f64;
1606 TypeTableEntry *entry_f128;1606 ZigType *entry_f128;
1607 TypeTableEntry *entry_void;1607 ZigType *entry_void;
1608 TypeTableEntry *entry_unreachable;1608 ZigType *entry_unreachable;
1609 TypeTableEntry *entry_type;1609 ZigType *entry_type;
1610 TypeTableEntry *entry_invalid;1610 ZigType *entry_invalid;
1611 TypeTableEntry *entry_namespace;1611 ZigType *entry_namespace;
1612 TypeTableEntry *entry_block;1612 ZigType *entry_block;
1613 TypeTableEntry *entry_num_lit_int;1613 ZigType *entry_num_lit_int;
1614 TypeTableEntry *entry_num_lit_float;1614 ZigType *entry_num_lit_float;
1615 TypeTableEntry *entry_undef;1615 ZigType *entry_undef;
1616 TypeTableEntry *entry_null;1616 ZigType *entry_null;
1617 TypeTableEntry *entry_var;1617 ZigType *entry_var;
1618 TypeTableEntry *entry_global_error_set;1618 ZigType *entry_global_error_set;
1619 TypeTableEntry *entry_arg_tuple;1619 ZigType *entry_arg_tuple;
1620 TypeTableEntry *entry_promise;1620 ZigType *entry_promise;
1621 } builtin_types;1621 } builtin_types;
16221622
1623 EmitFileType emit_file_type;1623 EmitFileType emit_file_type;
...@@ -1735,11 +1735,11 @@ struct CodeGen {...@@ -1735,11 +1735,11 @@ struct CodeGen {
1735 size_t llvm_argv_len;1735 size_t llvm_argv_len;
17361736
1737 ZigList<FnTableEntry *> test_fns;1737 ZigList<FnTableEntry *> test_fns;
1738 TypeTableEntry *test_fn_type;1738 ZigType *test_fn_type;
17391739
1740 bool each_lib_rpath;1740 bool each_lib_rpath;
17411741
1742 TypeTableEntry *err_tag_type;1742 ZigType *err_tag_type;
1743 ZigList<ZigLLVMDIEnumerator *> err_enumerators;1743 ZigList<ZigLLVMDIEnumerator *> err_enumerators;
1744 ZigList<ErrorTableEntry *> errors_by_index;1744 ZigList<ErrorTableEntry *> errors_by_index;
1745 bool generate_error_name_table;1745 bool generate_error_name_table;
...@@ -1769,9 +1769,9 @@ struct CodeGen {...@@ -1769,9 +1769,9 @@ struct CodeGen {
1769 ZigList<FnTableEntry *> inline_fns;1769 ZigList<FnTableEntry *> inline_fns;
1770 ZigList<AstNode *> tld_ref_source_node_stack;1770 ZigList<AstNode *> tld_ref_source_node_stack;
17711771
1772 TypeTableEntry *align_amt_type;1772 ZigType *align_amt_type;
1773 TypeTableEntry *stack_trace_type;1773 ZigType *stack_trace_type;
1774 TypeTableEntry *ptr_to_stack_trace_type;1774 ZigType *ptr_to_stack_trace_type;
17751775
1776 ZigList<ZigLLVMDIType **> error_di_types;1776 ZigList<ZigLLVMDIType **> error_di_types;
17771777
...@@ -1818,7 +1818,7 @@ struct ErrorTableEntry {...@@ -1818,7 +1818,7 @@ struct ErrorTableEntry {
1818 Buf name;1818 Buf name;
1819 uint32_t value;1819 uint32_t value;
1820 AstNode *decl_node;1820 AstNode *decl_node;
1821 TypeTableEntry *set_with_only_this_in_it;1821 ZigType *set_with_only_this_in_it;
1822 // If we generate a constant error name value for this error, we memoize it here.1822 // If we generate a constant error name value for this error, we memoize it here.
1823 // The type of this is array1823 // The type of this is array
1824 ConstExprValue *cached_error_name_val;1824 ConstExprValue *cached_error_name_val;
...@@ -1862,7 +1862,7 @@ struct ScopeDecls {...@@ -1862,7 +1862,7 @@ struct ScopeDecls {
1862 AstNode *fast_math_set_node;1862 AstNode *fast_math_set_node;
1863 ImportTableEntry *import;1863 ImportTableEntry *import;
1864 // If this is a scope from a container, this is the type entry, otherwise null1864 // If this is a scope from a container, this is the type entry, otherwise null
1865 TypeTableEntry *container_type;1865 ZigType *container_type;
1866};1866};
18671867
1868// This scope comes from a block expression in user code.1868// This scope comes from a block expression in user code.
...@@ -2386,7 +2386,7 @@ struct IrInstructionCast {...@@ -2386,7 +2386,7 @@ struct IrInstructionCast {
2386 IrInstruction base;2386 IrInstruction base;
23872387
2388 IrInstruction *value;2388 IrInstruction *value;
2389 TypeTableEntry *dest_type;2389 ZigType *dest_type;
2390 CastOp cast_op;2390 CastOp cast_op;
2391 LLVMValueRef tmp_ptr;2391 LLVMValueRef tmp_ptr;
2392};2392};
...@@ -2423,7 +2423,7 @@ struct IrInstructionStructInitField {...@@ -2423,7 +2423,7 @@ struct IrInstructionStructInitField {
2423struct IrInstructionStructInit {2423struct IrInstructionStructInit {
2424 IrInstruction base;2424 IrInstruction base;
24252425
2426 TypeTableEntry *struct_type;2426 ZigType *struct_type;
2427 size_t field_count;2427 size_t field_count;
2428 IrInstructionStructInitField *fields;2428 IrInstructionStructInitField *fields;
2429 LLVMValueRef tmp_ptr;2429 LLVMValueRef tmp_ptr;
...@@ -2432,7 +2432,7 @@ struct IrInstructionStructInit {...@@ -2432,7 +2432,7 @@ struct IrInstructionStructInit {
2432struct IrInstructionUnionInit {2432struct IrInstructionUnionInit {
2433 IrInstruction base;2433 IrInstruction base;
24342434
2435 TypeTableEntry *union_type;2435 ZigType *union_type;
2436 TypeUnionField *field;2436 TypeUnionField *field;
2437 IrInstruction *init_value;2437 IrInstruction *init_value;
2438 LLVMValueRef tmp_ptr;2438 LLVMValueRef tmp_ptr;
...@@ -2661,7 +2661,7 @@ struct IrInstructionCmpxchg {...@@ -2661,7 +2661,7 @@ struct IrInstructionCmpxchg {
2661 IrInstruction *failure_order_value;2661 IrInstruction *failure_order_value;
26622662
2663 // if this instruction gets to runtime then we know these values:2663 // if this instruction gets to runtime then we know these values:
2664 TypeTableEntry *type;2664 ZigType *type;
2665 AtomicOrder success_order;2665 AtomicOrder success_order;
2666 AtomicOrder failure_order;2666 AtomicOrder failure_order;
26672667
...@@ -2831,7 +2831,7 @@ struct IrInstructionOverflowOp {...@@ -2831,7 +2831,7 @@ struct IrInstructionOverflowOp {
2831 IrInstruction *op2;2831 IrInstruction *op2;
2832 IrInstruction *result_ptr;2832 IrInstruction *result_ptr;
28332833
2834 TypeTableEntry *result_ptr_type;2834 ZigType *result_ptr_type;
2835};2835};
28362836
2837struct IrInstructionAlignOf {2837struct IrInstructionAlignOf {
src/analyze.cpp+217-217
...@@ -19,12 +19,12 @@...@@ -19,12 +19,12 @@
1919
20static const size_t default_backward_branch_quota = 1000;20static const size_t default_backward_branch_quota = 1000;
2121
22static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type);22static Error resolve_enum_type(CodeGen *g, ZigType *enum_type);
23static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type);23static Error resolve_struct_type(CodeGen *g, ZigType *struct_type);
2424
25static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type);25static Error ATTRIBUTE_MUST_USE resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type);
26static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type);26static Error ATTRIBUTE_MUST_USE resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type);
27static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type);27static Error ATTRIBUTE_MUST_USE resolve_union_zero_bits(CodeGen *g, ZigType *union_type);
28static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);28static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);
2929
30ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {30ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
...@@ -70,13 +70,13 @@ ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *m...@@ -70,13 +70,13 @@ ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *m
70 return err;70 return err;
71}71}
7272
73TypeTableEntry *new_type_table_entry(TypeTableEntryId id) {73ZigType *new_type_table_entry(ZigTypeId id) {
74 TypeTableEntry *entry = allocate<TypeTableEntry>(1);74 ZigType *entry = allocate<ZigType>(1);
75 entry->id = id;75 entry->id = id;
76 return entry;76 return entry;
77}77}
7878
79static ScopeDecls **get_container_scope_ptr(TypeTableEntry *type_entry) {79static ScopeDecls **get_container_scope_ptr(ZigType *type_entry) {
80 if (type_entry->id == TypeTableEntryIdStruct) {80 if (type_entry->id == TypeTableEntryIdStruct) {
81 return &type_entry->data.structure.decls_scope;81 return &type_entry->data.structure.decls_scope;
82 } else if (type_entry->id == TypeTableEntryIdEnum) {82 } else if (type_entry->id == TypeTableEntryIdEnum) {
...@@ -87,7 +87,7 @@ static ScopeDecls **get_container_scope_ptr(TypeTableEntry *type_entry) {...@@ -87,7 +87,7 @@ static ScopeDecls **get_container_scope_ptr(TypeTableEntry *type_entry) {
87 zig_unreachable();87 zig_unreachable();
88}88}
8989
90ScopeDecls *get_container_scope(TypeTableEntry *type_entry) {90ScopeDecls *get_container_scope(ZigType *type_entry) {
91 return *get_container_scope_ptr(type_entry);91 return *get_container_scope_ptr(type_entry);
92}92}
9393
...@@ -97,7 +97,7 @@ void init_scope(Scope *dest, ScopeId id, AstNode *source_node, Scope *parent) {...@@ -97,7 +97,7 @@ void init_scope(Scope *dest, ScopeId id, AstNode *source_node, Scope *parent) {
97 dest->parent = parent;97 dest->parent = parent;
98}98}
9999
100ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, TypeTableEntry *container_type, ImportTableEntry *import) {100ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import) {
101 assert(node == nullptr || node->type == NodeTypeRoot || node->type == NodeTypeContainerDecl || node->type == NodeTypeFnCallExpr);101 assert(node == nullptr || node->type == NodeTypeRoot || node->type == NodeTypeContainerDecl || node->type == NodeTypeFnCallExpr);
102 ScopeDecls *scope = allocate<ScopeDecls>(1);102 ScopeDecls *scope = allocate<ScopeDecls>(1);
103 init_scope(&scope->base, ScopeIdDecls, node, parent);103 init_scope(&scope->base, ScopeIdDecls, node, parent);
...@@ -203,8 +203,8 @@ ImportTableEntry *get_scope_import(Scope *scope) {...@@ -203,8 +203,8 @@ ImportTableEntry *get_scope_import(Scope *scope) {
203 zig_unreachable();203 zig_unreachable();
204}204}
205205
206static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *source_node, Scope *parent_scope) {206static ZigType *new_container_type_entry(ZigTypeId id, AstNode *source_node, Scope *parent_scope) {
207 TypeTableEntry *entry = new_type_table_entry(id);207 ZigType *entry = new_type_table_entry(id);
208 *get_container_scope_ptr(entry) = create_decls_scope(source_node, parent_scope, entry, get_scope_import(parent_scope));208 *get_container_scope_ptr(entry) = create_decls_scope(source_node, parent_scope, entry, get_scope_import(parent_scope));
209 return entry;209 return entry;
210}210}
...@@ -218,7 +218,7 @@ static uint8_t bits_needed_for_unsigned(uint64_t x) {...@@ -218,7 +218,7 @@ static uint8_t bits_needed_for_unsigned(uint64_t x) {
218 return (upper >= x) ? base : (base + 1);218 return (upper >= x) ? base : (base + 1);
219}219}
220220
221AstNode *type_decl_node(TypeTableEntry *type_entry) {221AstNode *type_decl_node(ZigType *type_entry) {
222 switch (type_entry->id) {222 switch (type_entry->id) {
223 case TypeTableEntryIdInvalid:223 case TypeTableEntryIdInvalid:
224 zig_unreachable();224 zig_unreachable();
...@@ -255,7 +255,7 @@ AstNode *type_decl_node(TypeTableEntry *type_entry) {...@@ -255,7 +255,7 @@ AstNode *type_decl_node(TypeTableEntry *type_entry) {
255 zig_unreachable();255 zig_unreachable();
256}256}
257257
258bool type_is_complete(TypeTableEntry *type_entry) {258bool type_is_complete(ZigType *type_entry) {
259 switch (type_entry->id) {259 switch (type_entry->id) {
260 case TypeTableEntryIdInvalid:260 case TypeTableEntryIdInvalid:
261 zig_unreachable();261 zig_unreachable();
...@@ -293,7 +293,7 @@ bool type_is_complete(TypeTableEntry *type_entry) {...@@ -293,7 +293,7 @@ bool type_is_complete(TypeTableEntry *type_entry) {
293 zig_unreachable();293 zig_unreachable();
294}294}
295295
296bool type_has_zero_bits_known(TypeTableEntry *type_entry) {296bool type_has_zero_bits_known(ZigType *type_entry) {
297 switch (type_entry->id) {297 switch (type_entry->id) {
298 case TypeTableEntryIdInvalid:298 case TypeTableEntryIdInvalid:
299 zig_unreachable();299 zig_unreachable();
...@@ -331,7 +331,7 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {...@@ -331,7 +331,7 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
331}331}
332332
333333
334uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {334uint64_t type_size(CodeGen *g, ZigType *type_entry) {
335 assert(type_is_complete(type_entry));335 assert(type_is_complete(type_entry));
336336
337 if (!type_has_bits(type_entry))337 if (!type_has_bits(type_entry))
...@@ -341,7 +341,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {...@@ -341,7 +341,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {
341 uint64_t size_in_bits = type_size_bits(g, type_entry);341 uint64_t size_in_bits = type_size_bits(g, type_entry);
342 return (size_in_bits + 7) / 8;342 return (size_in_bits + 7) / 8;
343 } else if (type_entry->id == TypeTableEntryIdArray) {343 } else if (type_entry->id == TypeTableEntryIdArray) {
344 TypeTableEntry *child_type = type_entry->data.array.child_type;344 ZigType *child_type = type_entry->data.array.child_type;
345 if (child_type->id == TypeTableEntryIdStruct &&345 if (child_type->id == TypeTableEntryIdStruct &&
346 child_type->data.structure.layout == ContainerLayoutPacked)346 child_type->data.structure.layout == ContainerLayoutPacked)
347 {347 {
...@@ -353,7 +353,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {...@@ -353,7 +353,7 @@ uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry) {
353 return LLVMStoreSizeOfType(g->target_data_ref, type_entry->type_ref);353 return LLVMStoreSizeOfType(g->target_data_ref, type_entry->type_ref);
354}354}
355355
356uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {356uint64_t type_size_bits(CodeGen *g, ZigType *type_entry) {
357 assert(type_is_complete(type_entry));357 assert(type_is_complete(type_entry));
358358
359 if (!type_has_bits(type_entry))359 if (!type_has_bits(type_entry))
...@@ -366,7 +366,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {...@@ -366,7 +366,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {
366 }366 }
367 return result;367 return result;
368 } else if (type_entry->id == TypeTableEntryIdArray) {368 } else if (type_entry->id == TypeTableEntryIdArray) {
369 TypeTableEntry *child_type = type_entry->data.array.child_type;369 ZigType *child_type = type_entry->data.array.child_type;
370 if (child_type->id == TypeTableEntryIdStruct &&370 if (child_type->id == TypeTableEntryIdStruct &&
371 child_type->data.structure.layout == ContainerLayoutPacked)371 child_type->data.structure.layout == ContainerLayoutPacked)
372 {372 {
...@@ -377,7 +377,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {...@@ -377,7 +377,7 @@ uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry) {
377 return LLVMSizeOfTypeInBits(g->target_data_ref, type_entry->type_ref);377 return LLVMSizeOfTypeInBits(g->target_data_ref, type_entry->type_ref);
378}378}
379379
380Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry) {380Result<bool> type_is_copyable(CodeGen *g, ZigType *type_entry) {
381 Error err;381 Error err;
382 if ((err = type_ensure_zero_bits_known(g, type_entry)))382 if ((err = type_ensure_zero_bits_known(g, type_entry)))
383 return err;383 return err;
...@@ -394,23 +394,23 @@ Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry) {...@@ -394,23 +394,23 @@ Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry) {
394 return type_entry->is_copyable;394 return type_entry->is_copyable;
395}395}
396396
397static bool is_slice(TypeTableEntry *type) {397static bool is_slice(ZigType *type) {
398 return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;398 return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;
399}399}
400400
401TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) {401ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) {
402 return get_int_type(g, false, bits_needed_for_unsigned(x));402 return get_int_type(g, false, bits_needed_for_unsigned(x));
403}403}
404404
405TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type) {405ZigType *get_promise_type(CodeGen *g, ZigType *result_type) {
406 if (result_type != nullptr && result_type->promise_parent != nullptr) {406 if (result_type != nullptr && result_type->promise_parent != nullptr) {
407 return result_type->promise_parent;407 return result_type->promise_parent;
408 } else if (result_type == nullptr && g->builtin_types.entry_promise != nullptr) {408 } else if (result_type == nullptr && g->builtin_types.entry_promise != nullptr) {
409 return g->builtin_types.entry_promise;409 return g->builtin_types.entry_promise;
410 }410 }
411411
412 TypeTableEntry *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);412 ZigType *u8_ptr_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);
413 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPromise);413 ZigType *entry = new_type_table_entry(TypeTableEntryIdPromise);
414 entry->type_ref = u8_ptr_type->type_ref;414 entry->type_ref = u8_ptr_type->type_ref;
415 entry->zero_bits = false;415 entry->zero_bits = false;
416 entry->data.promise.result_type = result_type;416 entry->data.promise.result_type = result_type;
...@@ -428,14 +428,14 @@ TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type) {...@@ -428,14 +428,14 @@ TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type) {
428 return entry;428 return entry;
429}429}
430430
431TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type, bool is_const,431ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_const,
432 bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count)432 bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count)
433{433{
434 assert(!type_is_invalid(child_type));434 assert(!type_is_invalid(child_type));
435 assert(ptr_len == PtrLenSingle || child_type->id != TypeTableEntryIdOpaque);435 assert(ptr_len == PtrLenSingle || child_type->id != TypeTableEntryIdOpaque);
436436
437 TypeId type_id = {};437 TypeId type_id = {};
438 TypeTableEntry **parent_pointer = nullptr;438 ZigType **parent_pointer = nullptr;
439 uint32_t abi_alignment = get_abi_alignment(g, child_type);439 uint32_t abi_alignment = get_abi_alignment(g, child_type);
440 if (unaligned_bit_count != 0 || is_volatile || byte_alignment != abi_alignment || ptr_len != PtrLenSingle) {440 if (unaligned_bit_count != 0 || is_volatile || byte_alignment != abi_alignment || ptr_len != PtrLenSingle) {
441 type_id.id = TypeTableEntryIdPointer;441 type_id.id = TypeTableEntryIdPointer;
...@@ -461,7 +461,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type...@@ -461,7 +461,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
461461
462 assertNoError(type_ensure_zero_bits_known(g, child_type));462 assertNoError(type_ensure_zero_bits_known(g, child_type));
463463
464 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdPointer);464 ZigType *entry = new_type_table_entry(TypeTableEntryIdPointer);
465 entry->is_copyable = true;465 entry->is_copyable = true;
466466
467 const char *star_str = ptr_len == PtrLenSingle ? "*" : "[*]";467 const char *star_str = ptr_len == PtrLenSingle ? "*" : "[*]";
...@@ -487,7 +487,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type...@@ -487,7 +487,7 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
487 if (is_const || is_volatile || unaligned_bit_count != 0 || byte_alignment != abi_alignment ||487 if (is_const || is_volatile || unaligned_bit_count != 0 || byte_alignment != abi_alignment ||
488 ptr_len != PtrLenSingle)488 ptr_len != PtrLenSingle)
489 {489 {
490 TypeTableEntry *peer_type = get_pointer_to_type(g, child_type, false);490 ZigType *peer_type = get_pointer_to_type(g, child_type, false);
491 entry->type_ref = peer_type->type_ref;491 entry->type_ref = peer_type->type_ref;
492 entry->di_type = peer_type->di_type;492 entry->di_type = peer_type->di_type;
493 } else {493 } else {
...@@ -520,18 +520,18 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type...@@ -520,18 +520,18 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
520 return entry;520 return entry;
521}521}
522522
523TypeTableEntry *get_pointer_to_type(CodeGen *g, TypeTableEntry *child_type, bool is_const) {523ZigType *get_pointer_to_type(CodeGen *g, ZigType *child_type, bool is_const) {
524 return get_pointer_to_type_extra(g, child_type, is_const, false, PtrLenSingle,524 return get_pointer_to_type_extra(g, child_type, is_const, false, PtrLenSingle,
525 get_abi_alignment(g, child_type), 0, 0);525 get_abi_alignment(g, child_type), 0, 0);
526}526}
527527
528TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type) {528ZigType *get_promise_frame_type(CodeGen *g, ZigType *return_type) {
529 if (return_type->promise_frame_parent != nullptr) {529 if (return_type->promise_frame_parent != nullptr) {
530 return return_type->promise_frame_parent;530 return return_type->promise_frame_parent;
531 }531 }
532532
533 TypeTableEntry *atomic_state_type = g->builtin_types.entry_usize;533 ZigType *atomic_state_type = g->builtin_types.entry_usize;
534 TypeTableEntry *result_ptr_type = get_pointer_to_type(g, return_type, false);534 ZigType *result_ptr_type = get_pointer_to_type(g, return_type, false);
535535
536 ZigList<const char *> field_names = {};536 ZigList<const char *> field_names = {};
537 field_names.append(ATOMIC_STATE_FIELD_NAME);537 field_names.append(ATOMIC_STATE_FIELD_NAME);
...@@ -543,7 +543,7 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)...@@ -543,7 +543,7 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
543 field_names.append(RETURN_ADDRESSES_FIELD_NAME);543 field_names.append(RETURN_ADDRESSES_FIELD_NAME);
544 }544 }
545545
546 ZigList<TypeTableEntry *> field_types = {};546 ZigList<ZigType *> field_types = {};
547 field_types.append(atomic_state_type);547 field_types.append(atomic_state_type);
548 field_types.append(return_type);548 field_types.append(return_type);
549 field_types.append(result_ptr_type);549 field_types.append(result_ptr_type);
...@@ -555,20 +555,20 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)...@@ -555,20 +555,20 @@ TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type)
555555
556 assert(field_names.length == field_types.length);556 assert(field_names.length == field_types.length);
557 Buf *name = buf_sprintf("AsyncFramePromise(%s)", buf_ptr(&return_type->name));557 Buf *name = buf_sprintf("AsyncFramePromise(%s)", buf_ptr(&return_type->name));
558 TypeTableEntry *entry = get_struct_type(g, buf_ptr(name), field_names.items, field_types.items, field_names.length);558 ZigType *entry = get_struct_type(g, buf_ptr(name), field_names.items, field_types.items, field_names.length);
559559
560 return_type->promise_frame_parent = entry;560 return_type->promise_frame_parent = entry;
561 return entry;561 return entry;
562}562}
563563
564TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {564ZigType *get_optional_type(CodeGen *g, ZigType *child_type) {
565 if (child_type->optional_parent) {565 if (child_type->optional_parent) {
566 TypeTableEntry *entry = child_type->optional_parent;566 ZigType *entry = child_type->optional_parent;
567 return entry;567 return entry;
568 } else {568 } else {
569 assertNoError(ensure_complete_type(g, child_type));569 assertNoError(ensure_complete_type(g, child_type));
570570
571 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdOptional);571 ZigType *entry = new_type_table_entry(TypeTableEntryIdOptional);
572 assert(child_type->type_ref || child_type->zero_bits);572 assert(child_type->type_ref || child_type->zero_bits);
573 entry->is_copyable = type_is_copyable(g, child_type).unwrap();573 entry->is_copyable = type_is_copyable(g, child_type).unwrap();
574574
...@@ -606,7 +606,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {...@@ -606,7 +606,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
606 uint64_t val_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, child_type->type_ref);606 uint64_t val_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, child_type->type_ref);
607 uint64_t val_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);607 uint64_t val_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
608608
609 TypeTableEntry *bool_type = g->builtin_types.entry_bool;609 ZigType *bool_type = g->builtin_types.entry_bool;
610 uint64_t maybe_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, bool_type->type_ref);610 uint64_t maybe_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, bool_type->type_ref);
611 uint64_t maybe_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, bool_type->type_ref);611 uint64_t maybe_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, bool_type->type_ref);
612 uint64_t maybe_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);612 uint64_t maybe_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);
...@@ -645,7 +645,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {...@@ -645,7 +645,7 @@ TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type) {
645 }645 }
646}646}
647647
648TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *payload_type) {648ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type) {
649 assert(err_set_type->id == TypeTableEntryIdErrorSet);649 assert(err_set_type->id == TypeTableEntryIdErrorSet);
650 assert(!type_is_invalid(payload_type));650 assert(!type_is_invalid(payload_type));
651651
...@@ -659,7 +659,7 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T...@@ -659,7 +659,7 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T
659 return existing_entry->value;659 return existing_entry->value;
660 }660 }
661661
662 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdErrorUnion);662 ZigType *entry = new_type_table_entry(TypeTableEntryIdErrorUnion);
663 entry->is_copyable = true;663 entry->is_copyable = true;
664 assert(payload_type->di_type);664 assert(payload_type->di_type);
665 assertNoError(ensure_complete_type(g, payload_type));665 assertNoError(ensure_complete_type(g, payload_type));
...@@ -740,20 +740,20 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T...@@ -740,20 +740,20 @@ TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, T
740 return entry;740 return entry;
741}741}
742742
743TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t array_size) {743ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size) {
744 TypeId type_id = {};744 TypeId type_id = {};
745 type_id.id = TypeTableEntryIdArray;745 type_id.id = TypeTableEntryIdArray;
746 type_id.data.array.child_type = child_type;746 type_id.data.array.child_type = child_type;
747 type_id.data.array.size = array_size;747 type_id.data.array.size = array_size;
748 auto existing_entry = g->type_table.maybe_get(type_id);748 auto existing_entry = g->type_table.maybe_get(type_id);
749 if (existing_entry) {749 if (existing_entry) {
750 TypeTableEntry *entry = existing_entry->value;750 ZigType *entry = existing_entry->value;
751 return entry;751 return entry;
752 }752 }
753753
754 assertNoError(ensure_complete_type(g, child_type));754 assertNoError(ensure_complete_type(g, child_type));
755755
756 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdArray);756 ZigType *entry = new_type_table_entry(TypeTableEntryIdArray);
757 entry->zero_bits = (array_size == 0) || child_type->zero_bits;757 entry->zero_bits = (array_size == 0) || child_type->zero_bits;
758 entry->is_copyable = false;758 entry->is_copyable = false;
759759
...@@ -780,7 +780,7 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t...@@ -780,7 +780,7 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
780 return entry;780 return entry;
781}781}
782782
783static void slice_type_common_init(CodeGen *g, TypeTableEntry *pointer_type, TypeTableEntry *entry) {783static void slice_type_common_init(CodeGen *g, ZigType *pointer_type, ZigType *entry) {
784 unsigned element_count = 2;784 unsigned element_count = 2;
785 Buf *ptr_field_name = buf_create_from_str("ptr");785 Buf *ptr_field_name = buf_create_from_str("ptr");
786 Buf *len_field_name = buf_create_from_str("len");786 Buf *len_field_name = buf_create_from_str("len");
...@@ -811,16 +811,16 @@ static void slice_type_common_init(CodeGen *g, TypeTableEntry *pointer_type, Typ...@@ -811,16 +811,16 @@ static void slice_type_common_init(CodeGen *g, TypeTableEntry *pointer_type, Typ
811 }811 }
812}812}
813813
814TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {814ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type) {
815 assert(ptr_type->id == TypeTableEntryIdPointer);815 assert(ptr_type->id == TypeTableEntryIdPointer);
816 assert(ptr_type->data.pointer.ptr_len == PtrLenUnknown);816 assert(ptr_type->data.pointer.ptr_len == PtrLenUnknown);
817817
818 TypeTableEntry **parent_pointer = &ptr_type->data.pointer.slice_parent;818 ZigType **parent_pointer = &ptr_type->data.pointer.slice_parent;
819 if (*parent_pointer) {819 if (*parent_pointer) {
820 return *parent_pointer;820 return *parent_pointer;
821 }821 }
822822
823 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdStruct);823 ZigType *entry = new_type_table_entry(TypeTableEntryIdStruct);
824 entry->is_copyable = true;824 entry->is_copyable = true;
825825
826 // replace the & with [] to go from a ptr type name to a slice type name826 // replace the & with [] to go from a ptr type name to a slice type name
...@@ -828,14 +828,14 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {...@@ -828,14 +828,14 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
828 size_t name_offset = (ptr_type->data.pointer.ptr_len == PtrLenSingle) ? 1 : 3;828 size_t name_offset = (ptr_type->data.pointer.ptr_len == PtrLenSingle) ? 1 : 3;
829 buf_appendf(&entry->name, "[]%s", buf_ptr(&ptr_type->name) + name_offset);829 buf_appendf(&entry->name, "[]%s", buf_ptr(&ptr_type->name) + name_offset);
830830
831 TypeTableEntry *child_type = ptr_type->data.pointer.child_type;831 ZigType *child_type = ptr_type->data.pointer.child_type;
832 uint32_t abi_alignment = get_abi_alignment(g, child_type);832 uint32_t abi_alignment = get_abi_alignment(g, child_type);
833 if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile ||833 if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile ||
834 ptr_type->data.pointer.alignment != abi_alignment)834 ptr_type->data.pointer.alignment != abi_alignment)
835 {835 {
836 TypeTableEntry *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,836 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false,
837 PtrLenUnknown, abi_alignment, 0, 0);837 PtrLenUnknown, abi_alignment, 0, 0);
838 TypeTableEntry *peer_slice_type = get_slice_type(g, peer_ptr_type);838 ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
839839
840 slice_type_common_init(g, ptr_type, entry);840 slice_type_common_init(g, ptr_type, entry);
841841
...@@ -852,18 +852,18 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {...@@ -852,18 +852,18 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
852 // If the child type is []const T then we need to make sure the type ref852 // If the child type is []const T then we need to make sure the type ref
853 // and debug info is the same as if the child type were []T.853 // and debug info is the same as if the child type were []T.
854 if (is_slice(child_type)) {854 if (is_slice(child_type)) {
855 TypeTableEntry *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;855 ZigType *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry;
856 assert(child_ptr_type->id == TypeTableEntryIdPointer);856 assert(child_ptr_type->id == TypeTableEntryIdPointer);
857 TypeTableEntry *grand_child_type = child_ptr_type->data.pointer.child_type;857 ZigType *grand_child_type = child_ptr_type->data.pointer.child_type;
858 if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile ||858 if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile ||
859 child_ptr_type->data.pointer.alignment != get_abi_alignment(g, grand_child_type))859 child_ptr_type->data.pointer.alignment != get_abi_alignment(g, grand_child_type))
860 {860 {
861 TypeTableEntry *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,861 ZigType *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false,
862 PtrLenUnknown, get_abi_alignment(g, grand_child_type), 0, 0);862 PtrLenUnknown, get_abi_alignment(g, grand_child_type), 0, 0);
863 TypeTableEntry *bland_child_slice = get_slice_type(g, bland_child_ptr_type);863 ZigType *bland_child_slice = get_slice_type(g, bland_child_ptr_type);
864 TypeTableEntry *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,864 ZigType *peer_ptr_type = get_pointer_to_type_extra(g, bland_child_slice, false, false,
865 PtrLenUnknown, get_abi_alignment(g, bland_child_slice), 0, 0);865 PtrLenUnknown, get_abi_alignment(g, bland_child_slice), 0, 0);
866 TypeTableEntry *peer_slice_type = get_slice_type(g, peer_ptr_type);866 ZigType *peer_slice_type = get_slice_type(g, peer_ptr_type);
867867
868 entry->type_ref = peer_slice_type->type_ref;868 entry->type_ref = peer_slice_type->type_ref;
869 entry->di_type = peer_slice_type->di_type;869 entry->di_type = peer_slice_type->di_type;
...@@ -889,7 +889,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {...@@ -889,7 +889,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
889 };889 };
890 LLVMStructSetBody(entry->type_ref, element_types, 1, false);890 LLVMStructSetBody(entry->type_ref, element_types, 1, false);
891891
892 TypeTableEntry *usize_type = g->builtin_types.entry_usize;892 ZigType *usize_type = g->builtin_types.entry_usize;
893 uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);893 uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);
894 uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);894 uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);
895 uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);895 uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
...@@ -928,7 +928,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {...@@ -928,7 +928,7 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
928 uint64_t ptr_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, ptr_type->type_ref);928 uint64_t ptr_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, ptr_type->type_ref);
929 uint64_t ptr_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);929 uint64_t ptr_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 0);
930930
931 TypeTableEntry *usize_type = g->builtin_types.entry_usize;931 ZigType *usize_type = g->builtin_types.entry_usize;
932 uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);932 uint64_t len_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, usize_type->type_ref);
933 uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);933 uint64_t len_debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, usize_type->type_ref);
934 uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);934 uint64_t len_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, entry->type_ref, 1);
...@@ -971,8 +971,8 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {...@@ -971,8 +971,8 @@ TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type) {
971 return entry;971 return entry;
972}972}
973973
974TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name) {974ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name) {
975 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdOpaque);975 ZigType *entry = new_type_table_entry(TypeTableEntryIdOpaque);
976976
977 buf_init_from_str(&entry->name, name);977 buf_init_from_str(&entry->name, name);
978978
...@@ -991,13 +991,13 @@ TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node,...@@ -991,13 +991,13 @@ TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node,
991 return entry;991 return entry;
992}992}
993993
994TypeTableEntry *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) {994ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry) {
995 TypeTableEntry *fn_type = fn_entry->type_entry;995 ZigType *fn_type = fn_entry->type_entry;
996 assert(fn_type->id == TypeTableEntryIdFn);996 assert(fn_type->id == TypeTableEntryIdFn);
997 if (fn_type->data.fn.bound_fn_parent)997 if (fn_type->data.fn.bound_fn_parent)
998 return fn_type->data.fn.bound_fn_parent;998 return fn_type->data.fn.bound_fn_parent;
999999
1000 TypeTableEntry *bound_fn_type = new_type_table_entry(TypeTableEntryIdBoundFn);1000 ZigType *bound_fn_type = new_type_table_entry(TypeTableEntryIdBoundFn);
1001 bound_fn_type->is_copyable = false;1001 bound_fn_type->is_copyable = false;
1002 bound_fn_type->data.bound_fn.fn_type = fn_type;1002 bound_fn_type->data.bound_fn.fn_type = fn_type;
1003 bound_fn_type->zero_bits = true;1003 bound_fn_type->zero_bits = true;
...@@ -1051,7 +1051,7 @@ static bool calling_convention_allows_zig_types(CallingConvention cc) {...@@ -1051,7 +1051,7 @@ static bool calling_convention_allows_zig_types(CallingConvention cc) {
1051 zig_unreachable();1051 zig_unreachable();
1052}1052}
10531053
1054TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g) {1054ZigType *get_ptr_to_stack_trace_type(CodeGen *g) {
1055 if (g->stack_trace_type == nullptr) {1055 if (g->stack_trace_type == nullptr) {
1056 ConstExprValue *stack_trace_type_val = get_builtin_value(g, "StackTrace");1056 ConstExprValue *stack_trace_type_val = get_builtin_value(g, "StackTrace");
1057 assert(stack_trace_type_val->type->id == TypeTableEntryIdMetaType);1057 assert(stack_trace_type_val->type->id == TypeTableEntryIdMetaType);
...@@ -1061,7 +1061,7 @@ TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g) {...@@ -1061,7 +1061,7 @@ TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g) {
1061 return g->ptr_to_stack_trace_type;1061 return g->ptr_to_stack_trace_type;
1062}1062}
10631063
1064TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {1064ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1065 Error err;1065 Error err;
1066 auto table_entry = g->fn_type_table.maybe_get(fn_type_id);1066 auto table_entry = g->fn_type_table.maybe_get(fn_type_id);
1067 if (table_entry) {1067 if (table_entry) {
...@@ -1075,7 +1075,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1075,7 +1075,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1075 zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447");1075 zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447");
1076 }1076 }
10771077
1078 TypeTableEntry *fn_type = new_type_table_entry(TypeTableEntryIdFn);1078 ZigType *fn_type = new_type_table_entry(TypeTableEntryIdFn);
1079 fn_type->is_copyable = true;1079 fn_type->is_copyable = true;
1080 fn_type->data.fn.fn_type_id = *fn_type_id;1080 fn_type->data.fn.fn_type_id = *fn_type_id;
10811081
...@@ -1094,7 +1094,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1094,7 +1094,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1094 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {1094 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
1095 FnTypeParamInfo *param_info = &fn_type_id->param_info[i];1095 FnTypeParamInfo *param_info = &fn_type_id->param_info[i];
10961096
1097 TypeTableEntry *param_type = param_info->type;1097 ZigType *param_type = param_info->type;
1098 const char *comma = (i == 0) ? "" : ", ";1098 const char *comma = (i == 0) ? "" : ", ";
1099 const char *noalias_str = param_info->is_noalias ? "noalias " : "";1099 const char *noalias_str = param_info->is_noalias ? "noalias " : "";
1100 buf_appendf(&fn_type->name, "%s%s%s", comma, noalias_str, buf_ptr(&param_type->name));1100 buf_appendf(&fn_type->name, "%s%s%s", comma, noalias_str, buf_ptr(&param_type->name));
...@@ -1131,13 +1131,13 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1131,13 +1131,13 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1131 ZigLLVMDIType **param_di_types = allocate<ZigLLVMDIType*>(5 + fn_type_id->param_count);1131 ZigLLVMDIType **param_di_types = allocate<ZigLLVMDIType*>(5 + fn_type_id->param_count);
1132 param_di_types[0] = fn_type_id->return_type->di_type;1132 param_di_types[0] = fn_type_id->return_type->di_type;
1133 size_t gen_param_index = 0;1133 size_t gen_param_index = 0;
1134 TypeTableEntry *gen_return_type;1134 ZigType *gen_return_type;
1135 if (is_async) {1135 if (is_async) {
1136 gen_return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);1136 gen_return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, false);
1137 } else if (!type_has_bits(fn_type_id->return_type)) {1137 } else if (!type_has_bits(fn_type_id->return_type)) {
1138 gen_return_type = g->builtin_types.entry_void;1138 gen_return_type = g->builtin_types.entry_void;
1139 } else if (first_arg_return) {1139 } else if (first_arg_return) {
1140 TypeTableEntry *gen_type = get_pointer_to_type(g, fn_type_id->return_type, false);1140 ZigType *gen_type = get_pointer_to_type(g, fn_type_id->return_type, false);
1141 gen_param_types[gen_param_index] = gen_type->type_ref;1141 gen_param_types[gen_param_index] = gen_type->type_ref;
1142 gen_param_index += 1;1142 gen_param_index += 1;
1143 // after the gen_param_index += 1 because 0 is the return type1143 // after the gen_param_index += 1 because 0 is the return type
...@@ -1149,7 +1149,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1149,7 +1149,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1149 fn_type->data.fn.gen_return_type = gen_return_type;1149 fn_type->data.fn.gen_return_type = gen_return_type;
11501150
1151 if (prefix_arg_error_return_trace) {1151 if (prefix_arg_error_return_trace) {
1152 TypeTableEntry *gen_type = get_ptr_to_stack_trace_type(g);1152 ZigType *gen_type = get_ptr_to_stack_trace_type(g);
1153 gen_param_types[gen_param_index] = gen_type->type_ref;1153 gen_param_types[gen_param_index] = gen_type->type_ref;
1154 gen_param_index += 1;1154 gen_param_index += 1;
1155 // after the gen_param_index += 1 because 0 is the return type1155 // after the gen_param_index += 1 because 0 is the return type
...@@ -1158,7 +1158,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1158,7 +1158,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1158 if (is_async) {1158 if (is_async) {
1159 {1159 {
1160 // async allocator param1160 // async allocator param
1161 TypeTableEntry *gen_type = fn_type_id->async_allocator_type;1161 ZigType *gen_type = fn_type_id->async_allocator_type;
1162 gen_param_types[gen_param_index] = gen_type->type_ref;1162 gen_param_types[gen_param_index] = gen_type->type_ref;
1163 gen_param_index += 1;1163 gen_param_index += 1;
1164 // after the gen_param_index += 1 because 0 is the return type1164 // after the gen_param_index += 1 because 0 is the return type
...@@ -1167,7 +1167,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1167,7 +1167,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
11671167
1168 {1168 {
1169 // error code pointer1169 // error code pointer
1170 TypeTableEntry *gen_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);1170 ZigType *gen_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
1171 gen_param_types[gen_param_index] = gen_type->type_ref;1171 gen_param_types[gen_param_index] = gen_type->type_ref;
1172 gen_param_index += 1;1172 gen_param_index += 1;
1173 // after the gen_param_index += 1 because 0 is the return type1173 // after the gen_param_index += 1 because 0 is the return type
...@@ -1178,7 +1178,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1178,7 +1178,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1178 fn_type->data.fn.gen_param_info = allocate<FnGenParamInfo>(fn_type_id->param_count);1178 fn_type->data.fn.gen_param_info = allocate<FnGenParamInfo>(fn_type_id->param_count);
1179 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {1179 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
1180 FnTypeParamInfo *src_param_info = &fn_type->data.fn.fn_type_id.param_info[i];1180 FnTypeParamInfo *src_param_info = &fn_type->data.fn.fn_type_id.param_info[i];
1181 TypeTableEntry *type_entry = src_param_info->type;1181 ZigType *type_entry = src_param_info->type;
1182 FnGenParamInfo *gen_param_info = &fn_type->data.fn.gen_param_info[i];1182 FnGenParamInfo *gen_param_info = &fn_type->data.fn.gen_param_info[i];
11831183
1184 gen_param_info->src_index = i;1184 gen_param_info->src_index = i;
...@@ -1188,7 +1188,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1188,7 +1188,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1188 return g->builtin_types.entry_invalid;1188 return g->builtin_types.entry_invalid;
11891189
1190 if (type_has_bits(type_entry)) {1190 if (type_has_bits(type_entry)) {
1191 TypeTableEntry *gen_type;1191 ZigType *gen_type;
1192 if (handle_is_ptr(type_entry)) {1192 if (handle_is_ptr(type_entry)) {
1193 gen_type = get_pointer_to_type(g, type_entry, true);1193 gen_type = get_pointer_to_type(g, type_entry, true);
1194 gen_param_info->is_byval = true;1194 gen_param_info->is_byval = true;
...@@ -1219,7 +1219,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1219,7 +1219,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1219 return fn_type;1219 return fn_type;
1220}1220}
12211221
1222static TypeTableEntryId container_to_type(ContainerKind kind) {1222static ZigTypeId container_to_type(ContainerKind kind) {
1223 switch (kind) {1223 switch (kind) {
1224 case ContainerKindStruct:1224 case ContainerKindStruct:
1225 return TypeTableEntryIdStruct;1225 return TypeTableEntryIdStruct;
...@@ -1231,11 +1231,11 @@ static TypeTableEntryId container_to_type(ContainerKind kind) {...@@ -1231,11 +1231,11 @@ static TypeTableEntryId container_to_type(ContainerKind kind) {
1231 zig_unreachable();1231 zig_unreachable();
1232}1232}
12331233
1234TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,1234ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
1235 AstNode *decl_node, const char *name, ContainerLayout layout)1235 AstNode *decl_node, const char *name, ContainerLayout layout)
1236{1236{
1237 TypeTableEntryId type_id = container_to_type(kind);1237 ZigTypeId type_id = container_to_type(kind);
1238 TypeTableEntry *entry = new_container_type_entry(type_id, decl_node, scope);1238 ZigType *entry = new_container_type_entry(type_id, decl_node, scope);
12391239
1240 switch (kind) {1240 switch (kind) {
1241 case ContainerKindStruct:1241 case ContainerKindStruct:
...@@ -1266,14 +1266,14 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi...@@ -1266,14 +1266,14 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi
1266 return entry;1266 return entry;
1267}1267}
12681268
1269static IrInstruction *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, TypeTableEntry *type_entry, Buf *type_name) {1269static IrInstruction *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry, Buf *type_name) {
1270 size_t backward_branch_count = 0;1270 size_t backward_branch_count = 0;
1271 return ir_eval_const_value(g, scope, node, type_entry,1271 return ir_eval_const_value(g, scope, node, type_entry,
1272 &backward_branch_count, default_backward_branch_quota,1272 &backward_branch_count, default_backward_branch_quota,
1273 nullptr, nullptr, node, type_name, nullptr);1273 nullptr, nullptr, node, type_name, nullptr);
1274}1274}
12751275
1276TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {1276ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
1277 IrInstruction *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type, nullptr);1277 IrInstruction *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type, nullptr);
1278 if (result->value.type->id == TypeTableEntryIdInvalid)1278 if (result->value.type->id == TypeTableEntryIdInvalid)
1279 return g->builtin_types.entry_invalid;1279 return g->builtin_types.entry_invalid;
...@@ -1282,8 +1282,8 @@ TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {...@@ -1282,8 +1282,8 @@ TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
1282 return result->value.data.x_type;1282 return result->value.data.x_type;
1283}1283}
12841284
1285TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {1285ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1286 TypeTableEntry *fn_type = new_type_table_entry(TypeTableEntryIdFn);1286 ZigType *fn_type = new_type_table_entry(TypeTableEntryIdFn);
1287 fn_type->is_copyable = false;1287 fn_type->is_copyable = false;
1288 buf_resize(&fn_type->name, 0);1288 buf_resize(&fn_type->name, 0);
1289 if (fn_type->data.fn.fn_type_id.cc == CallingConventionAsync) {1289 if (fn_type->data.fn.fn_type_id.cc == CallingConventionAsync) {
...@@ -1350,9 +1350,9 @@ static bool analyze_const_align(CodeGen *g, Scope *scope, AstNode *node, uint32_...@@ -1350,9 +1350,9 @@ static bool analyze_const_align(CodeGen *g, Scope *scope, AstNode *node, uint32_
1350}1350}
13511351
1352static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **out_buffer) {1352static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **out_buffer) {
1353 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,1353 ZigType *ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
1354 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);1354 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
1355 TypeTableEntry *str_type = get_slice_type(g, ptr_type);1355 ZigType *str_type = get_slice_type(g, ptr_type);
1356 IrInstruction *instr = analyze_const_value(g, scope, node, str_type, nullptr);1356 IrInstruction *instr = analyze_const_value(g, scope, node, str_type, nullptr);
1357 if (type_is_invalid(instr->value.type))1357 if (type_is_invalid(instr->value.type))
1358 return false;1358 return false;
...@@ -1382,7 +1382,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **...@@ -1382,7 +1382,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf **
1382 return true;1382 return true;
1383}1383}
13841384
1385static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {1385static bool type_allowed_in_packed_struct(ZigType *type_entry) {
1386 switch (type_entry->id) {1386 switch (type_entry->id) {
1387 case TypeTableEntryIdInvalid:1387 case TypeTableEntryIdInvalid:
1388 zig_unreachable();1388 zig_unreachable();
...@@ -1415,7 +1415,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {...@@ -1415,7 +1415,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
1415 return type_entry->data.unionation.layout == ContainerLayoutPacked;1415 return type_entry->data.unionation.layout == ContainerLayoutPacked;
1416 case TypeTableEntryIdOptional:1416 case TypeTableEntryIdOptional:
1417 {1417 {
1418 TypeTableEntry *child_type = type_entry->data.maybe.child_type;1418 ZigType *child_type = type_entry->data.maybe.child_type;
1419 return type_is_codegen_pointer(child_type);1419 return type_is_codegen_pointer(child_type);
1420 }1420 }
1421 case TypeTableEntryIdEnum:1421 case TypeTableEntryIdEnum:
...@@ -1424,7 +1424,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {...@@ -1424,7 +1424,7 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
1424 zig_unreachable();1424 zig_unreachable();
1425}1425}
14261426
1427static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {1427static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) {
1428 switch (type_entry->id) {1428 switch (type_entry->id) {
1429 case TypeTableEntryIdInvalid:1429 case TypeTableEntryIdInvalid:
1430 zig_unreachable();1430 zig_unreachable();
...@@ -1471,7 +1471,7 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {...@@ -1471,7 +1471,7 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
1471 return type_entry->data.structure.layout == ContainerLayoutExtern || type_entry->data.structure.layout == ContainerLayoutPacked;1471 return type_entry->data.structure.layout == ContainerLayoutExtern || type_entry->data.structure.layout == ContainerLayoutPacked;
1472 case TypeTableEntryIdOptional:1472 case TypeTableEntryIdOptional:
1473 {1473 {
1474 TypeTableEntry *child_type = type_entry->data.maybe.child_type;1474 ZigType *child_type = type_entry->data.maybe.child_type;
1475 if (child_type->id != TypeTableEntryIdPointer && child_type->id != TypeTableEntryIdFn) {1475 if (child_type->id != TypeTableEntryIdPointer && child_type->id != TypeTableEntryIdFn) {
1476 return false;1476 return false;
1477 }1477 }
...@@ -1485,8 +1485,8 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {...@@ -1485,8 +1485,8 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
1485 zig_unreachable();1485 zig_unreachable();
1486}1486}
14871487
1488TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {1488ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
1489 TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);1489 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
1490 buf_resize(&err_set_type->name, 0);1490 buf_resize(&err_set_type->name, 0);
1491 buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));1491 buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));
1492 err_set_type->is_copyable = true;1492 err_set_type->is_copyable = true;
...@@ -1501,7 +1501,7 @@ TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {...@@ -1501,7 +1501,7 @@ TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry) {
1501 return err_set_type;1501 return err_set_type;
1502}1502}
15031503
1504static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) {1504static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_scope, FnTableEntry *fn_entry) {
1505 assert(proto_node->type == NodeTypeFnProto);1505 assert(proto_node->type == NodeTypeFnProto);
1506 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;1506 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
1507 Error err;1507 Error err;
...@@ -1524,7 +1524,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1524,7 +1524,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1524 return g->builtin_types.entry_invalid;1524 return g->builtin_types.entry_invalid;
1525 }1525 }
1526 if (param_node->data.param_decl.type != nullptr) {1526 if (param_node->data.param_decl.type != nullptr) {
1527 TypeTableEntry *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);1527 ZigType *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
1528 if (type_is_invalid(type_entry)) {1528 if (type_is_invalid(type_entry)) {
1529 return g->builtin_types.entry_invalid;1529 return g->builtin_types.entry_invalid;
1530 }1530 }
...@@ -1557,7 +1557,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1557,7 +1557,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1557 return get_generic_fn_type(g, &fn_type_id);1557 return get_generic_fn_type(g, &fn_type_id);
1558 }1558 }
15591559
1560 TypeTableEntry *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);1560 ZigType *type_entry = analyze_type_expr(g, child_scope, param_node->data.param_decl.type);
1561 if (type_is_invalid(type_entry)) {1561 if (type_is_invalid(type_entry)) {
1562 return g->builtin_types.entry_invalid;1562 return g->builtin_types.entry_invalid;
1563 }1563 }
...@@ -1645,14 +1645,14 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1645,14 +1645,14 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1645 //return get_generic_fn_type(g, &fn_type_id);1645 //return get_generic_fn_type(g, &fn_type_id);
1646 }1646 }
16471647
1648 TypeTableEntry *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type);1648 ZigType *specified_return_type = analyze_type_expr(g, child_scope, fn_proto->return_type);
1649 if (type_is_invalid(specified_return_type)) {1649 if (type_is_invalid(specified_return_type)) {
1650 fn_type_id.return_type = g->builtin_types.entry_invalid;1650 fn_type_id.return_type = g->builtin_types.entry_invalid;
1651 return g->builtin_types.entry_invalid;1651 return g->builtin_types.entry_invalid;
1652 }1652 }
16531653
1654 if (fn_proto->auto_err_set) {1654 if (fn_proto->auto_err_set) {
1655 TypeTableEntry *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);1655 ZigType *inferred_err_set_type = get_auto_err_set_type(g, fn_entry);
1656 fn_type_id.return_type = get_error_union_type(g, inferred_err_set_type, specified_return_type);1656 fn_type_id.return_type = get_error_union_type(g, inferred_err_set_type, specified_return_type);
1657 } else {1657 } else {
1658 fn_type_id.return_type = specified_return_type;1658 fn_type_id.return_type = specified_return_type;
...@@ -1723,7 +1723,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1723,7 +1723,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1723 return get_fn_type(g, &fn_type_id);1723 return get_fn_type(g, &fn_type_id);
1724}1724}
17251725
1726bool type_is_invalid(TypeTableEntry *type_entry) {1726bool type_is_invalid(ZigType *type_entry) {
1727 switch (type_entry->id) {1727 switch (type_entry->id) {
1728 case TypeTableEntryIdInvalid:1728 case TypeTableEntryIdInvalid:
1729 return true;1729 return true;
...@@ -1740,7 +1740,7 @@ bool type_is_invalid(TypeTableEntry *type_entry) {...@@ -1740,7 +1740,7 @@ bool type_is_invalid(TypeTableEntry *type_entry) {
1740}1740}
17411741
17421742
1743static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {1743static Error resolve_enum_type(CodeGen *g, ZigType *enum_type) {
1744 assert(enum_type->id == TypeTableEntryIdEnum);1744 assert(enum_type->id == TypeTableEntryIdEnum);
17451745
1746 if (enum_type->data.enumeration.is_invalid)1746 if (enum_type->data.enumeration.is_invalid)
...@@ -1815,7 +1815,7 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1815,7 +1815,7 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1815 return ErrorNone;1815 return ErrorNone;
1816 }1816 }
18171817
1818 TypeTableEntry *tag_int_type = enum_type->data.enumeration.tag_int_type;1818 ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type;
18191819
1820 // create debug type for tag1820 // create debug type for tag
1821 uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_int_type->type_ref);1821 uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_int_type->type_ref);
...@@ -1834,10 +1834,10 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1834,10 +1834,10 @@ static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1834}1834}
18351835
18361836
1837TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],1837ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
1838 TypeTableEntry *field_types[], size_t field_count)1838 ZigType *field_types[], size_t field_count)
1839{1839{
1840 TypeTableEntry *struct_type = new_type_table_entry(TypeTableEntryIdStruct);1840 ZigType *struct_type = new_type_table_entry(TypeTableEntryIdStruct);
18411841
1842 buf_init_from_str(&struct_type->name, type_name);1842 buf_init_from_str(&struct_type->name, type_name);
18431843
...@@ -1881,7 +1881,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f...@@ -1881,7 +1881,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f
1881 if (type_struct_field->gen_index == SIZE_MAX) {1881 if (type_struct_field->gen_index == SIZE_MAX) {
1882 continue;1882 continue;
1883 }1883 }
1884 TypeTableEntry *field_type = type_struct_field->type_entry;1884 ZigType *field_type = type_struct_field->type_entry;
1885 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);1885 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);
1886 uint64_t debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, field_type->type_ref);1886 uint64_t debug_align_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, field_type->type_ref);
1887 uint64_t debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, type_struct_field->gen_index);1887 uint64_t debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, type_struct_field->gen_index);
...@@ -1913,7 +1913,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f...@@ -1913,7 +1913,7 @@ TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *f
1913 return struct_type;1913 return struct_type;
1914}1914}
19151915
1916static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {1916static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
1917 assert(struct_type->id == TypeTableEntryIdStruct);1917 assert(struct_type->id == TypeTableEntryIdStruct);
19181918
1919 if (struct_type->data.structure.complete)1919 if (struct_type->data.structure.complete)
...@@ -1957,7 +1957,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1957,7 +1957,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
19571957
1958 for (size_t i = 0; i < field_count; i += 1) {1958 for (size_t i = 0; i < field_count; i += 1) {
1959 TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];1959 TypeStructField *type_struct_field = &struct_type->data.structure.fields[i];
1960 TypeTableEntry *field_type = type_struct_field->type_entry;1960 ZigType *field_type = type_struct_field->type_entry;
19611961
1962 if ((err = ensure_complete_type(g, field_type))) {1962 if ((err = ensure_complete_type(g, field_type))) {
1963 struct_type->data.structure.is_invalid = true;1963 struct_type->data.structure.is_invalid = true;
...@@ -2088,12 +2088,12 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -2088,12 +2088,12 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
2088 continue;2088 continue;
2089 }2089 }
20902090
2091 TypeTableEntry *field_type = type_struct_field->type_entry;2091 ZigType *field_type = type_struct_field->type_entry;
20922092
2093 // if the field is a function, actually the debug info should be a pointer.2093 // if the field is a function, actually the debug info should be a pointer.
2094 ZigLLVMDIType *field_di_type;2094 ZigLLVMDIType *field_di_type;
2095 if (field_type->id == TypeTableEntryIdFn) {2095 if (field_type->id == TypeTableEntryIdFn) {
2096 TypeTableEntry *field_ptr_type = get_pointer_to_type(g, field_type, true);2096 ZigType *field_ptr_type = get_pointer_to_type(g, field_type, true);
2097 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_ptr_type->type_ref);2097 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_ptr_type->type_ref);
2098 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_ptr_type->type_ref);2098 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_ptr_type->type_ref);
2099 field_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, field_type->di_type,2099 field_di_type = ZigLLVMCreateDebugPointerType(g->dbuilder, field_type->di_type,
...@@ -2147,7 +2147,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -2147,7 +2147,7 @@ static Error resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
2147 return ErrorNone;2147 return ErrorNone;
2148}2148}
21492149
2150static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {2150static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
2151 assert(union_type->id == TypeTableEntryIdUnion);2151 assert(union_type->id == TypeTableEntryIdUnion);
21522152
2153 if (union_type->data.unionation.complete)2153 if (union_type->data.unionation.complete)
...@@ -2179,7 +2179,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2179,7 +2179,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
2179 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;2179 uint32_t gen_field_count = union_type->data.unionation.gen_field_count;
2180 ZigLLVMDIType **union_inner_di_types = allocate<ZigLLVMDIType*>(gen_field_count);2180 ZigLLVMDIType **union_inner_di_types = allocate<ZigLLVMDIType*>(gen_field_count);
21812181
2182 TypeTableEntry *most_aligned_union_member = nullptr;2182 ZigType *most_aligned_union_member = nullptr;
2183 uint64_t size_of_most_aligned_member_in_bits = 0;2183 uint64_t size_of_most_aligned_member_in_bits = 0;
2184 uint64_t biggest_align_in_bits = 0;2184 uint64_t biggest_align_in_bits = 0;
2185 uint64_t biggest_size_in_bits = 0;2185 uint64_t biggest_size_in_bits = 0;
...@@ -2194,7 +2194,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2194,7 +2194,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
2194 for (uint32_t i = 0; i < field_count; i += 1) {2194 for (uint32_t i = 0; i < field_count; i += 1) {
2195 AstNode *field_node = decl_node->data.container_decl.fields.at(i);2195 AstNode *field_node = decl_node->data.container_decl.fields.at(i);
2196 TypeUnionField *union_field = &union_type->data.unionation.fields[i];2196 TypeUnionField *union_field = &union_type->data.unionation.fields[i];
2197 TypeTableEntry *field_type = union_field->type_entry;2197 ZigType *field_type = union_field->type_entry;
21982198
2199 if ((err = ensure_complete_type(g, field_type))) {2199 if ((err = ensure_complete_type(g, field_type))) {
2200 union_type->data.unionation.is_invalid = true;2200 union_type->data.unionation.is_invalid = true;
...@@ -2259,13 +2259,13 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2259,13 +2259,13 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
22592259
2260 uint64_t padding_in_bits = biggest_size_in_bits - size_of_most_aligned_member_in_bits;2260 uint64_t padding_in_bits = biggest_size_in_bits - size_of_most_aligned_member_in_bits;
22612261
2262 TypeTableEntry *tag_type = union_type->data.unionation.tag_type;2262 ZigType *tag_type = union_type->data.unionation.tag_type;
2263 if (tag_type == nullptr || tag_type->zero_bits) {2263 if (tag_type == nullptr || tag_type->zero_bits) {
2264 assert(most_aligned_union_member != nullptr);2264 assert(most_aligned_union_member != nullptr);
22652265
2266 if (padding_in_bits > 0) {2266 if (padding_in_bits > 0) {
2267 TypeTableEntry *u8_type = get_int_type(g, false, 8);2267 ZigType *u8_type = get_int_type(g, false, 8);
2268 TypeTableEntry *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);2268 ZigType *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
2269 LLVMTypeRef union_element_types[] = {2269 LLVMTypeRef union_element_types[] = {
2270 most_aligned_union_member->type_ref,2270 most_aligned_union_member->type_ref,
2271 padding_array->type_ref,2271 padding_array->type_ref,
...@@ -2295,8 +2295,8 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2295,8 +2295,8 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
22952295
2296 LLVMTypeRef union_type_ref;2296 LLVMTypeRef union_type_ref;
2297 if (padding_in_bits > 0) {2297 if (padding_in_bits > 0) {
2298 TypeTableEntry *u8_type = get_int_type(g, false, 8);2298 ZigType *u8_type = get_int_type(g, false, 8);
2299 TypeTableEntry *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);2299 ZigType *padding_array = get_array_type(g, u8_type, padding_in_bits / 8);
2300 LLVMTypeRef union_element_types[] = {2300 LLVMTypeRef union_element_types[] = {
2301 most_aligned_union_member->type_ref,2301 most_aligned_union_member->type_ref,
2302 padding_array->type_ref,2302 padding_array->type_ref,
...@@ -2319,7 +2319,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2319,7 +2319,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
2319 assert(8*LLVMStoreSizeOfType(g->target_data_ref, union_type_ref) >= biggest_size_in_bits);2319 assert(8*LLVMStoreSizeOfType(g->target_data_ref, union_type_ref) >= biggest_size_in_bits);
23202320
2321 // create llvm type for root struct2321 // create llvm type for root struct
2322 TypeTableEntry *tag_int_type = tag_type->data.enumeration.tag_int_type;2322 ZigType *tag_int_type = tag_type->data.enumeration.tag_int_type;
2323 uint64_t align_of_tag_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, tag_int_type->type_ref);2323 uint64_t align_of_tag_in_bits = 8*LLVMABIAlignmentOfType(g->target_data_ref, tag_int_type->type_ref);
23242324
2325 if (align_of_tag_in_bits >= biggest_align_in_bits) {2325 if (align_of_tag_in_bits >= biggest_align_in_bits) {
...@@ -2387,7 +2387,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {...@@ -2387,7 +2387,7 @@ static Error resolve_union_type(CodeGen *g, TypeTableEntry *union_type) {
2387 return ErrorNone;2387 return ErrorNone;
2388}2388}
23892389
2390static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {2390static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {
2391 assert(enum_type->id == TypeTableEntryIdEnum);2391 assert(enum_type->id == TypeTableEntryIdEnum);
23922392
2393 if (enum_type->data.enumeration.zero_bits_known)2393 if (enum_type->data.enumeration.zero_bits_known)
...@@ -2428,7 +2428,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {...@@ -2428,7 +2428,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
2428 HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> occupied_tag_values = {};2428 HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> occupied_tag_values = {};
2429 occupied_tag_values.init(field_count);2429 occupied_tag_values.init(field_count);
24302430
2431 TypeTableEntry *tag_int_type;2431 ZigType *tag_int_type;
2432 if (enum_type->data.enumeration.layout == ContainerLayoutExtern) {2432 if (enum_type->data.enumeration.layout == ContainerLayoutExtern) {
2433 tag_int_type = get_c_int_type(g, CIntTypeInt);2433 tag_int_type = get_c_int_type(g, CIntTypeInt);
2434 } else {2434 } else {
...@@ -2437,7 +2437,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {...@@ -2437,7 +2437,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
24372437
2438 // TODO: Are extern enums allowed to have an init_arg_expr?2438 // TODO: Are extern enums allowed to have an init_arg_expr?
2439 if (decl_node->data.container_decl.init_arg_expr != nullptr) {2439 if (decl_node->data.container_decl.init_arg_expr != nullptr) {
2440 TypeTableEntry *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr);2440 ZigType *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr);
2441 if (type_is_invalid(wanted_tag_int_type)) {2441 if (type_is_invalid(wanted_tag_int_type)) {
2442 enum_type->data.enumeration.is_invalid = true;2442 enum_type->data.enumeration.is_invalid = true;
2443 } else if (wanted_tag_int_type->id != TypeTableEntryIdInt) {2443 } else if (wanted_tag_int_type->id != TypeTableEntryIdInt) {
...@@ -2550,7 +2550,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {...@@ -2550,7 +2550,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
2550 return ErrorNone;2550 return ErrorNone;
2551}2551}
25522552
2553static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {2553static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
2554 assert(struct_type->id == TypeTableEntryIdStruct);2554 assert(struct_type->id == TypeTableEntryIdStruct);
25552555
2556 Error err;2556 Error err;
...@@ -2614,7 +2614,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {...@@ -2614,7 +2614,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
2614 continue;2614 continue;
2615 }2615 }
26162616
2617 TypeTableEntry *field_type = analyze_type_expr(g, scope, field_node->data.struct_field.type);2617 ZigType *field_type = analyze_type_expr(g, scope, field_node->data.struct_field.type);
2618 type_struct_field->type_entry = field_type;2618 type_struct_field->type_entry = field_type;
2619 type_struct_field->src_index = i;2619 type_struct_field->src_index = i;
2620 type_struct_field->gen_index = SIZE_MAX;2620 type_struct_field->gen_index = SIZE_MAX;
...@@ -2669,7 +2669,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {...@@ -2669,7 +2669,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
2669 return ErrorNone;2669 return ErrorNone;
2670}2670}
26712671
2672static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {2672static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
2673 assert(union_type->id == TypeTableEntryIdUnion);2673 assert(union_type->id == TypeTableEntryIdUnion);
26742674
2675 Error err;2675 Error err;
...@@ -2734,7 +2734,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2734,7 +2734,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
2734 enum_type_node != nullptr;2734 enum_type_node != nullptr;
2735 bool auto_layout = (union_type->data.unionation.layout == ContainerLayoutAuto);2735 bool auto_layout = (union_type->data.unionation.layout == ContainerLayoutAuto);
2736 bool want_safety = (field_count >= 2) && (auto_layout || enum_type_node != nullptr);2736 bool want_safety = (field_count >= 2) && (auto_layout || enum_type_node != nullptr);
2737 TypeTableEntry *tag_type;2737 ZigType *tag_type;
2738 bool create_enum_type = decl_node->data.container_decl.auto_enum || (enum_type_node == nullptr && want_safety);2738 bool create_enum_type = decl_node->data.container_decl.auto_enum || (enum_type_node == nullptr && want_safety);
2739 bool *covered_enum_fields;2739 bool *covered_enum_fields;
2740 ZigLLVMDIEnumerator **di_enumerators;2740 ZigLLVMDIEnumerator **di_enumerators;
...@@ -2744,7 +2744,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2744,7 +2744,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
27442744
2745 di_enumerators = allocate<ZigLLVMDIEnumerator*>(field_count);2745 di_enumerators = allocate<ZigLLVMDIEnumerator*>(field_count);
27462746
2747 TypeTableEntry *tag_int_type;2747 ZigType *tag_int_type;
2748 if (enum_type_node != nullptr) {2748 if (enum_type_node != nullptr) {
2749 tag_int_type = analyze_type_expr(g, scope, enum_type_node);2749 tag_int_type = analyze_type_expr(g, scope, enum_type_node);
2750 if (type_is_invalid(tag_int_type)) {2750 if (type_is_invalid(tag_int_type)) {
...@@ -2779,7 +2779,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2779,7 +2779,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
2779 tag_type->data.enumeration.decls_scope = union_type->data.unionation.decls_scope;2779 tag_type->data.enumeration.decls_scope = union_type->data.unionation.decls_scope;
2780 tag_type->data.enumeration.complete = true;2780 tag_type->data.enumeration.complete = true;
2781 } else if (enum_type_node != nullptr) {2781 } else if (enum_type_node != nullptr) {
2782 TypeTableEntry *enum_type = analyze_type_expr(g, scope, enum_type_node);2782 ZigType *enum_type = analyze_type_expr(g, scope, enum_type_node);
2783 if (type_is_invalid(enum_type)) {2783 if (type_is_invalid(enum_type)) {
2784 union_type->data.unionation.is_invalid = true;2784 union_type->data.unionation.is_invalid = true;
2785 return ErrorSemanticAnalyzeFail;2785 return ErrorSemanticAnalyzeFail;
...@@ -2816,7 +2816,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2816,7 +2816,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
2816 continue;2816 continue;
2817 }2817 }
28182818
2819 TypeTableEntry *field_type;2819 ZigType *field_type;
2820 if (field_node->data.struct_field.type == nullptr) {2820 if (field_node->data.struct_field.type == nullptr) {
2821 if (decl_node->data.container_decl.auto_enum || decl_node->data.container_decl.init_arg_expr != nullptr) {2821 if (decl_node->data.container_decl.auto_enum || decl_node->data.container_decl.init_arg_expr != nullptr) {
2822 field_type = g->builtin_types.entry_void;2822 field_type = g->builtin_types.entry_void;
...@@ -2860,7 +2860,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2860,7 +2860,7 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
2860 // In this first pass we resolve explicit tag values.2860 // In this first pass we resolve explicit tag values.
2861 // In a second pass we will fill in the unspecified ones.2861 // In a second pass we will fill in the unspecified ones.
2862 if (tag_value != nullptr) {2862 if (tag_value != nullptr) {
2863 TypeTableEntry *tag_int_type = tag_type->data.enumeration.tag_int_type;2863 ZigType *tag_int_type = tag_type->data.enumeration.tag_int_type;
2864 IrInstruction *result_inst = analyze_const_value(g, scope, tag_value, tag_int_type, nullptr);2864 IrInstruction *result_inst = analyze_const_value(g, scope, tag_value, tag_int_type, nullptr);
2865 if (result_inst->value.type->id == TypeTableEntryIdInvalid) {2865 if (result_inst->value.type->id == TypeTableEntryIdInvalid) {
2866 union_type->data.unionation.is_invalid = true;2866 union_type->data.unionation.is_invalid = true;
...@@ -3075,7 +3075,7 @@ static bool scope_is_root_decls(Scope *scope) {...@@ -3075,7 +3075,7 @@ static bool scope_is_root_decls(Scope *scope) {
3075 zig_unreachable();3075 zig_unreachable();
3076}3076}
30773077
3078static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntry *fn_type) {3078static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, ZigType *fn_type) {
3079 add_node_error(g, proto_node,3079 add_node_error(g, proto_node,
3080 buf_sprintf("expected 'fn([]const u8, ?*builtin.StackTrace) noreturn', found '%s'",3080 buf_sprintf("expected 'fn([]const u8, ?*builtin.StackTrace) noreturn', found '%s'",
3081 buf_ptr(&fn_type->name)));3081 buf_ptr(&fn_type->name)));
...@@ -3084,30 +3084,30 @@ static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntr...@@ -3084,30 +3084,30 @@ static void wrong_panic_prototype(CodeGen *g, AstNode *proto_node, TypeTableEntr
3084static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) {3084static void typecheck_panic_fn(CodeGen *g, FnTableEntry *panic_fn) {
3085 AstNode *proto_node = panic_fn->proto_node;3085 AstNode *proto_node = panic_fn->proto_node;
3086 assert(proto_node->type == NodeTypeFnProto);3086 assert(proto_node->type == NodeTypeFnProto);
3087 TypeTableEntry *fn_type = panic_fn->type_entry;3087 ZigType *fn_type = panic_fn->type_entry;
3088 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;3088 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
3089 if (fn_type_id->param_count != 2) {3089 if (fn_type_id->param_count != 2) {
3090 return wrong_panic_prototype(g, proto_node, fn_type);3090 return wrong_panic_prototype(g, proto_node, fn_type);
3091 }3091 }
3092 TypeTableEntry *const_u8_ptr = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,3092 ZigType *const_u8_ptr = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
3093 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);3093 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
3094 TypeTableEntry *const_u8_slice = get_slice_type(g, const_u8_ptr);3094 ZigType *const_u8_slice = get_slice_type(g, const_u8_ptr);
3095 if (fn_type_id->param_info[0].type != const_u8_slice) {3095 if (fn_type_id->param_info[0].type != const_u8_slice) {
3096 return wrong_panic_prototype(g, proto_node, fn_type);3096 return wrong_panic_prototype(g, proto_node, fn_type);
3097 }3097 }
30983098
3099 TypeTableEntry *optional_ptr_to_stack_trace_type = get_optional_type(g, get_ptr_to_stack_trace_type(g));3099 ZigType *optional_ptr_to_stack_trace_type = get_optional_type(g, get_ptr_to_stack_trace_type(g));
3100 if (fn_type_id->param_info[1].type != optional_ptr_to_stack_trace_type) {3100 if (fn_type_id->param_info[1].type != optional_ptr_to_stack_trace_type) {
3101 return wrong_panic_prototype(g, proto_node, fn_type);3101 return wrong_panic_prototype(g, proto_node, fn_type);
3102 }3102 }
31033103
3104 TypeTableEntry *actual_return_type = fn_type_id->return_type;3104 ZigType *actual_return_type = fn_type_id->return_type;
3105 if (actual_return_type != g->builtin_types.entry_unreachable) {3105 if (actual_return_type != g->builtin_types.entry_unreachable) {
3106 return wrong_panic_prototype(g, proto_node, fn_type);3106 return wrong_panic_prototype(g, proto_node, fn_type);
3107 }3107 }
3108}3108}
31093109
3110TypeTableEntry *get_test_fn_type(CodeGen *g) {3110ZigType *get_test_fn_type(CodeGen *g) {
3111 if (g->test_fn_type)3111 if (g->test_fn_type)
3112 return g->test_fn_type;3112 return g->test_fn_type;
31133113
...@@ -3280,7 +3280,7 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {...@@ -3280,7 +3280,7 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {
3280 }3280 }
32813281
3282 {3282 {
3283 TypeTableEntry *type = get_primitive_type(g, tld->name);3283 ZigType *type = get_primitive_type(g, tld->name);
3284 if (type != nullptr) {3284 if (type != nullptr) {
3285 add_node_error(g, tld->source_node,3285 add_node_error(g, tld->source_node,
3286 buf_sprintf("declaration shadows type '%s'", buf_ptr(&type->name)));3286 buf_sprintf("declaration shadows type '%s'", buf_ptr(&type->name)));
...@@ -3444,7 +3444,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {...@@ -3444,7 +3444,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
3444}3444}
34453445
3446static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {3446static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {
3447 TypeTableEntry *type_entry = tld_container->type_entry;3447 ZigType *type_entry = tld_container->type_entry;
3448 assert(type_entry);3448 assert(type_entry);
34493449
3450 switch (type_entry->id) {3450 switch (type_entry->id) {
...@@ -3462,7 +3462,7 @@ static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {...@@ -3462,7 +3462,7 @@ static void resolve_decl_container(CodeGen *g, TldContainer *tld_container) {
3462 }3462 }
3463}3463}
34643464
3465TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry) {3465ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry) {
3466 switch (type_entry->id) {3466 switch (type_entry->id) {
3467 case TypeTableEntryIdInvalid:3467 case TypeTableEntryIdInvalid:
3468 return g->builtin_types.entry_invalid;3468 return g->builtin_types.entry_invalid;
...@@ -3526,7 +3526,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent...@@ -3526,7 +3526,7 @@ VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent
3526 add_error_note(g, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));3526 add_error_note(g, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));
3527 variable_entry->value->type = g->builtin_types.entry_invalid;3527 variable_entry->value->type = g->builtin_types.entry_invalid;
3528 } else {3528 } else {
3529 TypeTableEntry *type = get_primitive_type(g, name);3529 ZigType *type = get_primitive_type(g, name);
3530 if (type != nullptr) {3530 if (type != nullptr) {
3531 add_node_error(g, source_node,3531 add_node_error(g, source_node,
3532 buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));3532 buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));
...@@ -3577,9 +3577,9 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {...@@ -3577,9 +3577,9 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
3577 bool is_extern = var_decl->is_extern;3577 bool is_extern = var_decl->is_extern;
3578 bool is_export = var_decl->is_export;3578 bool is_export = var_decl->is_export;
35793579
3580 TypeTableEntry *explicit_type = nullptr;3580 ZigType *explicit_type = nullptr;
3581 if (var_decl->type) {3581 if (var_decl->type) {
3582 TypeTableEntry *proposed_type = analyze_type_expr(g, tld_var->base.parent_scope, var_decl->type);3582 ZigType *proposed_type = analyze_type_expr(g, tld_var->base.parent_scope, var_decl->type);
3583 explicit_type = validate_var_type(g, var_decl->type, proposed_type);3583 explicit_type = validate_var_type(g, var_decl->type, proposed_type);
3584 }3584 }
35853585
...@@ -3597,7 +3597,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {...@@ -3597,7 +3597,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
3597 IrInstruction *init_value = nullptr;3597 IrInstruction *init_value = nullptr;
35983598
3599 // TODO more validation for types that can't be used for export/extern variables3599 // TODO more validation for types that can't be used for export/extern variables
3600 TypeTableEntry *implicit_type = nullptr;3600 ZigType *implicit_type = nullptr;
3601 if (explicit_type && explicit_type->id == TypeTableEntryIdInvalid) {3601 if (explicit_type && explicit_type->id == TypeTableEntryIdInvalid) {
3602 implicit_type = explicit_type;3602 implicit_type = explicit_type;
3603 } else if (var_decl->expr) {3603 } else if (var_decl->expr) {
...@@ -3627,7 +3627,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {...@@ -3627,7 +3627,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
3627 implicit_type = g->builtin_types.entry_invalid;3627 implicit_type = g->builtin_types.entry_invalid;
3628 }3628 }
36293629
3630 TypeTableEntry *type = explicit_type ? explicit_type : implicit_type;3630 ZigType *type = explicit_type ? explicit_type : implicit_type;
3631 assert(type != nullptr); // should have been caught by the parser3631 assert(type != nullptr); // should have been caught by the parser
36323632
3633 ConstExprValue *init_val = init_value ? &init_value->value : create_const_runtime(type);3633 ConstExprValue *init_val = init_value ? &init_value->value : create_const_runtime(type);
...@@ -3789,7 +3789,7 @@ FnTableEntry *scope_get_fn_if_root(Scope *scope) {...@@ -3789,7 +3789,7 @@ FnTableEntry *scope_get_fn_if_root(Scope *scope) {
3789 return nullptr;3789 return nullptr;
3790}3790}
37913791
3792TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) {3792TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) {
3793 assert(enum_type->id == TypeTableEntryIdEnum);3793 assert(enum_type->id == TypeTableEntryIdEnum);
3794 if (enum_type->data.enumeration.src_field_count == 0)3794 if (enum_type->data.enumeration.src_field_count == 0)
3795 return nullptr;3795 return nullptr;
...@@ -3799,7 +3799,7 @@ TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) {...@@ -3799,7 +3799,7 @@ TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) {
3799 return entry->value;3799 return entry->value;
3800}3800}
38013801
3802TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name) {3802TypeStructField *find_struct_type_field(ZigType *type_entry, Buf *name) {
3803 assert(type_entry->id == TypeTableEntryIdStruct);3803 assert(type_entry->id == TypeTableEntryIdStruct);
3804 assert(type_entry->data.structure.complete);3804 assert(type_entry->data.structure.complete);
3805 if (type_entry->data.structure.src_field_count == 0)3805 if (type_entry->data.structure.src_field_count == 0)
...@@ -3810,7 +3810,7 @@ TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name) {...@@ -3810,7 +3810,7 @@ TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name) {
3810 return entry->value;3810 return entry->value;
3811}3811}
38123812
3813TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name) {3813TypeUnionField *find_union_type_field(ZigType *type_entry, Buf *name) {
3814 assert(type_entry->id == TypeTableEntryIdUnion);3814 assert(type_entry->id == TypeTableEntryIdUnion);
3815 assert(type_entry->data.unionation.zero_bits_known);3815 assert(type_entry->data.unionation.zero_bits_known);
3816 if (type_entry->data.unionation.src_field_count == 0)3816 if (type_entry->data.unionation.src_field_count == 0)
...@@ -3821,7 +3821,7 @@ TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name) {...@@ -3821,7 +3821,7 @@ TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name) {
3821 return entry->value;3821 return entry->value;
3822}3822}
38233823
3824TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt *tag) {3824TypeUnionField *find_union_field_by_tag(ZigType *type_entry, const BigInt *tag) {
3825 assert(type_entry->id == TypeTableEntryIdUnion);3825 assert(type_entry->id == TypeTableEntryIdUnion);
3826 assert(type_entry->data.unionation.zero_bits_known);3826 assert(type_entry->data.unionation.zero_bits_known);
3827 for (uint32_t i = 0; i < type_entry->data.unionation.src_field_count; i += 1) {3827 for (uint32_t i = 0; i < type_entry->data.unionation.src_field_count; i += 1) {
...@@ -3833,7 +3833,7 @@ TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt...@@ -3833,7 +3833,7 @@ TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt
3833 return nullptr;3833 return nullptr;
3834}3834}
38353835
3836TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *tag) {3836TypeEnumField *find_enum_field_by_tag(ZigType *enum_type, const BigInt *tag) {
3837 assert(enum_type->data.enumeration.zero_bits_known);3837 assert(enum_type->data.enumeration.zero_bits_known);
3838 for (uint32_t i = 0; i < enum_type->data.enumeration.src_field_count; i += 1) {3838 for (uint32_t i = 0; i < enum_type->data.enumeration.src_field_count; i += 1) {
3839 TypeEnumField *field = &enum_type->data.enumeration.fields[i];3839 TypeEnumField *field = &enum_type->data.enumeration.fields[i];
...@@ -3845,7 +3845,7 @@ TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *t...@@ -3845,7 +3845,7 @@ TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *t
3845}3845}
38463846
38473847
3848static bool is_container(TypeTableEntry *type_entry) {3848static bool is_container(ZigType *type_entry) {
3849 switch (type_entry->id) {3849 switch (type_entry->id) {
3850 case TypeTableEntryIdInvalid:3850 case TypeTableEntryIdInvalid:
3851 zig_unreachable();3851 zig_unreachable();
...@@ -3880,28 +3880,28 @@ static bool is_container(TypeTableEntry *type_entry) {...@@ -3880,28 +3880,28 @@ static bool is_container(TypeTableEntry *type_entry) {
3880 zig_unreachable();3880 zig_unreachable();
3881}3881}
38823882
3883bool is_ref(TypeTableEntry *type_entry) {3883bool is_ref(ZigType *type_entry) {
3884 return type_entry->id == TypeTableEntryIdPointer && type_entry->data.pointer.ptr_len == PtrLenSingle;3884 return type_entry->id == TypeTableEntryIdPointer && type_entry->data.pointer.ptr_len == PtrLenSingle;
3885}3885}
38863886
3887bool is_array_ref(TypeTableEntry *type_entry) {3887bool is_array_ref(ZigType *type_entry) {
3888 TypeTableEntry *array = is_ref(type_entry) ?3888 ZigType *array = is_ref(type_entry) ?
3889 type_entry->data.pointer.child_type : type_entry;3889 type_entry->data.pointer.child_type : type_entry;
3890 return array->id == TypeTableEntryIdArray;3890 return array->id == TypeTableEntryIdArray;
3891}3891}
38923892
3893bool is_container_ref(TypeTableEntry *type_entry) {3893bool is_container_ref(ZigType *type_entry) {
3894 return is_ref(type_entry) ?3894 return is_ref(type_entry) ?
3895 is_container(type_entry->data.pointer.child_type) : is_container(type_entry);3895 is_container(type_entry->data.pointer.child_type) : is_container(type_entry);
3896}3896}
38973897
3898TypeTableEntry *container_ref_type(TypeTableEntry *type_entry) {3898ZigType *container_ref_type(ZigType *type_entry) {
3899 assert(is_container_ref(type_entry));3899 assert(is_container_ref(type_entry));
3900 return is_ref(type_entry) ?3900 return is_ref(type_entry) ?
3901 type_entry->data.pointer.child_type : type_entry;3901 type_entry->data.pointer.child_type : type_entry;
3902}3902}
39033903
3904void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {3904void resolve_container_type(CodeGen *g, ZigType *type_entry) {
3905 switch (type_entry->id) {3905 switch (type_entry->id) {
3906 case TypeTableEntryIdStruct:3906 case TypeTableEntryIdStruct:
3907 resolve_struct_type(g, type_entry);3907 resolve_struct_type(g, type_entry);
...@@ -3939,7 +3939,7 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {...@@ -3939,7 +3939,7 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
3939 }3939 }
3940}3940}
39413941
3942TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {3942ZigType *get_codegen_ptr_type(ZigType *type) {
3943 if (type->id == TypeTableEntryIdPointer) return type;3943 if (type->id == TypeTableEntryIdPointer) return type;
3944 if (type->id == TypeTableEntryIdFn) return type;3944 if (type->id == TypeTableEntryIdFn) return type;
3945 if (type->id == TypeTableEntryIdPromise) return type;3945 if (type->id == TypeTableEntryIdPromise) return type;
...@@ -3951,12 +3951,12 @@ TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {...@@ -3951,12 +3951,12 @@ TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {
3951 return nullptr;3951 return nullptr;
3952}3952}
39533953
3954bool type_is_codegen_pointer(TypeTableEntry *type) {3954bool type_is_codegen_pointer(ZigType *type) {
3955 return get_codegen_ptr_type(type) == type;3955 return get_codegen_ptr_type(type) == type;
3956}3956}
39573957
3958uint32_t get_ptr_align(TypeTableEntry *type) {3958uint32_t get_ptr_align(ZigType *type) {
3959 TypeTableEntry *ptr_type = get_codegen_ptr_type(type);3959 ZigType *ptr_type = get_codegen_ptr_type(type);
3960 if (ptr_type->id == TypeTableEntryIdPointer) {3960 if (ptr_type->id == TypeTableEntryIdPointer) {
3961 return ptr_type->data.pointer.alignment;3961 return ptr_type->data.pointer.alignment;
3962 } else if (ptr_type->id == TypeTableEntryIdFn) {3962 } else if (ptr_type->id == TypeTableEntryIdFn) {
...@@ -3968,8 +3968,8 @@ uint32_t get_ptr_align(TypeTableEntry *type) {...@@ -3968,8 +3968,8 @@ uint32_t get_ptr_align(TypeTableEntry *type) {
3968 }3968 }
3969}3969}
39703970
3971bool get_ptr_const(TypeTableEntry *type) {3971bool get_ptr_const(ZigType *type) {
3972 TypeTableEntry *ptr_type = get_codegen_ptr_type(type);3972 ZigType *ptr_type = get_codegen_ptr_type(type);
3973 if (ptr_type->id == TypeTableEntryIdPointer) {3973 if (ptr_type->id == TypeTableEntryIdPointer) {
3974 return ptr_type->data.pointer.is_const;3974 return ptr_type->data.pointer.is_const;
3975 } else if (ptr_type->id == TypeTableEntryIdFn) {3975 } else if (ptr_type->id == TypeTableEntryIdFn) {
...@@ -3991,7 +3991,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {...@@ -3991,7 +3991,7 @@ AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {
3991}3991}
39923992
3993static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) {3993static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entry) {
3994 TypeTableEntry *fn_type = fn_table_entry->type_entry;3994 ZigType *fn_type = fn_table_entry->type_entry;
3995 assert(!fn_type->data.fn.is_generic);3995 assert(!fn_type->data.fn.is_generic);
3996 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;3996 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
3997 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {3997 for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
...@@ -4008,7 +4008,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr...@@ -4008,7 +4008,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
4008 continue;4008 continue;
4009 }4009 }
40104010
4011 TypeTableEntry *param_type = param_info->type;4011 ZigType *param_type = param_info->type;
4012 bool is_noalias = param_info->is_noalias;4012 bool is_noalias = param_info->is_noalias;
40134013
4014 if (is_noalias && get_codegen_ptr_type(param_type) == nullptr) {4014 if (is_noalias && get_codegen_ptr_type(param_type) == nullptr) {
...@@ -4031,7 +4031,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr...@@ -4031,7 +4031,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
4031 }4031 }
4032}4032}
40334033
4034bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node) {4034bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) {
4035 FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;4035 FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;
4036 if (infer_fn != nullptr) {4036 if (infer_fn != nullptr) {
4037 if (infer_fn->anal_state == FnAnalStateInvalid) {4037 if (infer_fn->anal_state == FnAnalStateInvalid) {
...@@ -4053,11 +4053,11 @@ bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNod...@@ -4053,11 +4053,11 @@ bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNod
4053}4053}
40544054
4055void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) {4055void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node) {
4056 TypeTableEntry *fn_type = fn_table_entry->type_entry;4056 ZigType *fn_type = fn_table_entry->type_entry;
4057 assert(!fn_type->data.fn.is_generic);4057 assert(!fn_type->data.fn.is_generic);
4058 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;4058 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
40594059
4060 TypeTableEntry *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable,4060 ZigType *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable,
4061 &fn_table_entry->analyzed_executable, fn_type_id->return_type, return_type_node);4061 &fn_table_entry->analyzed_executable, fn_type_id->return_type, return_type_node);
4062 fn_table_entry->src_implicit_return_type = block_return_type;4062 fn_table_entry->src_implicit_return_type = block_return_type;
40634063
...@@ -4068,9 +4068,9 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ...@@ -4068,9 +4068,9 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ
4068 }4068 }
40694069
4070 if (fn_type_id->return_type->id == TypeTableEntryIdErrorUnion) {4070 if (fn_type_id->return_type->id == TypeTableEntryIdErrorUnion) {
4071 TypeTableEntry *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type;4071 ZigType *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type;
4072 if (return_err_set_type->data.error_set.infer_fn != nullptr) {4072 if (return_err_set_type->data.error_set.infer_fn != nullptr) {
4073 TypeTableEntry *inferred_err_set_type;4073 ZigType *inferred_err_set_type;
4074 if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorSet) {4074 if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorSet) {
4075 inferred_err_set_type = fn_table_entry->src_implicit_return_type;4075 inferred_err_set_type = fn_table_entry->src_implicit_return_type;
4076 } else if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorUnion) {4076 } else if (fn_table_entry->src_implicit_return_type->id == TypeTableEntryIdErrorUnion) {
...@@ -4129,7 +4129,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -4129,7 +4129,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
41294129
4130 define_local_param_variables(g, fn_table_entry);4130 define_local_param_variables(g, fn_table_entry);
41314131
4132 TypeTableEntry *fn_type = fn_table_entry->type_entry;4132 ZigType *fn_type = fn_table_entry->type_entry;
4133 assert(!fn_type->data.fn.is_generic);4133 assert(!fn_type->data.fn.is_generic);
41344134
4135 ir_gen_fn(g, fn_table_entry);4135 ir_gen_fn(g, fn_table_entry);
...@@ -4355,7 +4355,7 @@ void semantic_analyze(CodeGen *g) {...@@ -4355,7 +4355,7 @@ void semantic_analyze(CodeGen *g) {
4355 }4355 }
4356}4356}
43574357
4358TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {4358ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
4359 TypeId type_id = {};4359 TypeId type_id = {};
4360 type_id.id = TypeTableEntryIdInt;4360 type_id.id = TypeTableEntryIdInt;
4361 type_id.data.integer.is_signed = is_signed;4361 type_id.data.integer.is_signed = is_signed;
...@@ -4367,20 +4367,20 @@ TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits)...@@ -4367,20 +4367,20 @@ TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits)
4367 return entry->value;4367 return entry->value;
4368 }4368 }
43694369
4370 TypeTableEntry *new_entry = make_int_type(g, is_signed, size_in_bits);4370 ZigType *new_entry = make_int_type(g, is_signed, size_in_bits);
4371 g->type_table.put(type_id, new_entry);4371 g->type_table.put(type_id, new_entry);
4372 return new_entry;4372 return new_entry;
4373}4373}
43744374
4375TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type) {4375ZigType **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type) {
4376 return &g->builtin_types.entry_c_int[c_int_type];4376 return &g->builtin_types.entry_c_int[c_int_type];
4377}4377}
43784378
4379TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type) {4379ZigType *get_c_int_type(CodeGen *g, CIntType c_int_type) {
4380 return *get_c_int_type_ptr(g, c_int_type);4380 return *get_c_int_type_ptr(g, c_int_type);
4381}4381}
43824382
4383bool handle_is_ptr(TypeTableEntry *type_entry) {4383bool handle_is_ptr(ZigType *type_entry) {
4384 switch (type_entry->id) {4384 switch (type_entry->id) {
4385 case TypeTableEntryIdInvalid:4385 case TypeTableEntryIdInvalid:
4386 case TypeTableEntryIdMetaType:4386 case TypeTableEntryIdMetaType:
...@@ -4916,7 +4916,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {...@@ -4916,7 +4916,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
4916 zig_unreachable();4916 zig_unreachable();
4917}4917}
49184918
4919static bool return_type_is_cacheable(TypeTableEntry *return_type) {4919static bool return_type_is_cacheable(ZigType *return_type) {
4920 switch (return_type->id) {4920 switch (return_type->id) {
4921 case TypeTableEntryIdInvalid:4921 case TypeTableEntryIdInvalid:
4922 zig_unreachable();4922 zig_unreachable();
...@@ -4958,7 +4958,7 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {...@@ -4958,7 +4958,7 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {
4958 zig_unreachable();4958 zig_unreachable();
4959}4959}
49604960
4961bool fn_eval_cacheable(Scope *scope, TypeTableEntry *return_type) {4961bool fn_eval_cacheable(Scope *scope, ZigType *return_type) {
4962 if (!return_type_is_cacheable(return_type))4962 if (!return_type_is_cacheable(return_type))
4963 return false;4963 return false;
4964 while (scope) {4964 while (scope) {
...@@ -5027,14 +5027,14 @@ bool fn_eval_eql(Scope *a, Scope *b) {...@@ -5027,14 +5027,14 @@ bool fn_eval_eql(Scope *a, Scope *b) {
5027 return false;5027 return false;
5028}5028}
50295029
5030bool type_has_bits(TypeTableEntry *type_entry) {5030bool type_has_bits(ZigType *type_entry) {
5031 assert(type_entry);5031 assert(type_entry);
5032 assert(type_entry->id != TypeTableEntryIdInvalid);5032 assert(type_entry->id != TypeTableEntryIdInvalid);
5033 assert(type_has_zero_bits_known(type_entry));5033 assert(type_has_zero_bits_known(type_entry));
5034 return !type_entry->zero_bits;5034 return !type_entry->zero_bits;
5035}5035}
50365036
5037bool type_requires_comptime(TypeTableEntry *type_entry) {5037bool type_requires_comptime(ZigType *type_entry) {
5038 switch (type_entry->id) {5038 switch (type_entry->id) {
5039 case TypeTableEntryIdInvalid:5039 case TypeTableEntryIdInvalid:
5040 case TypeTableEntryIdOpaque:5040 case TypeTableEntryIdOpaque:
...@@ -5143,27 +5143,27 @@ ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *str) {...@@ -5143,27 +5143,27 @@ ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *str) {
5143 return const_val;5143 return const_val;
5144}5144}
51455145
5146void init_const_bigint(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *bigint) {5146void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint) {
5147 const_val->special = ConstValSpecialStatic;5147 const_val->special = ConstValSpecialStatic;
5148 const_val->type = type;5148 const_val->type = type;
5149 bigint_init_bigint(&const_val->data.x_bigint, bigint);5149 bigint_init_bigint(&const_val->data.x_bigint, bigint);
5150}5150}
51515151
5152ConstExprValue *create_const_bigint(TypeTableEntry *type, const BigInt *bigint) {5152ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint) {
5153 ConstExprValue *const_val = create_const_vals(1);5153 ConstExprValue *const_val = create_const_vals(1);
5154 init_const_bigint(const_val, type, bigint);5154 init_const_bigint(const_val, type, bigint);
5155 return const_val;5155 return const_val;
5156}5156}
51575157
51585158
5159void init_const_unsigned_negative(ConstExprValue *const_val, TypeTableEntry *type, uint64_t x, bool negative) {5159void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative) {
5160 const_val->special = ConstValSpecialStatic;5160 const_val->special = ConstValSpecialStatic;
5161 const_val->type = type;5161 const_val->type = type;
5162 bigint_init_unsigned(&const_val->data.x_bigint, x);5162 bigint_init_unsigned(&const_val->data.x_bigint, x);
5163 const_val->data.x_bigint.is_negative = negative;5163 const_val->data.x_bigint.is_negative = negative;
5164}5164}
51655165
5166ConstExprValue *create_const_unsigned_negative(TypeTableEntry *type, uint64_t x, bool negative) {5166ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative) {
5167 ConstExprValue *const_val = create_const_vals(1);5167 ConstExprValue *const_val = create_const_vals(1);
5168 init_const_unsigned_negative(const_val, type, x, negative);5168 init_const_unsigned_negative(const_val, type, x, negative);
5169 return const_val;5169 return const_val;
...@@ -5177,19 +5177,19 @@ ConstExprValue *create_const_usize(CodeGen *g, uint64_t x) {...@@ -5177,19 +5177,19 @@ ConstExprValue *create_const_usize(CodeGen *g, uint64_t x) {
5177 return create_const_unsigned_negative(g->builtin_types.entry_usize, x, false);5177 return create_const_unsigned_negative(g->builtin_types.entry_usize, x, false);
5178}5178}
51795179
5180void init_const_signed(ConstExprValue *const_val, TypeTableEntry *type, int64_t x) {5180void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x) {
5181 const_val->special = ConstValSpecialStatic;5181 const_val->special = ConstValSpecialStatic;
5182 const_val->type = type;5182 const_val->type = type;
5183 bigint_init_signed(&const_val->data.x_bigint, x);5183 bigint_init_signed(&const_val->data.x_bigint, x);
5184}5184}
51855185
5186ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x) {5186ConstExprValue *create_const_signed(ZigType *type, int64_t x) {
5187 ConstExprValue *const_val = create_const_vals(1);5187 ConstExprValue *const_val = create_const_vals(1);
5188 init_const_signed(const_val, type, x);5188 init_const_signed(const_val, type, x);
5189 return const_val;5189 return const_val;
5190}5190}
51915191
5192void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value) {5192void init_const_float(ConstExprValue *const_val, ZigType *type, double value) {
5193 const_val->special = ConstValSpecialStatic;5193 const_val->special = ConstValSpecialStatic;
5194 const_val->type = type;5194 const_val->type = type;
5195 if (type->id == TypeTableEntryIdComptimeFloat) {5195 if (type->id == TypeTableEntryIdComptimeFloat) {
...@@ -5216,19 +5216,19 @@ void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double va...@@ -5216,19 +5216,19 @@ void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double va
5216 }5216 }
5217}5217}
52185218
5219ConstExprValue *create_const_float(TypeTableEntry *type, double value) {5219ConstExprValue *create_const_float(ZigType *type, double value) {
5220 ConstExprValue *const_val = create_const_vals(1);5220 ConstExprValue *const_val = create_const_vals(1);
5221 init_const_float(const_val, type, value);5221 init_const_float(const_val, type, value);
5222 return const_val;5222 return const_val;
5223}5223}
52245224
5225void init_const_enum(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *tag) {5225void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag) {
5226 const_val->special = ConstValSpecialStatic;5226 const_val->special = ConstValSpecialStatic;
5227 const_val->type = type;5227 const_val->type = type;
5228 bigint_init_bigint(&const_val->data.x_enum_tag, tag);5228 bigint_init_bigint(&const_val->data.x_enum_tag, tag);
5229}5229}
52305230
5231ConstExprValue *create_const_enum(TypeTableEntry *type, const BigInt *tag) {5231ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag) {
5232 ConstExprValue *const_val = create_const_vals(1);5232 ConstExprValue *const_val = create_const_vals(1);
5233 init_const_enum(const_val, type, tag);5233 init_const_enum(const_val, type, tag);
5234 return const_val;5234 return const_val;
...@@ -5247,24 +5247,24 @@ ConstExprValue *create_const_bool(CodeGen *g, bool value) {...@@ -5247,24 +5247,24 @@ ConstExprValue *create_const_bool(CodeGen *g, bool value) {
5247 return const_val;5247 return const_val;
5248}5248}
52495249
5250void init_const_runtime(ConstExprValue *const_val, TypeTableEntry *type) {5250void init_const_runtime(ConstExprValue *const_val, ZigType *type) {
5251 const_val->special = ConstValSpecialRuntime;5251 const_val->special = ConstValSpecialRuntime;
5252 const_val->type = type;5252 const_val->type = type;
5253}5253}
52545254
5255ConstExprValue *create_const_runtime(TypeTableEntry *type) {5255ConstExprValue *create_const_runtime(ZigType *type) {
5256 ConstExprValue *const_val = create_const_vals(1);5256 ConstExprValue *const_val = create_const_vals(1);
5257 init_const_runtime(const_val, type);5257 init_const_runtime(const_val, type);
5258 return const_val;5258 return const_val;
5259}5259}
52605260
5261void init_const_type(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *type_value) {5261void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value) {
5262 const_val->special = ConstValSpecialStatic;5262 const_val->special = ConstValSpecialStatic;
5263 const_val->type = g->builtin_types.entry_type;5263 const_val->type = g->builtin_types.entry_type;
5264 const_val->data.x_type = type_value;5264 const_val->data.x_type = type_value;
5265}5265}
52665266
5267ConstExprValue *create_const_type(CodeGen *g, TypeTableEntry *type_value) {5267ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value) {
5268 ConstExprValue *const_val = create_const_vals(1);5268 ConstExprValue *const_val = create_const_vals(1);
5269 init_const_type(g, const_val, type_value);5269 init_const_type(g, const_val, type_value);
5270 return const_val;5270 return const_val;
...@@ -5275,7 +5275,7 @@ void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *arr...@@ -5275,7 +5275,7 @@ void init_const_slice(CodeGen *g, ConstExprValue *const_val, ConstExprValue *arr
5275{5275{
5276 assert(array_val->type->id == TypeTableEntryIdArray);5276 assert(array_val->type->id == TypeTableEntryIdArray);
52775277
5278 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, array_val->type->data.array.child_type,5278 ZigType *ptr_type = get_pointer_to_type_extra(g, array_val->type->data.array.child_type,
5279 is_const, false, PtrLenUnknown, get_abi_alignment(g, array_val->type->data.array.child_type),5279 is_const, false, PtrLenUnknown, get_abi_alignment(g, array_val->type->data.array.child_type),
5280 0, 0);5280 0, 0);
52815281
...@@ -5298,7 +5298,7 @@ void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue...@@ -5298,7 +5298,7 @@ void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue
5298 size_t elem_index, bool is_const, PtrLen ptr_len)5298 size_t elem_index, bool is_const, PtrLen ptr_len)
5299{5299{
5300 assert(array_val->type->id == TypeTableEntryIdArray);5300 assert(array_val->type->id == TypeTableEntryIdArray);
5301 TypeTableEntry *child_type = array_val->type->data.array.child_type;5301 ZigType *child_type = array_val->type->data.array.child_type;
53025302
5303 const_val->special = ConstValSpecialStatic;5303 const_val->special = ConstValSpecialStatic;
5304 const_val->type = get_pointer_to_type_extra(g, child_type, is_const, false,5304 const_val->type = get_pointer_to_type_extra(g, child_type, is_const, false,
...@@ -5329,7 +5329,7 @@ ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bo...@@ -5329,7 +5329,7 @@ ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bo
5329 return const_val;5329 return const_val;
5330}5330}
53315331
5332void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *pointee_type,5332void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
5333 size_t addr, bool is_const)5333 size_t addr, bool is_const)
5334{5334{
5335 const_val->special = ConstValSpecialStatic;5335 const_val->special = ConstValSpecialStatic;
...@@ -5338,7 +5338,7 @@ void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeT...@@ -5338,7 +5338,7 @@ void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeT
5338 const_val->data.x_ptr.data.hard_coded_addr.addr = addr;5338 const_val->data.x_ptr.data.hard_coded_addr.addr = addr;
5339}5339}
53405340
5341ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, TypeTableEntry *pointee_type,5341ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
5342 size_t addr, bool is_const)5342 size_t addr, bool is_const)
5343{5343{
5344 ConstExprValue *const_val = create_const_vals(1);5344 ConstExprValue *const_val = create_const_vals(1);
...@@ -5362,7 +5362,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_...@@ -5362,7 +5362,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_
53625362
5363void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {5363void init_const_undefined(CodeGen *g, ConstExprValue *const_val) {
5364 Error err;5364 Error err;
5365 TypeTableEntry *wanted_type = const_val->type;5365 ZigType *wanted_type = const_val->type;
5366 if (wanted_type->id == TypeTableEntryIdArray) {5366 if (wanted_type->id == TypeTableEntryIdArray) {
5367 const_val->special = ConstValSpecialStatic;5367 const_val->special = ConstValSpecialStatic;
5368 const_val->data.x_array.special = ConstArraySpecialUndef;5368 const_val->data.x_array.special = ConstArraySpecialUndef;
...@@ -5400,7 +5400,7 @@ ConstExprValue *create_const_vals(size_t count) {...@@ -5400,7 +5400,7 @@ ConstExprValue *create_const_vals(size_t count) {
5400 return vals;5400 return vals;
5401}5401}
54025402
5403Error ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {5403Error ensure_complete_type(CodeGen *g, ZigType *type_entry) {
5404 if (type_is_invalid(type_entry))5404 if (type_is_invalid(type_entry))
5405 return ErrorSemanticAnalyzeFail;5405 return ErrorSemanticAnalyzeFail;
5406 if (type_entry->id == TypeTableEntryIdStruct) {5406 if (type_entry->id == TypeTableEntryIdStruct) {
...@@ -5416,7 +5416,7 @@ Error ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {...@@ -5416,7 +5416,7 @@ Error ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry) {
5416 return ErrorNone;5416 return ErrorNone;
5417}5417}
54185418
5419Error type_ensure_zero_bits_known(CodeGen *g, TypeTableEntry *type_entry) {5419Error type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry) {
5420 if (type_is_invalid(type_entry))5420 if (type_is_invalid(type_entry))
5421 return ErrorSemanticAnalyzeFail;5421 return ErrorSemanticAnalyzeFail;
5422 if (type_entry->id == TypeTableEntryIdStruct) {5422 if (type_entry->id == TypeTableEntryIdStruct) {
...@@ -5591,7 +5591,7 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {...@@ -5591,7 +5591,7 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
5591 zig_unreachable();5591 zig_unreachable();
5592}5592}
55935593
5594void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint, bool is_max) {5594void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max) {
5595 assert(int_type->id == TypeTableEntryIdInt);5595 assert(int_type->id == TypeTableEntryIdInt);
5596 if (int_type->data.integral.bit_count == 0) {5596 if (int_type->data.integral.bit_count == 0) {
5597 bigint_init_unsigned(bigint, 0);5597 bigint_init_unsigned(bigint, 0);
...@@ -5628,7 +5628,7 @@ void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint...@@ -5628,7 +5628,7 @@ void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint
5628 }5628 }
5629}5629}
56305630
5631void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *const_val, bool is_max) {5631void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max) {
5632 if (type_entry->id == TypeTableEntryIdInt) {5632 if (type_entry->id == TypeTableEntryIdInt) {
5633 const_val->special = ConstValSpecialStatic;5633 const_val->special = ConstValSpecialStatic;
5634 eval_min_max_value_int(g, type_entry, &const_val->data.x_bigint, is_max);5634 eval_min_max_value_int(g, type_entry, &const_val->data.x_bigint, is_max);
...@@ -5642,7 +5642,7 @@ void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *...@@ -5642,7 +5642,7 @@ void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *
5642 }5642 }
5643}5643}
56445644
5645void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, TypeTableEntry *type_entry) {5645void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) {
5646 switch (const_val->data.x_ptr.special) {5646 switch (const_val->data.x_ptr.special) {
5647 case ConstPtrSpecialInvalid:5647 case ConstPtrSpecialInvalid:
5648 zig_unreachable();5648 zig_unreachable();
...@@ -5690,7 +5690,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5690,7 +5690,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5690 }5690 }
5691 assert(const_val->type);5691 assert(const_val->type);
56925692
5693 TypeTableEntry *type_entry = const_val->type;5693 ZigType *type_entry = const_val->type;
5694 switch (type_entry->id) {5694 switch (type_entry->id) {
5695 case TypeTableEntryIdOpaque:5695 case TypeTableEntryIdOpaque:
5696 zig_unreachable();5696 zig_unreachable();
...@@ -5765,7 +5765,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5765,7 +5765,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5765 }5765 }
5766 case TypeTableEntryIdArray:5766 case TypeTableEntryIdArray:
5767 {5767 {
5768 TypeTableEntry *child_type = type_entry->data.array.child_type;5768 ZigType *child_type = type_entry->data.array.child_type;
5769 uint64_t len = type_entry->data.array.len;5769 uint64_t len = type_entry->data.array.len;
57705770
5771 if (const_val->data.x_array.special == ConstArraySpecialUndef) {5771 if (const_val->data.x_array.special == ConstArraySpecialUndef) {
...@@ -5878,8 +5878,8 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5878,8 +5878,8 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5878 zig_unreachable();5878 zig_unreachable();
5879}5879}
58805880
5881TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {5881ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
5882 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);5882 ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
5883 entry->is_copyable = true;5883 entry->is_copyable = true;
5884 entry->type_ref = (size_in_bits == 0) ? LLVMVoidType() : LLVMIntType(size_in_bits);5884 entry->type_ref = (size_in_bits == 0) ? LLVMVoidType() : LLVMIntType(size_in_bits);
5885 entry->zero_bits = (size_in_bits == 0);5885 entry->zero_bits = (size_in_bits == 0);
...@@ -6071,7 +6071,7 @@ void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {...@@ -6071,7 +6071,7 @@ void expand_undef_array(CodeGen *g, ConstExprValue *const_val) {
60716071
6072ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {6072ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {
6073 assert(value->type);6073 assert(value->type);
6074 TypeTableEntry *type_entry = value->type;6074 ZigType *type_entry = value->type;
6075 if (type_entry->id == TypeTableEntryIdArray) {6075 if (type_entry->id == TypeTableEntryIdArray) {
6076 expand_undef_array(g, value);6076 expand_undef_array(g, value);
6077 return &value->data.x_array.s_none.parent;6077 return &value->data.x_array.s_none.parent;
...@@ -6083,7 +6083,7 @@ ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {...@@ -6083,7 +6083,7 @@ ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value) {
6083 return nullptr;6083 return nullptr;
6084}6084}
60856085
6086static const TypeTableEntryId all_type_ids[] = {6086static const ZigTypeId all_type_ids[] = {
6087 TypeTableEntryIdMetaType,6087 TypeTableEntryIdMetaType,
6088 TypeTableEntryIdVoid,6088 TypeTableEntryIdVoid,
6089 TypeTableEntryIdBool,6089 TypeTableEntryIdBool,
...@@ -6111,7 +6111,7 @@ static const TypeTableEntryId all_type_ids[] = {...@@ -6111,7 +6111,7 @@ static const TypeTableEntryId all_type_ids[] = {
6111 TypeTableEntryIdPromise,6111 TypeTableEntryIdPromise,
6112};6112};
61136113
6114TypeTableEntryId type_id_at_index(size_t index) {6114ZigTypeId type_id_at_index(size_t index) {
6115 assert(index < array_length(all_type_ids));6115 assert(index < array_length(all_type_ids));
6116 return all_type_ids[index];6116 return all_type_ids[index];
6117}6117}
...@@ -6120,7 +6120,7 @@ size_t type_id_len() {...@@ -6120,7 +6120,7 @@ size_t type_id_len() {
6120 return array_length(all_type_ids);6120 return array_length(all_type_ids);
6121}6121}
61226122
6123size_t type_id_index(TypeTableEntry *entry) {6123size_t type_id_index(ZigType *entry) {
6124 switch (entry->id) {6124 switch (entry->id) {
6125 case TypeTableEntryIdInvalid:6125 case TypeTableEntryIdInvalid:
6126 zig_unreachable();6126 zig_unreachable();
...@@ -6180,7 +6180,7 @@ size_t type_id_index(TypeTableEntry *entry) {...@@ -6180,7 +6180,7 @@ size_t type_id_index(TypeTableEntry *entry) {
6180 zig_unreachable();6180 zig_unreachable();
6181}6181}
61826182
6183const char *type_id_name(TypeTableEntryId id) {6183const char *type_id_name(ZigTypeId id) {
6184 switch (id) {6184 switch (id) {
6185 case TypeTableEntryIdInvalid:6185 case TypeTableEntryIdInvalid:
6186 zig_unreachable();6186 zig_unreachable();
...@@ -6266,7 +6266,7 @@ LinkLib *add_link_lib(CodeGen *g, Buf *name) {...@@ -6266,7 +6266,7 @@ LinkLib *add_link_lib(CodeGen *g, Buf *name) {
6266 return link_lib;6266 return link_lib;
6267}6267}
62686268
6269uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) {6269uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry) {
6270 assertNoError(type_ensure_zero_bits_known(g, type_entry));6270 assertNoError(type_ensure_zero_bits_known(g, type_entry));
6271 if (type_entry->zero_bits) return 0;6271 if (type_entry->zero_bits) return 0;
62726272
...@@ -6290,7 +6290,7 @@ uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) {...@@ -6290,7 +6290,7 @@ uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry) {
6290 }6290 }
6291}6291}
62926292
6293TypeTableEntry *get_align_amt_type(CodeGen *g) {6293ZigType *get_align_amt_type(CodeGen *g) {
6294 if (g->align_amt_type == nullptr) {6294 if (g->align_amt_type == nullptr) {
6295 // according to LLVM the maximum alignment is 1 << 29.6295 // according to LLVM the maximum alignment is 1 << 29.
6296 g->align_amt_type = get_int_type(g, false, 29);6296 g->align_amt_type = get_int_type(g, false, 29);
...@@ -6298,11 +6298,11 @@ TypeTableEntry *get_align_amt_type(CodeGen *g) {...@@ -6298,11 +6298,11 @@ TypeTableEntry *get_align_amt_type(CodeGen *g) {
6298 return g->align_amt_type;6298 return g->align_amt_type;
6299}6299}
63006300
6301uint32_t type_ptr_hash(const TypeTableEntry *ptr) {6301uint32_t type_ptr_hash(const ZigType *ptr) {
6302 return hash_ptr((void*)ptr);6302 return hash_ptr((void*)ptr);
6303}6303}
63046304
6305bool type_ptr_eql(const TypeTableEntry *a, const TypeTableEntry *b) {6305bool type_ptr_eql(const ZigType *a, const ZigType *b) {
6306 return a == b;6306 return a == b;
6307}6307}
63086308
...@@ -6316,7 +6316,7 @@ ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) {...@@ -6316,7 +6316,7 @@ ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) {
6316 return var_value;6316 return var_value;
6317}6317}
63186318
6319bool type_is_global_error_set(TypeTableEntry *err_set_type) {6319bool type_is_global_error_set(ZigType *err_set_type) {
6320 assert(err_set_type->id == TypeTableEntryIdErrorSet);6320 assert(err_set_type->id == TypeTableEntryIdErrorSet);
6321 assert(err_set_type->data.error_set.infer_fn == nullptr);6321 assert(err_set_type->data.error_set.infer_fn == nullptr);
6322 return err_set_type->data.error_set.err_count == UINT32_MAX;6322 return err_set_type->data.error_set.err_count == UINT32_MAX;
...@@ -6326,7 +6326,7 @@ uint32_t get_coro_frame_align_bytes(CodeGen *g) {...@@ -6326,7 +6326,7 @@ uint32_t get_coro_frame_align_bytes(CodeGen *g) {
6326 return g->pointer_size_bytes * 2;6326 return g->pointer_size_bytes * 2;
6327}6327}
63286328
6329bool type_can_fail(TypeTableEntry *type_entry) {6329bool type_can_fail(ZigType *type_entry) {
6330 return type_entry->id == TypeTableEntryIdErrorUnion || type_entry->id == TypeTableEntryIdErrorSet;6330 return type_entry->id == TypeTableEntryIdErrorUnion || type_entry->id == TypeTableEntryIdErrorSet;
6331}6331}
63326332
...@@ -6334,7 +6334,7 @@ bool fn_type_can_fail(FnTypeId *fn_type_id) {...@@ -6334,7 +6334,7 @@ bool fn_type_can_fail(FnTypeId *fn_type_id) {
6334 return type_can_fail(fn_type_id->return_type) || fn_type_id->cc == CallingConventionAsync;6334 return type_can_fail(fn_type_id->return_type) || fn_type_id->cc == CallingConventionAsync;
6335}6335}
63366336
6337TypeTableEntry *get_primitive_type(CodeGen *g, Buf *name) {6337ZigType *get_primitive_type(CodeGen *g, Buf *name) {
6338 if (buf_len(name) >= 2) {6338 if (buf_len(name) >= 2) {
6339 uint8_t first_c = buf_ptr(name)[0];6339 uint8_t first_c = buf_ptr(name)[0];
6340 if (first_c == 'i' || first_c == 'u') {6340 if (first_c == 'i' || first_c == 'u') {
src/analyze.hpp+85-85
...@@ -14,35 +14,35 @@...@@ -14,35 +14,35 @@
14void semantic_analyze(CodeGen *g);14void semantic_analyze(CodeGen *g);
15ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg);15ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg);
16ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *msg);16ErrorMsg *add_error_note(CodeGen *g, ErrorMsg *parent_msg, AstNode *node, Buf *msg);
17TypeTableEntry *new_type_table_entry(TypeTableEntryId id);17ZigType *new_type_table_entry(ZigTypeId id);
18TypeTableEntry *get_pointer_to_type(CodeGen *g, TypeTableEntry *child_type, bool is_const);18ZigType *get_pointer_to_type(CodeGen *g, ZigType *child_type, bool is_const);
19TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type, bool is_const,19ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_const,
20 bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count);20 bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset, uint32_t unaligned_bit_count);
21uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry);21uint64_t type_size(CodeGen *g, ZigType *type_entry);
22uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry);22uint64_t type_size_bits(CodeGen *g, ZigType *type_entry);
23TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);23ZigType *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
24TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);24ZigType **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
25TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);25ZigType *get_c_int_type(CodeGen *g, CIntType c_int_type);
26TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);26ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id);
27TypeTableEntry *get_optional_type(CodeGen *g, TypeTableEntry *child_type);27ZigType *get_optional_type(CodeGen *g, ZigType *child_type);
28TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t array_size);28ZigType *get_array_type(CodeGen *g, ZigType *child_type, uint64_t array_size);
29TypeTableEntry *get_slice_type(CodeGen *g, TypeTableEntry *ptr_type);29ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type);
30TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,30ZigType *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKind kind,
31 AstNode *decl_node, const char *name, ContainerLayout layout);31 AstNode *decl_node, const char *name, ContainerLayout layout);
32TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);32ZigType *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x);
33TypeTableEntry *get_error_union_type(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *payload_type);33ZigType *get_error_union_type(CodeGen *g, ZigType *err_set_type, ZigType *payload_type);
34TypeTableEntry *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry);34ZigType *get_bound_fn_type(CodeGen *g, FnTableEntry *fn_entry);
35TypeTableEntry *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name);35ZigType *get_opaque_type(CodeGen *g, Scope *scope, AstNode *source_node, const char *name);
36TypeTableEntry *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],36ZigType *get_struct_type(CodeGen *g, const char *type_name, const char *field_names[],
37 TypeTableEntry *field_types[], size_t field_count);37 ZigType *field_types[], size_t field_count);
38TypeTableEntry *get_promise_type(CodeGen *g, TypeTableEntry *result_type);38ZigType *get_promise_type(CodeGen *g, ZigType *result_type);
39TypeTableEntry *get_promise_frame_type(CodeGen *g, TypeTableEntry *return_type);39ZigType *get_promise_frame_type(CodeGen *g, ZigType *return_type);
40TypeTableEntry *get_test_fn_type(CodeGen *g);40ZigType *get_test_fn_type(CodeGen *g);
41bool handle_is_ptr(TypeTableEntry *type_entry);41bool handle_is_ptr(ZigType *type_entry);
42void find_libc_include_path(CodeGen *g);42void find_libc_include_path(CodeGen *g);
43void find_libc_lib_path(CodeGen *g);43void find_libc_lib_path(CodeGen *g);
4444
45bool type_has_bits(TypeTableEntry *type_entry);45bool type_has_bits(ZigType *type_entry);
4646
4747
48ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *abs_full_path, Buf *source_code);48ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *abs_full_path, Buf *source_code);
...@@ -51,28 +51,28 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *a...@@ -51,28 +51,28 @@ ImportTableEntry *add_source_file(CodeGen *g, PackageTableEntry *package, Buf *a
51VariableTableEntry *find_variable(CodeGen *g, Scope *orig_context, Buf *name);51VariableTableEntry *find_variable(CodeGen *g, Scope *orig_context, Buf *name);
52Tld *find_decl(CodeGen *g, Scope *scope, Buf *name);52Tld *find_decl(CodeGen *g, Scope *scope, Buf *name);
53void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only, AstNode *source_node);53void resolve_top_level_decl(CodeGen *g, Tld *tld, bool pointer_only, AstNode *source_node);
54bool type_is_codegen_pointer(TypeTableEntry *type);54bool type_is_codegen_pointer(ZigType *type);
5555
56TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type);56ZigType *get_codegen_ptr_type(ZigType *type);
57uint32_t get_ptr_align(TypeTableEntry *type);57uint32_t get_ptr_align(ZigType *type);
58bool get_ptr_const(TypeTableEntry *type);58bool get_ptr_const(ZigType *type);
59TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEntry *type_entry);59ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry);
60TypeTableEntry *container_ref_type(TypeTableEntry *type_entry);60ZigType *container_ref_type(ZigType *type_entry);
61bool type_is_complete(TypeTableEntry *type_entry);61bool type_is_complete(ZigType *type_entry);
62bool type_is_invalid(TypeTableEntry *type_entry);62bool type_is_invalid(ZigType *type_entry);
63bool type_is_global_error_set(TypeTableEntry *err_set_type);63bool type_is_global_error_set(ZigType *err_set_type);
64bool type_has_zero_bits_known(TypeTableEntry *type_entry);64bool type_has_zero_bits_known(ZigType *type_entry);
65void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry);65void resolve_container_type(CodeGen *g, ZigType *type_entry);
66ScopeDecls *get_container_scope(TypeTableEntry *type_entry);66ScopeDecls *get_container_scope(ZigType *type_entry);
67TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name);67TypeStructField *find_struct_type_field(ZigType *type_entry, Buf *name);
68TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name);68TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name);
69TypeUnionField *find_union_type_field(TypeTableEntry *type_entry, Buf *name);69TypeUnionField *find_union_type_field(ZigType *type_entry, Buf *name);
70TypeEnumField *find_enum_field_by_tag(TypeTableEntry *enum_type, const BigInt *tag);70TypeEnumField *find_enum_field_by_tag(ZigType *enum_type, const BigInt *tag);
71TypeUnionField *find_union_field_by_tag(TypeTableEntry *type_entry, const BigInt *tag);71TypeUnionField *find_union_field_by_tag(ZigType *type_entry, const BigInt *tag);
7272
73bool is_ref(TypeTableEntry *type_entry);73bool is_ref(ZigType *type_entry);
74bool is_array_ref(TypeTableEntry *type_entry);74bool is_array_ref(ZigType *type_entry);
75bool is_container_ref(TypeTableEntry *type_entry);75bool is_container_ref(ZigType *type_entry);
76void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node);76void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node);
77void scan_import(CodeGen *g, ImportTableEntry *import);77void scan_import(CodeGen *g, ImportTableEntry *import);
78void preview_use_decl(CodeGen *g, AstNode *node);78void preview_use_decl(CodeGen *g, AstNode *node);
...@@ -82,20 +82,20 @@ ImportTableEntry *get_scope_import(Scope *scope);...@@ -82,20 +82,20 @@ ImportTableEntry *get_scope_import(Scope *scope);
82void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope);82void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source_node, Scope *parent_scope);
83VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,83VariableTableEntry *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf *name,
84 bool is_const, ConstExprValue *init_value, Tld *src_tld);84 bool is_const, ConstExprValue *init_value, Tld *src_tld);
85TypeTableEntry *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);85ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node);
86FnTableEntry *create_fn(AstNode *proto_node);86FnTableEntry *create_fn(AstNode *proto_node);
87FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);87FnTableEntry *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
88void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);88void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
89AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);89AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index);
90FnTableEntry *scope_get_fn_if_root(Scope *scope);90FnTableEntry *scope_get_fn_if_root(Scope *scope);
91bool type_requires_comptime(TypeTableEntry *type_entry);91bool type_requires_comptime(ZigType *type_entry);
92Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, TypeTableEntry *type_entry);92Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry);
93Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, TypeTableEntry *type_entry);93Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry);
94void complete_enum(CodeGen *g, TypeTableEntry *enum_type);94void complete_enum(CodeGen *g, ZigType *enum_type);
95bool ir_get_var_is_comptime(VariableTableEntry *var);95bool ir_get_var_is_comptime(VariableTableEntry *var);
96bool const_values_equal(ConstExprValue *a, ConstExprValue *b);96bool const_values_equal(ConstExprValue *a, ConstExprValue *b);
97void eval_min_max_value(CodeGen *g, TypeTableEntry *type_entry, ConstExprValue *const_val, bool is_max);97void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_val, bool is_max);
98void eval_min_max_value_int(CodeGen *g, TypeTableEntry *int_type, BigInt *bigint, bool is_max);98void eval_min_max_value_int(CodeGen *g, ZigType *int_type, BigInt *bigint, bool is_max);
9999
100void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val);100void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val);
101void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node);101void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_type_node);
...@@ -108,7 +108,7 @@ ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent);...@@ -108,7 +108,7 @@ ScopeCImport *create_cimport_scope(AstNode *node, Scope *parent);
108ScopeLoop *create_loop_scope(AstNode *node, Scope *parent);108ScopeLoop *create_loop_scope(AstNode *node, Scope *parent);
109ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent);109ScopeSuspend *create_suspend_scope(AstNode *node, Scope *parent);
110ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry);110ScopeFnDef *create_fndef_scope(AstNode *node, Scope *parent, FnTableEntry *fn_entry);
111ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, TypeTableEntry *container_type, ImportTableEntry *import);111ScopeDecls *create_decls_scope(AstNode *node, Scope *parent, ZigType *container_type, ImportTableEntry *import);
112Scope *create_comptime_scope(AstNode *node, Scope *parent);112Scope *create_comptime_scope(AstNode *node, Scope *parent);
113Scope *create_coro_prelude_scope(AstNode *node, Scope *parent);113Scope *create_coro_prelude_scope(AstNode *node, Scope *parent);
114Scope *create_runtime_scope(AstNode *node, Scope *parent, IrInstruction *is_comptime);114Scope *create_runtime_scope(AstNode *node, Scope *parent, IrInstruction *is_comptime);
...@@ -119,39 +119,39 @@ ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);...@@ -119,39 +119,39 @@ ConstExprValue *create_const_str_lit(CodeGen *g, Buf *str);
119void init_const_c_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *c_str);119void init_const_c_str_lit(CodeGen *g, ConstExprValue *const_val, Buf *c_str);
120ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *c_str);120ConstExprValue *create_const_c_str_lit(CodeGen *g, Buf *c_str);
121121
122void init_const_bigint(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *bigint);122void init_const_bigint(ConstExprValue *const_val, ZigType *type, const BigInt *bigint);
123ConstExprValue *create_const_bigint(TypeTableEntry *type, const BigInt *bigint);123ConstExprValue *create_const_bigint(ZigType *type, const BigInt *bigint);
124124
125void init_const_unsigned_negative(ConstExprValue *const_val, TypeTableEntry *type, uint64_t x, bool negative);125void init_const_unsigned_negative(ConstExprValue *const_val, ZigType *type, uint64_t x, bool negative);
126ConstExprValue *create_const_unsigned_negative(TypeTableEntry *type, uint64_t x, bool negative);126ConstExprValue *create_const_unsigned_negative(ZigType *type, uint64_t x, bool negative);
127127
128void init_const_signed(ConstExprValue *const_val, TypeTableEntry *type, int64_t x);128void init_const_signed(ConstExprValue *const_val, ZigType *type, int64_t x);
129ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x);129ConstExprValue *create_const_signed(ZigType *type, int64_t x);
130130
131void init_const_usize(CodeGen *g, ConstExprValue *const_val, uint64_t x);131void init_const_usize(CodeGen *g, ConstExprValue *const_val, uint64_t x);
132ConstExprValue *create_const_usize(CodeGen *g, uint64_t x);132ConstExprValue *create_const_usize(CodeGen *g, uint64_t x);
133133
134void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value);134void init_const_float(ConstExprValue *const_val, ZigType *type, double value);
135ConstExprValue *create_const_float(TypeTableEntry *type, double value);135ConstExprValue *create_const_float(ZigType *type, double value);
136136
137void init_const_enum(ConstExprValue *const_val, TypeTableEntry *type, const BigInt *tag);137void init_const_enum(ConstExprValue *const_val, ZigType *type, const BigInt *tag);
138ConstExprValue *create_const_enum(TypeTableEntry *type, const BigInt *tag);138ConstExprValue *create_const_enum(ZigType *type, const BigInt *tag);
139139
140void init_const_bool(CodeGen *g, ConstExprValue *const_val, bool value);140void init_const_bool(CodeGen *g, ConstExprValue *const_val, bool value);
141ConstExprValue *create_const_bool(CodeGen *g, bool value);141ConstExprValue *create_const_bool(CodeGen *g, bool value);
142142
143void init_const_type(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *type_value);143void init_const_type(CodeGen *g, ConstExprValue *const_val, ZigType *type_value);
144ConstExprValue *create_const_type(CodeGen *g, TypeTableEntry *type_value);144ConstExprValue *create_const_type(CodeGen *g, ZigType *type_value);
145145
146void init_const_runtime(ConstExprValue *const_val, TypeTableEntry *type);146void init_const_runtime(ConstExprValue *const_val, ZigType *type);
147ConstExprValue *create_const_runtime(TypeTableEntry *type);147ConstExprValue *create_const_runtime(ZigType *type);
148148
149void init_const_ptr_ref(CodeGen *g, ConstExprValue *const_val, ConstExprValue *pointee_val, bool is_const);149void init_const_ptr_ref(CodeGen *g, ConstExprValue *const_val, ConstExprValue *pointee_val, bool is_const);
150ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bool is_const);150ConstExprValue *create_const_ptr_ref(CodeGen *g, ConstExprValue *pointee_val, bool is_const);
151151
152void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, TypeTableEntry *pointee_type,152void init_const_ptr_hard_coded_addr(CodeGen *g, ConstExprValue *const_val, ZigType *pointee_type,
153 size_t addr, bool is_const);153 size_t addr, bool is_const);
154ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, TypeTableEntry *pointee_type,154ConstExprValue *create_const_ptr_hard_coded_addr(CodeGen *g, ZigType *pointee_type,
155 size_t addr, bool is_const);155 size_t addr, bool is_const);
156156
157void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,157void init_const_ptr_array(CodeGen *g, ConstExprValue *const_val, ConstExprValue *array_val,
...@@ -170,23 +170,23 @@ void init_const_undefined(CodeGen *g, ConstExprValue *const_val);...@@ -170,23 +170,23 @@ void init_const_undefined(CodeGen *g, ConstExprValue *const_val);
170170
171ConstExprValue *create_const_vals(size_t count);171ConstExprValue *create_const_vals(size_t count);
172172
173TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);173ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
174ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value);174ConstParent *get_const_val_parent(CodeGen *g, ConstExprValue *value);
175void expand_undef_array(CodeGen *g, ConstExprValue *const_val);175void expand_undef_array(CodeGen *g, ConstExprValue *const_val);
176void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value);176void update_compile_var(CodeGen *g, Buf *name, ConstExprValue *value);
177177
178const char *type_id_name(TypeTableEntryId id);178const char *type_id_name(ZigTypeId id);
179TypeTableEntryId type_id_at_index(size_t index);179ZigTypeId type_id_at_index(size_t index);
180size_t type_id_len();180size_t type_id_len();
181size_t type_id_index(TypeTableEntry *entry);181size_t type_id_index(ZigType *entry);
182TypeTableEntry *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id);182ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id);
183Result<bool> type_is_copyable(CodeGen *g, TypeTableEntry *type_entry);183Result<bool> type_is_copyable(CodeGen *g, ZigType *type_entry);
184LinkLib *create_link_lib(Buf *name);184LinkLib *create_link_lib(Buf *name);
185bool calling_convention_does_first_arg_return(CallingConvention cc);185bool calling_convention_does_first_arg_return(CallingConvention cc);
186LinkLib *add_link_lib(CodeGen *codegen, Buf *lib);186LinkLib *add_link_lib(CodeGen *codegen, Buf *lib);
187187
188uint32_t get_abi_alignment(CodeGen *g, TypeTableEntry *type_entry);188uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry);
189TypeTableEntry *get_align_amt_type(CodeGen *g);189ZigType *get_align_amt_type(CodeGen *g);
190PackageTableEntry *new_anonymous_package(void);190PackageTableEntry *new_anonymous_package(void);
191191
192Buf *const_value_to_buffer(ConstExprValue *const_val);192Buf *const_value_to_buffer(ConstExprValue *const_val);
...@@ -194,17 +194,17 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G...@@ -194,17 +194,17 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G
194194
195195
196ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);196ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
197TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g);197ZigType *get_ptr_to_stack_trace_type(CodeGen *g);
198bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node);198bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node);
199199
200TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);200ZigType *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);
201201
202uint32_t get_coro_frame_align_bytes(CodeGen *g);202uint32_t get_coro_frame_align_bytes(CodeGen *g);
203bool fn_type_can_fail(FnTypeId *fn_type_id);203bool fn_type_can_fail(FnTypeId *fn_type_id);
204bool type_can_fail(TypeTableEntry *type_entry);204bool type_can_fail(ZigType *type_entry);
205bool fn_eval_cacheable(Scope *scope, TypeTableEntry *return_type);205bool fn_eval_cacheable(Scope *scope, ZigType *return_type);
206AstNode *type_decl_node(TypeTableEntry *type_entry);206AstNode *type_decl_node(ZigType *type_entry);
207207
208TypeTableEntry *get_primitive_type(CodeGen *g, Buf *name);208ZigType *get_primitive_type(CodeGen *g, Buf *name);
209209
210#endif210#endif
src/codegen.cpp+192-192
...@@ -437,11 +437,11 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e...@@ -437,11 +437,11 @@ static uint32_t get_err_ret_trace_arg_index(CodeGen *g, FnTableEntry *fn_table_e
437 if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync) {437 if (fn_table_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync) {
438 return 0;438 return 0;
439 }439 }
440 TypeTableEntry *fn_type = fn_table_entry->type_entry;440 ZigType *fn_type = fn_table_entry->type_entry;
441 if (!fn_type_can_fail(&fn_type->data.fn.fn_type_id)) {441 if (!fn_type_can_fail(&fn_type->data.fn.fn_type_id)) {
442 return UINT32_MAX;442 return UINT32_MAX;
443 }443 }
444 TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;444 ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
445 bool first_arg_ret = type_has_bits(return_type) && handle_is_ptr(return_type);445 bool first_arg_ret = type_has_bits(return_type) && handle_is_ptr(return_type);
446 return first_arg_ret ? 1 : 0;446 return first_arg_ret ? 1 : 0;
447}447}
...@@ -474,7 +474,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -474,7 +474,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
474 }474 }
475475
476476
477 TypeTableEntry *fn_type = fn_table_entry->type_entry;477 ZigType *fn_type = fn_table_entry->type_entry;
478 LLVMTypeRef fn_llvm_type = fn_type->data.fn.raw_type_ref;478 LLVMTypeRef fn_llvm_type = fn_type->data.fn.raw_type_ref;
479 if (fn_table_entry->body_node == nullptr) {479 if (fn_table_entry->body_node == nullptr) {
480 LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name));480 LLVMValueRef existing_llvm_fn = LLVMGetNamedFunction(g->module, buf_ptr(symbol_name));
...@@ -532,7 +532,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -532,7 +532,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
532 LLVMSetUnnamedAddr(fn_table_entry->llvm_value, true);532 LLVMSetUnnamedAddr(fn_table_entry->llvm_value, true);
533 }533 }
534534
535 TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;535 ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
536 if (return_type->id == TypeTableEntryIdUnreachable) {536 if (return_type->id == TypeTableEntryIdUnreachable) {
537 addLLVMFnAttr(fn_table_entry->llvm_value, "noreturn");537 addLLVMFnAttr(fn_table_entry->llvm_value, "noreturn");
538 }538 }
...@@ -596,7 +596,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -596,7 +596,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
596596
597 FnTypeParamInfo *param_info = &fn_type->data.fn.fn_type_id.param_info[param_i];597 FnTypeParamInfo *param_info = &fn_type->data.fn.fn_type_id.param_info[param_i];
598598
599 TypeTableEntry *param_type = gen_info->type;599 ZigType *param_type = gen_info->type;
600 if (param_info->is_noalias) {600 if (param_info->is_noalias) {
601 addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "noalias");601 addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "noalias");
602 }602 }
...@@ -688,7 +688,7 @@ static void clear_debug_source_node(CodeGen *g) {...@@ -688,7 +688,7 @@ static void clear_debug_source_node(CodeGen *g) {
688 ZigLLVMClearCurrentDebugLocation(g->builder);688 ZigLLVMClearCurrentDebugLocation(g->builder);
689}689}
690690
691static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,691static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, ZigType *type_entry,
692 const char *signed_name, const char *unsigned_name)692 const char *signed_name, const char *unsigned_name)
693{693{
694 char fn_name[64];694 char fn_name[64];
...@@ -712,7 +712,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_...@@ -712,7 +712,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_
712 return fn_val;712 return fn_val;
713}713}
714714
715static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry, AddSubMul add_sub_mul) {715static LLVMValueRef get_int_overflow_fn(CodeGen *g, ZigType *type_entry, AddSubMul add_sub_mul) {
716 assert(type_entry->id == TypeTableEntryIdInt);716 assert(type_entry->id == TypeTableEntryIdInt);
717717
718 ZigLLVMFnKey key = {};718 ZigLLVMFnKey key = {};
...@@ -742,7 +742,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,...@@ -742,7 +742,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
742 return fn_val;742 return fn_val;
743}743}
744744
745static LLVMValueRef get_float_fn(CodeGen *g, TypeTableEntry *type_entry, ZigLLVMFnId fn_id) {745static LLVMValueRef get_float_fn(CodeGen *g, ZigType *type_entry, ZigLLVMFnId fn_id) {
746 assert(type_entry->id == TypeTableEntryIdFloat);746 assert(type_entry->id == TypeTableEntryIdFloat);
747747
748 ZigLLVMFnKey key = {};748 ZigLLVMFnKey key = {};
...@@ -787,7 +787,7 @@ static LLVMValueRef gen_store_untyped(CodeGen *g, LLVMValueRef value, LLVMValueR...@@ -787,7 +787,7 @@ static LLVMValueRef gen_store_untyped(CodeGen *g, LLVMValueRef value, LLVMValueR
787 return instruction;787 return instruction;
788}788}
789789
790static LLVMValueRef gen_store(CodeGen *g, LLVMValueRef value, LLVMValueRef ptr, TypeTableEntry *ptr_type) {790static LLVMValueRef gen_store(CodeGen *g, LLVMValueRef value, LLVMValueRef ptr, ZigType *ptr_type) {
791 assert(ptr_type->id == TypeTableEntryIdPointer);791 assert(ptr_type->id == TypeTableEntryIdPointer);
792 return gen_store_untyped(g, value, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile);792 return gen_store_untyped(g, value, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile);
793}793}
...@@ -805,12 +805,12 @@ static LLVMValueRef gen_load_untyped(CodeGen *g, LLVMValueRef ptr, uint32_t alig...@@ -805,12 +805,12 @@ static LLVMValueRef gen_load_untyped(CodeGen *g, LLVMValueRef ptr, uint32_t alig
805 return result;805 return result;
806}806}
807807
808static LLVMValueRef gen_load(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *ptr_type, const char *name) {808static LLVMValueRef gen_load(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type, const char *name) {
809 assert(ptr_type->id == TypeTableEntryIdPointer);809 assert(ptr_type->id == TypeTableEntryIdPointer);
810 return gen_load_untyped(g, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile, name);810 return gen_load_untyped(g, ptr, ptr_type->data.pointer.alignment, ptr_type->data.pointer.is_volatile, name);
811}811}
812812
813static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *type, TypeTableEntry *ptr_type) {813static LLVMValueRef get_handle_value(CodeGen *g, LLVMValueRef ptr, ZigType *type, ZigType *ptr_type) {
814 if (type_has_bits(type)) {814 if (type_has_bits(type)) {
815 if (handle_is_ptr(type)) {815 if (handle_is_ptr(type)) {
816 return ptr;816 return ptr;
...@@ -918,9 +918,9 @@ static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) {...@@ -918,9 +918,9 @@ static LLVMValueRef get_panic_msg_ptr_val(CodeGen *g, PanicMsgId msg_id) {
918 assert(val->global_refs->llvm_global);918 assert(val->global_refs->llvm_global);
919 }919 }
920920
921 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,921 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
922 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);922 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
923 TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);923 ZigType *str_type = get_slice_type(g, u8_ptr_type);
924 return LLVMConstBitCast(val->global_refs->llvm_global, LLVMPointerType(str_type->type_ref, 0));924 return LLVMConstBitCast(val->global_refs->llvm_global, LLVMPointerType(str_type->type_ref, 0));
925}925}
926926
...@@ -929,7 +929,7 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace...@@ -929,7 +929,7 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg, LLVMValueRef stack_trace
929 LLVMValueRef fn_val = fn_llvm_value(g, g->panic_fn);929 LLVMValueRef fn_val = fn_llvm_value(g, g->panic_fn);
930 LLVMCallConv llvm_cc = get_llvm_cc(g, g->panic_fn->type_entry->data.fn.fn_type_id.cc);930 LLVMCallConv llvm_cc = get_llvm_cc(g, g->panic_fn->type_entry->data.fn.fn_type_id.cc);
931 if (stack_trace_arg == nullptr) {931 if (stack_trace_arg == nullptr) {
932 TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);932 ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
933 stack_trace_arg = LLVMConstNull(ptr_to_stack_trace_type->type_ref);933 stack_trace_arg = LLVMConstNull(ptr_to_stack_trace_type->type_ref);
934 }934 }
935 LLVMValueRef args[] = {935 LLVMValueRef args[] = {
...@@ -1186,7 +1186,7 @@ static LLVMValueRef get_return_address_fn_val(CodeGen *g) {...@@ -1186,7 +1186,7 @@ static LLVMValueRef get_return_address_fn_val(CodeGen *g) {
1186 if (g->return_address_fn_val)1186 if (g->return_address_fn_val)
1187 return g->return_address_fn_val;1187 return g->return_address_fn_val;
11881188
1189 TypeTableEntry *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);1189 ZigType *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
11901190
1191 LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,1191 LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,
1192 &g->builtin_types.entry_i32->type_ref, 1, false);1192 &g->builtin_types.entry_i32->type_ref, 1, false);
...@@ -1237,7 +1237,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {...@@ -1237,7 +1237,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) {
1237 size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;1237 size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;
1238 LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, err_ret_trace_ptr, (unsigned)addresses_field_index, "");1238 LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, err_ret_trace_ptr, (unsigned)addresses_field_index, "");
12391239
1240 TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;1240 ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
1241 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;1241 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
1242 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");1242 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");
1243 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;1243 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
...@@ -1337,7 +1337,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {...@@ -1337,7 +1337,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
1337 (unsigned)src_index_field_index, "");1337 (unsigned)src_index_field_index, "");
1338 LLVMValueRef src_addresses_field_ptr = LLVMBuildStructGEP(g->builder, src_stack_trace_ptr,1338 LLVMValueRef src_addresses_field_ptr = LLVMBuildStructGEP(g->builder, src_stack_trace_ptr,
1339 (unsigned)src_addresses_field_index, "");1339 (unsigned)src_addresses_field_index, "");
1340 TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;1340 ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
1341 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;1341 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
1342 LLVMValueRef src_ptr_field_ptr = LLVMBuildStructGEP(g->builder, src_addresses_field_ptr, (unsigned)ptr_field_index, "");1342 LLVMValueRef src_ptr_field_ptr = LLVMBuildStructGEP(g->builder, src_addresses_field_ptr, (unsigned)ptr_field_index, "");
1343 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;1343 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
...@@ -1479,7 +1479,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {...@@ -1479,7 +1479,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
1479 LLVMSetUnnamedAddr(global_array, true);1479 LLVMSetUnnamedAddr(global_array, true);
1480 LLVMSetAlignment(global_array, u8_align_bytes);1480 LLVMSetAlignment(global_array, u8_align_bytes);
14811481
1482 TypeTableEntry *usize = g->builtin_types.entry_usize;1482 ZigType *usize = g->builtin_types.entry_usize;
1483 LLVMValueRef full_buf_ptr_indices[] = {1483 LLVMValueRef full_buf_ptr_indices[] = {
1484 LLVMConstNull(usize->type_ref),1484 LLVMConstNull(usize->type_ref),
1485 LLVMConstNull(usize->type_ref),1485 LLVMConstNull(usize->type_ref),
...@@ -1487,9 +1487,9 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {...@@ -1487,9 +1487,9 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) {
1487 LLVMValueRef full_buf_ptr = LLVMConstInBoundsGEP(global_array, full_buf_ptr_indices, 2);1487 LLVMValueRef full_buf_ptr = LLVMConstInBoundsGEP(global_array, full_buf_ptr_indices, 2);
14881488
14891489
1490 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,1490 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
1491 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);1491 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
1492 TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);1492 ZigType *str_type = get_slice_type(g, u8_ptr_type);
1493 LLVMValueRef global_slice_fields[] = {1493 LLVMValueRef global_slice_fields[] = {
1494 full_buf_ptr,1494 full_buf_ptr,
1495 LLVMConstNull(usize->type_ref),1495 LLVMConstNull(usize->type_ref),
...@@ -1603,7 +1603,7 @@ static void gen_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val, Scope *sc...@@ -1603,7 +1603,7 @@ static void gen_safety_crash_for_err(CodeGen *g, LLVMValueRef err_val, Scope *sc
1603 LLVMValueRef safety_crash_err_fn = get_safety_crash_err_fn(g);1603 LLVMValueRef safety_crash_err_fn = get_safety_crash_err_fn(g);
1604 LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, scope);1604 LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, scope);
1605 if (err_ret_trace_val == nullptr) {1605 if (err_ret_trace_val == nullptr) {
1606 TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);1606 ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
1607 err_ret_trace_val = LLVMConstNull(ptr_to_stack_trace_type->type_ref);1607 err_ret_trace_val = LLVMConstNull(ptr_to_stack_trace_type->type_ref);
1608 }1608 }
1609 LLVMValueRef args[] = {1609 LLVMValueRef args[] = {
...@@ -1649,8 +1649,8 @@ static void add_bounds_check(CodeGen *g, LLVMValueRef target_val,...@@ -1649,8 +1649,8 @@ static void add_bounds_check(CodeGen *g, LLVMValueRef target_val,
1649 LLVMPositionBuilderAtEnd(g->builder, ok_block);1649 LLVMPositionBuilderAtEnd(g->builder, ok_block);
1650}1650}
16511651
1652static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, TypeTableEntry *actual_type,1652static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, ZigType *actual_type,
1653 TypeTableEntry *wanted_type, LLVMValueRef expr_val)1653 ZigType *wanted_type, LLVMValueRef expr_val)
1654{1654{
1655 assert(actual_type->id == wanted_type->id);1655 assert(actual_type->id == wanted_type->id);
16561656
...@@ -1729,7 +1729,7 @@ static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, T...@@ -1729,7 +1729,7 @@ static LLVMValueRef gen_widen_or_shorten(CodeGen *g, bool want_runtime_safety, T
1729 }1729 }
1730}1730}
17311731
1732static LLVMValueRef gen_overflow_op(CodeGen *g, TypeTableEntry *type_entry, AddSubMul op,1732static LLVMValueRef gen_overflow_op(CodeGen *g, ZigType *type_entry, AddSubMul op,
1733 LLVMValueRef val1, LLVMValueRef val2)1733 LLVMValueRef val1, LLVMValueRef val2)
1734{1734{
1735 LLVMValueRef fn_val = get_int_overflow_fn(g, type_entry, op);1735 LLVMValueRef fn_val = get_int_overflow_fn(g, type_entry, op);
...@@ -1789,11 +1789,11 @@ static LLVMRealPredicate cmp_op_to_real_predicate(IrBinOp cmp_op) {...@@ -1789,11 +1789,11 @@ static LLVMRealPredicate cmp_op_to_real_predicate(IrBinOp cmp_op) {
1789 }1789 }
1790}1790}
17911791
1792static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry *ptr_type,1792static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type,
1793 LLVMValueRef value)1793 LLVMValueRef value)
1794{1794{
1795 assert(ptr_type->id == TypeTableEntryIdPointer);1795 assert(ptr_type->id == TypeTableEntryIdPointer);
1796 TypeTableEntry *child_type = ptr_type->data.pointer.child_type;1796 ZigType *child_type = ptr_type->data.pointer.child_type;
17971797
1798 if (!type_has_bits(child_type))1798 if (!type_has_bits(child_type))
1799 return nullptr;1799 return nullptr;
...@@ -1807,7 +1807,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry...@@ -1807,7 +1807,7 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry
1807 LLVMValueRef src_ptr = LLVMBuildBitCast(g->builder, value, ptr_u8, "");1807 LLVMValueRef src_ptr = LLVMBuildBitCast(g->builder, value, ptr_u8, "");
1808 LLVMValueRef dest_ptr = LLVMBuildBitCast(g->builder, ptr, ptr_u8, "");1808 LLVMValueRef dest_ptr = LLVMBuildBitCast(g->builder, ptr, ptr_u8, "");
18091809
1810 TypeTableEntry *usize = g->builtin_types.entry_usize;1810 ZigType *usize = g->builtin_types.entry_usize;
1811 uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, child_type->type_ref);1811 uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, child_type->type_ref);
1812 uint64_t align_bytes = ptr_type->data.pointer.alignment;1812 uint64_t align_bytes = ptr_type->data.pointer.alignment;
1813 assert(size_bytes > 0);1813 assert(size_bytes > 0);
...@@ -1876,7 +1876,7 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {...@@ -1876,7 +1876,7 @@ static LLVMValueRef ir_llvm_value(CodeGen *g, IrInstruction *instruction) {
1876 // values are rendered with a type other than the one we expect1876 // values are rendered with a type other than the one we expect
1877 if (handle_is_ptr(instruction->value.type)) {1877 if (handle_is_ptr(instruction->value.type)) {
1878 render_const_val_global(g, &instruction->value, "");1878 render_const_val_global(g, &instruction->value, "");
1879 TypeTableEntry *ptr_type = get_pointer_to_type(g, instruction->value.type, true);1879 ZigType *ptr_type = get_pointer_to_type(g, instruction->value.type, true);
1880 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_global, ptr_type->type_ref, "");1880 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_global, ptr_type->type_ref, "");
1881 } else if (instruction->value.type->id == TypeTableEntryIdPointer) {1881 } else if (instruction->value.type->id == TypeTableEntryIdPointer) {
1882 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_value, instruction->value.type->type_ref, "");1882 instruction->llvm_value = LLVMBuildBitCast(g->builder, instruction->value.global_refs->llvm_value, instruction->value.type->type_ref, "");
...@@ -1904,7 +1904,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut...@@ -1904,7 +1904,7 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutable *execut
19041904
1905static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrInstructionReturn *return_instruction) {1905static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrInstructionReturn *return_instruction) {
1906 LLVMValueRef value = ir_llvm_value(g, return_instruction->value);1906 LLVMValueRef value = ir_llvm_value(g, return_instruction->value);
1907 TypeTableEntry *return_type = return_instruction->value->value.type;1907 ZigType *return_type = return_instruction->value->value.type;
19081908
1909 if (handle_is_ptr(return_type)) {1909 if (handle_is_ptr(return_type)) {
1910 if (calling_convention_does_first_arg_return(g->cur_fn->type_entry->data.fn.fn_type_id.cc)) {1910 if (calling_convention_does_first_arg_return(g->cur_fn->type_entry->data.fn.fn_type_id.cc)) {
...@@ -1921,7 +1921,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns...@@ -1921,7 +1921,7 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutable *executable, IrIns
1921 return nullptr;1921 return nullptr;
1922}1922}
19231923
1924static LLVMValueRef gen_overflow_shl_op(CodeGen *g, TypeTableEntry *type_entry,1924static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry,
1925 LLVMValueRef val1, LLVMValueRef val2)1925 LLVMValueRef val1, LLVMValueRef val2)
1926{1926{
1927 // for unsigned left shifting, we do the lossy shift, then logically shift1927 // for unsigned left shifting, we do the lossy shift, then logically shift
...@@ -1951,7 +1951,7 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, TypeTableEntry *type_entry,...@@ -1951,7 +1951,7 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, TypeTableEntry *type_entry,
1951 return result;1951 return result;
1952}1952}
19531953
1954static LLVMValueRef gen_overflow_shr_op(CodeGen *g, TypeTableEntry *type_entry,1954static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry,
1955 LLVMValueRef val1, LLVMValueRef val2)1955 LLVMValueRef val1, LLVMValueRef val2)
1956{1956{
1957 assert(type_entry->id == TypeTableEntryIdInt);1957 assert(type_entry->id == TypeTableEntryIdInt);
...@@ -1976,7 +1976,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, TypeTableEntry *type_entry,...@@ -1976,7 +1976,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, TypeTableEntry *type_entry,
1976 return result;1976 return result;
1977}1977}
19781978
1979static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, TypeTableEntry *type_entry) {1979static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, ZigType *type_entry) {
1980 if (type_entry->id == TypeTableEntryIdInt)1980 if (type_entry->id == TypeTableEntryIdInt)
1981 return val;1981 return val;
19821982
...@@ -1984,7 +1984,7 @@ static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, TypeTableEntry *type...@@ -1984,7 +1984,7 @@ static LLVMValueRef gen_floor(CodeGen *g, LLVMValueRef val, TypeTableEntry *type
1984 return LLVMBuildCall(g->builder, floor_fn, &val, 1, "");1984 return LLVMBuildCall(g->builder, floor_fn, &val, 1, "");
1985}1985}
19861986
1987static LLVMValueRef gen_ceil(CodeGen *g, LLVMValueRef val, TypeTableEntry *type_entry) {1987static LLVMValueRef gen_ceil(CodeGen *g, LLVMValueRef val, ZigType *type_entry) {
1988 if (type_entry->id == TypeTableEntryIdInt)1988 if (type_entry->id == TypeTableEntryIdInt)
1989 return val;1989 return val;
19901990
...@@ -2018,7 +2018,7 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {...@@ -2018,7 +2018,7 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) {
20182018
2019static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math,2019static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
2020 LLVMValueRef val1, LLVMValueRef val2,2020 LLVMValueRef val1, LLVMValueRef val2,
2021 TypeTableEntry *type_entry, DivKind div_kind)2021 ZigType *type_entry, DivKind div_kind)
2022{2022{
2023 ZigLLVMSetFastMath(g->builder, want_fast_math);2023 ZigLLVMSetFastMath(g->builder, want_fast_math);
20242024
...@@ -2177,7 +2177,7 @@ enum RemKind {...@@ -2177,7 +2177,7 @@ enum RemKind {
21772177
2178static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math,2178static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math,
2179 LLVMValueRef val1, LLVMValueRef val2,2179 LLVMValueRef val1, LLVMValueRef val2,
2180 TypeTableEntry *type_entry, RemKind rem_kind)2180 ZigType *type_entry, RemKind rem_kind)
2181{2181{
2182 ZigLLVMSetFastMath(g->builder, want_fast_math);2182 ZigLLVMSetFastMath(g->builder, want_fast_math);
21832183
...@@ -2246,7 +2246,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,...@@ -2246,7 +2246,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
2246 (op_id == IrBinOpAdd || op_id == IrBinOpSub) &&2246 (op_id == IrBinOpAdd || op_id == IrBinOpSub) &&
2247 op1->value.type->data.pointer.ptr_len == PtrLenUnknown)2247 op1->value.type->data.pointer.ptr_len == PtrLenUnknown)
2248 );2248 );
2249 TypeTableEntry *type_entry = op1->value.type;2249 ZigType *type_entry = op1->value.type;
22502250
2251 bool want_runtime_safety = bin_op_instruction->safety_check_on &&2251 bool want_runtime_safety = bin_op_instruction->safety_check_on &&
2252 ir_want_runtime_safety(g, &bin_op_instruction->base);2252 ir_want_runtime_safety(g, &bin_op_instruction->base);
...@@ -2421,7 +2421,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,...@@ -2421,7 +2421,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
2421 zig_unreachable();2421 zig_unreachable();
2422}2422}
24232423
2424static void add_error_range_check(CodeGen *g, TypeTableEntry *err_set_type, TypeTableEntry *int_type, LLVMValueRef target_val) {2424static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *int_type, LLVMValueRef target_val) {
2425 assert(err_set_type->id == TypeTableEntryIdErrorSet);2425 assert(err_set_type->id == TypeTableEntryIdErrorSet);
24262426
2427 if (type_is_global_error_set(err_set_type)) {2427 if (type_is_global_error_set(err_set_type)) {
...@@ -2472,8 +2472,8 @@ static void add_error_range_check(CodeGen *g, TypeTableEntry *err_set_type, Type...@@ -2472,8 +2472,8 @@ static void add_error_range_check(CodeGen *g, TypeTableEntry *err_set_type, Type
2472static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,2472static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2473 IrInstructionCast *cast_instruction)2473 IrInstructionCast *cast_instruction)
2474{2474{
2475 TypeTableEntry *actual_type = cast_instruction->value->value.type;2475 ZigType *actual_type = cast_instruction->value->value.type;
2476 TypeTableEntry *wanted_type = cast_instruction->base.value.type;2476 ZigType *wanted_type = cast_instruction->base.value.type;
2477 LLVMValueRef expr_val = ir_llvm_value(g, cast_instruction->value);2477 LLVMValueRef expr_val = ir_llvm_value(g, cast_instruction->value);
2478 assert(expr_val);2478 assert(expr_val);
24792479
...@@ -2491,10 +2491,10 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -2491,10 +2491,10 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2491 assert(actual_type->id == TypeTableEntryIdStruct);2491 assert(actual_type->id == TypeTableEntryIdStruct);
2492 assert(actual_type->data.structure.is_slice);2492 assert(actual_type->data.structure.is_slice);
24932493
2494 TypeTableEntry *actual_pointer_type = actual_type->data.structure.fields[0].type_entry;2494 ZigType *actual_pointer_type = actual_type->data.structure.fields[0].type_entry;
2495 TypeTableEntry *actual_child_type = actual_pointer_type->data.pointer.child_type;2495 ZigType *actual_child_type = actual_pointer_type->data.pointer.child_type;
2496 TypeTableEntry *wanted_pointer_type = wanted_type->data.structure.fields[0].type_entry;2496 ZigType *wanted_pointer_type = wanted_type->data.structure.fields[0].type_entry;
2497 TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;2497 ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
24982498
24992499
2500 size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index].gen_index;2500 size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index].gen_index;
...@@ -2553,8 +2553,8 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -2553,8 +2553,8 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2553 assert(wanted_type->data.structure.is_slice);2553 assert(wanted_type->data.structure.is_slice);
2554 assert(actual_type->id == TypeTableEntryIdArray);2554 assert(actual_type->id == TypeTableEntryIdArray);
25552555
2556 TypeTableEntry *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;2556 ZigType *wanted_pointer_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
2557 TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;2557 ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
25582558
25592559
2560 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;2560 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
...@@ -2628,7 +2628,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -2628,7 +2628,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2628 case CastOpPtrOfArrayToSlice: {2628 case CastOpPtrOfArrayToSlice: {
2629 assert(cast_instruction->tmp_ptr);2629 assert(cast_instruction->tmp_ptr);
2630 assert(actual_type->id == TypeTableEntryIdPointer);2630 assert(actual_type->id == TypeTableEntryIdPointer);
2631 TypeTableEntry *array_type = actual_type->data.pointer.child_type;2631 ZigType *array_type = actual_type->data.pointer.child_type;
2632 assert(array_type->id == TypeTableEntryIdArray);2632 assert(array_type->id == TypeTableEntryIdArray);
26332633
2634 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,2634 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
...@@ -2655,7 +2655,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -2655,7 +2655,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
2655static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,2655static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
2656 IrInstructionPtrCast *instruction)2656 IrInstructionPtrCast *instruction)
2657{2657{
2658 TypeTableEntry *wanted_type = instruction->base.value.type;2658 ZigType *wanted_type = instruction->base.value.type;
2659 if (!type_has_bits(wanted_type)) {2659 if (!type_has_bits(wanted_type)) {
2660 return nullptr;2660 return nullptr;
2661 }2661 }
...@@ -2666,7 +2666,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,...@@ -2666,7 +2666,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutable *executable,
2666static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,2666static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
2667 IrInstructionBitCast *instruction)2667 IrInstructionBitCast *instruction)
2668{2668{
2669 TypeTableEntry *wanted_type = instruction->base.value.type;2669 ZigType *wanted_type = instruction->base.value.type;
2670 LLVMValueRef value = ir_llvm_value(g, instruction->value);2670 LLVMValueRef value = ir_llvm_value(g, instruction->value);
2671 return LLVMBuildBitCast(g->builder, value, wanted_type->type_ref, "");2671 return LLVMBuildBitCast(g->builder, value, wanted_type->type_ref, "");
2672}2672}
...@@ -2674,10 +2674,10 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,...@@ -2674,10 +2674,10 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutable *executable,
2674static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executable,2674static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executable,
2675 IrInstructionWidenOrShorten *instruction)2675 IrInstructionWidenOrShorten *instruction)
2676{2676{
2677 TypeTableEntry *actual_type = instruction->target->value.type;2677 ZigType *actual_type = instruction->target->value.type;
2678 // TODO instead of this logic, use the Noop instruction to change the type from2678 // TODO instead of this logic, use the Noop instruction to change the type from
2679 // enum_tag to the underlying int type2679 // enum_tag to the underlying int type
2680 TypeTableEntry *int_type;2680 ZigType *int_type;
2681 if (actual_type->id == TypeTableEntryIdEnum) {2681 if (actual_type->id == TypeTableEntryIdEnum) {
2682 int_type = actual_type->data.enumeration.tag_int_type;2682 int_type = actual_type->data.enumeration.tag_int_type;
2683 } else {2683 } else {
...@@ -2689,21 +2689,21 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executa...@@ -2689,21 +2689,21 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutable *executa
2689}2689}
26902690
2691static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutable *executable, IrInstructionIntToPtr *instruction) {2691static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutable *executable, IrInstructionIntToPtr *instruction) {
2692 TypeTableEntry *wanted_type = instruction->base.value.type;2692 ZigType *wanted_type = instruction->base.value.type;
2693 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);2693 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
2694 return LLVMBuildIntToPtr(g->builder, target_val, wanted_type->type_ref, "");2694 return LLVMBuildIntToPtr(g->builder, target_val, wanted_type->type_ref, "");
2695}2695}
26962696
2697static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutable *executable, IrInstructionPtrToInt *instruction) {2697static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutable *executable, IrInstructionPtrToInt *instruction) {
2698 TypeTableEntry *wanted_type = instruction->base.value.type;2698 ZigType *wanted_type = instruction->base.value.type;
2699 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);2699 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
2700 return LLVMBuildPtrToInt(g->builder, target_val, wanted_type->type_ref, "");2700 return LLVMBuildPtrToInt(g->builder, target_val, wanted_type->type_ref, "");
2701}2701}
27022702
2703static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable, IrInstructionIntToEnum *instruction) {2703static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable, IrInstructionIntToEnum *instruction) {
2704 TypeTableEntry *wanted_type = instruction->base.value.type;2704 ZigType *wanted_type = instruction->base.value.type;
2705 assert(wanted_type->id == TypeTableEntryIdEnum);2705 assert(wanted_type->id == TypeTableEntryIdEnum);
2706 TypeTableEntry *tag_int_type = wanted_type->data.enumeration.tag_int_type;2706 ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type;
27072707
2708 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);2708 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
2709 LLVMValueRef tag_int_value = gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base),2709 LLVMValueRef tag_int_value = gen_widen_or_shorten(g, ir_want_runtime_safety(g, &instruction->base),
...@@ -2728,10 +2728,10 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable,...@@ -2728,10 +2728,10 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutable *executable,
2728}2728}
27292729
2730static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, IrInstructionIntToErr *instruction) {2730static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, IrInstructionIntToErr *instruction) {
2731 TypeTableEntry *wanted_type = instruction->base.value.type;2731 ZigType *wanted_type = instruction->base.value.type;
2732 assert(wanted_type->id == TypeTableEntryIdErrorSet);2732 assert(wanted_type->id == TypeTableEntryIdErrorSet);
27332733
2734 TypeTableEntry *actual_type = instruction->target->value.type;2734 ZigType *actual_type = instruction->target->value.type;
2735 assert(actual_type->id == TypeTableEntryIdInt);2735 assert(actual_type->id == TypeTableEntryIdInt);
2736 assert(!actual_type->data.integral.is_signed);2736 assert(!actual_type->data.integral.is_signed);
27372737
...@@ -2745,11 +2745,11 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, I...@@ -2745,11 +2745,11 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutable *executable, I
2745}2745}
27462746
2747static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, IrInstructionErrToInt *instruction) {2747static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutable *executable, IrInstructionErrToInt *instruction) {
2748 TypeTableEntry *wanted_type = instruction->base.value.type;2748 ZigType *wanted_type = instruction->base.value.type;
2749 assert(wanted_type->id == TypeTableEntryIdInt);2749 assert(wanted_type->id == TypeTableEntryIdInt);
2750 assert(!wanted_type->data.integral.is_signed);2750 assert(!wanted_type->data.integral.is_signed);
27512751
2752 TypeTableEntry *actual_type = instruction->target->value.type;2752 ZigType *actual_type = instruction->target->value.type;
2753 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);2753 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
27542754
2755 if (actual_type->id == TypeTableEntryIdErrorSet) {2755 if (actual_type->id == TypeTableEntryIdErrorSet) {
...@@ -2799,7 +2799,7 @@ static LLVMValueRef ir_render_br(CodeGen *g, IrExecutable *executable, IrInstruc...@@ -2799,7 +2799,7 @@ static LLVMValueRef ir_render_br(CodeGen *g, IrExecutable *executable, IrInstruc
2799static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInstructionUnOp *un_op_instruction) {2799static LLVMValueRef ir_render_un_op(CodeGen *g, IrExecutable *executable, IrInstructionUnOp *un_op_instruction) {
2800 IrUnOp op_id = un_op_instruction->op_id;2800 IrUnOp op_id = un_op_instruction->op_id;
2801 LLVMValueRef expr = ir_llvm_value(g, un_op_instruction->value);2801 LLVMValueRef expr = ir_llvm_value(g, un_op_instruction->value);
2802 TypeTableEntry *expr_type = un_op_instruction->value->value.type;2802 ZigType *expr_type = un_op_instruction->value->value.type;
28032803
2804 switch (op_id) {2804 switch (op_id) {
2805 case IrUnOpInvalid:2805 case IrUnOpInvalid:
...@@ -2880,13 +2880,13 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,...@@ -2880,13 +2880,13 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
28802880
2881 if (have_init_expr) {2881 if (have_init_expr) {
2882 assert(var->value->type == init_value->value.type);2882 assert(var->value->type == init_value->value.type);
2883 TypeTableEntry *var_ptr_type = get_pointer_to_type_extra(g, var->value->type, false, false,2883 ZigType *var_ptr_type = get_pointer_to_type_extra(g, var->value->type, false, false,
2884 PtrLenSingle, var->align_bytes, 0, 0);2884 PtrLenSingle, var->align_bytes, 0, 0);
2885 gen_assign_raw(g, var->value_ref, var_ptr_type, ir_llvm_value(g, init_value));2885 gen_assign_raw(g, var->value_ref, var_ptr_type, ir_llvm_value(g, init_value));
2886 } else {2886 } else {
2887 bool want_safe = ir_want_runtime_safety(g, &decl_var_instruction->base);2887 bool want_safe = ir_want_runtime_safety(g, &decl_var_instruction->base);
2888 if (want_safe) {2888 if (want_safe) {
2889 TypeTableEntry *usize = g->builtin_types.entry_usize;2889 ZigType *usize = g->builtin_types.entry_usize;
2890 uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, var->value->type->type_ref);2890 uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, var->value->type->type_ref);
2891 assert(size_bytes > 0);2891 assert(size_bytes > 0);
28922892
...@@ -2915,12 +2915,12 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,...@@ -2915,12 +2915,12 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
2915}2915}
29162916
2917static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrInstructionLoadPtr *instruction) {2917static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, IrInstructionLoadPtr *instruction) {
2918 TypeTableEntry *child_type = instruction->base.value.type;2918 ZigType *child_type = instruction->base.value.type;
2919 if (!type_has_bits(child_type))2919 if (!type_has_bits(child_type))
2920 return nullptr;2920 return nullptr;
29212921
2922 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);2922 LLVMValueRef ptr = ir_llvm_value(g, instruction->ptr);
2923 TypeTableEntry *ptr_type = instruction->ptr->value.type;2923 ZigType *ptr_type = instruction->ptr->value.type;
2924 assert(ptr_type->id == TypeTableEntryIdPointer);2924 assert(ptr_type->id == TypeTableEntryIdPointer);
29252925
2926 uint32_t unaligned_bit_count = ptr_type->data.pointer.unaligned_bit_count;2926 uint32_t unaligned_bit_count = ptr_type->data.pointer.unaligned_bit_count;
...@@ -2947,7 +2947,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir...@@ -2947,7 +2947,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutable *executable, Ir
2947 LLVMValueRef value = ir_llvm_value(g, instruction->value);2947 LLVMValueRef value = ir_llvm_value(g, instruction->value);
29482948
2949 assert(instruction->ptr->value.type->id == TypeTableEntryIdPointer);2949 assert(instruction->ptr->value.type->id == TypeTableEntryIdPointer);
2950 TypeTableEntry *ptr_type = instruction->ptr->value.type;2950 ZigType *ptr_type = instruction->ptr->value.type;
29512951
2952 gen_assign_raw(g, ptr, ptr_type, value);2952 gen_assign_raw(g, ptr, ptr_type, value);
29532953
...@@ -2966,9 +2966,9 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutable *executable, IrIn...@@ -2966,9 +2966,9 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutable *executable, IrIn
29662966
2967static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrInstructionElemPtr *instruction) {2967static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrInstructionElemPtr *instruction) {
2968 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);2968 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);
2969 TypeTableEntry *array_ptr_type = instruction->array_ptr->value.type;2969 ZigType *array_ptr_type = instruction->array_ptr->value.type;
2970 assert(array_ptr_type->id == TypeTableEntryIdPointer);2970 assert(array_ptr_type->id == TypeTableEntryIdPointer);
2971 TypeTableEntry *array_type = array_ptr_type->data.pointer.child_type;2971 ZigType *array_type = array_ptr_type->data.pointer.child_type;
2972 LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);2972 LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);
2973 LLVMValueRef subscript_value = ir_llvm_value(g, instruction->elem_index);2973 LLVMValueRef subscript_value = ir_llvm_value(g, instruction->elem_index);
2974 assert(subscript_value);2974 assert(subscript_value);
...@@ -2993,7 +2993,7 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI...@@ -2993,7 +2993,7 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
2993 if (array_ptr_type->data.pointer.unaligned_bit_count != 0) {2993 if (array_ptr_type->data.pointer.unaligned_bit_count != 0) {
2994 return array_ptr_ptr;2994 return array_ptr_ptr;
2995 }2995 }
2996 TypeTableEntry *child_type = array_type->data.array.child_type;2996 ZigType *child_type = array_type->data.array.child_type;
2997 if (child_type->id == TypeTableEntryIdStruct &&2997 if (child_type->id == TypeTableEntryIdStruct &&
2998 child_type->data.structure.layout == ContainerLayoutPacked)2998 child_type->data.structure.layout == ContainerLayoutPacked)
2999 {2999 {
...@@ -3113,7 +3113,7 @@ static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) {...@@ -3113,7 +3113,7 @@ static void set_call_instr_sret(CodeGen *g, LLVMValueRef call_instr) {
31133113
3114static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {3114static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {
3115 LLVMValueRef fn_val;3115 LLVMValueRef fn_val;
3116 TypeTableEntry *fn_type;3116 ZigType *fn_type;
3117 if (instruction->fn_entry) {3117 if (instruction->fn_entry) {
3118 fn_val = fn_llvm_value(g, instruction->fn_entry);3118 fn_val = fn_llvm_value(g, instruction->fn_entry);
3119 fn_type = instruction->fn_entry->type_entry;3119 fn_type = instruction->fn_entry->type_entry;
...@@ -3125,7 +3125,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3125,7 +3125,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
31253125
3126 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;3126 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
31273127
3128 TypeTableEntry *src_return_type = fn_type_id->return_type;3128 ZigType *src_return_type = fn_type_id->return_type;
3129 bool ret_has_bits = type_has_bits(src_return_type);3129 bool ret_has_bits = type_has_bits(src_return_type);
31303130
3131 bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&3131 bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&
...@@ -3154,7 +3154,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -3154,7 +3154,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
3154 }3154 }
3155 for (size_t call_i = 0; call_i < instruction->arg_count; call_i += 1) {3155 for (size_t call_i = 0; call_i < instruction->arg_count; call_i += 1) {
3156 IrInstruction *param_instruction = instruction->args[call_i];3156 IrInstruction *param_instruction = instruction->args[call_i];
3157 TypeTableEntry *param_type = param_instruction->value.type;3157 ZigType *param_type = param_instruction->value.type;
3158 if (is_var_args || type_has_bits(param_type)) {3158 if (is_var_args || type_has_bits(param_type)) {
3159 LLVMValueRef param_value = ir_llvm_value(g, param_instruction);3159 LLVMValueRef param_value = ir_llvm_value(g, param_instruction);
3160 assert(param_value);3160 assert(param_value);
...@@ -3222,7 +3222,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa...@@ -3222,7 +3222,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
3222{3222{
3223 LLVMValueRef struct_ptr = ir_llvm_value(g, instruction->struct_ptr);3223 LLVMValueRef struct_ptr = ir_llvm_value(g, instruction->struct_ptr);
3224 // not necessarily a pointer. could be TypeTableEntryIdStruct3224 // not necessarily a pointer. could be TypeTableEntryIdStruct
3225 TypeTableEntry *struct_ptr_type = instruction->struct_ptr->value.type;3225 ZigType *struct_ptr_type = instruction->struct_ptr->value.type;
3226 TypeStructField *field = instruction->field;3226 TypeStructField *field = instruction->field;
32273227
3228 if (!type_has_bits(field->type_entry))3228 if (!type_has_bits(field->type_entry))
...@@ -3241,9 +3241,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa...@@ -3241,9 +3241,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
3241static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,3241static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable,
3242 IrInstructionUnionFieldPtr *instruction)3242 IrInstructionUnionFieldPtr *instruction)
3243{3243{
3244 TypeTableEntry *union_ptr_type = instruction->union_ptr->value.type;3244 ZigType *union_ptr_type = instruction->union_ptr->value.type;
3245 assert(union_ptr_type->id == TypeTableEntryIdPointer);3245 assert(union_ptr_type->id == TypeTableEntryIdPointer);
3246 TypeTableEntry *union_type = union_ptr_type->data.pointer.child_type;3246 ZigType *union_type = union_ptr_type->data.pointer.child_type;
3247 assert(union_type->id == TypeTableEntryIdUnion);3247 assert(union_type->id == TypeTableEntryIdUnion);
32483248
3249 TypeUnionField *field = instruction->field;3249 TypeUnionField *field = instruction->field;
...@@ -3411,9 +3411,9 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru...@@ -3411,9 +3411,9 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
3411 return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");3411 return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");
3412}3412}
34133413
3414static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {3414static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueRef maybe_handle) {
3415 assert(maybe_type->id == TypeTableEntryIdOptional);3415 assert(maybe_type->id == TypeTableEntryIdOptional);
3416 TypeTableEntry *child_type = maybe_type->data.maybe.child_type;3416 ZigType *child_type = maybe_type->data.maybe.child_type;
3417 if (child_type->zero_bits) {3417 if (child_type->zero_bits) {
3418 return maybe_handle;3418 return maybe_handle;
3419 } else {3419 } else {
...@@ -3436,11 +3436,11 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable...@@ -3436,11 +3436,11 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable
3436static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,3436static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,
3437 IrInstructionUnwrapOptional *instruction)3437 IrInstructionUnwrapOptional *instruction)
3438{3438{
3439 TypeTableEntry *ptr_type = instruction->value->value.type;3439 ZigType *ptr_type = instruction->value->value.type;
3440 assert(ptr_type->id == TypeTableEntryIdPointer);3440 assert(ptr_type->id == TypeTableEntryIdPointer);
3441 TypeTableEntry *maybe_type = ptr_type->data.pointer.child_type;3441 ZigType *maybe_type = ptr_type->data.pointer.child_type;
3442 assert(maybe_type->id == TypeTableEntryIdOptional);3442 assert(maybe_type->id == TypeTableEntryIdOptional);
3443 TypeTableEntry *child_type = maybe_type->data.maybe.child_type;3443 ZigType *child_type = maybe_type->data.maybe.child_type;
3444 LLVMValueRef maybe_ptr = ir_llvm_value(g, instruction->value);3444 LLVMValueRef maybe_ptr = ir_llvm_value(g, instruction->value);
3445 LLVMValueRef maybe_handle = get_handle_value(g, maybe_ptr, maybe_type, ptr_type);3445 LLVMValueRef maybe_handle = get_handle_value(g, maybe_ptr, maybe_type, ptr_type);
3446 if (ir_want_runtime_safety(g, &instruction->base) && instruction->safety_check_on) {3446 if (ir_want_runtime_safety(g, &instruction->base) && instruction->safety_check_on) {
...@@ -3467,7 +3467,7 @@ static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,...@@ -3467,7 +3467,7 @@ static LLVMValueRef ir_render_unwrap_maybe(CodeGen *g, IrExecutable *executable,
3467 }3467 }
3468}3468}
34693469
3470static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, BuiltinFnId fn_id) {3470static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *int_type, BuiltinFnId fn_id) {
3471 ZigLLVMFnKey key = {};3471 ZigLLVMFnKey key = {};
3472 const char *fn_name;3472 const char *fn_name;
3473 uint32_t n_args;3473 uint32_t n_args;
...@@ -3510,7 +3510,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui...@@ -3510,7 +3510,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
3510}3510}
35113511
3512static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstructionClz *instruction) {3512static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstructionClz *instruction) {
3513 TypeTableEntry *int_type = instruction->value->value.type;3513 ZigType *int_type = instruction->value->value.type;
3514 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);3514 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);
3515 LLVMValueRef operand = ir_llvm_value(g, instruction->value);3515 LLVMValueRef operand = ir_llvm_value(g, instruction->value);
3516 LLVMValueRef params[] {3516 LLVMValueRef params[] {
...@@ -3522,7 +3522,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstru...@@ -3522,7 +3522,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutable *executable, IrInstru
3522}3522}
35233523
3524static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstructionCtz *instruction) {3524static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstructionCtz *instruction) {
3525 TypeTableEntry *int_type = instruction->value->value.type;3525 ZigType *int_type = instruction->value->value.type;
3526 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);3526 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);
3527 LLVMValueRef operand = ir_llvm_value(g, instruction->value);3527 LLVMValueRef operand = ir_llvm_value(g, instruction->value);
3528 LLVMValueRef params[] {3528 LLVMValueRef params[] {
...@@ -3534,7 +3534,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru...@@ -3534,7 +3534,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
3534}3534}
35353535
3536static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutable *executable, IrInstructionPopCount *instruction) {3536static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutable *executable, IrInstructionPopCount *instruction) {
3537 TypeTableEntry *int_type = instruction->value->value.type;3537 ZigType *int_type = instruction->value->value.type;
3538 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);3538 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
3539 LLVMValueRef operand = ir_llvm_value(g, instruction->value);3539 LLVMValueRef operand = ir_llvm_value(g, instruction->value);
3540 LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, &operand, 1, "");3540 LLVMValueRef wrong_size_int = LLVMBuildCall(g->builder, fn_val, &operand, 1, "");
...@@ -3611,15 +3611,15 @@ static LLVMValueRef ir_render_err_name(CodeGen *g, IrExecutable *executable, IrI...@@ -3611,15 +3611,15 @@ static LLVMValueRef ir_render_err_name(CodeGen *g, IrExecutable *executable, IrI
3611 return LLVMBuildInBoundsGEP(g->builder, g->err_name_table, indices, 2, "");3611 return LLVMBuildInBoundsGEP(g->builder, g->err_name_table, indices, 2, "");
3612}3612}
36133613
3614static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_type) {3614static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
3615 assert(enum_type->id == TypeTableEntryIdEnum);3615 assert(enum_type->id == TypeTableEntryIdEnum);
3616 if (enum_type->data.enumeration.name_function)3616 if (enum_type->data.enumeration.name_function)
3617 return enum_type->data.enumeration.name_function;3617 return enum_type->data.enumeration.name_function;
36183618
3619 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,3619 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
3620 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);3620 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
3621 TypeTableEntry *u8_slice_type = get_slice_type(g, u8_ptr_type);3621 ZigType *u8_slice_type = get_slice_type(g, u8_ptr_type);
3622 TypeTableEntry *tag_int_type = enum_type->data.enumeration.tag_int_type;3622 ZigType *tag_int_type = enum_type->data.enumeration.tag_int_type;
36233623
3624 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMPointerType(u8_slice_type->type_ref, 0),3624 LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMPointerType(u8_slice_type->type_ref, 0),
3625 &tag_int_type->type_ref, 1, false);3625 &tag_int_type->type_ref, 1, false);
...@@ -3652,7 +3652,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_...@@ -3652,7 +3652,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_
3652 LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, tag_int_value, bad_value_block, field_count);3652 LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, tag_int_value, bad_value_block, field_count);
36533653
36543654
3655 TypeTableEntry *usize = g->builtin_types.entry_usize;3655 ZigType *usize = g->builtin_types.entry_usize;
3656 LLVMValueRef array_ptr_indices[] = {3656 LLVMValueRef array_ptr_indices[] = {
3657 LLVMConstNull(usize->type_ref),3657 LLVMConstNull(usize->type_ref),
3658 LLVMConstNull(usize->type_ref),3658 LLVMConstNull(usize->type_ref),
...@@ -3709,7 +3709,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_...@@ -3709,7 +3709,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, TypeTableEntry *enum_
3709static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable,3709static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable,
3710 IrInstructionTagName *instruction)3710 IrInstructionTagName *instruction)
3711{3711{
3712 TypeTableEntry *enum_type = instruction->target->value.type;3712 ZigType *enum_type = instruction->target->value.type;
3713 assert(enum_type->id == TypeTableEntryIdEnum);3713 assert(enum_type->id == TypeTableEntryIdEnum);
37143714
3715 LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type);3715 LLVMValueRef enum_name_function = get_enum_tag_name_function(g, enum_type);
...@@ -3722,10 +3722,10 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable...@@ -3722,10 +3722,10 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutable *executable
3722static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executable,3722static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executable,
3723 IrInstructionFieldParentPtr *instruction)3723 IrInstructionFieldParentPtr *instruction)
3724{3724{
3725 TypeTableEntry *container_ptr_type = instruction->base.value.type;3725 ZigType *container_ptr_type = instruction->base.value.type;
3726 assert(container_ptr_type->id == TypeTableEntryIdPointer);3726 assert(container_ptr_type->id == TypeTableEntryIdPointer);
37273727
3728 TypeTableEntry *container_type = container_ptr_type->data.pointer.child_type;3728 ZigType *container_type = container_ptr_type->data.pointer.child_type;
37293729
3730 size_t byte_offset = LLVMOffsetOfElement(g->target_data_ref,3730 size_t byte_offset = LLVMOffsetOfElement(g->target_data_ref,
3731 container_type->type_ref, instruction->field->gen_index);3731 container_type->type_ref, instruction->field->gen_index);
...@@ -3735,7 +3735,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executa...@@ -3735,7 +3735,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutable *executa
3735 if (byte_offset == 0) {3735 if (byte_offset == 0) {
3736 return LLVMBuildBitCast(g->builder, field_ptr_val, container_ptr_type->type_ref, "");3736 return LLVMBuildBitCast(g->builder, field_ptr_val, container_ptr_type->type_ref, "");
3737 } else {3737 } else {
3738 TypeTableEntry *usize = g->builtin_types.entry_usize;3738 ZigType *usize = g->builtin_types.entry_usize;
37393739
3740 LLVMValueRef field_ptr_int = LLVMBuildPtrToInt(g->builder, field_ptr_val,3740 LLVMValueRef field_ptr_int = LLVMBuildPtrToInt(g->builder, field_ptr_val,
3741 usize->type_ref, "");3741 usize->type_ref, "");
...@@ -3756,7 +3756,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I...@@ -3756,7 +3756,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
3756 return target_val;3756 return target_val;
3757 }3757 }
37583758
3759 TypeTableEntry *target_type = instruction->base.value.type;3759 ZigType *target_type = instruction->base.value.type;
3760 uint32_t align_bytes;3760 uint32_t align_bytes;
3761 LLVMValueRef ptr_val;3761 LLVMValueRef ptr_val;
37623762
...@@ -3781,7 +3781,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I...@@ -3781,7 +3781,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
3781 {3781 {
3782 zig_panic("TODO audit this function");3782 zig_panic("TODO audit this function");
3783 } else if (target_type->id == TypeTableEntryIdStruct && target_type->data.structure.is_slice) {3783 } else if (target_type->id == TypeTableEntryIdStruct && target_type->data.structure.is_slice) {
3784 TypeTableEntry *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;3784 ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
3785 align_bytes = slice_ptr_type->data.pointer.alignment;3785 align_bytes = slice_ptr_type->data.pointer.alignment;
37863786
3787 size_t ptr_index = target_type->data.structure.fields[slice_ptr_index].gen_index;3787 size_t ptr_index = target_type->data.structure.fields[slice_ptr_index].gen_index;
...@@ -3793,7 +3793,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I...@@ -3793,7 +3793,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutable *executable, I
37933793
3794 assert(align_bytes != 1);3794 assert(align_bytes != 1);
37953795
3796 TypeTableEntry *usize = g->builtin_types.entry_usize;3796 ZigType *usize = g->builtin_types.entry_usize;
3797 LLVMValueRef ptr_as_int_val = LLVMBuildPtrToInt(g->builder, ptr_val, usize->type_ref, "");3797 LLVMValueRef ptr_as_int_val = LLVMBuildPtrToInt(g->builder, ptr_val, usize->type_ref, "");
3798 LLVMValueRef alignment_minus_1 = LLVMConstInt(usize->type_ref, align_bytes - 1, false);3798 LLVMValueRef alignment_minus_1 = LLVMConstInt(usize->type_ref, align_bytes - 1, false);
3799 LLVMValueRef anded_val = LLVMBuildAnd(g->builder, ptr_as_int_val, alignment_minus_1, "");3799 LLVMValueRef anded_val = LLVMBuildAnd(g->builder, ptr_as_int_val, alignment_minus_1, "");
...@@ -3817,7 +3817,7 @@ static LLVMValueRef ir_render_error_return_trace(CodeGen *g, IrExecutable *execu...@@ -3817,7 +3817,7 @@ static LLVMValueRef ir_render_error_return_trace(CodeGen *g, IrExecutable *execu
3817{3817{
3818 LLVMValueRef cur_err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope);3818 LLVMValueRef cur_err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.scope);
3819 if (cur_err_ret_trace_val == nullptr) {3819 if (cur_err_ret_trace_val == nullptr) {
3820 TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);3820 ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(g);
3821 return LLVMConstNull(ptr_to_stack_trace_type->type_ref);3821 return LLVMConstNull(ptr_to_stack_trace_type->type_ref);
3822 }3822 }
3823 return cur_err_ret_trace_val;3823 return cur_err_ret_trace_val;
...@@ -3877,9 +3877,9 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn...@@ -3877,9 +3877,9 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutable *executable, IrIn
3877 LLVMValueRef result_val = ZigLLVMBuildCmpXchg(g->builder, ptr_val, cmp_val, new_val,3877 LLVMValueRef result_val = ZigLLVMBuildCmpXchg(g->builder, ptr_val, cmp_val, new_val,
3878 success_order, failure_order, instruction->is_weak);3878 success_order, failure_order, instruction->is_weak);
38793879
3880 TypeTableEntry *maybe_type = instruction->base.value.type;3880 ZigType *maybe_type = instruction->base.value.type;
3881 assert(maybe_type->id == TypeTableEntryIdOptional);3881 assert(maybe_type->id == TypeTableEntryIdOptional);
3882 TypeTableEntry *child_type = maybe_type->data.maybe.child_type;3882 ZigType *child_type = maybe_type->data.maybe.child_type;
38833883
3884 if (type_is_codegen_pointer(child_type)) {3884 if (type_is_codegen_pointer(child_type)) {
3885 LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, "");3885 LLVMValueRef payload_val = LLVMBuildExtractValue(g->builder, result_val, 0, "");
...@@ -3909,8 +3909,8 @@ static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutable *executable, IrInst...@@ -3909,8 +3909,8 @@ static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutable *executable, IrInst
39093909
3910static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutable *executable, IrInstructionTruncate *instruction) {3910static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutable *executable, IrInstructionTruncate *instruction) {
3911 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);3911 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
3912 TypeTableEntry *dest_type = instruction->base.value.type;3912 ZigType *dest_type = instruction->base.value.type;
3913 TypeTableEntry *src_type = instruction->target->value.type;3913 ZigType *src_type = instruction->target->value.type;
3914 if (dest_type == src_type) {3914 if (dest_type == src_type) {
3915 // no-op3915 // no-op
3916 return target_val;3916 return target_val;
...@@ -3931,7 +3931,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns...@@ -3931,7 +3931,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
39313931
3932 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");3932 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
39333933
3934 TypeTableEntry *ptr_type = instruction->dest_ptr->value.type;3934 ZigType *ptr_type = instruction->dest_ptr->value.type;
3935 assert(ptr_type->id == TypeTableEntryIdPointer);3935 assert(ptr_type->id == TypeTableEntryIdPointer);
39363936
3937 LLVMValueRef is_volatile = ptr_type->data.pointer.is_volatile ?3937 LLVMValueRef is_volatile = ptr_type->data.pointer.is_volatile ?
...@@ -3961,8 +3961,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns...@@ -3961,8 +3961,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
3961 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");3961 LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
3962 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, ptr_u8, "");3962 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, ptr_u8, "");
39633963
3964 TypeTableEntry *dest_ptr_type = instruction->dest_ptr->value.type;3964 ZigType *dest_ptr_type = instruction->dest_ptr->value.type;
3965 TypeTableEntry *src_ptr_type = instruction->src_ptr->value.type;3965 ZigType *src_ptr_type = instruction->src_ptr->value.type;
39663966
3967 assert(dest_ptr_type->id == TypeTableEntryIdPointer);3967 assert(dest_ptr_type->id == TypeTableEntryIdPointer);
3968 assert(src_ptr_type->id == TypeTableEntryIdPointer);3968 assert(src_ptr_type->id == TypeTableEntryIdPointer);
...@@ -3989,9 +3989,9 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst...@@ -3989,9 +3989,9 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
3989 assert(instruction->tmp_ptr);3989 assert(instruction->tmp_ptr);
39903990
3991 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);3991 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);
3992 TypeTableEntry *array_ptr_type = instruction->ptr->value.type;3992 ZigType *array_ptr_type = instruction->ptr->value.type;
3993 assert(array_ptr_type->id == TypeTableEntryIdPointer);3993 assert(array_ptr_type->id == TypeTableEntryIdPointer);
3994 TypeTableEntry *array_type = array_ptr_type->data.pointer.child_type;3994 ZigType *array_type = array_ptr_type->data.pointer.child_type;
3995 LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);3995 LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type);
39963996
3997 LLVMValueRef tmp_struct_ptr = instruction->tmp_ptr;3997 LLVMValueRef tmp_struct_ptr = instruction->tmp_ptr;
...@@ -4140,7 +4140,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) {...@@ -4140,7 +4140,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) {
4140 if (g->frame_address_fn_val)4140 if (g->frame_address_fn_val)
4141 return g->frame_address_fn_val;4141 return g->frame_address_fn_val;
41424142
4143 TypeTableEntry *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);4143 ZigType *return_type = get_pointer_to_type(g, g->builtin_types.entry_u8, true);
41444144
4145 LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,4145 LLVMTypeRef fn_type = LLVMFunctionType(return_type->type_ref,
4146 &g->builtin_types.entry_i32->type_ref, 1, false);4146 &g->builtin_types.entry_i32->type_ref, 1, false);
...@@ -4178,7 +4178,7 @@ static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable,...@@ -4178,7 +4178,7 @@ static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable,
4178}4178}
41794179
4180static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) {4180static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) {
4181 TypeTableEntry *int_type = instruction->result_ptr_type;4181 ZigType *int_type = instruction->result_ptr_type;
4182 assert(int_type->id == TypeTableEntryIdInt);4182 assert(int_type->id == TypeTableEntryIdInt);
41834183
4184 LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);4184 LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);
...@@ -4218,7 +4218,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,...@@ -4218,7 +4218,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,
4218 return render_shl_with_overflow(g, instruction);4218 return render_shl_with_overflow(g, instruction);
4219 }4219 }
42204220
4221 TypeTableEntry *int_type = instruction->result_ptr_type;4221 ZigType *int_type = instruction->result_ptr_type;
4222 assert(int_type->id == TypeTableEntryIdInt);4222 assert(int_type->id == TypeTableEntryIdInt);
42234223
4224 LLVMValueRef fn_val = get_int_overflow_fn(g, int_type, add_sub_mul);4224 LLVMValueRef fn_val = get_int_overflow_fn(g, int_type, add_sub_mul);
...@@ -4241,8 +4241,8 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,...@@ -4241,8 +4241,8 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutable *executable,
4241}4241}
42424242
4243static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrInstructionTestErr *instruction) {4243static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrInstructionTestErr *instruction) {
4244 TypeTableEntry *err_union_type = instruction->value->value.type;4244 ZigType *err_union_type = instruction->value->value.type;
4245 TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;4245 ZigType *payload_type = err_union_type->data.error_union.payload_type;
4246 LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->value);4246 LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->value);
42474247
4248 LLVMValueRef err_val;4248 LLVMValueRef err_val;
...@@ -4258,10 +4258,10 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI...@@ -4258,10 +4258,10 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutable *executable, IrI
4258}4258}
42594259
4260static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrCode *instruction) {4260static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrCode *instruction) {
4261 TypeTableEntry *ptr_type = instruction->value->value.type;4261 ZigType *ptr_type = instruction->value->value.type;
4262 assert(ptr_type->id == TypeTableEntryIdPointer);4262 assert(ptr_type->id == TypeTableEntryIdPointer);
4263 TypeTableEntry *err_union_type = ptr_type->data.pointer.child_type;4263 ZigType *err_union_type = ptr_type->data.pointer.child_type;
4264 TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;4264 ZigType *payload_type = err_union_type->data.error_union.payload_type;
4265 LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);4265 LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);
4266 LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);4266 LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);
42674267
...@@ -4274,10 +4274,10 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab...@@ -4274,10 +4274,10 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutable *executab
4274}4274}
42754275
4276static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrPayload *instruction) {4276static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *executable, IrInstructionUnwrapErrPayload *instruction) {
4277 TypeTableEntry *ptr_type = instruction->value->value.type;4277 ZigType *ptr_type = instruction->value->value.type;
4278 assert(ptr_type->id == TypeTableEntryIdPointer);4278 assert(ptr_type->id == TypeTableEntryIdPointer);
4279 TypeTableEntry *err_union_type = ptr_type->data.pointer.child_type;4279 ZigType *err_union_type = ptr_type->data.pointer.child_type;
4280 TypeTableEntry *payload_type = err_union_type->data.error_union.payload_type;4280 ZigType *payload_type = err_union_type->data.error_union.payload_type;
4281 LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);4281 LLVMValueRef err_union_ptr = ir_llvm_value(g, instruction->value);
4282 LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);4282 LLVMValueRef err_union_handle = get_handle_value(g, err_union_ptr, err_union_type, ptr_type);
42834283
...@@ -4313,11 +4313,11 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu...@@ -4313,11 +4313,11 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutable *execu
4313}4313}
43144314
4315static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, IrInstructionOptionalWrap *instruction) {4315static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, IrInstructionOptionalWrap *instruction) {
4316 TypeTableEntry *wanted_type = instruction->base.value.type;4316 ZigType *wanted_type = instruction->base.value.type;
43174317
4318 assert(wanted_type->id == TypeTableEntryIdOptional);4318 assert(wanted_type->id == TypeTableEntryIdOptional);
43194319
4320 TypeTableEntry *child_type = wanted_type->data.maybe.child_type;4320 ZigType *child_type = wanted_type->data.maybe.child_type;
43214321
4322 if (child_type->zero_bits) {4322 if (child_type->zero_bits) {
4323 return LLVMConstInt(LLVMInt1Type(), 1, false);4323 return LLVMConstInt(LLVMInt1Type(), 1, false);
...@@ -4340,12 +4340,12 @@ static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, I...@@ -4340,12 +4340,12 @@ static LLVMValueRef ir_render_maybe_wrap(CodeGen *g, IrExecutable *executable, I
4340}4340}
43414341
4342static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapCode *instruction) {4342static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapCode *instruction) {
4343 TypeTableEntry *wanted_type = instruction->base.value.type;4343 ZigType *wanted_type = instruction->base.value.type;
43444344
4345 assert(wanted_type->id == TypeTableEntryIdErrorUnion);4345 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
43464346
4347 TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;4347 ZigType *payload_type = wanted_type->data.error_union.payload_type;
4348 TypeTableEntry *err_set_type = wanted_type->data.error_union.err_set_type;4348 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
43494349
4350 LLVMValueRef err_val = ir_llvm_value(g, instruction->value);4350 LLVMValueRef err_val = ir_llvm_value(g, instruction->value);
43514351
...@@ -4361,12 +4361,12 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable...@@ -4361,12 +4361,12 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutable *executable
4361}4361}
43624362
4363static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapPayload *instruction) {4363static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executable, IrInstructionErrWrapPayload *instruction) {
4364 TypeTableEntry *wanted_type = instruction->base.value.type;4364 ZigType *wanted_type = instruction->base.value.type;
43654365
4366 assert(wanted_type->id == TypeTableEntryIdErrorUnion);4366 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
43674367
4368 TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;4368 ZigType *payload_type = wanted_type->data.error_union.payload_type;
4369 TypeTableEntry *err_set_type = wanted_type->data.error_union.err_set_type;4369 ZigType *err_set_type = wanted_type->data.error_union.err_set_type;
43704370
4371 if (!type_has_bits(err_set_type)) {4371 if (!type_has_bits(err_set_type)) {
4372 return ir_llvm_value(g, instruction->value);4372 return ir_llvm_value(g, instruction->value);
...@@ -4391,10 +4391,10 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executa...@@ -4391,10 +4391,10 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executa
4391}4391}
43924392
4393static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, IrInstructionUnionTag *instruction) {4393static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, IrInstructionUnionTag *instruction) {
4394 TypeTableEntry *union_type = instruction->value->value.type;4394 ZigType *union_type = instruction->value->value.type;
4395 assert(union_type->data.unionation.gen_tag_index != SIZE_MAX);4395 assert(union_type->data.unionation.gen_tag_index != SIZE_MAX);
43964396
4397 TypeTableEntry *tag_type = union_type->data.unionation.tag_type;4397 ZigType *tag_type = union_type->data.unionation.tag_type;
4398 if (!type_has_bits(tag_type))4398 if (!type_has_bits(tag_type))
4399 return nullptr;4399 return nullptr;
44004400
...@@ -4404,7 +4404,7 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, Ir...@@ -4404,7 +4404,7 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, Ir
44044404
4405 LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, union_val,4405 LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, union_val,
4406 union_type->data.unionation.gen_tag_index, "");4406 union_type->data.unionation.gen_tag_index, "");
4407 TypeTableEntry *ptr_type = get_pointer_to_type(g, tag_type, false);4407 ZigType *ptr_type = get_pointer_to_type(g, tag_type, false);
4408 return get_handle_value(g, tag_field_ptr, tag_type, ptr_type);4408 return get_handle_value(g, tag_field_ptr, tag_type, ptr_type);
4409}4409}
44104410
...@@ -4421,7 +4421,7 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,...@@ -4421,7 +4421,7 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,
44214421
4422 uint32_t field_align_bytes = get_abi_alignment(g, type_struct_field->type_entry);4422 uint32_t field_align_bytes = get_abi_alignment(g, type_struct_field->type_entry);
44234423
4424 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,4424 ZigType *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,
4425 false, false, PtrLenSingle, field_align_bytes,4425 false, false, PtrLenSingle, field_align_bytes,
4426 (uint32_t)type_struct_field->packed_bits_offset, (uint32_t)type_struct_field->unaligned_bit_count);4426 (uint32_t)type_struct_field->packed_bits_offset, (uint32_t)type_struct_field->unaligned_bit_count);
44274427
...@@ -4437,14 +4437,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I...@@ -4437,14 +4437,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I
4437 return nullptr;4437 return nullptr;
44384438
4439 uint32_t field_align_bytes = get_abi_alignment(g, type_union_field->type_entry);4439 uint32_t field_align_bytes = get_abi_alignment(g, type_union_field->type_entry);
4440 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_union_field->type_entry,4440 ZigType *ptr_type = get_pointer_to_type_extra(g, type_union_field->type_entry,
4441 false, false, PtrLenSingle, field_align_bytes,4441 false, false, PtrLenSingle, field_align_bytes,
4442 0, 0);4442 0, 0);
44434443
4444 LLVMValueRef uncasted_union_ptr;4444 LLVMValueRef uncasted_union_ptr;
4445 // Even if safety is off in this block, if the union type has the safety field, we have to populate it4445 // Even if safety is off in this block, if the union type has the safety field, we have to populate it
4446 // correctly. Otherwise safety code somewhere other than here could fail.4446 // correctly. Otherwise safety code somewhere other than here could fail.
4447 TypeTableEntry *union_type = instruction->union_type;4447 ZigType *union_type = instruction->union_type;
4448 if (union_type->data.unionation.gen_tag_index != SIZE_MAX) {4448 if (union_type->data.unionation.gen_tag_index != SIZE_MAX) {
4449 LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr,4449 LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr,
4450 union_type->data.unionation.gen_tag_index, "");4450 union_type->data.unionation.gen_tag_index, "");
...@@ -4470,14 +4470,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I...@@ -4470,14 +4470,14 @@ static LLVMValueRef ir_render_union_init(CodeGen *g, IrExecutable *executable, I
4470static LLVMValueRef ir_render_container_init_list(CodeGen *g, IrExecutable *executable,4470static LLVMValueRef ir_render_container_init_list(CodeGen *g, IrExecutable *executable,
4471 IrInstructionContainerInitList *instruction)4471 IrInstructionContainerInitList *instruction)
4472{4472{
4473 TypeTableEntry *array_type = instruction->base.value.type;4473 ZigType *array_type = instruction->base.value.type;
4474 assert(array_type->id == TypeTableEntryIdArray);4474 assert(array_type->id == TypeTableEntryIdArray);
4475 LLVMValueRef tmp_array_ptr = instruction->tmp_ptr;4475 LLVMValueRef tmp_array_ptr = instruction->tmp_ptr;
4476 assert(tmp_array_ptr);4476 assert(tmp_array_ptr);
44774477
4478 size_t field_count = instruction->item_count;4478 size_t field_count = instruction->item_count;
44794479
4480 TypeTableEntry *child_type = array_type->data.array.child_type;4480 ZigType *child_type = array_type->data.array.child_type;
4481 for (size_t i = 0; i < field_count; i += 1) {4481 for (size_t i = 0; i < field_count; i += 1) {
4482 LLVMValueRef elem_val = ir_llvm_value(g, instruction->items[i]);4482 LLVMValueRef elem_val = ir_llvm_value(g, instruction->items[i]);
4483 LLVMValueRef indices[] = {4483 LLVMValueRef indices[] = {
...@@ -4601,13 +4601,13 @@ static LLVMValueRef ir_render_coro_promise(CodeGen *g, IrExecutable *executable,...@@ -4601,13 +4601,13 @@ static LLVMValueRef ir_render_coro_promise(CodeGen *g, IrExecutable *executable,
4601 return LLVMBuildBitCast(g->builder, uncasted_result, instruction->base.value.type->type_ref, "");4601 return LLVMBuildBitCast(g->builder, uncasted_result, instruction->base.value.type->type_ref, "");
4602}4602}
46034603
4604static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_fn_type_ref, TypeTableEntry *fn_type) {4604static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_fn_type_ref, ZigType *fn_type) {
4605 if (g->coro_alloc_helper_fn_val != nullptr)4605 if (g->coro_alloc_helper_fn_val != nullptr)
4606 return g->coro_alloc_helper_fn_val;4606 return g->coro_alloc_helper_fn_val;
46074607
4608 assert(fn_type->id == TypeTableEntryIdFn);4608 assert(fn_type->id == TypeTableEntryIdFn);
46094609
4610 TypeTableEntry *ptr_to_err_code_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);4610 ZigType *ptr_to_err_code_type = get_pointer_to_type(g, g->builtin_types.entry_global_error_set, false);
46114611
4612 LLVMTypeRef alloc_raw_fn_type_ref = LLVMGetElementType(alloc_fn_type_ref);4612 LLVMTypeRef alloc_raw_fn_type_ref = LLVMGetElementType(alloc_fn_type_ref);
4613 LLVMTypeRef *alloc_fn_arg_types = allocate<LLVMTypeRef>(LLVMCountParamTypes(alloc_raw_fn_type_ref));4613 LLVMTypeRef *alloc_fn_arg_types = allocate<LLVMTypeRef>(LLVMCountParamTypes(alloc_raw_fn_type_ref));
...@@ -4686,9 +4686,9 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f...@@ -4686,9 +4686,9 @@ static LLVMValueRef get_coro_alloc_helper_fn_val(CodeGen *g, LLVMTypeRef alloc_f
46864686
4687 LLVMPositionBuilderAtEnd(g->builder, ok_block);4687 LLVMPositionBuilderAtEnd(g->builder, ok_block);
4688 LLVMValueRef payload_ptr = LLVMBuildStructGEP(g->builder, sret_ptr, err_union_payload_index, "");4688 LLVMValueRef payload_ptr = LLVMBuildStructGEP(g->builder, sret_ptr, err_union_payload_index, "");
4689 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,4689 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, false, false,
4690 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);4690 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
4691 TypeTableEntry *slice_type = get_slice_type(g, u8_ptr_type);4691 ZigType *slice_type = get_slice_type(g, u8_ptr_type);
4692 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;4692 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
4693 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, payload_ptr, ptr_field_index, "");4693 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, payload_ptr, ptr_field_index, "");
4694 LLVMValueRef ptr_val = LLVMBuildLoad(g->builder, ptr_field_ptr, "");4694 LLVMValueRef ptr_val = LLVMBuildLoad(g->builder, ptr_field_ptr, "");
...@@ -4733,7 +4733,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutable *executable,...@@ -4733,7 +4733,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutable *executable,
4733 IrInstructionAtomicRmw *instruction)4733 IrInstructionAtomicRmw *instruction)
4734{4734{
4735 bool is_signed;4735 bool is_signed;
4736 TypeTableEntry *operand_type = instruction->operand->value.type;4736 ZigType *operand_type = instruction->operand->value.type;
4737 if (operand_type->id == TypeTableEntryIdInt) {4737 if (operand_type->id == TypeTableEntryIdInt) {
4738 is_signed = operand_type->data.integral.is_signed;4738 is_signed = operand_type->data.integral.is_signed;
4739 } else {4739 } else {
...@@ -5090,14 +5090,14 @@ static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *ar...@@ -5090,14 +5090,14 @@ static LLVMValueRef gen_const_ptr_array_recursive(CodeGen *g, ConstExprValue *ar
50905090
5091 LLVMTypeKind el_type = LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(base_ptr)));5091 LLVMTypeKind el_type = LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(base_ptr)));
5092 if (el_type == LLVMArrayTypeKind) {5092 if (el_type == LLVMArrayTypeKind) {
5093 TypeTableEntry *usize = g->builtin_types.entry_usize;5093 ZigType *usize = g->builtin_types.entry_usize;
5094 LLVMValueRef indices[] = {5094 LLVMValueRef indices[] = {
5095 LLVMConstNull(usize->type_ref),5095 LLVMConstNull(usize->type_ref),
5096 LLVMConstInt(usize->type_ref, index, false),5096 LLVMConstInt(usize->type_ref, index, false),
5097 };5097 };
5098 return LLVMConstInBoundsGEP(base_ptr, indices, 2);5098 return LLVMConstInBoundsGEP(base_ptr, indices, 2);
5099 } else if (el_type == LLVMStructTypeKind) {5099 } else if (el_type == LLVMStructTypeKind) {
5100 TypeTableEntry *u32 = g->builtin_types.entry_u32;5100 ZigType *u32 = g->builtin_types.entry_u32;
5101 LLVMValueRef indices[] = {5101 LLVMValueRef indices[] = {
5102 LLVMConstNull(u32->type_ref),5102 LLVMConstNull(u32->type_ref),
5103 LLVMConstInt(u32->type_ref, index, false),5103 LLVMConstInt(u32->type_ref, index, false),
...@@ -5113,7 +5113,7 @@ static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *s...@@ -5113,7 +5113,7 @@ static LLVMValueRef gen_const_ptr_struct_recursive(CodeGen *g, ConstExprValue *s
5113 ConstParent *parent = &struct_const_val->data.x_struct.parent;5113 ConstParent *parent = &struct_const_val->data.x_struct.parent;
5114 LLVMValueRef base_ptr = gen_parent_ptr(g, struct_const_val, parent);5114 LLVMValueRef base_ptr = gen_parent_ptr(g, struct_const_val, parent);
51155115
5116 TypeTableEntry *u32 = g->builtin_types.entry_u32;5116 ZigType *u32 = g->builtin_types.entry_u32;
5117 LLVMValueRef indices[] = {5117 LLVMValueRef indices[] = {
5118 LLVMConstNull(u32->type_ref),5118 LLVMConstNull(u32->type_ref),
5119 LLVMConstInt(u32->type_ref, field_index, false),5119 LLVMConstInt(u32->type_ref, field_index, false),
...@@ -5125,7 +5125,7 @@ static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *un...@@ -5125,7 +5125,7 @@ static LLVMValueRef gen_const_ptr_union_recursive(CodeGen *g, ConstExprValue *un
5125 ConstParent *parent = &union_const_val->data.x_union.parent;5125 ConstParent *parent = &union_const_val->data.x_union.parent;
5126 LLVMValueRef base_ptr = gen_parent_ptr(g, union_const_val, parent);5126 LLVMValueRef base_ptr = gen_parent_ptr(g, union_const_val, parent);
51275127
5128 TypeTableEntry *u32 = g->builtin_types.entry_u32;5128 ZigType *u32 = g->builtin_types.entry_u32;
5129 LLVMValueRef indices[] = {5129 LLVMValueRef indices[] = {
5130 LLVMConstNull(u32->type_ref),5130 LLVMConstNull(u32->type_ref),
5131 LLVMConstInt(u32->type_ref, 0, false), // TODO test const union with more aligned tag type than payload5131 LLVMConstInt(u32->type_ref, 0, false), // TODO test const union with more aligned tag type than payload
...@@ -5143,7 +5143,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con...@@ -5143,7 +5143,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
5143 break;5143 break;
5144 }5144 }
51455145
5146 TypeTableEntry *type_entry = const_val->type;5146 ZigType *type_entry = const_val->type;
5147 assert(!type_entry->zero_bits);5147 assert(!type_entry->zero_bits);
5148 switch (type_entry->id) {5148 switch (type_entry->id) {
5149 case TypeTableEntryIdInvalid:5149 case TypeTableEntryIdInvalid:
...@@ -5228,7 +5228,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con...@@ -5228,7 +5228,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
52285228
5229// We have this because union constants can't be represented by the official union type,5229// We have this because union constants can't be represented by the official union type,
5230// and this property bubbles up in whatever aggregate type contains a union constant5230// and this property bubbles up in whatever aggregate type contains a union constant
5231static bool is_llvm_value_unnamed_type(TypeTableEntry *type_entry, LLVMValueRef val) {5231static bool is_llvm_value_unnamed_type(ZigType *type_entry, LLVMValueRef val) {
5232 return LLVMTypeOf(val) != type_entry->type_ref;5232 return LLVMTypeOf(val) != type_entry->type_ref;
5233}5233}
52345234
...@@ -5256,7 +5256,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con...@@ -5256,7 +5256,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
5256 assert(array_const_val->type->id == TypeTableEntryIdArray);5256 assert(array_const_val->type->id == TypeTableEntryIdArray);
5257 if (array_const_val->type->zero_bits) {5257 if (array_const_val->type->zero_bits) {
5258 // make this a null pointer5258 // make this a null pointer
5259 TypeTableEntry *usize = g->builtin_types.entry_usize;5259 ZigType *usize = g->builtin_types.entry_usize;
5260 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),5260 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),
5261 const_val->type->type_ref);5261 const_val->type->type_ref);
5262 render_const_val_global(g, const_val, "");5262 render_const_val_global(g, const_val, "");
...@@ -5276,7 +5276,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con...@@ -5276,7 +5276,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
5276 assert(struct_const_val->type->id == TypeTableEntryIdStruct);5276 assert(struct_const_val->type->id == TypeTableEntryIdStruct);
5277 if (struct_const_val->type->zero_bits) {5277 if (struct_const_val->type->zero_bits) {
5278 // make this a null pointer5278 // make this a null pointer
5279 TypeTableEntry *usize = g->builtin_types.entry_usize;5279 ZigType *usize = g->builtin_types.entry_usize;
5280 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),5280 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstNull(usize->type_ref),
5281 const_val->type->type_ref);5281 const_val->type->type_ref);
5282 render_const_val_global(g, const_val, "");5282 render_const_val_global(g, const_val, "");
...@@ -5296,7 +5296,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con...@@ -5296,7 +5296,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
5296 {5296 {
5297 render_const_val_global(g, const_val, name);5297 render_const_val_global(g, const_val, name);
5298 uint64_t addr_value = const_val->data.x_ptr.data.hard_coded_addr.addr;5298 uint64_t addr_value = const_val->data.x_ptr.data.hard_coded_addr.addr;
5299 TypeTableEntry *usize = g->builtin_types.entry_usize;5299 ZigType *usize = g->builtin_types.entry_usize;
5300 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstInt(usize->type_ref, addr_value, false),5300 const_val->global_refs->llvm_value = LLVMConstIntToPtr(LLVMConstInt(usize->type_ref, addr_value, false),
5301 const_val->type->type_ref);5301 const_val->type->type_ref);
5302 render_const_val_global(g, const_val, "");5302 render_const_val_global(g, const_val, "");
...@@ -5309,7 +5309,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con...@@ -5309,7 +5309,7 @@ static LLVMValueRef gen_const_val_ptr(CodeGen *g, ConstExprValue *const_val, con
5309}5309}
53105310
5311static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) {5311static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const char *name) {
5312 TypeTableEntry *type_entry = const_val->type;5312 ZigType *type_entry = const_val->type;
5313 assert(!type_entry->zero_bits);5313 assert(!type_entry->zero_bits);
53145314
5315 switch (const_val->special) {5315 switch (const_val->special) {
...@@ -5356,7 +5356,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c...@@ -5356,7 +5356,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
5356 }5356 }
5357 case TypeTableEntryIdOptional:5357 case TypeTableEntryIdOptional:
5358 {5358 {
5359 TypeTableEntry *child_type = type_entry->data.maybe.child_type;5359 ZigType *child_type = type_entry->data.maybe.child_type;
5360 if (child_type->zero_bits) {5360 if (child_type->zero_bits) {
5361 return LLVMConstInt(LLVMInt1Type(), const_val->data.x_optional ? 1 : 0, false);5361 return LLVMConstInt(LLVMInt1Type(), const_val->data.x_optional ? 1 : 0, false);
5362 } else if (type_is_codegen_pointer(child_type)) {5362 } else if (type_is_codegen_pointer(child_type)) {
...@@ -5559,8 +5559,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c...@@ -5559,8 +5559,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
5559 return gen_const_val_ptr(g, const_val, name);5559 return gen_const_val_ptr(g, const_val, name);
5560 case TypeTableEntryIdErrorUnion:5560 case TypeTableEntryIdErrorUnion:
5561 {5561 {
5562 TypeTableEntry *payload_type = type_entry->data.error_union.payload_type;5562 ZigType *payload_type = type_entry->data.error_union.payload_type;
5563 TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;5563 ZigType *err_set_type = type_entry->data.error_union.err_set_type;
5564 if (!type_has_bits(payload_type)) {5564 if (!type_has_bits(payload_type)) {
5565 assert(type_has_bits(err_set_type));5565 assert(type_has_bits(err_set_type));
5566 uint64_t value = const_val->data.x_err_union.err ? const_val->data.x_err_union.err->value : 0;5566 uint64_t value = const_val->data.x_err_union.err ? const_val->data.x_err_union.err->value : 0;
...@@ -5650,9 +5650,9 @@ static void generate_error_name_table(CodeGen *g) {...@@ -5650,9 +5650,9 @@ static void generate_error_name_table(CodeGen *g) {
56505650
5651 assert(g->errors_by_index.length > 0);5651 assert(g->errors_by_index.length > 0);
56525652
5653 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,5653 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
5654 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);5654 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
5655 TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);5655 ZigType *str_type = get_slice_type(g, u8_ptr_type);
56565656
5657 LLVMValueRef *values = allocate<LLVMValueRef>(g->errors_by_index.length);5657 LLVMValueRef *values = allocate<LLVMValueRef>(g->errors_by_index.length);
5658 values[0] = LLVMGetUndef(str_type->type_ref);5658 values[0] = LLVMGetUndef(str_type->type_ref);
...@@ -5700,7 +5700,7 @@ static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) {...@@ -5700,7 +5700,7 @@ static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) {
5700}5700}
57015701
5702static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef init_val,5702static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef init_val,
5703 TypeTableEntry *type_entry)5703 ZigType *type_entry)
5704{5704{
5705 if (g->strip_debug_symbols) {5705 if (g->strip_debug_symbols) {
5706 return;5706 return;
...@@ -5721,7 +5721,7 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini...@@ -5721,7 +5721,7 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini
5721 // TODO ^^ make an actual global variable5721 // TODO ^^ make an actual global variable
5722}5722}
57235723
5724static LLVMValueRef build_alloca(CodeGen *g, TypeTableEntry *type_entry, const char *name, uint32_t alignment) {5724static LLVMValueRef build_alloca(CodeGen *g, ZigType *type_entry, const char *name, uint32_t alignment) {
5725 assert(alignment > 0);5725 assert(alignment > 0);
5726 LLVMValueRef result = LLVMBuildAlloca(g->builder, type_entry->type_ref, name);5726 LLVMValueRef result = LLVMBuildAlloca(g->builder, type_entry->type_ref, name);
5727 LLVMSetAlignment(result, alignment);5727 LLVMSetAlignment(result, alignment);
...@@ -5794,7 +5794,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5794,7 +5794,7 @@ static void do_code_gen(CodeGen *g) {
5794 // Generate debug info for it but that's it.5794 // Generate debug info for it but that's it.
5795 ConstExprValue *const_val = var->value;5795 ConstExprValue *const_val = var->value;
5796 assert(const_val->special != ConstValSpecialRuntime);5796 assert(const_val->special != ConstValSpecialRuntime);
5797 TypeTableEntry *var_type = g->builtin_types.entry_f128;5797 ZigType *var_type = g->builtin_types.entry_f128;
5798 ConstExprValue coerced_value;5798 ConstExprValue coerced_value;
5799 coerced_value.special = ConstValSpecialStatic;5799 coerced_value.special = ConstValSpecialStatic;
5800 coerced_value.type = var_type;5800 coerced_value.type = var_type;
...@@ -5812,7 +5812,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5812,7 +5812,7 @@ static void do_code_gen(CodeGen *g) {
5812 if (bits_needed < 8) {5812 if (bits_needed < 8) {
5813 bits_needed = 8;5813 bits_needed = 8;
5814 }5814 }
5815 TypeTableEntry *var_type = get_int_type(g, const_val->data.x_bigint.is_negative, bits_needed);5815 ZigType *var_type = get_int_type(g, const_val->data.x_bigint.is_negative, bits_needed);
5816 LLVMValueRef init_val = bigint_to_llvm_const(var_type->type_ref, &const_val->data.x_bigint);5816 LLVMValueRef init_val = bigint_to_llvm_const(var_type->type_ref, &const_val->data.x_bigint);
5817 gen_global_var(g, var, init_val, var_type);5817 gen_global_var(g, var, init_val, var_type);
5818 continue;5818 continue;
...@@ -5869,7 +5869,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5869,7 +5869,7 @@ static void do_code_gen(CodeGen *g) {
5869 LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);5869 LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);
5870 g->cur_fn = fn_table_entry;5870 g->cur_fn = fn_table_entry;
5871 g->cur_fn_val = fn;5871 g->cur_fn_val = fn;
5872 TypeTableEntry *return_type = fn_table_entry->type_entry->data.fn.fn_type_id.return_type;5872 ZigType *return_type = fn_table_entry->type_entry->data.fn.fn_type_id.return_type;
5873 if (handle_is_ptr(return_type)) {5873 if (handle_is_ptr(return_type)) {
5874 g->cur_ret_ptr = LLVMGetParam(fn, 0);5874 g->cur_ret_ptr = LLVMGetParam(fn, 0);
5875 } else {5875 } else {
...@@ -5892,7 +5892,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5892,7 +5892,7 @@ static void do_code_gen(CodeGen *g) {
5892 bool have_err_ret_trace_stack = g->have_err_ret_tracing && fn_table_entry->calls_or_awaits_errorable_fn && !is_async && !have_err_ret_trace_arg;5892 bool have_err_ret_trace_stack = g->have_err_ret_tracing && fn_table_entry->calls_or_awaits_errorable_fn && !is_async && !have_err_ret_trace_arg;
5893 LLVMValueRef err_ret_array_val = nullptr;5893 LLVMValueRef err_ret_array_val = nullptr;
5894 if (have_err_ret_trace_stack) {5894 if (have_err_ret_trace_stack) {
5895 TypeTableEntry *array_type = get_array_type(g, g->builtin_types.entry_usize, stack_trace_ptr_count);5895 ZigType *array_type = get_array_type(g, g->builtin_types.entry_usize, stack_trace_ptr_count);
5896 err_ret_array_val = build_alloca(g, array_type, "error_return_trace_addresses", get_abi_alignment(g, array_type));5896 err_ret_array_val = build_alloca(g, array_type, "error_return_trace_addresses", get_abi_alignment(g, array_type));
5897 g->cur_err_ret_trace_val_stack = build_alloca(g, g->stack_trace_type, "error_return_trace", get_abi_alignment(g, g->stack_trace_type));5897 g->cur_err_ret_trace_val_stack = build_alloca(g, g->stack_trace_type, "error_return_trace", get_abi_alignment(g, g->stack_trace_type));
5898 } else {5898 } else {
...@@ -5903,7 +5903,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5903,7 +5903,7 @@ static void do_code_gen(CodeGen *g) {
5903 for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_list.length; alloca_i += 1) {5903 for (size_t alloca_i = 0; alloca_i < fn_table_entry->alloca_list.length; alloca_i += 1) {
5904 IrInstruction *instruction = fn_table_entry->alloca_list.at(alloca_i);5904 IrInstruction *instruction = fn_table_entry->alloca_list.at(alloca_i);
5905 LLVMValueRef *slot;5905 LLVMValueRef *slot;
5906 TypeTableEntry *slot_type = instruction->value.type;5906 ZigType *slot_type = instruction->value.type;
5907 if (instruction->id == IrInstructionIdCast) {5907 if (instruction->id == IrInstructionIdCast) {
5908 IrInstructionCast *cast_instruction = (IrInstructionCast *)instruction;5908 IrInstructionCast *cast_instruction = (IrInstructionCast *)instruction;
5909 slot = &cast_instruction->tmp_ptr;5909 slot = &cast_instruction->tmp_ptr;
...@@ -5968,7 +5968,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5968,7 +5968,7 @@ static void do_code_gen(CodeGen *g) {
59685968
5969 } else {5969 } else {
5970 assert(var->gen_arg_index != SIZE_MAX);5970 assert(var->gen_arg_index != SIZE_MAX);
5971 TypeTableEntry *gen_type;5971 ZigType *gen_type;
5972 FnGenParamInfo *gen_info = &fn_table_entry->type_entry->data.fn.gen_param_info[var->src_arg_index];5972 FnGenParamInfo *gen_info = &fn_table_entry->type_entry->data.fn.gen_param_info[var->src_arg_index];
59735973
5974 if (handle_is_ptr(var->value->type)) {5974 if (handle_is_ptr(var->value->type)) {
...@@ -5994,7 +5994,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5994,7 +5994,7 @@ static void do_code_gen(CodeGen *g) {
59945994
5995 // finishing error return trace setup. we have to do this after all the allocas.5995 // finishing error return trace setup. we have to do this after all the allocas.
5996 if (have_err_ret_trace_stack) {5996 if (have_err_ret_trace_stack) {
5997 TypeTableEntry *usize = g->builtin_types.entry_usize;5997 ZigType *usize = g->builtin_types.entry_usize;
5998 size_t index_field_index = g->stack_trace_type->data.structure.fields[0].gen_index;5998 size_t index_field_index = g->stack_trace_type->data.structure.fields[0].gen_index;
5999 LLVMValueRef index_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)index_field_index, "");5999 LLVMValueRef index_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)index_field_index, "");
6000 gen_store_untyped(g, LLVMConstNull(usize->type_ref), index_field_ptr, 0, false);6000 gen_store_untyped(g, LLVMConstNull(usize->type_ref), index_field_ptr, 0, false);
...@@ -6002,14 +6002,14 @@ static void do_code_gen(CodeGen *g) {...@@ -6002,14 +6002,14 @@ static void do_code_gen(CodeGen *g) {
6002 size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;6002 size_t addresses_field_index = g->stack_trace_type->data.structure.fields[1].gen_index;
6003 LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)addresses_field_index, "");6003 LLVMValueRef addresses_field_ptr = LLVMBuildStructGEP(g->builder, g->cur_err_ret_trace_val_stack, (unsigned)addresses_field_index, "");
60046004
6005 TypeTableEntry *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;6005 ZigType *slice_type = g->stack_trace_type->data.structure.fields[1].type_entry;
6006 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;6006 size_t ptr_field_index = slice_type->data.structure.fields[slice_ptr_index].gen_index;
6007 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");6007 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, addresses_field_ptr, (unsigned)ptr_field_index, "");
6008 LLVMValueRef zero = LLVMConstNull(usize->type_ref);6008 LLVMValueRef zero = LLVMConstNull(usize->type_ref);
6009 LLVMValueRef indices[] = {zero, zero};6009 LLVMValueRef indices[] = {zero, zero};
6010 LLVMValueRef err_ret_array_val_elem0_ptr = LLVMBuildInBoundsGEP(g->builder, err_ret_array_val,6010 LLVMValueRef err_ret_array_val_elem0_ptr = LLVMBuildInBoundsGEP(g->builder, err_ret_array_val,
6011 indices, 2, "");6011 indices, 2, "");
6012 TypeTableEntry *ptr_ptr_usize_type = get_pointer_to_type(g, get_pointer_to_type(g, usize, false), false);6012 ZigType *ptr_ptr_usize_type = get_pointer_to_type(g, get_pointer_to_type(g, usize, false), false);
6013 gen_store(g, err_ret_array_val_elem0_ptr, ptr_field_ptr, ptr_ptr_usize_type);6013 gen_store(g, err_ret_array_val_elem0_ptr, ptr_field_ptr, ptr_ptr_usize_type);
60146014
6015 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;6015 size_t len_field_index = slice_type->data.structure.fields[slice_len_index].gen_index;
...@@ -6173,51 +6173,51 @@ static const GlobalLinkageValue global_linkage_values[] = {...@@ -6173,51 +6173,51 @@ static const GlobalLinkageValue global_linkage_values[] = {
6173static void define_builtin_types(CodeGen *g) {6173static void define_builtin_types(CodeGen *g) {
6174 {6174 {
6175 // if this type is anywhere in the AST, we should never hit codegen.6175 // if this type is anywhere in the AST, we should never hit codegen.
6176 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInvalid);6176 ZigType *entry = new_type_table_entry(TypeTableEntryIdInvalid);
6177 buf_init_from_str(&entry->name, "(invalid)");6177 buf_init_from_str(&entry->name, "(invalid)");
6178 entry->zero_bits = true;6178 entry->zero_bits = true;
6179 g->builtin_types.entry_invalid = entry;6179 g->builtin_types.entry_invalid = entry;
6180 }6180 }
6181 {6181 {
6182 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNamespace);6182 ZigType *entry = new_type_table_entry(TypeTableEntryIdNamespace);
6183 buf_init_from_str(&entry->name, "(namespace)");6183 buf_init_from_str(&entry->name, "(namespace)");
6184 entry->zero_bits = true;6184 entry->zero_bits = true;
6185 g->builtin_types.entry_namespace = entry;6185 g->builtin_types.entry_namespace = entry;
6186 }6186 }
6187 {6187 {
6188 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdBlock);6188 ZigType *entry = new_type_table_entry(TypeTableEntryIdBlock);
6189 buf_init_from_str(&entry->name, "(block)");6189 buf_init_from_str(&entry->name, "(block)");
6190 entry->zero_bits = true;6190 entry->zero_bits = true;
6191 g->builtin_types.entry_block = entry;6191 g->builtin_types.entry_block = entry;
6192 }6192 }
6193 {6193 {
6194 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);6194 ZigType *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);
6195 buf_init_from_str(&entry->name, "comptime_float");6195 buf_init_from_str(&entry->name, "comptime_float");
6196 entry->zero_bits = true;6196 entry->zero_bits = true;
6197 g->builtin_types.entry_num_lit_float = entry;6197 g->builtin_types.entry_num_lit_float = entry;
6198 g->primitive_type_table.put(&entry->name, entry);6198 g->primitive_type_table.put(&entry->name, entry);
6199 }6199 }
6200 {6200 {
6201 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);6201 ZigType *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);
6202 buf_init_from_str(&entry->name, "comptime_int");6202 buf_init_from_str(&entry->name, "comptime_int");
6203 entry->zero_bits = true;6203 entry->zero_bits = true;
6204 g->builtin_types.entry_num_lit_int = entry;6204 g->builtin_types.entry_num_lit_int = entry;
6205 g->primitive_type_table.put(&entry->name, entry);6205 g->primitive_type_table.put(&entry->name, entry);
6206 }6206 }
6207 {6207 {
6208 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefined);6208 ZigType *entry = new_type_table_entry(TypeTableEntryIdUndefined);
6209 buf_init_from_str(&entry->name, "(undefined)");6209 buf_init_from_str(&entry->name, "(undefined)");
6210 entry->zero_bits = true;6210 entry->zero_bits = true;
6211 g->builtin_types.entry_undef = entry;6211 g->builtin_types.entry_undef = entry;
6212 }6212 }
6213 {6213 {
6214 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNull);6214 ZigType *entry = new_type_table_entry(TypeTableEntryIdNull);
6215 buf_init_from_str(&entry->name, "(null)");6215 buf_init_from_str(&entry->name, "(null)");
6216 entry->zero_bits = true;6216 entry->zero_bits = true;
6217 g->builtin_types.entry_null = entry;6217 g->builtin_types.entry_null = entry;
6218 }6218 }
6219 {6219 {
6220 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdArgTuple);6220 ZigType *entry = new_type_table_entry(TypeTableEntryIdArgTuple);
6221 buf_init_from_str(&entry->name, "(args)");6221 buf_init_from_str(&entry->name, "(args)");
6222 entry->zero_bits = true;6222 entry->zero_bits = true;
6223 g->builtin_types.entry_arg_tuple = entry;6223 g->builtin_types.entry_arg_tuple = entry;
...@@ -6228,7 +6228,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6228,7 +6228,7 @@ static void define_builtin_types(CodeGen *g) {
6228 uint32_t size_in_bits = target_c_type_size_in_bits(&g->zig_target, info->id);6228 uint32_t size_in_bits = target_c_type_size_in_bits(&g->zig_target, info->id);
6229 bool is_signed = info->is_signed;6229 bool is_signed = info->is_signed;
62306230
6231 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);6231 ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
6232 entry->type_ref = LLVMIntType(size_in_bits);6232 entry->type_ref = LLVMIntType(size_in_bits);
62336233
6234 buf_init_from_str(&entry->name, info->name);6234 buf_init_from_str(&entry->name, info->name);
...@@ -6245,7 +6245,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6245,7 +6245,7 @@ static void define_builtin_types(CodeGen *g) {
6245 }6245 }
62466246
6247 {6247 {
6248 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdBool);6248 ZigType *entry = new_type_table_entry(TypeTableEntryIdBool);
6249 entry->type_ref = LLVMInt1Type();6249 entry->type_ref = LLVMInt1Type();
6250 buf_init_from_str(&entry->name, "bool");6250 buf_init_from_str(&entry->name, "bool");
6251 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);6251 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);
...@@ -6259,7 +6259,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6259,7 +6259,7 @@ static void define_builtin_types(CodeGen *g) {
6259 for (size_t sign_i = 0; sign_i < array_length(is_signed_list); sign_i += 1) {6259 for (size_t sign_i = 0; sign_i < array_length(is_signed_list); sign_i += 1) {
6260 bool is_signed = is_signed_list[sign_i];6260 bool is_signed = is_signed_list[sign_i];
62616261
6262 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);6262 ZigType *entry = new_type_table_entry(TypeTableEntryIdInt);
6263 entry->type_ref = LLVMIntType(g->pointer_size_bytes * 8);6263 entry->type_ref = LLVMIntType(g->pointer_size_bytes * 8);
62646264
6265 const char u_or_i = is_signed ? 'i' : 'u';6265 const char u_or_i = is_signed ? 'i' : 'u';
...@@ -6286,8 +6286,8 @@ static void define_builtin_types(CodeGen *g) {...@@ -6286,8 +6286,8 @@ static void define_builtin_types(CodeGen *g) {
6286 const char *name,6286 const char *name,
6287 uint32_t bit_count,6287 uint32_t bit_count,
6288 LLVMTypeRef type_ref,6288 LLVMTypeRef type_ref,
6289 TypeTableEntry **field) {6289 ZigType **field) {
6290 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdFloat);6290 ZigType *entry = new_type_table_entry(TypeTableEntryIdFloat);
6291 entry->type_ref = type_ref;6291 entry->type_ref = type_ref;
6292 buf_init_from_str(&entry->name, name);6292 buf_init_from_str(&entry->name, name);
6293 entry->data.floating.bit_count = bit_count;6293 entry->data.floating.bit_count = bit_count;
...@@ -6306,7 +6306,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6306,7 +6306,7 @@ static void define_builtin_types(CodeGen *g) {
6306 add_fp_entry(g, "c_longdouble", 80, LLVMX86FP80Type(), &g->builtin_types.entry_c_longdouble);6306 add_fp_entry(g, "c_longdouble", 80, LLVMX86FP80Type(), &g->builtin_types.entry_c_longdouble);
63076307
6308 {6308 {
6309 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdVoid);6309 ZigType *entry = new_type_table_entry(TypeTableEntryIdVoid);
6310 entry->type_ref = LLVMVoidType();6310 entry->type_ref = LLVMVoidType();
6311 entry->zero_bits = true;6311 entry->zero_bits = true;
6312 buf_init_from_str(&entry->name, "void");6312 buf_init_from_str(&entry->name, "void");
...@@ -6317,7 +6317,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6317,7 +6317,7 @@ static void define_builtin_types(CodeGen *g) {
6317 g->primitive_type_table.put(&entry->name, entry);6317 g->primitive_type_table.put(&entry->name, entry);
6318 }6318 }
6319 {6319 {
6320 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUnreachable);6320 ZigType *entry = new_type_table_entry(TypeTableEntryIdUnreachable);
6321 entry->type_ref = LLVMVoidType();6321 entry->type_ref = LLVMVoidType();
6322 entry->zero_bits = true;6322 entry->zero_bits = true;
6323 buf_init_from_str(&entry->name, "noreturn");6323 buf_init_from_str(&entry->name, "noreturn");
...@@ -6326,7 +6326,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6326,7 +6326,7 @@ static void define_builtin_types(CodeGen *g) {
6326 g->primitive_type_table.put(&entry->name, entry);6326 g->primitive_type_table.put(&entry->name, entry);
6327 }6327 }
6328 {6328 {
6329 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdMetaType);6329 ZigType *entry = new_type_table_entry(TypeTableEntryIdMetaType);
6330 buf_init_from_str(&entry->name, "type");6330 buf_init_from_str(&entry->name, "type");
6331 entry->zero_bits = true;6331 entry->zero_bits = true;
6332 g->builtin_types.entry_type = entry;6332 g->builtin_types.entry_type = entry;
...@@ -6348,7 +6348,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6348,7 +6348,7 @@ static void define_builtin_types(CodeGen *g) {
6348 }6348 }
63496349
6350 {6350 {
6351 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdErrorSet);6351 ZigType *entry = new_type_table_entry(TypeTableEntryIdErrorSet);
6352 buf_init_from_str(&entry->name, "error");6352 buf_init_from_str(&entry->name, "error");
6353 entry->data.error_set.err_count = UINT32_MAX;6353 entry->data.error_set.err_count = UINT32_MAX;
63546354
...@@ -6370,7 +6370,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -6370,7 +6370,7 @@ static void define_builtin_types(CodeGen *g) {
6370 g->primitive_type_table.put(&entry->name, entry);6370 g->primitive_type_table.put(&entry->name, entry);
6371 }6371 }
6372 {6372 {
6373 TypeTableEntry *entry = get_promise_type(g, nullptr);6373 ZigType *entry = get_promise_type(g, nullptr);
6374 g->primitive_type_table.put(&entry->name, entry);6374 g->primitive_type_table.put(&entry->name, entry);
6375 }6375 }
63766376
...@@ -6623,7 +6623,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {...@@ -6623,7 +6623,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
6623 buf_appendf(contents, "pub const TypeId = enum {\n");6623 buf_appendf(contents, "pub const TypeId = enum {\n");
6624 size_t field_count = type_id_len();6624 size_t field_count = type_id_len();
6625 for (size_t i = 0; i < field_count; i += 1) {6625 for (size_t i = 0; i < field_count; i += 1) {
6626 const TypeTableEntryId id = type_id_at_index(i);6626 const ZigTypeId id = type_id_at_index(i);
6627 buf_appendf(contents, " %s,\n", type_id_name(id));6627 buf_appendf(contents, " %s,\n", type_id_name(id));
6628 }6628 }
6629 buf_appendf(contents, "};\n\n");6629 buf_appendf(contents, "};\n\n");
...@@ -7068,14 +7068,14 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {...@@ -7068,14 +7068,14 @@ static void create_test_compile_var_and_add_test_runner(CodeGen *g) {
7068 exit(0);7068 exit(0);
7069 }7069 }
70707070
7071 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,7071 ZigType *u8_ptr_type = get_pointer_to_type_extra(g, g->builtin_types.entry_u8, true, false,
7072 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);7072 PtrLenUnknown, get_abi_alignment(g, g->builtin_types.entry_u8), 0, 0);
7073 TypeTableEntry *str_type = get_slice_type(g, u8_ptr_type);7073 ZigType *str_type = get_slice_type(g, u8_ptr_type);
7074 TypeTableEntry *fn_type = get_test_fn_type(g);7074 ZigType *fn_type = get_test_fn_type(g);
70757075
7076 const char *field_names[] = { "name", "func", };7076 const char *field_names[] = { "name", "func", };
7077 TypeTableEntry *field_types[] = { str_type, fn_type, };7077 ZigType *field_types[] = { str_type, fn_type, };
7078 TypeTableEntry *struct_type = get_struct_type(g, "ZigTestFn", field_names, field_types, 2);7078 ZigType *struct_type = get_struct_type(g, "ZigTestFn", field_names, field_types, 2);
70797079
7080 ConstExprValue *test_fn_array = create_const_vals(1);7080 ConstExprValue *test_fn_array = create_const_vals(1);
7081 test_fn_array->type = get_array_type(g, struct_type, g->test_fns.length);7081 test_fn_array->type = get_array_type(g, struct_type, g->test_fns.length);
...@@ -7217,10 +7217,10 @@ static const char *c_int_type_names[] = {...@@ -7217,10 +7217,10 @@ static const char *c_int_type_names[] = {
7217};7217};
72187218
7219struct GenH {7219struct GenH {
7220 ZigList<TypeTableEntry *> types_to_declare;7220 ZigList<ZigType *> types_to_declare;
7221};7221};
72227222
7223static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry) {7223static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_entry) {
7224 if (type_entry->gen_h_loop_flag)7224 if (type_entry->gen_h_loop_flag)
7225 return;7225 return;
7226 type_entry->gen_h_loop_flag = true;7226 type_entry->gen_h_loop_flag = true;
...@@ -7285,7 +7285,7 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry...@@ -7285,7 +7285,7 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry
7285 }7285 }
7286}7286}
72877287
7288static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf *out_buf) {7288static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_buf) {
7289 assert(type_entry);7289 assert(type_entry);
72907290
7291 for (size_t i = 0; i < array_length(c_int_type_names); i += 1) {7291 for (size_t i = 0; i < array_length(c_int_type_names); i += 1) {
...@@ -7354,7 +7354,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf...@@ -7354,7 +7354,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
7354 case TypeTableEntryIdPointer:7354 case TypeTableEntryIdPointer:
7355 {7355 {
7356 Buf child_buf = BUF_INIT;7356 Buf child_buf = BUF_INIT;
7357 TypeTableEntry *child_type = type_entry->data.pointer.child_type;7357 ZigType *child_type = type_entry->data.pointer.child_type;
7358 get_c_type(g, gen_h, child_type, &child_buf);7358 get_c_type(g, gen_h, child_type, &child_buf);
73597359
7360 const char *const_str = type_entry->data.pointer.is_const ? "const " : "";7360 const char *const_str = type_entry->data.pointer.is_const ? "const " : "";
...@@ -7364,7 +7364,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf...@@ -7364,7 +7364,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
7364 }7364 }
7365 case TypeTableEntryIdOptional:7365 case TypeTableEntryIdOptional:
7366 {7366 {
7367 TypeTableEntry *child_type = type_entry->data.maybe.child_type;7367 ZigType *child_type = type_entry->data.maybe.child_type;
7368 if (child_type->zero_bits) {7368 if (child_type->zero_bits) {
7369 buf_init_from_str(out_buf, "bool");7369 buf_init_from_str(out_buf, "bool");
7370 return;7370 return;
...@@ -7555,7 +7555,7 @@ static void gen_h_file(CodeGen *g) {...@@ -7555,7 +7555,7 @@ static void gen_h_file(CodeGen *g) {
7555 fprintf(out_h, "\n");7555 fprintf(out_h, "\n");
75567556
7557 for (size_t type_i = 0; type_i < gen_h->types_to_declare.length; type_i += 1) {7557 for (size_t type_i = 0; type_i < gen_h->types_to_declare.length; type_i += 1) {
7558 TypeTableEntry *type_entry = gen_h->types_to_declare.at(type_i);7558 ZigType *type_entry = gen_h->types_to_declare.at(type_i);
7559 switch (type_entry->id) {7559 switch (type_entry->id) {
7560 case TypeTableEntryIdInvalid:7560 case TypeTableEntryIdInvalid:
7561 case TypeTableEntryIdMetaType:7561 case TypeTableEntryIdMetaType:
src/ir.cpp+553-553
...@@ -33,7 +33,7 @@ struct IrAnalyze {...@@ -33,7 +33,7 @@ struct IrAnalyze {
33 IrExecContext exec_context;33 IrExecContext exec_context;
34 size_t old_bb_index;34 size_t old_bb_index;
35 size_t instruction_index;35 size_t instruction_index;
36 TypeTableEntry *explicit_return_type;36 ZigType *explicit_return_type;
37 ZigList<IrInstruction *> src_implicit_return_type_list;37 ZigList<IrInstruction *> src_implicit_return_type_list;
38 IrBasicBlock *const_predecessor_bb;38 IrBasicBlock *const_predecessor_bb;
39};39};
...@@ -99,38 +99,38 @@ struct ConstCastOnly {...@@ -99,38 +99,38 @@ struct ConstCastOnly {
99};99};
100100
101struct ConstCastTypeMismatch {101struct ConstCastTypeMismatch {
102 TypeTableEntry *wanted_type;102 ZigType *wanted_type;
103 TypeTableEntry *actual_type;103 ZigType *actual_type;
104};104};
105105
106struct ConstCastOptionalMismatch {106struct ConstCastOptionalMismatch {
107 ConstCastOnly child;107 ConstCastOnly child;
108 TypeTableEntry *wanted_child;108 ZigType *wanted_child;
109 TypeTableEntry *actual_child;109 ZigType *actual_child;
110};110};
111111
112struct ConstCastPointerMismatch {112struct ConstCastPointerMismatch {
113 ConstCastOnly child;113 ConstCastOnly child;
114 TypeTableEntry *wanted_child;114 ZigType *wanted_child;
115 TypeTableEntry *actual_child;115 ZigType *actual_child;
116};116};
117117
118struct ConstCastSliceMismatch {118struct ConstCastSliceMismatch {
119 ConstCastOnly child;119 ConstCastOnly child;
120 TypeTableEntry *wanted_child;120 ZigType *wanted_child;
121 TypeTableEntry *actual_child;121 ZigType *actual_child;
122};122};
123123
124struct ConstCastErrUnionErrSetMismatch {124struct ConstCastErrUnionErrSetMismatch {
125 ConstCastOnly child;125 ConstCastOnly child;
126 TypeTableEntry *wanted_err_set;126 ZigType *wanted_err_set;
127 TypeTableEntry *actual_err_set;127 ZigType *actual_err_set;
128};128};
129129
130struct ConstCastErrUnionPayloadMismatch {130struct ConstCastErrUnionPayloadMismatch {
131 ConstCastOnly child;131 ConstCastOnly child;
132 TypeTableEntry *wanted_payload;132 ZigType *wanted_payload;
133 TypeTableEntry *actual_payload;133 ZigType *actual_payload;
134};134};
135135
136struct ConstCastErrSetMismatch {136struct ConstCastErrSetMismatch {
...@@ -139,17 +139,17 @@ struct ConstCastErrSetMismatch {...@@ -139,17 +139,17 @@ struct ConstCastErrSetMismatch {
139139
140static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);140static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
141static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval);141static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval);
142static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction);142static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction);
143static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *expected_type);143static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type);
144static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr);144static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr);
145static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg);145static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg);
146static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,146static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,
147 IrInstruction *source_instr, IrInstruction *container_ptr, TypeTableEntry *container_type);147 IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type);
148static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, VariableTableEntry *var);148static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, VariableTableEntry *var);
149static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op);149static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op);
150static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval);150static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval);
151static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, uint32_t new_align);151static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align);
152static TypeTableEntry *adjust_slice_align(CodeGen *g, TypeTableEntry *slice_type, uint32_t new_align);152static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align);
153static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);153static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);
154static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);154static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val);
155155
...@@ -183,7 +183,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c...@@ -183,7 +183,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c
183 return result;183 return result;
184}184}
185185
186static bool types_have_same_zig_comptime_repr(TypeTableEntry *a, TypeTableEntry *b) {186static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) {
187 if (a == b)187 if (a == b)
188 return true;188 return true;
189189
...@@ -878,7 +878,7 @@ static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_nod...@@ -878,7 +878,7 @@ static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_nod
878 return special_instruction;878 return special_instruction;
879}879}
880880
881static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, TypeTableEntry *dest_type,881static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *dest_type,
882 IrInstruction *value, CastOp cast_op)882 IrInstruction *value, CastOp cast_op)
883{883{
884 IrInstructionCast *cast_instruction = ir_build_instruction<IrInstructionCast>(irb, scope, source_node);884 IrInstructionCast *cast_instruction = ir_build_instruction<IrInstructionCast>(irb, scope, source_node);
...@@ -931,7 +931,7 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou...@@ -931,7 +931,7 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou
931}931}
932932
933static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node,933static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node,
934 TypeTableEntry *type_entry)934 ZigType *type_entry)
935{935{
936 assert(type_entry);936 assert(type_entry);
937 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);937 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
...@@ -1002,7 +1002,7 @@ static IrInstruction *ir_build_const_u8(IrBuilder *irb, Scope *scope, AstNode *s...@@ -1002,7 +1002,7 @@ static IrInstruction *ir_build_const_u8(IrBuilder *irb, Scope *scope, AstNode *s
1002}1002}
10031003
1004static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,1004static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
1005 TypeTableEntry *type_entry)1005 ZigType *type_entry)
1006{1006{
1007 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);1007 IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node);
1008 const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;1008 const_instruction->base.value.type = irb->codegen->builtin_types.entry_type;
...@@ -1012,7 +1012,7 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode...@@ -1012,7 +1012,7 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode
1012}1012}
10131013
1014static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,1014static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
1015 TypeTableEntry *type_entry)1015 ZigType *type_entry)
1016{1016{
1017 IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry);1017 IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry);
1018 ir_instruction_append(irb->current_basic_block, instruction);1018 ir_instruction_append(irb->current_basic_block, instruction);
...@@ -1376,7 +1376,7 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop...@@ -1376,7 +1376,7 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop
1376}1376}
13771377
1378static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode *source_node,1378static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode *source_node,
1379 TypeTableEntry *struct_type, size_t field_count, IrInstructionStructInitField *fields)1379 ZigType *struct_type, size_t field_count, IrInstructionStructInitField *fields)
1380{1380{
1381 IrInstructionStructInit *struct_init_instruction = ir_build_instruction<IrInstructionStructInit>(irb, scope, source_node);1381 IrInstructionStructInit *struct_init_instruction = ir_build_instruction<IrInstructionStructInit>(irb, scope, source_node);
1382 struct_init_instruction->struct_type = struct_type;1382 struct_init_instruction->struct_type = struct_type;
...@@ -1390,7 +1390,7 @@ static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode...@@ -1390,7 +1390,7 @@ static IrInstruction *ir_build_struct_init(IrBuilder *irb, Scope *scope, AstNode
1390}1390}
13911391
1392static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *old_instruction,1392static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *old_instruction,
1393 TypeTableEntry *struct_type, size_t field_count, IrInstructionStructInitField *fields)1393 ZigType *struct_type, size_t field_count, IrInstructionStructInitField *fields)
1394{1394{
1395 IrInstruction *new_instruction = ir_build_struct_init(irb, old_instruction->scope,1395 IrInstruction *new_instruction = ir_build_struct_init(irb, old_instruction->scope,
1396 old_instruction->source_node, struct_type, field_count, fields);1396 old_instruction->source_node, struct_type, field_count, fields);
...@@ -1399,7 +1399,7 @@ static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *o...@@ -1399,7 +1399,7 @@ static IrInstruction *ir_build_struct_init_from(IrBuilder *irb, IrInstruction *o
1399}1399}
14001400
1401static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode *source_node,1401static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode *source_node,
1402 TypeTableEntry *union_type, TypeUnionField *field, IrInstruction *init_value)1402 ZigType *union_type, TypeUnionField *field, IrInstruction *init_value)
1403{1403{
1404 IrInstructionUnionInit *union_init_instruction = ir_build_instruction<IrInstructionUnionInit>(irb, scope, source_node);1404 IrInstructionUnionInit *union_init_instruction = ir_build_instruction<IrInstructionUnionInit>(irb, scope, source_node);
1405 union_init_instruction->union_type = union_type;1405 union_init_instruction->union_type = union_type;
...@@ -1412,7 +1412,7 @@ static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode...@@ -1412,7 +1412,7 @@ static IrInstruction *ir_build_union_init(IrBuilder *irb, Scope *scope, AstNode
1412}1412}
14131413
1414static IrInstruction *ir_build_union_init_from(IrBuilder *irb, IrInstruction *old_instruction,1414static IrInstruction *ir_build_union_init_from(IrBuilder *irb, IrInstruction *old_instruction,
1415 TypeTableEntry *union_type, TypeUnionField *field, IrInstruction *init_value)1415 ZigType *union_type, TypeUnionField *field, IrInstruction *init_value)
1416{1416{
1417 IrInstruction *new_instruction = ir_build_union_init(irb, old_instruction->scope,1417 IrInstruction *new_instruction = ir_build_union_init(irb, old_instruction->scope,
1418 old_instruction->source_node, union_type, field, init_value);1418 old_instruction->source_node, union_type, field, init_value);
...@@ -1973,7 +1973,7 @@ static IrInstruction *ir_build_cmpxchg(IrBuilder *irb, Scope *scope, AstNode *so...@@ -1973,7 +1973,7 @@ static IrInstruction *ir_build_cmpxchg(IrBuilder *irb, Scope *scope, AstNode *so
1973 IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value,1973 IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value,
1974 IrInstruction *success_order_value, IrInstruction *failure_order_value,1974 IrInstruction *success_order_value, IrInstruction *failure_order_value,
1975 bool is_weak,1975 bool is_weak,
1976 TypeTableEntry *type, AtomicOrder success_order, AtomicOrder failure_order)1976 ZigType *type, AtomicOrder success_order, AtomicOrder failure_order)
1977{1977{
1978 IrInstructionCmpxchg *instruction = ir_build_instruction<IrInstructionCmpxchg>(irb, scope, source_node);1978 IrInstructionCmpxchg *instruction = ir_build_instruction<IrInstructionCmpxchg>(irb, scope, source_node);
1979 instruction->type_value = type_value;1979 instruction->type_value = type_value;
...@@ -2286,7 +2286,7 @@ static IrInstruction *ir_build_handle_from(IrBuilder *irb, IrInstruction *old_in...@@ -2286,7 +2286,7 @@ static IrInstruction *ir_build_handle_from(IrBuilder *irb, IrInstruction *old_in
22862286
2287static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,2287static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,
2288 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,2288 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
2289 IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)2289 IrInstruction *result_ptr, ZigType *result_ptr_type)
2290{2290{
2291 IrInstructionOverflowOp *instruction = ir_build_instruction<IrInstructionOverflowOp>(irb, scope, source_node);2291 IrInstructionOverflowOp *instruction = ir_build_instruction<IrInstructionOverflowOp>(irb, scope, source_node);
2292 instruction->op = op;2292 instruction->op = op;
...@@ -2306,7 +2306,7 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode...@@ -2306,7 +2306,7 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode
23062306
2307static IrInstruction *ir_build_overflow_op_from(IrBuilder *irb, IrInstruction *old_instruction,2307static IrInstruction *ir_build_overflow_op_from(IrBuilder *irb, IrInstruction *old_instruction,
2308 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,2308 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
2309 IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)2309 IrInstruction *result_ptr, ZigType *result_ptr_type)
2310{2310{
2311 IrInstruction *new_instruction = ir_build_overflow_op(irb, old_instruction->scope, old_instruction->source_node,2311 IrInstruction *new_instruction = ir_build_overflow_op(irb, old_instruction->scope, old_instruction->source_node,
2312 op, type_value, op1, op2, result_ptr, result_ptr_type);2312 op, type_value, op1, op2, result_ptr, result_ptr_type);
...@@ -3343,7 +3343,7 @@ static VariableTableEntry *create_local_var(CodeGen *codegen, AstNode *node, Sco...@@ -3343,7 +3343,7 @@ static VariableTableEntry *create_local_var(CodeGen *codegen, AstNode *node, Sco
3343 add_error_note(codegen, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));3343 add_error_note(codegen, msg, existing_var->decl_node, buf_sprintf("previous declaration is here"));
3344 variable_entry->value->type = codegen->builtin_types.entry_invalid;3344 variable_entry->value->type = codegen->builtin_types.entry_invalid;
3345 } else {3345 } else {
3346 TypeTableEntry *type = get_primitive_type(codegen, name);3346 ZigType *type = get_primitive_type(codegen, name);
3347 if (type != nullptr) {3347 if (type != nullptr) {
3348 add_node_error(codegen, node,3348 add_node_error(codegen, node,
3349 buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));3349 buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));
...@@ -3789,7 +3789,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,...@@ -3789,7 +3789,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
3789 return &const_instruction->base;3789 return &const_instruction->base;
3790 }3790 }
37913791
3792 TypeTableEntry *primitive_type = get_primitive_type(irb->codegen, variable_name);3792 ZigType *primitive_type = get_primitive_type(irb->codegen, variable_name);
3793 if (primitive_type != nullptr) {3793 if (primitive_type != nullptr) {
3794 IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_type);3794 IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_type);
3795 if (lval == LValPtr) {3795 if (lval == LValPtr) {
...@@ -5696,7 +5696,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode...@@ -5696,7 +5696,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode
56965696
5697 if (scope->id == ScopeIdDecls) {5697 if (scope->id == ScopeIdDecls) {
5698 ScopeDecls *decls_scope = (ScopeDecls *)scope;5698 ScopeDecls *decls_scope = (ScopeDecls *)scope;
5699 TypeTableEntry *container_type = decls_scope->container_type;5699 ZigType *container_type = decls_scope->container_type;
5700 assert(container_type);5700 assert(container_type);
5701 return ir_build_const_type(irb, scope, node, container_type);5701 return ir_build_const_type(irb, scope, node, container_type);
5702 }5702 }
...@@ -6566,7 +6566,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,...@@ -6566,7 +6566,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
6566 init_tld(&tld_container->base, TldIdContainer, name, visib_mod, node, parent_scope);6566 init_tld(&tld_container->base, TldIdContainer, name, visib_mod, node, parent_scope);
65676567
6568 ContainerLayout layout = node->data.container_decl.layout;6568 ContainerLayout layout = node->data.container_decl.layout;
6569 TypeTableEntry *container_type = get_partial_container_type(irb->codegen, parent_scope,6569 ZigType *container_type = get_partial_container_type(irb->codegen, parent_scope,
6570 kind, node, buf_ptr(name), layout);6570 kind, node, buf_ptr(name), layout);
6571 ScopeDecls *child_scope = get_container_scope(container_type);6571 ScopeDecls *child_scope = get_container_scope(container_type);
65726572
...@@ -6586,11 +6586,11 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,...@@ -6586,11 +6586,11 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope,
6586}6586}
65876587
6588// errors should be populated with set1's values6588// errors should be populated with set1's values
6589static TypeTableEntry *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, TypeTableEntry *set1, TypeTableEntry *set2) {6589static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigType *set1, ZigType *set2) {
6590 assert(set1->id == TypeTableEntryIdErrorSet);6590 assert(set1->id == TypeTableEntryIdErrorSet);
6591 assert(set2->id == TypeTableEntryIdErrorSet);6591 assert(set2->id == TypeTableEntryIdErrorSet);
65926592
6593 TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);6593 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
6594 buf_resize(&err_set_type->name, 0);6594 buf_resize(&err_set_type->name, 0);
6595 buf_appendf(&err_set_type->name, "error{");6595 buf_appendf(&err_set_type->name, "error{");
65966596
...@@ -6639,10 +6639,10 @@ static TypeTableEntry *get_error_set_union(CodeGen *g, ErrorTableEntry **errors,...@@ -6639,10 +6639,10 @@ static TypeTableEntry *get_error_set_union(CodeGen *g, ErrorTableEntry **errors,
66396639
6640}6640}
66416641
6642static TypeTableEntry *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node,6642static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node,
6643 ErrorTableEntry *err_entry)6643 ErrorTableEntry *err_entry)
6644{6644{
6645 TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);6645 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
6646 buf_resize(&err_set_type->name, 0);6646 buf_resize(&err_set_type->name, 0);
6647 buf_appendf(&err_set_type->name, "error{%s}", buf_ptr(&err_entry->name));6647 buf_appendf(&err_set_type->name, "error{%s}", buf_ptr(&err_entry->name));
6648 err_set_type->is_copyable = true;6648 err_set_type->is_copyable = true;
...@@ -6664,7 +6664,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A...@@ -6664,7 +6664,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A
6664 uint32_t err_count = node->data.err_set_decl.decls.length;6664 uint32_t err_count = node->data.err_set_decl.decls.length;
66656665
6666 Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node);6666 Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node);
6667 TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);6667 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
6668 buf_init_from_buf(&err_set_type->name, type_name);6668 buf_init_from_buf(&err_set_type->name, type_name);
6669 err_set_type->is_copyable = true;6669 err_set_type->is_copyable = true;
6670 err_set_type->data.error_set.err_count = err_count;6670 err_set_type->data.error_set.err_count = err_count;
...@@ -7386,7 +7386,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec...@@ -7386,7 +7386,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
7386 IrInstruction *const_bool_false;7386 IrInstruction *const_bool_false;
7387 IrInstruction *coro_promise_ptr;7387 IrInstruction *coro_promise_ptr;
7388 IrInstruction *err_ret_trace_ptr;7388 IrInstruction *err_ret_trace_ptr;
7389 TypeTableEntry *return_type;7389 ZigType *return_type;
7390 Buf *result_ptr_field_name;7390 Buf *result_ptr_field_name;
7391 VariableTableEntry *coro_size_var;7391 VariableTableEntry *coro_size_var;
7392 if (is_async) {7392 if (is_async) {
...@@ -7397,7 +7397,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec...@@ -7397,7 +7397,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
73977397
7398 return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;7398 return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;
7399 IrInstruction *undef = ir_build_const_undefined(irb, coro_scope, node);7399 IrInstruction *undef = ir_build_const_undefined(irb, coro_scope, node);
7400 TypeTableEntry *coro_frame_type = get_promise_frame_type(irb->codegen, return_type);7400 ZigType *coro_frame_type = get_promise_frame_type(irb->codegen, return_type);
7401 IrInstruction *coro_frame_type_value = ir_build_const_type(irb, coro_scope, node, coro_frame_type);7401 IrInstruction *coro_frame_type_value = ir_build_const_type(irb, coro_scope, node, coro_frame_type);
7402 // TODO mark this var decl as "no safety" e.g. disable initializing the undef value to 0xaa7402 // TODO mark this var decl as "no safety" e.g. disable initializing the undef value to 0xaa
7403 ir_build_var_decl(irb, coro_scope, node, promise_var, coro_frame_type_value, nullptr, undef);7403 ir_build_var_decl(irb, coro_scope, node, promise_var, coro_frame_type_value, nullptr, undef);
...@@ -7629,7 +7629,7 @@ static ConstExprValue *ir_const_ptr_pointee(IrAnalyze *ira, ConstExprValue *cons...@@ -7629,7 +7629,7 @@ static ConstExprValue *ir_const_ptr_pointee(IrAnalyze *ira, ConstExprValue *cons
7629 ConstExprValue *val = const_ptr_pointee_unchecked(ira->codegen, const_val);7629 ConstExprValue *val = const_ptr_pointee_unchecked(ira->codegen, const_val);
7630 assert(val != nullptr);7630 assert(val != nullptr);
7631 assert(const_val->type->id == TypeTableEntryIdPointer);7631 assert(const_val->type->id == TypeTableEntryIdPointer);
7632 TypeTableEntry *expected_type = const_val->type->data.pointer.child_type;7632 ZigType *expected_type = const_val->type->data.pointer.child_type;
7633 if (!types_have_same_zig_comptime_repr(val->type, expected_type)) {7633 if (!types_have_same_zig_comptime_repr(val->type, expected_type)) {
7634 ir_add_error_node(ira, source_node,7634 ir_add_error_node(ira, source_node,
7635 buf_sprintf("TODO handle comptime reinterpreted pointer. See https://github.com/ziglang/zig/issues/955"));7635 buf_sprintf("TODO handle comptime reinterpreted pointer. See https://github.com/ziglang/zig/issues/955"));
...@@ -7668,7 +7668,7 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so...@@ -7668,7 +7668,7 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so
7668 return true;7668 return true;
7669}7669}
76707670
7671static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) {7671static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) {
7672 return ((num_lit_type->id == TypeTableEntryIdComptimeFloat &&7672 return ((num_lit_type->id == TypeTableEntryIdComptimeFloat &&
7673 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) ||7673 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) ||
7674 (num_lit_type->id == TypeTableEntryIdComptimeInt &&7674 (num_lit_type->id == TypeTableEntryIdComptimeInt &&
...@@ -8365,7 +8365,7 @@ void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) {...@@ -8365,7 +8365,7 @@ void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) {
8365 }8365 }
8366}8366}
83678367
8368static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *other_type,8368static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, ZigType *other_type,
8369 bool explicit_cast)8369 bool explicit_cast)
8370{8370{
8371 if (type_is_invalid(other_type)) {8371 if (type_is_invalid(other_type)) {
...@@ -8399,7 +8399,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc...@@ -8399,7 +8399,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
8399 } else if (const_val_fits_in_num_lit(const_val, other_type)) {8399 } else if (const_val_fits_in_num_lit(const_val, other_type)) {
8400 return true;8400 return true;
8401 } else if (other_type->id == TypeTableEntryIdOptional) {8401 } else if (other_type->id == TypeTableEntryIdOptional) {
8402 TypeTableEntry *child_type = other_type->data.maybe.child_type;8402 ZigType *child_type = other_type->data.maybe.child_type;
8403 if (const_val_fits_in_num_lit(const_val, child_type)) {8403 if (const_val_fits_in_num_lit(const_val, child_type)) {
8404 return true;8404 return true;
8405 } else if (child_type->id == TypeTableEntryIdInt && const_val_is_int) {8405 } else if (child_type->id == TypeTableEntryIdInt && const_val_is_int) {
...@@ -8467,16 +8467,16 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc...@@ -8467,16 +8467,16 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
8467 return false;8467 return false;
8468}8468}
84698469
8470static bool is_slice(TypeTableEntry *type) {8470static bool is_slice(ZigType *type) {
8471 return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;8471 return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice;
8472}8472}
84738473
8474static bool slice_is_const(TypeTableEntry *type) {8474static bool slice_is_const(ZigType *type) {
8475 assert(is_slice(type));8475 assert(is_slice(type));
8476 return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;8476 return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
8477}8477}
84788478
8479static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry *set1, TypeTableEntry *set2,8479static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2,
8480 AstNode *source_node)8480 AstNode *source_node)
8481{8481{
8482 assert(set1->id == TypeTableEntryIdErrorSet);8482 assert(set1->id == TypeTableEntryIdErrorSet);
...@@ -8502,7 +8502,7 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry...@@ -8502,7 +8502,7 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry
8502 }8502 }
8503 ZigList<ErrorTableEntry *> intersection_list = {};8503 ZigList<ErrorTableEntry *> intersection_list = {};
85048504
8505 TypeTableEntry *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);8505 ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet);
8506 buf_resize(&err_set_type->name, 0);8506 buf_resize(&err_set_type->name, 0);
8507 buf_appendf(&err_set_type->name, "error{");8507 buf_appendf(&err_set_type->name, "error{");
85088508
...@@ -8531,8 +8531,8 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry...@@ -8531,8 +8531,8 @@ static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry
8531}8531}
85328532
85338533
8534static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry *wanted_type,8534static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted_type,
8535 TypeTableEntry *actual_type, AstNode *source_node, bool wanted_is_mutable)8535 ZigType *actual_type, AstNode *source_node, bool wanted_is_mutable)
8536{8536{
8537 CodeGen *g = ira->codegen;8537 CodeGen *g = ira->codegen;
8538 ConstCastOnly result = {};8538 ConstCastOnly result = {};
...@@ -8595,8 +8595,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry...@@ -8595,8 +8595,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
85958595
8596 // slice const8596 // slice const
8597 if (is_slice(wanted_type) && is_slice(actual_type)) {8597 if (is_slice(wanted_type) && is_slice(actual_type)) {
8598 TypeTableEntry *actual_ptr_type = actual_type->data.structure.fields[slice_ptr_index].type_entry;8598 ZigType *actual_ptr_type = actual_type->data.structure.fields[slice_ptr_index].type_entry;
8599 TypeTableEntry *wanted_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;8599 ZigType *wanted_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
8600 if ((!actual_ptr_type->data.pointer.is_const || wanted_ptr_type->data.pointer.is_const) &&8600 if ((!actual_ptr_type->data.pointer.is_const || wanted_ptr_type->data.pointer.is_const) &&
8601 (!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile) &&8601 (!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile) &&
8602 actual_ptr_type->data.pointer.bit_offset == wanted_ptr_type->data.pointer.bit_offset &&8602 actual_ptr_type->data.pointer.bit_offset == wanted_ptr_type->data.pointer.bit_offset &&
...@@ -8657,8 +8657,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry...@@ -8657,8 +8657,8 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
86578657
8658 // error set8658 // error set
8659 if (wanted_type->id == TypeTableEntryIdErrorSet && actual_type->id == TypeTableEntryIdErrorSet) {8659 if (wanted_type->id == TypeTableEntryIdErrorSet && actual_type->id == TypeTableEntryIdErrorSet) {
8660 TypeTableEntry *contained_set = actual_type;8660 ZigType *contained_set = actual_type;
8661 TypeTableEntry *container_set = wanted_type;8661 ZigType *container_set = wanted_type;
86628662
8663 // if the container set is inferred, then this will always work.8663 // if the container set is inferred, then this will always work.
8664 if (container_set->data.error_set.infer_fn != nullptr) {8664 if (container_set->data.error_set.infer_fn != nullptr) {
...@@ -8797,7 +8797,7 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t *...@@ -8797,7 +8797,7 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t *
8797 *errors = reallocate(*errors, old_errors_count, *errors_count);8797 *errors = reallocate(*errors, old_errors_count, *errors_count);
8798}8798}
87998799
8800static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, TypeTableEntry *expected_type, IrInstruction **instructions, size_t instruction_count) {8800static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, IrInstruction **instructions, size_t instruction_count) {
8801 Error err;8801 Error err;
8802 assert(instruction_count >= 1);8802 assert(instruction_count >= 1);
8803 IrInstruction *prev_inst = instructions[0];8803 IrInstruction *prev_inst = instructions[0];
...@@ -8806,7 +8806,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8806,7 +8806,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8806 }8806 }
8807 ErrorTableEntry **errors = nullptr;8807 ErrorTableEntry **errors = nullptr;
8808 size_t errors_count = 0;8808 size_t errors_count = 0;
8809 TypeTableEntry *err_set_type = nullptr;8809 ZigType *err_set_type = nullptr;
8810 if (prev_inst->value.type->id == TypeTableEntryIdErrorSet) {8810 if (prev_inst->value.type->id == TypeTableEntryIdErrorSet) {
8811 if (type_is_global_error_set(prev_inst->value.type)) {8811 if (type_is_global_error_set(prev_inst->value.type)) {
8812 err_set_type = ira->codegen->builtin_types.entry_global_error_set;8812 err_set_type = ira->codegen->builtin_types.entry_global_error_set;
...@@ -8829,8 +8829,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8829,8 +8829,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8829 bool convert_to_const_slice = false;8829 bool convert_to_const_slice = false;
8830 for (size_t i = 1; i < instruction_count; i += 1) {8830 for (size_t i = 1; i < instruction_count; i += 1) {
8831 IrInstruction *cur_inst = instructions[i];8831 IrInstruction *cur_inst = instructions[i];
8832 TypeTableEntry *cur_type = cur_inst->value.type;8832 ZigType *cur_type = cur_inst->value.type;
8833 TypeTableEntry *prev_type = prev_inst->value.type;8833 ZigType *prev_type = prev_inst->value.type;
88348834
8835 if (type_is_invalid(cur_type)) {8835 if (type_is_invalid(cur_type)) {
8836 return cur_type;8836 return cur_type;
...@@ -8916,7 +8916,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8916,7 +8916,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8916 prev_inst = cur_inst;8916 prev_inst = cur_inst;
8917 continue;8917 continue;
8918 }8918 }
8919 TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;8919 ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
8920 if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {8920 if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
8921 return ira->codegen->builtin_types.entry_invalid;8921 return ira->codegen->builtin_types.entry_invalid;
8922 }8922 }
...@@ -9021,8 +9021,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -9021,8 +9021,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
9021 }9021 }
90229022
9023 if (prev_type->id == TypeTableEntryIdErrorUnion && cur_type->id == TypeTableEntryIdErrorUnion) {9023 if (prev_type->id == TypeTableEntryIdErrorUnion && cur_type->id == TypeTableEntryIdErrorUnion) {
9024 TypeTableEntry *prev_payload_type = prev_type->data.error_union.payload_type;9024 ZigType *prev_payload_type = prev_type->data.error_union.payload_type;
9025 TypeTableEntry *cur_payload_type = cur_type->data.error_union.payload_type;9025 ZigType *cur_payload_type = cur_type->data.error_union.payload_type;
90269026
9027 bool const_cast_prev = types_match_const_cast_only(ira, prev_payload_type, cur_payload_type,9027 bool const_cast_prev = types_match_const_cast_only(ira, prev_payload_type, cur_payload_type,
9028 source_node, false).id == ConstCastResultIdOk;9028 source_node, false).id == ConstCastResultIdOk;
...@@ -9034,8 +9034,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -9034,8 +9034,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
9034 prev_inst = cur_inst;9034 prev_inst = cur_inst;
9035 }9035 }
90369036
9037 TypeTableEntry *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type;9037 ZigType *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type;
9038 TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;9038 ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
90399039
9040 if (!resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) {9040 if (!resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) {
9041 return ira->codegen->builtin_types.entry_invalid;9041 return ira->codegen->builtin_types.entry_invalid;
...@@ -9152,7 +9152,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -9152,7 +9152,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
9152 source_node, false).id == ConstCastResultIdOk)9152 source_node, false).id == ConstCastResultIdOk)
9153 {9153 {
9154 if (err_set_type != nullptr) {9154 if (err_set_type != nullptr) {
9155 TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;9155 ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type;
9156 if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {9156 if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
9157 return ira->codegen->builtin_types.entry_invalid;9157 return ira->codegen->builtin_types.entry_invalid;
9158 }9158 }
...@@ -9293,12 +9293,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -9293,12 +9293,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
92939293
9294 if (convert_to_const_slice) {9294 if (convert_to_const_slice) {
9295 assert(prev_inst->value.type->id == TypeTableEntryIdArray);9295 assert(prev_inst->value.type->id == TypeTableEntryIdArray);
9296 TypeTableEntry *ptr_type = get_pointer_to_type_extra(9296 ZigType *ptr_type = get_pointer_to_type_extra(
9297 ira->codegen, prev_inst->value.type->data.array.child_type,9297 ira->codegen, prev_inst->value.type->data.array.child_type,
9298 true, false, PtrLenUnknown,9298 true, false, PtrLenUnknown,
9299 get_abi_alignment(ira->codegen, prev_inst->value.type->data.array.child_type),9299 get_abi_alignment(ira->codegen, prev_inst->value.type->data.array.child_type),
9300 0, 0);9300 0, 0);
9301 TypeTableEntry *slice_type = get_slice_type(ira->codegen, ptr_type);9301 ZigType *slice_type = get_slice_type(ira->codegen, ptr_type);
9302 if (err_set_type != nullptr) {9302 if (err_set_type != nullptr) {
9303 return get_error_union_type(ira->codegen, err_set_type, slice_type);9303 return get_error_union_type(ira->codegen, err_set_type, slice_type);
9304 } else {9304 } else {
...@@ -9343,7 +9343,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -9343,7 +9343,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
9343 }9343 }
9344}9344}
93459345
9346static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, TypeTableEntry *type_entry) {9346static void ir_add_alloca(IrAnalyze *ira, IrInstruction *instruction, ZigType *type_entry) {
9347 if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) {9347 if (type_has_bits(type_entry) && handle_is_ptr(type_entry)) {
9348 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);9348 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
9349 if (fn_entry != nullptr) {9349 if (fn_entry != nullptr) {
...@@ -9366,8 +9366,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_...@@ -9366,8 +9366,8 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_
93669366
9367static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,9367static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr,
9368 CastOp cast_op,9368 CastOp cast_op,
9369 ConstExprValue *other_val, TypeTableEntry *other_type,9369 ConstExprValue *other_val, ZigType *other_type,
9370 ConstExprValue *const_val, TypeTableEntry *new_type)9370 ConstExprValue *const_val, ZigType *new_type)
9371{9371{
9372 const_val->special = other_val->special;9372 const_val->special = other_val->special;
93739373
...@@ -9467,7 +9467,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_...@@ -9467,7 +9467,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_
9467 return true;9467 return true;
9468}9468}
9469static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,9469static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
9470 TypeTableEntry *wanted_type, CastOp cast_op, bool need_alloca)9470 ZigType *wanted_type, CastOp cast_op, bool need_alloca)
9471{9471{
9472 if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&9472 if ((instr_is_comptime(value) || !type_has_bits(wanted_type)) &&
9473 cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)9473 cast_op != CastOpResizeSlice && cast_op != CastOpBytesToSlice)
...@@ -9491,7 +9491,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -9491,7 +9491,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst
9491}9491}
94929492
9493static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr,9493static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr,
9494 IrInstruction *value, TypeTableEntry *wanted_type)9494 IrInstruction *value, ZigType *wanted_type)
9495{9495{
9496 assert(value->value.type->id == TypeTableEntryIdPointer);9496 assert(value->value.type->id == TypeTableEntryIdPointer);
9497 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);9497 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);
...@@ -9520,7 +9520,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira,...@@ -9520,7 +9520,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira,
9520}9520}
95219521
9522static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,9522static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,
9523 IrInstruction *value, TypeTableEntry *wanted_type)9523 IrInstruction *value, ZigType *wanted_type)
9524{9524{
9525 wanted_type = adjust_slice_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);9525 wanted_type = adjust_slice_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment);
95269526
...@@ -9530,7 +9530,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc...@@ -9530,7 +9530,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
9530 return ira->codegen->invalid_instruction;9530 return ira->codegen->invalid_instruction;
9531 if (pointee->special != ConstValSpecialRuntime) {9531 if (pointee->special != ConstValSpecialRuntime) {
9532 assert(value->value.type->id == TypeTableEntryIdPointer);9532 assert(value->value.type->id == TypeTableEntryIdPointer);
9533 TypeTableEntry *array_type = value->value.type->data.pointer.child_type;9533 ZigType *array_type = value->value.type->data.pointer.child_type;
9534 assert(is_slice(wanted_type));9534 assert(is_slice(wanted_type));
9535 bool is_const = wanted_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;9535 bool is_const = wanted_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
95369536
...@@ -9551,7 +9551,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc...@@ -9551,7 +9551,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc
9551 return result;9551 return result;
9552}9552}
95539553
9554static bool is_container(TypeTableEntry *type) {9554static bool is_container(ZigType *type) {
9555 return type->id == TypeTableEntryIdStruct ||9555 return type->id == TypeTableEntryIdStruct ||
9556 type->id == TypeTableEntryIdEnum ||9556 type->id == TypeTableEntryIdEnum ||
9557 type->id == TypeTableEntryIdUnion;9557 type->id == TypeTableEntryIdUnion;
...@@ -9630,7 +9630,7 @@ static void ir_finish_bb(IrAnalyze *ira) {...@@ -9630,7 +9630,7 @@ static void ir_finish_bb(IrAnalyze *ira) {
9630 }9630 }
9631}9631}
96329632
9633static TypeTableEntry *ir_unreach_error(IrAnalyze *ira) {9633static ZigType *ir_unreach_error(IrAnalyze *ira) {
9634 ira->old_bb_index = SIZE_MAX;9634 ira->old_bb_index = SIZE_MAX;
9635 ira->new_irb.exec->invalid = true;9635 ira->new_irb.exec->invalid = true;
9636 return ira->codegen->builtin_types.entry_unreachable;9636 return ira->codegen->builtin_types.entry_unreachable;
...@@ -9653,7 +9653,7 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru...@@ -9653,7 +9653,7 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru
9653 return true;9653 return true;
9654}9654}
96559655
9656static TypeTableEntry *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) {9656static ZigType *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) {
9657 if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) {9657 if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) {
9658 if (!ir_emit_backward_branch(ira, source_instruction))9658 if (!ir_emit_backward_branch(ira, source_instruction))
9659 return ir_unreach_error(ira);9659 return ir_unreach_error(ira);
...@@ -9664,7 +9664,7 @@ static TypeTableEntry *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instru...@@ -9664,7 +9664,7 @@ static TypeTableEntry *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instru
9664 return ira->codegen->builtin_types.entry_unreachable;9664 return ira->codegen->builtin_types.entry_unreachable;
9665}9665}
96669666
9667static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_type) {9667static ZigType *ir_finish_anal(IrAnalyze *ira, ZigType *result_type) {
9668 if (result_type->id == TypeTableEntryIdUnreachable)9668 if (result_type->id == TypeTableEntryIdUnreachable)
9669 ir_finish_bb(ira);9669 ir_finish_bb(ira);
9670 return result_type;9670 return result_type;
...@@ -9684,16 +9684,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in...@@ -9684,16 +9684,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in
9684 return &new_instruction->value;9684 return &new_instruction->value;
9685}9685}
96869686
9687static TypeTableEntry *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) {9687static ZigType *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) {
9688 ir_build_const_from(ira, instruction);9688 ir_build_const_from(ira, instruction);
9689 return ira->codegen->builtin_types.entry_void;9689 return ira->codegen->builtin_types.entry_void;
9690}9690}
96919691
9692static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction,9692static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
9693 ConstExprValue *pointee, TypeTableEntry *pointee_type,9693 ConstExprValue *pointee, ZigType *pointee_type,
9694 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align)9694 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align)
9695{9695{
9696 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,9696 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
9697 ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0);9697 ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0);
9698 IrInstruction *const_instr = ir_get_const(ira, instruction);9698 IrInstruction *const_instr = ir_get_const(ira, instruction);
9699 ConstExprValue *const_val = &const_instr->value;9699 ConstExprValue *const_val = &const_instr->value;
...@@ -9704,8 +9704,8 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio...@@ -9704,8 +9704,8 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio
9704 return const_instr;9704 return const_instr;
9705}9705}
97069706
9707static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,9707static ZigType *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
9708 ConstExprValue *pointee, TypeTableEntry *pointee_type,9708 ConstExprValue *pointee, ZigType *pointee_type,
9709 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile)9709 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile)
9710{9710{
9711 IrInstruction *const_instr = ir_get_const_ptr(ira, instruction, pointee,9711 IrInstruction *const_instr = ir_get_const_ptr(ira, instruction, pointee,
...@@ -9715,7 +9715,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr...@@ -9715,7 +9715,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr
9715 return const_instr->value.type;9715 return const_instr->value.type;
9716}9716}
97179717
9718static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) {9718static ZigType *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) {
9719 ConstExprValue *const_val = ir_build_const_from(ira, instruction);9719 ConstExprValue *const_val = ir_build_const_from(ira, instruction);
9720 bigint_init_unsigned(&const_val->data.x_bigint, value);9720 bigint_init_unsigned(&const_val->data.x_bigint, value);
9721 return ira->codegen->builtin_types.entry_usize;9721 return ira->codegen->builtin_types.entry_usize;
...@@ -9748,7 +9748,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un...@@ -9748,7 +9748,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
9748}9748}
97499749
9750IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,9750IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
9751 TypeTableEntry *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,9751 ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
9752 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,9752 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
9753 IrExecutable *parent_exec)9753 IrExecutable *parent_exec)
9754{9754{
...@@ -9786,7 +9786,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node...@@ -9786,7 +9786,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node
9786 analyzed_executable->backward_branch_count = backward_branch_count;9786 analyzed_executable->backward_branch_count = backward_branch_count;
9787 analyzed_executable->backward_branch_quota = backward_branch_quota;9787 analyzed_executable->backward_branch_quota = backward_branch_quota;
9788 analyzed_executable->begin_scope = scope;9788 analyzed_executable->begin_scope = scope;
9789 TypeTableEntry *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, node);9789 ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, node);
9790 if (type_is_invalid(result_type))9790 if (type_is_invalid(result_type))
9791 return codegen->invalid_instruction;9791 return codegen->invalid_instruction;
97929792
...@@ -9799,7 +9799,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node...@@ -9799,7 +9799,7 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node
9799 return ir_exec_const_result(codegen, analyzed_executable);9799 return ir_exec_const_result(codegen, analyzed_executable);
9800}9800}
98019801
9802static TypeTableEntry *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {9802static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
9803 if (type_is_invalid(type_value->value.type))9803 if (type_is_invalid(type_value->value.type))
9804 return ira->codegen->builtin_types.entry_invalid;9804 return ira->codegen->builtin_types.entry_invalid;
98059805
...@@ -9837,11 +9837,11 @@ static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {...@@ -9837,11 +9837,11 @@ static FnTableEntry *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
9837 return const_val->data.x_ptr.data.fn.fn_entry;9837 return const_val->data.x_ptr.data.fn.fn_entry;
9838}9838}
98399839
9840static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {9840static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
9841 assert(wanted_type->id == TypeTableEntryIdOptional);9841 assert(wanted_type->id == TypeTableEntryIdOptional);
98429842
9843 if (instr_is_comptime(value)) {9843 if (instr_is_comptime(value)) {
9844 TypeTableEntry *payload_type = wanted_type->data.maybe.child_type;9844 ZigType *payload_type = wanted_type->data.maybe.child_type;
9845 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);9845 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
9846 if (type_is_invalid(casted_payload->value.type))9846 if (type_is_invalid(casted_payload->value.type))
9847 return ira->codegen->invalid_instruction;9847 return ira->codegen->invalid_instruction;
...@@ -9870,12 +9870,12 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc...@@ -9870,12 +9870,12 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc
9870}9870}
98719871
9872static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr,9872static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr,
9873 IrInstruction *value, TypeTableEntry *wanted_type)9873 IrInstruction *value, ZigType *wanted_type)
9874{9874{
9875 assert(wanted_type->id == TypeTableEntryIdErrorUnion);9875 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
98769876
9877 if (instr_is_comptime(value)) {9877 if (instr_is_comptime(value)) {
9878 TypeTableEntry *payload_type = wanted_type->data.error_union.payload_type;9878 ZigType *payload_type = wanted_type->data.error_union.payload_type;
9879 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);9879 IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type);
9880 if (type_is_invalid(casted_payload->value.type))9880 if (type_is_invalid(casted_payload->value.type))
9881 return ira->codegen->invalid_instruction;9881 return ira->codegen->invalid_instruction;
...@@ -9901,7 +9901,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction...@@ -9901,7 +9901,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction
9901}9901}
99029902
9903static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,9903static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value,
9904 TypeTableEntry *wanted_type)9904 ZigType *wanted_type)
9905{9905{
9906 assert(value->value.type->id == TypeTableEntryIdErrorSet);9906 assert(value->value.type->id == TypeTableEntryIdErrorSet);
9907 assert(wanted_type->id == TypeTableEntryIdErrorSet);9907 assert(wanted_type->id == TypeTableEntryIdErrorSet);
...@@ -9943,7 +9943,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou...@@ -9943,7 +9943,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou
9943 return result;9943 return result;
9944}9944}
99459945
9946static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {9946static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
9947 assert(wanted_type->id == TypeTableEntryIdErrorUnion);9947 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
99489948
9949 IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type);9949 IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type);
...@@ -9970,7 +9970,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so...@@ -9970,7 +9970,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so
9970}9970}
99719971
9972static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_instr,9972static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_instr,
9973 IrInstruction *value, TypeTableEntry *wanted_type)9973 IrInstruction *value, ZigType *wanted_type)
9974{9974{
9975 if (instr_is_comptime(value)) {9975 if (instr_is_comptime(value)) {
9976 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);9976 ConstExprValue *val = ir_resolve_const(ira, value, UndefBad);
...@@ -9994,7 +9994,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_...@@ -9994,7 +9994,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
9994 source_instr->source_node, value, true, false);9994 source_instr->source_node, value, true, false);
9995 new_instruction->value.type = wanted_type;9995 new_instruction->value.type = wanted_type;
99969996
9997 TypeTableEntry *child_type = wanted_type->data.pointer.child_type;9997 ZigType *child_type = wanted_type->data.pointer.child_type;
9998 if (type_has_bits(child_type)) {9998 if (type_has_bits(child_type)) {
9999 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);9999 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
10000 assert(fn_entry);10000 assert(fn_entry);
...@@ -10005,7 +10005,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_...@@ -10005,7 +10005,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_
10005 }10005 }
10006}10006}
1000710007
10008static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, TypeTableEntry *wanted_type) {10008static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) {
10009 assert(wanted_type->id == TypeTableEntryIdOptional);10009 assert(wanted_type->id == TypeTableEntryIdOptional);
10010 assert(instr_is_comptime(value));10010 assert(instr_is_comptime(value));
1001110011
...@@ -10039,7 +10039,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi...@@ -10039,7 +10039,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
10039 get_abi_alignment(ira->codegen, value->value.type));10039 get_abi_alignment(ira->codegen, value->value.type));
10040 }10040 }
1004110041
10042 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,10042 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type,
10043 is_const, is_volatile, PtrLenSingle, get_abi_alignment(ira->codegen, value->value.type), 0, 0);10043 is_const, is_volatile, PtrLenSingle, get_abi_alignment(ira->codegen, value->value.type), 0, 0);
10044 IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instruction->scope,10044 IrInstruction *new_instruction = ir_build_ref(&ira->new_irb, source_instruction->scope,
10045 source_instruction->source_node, value, is_const, is_volatile);10045 source_instruction->source_node, value, is_const, is_volatile);
...@@ -10054,7 +10054,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi...@@ -10054,7 +10054,7 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
10054}10054}
1005510055
10056static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,10056static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr,
10057 IrInstruction *array_arg, TypeTableEntry *wanted_type)10057 IrInstruction *array_arg, ZigType *wanted_type)
10058{10058{
10059 assert(is_slice(wanted_type));10059 assert(is_slice(wanted_type));
10060 // In this function we honor the const-ness of wanted_type, because10060 // In this function we honor the const-ness of wanted_type, because
...@@ -10068,7 +10068,7 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s...@@ -10068,7 +10068,7 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
10068 } else {10068 } else {
10069 array = array_arg;10069 array = array_arg;
10070 }10070 }
10071 TypeTableEntry *array_type = array->value.type;10071 ZigType *array_type = array->value.type;
10072 assert(array_type->id == TypeTableEntryIdArray);10072 assert(array_type->id == TypeTableEntryIdArray);
1007310073
10074 if (instr_is_comptime(array)) {10074 if (instr_is_comptime(array)) {
...@@ -10100,12 +10100,12 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s...@@ -10100,12 +10100,12 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s
10100}10100}
1010110101
10102static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *source_instr,10102static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *source_instr,
10103 IrInstruction *target, TypeTableEntry *wanted_type)10103 IrInstruction *target, ZigType *wanted_type)
10104{10104{
10105 Error err;10105 Error err;
10106 assert(wanted_type->id == TypeTableEntryIdInt);10106 assert(wanted_type->id == TypeTableEntryIdInt);
1010710107
10108 TypeTableEntry *actual_type = target->value.type;10108 ZigType *actual_type = target->value.type;
10109 if ((err = ensure_complete_type(ira->codegen, actual_type)))10109 if ((err = ensure_complete_type(ira->codegen, actual_type)))
10110 return ira->codegen->invalid_instruction;10110 return ira->codegen->invalid_instruction;
1011110111
...@@ -10136,7 +10136,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour...@@ -10136,7 +10136,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour
10136}10136}
1013710137
10138static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr,10138static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr,
10139 IrInstruction *target, TypeTableEntry *wanted_type)10139 IrInstruction *target, ZigType *wanted_type)
10140{10140{
10141 assert(target->value.type->id == TypeTableEntryIdUnion);10141 assert(target->value.type->id == TypeTableEntryIdUnion);
10142 assert(wanted_type->id == TypeTableEntryIdEnum);10142 assert(wanted_type->id == TypeTableEntryIdEnum);
...@@ -10161,7 +10161,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou...@@ -10161,7 +10161,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou
10161}10161}
1016210162
10163static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruction *source_instr,10163static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruction *source_instr,
10164 IrInstruction *target, TypeTableEntry *wanted_type)10164 IrInstruction *target, ZigType *wanted_type)
10165{10165{
10166 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,10166 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
10167 source_instr->source_node, wanted_type);10167 source_instr->source_node, wanted_type);
...@@ -10170,7 +10170,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc...@@ -10170,7 +10170,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc
10170}10170}
1017110171
10172static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *source_instr,10172static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *source_instr,
10173 IrInstruction *target, TypeTableEntry *wanted_type)10173 IrInstruction *target, ZigType *wanted_type)
10174{10174{
10175 Error err;10175 Error err;
10176 assert(wanted_type->id == TypeTableEntryIdUnion);10176 assert(wanted_type->id == TypeTableEntryIdUnion);
...@@ -10229,7 +10229,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so...@@ -10229,7 +10229,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
10229}10229}
1023010230
10231static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr,10231static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr,
10232 IrInstruction *target, TypeTableEntry *wanted_type)10232 IrInstruction *target, ZigType *wanted_type)
10233{10233{
10234 assert(wanted_type->id == TypeTableEntryIdInt || wanted_type->id == TypeTableEntryIdFloat);10234 assert(wanted_type->id == TypeTableEntryIdInt || wanted_type->id == TypeTableEntryIdFloat);
1023510235
...@@ -10270,12 +10270,12 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction...@@ -10270,12 +10270,12 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction
10270}10270}
1027110271
10272static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *source_instr,10272static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *source_instr,
10273 IrInstruction *target, TypeTableEntry *wanted_type)10273 IrInstruction *target, ZigType *wanted_type)
10274{10274{
10275 Error err;10275 Error err;
10276 assert(wanted_type->id == TypeTableEntryIdEnum);10276 assert(wanted_type->id == TypeTableEntryIdEnum);
1027710277
10278 TypeTableEntry *actual_type = target->value.type;10278 ZigType *actual_type = target->value.type;
1027910279
10280 if ((err = ensure_complete_type(ira->codegen, wanted_type)))10280 if ((err = ensure_complete_type(ira->codegen, wanted_type)))
10281 return ira->codegen->invalid_instruction;10281 return ira->codegen->invalid_instruction;
...@@ -10320,7 +10320,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour...@@ -10320,7 +10320,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour
10320}10320}
1032110321
10322static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr,10322static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr,
10323 IrInstruction *target, TypeTableEntry *wanted_type)10323 IrInstruction *target, ZigType *wanted_type)
10324{10324{
10325 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);10325 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
10326 if (!val)10326 if (!val)
...@@ -10339,7 +10339,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction...@@ -10339,7 +10339,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
10339}10339}
1034010340
10341static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,10341static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
10342 TypeTableEntry *wanted_type)10342 ZigType *wanted_type)
10343{10343{
10344 assert(target->value.type->id == TypeTableEntryIdInt);10344 assert(target->value.type->id == TypeTableEntryIdInt);
10345 assert(!target->value.type->data.integral.is_signed);10345 assert(!target->value.type->data.integral.is_signed);
...@@ -10404,11 +10404,11 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc...@@ -10404,11 +10404,11 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
10404}10404}
1040510405
10406static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,10406static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
10407 TypeTableEntry *wanted_type)10407 ZigType *wanted_type)
10408{10408{
10409 assert(wanted_type->id == TypeTableEntryIdInt);10409 assert(wanted_type->id == TypeTableEntryIdInt);
1041010410
10411 TypeTableEntry *err_type = target->value.type;10411 ZigType *err_type = target->value.type;
1041210412
10413 if (instr_is_comptime(target)) {10413 if (instr_is_comptime(target)) {
10414 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);10414 ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
...@@ -10442,7 +10442,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc...@@ -10442,7 +10442,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
10442 return result;10442 return result;
10443 }10443 }
1044410444
10445 TypeTableEntry *err_set_type;10445 ZigType *err_set_type;
10446 if (err_type->id == TypeTableEntryIdErrorUnion) {10446 if (err_type->id == TypeTableEntryIdErrorUnion) {
10447 err_set_type = err_type->data.error_union.err_set_type;10447 err_set_type = err_type->data.error_union.err_set_type;
10448 } else if (err_type->id == TypeTableEntryIdErrorSet) {10448 } else if (err_type->id == TypeTableEntryIdErrorSet) {
...@@ -10484,11 +10484,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc...@@ -10484,11 +10484,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
10484}10484}
1048510485
10486static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,10486static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target,
10487 TypeTableEntry *wanted_type)10487 ZigType *wanted_type)
10488{10488{
10489 assert(wanted_type->id == TypeTableEntryIdPointer);10489 assert(wanted_type->id == TypeTableEntryIdPointer);
10490 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, target->value.type->data.pointer.alignment);10490 wanted_type = adjust_ptr_align(ira->codegen, wanted_type, target->value.type->data.pointer.alignment);
10491 TypeTableEntry *array_type = wanted_type->data.pointer.child_type;10491 ZigType *array_type = wanted_type->data.pointer.child_type;
10492 assert(array_type->id == TypeTableEntryIdArray);10492 assert(array_type->id == TypeTableEntryIdArray);
10493 assert(array_type->data.array.len == 1);10493 assert(array_type->data.array.len == 1);
1049410494
...@@ -10620,10 +10620,10 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa...@@ -10620,10 +10620,10 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
10620}10620}
1062110621
10622static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr,10622static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr,
10623 TypeTableEntry *wanted_type, IrInstruction *value)10623 ZigType *wanted_type, IrInstruction *value)
10624{10624{
10625 Error err;10625 Error err;
10626 TypeTableEntry *actual_type = value->value.type;10626 ZigType *actual_type = value->value.type;
10627 AstNode *source_node = source_instr->source_node;10627 AstNode *source_node = source_instr->source_node;
1062810628
10629 if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) {10629 if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) {
...@@ -10665,7 +10665,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10665,7 +10665,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1066510665
10666 // cast from [N]T to []const T10666 // cast from [N]T to []const T
10667 if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdArray) {10667 if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdArray) {
10668 TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;10668 ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
10669 assert(ptr_type->id == TypeTableEntryIdPointer);10669 assert(ptr_type->id == TypeTableEntryIdPointer);
10670 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&10670 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
10671 types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,10671 types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type,
...@@ -10681,10 +10681,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10681,10 +10681,10 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10681 actual_type->data.pointer.is_const &&10681 actual_type->data.pointer.is_const &&
10682 actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)10682 actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
10683 {10683 {
10684 TypeTableEntry *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;10684 ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
10685 assert(ptr_type->id == TypeTableEntryIdPointer);10685 assert(ptr_type->id == TypeTableEntryIdPointer);
1068610686
10687 TypeTableEntry *array_type = actual_type->data.pointer.child_type;10687 ZigType *array_type = actual_type->data.pointer.child_type;
1068810688
10689 if ((ptr_type->data.pointer.is_const || array_type->data.array.len == 0) &&10689 if ((ptr_type->data.pointer.is_const || array_type->data.array.len == 0) &&
10690 types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, array_type->data.array.child_type,10690 types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, array_type->data.array.child_type,
...@@ -10700,7 +10700,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10700,7 +10700,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10700 is_slice(wanted_type->data.pointer.child_type) &&10700 is_slice(wanted_type->data.pointer.child_type) &&
10701 actual_type->id == TypeTableEntryIdArray)10701 actual_type->id == TypeTableEntryIdArray)
10702 {10702 {
10703 TypeTableEntry *ptr_type =10703 ZigType *ptr_type =
10704 wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry;10704 wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry;
10705 assert(ptr_type->id == TypeTableEntryIdPointer);10705 assert(ptr_type->id == TypeTableEntryIdPointer);
10706 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&10706 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
...@@ -10724,7 +10724,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10724,7 +10724,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10724 is_slice(wanted_type->data.maybe.child_type) &&10724 is_slice(wanted_type->data.maybe.child_type) &&
10725 actual_type->id == TypeTableEntryIdArray)10725 actual_type->id == TypeTableEntryIdArray)
10726 {10726 {
10727 TypeTableEntry *ptr_type =10727 ZigType *ptr_type =
10728 wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry;10728 wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry;
10729 assert(ptr_type->id == TypeTableEntryIdPointer);10729 assert(ptr_type->id == TypeTableEntryIdPointer);
10730 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&10730 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
...@@ -10763,7 +10763,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10763,7 +10763,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10763 actual_type->data.pointer.ptr_len == PtrLenSingle &&10763 actual_type->data.pointer.ptr_len == PtrLenSingle &&
10764 actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)10764 actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
10765 {10765 {
10766 TypeTableEntry *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;10766 ZigType *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry;
10767 assert(slice_ptr_type->id == TypeTableEntryIdPointer);10767 assert(slice_ptr_type->id == TypeTableEntryIdPointer);
10768 if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type,10768 if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type,
10769 actual_type->data.pointer.child_type->data.array.child_type, source_node,10769 actual_type->data.pointer.child_type->data.array.child_type, source_node,
...@@ -10777,7 +10777,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10777,7 +10777,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10777 // cast from T to ?T10777 // cast from T to ?T
10778 // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism10778 // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism
10779 if (wanted_type->id == TypeTableEntryIdOptional) {10779 if (wanted_type->id == TypeTableEntryIdOptional) {
10780 TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;10780 ZigType *wanted_child_type = wanted_type->data.maybe.child_type;
10781 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node,10781 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node,
10782 false).id == ConstCastResultIdOk)10782 false).id == ConstCastResultIdOk)
10783 {10783 {
...@@ -10850,7 +10850,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10850,7 +10850,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10850 is_slice(wanted_type->data.error_union.payload_type) &&10850 is_slice(wanted_type->data.error_union.payload_type) &&
10851 actual_type->id == TypeTableEntryIdArray)10851 actual_type->id == TypeTableEntryIdArray)
10852 {10852 {
10853 TypeTableEntry *ptr_type =10853 ZigType *ptr_type =
10854 wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry;10854 wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry;
10855 assert(ptr_type->id == TypeTableEntryIdPointer);10855 assert(ptr_type->id == TypeTableEntryIdPointer);
10856 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&10856 if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
...@@ -10881,7 +10881,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10881,7 +10881,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10881 wanted_type->data.error_union.payload_type->id == TypeTableEntryIdOptional &&10881 wanted_type->data.error_union.payload_type->id == TypeTableEntryIdOptional &&
10882 actual_type->id != TypeTableEntryIdOptional)10882 actual_type->id != TypeTableEntryIdOptional)
10883 {10883 {
10884 TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;10884 ZigType *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
10885 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk ||10885 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk ||
10886 actual_type->id == TypeTableEntryIdNull ||10886 actual_type->id == TypeTableEntryIdNull ||
10887 actual_type->id == TypeTableEntryIdComptimeInt ||10887 actual_type->id == TypeTableEntryIdComptimeInt ||
...@@ -10983,7 +10983,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10983,7 +10983,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1098310983
10984 // enum to &const union which has the enum as the tag type10984 // enum to &const union which has the enum as the tag type
10985 if (actual_type->id == TypeTableEntryIdEnum && wanted_type->id == TypeTableEntryIdPointer) {10985 if (actual_type->id == TypeTableEntryIdEnum && wanted_type->id == TypeTableEntryIdPointer) {
10986 TypeTableEntry *union_type = wanted_type->data.pointer.child_type;10986 ZigType *union_type = wanted_type->data.pointer.child_type;
10987 if (union_type->data.unionation.decl_node->data.container_decl.auto_enum ||10987 if (union_type->data.unionation.decl_node->data.container_decl.auto_enum ||
10988 union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)10988 union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)
10989 {10989 {
...@@ -11008,7 +11008,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -11008,7 +11008,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
11008 if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle &&11008 if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle &&
11009 actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle)11009 actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle)
11010 {11010 {
11011 TypeTableEntry *array_type = wanted_type->data.pointer.child_type;11011 ZigType *array_type = wanted_type->data.pointer.child_type;
11012 if (array_type->id == TypeTableEntryIdArray && array_type->data.array.len == 1 &&11012 if (array_type->id == TypeTableEntryIdArray && array_type->data.array.len == 1 &&
11013 types_match_const_cast_only(ira, array_type->data.array.child_type,11013 types_match_const_cast_only(ira, array_type->data.array.child_type,
11014 actual_type->data.pointer.child_type, source_node,11014 actual_type->data.pointer.child_type, source_node,
...@@ -11049,7 +11049,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -11049,7 +11049,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1104911049
11050 // cast from something to const pointer of it11050 // cast from something to const pointer of it
11051 if (!type_requires_comptime(actual_type)) {11051 if (!type_requires_comptime(actual_type)) {
11052 TypeTableEntry *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);11052 ZigType *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);
11053 if (types_match_const_cast_only(ira, wanted_type, const_ptr_actual, source_node, false).id == ConstCastResultIdOk) {11053 if (types_match_const_cast_only(ira, wanted_type, const_ptr_actual, source_node, false).id == ConstCastResultIdOk) {
11054 return ir_analyze_cast_ref(ira, source_instr, value, wanted_type);11054 return ir_analyze_cast_ref(ira, source_instr, value, wanted_type);
11055 }11055 }
...@@ -11063,7 +11063,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -11063,7 +11063,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
11063 return ira->codegen->invalid_instruction;11063 return ira->codegen->invalid_instruction;
11064}11064}
1106511065
11066static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *expected_type) {11066static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) {
11067 assert(value);11067 assert(value);
11068 assert(value != ira->codegen->invalid_instruction);11068 assert(value != ira->codegen->invalid_instruction);
11069 assert(!expected_type || !type_is_invalid(expected_type));11069 assert(!expected_type || !type_is_invalid(expected_type));
...@@ -11080,11 +11080,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Typ...@@ -11080,11 +11080,11 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Typ
11080}11080}
1108111081
11082static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr) {11082static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr) {
11083 TypeTableEntry *type_entry = ptr->value.type;11083 ZigType *type_entry = ptr->value.type;
11084 if (type_is_invalid(type_entry)) {11084 if (type_is_invalid(type_entry)) {
11085 return ira->codegen->invalid_instruction;11085 return ira->codegen->invalid_instruction;
11086 } else if (type_entry->id == TypeTableEntryIdPointer) {11086 } else if (type_entry->id == TypeTableEntryIdPointer) {
11087 TypeTableEntry *child_type = type_entry->data.pointer.child_type;11087 ZigType *child_type = type_entry->data.pointer.child_type;
11088 if (instr_is_comptime(ptr)) {11088 if (instr_is_comptime(ptr)) {
11089 if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst ||11089 if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst ||
11090 ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar)11090 ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar)
...@@ -11114,7 +11114,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc...@@ -11114,7 +11114,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
11114 }11114 }
11115}11115}
1111611116
11117static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value,11117static ZigType *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value,
11118 bool is_const, bool is_volatile)11118 bool is_const, bool is_volatile)
11119{11119{
11120 IrInstruction *result = ir_get_ref(ira, source_instruction, value, is_const, is_volatile);11120 IrInstruction *result = ir_get_ref(ira, source_instruction, value, is_const, is_volatile);
...@@ -11149,7 +11149,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, uint32_t *out...@@ -11149,7 +11149,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, uint32_t *out
11149 return true;11149 return true;
11150}11150}
1115111151
11152static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, TypeTableEntry *int_type, uint64_t *out) {11152static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) {
11153 if (type_is_invalid(value->value.type))11153 if (type_is_invalid(value->value.type))
11154 return false;11154 return false;
1115511155
...@@ -11199,7 +11199,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic...@@ -11199,7 +11199,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic
1119911199
11200 ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");11200 ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder");
11201 assert(atomic_order_val->type->id == TypeTableEntryIdMetaType);11201 assert(atomic_order_val->type->id == TypeTableEntryIdMetaType);
11202 TypeTableEntry *atomic_order_type = atomic_order_val->data.x_type;11202 ZigType *atomic_order_type = atomic_order_val->data.x_type;
1120311203
11204 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type);11204 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type);
11205 if (type_is_invalid(casted_value->value.type))11205 if (type_is_invalid(casted_value->value.type))
...@@ -11219,7 +11219,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi...@@ -11219,7 +11219,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi
1121911219
11220 ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");11220 ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp");
11221 assert(atomic_rmw_op_val->type->id == TypeTableEntryIdMetaType);11221 assert(atomic_rmw_op_val->type->id == TypeTableEntryIdMetaType);
11222 TypeTableEntry *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;11222 ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type;
1122311223
11224 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type);11224 IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type);
11225 if (type_is_invalid(casted_value->value.type))11225 if (type_is_invalid(casted_value->value.type))
...@@ -11239,7 +11239,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob...@@ -11239,7 +11239,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob
1123911239
11240 ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");11240 ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage");
11241 assert(global_linkage_val->type->id == TypeTableEntryIdMetaType);11241 assert(global_linkage_val->type->id == TypeTableEntryIdMetaType);
11242 TypeTableEntry *global_linkage_type = global_linkage_val->data.x_type;11242 ZigType *global_linkage_type = global_linkage_val->data.x_type;
1124311243
11244 IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type);11244 IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type);
11245 if (type_is_invalid(casted_value->value.type))11245 if (type_is_invalid(casted_value->value.type))
...@@ -11259,7 +11259,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod...@@ -11259,7 +11259,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod
1125911259
11260 ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");11260 ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode");
11261 assert(float_mode_val->type->id == TypeTableEntryIdMetaType);11261 assert(float_mode_val->type->id == TypeTableEntryIdMetaType);
11262 TypeTableEntry *float_mode_type = float_mode_val->data.x_type;11262 ZigType *float_mode_type = float_mode_val->data.x_type;
1126311263
11264 IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type);11264 IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type);
11265 if (type_is_invalid(casted_value->value.type))11265 if (type_is_invalid(casted_value->value.type))
...@@ -11278,10 +11278,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {...@@ -11278,10 +11278,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
11278 if (type_is_invalid(value->value.type))11278 if (type_is_invalid(value->value.type))
11279 return nullptr;11279 return nullptr;
1128011280
11281 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,11281 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
11282 true, false, PtrLenUnknown,11282 true, false, PtrLenUnknown,
11283 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);11283 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
11284 TypeTableEntry *str_type = get_slice_type(ira->codegen, ptr_type);11284 ZigType *str_type = get_slice_type(ira->codegen, ptr_type);
11285 IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type);11285 IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type);
11286 if (type_is_invalid(casted_value->value.type))11286 if (type_is_invalid(casted_value->value.type))
11287 return nullptr;11287 return nullptr;
...@@ -11314,7 +11314,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {...@@ -11314,7 +11314,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
11314 return result;11314 return result;
11315}11315}
1131611316
11317static TypeTableEntry *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira,11317static ZigType *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira,
11318 IrInstructionAddImplicitReturnType *instruction)11318 IrInstructionAddImplicitReturnType *instruction)
11319{11319{
11320 IrInstruction *value = instruction->value->other;11320 IrInstruction *value = instruction->value->other;
...@@ -11328,7 +11328,7 @@ static TypeTableEntry *ir_analyze_instruction_add_implicit_return_type(IrAnalyze...@@ -11328,7 +11328,7 @@ static TypeTableEntry *ir_analyze_instruction_add_implicit_return_type(IrAnalyze
11328 return out_val->type;11328 return out_val->type;
11329}11329}
1133011330
11331static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,11331static ZigType *ir_analyze_instruction_return(IrAnalyze *ira,
11332 IrInstructionReturn *return_instruction)11332 IrInstructionReturn *return_instruction)
11333{11333{
11334 IrInstruction *value = return_instruction->value->other;11334 IrInstruction *value = return_instruction->value->other;
...@@ -11353,13 +11353,13 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,...@@ -11353,13 +11353,13 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira,
11353 return ir_finish_anal(ira, result->value.type);11353 return ir_finish_anal(ira, result->value.type);
11354}11354}
1135511355
11356static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) {11356static ZigType *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) {
11357 ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base);11357 ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base);
11358 *out_val = const_instruction->base.value;11358 *out_val = const_instruction->base.value;
11359 return const_instruction->base.value.type;11359 return const_instruction->base.value.type;
11360}11360}
1136111361
11362static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {11362static ZigType *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
11363 IrInstruction *op1 = bin_op_instruction->op1->other;11363 IrInstruction *op1 = bin_op_instruction->op1->other;
11364 if (type_is_invalid(op1->value.type))11364 if (type_is_invalid(op1->value.type))
11365 return ira->codegen->builtin_types.entry_invalid;11365 return ira->codegen->builtin_types.entry_invalid;
...@@ -11368,7 +11368,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp...@@ -11368,7 +11368,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
11368 if (type_is_invalid(op2->value.type))11368 if (type_is_invalid(op2->value.type))
11369 return ira->codegen->builtin_types.entry_invalid;11369 return ira->codegen->builtin_types.entry_invalid;
1137011370
11371 TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;11371 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
1137211372
11373 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type);11373 IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type);
11374 if (casted_op1 == ira->codegen->invalid_instruction)11374 if (casted_op1 == ira->codegen->invalid_instruction)
...@@ -11433,7 +11433,7 @@ static bool optional_value_is_null(ConstExprValue *val) {...@@ -11433,7 +11433,7 @@ static bool optional_value_is_null(ConstExprValue *val) {
11433 }11433 }
11434}11434}
1143511435
11436static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {11436static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
11437 Error err;11437 Error err;
11438 IrInstruction *op1 = bin_op_instruction->op1->other;11438 IrInstruction *op1 = bin_op_instruction->op1->other;
11439 IrInstruction *op2 = bin_op_instruction->op2->other;11439 IrInstruction *op2 = bin_op_instruction->op2->other;
...@@ -11486,7 +11486,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -11486,7 +11486,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
11486 ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors"));11486 ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors"));
11487 return ira->codegen->builtin_types.entry_invalid;11487 return ira->codegen->builtin_types.entry_invalid;
11488 }11488 }
11489 TypeTableEntry *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node);11489 ZigType *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node);
11490 if (type_is_invalid(intersect_type)) {11490 if (type_is_invalid(intersect_type)) {
11491 return ira->codegen->builtin_types.entry_invalid;11491 return ira->codegen->builtin_types.entry_invalid;
11492 }11492 }
...@@ -11567,7 +11567,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -11567,7 +11567,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
11567 }11567 }
1156811568
11569 IrInstruction *instructions[] = {op1, op2};11569 IrInstruction *instructions[] = {op1, op2};
11570 TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2);11570 ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2);
11571 if (type_is_invalid(resolved_type))11571 if (type_is_invalid(resolved_type))
11572 return resolved_type;11572 return resolved_type;
11573 if ((err = type_ensure_zero_bits_known(ira->codegen, resolved_type)))11573 if ((err = type_ensure_zero_bits_known(ira->codegen, resolved_type)))
...@@ -11705,7 +11705,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -11705,7 +11705,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
11705 return ira->codegen->builtin_types.entry_bool;11705 return ira->codegen->builtin_types.entry_bool;
11706}11706}
1170711707
11708static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,11708static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val,
11709 IrBinOp op_id, ConstExprValue *op2_val, ConstExprValue *out_val)11709 IrBinOp op_id, ConstExprValue *op2_val, ConstExprValue *out_val)
11710{11710{
11711 bool is_int;11711 bool is_int;
...@@ -11885,7 +11885,7 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,...@@ -11885,7 +11885,7 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,
11885 return 0;11885 return 0;
11886}11886}
1188711887
11888static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {11888static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
11889 IrInstruction *op1 = bin_op_instruction->op1->other;11889 IrInstruction *op1 = bin_op_instruction->op1->other;
11890 if (type_is_invalid(op1->value.type))11890 if (type_is_invalid(op1->value.type))
11891 return ira->codegen->builtin_types.entry_invalid;11891 return ira->codegen->builtin_types.entry_invalid;
...@@ -11917,7 +11917,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11917,7 +11917,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
11917 return ira->codegen->builtin_types.entry_invalid;11917 return ira->codegen->builtin_types.entry_invalid;
11918 }11918 }
11919 } else {11919 } else {
11920 TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,11920 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
11921 op1->value.type->data.integral.bit_count - 1);11921 op1->value.type->data.integral.bit_count - 1);
11922 if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy &&11922 if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy &&
11923 op2->value.type->id == TypeTableEntryIdComptimeInt) {11923 op2->value.type->id == TypeTableEntryIdComptimeInt) {
...@@ -11985,7 +11985,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11985,7 +11985,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
11985 return op1->value.type;11985 return op1->value.type;
11986}11986}
1198711987
11988static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {11988static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
11989 IrInstruction *op1 = bin_op_instruction->op1->other;11989 IrInstruction *op1 = bin_op_instruction->op1->other;
11990 if (type_is_invalid(op1->value.type))11990 if (type_is_invalid(op1->value.type))
11991 return ira->codegen->builtin_types.entry_invalid;11991 return ira->codegen->builtin_types.entry_invalid;
...@@ -12012,7 +12012,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -12012,7 +12012,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
12012 }12012 }
1201312013
12014 IrInstruction *instructions[] = {op1, op2};12014 IrInstruction *instructions[] = {op1, op2};
12015 TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, nullptr, instructions, 2);12015 ZigType *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, nullptr, instructions, 2);
12016 if (type_is_invalid(resolved_type))12016 if (type_is_invalid(resolved_type))
12017 return resolved_type;12017 return resolved_type;
1201812018
...@@ -12206,14 +12206,14 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -12206,14 +12206,14 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
12206}12206}
1220712207
1220812208
12209static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) {12209static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) {
12210 IrInstruction *op1 = instruction->op1->other;12210 IrInstruction *op1 = instruction->op1->other;
12211 TypeTableEntry *op1_type = op1->value.type;12211 ZigType *op1_type = op1->value.type;
12212 if (type_is_invalid(op1_type))12212 if (type_is_invalid(op1_type))
12213 return ira->codegen->builtin_types.entry_invalid;12213 return ira->codegen->builtin_types.entry_invalid;
1221412214
12215 IrInstruction *op2 = instruction->op2->other;12215 IrInstruction *op2 = instruction->op2->other;
12216 TypeTableEntry *op2_type = op2->value.type;12216 ZigType *op2_type = op2->value.type;
12217 if (type_is_invalid(op2_type))12217 if (type_is_invalid(op2_type))
12218 return ira->codegen->builtin_types.entry_invalid;12218 return ira->codegen->builtin_types.entry_invalid;
1221912219
...@@ -12228,7 +12228,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12228,7 +12228,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
12228 ConstExprValue *op1_array_val;12228 ConstExprValue *op1_array_val;
12229 size_t op1_array_index;12229 size_t op1_array_index;
12230 size_t op1_array_end;12230 size_t op1_array_end;
12231 TypeTableEntry *child_type;12231 ZigType *child_type;
12232 if (op1_type->id == TypeTableEntryIdArray) {12232 if (op1_type->id == TypeTableEntryIdArray) {
12233 child_type = op1_type->data.array.child_type;12233 child_type = op1_type->data.array.child_type;
12234 op1_array_val = op1_val;12234 op1_array_val = op1_val;
...@@ -12244,7 +12244,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12244,7 +12244,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
12244 op1_array_index = op1_val->data.x_ptr.data.base_array.elem_index;12244 op1_array_index = op1_val->data.x_ptr.data.base_array.elem_index;
12245 op1_array_end = op1_array_val->type->data.array.len - 1;12245 op1_array_end = op1_array_val->type->data.array.len - 1;
12246 } else if (is_slice(op1_type)) {12246 } else if (is_slice(op1_type)) {
12247 TypeTableEntry *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry;12247 ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry;
12248 child_type = ptr_type->data.pointer.child_type;12248 child_type = ptr_type->data.pointer.child_type;
12249 ConstExprValue *ptr_val = &op1_val->data.x_struct.fields[slice_ptr_index];12249 ConstExprValue *ptr_val = &op1_val->data.x_struct.fields[slice_ptr_index];
12250 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);12250 assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray);
...@@ -12285,7 +12285,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12285,7 +12285,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
12285 op2_array_index = op2_val->data.x_ptr.data.base_array.elem_index;12285 op2_array_index = op2_val->data.x_ptr.data.base_array.elem_index;
12286 op2_array_end = op2_array_val->type->data.array.len - 1;12286 op2_array_end = op2_array_val->type->data.array.len - 1;
12287 } else if (is_slice(op2_type)) {12287 } else if (is_slice(op2_type)) {
12288 TypeTableEntry *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;12288 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
12289 if (ptr_type->data.pointer.child_type != child_type) {12289 if (ptr_type->data.pointer.child_type != child_type) {
12290 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",12290 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12291 buf_ptr(&child_type->name),12291 buf_ptr(&child_type->name),
...@@ -12305,7 +12305,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12305,7 +12305,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
1230512305
12306 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);12306 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1230712307
12308 TypeTableEntry *result_type;12308 ZigType *result_type;
12309 ConstExprValue *out_array_val;12309 ConstExprValue *out_array_val;
12310 size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index);12310 size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index);
12311 if (op1_type->id == TypeTableEntryIdArray || op2_type->id == TypeTableEntryIdArray) {12311 if (op1_type->id == TypeTableEntryIdArray || op2_type->id == TypeTableEntryIdArray) {
...@@ -12313,7 +12313,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12313,7 +12313,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
1231312313
12314 out_array_val = out_val;12314 out_array_val = out_val;
12315 } else if (is_slice(op1_type) || is_slice(op2_type)) {12315 } else if (is_slice(op1_type) || is_slice(op2_type)) {
12316 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,12316 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
12317 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, child_type), 0, 0);12317 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, child_type), 0, 0);
12318 result_type = get_slice_type(ira->codegen, ptr_type);12318 result_type = get_slice_type(ira->codegen, ptr_type);
12319 out_array_val = create_const_vals(1);12319 out_array_val = create_const_vals(1);
...@@ -12374,7 +12374,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -12374,7 +12374,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
12374 return result_type;12374 return result_type;
12375}12375}
1237612376
12377static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) {12377static ZigType *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) {
12378 IrInstruction *op1 = instruction->op1->other;12378 IrInstruction *op1 = instruction->op1->other;
12379 if (type_is_invalid(op1->value.type))12379 if (type_is_invalid(op1->value.type))
12380 return ira->codegen->builtin_types.entry_invalid;12380 return ira->codegen->builtin_types.entry_invalid;
...@@ -12391,7 +12391,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp...@@ -12391,7 +12391,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
12391 if (!ir_resolve_usize(ira, op2, &mult_amt))12391 if (!ir_resolve_usize(ira, op2, &mult_amt))
12392 return ira->codegen->builtin_types.entry_invalid;12392 return ira->codegen->builtin_types.entry_invalid;
1239312393
12394 TypeTableEntry *array_type = op1->value.type;12394 ZigType *array_type = op1->value.type;
12395 if (array_type->id != TypeTableEntryIdArray) {12395 if (array_type->id != TypeTableEntryIdArray) {
12396 ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name)));12396 ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name)));
12397 return ira->codegen->builtin_types.entry_invalid;12397 return ira->codegen->builtin_types.entry_invalid;
...@@ -12410,7 +12410,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp...@@ -12410,7 +12410,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
12410 if (array_val->data.x_array.special == ConstArraySpecialUndef) {12410 if (array_val->data.x_array.special == ConstArraySpecialUndef) {
12411 out_val->data.x_array.special = ConstArraySpecialUndef;12411 out_val->data.x_array.special = ConstArraySpecialUndef;
1241212412
12413 TypeTableEntry *child_type = array_type->data.array.child_type;12413 ZigType *child_type = array_type->data.array.child_type;
12414 return get_array_type(ira->codegen, child_type, new_array_len);12414 return get_array_type(ira->codegen, child_type, new_array_len);
12415 }12415 }
1241612416
...@@ -12425,16 +12425,16 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp...@@ -12425,16 +12425,16 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
12425 }12425 }
12426 assert(i == new_array_len);12426 assert(i == new_array_len);
1242712427
12428 TypeTableEntry *child_type = array_type->data.array.child_type;12428 ZigType *child_type = array_type->data.array.child_type;
12429 return get_array_type(ira->codegen, child_type, new_array_len);12429 return get_array_type(ira->codegen, child_type, new_array_len);
12430}12430}
1243112431
12432static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {12432static ZigType *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
12433 TypeTableEntry *op1_type = ir_resolve_type(ira, instruction->op1->other);12433 ZigType *op1_type = ir_resolve_type(ira, instruction->op1->other);
12434 if (type_is_invalid(op1_type))12434 if (type_is_invalid(op1_type))
12435 return ira->codegen->builtin_types.entry_invalid;12435 return ira->codegen->builtin_types.entry_invalid;
1243612436
12437 TypeTableEntry *op2_type = ir_resolve_type(ira, instruction->op2->other);12437 ZigType *op2_type = ir_resolve_type(ira, instruction->op2->other);
12438 if (type_is_invalid(op2_type))12438 if (type_is_invalid(op2_type))
12439 return ira->codegen->builtin_types.entry_invalid;12439 return ira->codegen->builtin_types.entry_invalid;
1244012440
...@@ -12460,7 +12460,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction...@@ -12460,7 +12460,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction
12460 assert(errors[error_entry->value] == nullptr);12460 assert(errors[error_entry->value] == nullptr);
12461 errors[error_entry->value] = error_entry;12461 errors[error_entry->value] = error_entry;
12462 }12462 }
12463 TypeTableEntry *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type);12463 ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type);
12464 free(errors);12464 free(errors);
1246512465
1246612466
...@@ -12469,7 +12469,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction...@@ -12469,7 +12469,7 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction
12469 return ira->codegen->builtin_types.entry_type;12469 return ira->codegen->builtin_types.entry_type;
12470}12470}
1247112471
12472static TypeTableEntry *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {12472static ZigType *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) {
12473 IrBinOp op_id = bin_op_instruction->op_id;12473 IrBinOp op_id = bin_op_instruction->op_id;
12474 switch (op_id) {12474 switch (op_id) {
12475 case IrBinOpInvalid:12475 case IrBinOpInvalid:
...@@ -12516,7 +12516,7 @@ static TypeTableEntry *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructi...@@ -12516,7 +12516,7 @@ static TypeTableEntry *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructi
12516 zig_unreachable();12516 zig_unreachable();
12517}12517}
1251812518
12519static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDeclVar *decl_var_instruction) {12519static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDeclVar *decl_var_instruction) {
12520 Error err;12520 Error err;
12521 VariableTableEntry *var = decl_var_instruction->var;12521 VariableTableEntry *var = decl_var_instruction->var;
1252212522
...@@ -12526,11 +12526,11 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12526,11 +12526,11 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
12526 return var->value->type;12526 return var->value->type;
12527 }12527 }
1252812528
12529 TypeTableEntry *explicit_type = nullptr;12529 ZigType *explicit_type = nullptr;
12530 IrInstruction *var_type = nullptr;12530 IrInstruction *var_type = nullptr;
12531 if (decl_var_instruction->var_type != nullptr) {12531 if (decl_var_instruction->var_type != nullptr) {
12532 var_type = decl_var_instruction->var_type->other;12532 var_type = decl_var_instruction->var_type->other;
12533 TypeTableEntry *proposed_type = ir_resolve_type(ira, var_type);12533 ZigType *proposed_type = ir_resolve_type(ira, var_type);
12534 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);12534 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);
12535 if (type_is_invalid(explicit_type)) {12535 if (type_is_invalid(explicit_type)) {
12536 var->value->type = ira->codegen->builtin_types.entry_invalid;12536 var->value->type = ira->codegen->builtin_types.entry_invalid;
...@@ -12545,7 +12545,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12545,7 +12545,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
1254512545
12546 bool var_class_requires_const = false;12546 bool var_class_requires_const = false;
1254712547
12548 TypeTableEntry *result_type = casted_init_value->value.type;12548 ZigType *result_type = casted_init_value->value.type;
12549 if (type_is_invalid(result_type)) {12549 if (type_is_invalid(result_type)) {
12550 result_type = ira->codegen->builtin_types.entry_invalid;12550 result_type = ira->codegen->builtin_types.entry_invalid;
12551 } else {12551 } else {
...@@ -12651,7 +12651,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc...@@ -12651,7 +12651,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc
12651 return ira->codegen->builtin_types.entry_void;12651 return ira->codegen->builtin_types.entry_void;
12652}12652}
1265312653
12654static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {12654static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) {
12655 IrInstruction *name = instruction->name->other;12655 IrInstruction *name = instruction->name->other;
12656 Buf *symbol_name = ir_resolve_str(ira, name);12656 Buf *symbol_name = ir_resolve_str(ira, name);
12657 if (symbol_name == nullptr) {12657 if (symbol_name == nullptr) {
...@@ -12731,7 +12731,7 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi...@@ -12731,7 +12731,7 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
12731 }12731 }
12732 break;12732 break;
12733 case TypeTableEntryIdMetaType: {12733 case TypeTableEntryIdMetaType: {
12734 TypeTableEntry *type_value = target->value.data.x_type;12734 ZigType *type_value = target->value.data.x_type;
12735 switch (type_value->id) {12735 switch (type_value->id) {
12736 case TypeTableEntryIdInvalid:12736 case TypeTableEntryIdInvalid:
12737 zig_unreachable();12737 zig_unreachable();
...@@ -12826,12 +12826,12 @@ static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) {...@@ -12826,12 +12826,12 @@ static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) {
12826 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;12826 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;
12827}12827}
1282812828
12829static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,12829static ZigType *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
12830 IrInstructionErrorReturnTrace *instruction)12830 IrInstructionErrorReturnTrace *instruction)
12831{12831{
12832 if (instruction->optional == IrInstructionErrorReturnTrace::Null) {12832 if (instruction->optional == IrInstructionErrorReturnTrace::Null) {
12833 TypeTableEntry *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(ira->codegen);12833 ZigType *ptr_to_stack_trace_type = get_ptr_to_stack_trace_type(ira->codegen);
12834 TypeTableEntry *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);12834 ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
12835 if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {12835 if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) {
12836 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);12836 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
12837 assert(get_codegen_ptr_type(optional_type) != nullptr);12837 assert(get_codegen_ptr_type(optional_type) != nullptr);
...@@ -12852,14 +12852,14 @@ static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,...@@ -12852,14 +12852,14 @@ static TypeTableEntry *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
12852 }12852 }
12853}12853}
1285412854
12855static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira,12855static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira,
12856 IrInstructionErrorUnion *instruction)12856 IrInstructionErrorUnion *instruction)
12857{12857{
12858 TypeTableEntry *err_set_type = ir_resolve_type(ira, instruction->err_set->other);12858 ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->other);
12859 if (type_is_invalid(err_set_type))12859 if (type_is_invalid(err_set_type))
12860 return ira->codegen->builtin_types.entry_invalid;12860 return ira->codegen->builtin_types.entry_invalid;
1286112861
12862 TypeTableEntry *payload_type = ir_resolve_type(ira, instruction->payload->other);12862 ZigType *payload_type = ir_resolve_type(ira, instruction->payload->other);
12863 if (type_is_invalid(payload_type))12863 if (type_is_invalid(payload_type))
12864 return ira->codegen->builtin_types.entry_invalid;12864 return ira->codegen->builtin_types.entry_invalid;
1286512865
...@@ -12870,7 +12870,7 @@ static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira,...@@ -12870,7 +12870,7 @@ static TypeTableEntry *ir_analyze_instruction_error_union(IrAnalyze *ira,
12870 return ira->codegen->builtin_types.entry_invalid;12870 return ira->codegen->builtin_types.entry_invalid;
12871 }12871 }
1287212872
12873 TypeTableEntry *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);12873 ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);
1287412874
12875 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);12875 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
12876 out_val->data.x_type = result_type;12876 out_val->data.x_type = result_type;
...@@ -12913,38 +12913,38 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i...@@ -12913,38 +12913,38 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i
12913 zig_unreachable();12913 zig_unreachable();
12914}12914}
1291512915
12916static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, TypeTableEntry *fn_type,12916static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, FnTableEntry *fn_entry, ZigType *fn_type,
12917 IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst)12917 IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst)
12918{12918{
12919 Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME);12919 Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME);
12920 //Buf *free_field_name = buf_create_from_str("freeFn");12920 //Buf *free_field_name = buf_create_from_str("freeFn");
12921 assert(async_allocator_inst->value.type->id == TypeTableEntryIdPointer);12921 assert(async_allocator_inst->value.type->id == TypeTableEntryIdPointer);
12922 TypeTableEntry *container_type = async_allocator_inst->value.type->data.pointer.child_type;12922 ZigType *container_type = async_allocator_inst->value.type->data.pointer.child_type;
12923 IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, alloc_field_name, &call_instruction->base,12923 IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, alloc_field_name, &call_instruction->base,
12924 async_allocator_inst, container_type);12924 async_allocator_inst, container_type);
12925 if (type_is_invalid(field_ptr_inst->value.type)) {12925 if (type_is_invalid(field_ptr_inst->value.type)) {
12926 return ira->codegen->invalid_instruction;12926 return ira->codegen->invalid_instruction;
12927 }12927 }
12928 TypeTableEntry *ptr_to_alloc_fn_type = field_ptr_inst->value.type;12928 ZigType *ptr_to_alloc_fn_type = field_ptr_inst->value.type;
12929 assert(ptr_to_alloc_fn_type->id == TypeTableEntryIdPointer);12929 assert(ptr_to_alloc_fn_type->id == TypeTableEntryIdPointer);
1293012930
12931 TypeTableEntry *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;12931 ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
12932 if (alloc_fn_type->id != TypeTableEntryIdFn) {12932 if (alloc_fn_type->id != TypeTableEntryIdFn) {
12933 ir_add_error(ira, &call_instruction->base,12933 ir_add_error(ira, &call_instruction->base,
12934 buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name)));12934 buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name)));
12935 return ira->codegen->invalid_instruction;12935 return ira->codegen->invalid_instruction;
12936 }12936 }
1293712937
12938 TypeTableEntry *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type;12938 ZigType *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type;
12939 if (alloc_fn_return_type->id != TypeTableEntryIdErrorUnion) {12939 if (alloc_fn_return_type->id != TypeTableEntryIdErrorUnion) {
12940 ir_add_error(ira, fn_ref,12940 ir_add_error(ira, fn_ref,
12941 buf_sprintf("expected allocation function to return error union, but it returns '%s'", buf_ptr(&alloc_fn_return_type->name)));12941 buf_sprintf("expected allocation function to return error union, but it returns '%s'", buf_ptr(&alloc_fn_return_type->name)));
12942 return ira->codegen->invalid_instruction;12942 return ira->codegen->invalid_instruction;
12943 }12943 }
12944 TypeTableEntry *alloc_fn_error_set_type = alloc_fn_return_type->data.error_union.err_set_type;12944 ZigType *alloc_fn_error_set_type = alloc_fn_return_type->data.error_union.err_set_type;
12945 TypeTableEntry *return_type = fn_type->data.fn.fn_type_id.return_type;12945 ZigType *return_type = fn_type->data.fn.fn_type_id.return_type;
12946 TypeTableEntry *promise_type = get_promise_type(ira->codegen, return_type);12946 ZigType *promise_type = get_promise_type(ira->codegen, return_type);
12947 TypeTableEntry *async_return_type = get_error_union_type(ira->codegen, alloc_fn_error_set_type, promise_type);12947 ZigType *async_return_type = get_error_union_type(ira->codegen, alloc_fn_error_set_type, promise_type);
1294812948
12949 IrInstruction *result = ir_build_call(&ira->new_irb, call_instruction->base.scope, call_instruction->base.source_node,12949 IrInstruction *result = ir_build_call(&ira->new_irb, call_instruction->base.scope, call_instruction->base.source_node,
12950 fn_entry, fn_ref, arg_count, casted_args, false, FnInlineAuto, true, async_allocator_inst, nullptr);12950 fn_entry, fn_ref, arg_count, casted_args, false, FnInlineAuto, true, async_allocator_inst, nullptr);
...@@ -12961,7 +12961,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node...@@ -12961,7 +12961,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
12961 IrInstruction *casted_arg;12961 IrInstruction *casted_arg;
12962 if (param_decl_node->data.param_decl.var_token == nullptr) {12962 if (param_decl_node->data.param_decl.var_token == nullptr) {
12963 AstNode *param_type_node = param_decl_node->data.param_decl.type;12963 AstNode *param_type_node = param_decl_node->data.param_decl.type;
12964 TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node);12964 ZigType *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node);
12965 if (type_is_invalid(param_type))12965 if (type_is_invalid(param_type))
12966 return false;12966 return false;
1296712967
...@@ -13001,7 +13001,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod...@@ -13001,7 +13001,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
13001 } else {13001 } else {
13002 if (param_decl_node->data.param_decl.var_token == nullptr) {13002 if (param_decl_node->data.param_decl.var_token == nullptr) {
13003 AstNode *param_type_node = param_decl_node->data.param_decl.type;13003 AstNode *param_type_node = param_decl_node->data.param_decl.type;
13004 TypeTableEntry *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node);13004 ZigType *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node);
13005 if (type_is_invalid(param_type))13005 if (type_is_invalid(param_type))
13006 return false;13006 return false;
1300713007
...@@ -13156,8 +13156,8 @@ no_mem_slot:...@@ -13156,8 +13156,8 @@ no_mem_slot:
13156 return var_ptr_instruction;13156 return var_ptr_instruction;
13157}13157}
1315813158
13159static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction,13159static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instruction,
13160 FnTableEntry *fn_entry, TypeTableEntry *fn_type, IrInstruction *fn_ref,13160 FnTableEntry *fn_entry, ZigType *fn_type, IrInstruction *fn_ref,
13161 IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)13161 IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline)
13162{13162{
13163 Error err;13163 Error err;
...@@ -13249,7 +13249,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13249,7 +13249,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1324913249
13250 bool first_arg_known_bare = false;13250 bool first_arg_known_bare = false;
13251 if (fn_type_id->next_param_index >= 1) {13251 if (fn_type_id->next_param_index >= 1) {
13252 TypeTableEntry *param_type = fn_type_id->param_info[next_proto_i].type;13252 ZigType *param_type = fn_type_id->param_info[next_proto_i].type;
13253 if (type_is_invalid(param_type))13253 if (type_is_invalid(param_type))
13254 return ira->codegen->builtin_types.entry_invalid;13254 return ira->codegen->builtin_types.entry_invalid;
13255 first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;13255 first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;
...@@ -13285,11 +13285,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13285,11 +13285,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13285 }13285 }
1328613286
13287 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;13287 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
13288 TypeTableEntry *specified_return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node);13288 ZigType *specified_return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node);
13289 if (type_is_invalid(specified_return_type))13289 if (type_is_invalid(specified_return_type))
13290 return ira->codegen->builtin_types.entry_invalid;13290 return ira->codegen->builtin_types.entry_invalid;
13291 TypeTableEntry *return_type;13291 ZigType *return_type;
13292 TypeTableEntry *inferred_err_set_type = nullptr;13292 ZigType *inferred_err_set_type = nullptr;
13293 if (fn_proto_node->data.fn_proto.auto_err_set) {13293 if (fn_proto_node->data.fn_proto.auto_err_set) {
13294 inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry);13294 inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry);
13295 return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);13295 return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);
...@@ -13320,7 +13320,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13320,7 +13320,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13320 inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1);13320 inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1);
13321 inferred_err_set_type->data.error_set.errors[0] = result->value.data.x_err_union.err;13321 inferred_err_set_type->data.error_set.errors[0] = result->value.data.x_err_union.err;
13322 }13322 }
13323 TypeTableEntry *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type;13323 ZigType *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type;
13324 inferred_err_set_type->data.error_set.err_count = fn_inferred_err_set_type->data.error_set.err_count;13324 inferred_err_set_type->data.error_set.err_count = fn_inferred_err_set_type->data.error_set.err_count;
13325 inferred_err_set_type->data.error_set.errors = fn_inferred_err_set_type->data.error_set.errors;13325 inferred_err_set_type->data.error_set.errors = fn_inferred_err_set_type->data.error_set.errors;
13326 } else if (result->value.type->id == TypeTableEntryIdErrorSet) {13326 } else if (result->value.type->id == TypeTableEntryIdErrorSet) {
...@@ -13344,10 +13344,10 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13344,10 +13344,10 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1334413344
13345 IrInstruction *casted_new_stack = nullptr;13345 IrInstruction *casted_new_stack = nullptr;
13346 if (call_instruction->new_stack != nullptr) {13346 if (call_instruction->new_stack != nullptr) {
13347 TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,13347 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
13348 false, false, PtrLenUnknown,13348 false, false, PtrLenUnknown,
13349 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);13349 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
13350 TypeTableEntry *u8_slice = get_slice_type(ira->codegen, u8_ptr);13350 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
13351 IrInstruction *new_stack = call_instruction->new_stack->other;13351 IrInstruction *new_stack = call_instruction->new_stack->other;
13352 if (type_is_invalid(new_stack->value.type))13352 if (type_is_invalid(new_stack->value.type))
13353 return ira->codegen->builtin_types.entry_invalid;13353 return ira->codegen->builtin_types.entry_invalid;
...@@ -13405,7 +13405,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13405,7 +13405,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1340513405
13406 bool first_arg_known_bare = false;13406 bool first_arg_known_bare = false;
13407 if (fn_type_id->next_param_index >= 1) {13407 if (fn_type_id->next_param_index >= 1) {
13408 TypeTableEntry *param_type = fn_type_id->param_info[next_proto_i].type;13408 ZigType *param_type = fn_type_id->param_info[next_proto_i].type;
13409 if (type_is_invalid(param_type))13409 if (type_is_invalid(param_type))
13410 return ira->codegen->builtin_types.entry_invalid;13410 return ira->codegen->builtin_types.entry_invalid;
13411 first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;13411 first_arg_known_bare = param_type->id != TypeTableEntryIdPointer;
...@@ -13515,11 +13515,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13515,11 +13515,11 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1351513515
13516 if (fn_proto_node->data.fn_proto.return_var_token == nullptr) {13516 if (fn_proto_node->data.fn_proto.return_var_token == nullptr) {
13517 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;13517 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
13518 TypeTableEntry *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node);13518 ZigType *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node);
13519 if (type_is_invalid(specified_return_type))13519 if (type_is_invalid(specified_return_type))
13520 return ira->codegen->builtin_types.entry_invalid;13520 return ira->codegen->builtin_types.entry_invalid;
13521 if (fn_proto_node->data.fn_proto.auto_err_set) {13521 if (fn_proto_node->data.fn_proto.auto_err_set) {
13522 TypeTableEntry *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn);13522 ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn);
13523 inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);13523 inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type);
13524 } else {13524 } else {
13525 inst_fn_type_id.return_type = specified_return_type;13525 inst_fn_type_id.return_type = specified_return_type;
...@@ -13537,7 +13537,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13537,7 +13537,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13537 if (call_instruction->is_async) {13537 if (call_instruction->is_async) {
13538 AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type;13538 AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type;
13539 if (async_allocator_type_node != nullptr) {13539 if (async_allocator_type_node != nullptr) {
13540 TypeTableEntry *async_allocator_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, async_allocator_type_node);13540 ZigType *async_allocator_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, async_allocator_type_node);
13541 if (type_is_invalid(async_allocator_type))13541 if (type_is_invalid(async_allocator_type))
13542 return ira->codegen->builtin_types.entry_invalid;13542 return ira->codegen->builtin_types.entry_invalid;
13543 inst_fn_type_id.async_allocator_type = async_allocator_type;13543 inst_fn_type_id.async_allocator_type = async_allocator_type;
...@@ -13581,7 +13581,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13581,7 +13581,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13581 ira->codegen->fn_defs.append(impl_fn);13581 ira->codegen->fn_defs.append(impl_fn);
13582 }13582 }
1358313583
13584 TypeTableEntry *return_type = impl_fn->type_entry->data.fn.fn_type_id.return_type;13584 ZigType *return_type = impl_fn->type_entry->data.fn.fn_type_id.return_type;
13585 if (fn_type_can_fail(&impl_fn->type_entry->data.fn.fn_type_id)) {13585 if (fn_type_can_fail(&impl_fn->type_entry->data.fn.fn_type_id)) {
13586 parent_fn_entry->calls_or_awaits_errorable_fn = true;13586 parent_fn_entry->calls_or_awaits_errorable_fn = true;
13587 }13587 }
...@@ -13618,7 +13618,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13618,7 +13618,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13618 if (first_arg_ptr) {13618 if (first_arg_ptr) {
13619 assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer);13619 assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer);
1362013620
13621 TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type;13621 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
13622 if (type_is_invalid(param_type))13622 if (type_is_invalid(param_type))
13623 return ira->codegen->builtin_types.entry_invalid;13623 return ira->codegen->builtin_types.entry_invalid;
1362413624
...@@ -13646,7 +13646,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13646,7 +13646,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13646 return ira->codegen->builtin_types.entry_invalid;13646 return ira->codegen->builtin_types.entry_invalid;
13647 IrInstruction *casted_arg;13647 IrInstruction *casted_arg;
13648 if (next_arg_index < src_param_count) {13648 if (next_arg_index < src_param_count) {
13649 TypeTableEntry *param_type = fn_type_id->param_info[next_arg_index].type;13649 ZigType *param_type = fn_type_id->param_info[next_arg_index].type;
13650 if (type_is_invalid(param_type))13650 if (type_is_invalid(param_type))
13651 return ira->codegen->builtin_types.entry_invalid;13651 return ira->codegen->builtin_types.entry_invalid;
13652 casted_arg = ir_implicit_cast(ira, old_arg, param_type);13652 casted_arg = ir_implicit_cast(ira, old_arg, param_type);
...@@ -13662,7 +13662,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13662,7 +13662,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1366213662
13663 assert(next_arg_index == call_param_count);13663 assert(next_arg_index == call_param_count);
1366413664
13665 TypeTableEntry *return_type = fn_type_id->return_type;13665 ZigType *return_type = fn_type_id->return_type;
13666 if (type_is_invalid(return_type))13666 if (type_is_invalid(return_type))
13667 return ira->codegen->builtin_types.entry_invalid;13667 return ira->codegen->builtin_types.entry_invalid;
1366813668
...@@ -13703,7 +13703,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal...@@ -13703,7 +13703,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
13703 return ir_finish_anal(ira, return_type);13703 return ir_finish_anal(ira, return_type);
13704}13704}
1370513705
13706static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *call_instruction) {13706static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *call_instruction) {
13707 IrInstruction *fn_ref = call_instruction->fn_ref->other;13707 IrInstruction *fn_ref = call_instruction->fn_ref->other;
13708 if (type_is_invalid(fn_ref->value.type))13708 if (type_is_invalid(fn_ref->value.type))
13709 return ira->codegen->builtin_types.entry_invalid;13709 return ira->codegen->builtin_types.entry_invalid;
...@@ -13713,7 +13713,7 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction...@@ -13713,7 +13713,7 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction
1371313713
13714 if (is_comptime || instr_is_comptime(fn_ref)) {13714 if (is_comptime || instr_is_comptime(fn_ref)) {
13715 if (fn_ref->value.type->id == TypeTableEntryIdMetaType) {13715 if (fn_ref->value.type->id == TypeTableEntryIdMetaType) {
13716 TypeTableEntry *dest_type = ir_resolve_type(ira, fn_ref);13716 ZigType *dest_type = ir_resolve_type(ira, fn_ref);
13717 if (type_is_invalid(dest_type))13717 if (type_is_invalid(dest_type))
13718 return ira->codegen->builtin_types.entry_invalid;13718 return ira->codegen->builtin_types.entry_invalid;
1371913719
...@@ -13793,12 +13793,12 @@ static Error ir_read_const_ptr(IrAnalyze *ira, AstNode *source_node,...@@ -13793,12 +13793,12 @@ static Error ir_read_const_ptr(IrAnalyze *ira, AstNode *source_node,
13793 return ErrorNone;13793 return ErrorNone;
13794}13794}
1379513795
13796static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {13796static ZigType *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
13797 Error err;13797 Error err;
13798 IrInstruction *value = un_op_instruction->value->other;13798 IrInstruction *value = un_op_instruction->value->other;
1379913799
13800 TypeTableEntry *ptr_type = value->value.type;13800 ZigType *ptr_type = value->value.type;
13801 TypeTableEntry *child_type;13801 ZigType *child_type;
13802 if (type_is_invalid(ptr_type)) {13802 if (type_is_invalid(ptr_type)) {
13803 return ira->codegen->builtin_types.entry_invalid;13803 return ira->codegen->builtin_types.entry_invalid;
13804 } else if (ptr_type->id == TypeTableEntryIdPointer) {13804 } else if (ptr_type->id == TypeTableEntryIdPointer) {
...@@ -13835,10 +13835,10 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp...@@ -13835,10 +13835,10 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp
13835 return child_type;13835 return child_type;
13836}13836}
1383713837
13838static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {13838static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
13839 Error err;13839 Error err;
13840 IrInstruction *value = un_op_instruction->value->other;13840 IrInstruction *value = un_op_instruction->value->other;
13841 TypeTableEntry *type_entry = ir_resolve_type(ira, value);13841 ZigType *type_entry = ir_resolve_type(ira, value);
13842 if (type_is_invalid(type_entry))13842 if (type_is_invalid(type_entry))
13843 return ira->codegen->builtin_types.entry_invalid;13843 return ira->codegen->builtin_types.entry_invalid;
13844 if ((err = ensure_complete_type(ira->codegen, type_entry)))13844 if ((err = ensure_complete_type(ira->codegen, type_entry)))
...@@ -13884,9 +13884,9 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op...@@ -13884,9 +13884,9 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
13884 zig_unreachable();13884 zig_unreachable();
13885}13885}
1388613886
13887static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {13887static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
13888 IrInstruction *value = un_op_instruction->value->other;13888 IrInstruction *value = un_op_instruction->value->other;
13889 TypeTableEntry *expr_type = value->value.type;13889 ZigType *expr_type = value->value.type;
13890 if (type_is_invalid(expr_type))13890 if (type_is_invalid(expr_type))
13891 return ira->codegen->builtin_types.entry_invalid;13891 return ira->codegen->builtin_types.entry_invalid;
1389213892
...@@ -13931,9 +13931,9 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un...@@ -13931,9 +13931,9 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
13931 return ira->codegen->builtin_types.entry_invalid;13931 return ira->codegen->builtin_types.entry_invalid;
13932}13932}
1393313933
13934static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) {13934static ZigType *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) {
13935 IrInstruction *value = instruction->value->other;13935 IrInstruction *value = instruction->value->other;
13936 TypeTableEntry *expr_type = value->value.type;13936 ZigType *expr_type = value->value.type;
13937 if (type_is_invalid(expr_type))13937 if (type_is_invalid(expr_type))
13938 return ira->codegen->builtin_types.entry_invalid;13938 return ira->codegen->builtin_types.entry_invalid;
1393913939
...@@ -13958,7 +13958,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins...@@ -13958,7 +13958,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins
13958 return ira->codegen->builtin_types.entry_invalid;13958 return ira->codegen->builtin_types.entry_invalid;
13959}13959}
1396013960
13961static TypeTableEntry *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {13961static ZigType *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
13962 IrUnOp op_id = un_op_instruction->op_id;13962 IrUnOp op_id = un_op_instruction->op_id;
13963 switch (op_id) {13963 switch (op_id) {
13964 case IrUnOpInvalid:13964 case IrUnOpInvalid:
...@@ -13976,7 +13976,7 @@ static TypeTableEntry *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructio...@@ -13976,7 +13976,7 @@ static TypeTableEntry *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructio
13976 zig_unreachable();13976 zig_unreachable();
13977}13977}
1397813978
13979static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) {13979static ZigType *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) {
13980 IrBasicBlock *old_dest_block = br_instruction->dest_block;13980 IrBasicBlock *old_dest_block = br_instruction->dest_block;
1398113981
13982 bool is_comptime;13982 bool is_comptime;
...@@ -13994,7 +13994,7 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr...@@ -13994,7 +13994,7 @@ static TypeTableEntry *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr
13994 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);13994 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
13995}13995}
1399613996
13997static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) {13997static ZigType *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) {
13998 IrInstruction *condition = cond_br_instruction->condition->other;13998 IrInstruction *condition = cond_br_instruction->condition->other;
13999 if (type_is_invalid(condition->value.type))13999 if (type_is_invalid(condition->value.type))
14000 return ir_unreach_error(ira);14000 return ir_unreach_error(ira);
...@@ -14022,7 +14022,7 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct...@@ -14022,7 +14022,7 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct
14022 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);14022 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
14023 }14023 }
1402414024
14025 TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;14025 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
14026 IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type);14026 IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type);
14027 if (casted_condition == ira->codegen->invalid_instruction)14027 if (casted_condition == ira->codegen->invalid_instruction)
14028 return ir_unreach_error(ira);14028 return ir_unreach_error(ira);
...@@ -14041,14 +14041,14 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct...@@ -14041,14 +14041,14 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct
14041 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);14041 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
14042}14042}
1404314043
14044static TypeTableEntry *ir_analyze_instruction_unreachable(IrAnalyze *ira,14044static ZigType *ir_analyze_instruction_unreachable(IrAnalyze *ira,
14045 IrInstructionUnreachable *unreachable_instruction)14045 IrInstructionUnreachable *unreachable_instruction)
14046{14046{
14047 ir_build_unreachable_from(&ira->new_irb, &unreachable_instruction->base);14047 ir_build_unreachable_from(&ira->new_irb, &unreachable_instruction->base);
14048 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);14048 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
14049}14049}
1405014050
14051static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) {14051static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) {
14052 if (ira->const_predecessor_bb) {14052 if (ira->const_predecessor_bb) {
14053 for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) {14053 for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) {
14054 IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i];14054 IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i];
...@@ -14105,7 +14105,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP...@@ -14105,7 +14105,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
14105 return first_value->value.type;14105 return first_value->value.type;
14106 }14106 }
1410714107
14108 TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,14108 ZigType *resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr,
14109 new_incoming_values.items, new_incoming_values.length);14109 new_incoming_values.items, new_incoming_values.length);
14110 if (type_is_invalid(resolved_type))14110 if (type_is_invalid(resolved_type))
14111 return resolved_type;14111 return resolved_type;
...@@ -14157,7 +14157,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP...@@ -14157,7 +14157,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
14157 return resolved_type;14157 return resolved_type;
14158}14158}
1415914159
14160static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,14160static ZigType *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
14161 VariableTableEntry *var)14161 VariableTableEntry *var)
14162{14162{
14163 IrInstruction *result = ir_get_var_ptr(ira, instruction, var);14163 IrInstruction *result = ir_get_var_ptr(ira, instruction, var);
...@@ -14165,12 +14165,12 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc...@@ -14165,12 +14165,12 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc
14165 return result->value.type;14165 return result->value.type;
14166}14166}
1416714167
14168static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {14168static ZigType *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {
14169 VariableTableEntry *var = var_ptr_instruction->var;14169 VariableTableEntry *var = var_ptr_instruction->var;
14170 return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var);14170 return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var);
14171}14171}
1417214172
14173static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, uint32_t new_align) {14173static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align) {
14174 assert(ptr_type->id == TypeTableEntryIdPointer);14174 assert(ptr_type->id == TypeTableEntryIdPointer);
14175 return get_pointer_to_type_extra(g,14175 return get_pointer_to_type_extra(g,
14176 ptr_type->data.pointer.child_type,14176 ptr_type->data.pointer.child_type,
...@@ -14180,14 +14180,14 @@ static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, ui...@@ -14180,14 +14180,14 @@ static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, ui
14180 ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);14180 ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);
14181}14181}
1418214182
14183static TypeTableEntry *adjust_slice_align(CodeGen *g, TypeTableEntry *slice_type, uint32_t new_align) {14183static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align) {
14184 assert(is_slice(slice_type));14184 assert(is_slice(slice_type));
14185 TypeTableEntry *ptr_type = adjust_ptr_align(g, slice_type->data.structure.fields[slice_ptr_index].type_entry,14185 ZigType *ptr_type = adjust_ptr_align(g, slice_type->data.structure.fields[slice_ptr_index].type_entry,
14186 new_align);14186 new_align);
14187 return get_slice_type(g, ptr_type);14187 return get_slice_type(g, ptr_type);
14188}14188}
1418914189
14190static TypeTableEntry *adjust_ptr_len(CodeGen *g, TypeTableEntry *ptr_type, PtrLen ptr_len) {14190static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) {
14191 assert(ptr_type->id == TypeTableEntryIdPointer);14191 assert(ptr_type->id == TypeTableEntryIdPointer);
14192 return get_pointer_to_type_extra(g,14192 return get_pointer_to_type_extra(g,
14193 ptr_type->data.pointer.child_type,14193 ptr_type->data.pointer.child_type,
...@@ -14197,7 +14197,7 @@ static TypeTableEntry *adjust_ptr_len(CodeGen *g, TypeTableEntry *ptr_type, PtrL...@@ -14197,7 +14197,7 @@ static TypeTableEntry *adjust_ptr_len(CodeGen *g, TypeTableEntry *ptr_type, PtrL
14197 ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);14197 ptr_type->data.pointer.bit_offset, ptr_type->data.pointer.unaligned_bit_count);
14198}14198}
1419914199
14200static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) {14200static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) {
14201 Error err;14201 Error err;
14202 IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->other;14202 IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->other;
14203 if (type_is_invalid(array_ptr->value.type))14203 if (type_is_invalid(array_ptr->value.type))
...@@ -14209,14 +14209,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc...@@ -14209,14 +14209,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
14209 if (type_is_invalid(elem_index->value.type))14209 if (type_is_invalid(elem_index->value.type))
14210 return ira->codegen->builtin_types.entry_invalid;14210 return ira->codegen->builtin_types.entry_invalid;
1421114211
14212 TypeTableEntry *ptr_type = orig_array_ptr_val->type;14212 ZigType *ptr_type = orig_array_ptr_val->type;
14213 assert(ptr_type->id == TypeTableEntryIdPointer);14213 assert(ptr_type->id == TypeTableEntryIdPointer);
1421414214
14215 TypeTableEntry *array_type = ptr_type->data.pointer.child_type;14215 ZigType *array_type = ptr_type->data.pointer.child_type;
1421614216
14217 // At first return_type will be the pointer type we want to return, except with an optimistic alignment.14217 // At first return_type will be the pointer type we want to return, except with an optimistic alignment.
14218 // We will adjust return_type's alignment before returning it.14218 // We will adjust return_type's alignment before returning it.
14219 TypeTableEntry *return_type;14219 ZigType *return_type;
1422014220
14221 if (type_is_invalid(array_type)) {14221 if (type_is_invalid(array_type)) {
14222 return array_type;14222 return array_type;
...@@ -14240,7 +14240,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc...@@ -14240,7 +14240,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
14240 buf_sprintf("index 0 outside array of size 0"));14240 buf_sprintf("index 0 outside array of size 0"));
14241 return ira->codegen->builtin_types.entry_invalid;14241 return ira->codegen->builtin_types.entry_invalid;
14242 }14242 }
14243 TypeTableEntry *child_type = array_type->data.array.child_type;14243 ZigType *child_type = array_type->data.array.child_type;
14244 if (ptr_type->data.pointer.unaligned_bit_count == 0) {14244 if (ptr_type->data.pointer.unaligned_bit_count == 0) {
14245 return_type = get_pointer_to_type_extra(ira->codegen, child_type,14245 return_type = get_pointer_to_type_extra(ira->codegen, child_type,
14246 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,14246 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
...@@ -14306,7 +14306,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc...@@ -14306,7 +14306,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
14306 return ira->codegen->builtin_types.entry_invalid;14306 return ira->codegen->builtin_types.entry_invalid;
14307 }14307 }
1430814308
14309 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;14309 ZigType *usize = ira->codegen->builtin_types.entry_usize;
14310 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize);14310 IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize);
14311 if (casted_elem_index == ira->codegen->invalid_instruction)14311 if (casted_elem_index == ira->codegen->invalid_instruction)
14312 return ira->codegen->builtin_types.entry_invalid;14312 return ira->codegen->builtin_types.entry_invalid;
...@@ -14496,8 +14496,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc...@@ -14496,8 +14496,8 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
14496}14496}
1449714497
14498static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,14498static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,
14499 TypeTableEntry *bare_struct_type, Buf *field_name, IrInstruction *source_instr,14499 ZigType *bare_struct_type, Buf *field_name, IrInstruction *source_instr,
14500 IrInstruction *container_ptr, TypeTableEntry *container_type)14500 IrInstruction *container_ptr, ZigType *container_type)
14501{14501{
14502 if (!is_slice(bare_struct_type)) {14502 if (!is_slice(bare_struct_type)) {
14503 ScopeDecls *container_scope = get_container_scope(bare_struct_type);14503 ScopeDecls *container_scope = get_container_scope(bare_struct_type);
...@@ -14536,11 +14536,11 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,...@@ -14536,11 +14536,11 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira,
14536}14536}
1453714537
14538static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,14538static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,
14539 IrInstruction *source_instr, IrInstruction *container_ptr, TypeTableEntry *container_type)14539 IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type)
14540{14540{
14541 Error err;14541 Error err;
1454214542
14543 TypeTableEntry *bare_type = container_ref_type(container_type);14543 ZigType *bare_type = container_ref_type(container_type);
14544 if ((err = ensure_complete_type(ira->codegen, bare_type)))14544 if ((err = ensure_complete_type(ira->codegen, bare_type)))
14545 return ira->codegen->invalid_instruction;14545 return ira->codegen->invalid_instruction;
1454614546
...@@ -14568,7 +14568,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_...@@ -14568,7 +14568,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
14568 if (type_is_invalid(struct_val->type))14568 if (type_is_invalid(struct_val->type))
14569 return ira->codegen->invalid_instruction;14569 return ira->codegen->invalid_instruction;
14570 ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index];14570 ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index];
14571 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, field_val->type,14571 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_val->type,
14572 is_const, is_volatile, PtrLenSingle, align_bytes,14572 is_const, is_volatile, PtrLenSingle, align_bytes,
14573 (uint32_t)(ptr_bit_offset + field->packed_bits_offset),14573 (uint32_t)(ptr_bit_offset + field->packed_bits_offset),
14574 (uint32_t)unaligned_bit_count_for_result_type);14574 (uint32_t)unaligned_bit_count_for_result_type);
...@@ -14625,7 +14625,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_...@@ -14625,7 +14625,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
1462514625
14626 ConstExprValue *payload_val = union_val->data.x_union.payload;14626 ConstExprValue *payload_val = union_val->data.x_union.payload;
1462714627
14628 TypeTableEntry *field_type = field->type_entry;14628 ZigType *field_type = field->type_entry;
14629 if (field_type->id == TypeTableEntryIdVoid) {14629 if (field_type->id == TypeTableEntryIdVoid) {
14630 assert(payload_val == nullptr);14630 assert(payload_val == nullptr);
14631 payload_val = create_const_vals(1);14631 payload_val = create_const_vals(1);
...@@ -14633,7 +14633,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_...@@ -14633,7 +14633,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_
14633 payload_val->type = field_type;14633 payload_val->type = field_type;
14634 }14634 }
1463514635
14636 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,14636 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type,
14637 is_const, is_volatile,14637 is_const, is_volatile,
14638 PtrLenSingle,14638 PtrLenSingle,
14639 get_abi_alignment(ira->codegen, field_type), 0, 0);14639 get_abi_alignment(ira->codegen, field_type), 0, 0);
...@@ -14680,7 +14680,7 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name,...@@ -14680,7 +14680,7 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name,
14680}14680}
1468114681
1468214682
14683static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) {14683static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) {
14684 bool pointer_only = false;14684 bool pointer_only = false;
14685 resolve_top_level_decl(ira->codegen, tld, pointer_only, source_instruction->source_node);14685 resolve_top_level_decl(ira->codegen, tld, pointer_only, source_instruction->source_node);
14686 if (tld->resolution == TldResolutionInvalid)14686 if (tld->resolution == TldResolutionInvalid)
...@@ -14731,7 +14731,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source...@@ -14731,7 +14731,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
14731 zig_unreachable();14731 zig_unreachable();
14732}14732}
1473314733
14734static ErrorTableEntry *find_err_table_entry(TypeTableEntry *err_set_type, Buf *field_name) {14734static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_name) {
14735 assert(err_set_type->id == TypeTableEntryIdErrorSet);14735 assert(err_set_type->id == TypeTableEntryIdErrorSet);
14736 for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {14736 for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {
14737 ErrorTableEntry *err_table_entry = err_set_type->data.error_set.errors[i];14737 ErrorTableEntry *err_table_entry = err_set_type->data.error_set.errors[i];
...@@ -14742,13 +14742,13 @@ static ErrorTableEntry *find_err_table_entry(TypeTableEntry *err_set_type, Buf *...@@ -14742,13 +14742,13 @@ static ErrorTableEntry *find_err_table_entry(TypeTableEntry *err_set_type, Buf *
14742 return nullptr;14742 return nullptr;
14743}14743}
1474414744
14745static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) {14745static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) {
14746 Error err;14746 Error err;
14747 IrInstruction *container_ptr = field_ptr_instruction->container_ptr->other;14747 IrInstruction *container_ptr = field_ptr_instruction->container_ptr->other;
14748 if (type_is_invalid(container_ptr->value.type))14748 if (type_is_invalid(container_ptr->value.type))
14749 return ira->codegen->builtin_types.entry_invalid;14749 return ira->codegen->builtin_types.entry_invalid;
1475014750
14751 TypeTableEntry *container_type = container_ptr->value.type->data.pointer.child_type;14751 ZigType *container_type = container_ptr->value.type->data.pointer.child_type;
14752 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);14752 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
1475314753
14754 Buf *field_name = field_ptr_instruction->field_name_buffer;14754 Buf *field_name = field_ptr_instruction->field_name_buffer;
...@@ -14767,7 +14767,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14767,7 +14767,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14767 } else if (is_container_ref(container_type)) {14767 } else if (is_container_ref(container_type)) {
14768 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);14768 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
14769 if (container_type->id == TypeTableEntryIdPointer) {14769 if (container_type->id == TypeTableEntryIdPointer) {
14770 TypeTableEntry *bare_type = container_ref_type(container_type);14770 ZigType *bare_type = container_ref_type(container_type);
14771 IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr);14771 IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr);
14772 IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type);14772 IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type);
14773 ir_link_new_instruction(result, &field_ptr_instruction->base);14773 ir_link_new_instruction(result, &field_ptr_instruction->base);
...@@ -14786,7 +14786,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14786,7 +14786,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14786 init_const_usize(ira->codegen, len_val, container_type->data.array.len);14786 init_const_usize(ira->codegen, len_val, container_type->data.array.len);
14787 }14787 }
1478814788
14789 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;14789 ZigType *usize = ira->codegen->builtin_types.entry_usize;
14790 bool ptr_is_const = true;14790 bool ptr_is_const = true;
14791 bool ptr_is_volatile = false;14791 bool ptr_is_volatile = false;
14792 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,14792 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
...@@ -14812,7 +14812,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14812,7 +14812,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14812 size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index;14812 size_t len = child_val->data.x_arg_tuple.end_index - child_val->data.x_arg_tuple.start_index;
14813 init_const_usize(ira->codegen, len_val, len);14813 init_const_usize(ira->codegen, len_val, len);
1481414814
14815 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;14815 ZigType *usize = ira->codegen->builtin_types.entry_usize;
14816 bool ptr_is_const = true;14816 bool ptr_is_const = true;
14817 bool ptr_is_volatile = false;14817 bool ptr_is_volatile = false;
14818 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,14818 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val,
...@@ -14832,7 +14832,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14832,7 +14832,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14832 ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node);14832 ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node);
14833 if (child_val == nullptr)14833 if (child_val == nullptr)
14834 return ira->codegen->builtin_types.entry_invalid;14834 return ira->codegen->builtin_types.entry_invalid;
14835 TypeTableEntry *child_type = child_val->data.x_type;14835 ZigType *child_type = child_val->data.x_type;
1483614836
14837 if (type_is_invalid(child_type)) {14837 if (type_is_invalid(child_type)) {
14838 return ira->codegen->builtin_types.entry_invalid;14838 return ira->codegen->builtin_types.entry_invalid;
...@@ -14842,7 +14842,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14842,7 +14842,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14842 bool ptr_is_volatile = false;14842 bool ptr_is_volatile = false;
14843 TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index];14843 TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index];
14844 assert(ptr_field->type_entry->id == TypeTableEntryIdPointer);14844 assert(ptr_field->type_entry->id == TypeTableEntryIdPointer);
14845 TypeTableEntry *child_type = ptr_field->type_entry->data.pointer.child_type;14845 ZigType *child_type = ptr_field->type_entry->data.pointer.child_type;
14846 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,14846 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
14847 create_const_type(ira->codegen, child_type),14847 create_const_type(ira->codegen, child_type),
14848 ira->codegen->builtin_types.entry_type,14848 ira->codegen->builtin_types.entry_type,
...@@ -14877,7 +14877,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14877,7 +14877,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14877 return ira->codegen->builtin_types.entry_invalid;14877 return ira->codegen->builtin_types.entry_invalid;
14878 TypeUnionField *field = find_union_type_field(child_type, field_name);14878 TypeUnionField *field = find_union_type_field(child_type, field_name);
14879 if (field) {14879 if (field) {
14880 TypeTableEntry *enum_type = child_type->data.unionation.tag_type;14880 ZigType *enum_type = child_type->data.unionation.tag_type;
14881 bool ptr_is_const = true;14881 bool ptr_is_const = true;
14882 bool ptr_is_volatile = false;14882 bool ptr_is_volatile = false;
14883 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,14883 return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
...@@ -14891,7 +14891,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -14891,7 +14891,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
14891 return ira->codegen->builtin_types.entry_invalid;14891 return ira->codegen->builtin_types.entry_invalid;
14892 } else if (child_type->id == TypeTableEntryIdErrorSet) {14892 } else if (child_type->id == TypeTableEntryIdErrorSet) {
14893 ErrorTableEntry *err_entry;14893 ErrorTableEntry *err_entry;
14894 TypeTableEntry *err_set_type;14894 ZigType *err_set_type;
14895 if (type_is_global_error_set(child_type)) {14895 if (type_is_global_error_set(child_type)) {
14896 auto existing_entry = ira->codegen->error_table.maybe_get(field_name);14896 auto existing_entry = ira->codegen->error_table.maybe_get(field_name);
14897 if (existing_entry) {14897 if (existing_entry) {
...@@ -15131,7 +15131,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru...@@ -15131,7 +15131,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
15131 }15131 }
15132}15132}
1513315133
15134static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *load_ptr_instruction) {15134static ZigType *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *load_ptr_instruction) {
15135 IrInstruction *ptr = load_ptr_instruction->ptr->other;15135 IrInstruction *ptr = load_ptr_instruction->ptr->other;
15136 if (type_is_invalid(ptr->value.type))15136 if (type_is_invalid(ptr->value.type))
15137 return ira->codegen->builtin_types.entry_invalid;15137 return ira->codegen->builtin_types.entry_invalid;
...@@ -15142,7 +15142,7 @@ static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstruc...@@ -15142,7 +15142,7 @@ static TypeTableEntry *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstruc
15142 return result->value.type;15142 return result->value.type;
15143}15143}
1514415144
15145static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *store_ptr_instruction) {15145static ZigType *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *store_ptr_instruction) {
15146 IrInstruction *ptr = store_ptr_instruction->ptr->other;15146 IrInstruction *ptr = store_ptr_instruction->ptr->other;
15147 if (type_is_invalid(ptr->value.type))15147 if (type_is_invalid(ptr->value.type))
15148 return ptr->value.type;15148 return ptr->value.type;
...@@ -15166,7 +15166,7 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru...@@ -15166,7 +15166,7 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
15166 return ira->codegen->builtin_types.entry_invalid;15166 return ira->codegen->builtin_types.entry_invalid;
15167 }15167 }
1516815168
15169 TypeTableEntry *child_type = ptr->value.type->data.pointer.child_type;15169 ZigType *child_type = ptr->value.type->data.pointer.child_type;
15170 IrInstruction *casted_value = ir_implicit_cast(ira, value, child_type);15170 IrInstruction *casted_value = ir_implicit_cast(ira, value, child_type);
15171 if (casted_value == ira->codegen->invalid_instruction)15171 if (casted_value == ira->codegen->invalid_instruction)
15172 return ira->codegen->builtin_types.entry_invalid;15172 return ira->codegen->builtin_types.entry_invalid;
...@@ -15202,9 +15202,9 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru...@@ -15202,9 +15202,9 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
15202 return ira->codegen->builtin_types.entry_void;15202 return ira->codegen->builtin_types.entry_void;
15203}15203}
1520415204
15205static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) {15205static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) {
15206 IrInstruction *expr_value = typeof_instruction->value->other;15206 IrInstruction *expr_value = typeof_instruction->value->other;
15207 TypeTableEntry *type_entry = expr_value->value.type;15207 ZigType *type_entry = expr_value->value.type;
15208 if (type_is_invalid(type_entry))15208 if (type_is_invalid(type_entry))
15209 return ira->codegen->builtin_types.entry_invalid;15209 return ira->codegen->builtin_types.entry_invalid;
15210 switch (type_entry->id) {15210 switch (type_entry->id) {
...@@ -15246,15 +15246,15 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi...@@ -15246,15 +15246,15 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi
15246 zig_unreachable();15246 zig_unreachable();
15247}15247}
1524815248
15249static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,15249static ZigType *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
15250 IrInstructionToPtrType *to_ptr_type_instruction)15250 IrInstructionToPtrType *to_ptr_type_instruction)
15251{15251{
15252 IrInstruction *value = to_ptr_type_instruction->value->other;15252 IrInstruction *value = to_ptr_type_instruction->value->other;
15253 TypeTableEntry *type_entry = value->value.type;15253 ZigType *type_entry = value->value.type;
15254 if (type_is_invalid(type_entry))15254 if (type_is_invalid(type_entry))
15255 return type_entry;15255 return type_entry;
1525615256
15257 TypeTableEntry *ptr_type;15257 ZigType *ptr_type;
15258 if (type_entry->id == TypeTableEntryIdArray) {15258 if (type_entry->id == TypeTableEntryIdArray) {
15259 ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, false);15259 ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, false);
15260 } else if (is_slice(type_entry)) {15260 } else if (is_slice(type_entry)) {
...@@ -15275,11 +15275,11 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,...@@ -15275,11 +15275,11 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira,
15275 return ira->codegen->builtin_types.entry_type;15275 return ira->codegen->builtin_types.entry_type;
15276}15276}
1527715277
15278static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,15278static ZigType *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
15279 IrInstructionPtrTypeChild *ptr_type_child_instruction)15279 IrInstructionPtrTypeChild *ptr_type_child_instruction)
15280{15280{
15281 IrInstruction *type_value = ptr_type_child_instruction->value->other;15281 IrInstruction *type_value = ptr_type_child_instruction->value->other;
15282 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);15282 ZigType *type_entry = ir_resolve_type(ira, type_value);
15283 if (type_is_invalid(type_entry))15283 if (type_is_invalid(type_entry))
15284 return type_entry;15284 return type_entry;
1528515285
...@@ -15294,7 +15294,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,...@@ -15294,7 +15294,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
15294 return ira->codegen->builtin_types.entry_type;15294 return ira->codegen->builtin_types.entry_type;
15295}15295}
1529615296
15297static TypeTableEntry *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) {15297static ZigType *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) {
15298 if (ira->new_irb.exec->is_inline) {15298 if (ira->new_irb.exec->is_inline) {
15299 // ignore setCold when running functions at compile time15299 // ignore setCold when running functions at compile time
15300 ir_build_const_from(ira, &instruction->base);15300 ir_build_const_from(ira, &instruction->base);
...@@ -15324,7 +15324,7 @@ static TypeTableEntry *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstruc...@@ -15324,7 +15324,7 @@ static TypeTableEntry *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstruc
15324 ir_build_const_from(ira, &instruction->base);15324 ir_build_const_from(ira, &instruction->base);
15325 return ira->codegen->builtin_types.entry_void;15325 return ira->codegen->builtin_types.entry_void;
15326}15326}
15327static TypeTableEntry *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,15327static ZigType *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
15328 IrInstructionSetRuntimeSafety *set_runtime_safety_instruction)15328 IrInstructionSetRuntimeSafety *set_runtime_safety_instruction)
15329{15329{
15330 if (ira->new_irb.exec->is_inline) {15330 if (ira->new_irb.exec->is_inline) {
...@@ -15381,11 +15381,11 @@ static TypeTableEntry *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,...@@ -15381,11 +15381,11 @@ static TypeTableEntry *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira,
15381 return ira->codegen->builtin_types.entry_void;15381 return ira->codegen->builtin_types.entry_void;
15382}15382}
1538315383
15384static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,15384static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
15385 IrInstructionSetFloatMode *instruction)15385 IrInstructionSetFloatMode *instruction)
15386{15386{
15387 IrInstruction *target_instruction = instruction->scope_value->other;15387 IrInstruction *target_instruction = instruction->scope_value->other;
15388 TypeTableEntry *target_type = target_instruction->value.type;15388 ZigType *target_type = target_instruction->value.type;
15389 if (type_is_invalid(target_type))15389 if (type_is_invalid(target_type))
15390 return ira->codegen->builtin_types.entry_invalid;15390 return ira->codegen->builtin_types.entry_invalid;
15391 ConstExprValue *target_val = ir_resolve_const(ira, target_instruction, UndefBad);15391 ConstExprValue *target_val = ir_resolve_const(ira, target_instruction, UndefBad);
...@@ -15412,7 +15412,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,...@@ -15412,7 +15412,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
15412 fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node;15412 fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node;
15413 } else if (target_type->id == TypeTableEntryIdMetaType) {15413 } else if (target_type->id == TypeTableEntryIdMetaType) {
15414 ScopeDecls *decls_scope;15414 ScopeDecls *decls_scope;
15415 TypeTableEntry *type_arg = target_val->data.x_type;15415 ZigType *type_arg = target_val->data.x_type;
15416 if (type_arg->id == TypeTableEntryIdStruct) {15416 if (type_arg->id == TypeTableEntryIdStruct) {
15417 decls_scope = type_arg->data.structure.decls_scope;15417 decls_scope = type_arg->data.structure.decls_scope;
15418 } else if (type_arg->id == TypeTableEntryIdEnum) {15418 } else if (type_arg->id == TypeTableEntryIdEnum) {
...@@ -15452,7 +15452,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,...@@ -15452,7 +15452,7 @@ static TypeTableEntry *ir_analyze_instruction_set_float_mode(IrAnalyze *ira,
15452 return ira->codegen->builtin_types.entry_void;15452 return ira->codegen->builtin_types.entry_void;
15453}15453}
1545415454
15455static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,15455static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15456 IrInstructionSliceType *slice_type_instruction)15456 IrInstructionSliceType *slice_type_instruction)
15457{15457{
15458 Error err;15458 Error err;
...@@ -15462,7 +15462,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -15462,7 +15462,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15462 return ira->codegen->builtin_types.entry_invalid;15462 return ira->codegen->builtin_types.entry_invalid;
15463 }15463 }
1546415464
15465 TypeTableEntry *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->other);15465 ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->other);
15466 if (type_is_invalid(child_type))15466 if (type_is_invalid(child_type))
15467 return ira->codegen->builtin_types.entry_invalid;15467 return ira->codegen->builtin_types.entry_invalid;
1546815468
...@@ -15509,9 +15509,9 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -15509,9 +15509,9 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15509 {15509 {
15510 if ((err = type_ensure_zero_bits_known(ira->codegen, child_type)))15510 if ((err = type_ensure_zero_bits_known(ira->codegen, child_type)))
15511 return ira->codegen->builtin_types.entry_invalid;15511 return ira->codegen->builtin_types.entry_invalid;
15512 TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,15512 ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, child_type,
15513 is_const, is_volatile, PtrLenUnknown, align_bytes, 0, 0);15513 is_const, is_volatile, PtrLenUnknown, align_bytes, 0, 0);
15514 TypeTableEntry *result_type = get_slice_type(ira->codegen, slice_ptr_type);15514 ZigType *result_type = get_slice_type(ira->codegen, slice_ptr_type);
15515 ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base);15515 ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base);
15516 out_val->data.x_type = result_type;15516 out_val->data.x_type = result_type;
15517 return ira->codegen->builtin_types.entry_type;15517 return ira->codegen->builtin_types.entry_type;
...@@ -15520,7 +15520,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -15520,7 +15520,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15520 zig_unreachable();15520 zig_unreachable();
15521}15521}
1552215522
15523static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsm *asm_instruction) {15523static ZigType *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsm *asm_instruction) {
15524 assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr);15524 assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr);
1552515525
15526 AstNodeAsmExpr *asm_expr = &asm_instruction->base.source_node->data.asm_expr;15526 AstNodeAsmExpr *asm_expr = &asm_instruction->base.source_node->data.asm_expr;
...@@ -15550,7 +15550,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA...@@ -15550,7 +15550,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA
15550 IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length);15550 IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length);
15551 IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length);15551 IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length);
1555215552
15553 TypeTableEntry *return_type = ira->codegen->builtin_types.entry_void;15553 ZigType *return_type = ira->codegen->builtin_types.entry_void;
15554 for (size_t i = 0; i < asm_expr->output_list.length; i += 1) {15554 for (size_t i = 0; i < asm_expr->output_list.length; i += 1) {
15555 AsmOutput *asm_output = asm_expr->output_list.at(i);15555 AsmOutput *asm_output = asm_expr->output_list.at(i);
15556 if (asm_output->return_type) {15556 if (asm_output->return_type) {
...@@ -15572,7 +15572,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA...@@ -15572,7 +15572,7 @@ static TypeTableEntry *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionA
15572 return return_type;15572 return return_type;
15573}15573}
1557415574
15575static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,15575static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira,
15576 IrInstructionArrayType *array_type_instruction)15576 IrInstructionArrayType *array_type_instruction)
15577{15577{
15578 Error err;15578 Error err;
...@@ -15583,7 +15583,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -15583,7 +15583,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
15583 return ira->codegen->builtin_types.entry_invalid;15583 return ira->codegen->builtin_types.entry_invalid;
1558415584
15585 IrInstruction *child_type_value = array_type_instruction->child_type->other;15585 IrInstruction *child_type_value = array_type_instruction->child_type->other;
15586 TypeTableEntry *child_type = ir_resolve_type(ira, child_type_value);15586 ZigType *child_type = ir_resolve_type(ira, child_type_value);
15587 if (type_is_invalid(child_type))15587 if (type_is_invalid(child_type))
15588 return ira->codegen->builtin_types.entry_invalid;15588 return ira->codegen->builtin_types.entry_invalid;
15589 switch (child_type->id) {15589 switch (child_type->id) {
...@@ -15620,7 +15620,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -15620,7 +15620,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
15620 {15620 {
15621 if ((err = ensure_complete_type(ira->codegen, child_type)))15621 if ((err = ensure_complete_type(ira->codegen, child_type)))
15622 return ira->codegen->builtin_types.entry_invalid;15622 return ira->codegen->builtin_types.entry_invalid;
15623 TypeTableEntry *result_type = get_array_type(ira->codegen, child_type, size);15623 ZigType *result_type = get_array_type(ira->codegen, child_type, size);
15624 ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base);15624 ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base);
15625 out_val->data.x_type = result_type;15625 out_val->data.x_type = result_type;
15626 return ira->codegen->builtin_types.entry_type;15626 return ira->codegen->builtin_types.entry_type;
...@@ -15629,13 +15629,13 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -15629,13 +15629,13 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
15629 zig_unreachable();15629 zig_unreachable();
15630}15630}
1563115631
15632static TypeTableEntry *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInstructionPromiseType *instruction) {15632static ZigType *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInstructionPromiseType *instruction) {
15633 TypeTableEntry *promise_type;15633 ZigType *promise_type;
1563415634
15635 if (instruction->payload_type == nullptr) {15635 if (instruction->payload_type == nullptr) {
15636 promise_type = ira->codegen->builtin_types.entry_promise;15636 promise_type = ira->codegen->builtin_types.entry_promise;
15637 } else {15637 } else {
15638 TypeTableEntry *payload_type = ir_resolve_type(ira, instruction->payload_type->other);15638 ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->other);
15639 if (type_is_invalid(payload_type))15639 if (type_is_invalid(payload_type))
15640 return ira->codegen->builtin_types.entry_invalid;15640 return ira->codegen->builtin_types.entry_invalid;
1564115641
...@@ -15647,12 +15647,12 @@ static TypeTableEntry *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrIns...@@ -15647,12 +15647,12 @@ static TypeTableEntry *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrIns
15647 return ira->codegen->builtin_types.entry_type;15647 return ira->codegen->builtin_types.entry_type;
15648}15648}
1564915649
15650static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,15650static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira,
15651 IrInstructionSizeOf *size_of_instruction)15651 IrInstructionSizeOf *size_of_instruction)
15652{15652{
15653 Error err;15653 Error err;
15654 IrInstruction *type_value = size_of_instruction->type_value->other;15654 IrInstruction *type_value = size_of_instruction->type_value->other;
15655 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);15655 ZigType *type_entry = ir_resolve_type(ira, type_value);
1565615656
15657 if ((err = ensure_complete_type(ira->codegen, type_entry)))15657 if ((err = ensure_complete_type(ira->codegen, type_entry)))
15658 return ira->codegen->builtin_types.entry_invalid;15658 return ira->codegen->builtin_types.entry_invalid;
...@@ -15698,12 +15698,12 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,...@@ -15698,12 +15698,12 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
15698 zig_unreachable();15698 zig_unreachable();
15699}15699}
1570015700
15701static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) {15701static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) {
15702 IrInstruction *value = instruction->value->other;15702 IrInstruction *value = instruction->value->other;
15703 if (type_is_invalid(value->value.type))15703 if (type_is_invalid(value->value.type))
15704 return ira->codegen->builtin_types.entry_invalid;15704 return ira->codegen->builtin_types.entry_invalid;
1570515705
15706 TypeTableEntry *type_entry = value->value.type;15706 ZigType *type_entry = value->value.type;
1570715707
15708 if (type_entry->id == TypeTableEntryIdOptional) {15708 if (type_entry->id == TypeTableEntryIdOptional) {
15709 if (instr_is_comptime(value)) {15709 if (instr_is_comptime(value)) {
...@@ -15729,17 +15729,17 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn...@@ -15729,17 +15729,17 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
15729 }15729 }
15730}15730}
1573115731
15732static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,15732static ZigType *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
15733 IrInstructionUnwrapOptional *unwrap_maybe_instruction)15733 IrInstructionUnwrapOptional *unwrap_maybe_instruction)
15734{15734{
15735 IrInstruction *value = unwrap_maybe_instruction->value->other;15735 IrInstruction *value = unwrap_maybe_instruction->value->other;
15736 if (type_is_invalid(value->value.type))15736 if (type_is_invalid(value->value.type))
15737 return ira->codegen->builtin_types.entry_invalid;15737 return ira->codegen->builtin_types.entry_invalid;
1573815738
15739 TypeTableEntry *ptr_type = value->value.type;15739 ZigType *ptr_type = value->value.type;
15740 assert(ptr_type->id == TypeTableEntryIdPointer);15740 assert(ptr_type->id == TypeTableEntryIdPointer);
1574115741
15742 TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;15742 ZigType *type_entry = ptr_type->data.pointer.child_type;
15743 if (type_is_invalid(type_entry)) {15743 if (type_is_invalid(type_entry)) {
15744 return ira->codegen->builtin_types.entry_invalid;15744 return ira->codegen->builtin_types.entry_invalid;
15745 } else if (type_entry->id != TypeTableEntryIdOptional) {15745 } else if (type_entry->id != TypeTableEntryIdOptional) {
...@@ -15747,8 +15747,8 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,...@@ -15747,8 +15747,8 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
15747 buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name)));15747 buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name)));
15748 return ira->codegen->builtin_types.entry_invalid;15748 return ira->codegen->builtin_types.entry_invalid;
15749 }15749 }
15750 TypeTableEntry *child_type = type_entry->data.maybe.child_type;15750 ZigType *child_type = type_entry->data.maybe.child_type;
15751 TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, child_type,15751 ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type,
15752 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,15752 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
15753 PtrLenSingle,15753 PtrLenSingle,
15754 get_abi_alignment(ira->codegen, child_type), 0, 0);15754 get_abi_alignment(ira->codegen, child_type), 0, 0);
...@@ -15783,12 +15783,12 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,...@@ -15783,12 +15783,12 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
15783 return result_type;15783 return result_type;
15784}15784}
1578515785
15786static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz_instruction) {15786static ZigType *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz_instruction) {
15787 IrInstruction *value = ctz_instruction->value->other;15787 IrInstruction *value = ctz_instruction->value->other;
15788 if (type_is_invalid(value->value.type)) {15788 if (type_is_invalid(value->value.type)) {
15789 return ira->codegen->builtin_types.entry_invalid;15789 return ira->codegen->builtin_types.entry_invalid;
15790 } else if (value->value.type->id == TypeTableEntryIdInt) {15790 } else if (value->value.type->id == TypeTableEntryIdInt) {
15791 TypeTableEntry *return_type = get_smallest_unsigned_int_type(ira->codegen,15791 ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen,
15792 value->value.type->data.integral.bit_count);15792 value->value.type->data.integral.bit_count);
15793 if (value->value.special != ConstValSpecialRuntime) {15793 if (value->value.special != ConstValSpecialRuntime) {
15794 size_t result = bigint_ctz(&value->value.data.x_bigint,15794 size_t result = bigint_ctz(&value->value.data.x_bigint,
...@@ -15807,12 +15807,12 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC...@@ -15807,12 +15807,12 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC
15807 }15807 }
15808}15808}
1580915809
15810static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz_instruction) {15810static ZigType *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz_instruction) {
15811 IrInstruction *value = clz_instruction->value->other;15811 IrInstruction *value = clz_instruction->value->other;
15812 if (type_is_invalid(value->value.type)) {15812 if (type_is_invalid(value->value.type)) {
15813 return ira->codegen->builtin_types.entry_invalid;15813 return ira->codegen->builtin_types.entry_invalid;
15814 } else if (value->value.type->id == TypeTableEntryIdInt) {15814 } else if (value->value.type->id == TypeTableEntryIdInt) {
15815 TypeTableEntry *return_type = get_smallest_unsigned_int_type(ira->codegen,15815 ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen,
15816 value->value.type->data.integral.bit_count);15816 value->value.type->data.integral.bit_count);
15817 if (value->value.special != ConstValSpecialRuntime) {15817 if (value->value.special != ConstValSpecialRuntime) {
15818 size_t result = bigint_clz(&value->value.data.x_bigint,15818 size_t result = bigint_clz(&value->value.data.x_bigint,
...@@ -15831,7 +15831,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC...@@ -15831,7 +15831,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC
15831 }15831 }
15832}15832}
1583315833
15834static TypeTableEntry *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) {15834static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) {
15835 IrInstruction *value = instruction->value->other;15835 IrInstruction *value = instruction->value->other;
15836 if (type_is_invalid(value->value.type))15836 if (type_is_invalid(value->value.type))
15837 return ira->codegen->builtin_types.entry_invalid;15837 return ira->codegen->builtin_types.entry_invalid;
...@@ -15895,7 +15895,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source...@@ -15895,7 +15895,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
15895 return ira->codegen->invalid_instruction;15895 return ira->codegen->invalid_instruction;
15896 }15896 }
1589715897
15898 TypeTableEntry *tag_type = value->value.type->data.unionation.tag_type;15898 ZigType *tag_type = value->value.type->data.unionation.tag_type;
15899 assert(tag_type->id == TypeTableEntryIdEnum);15899 assert(tag_type->id == TypeTableEntryIdEnum);
1590015900
15901 if (instr_is_comptime(value)) {15901 if (instr_is_comptime(value)) {
...@@ -15916,7 +15916,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source...@@ -15916,7 +15916,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source
15916 return result;15916 return result;
15917}15917}
1591815918
15919static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira,15919static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira,
15920 IrInstructionSwitchBr *switch_br_instruction)15920 IrInstructionSwitchBr *switch_br_instruction)
15921{15921{
15922 IrInstruction *target_value = switch_br_instruction->target_value->other;15922 IrInstruction *target_value = switch_br_instruction->target_value->other;
...@@ -16024,7 +16024,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira,...@@ -16024,7 +16024,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira,
16024 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);16024 return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
16025}16025}
1602616026
16027static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,16027static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira,
16028 IrInstructionSwitchTarget *switch_target_instruction)16028 IrInstructionSwitchTarget *switch_target_instruction)
16029{16029{
16030 Error err;16030 Error err;
...@@ -16034,7 +16034,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -16034,7 +16034,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1603416034
16035 if (target_value_ptr->value.type->id == TypeTableEntryIdMetaType) {16035 if (target_value_ptr->value.type->id == TypeTableEntryIdMetaType) {
16036 assert(instr_is_comptime(target_value_ptr));16036 assert(instr_is_comptime(target_value_ptr));
16037 TypeTableEntry *ptr_type = target_value_ptr->value.data.x_type;16037 ZigType *ptr_type = target_value_ptr->value.data.x_type;
16038 assert(ptr_type->id == TypeTableEntryIdPointer);16038 assert(ptr_type->id == TypeTableEntryIdPointer);
16039 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base);16039 ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base);
16040 out_val->type = ira->codegen->builtin_types.entry_type;16040 out_val->type = ira->codegen->builtin_types.entry_type;
...@@ -16047,7 +16047,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -16047,7 +16047,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
16047 return ira->codegen->builtin_types.entry_invalid;16047 return ira->codegen->builtin_types.entry_invalid;
16048 }16048 }
1604916049
16050 TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type;16050 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
16051 ConstExprValue *pointee_val = nullptr;16051 ConstExprValue *pointee_val = nullptr;
16052 if (instr_is_comptime(target_value_ptr)) {16052 if (instr_is_comptime(target_value_ptr)) {
16053 pointee_val = ir_const_ptr_pointee(ira, &target_value_ptr->value, target_value_ptr->source_node);16053 pointee_val = ir_const_ptr_pointee(ira, &target_value_ptr->value, target_value_ptr->source_node);
...@@ -16095,7 +16095,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -16095,7 +16095,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
16095 buf_sprintf("consider 'union(enum)' here"));16095 buf_sprintf("consider 'union(enum)' here"));
16096 return ira->codegen->builtin_types.entry_invalid;16096 return ira->codegen->builtin_types.entry_invalid;
16097 }16097 }
16098 TypeTableEntry *tag_type = target_type->data.unionation.tag_type;16098 ZigType *tag_type = target_type->data.unionation.tag_type;
16099 assert(tag_type != nullptr);16099 assert(tag_type != nullptr);
16100 assert(tag_type->id == TypeTableEntryIdEnum);16100 assert(tag_type->id == TypeTableEntryIdEnum);
16101 if (pointee_val) {16101 if (pointee_val) {
...@@ -16160,7 +16160,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -16160,7 +16160,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
16160 zig_unreachable();16160 zig_unreachable();
16161}16161}
1616216162
16163static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) {16163static ZigType *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) {
16164 IrInstruction *target_value_ptr = instruction->target_value_ptr->other;16164 IrInstruction *target_value_ptr = instruction->target_value_ptr->other;
16165 if (type_is_invalid(target_value_ptr->value.type))16165 if (type_is_invalid(target_value_ptr->value.type))
16166 return ira->codegen->builtin_types.entry_invalid;16166 return ira->codegen->builtin_types.entry_invalid;
...@@ -16170,7 +16170,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr...@@ -16170,7 +16170,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr
16170 return ira->codegen->builtin_types.entry_invalid;16170 return ira->codegen->builtin_types.entry_invalid;
1617116171
16172 assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer);16172 assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer);
16173 TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type;16173 ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type;
16174 if (target_type->id == TypeTableEntryIdUnion) {16174 if (target_type->id == TypeTableEntryIdUnion) {
16175 ConstExprValue *prong_val = ir_resolve_const(ira, prong_value, UndefBad);16175 ConstExprValue *prong_val = ir_resolve_const(ira, prong_value, UndefBad);
16176 if (!prong_val)16176 if (!prong_val)
...@@ -16205,14 +16205,14 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr...@@ -16205,14 +16205,14 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr
16205 }16205 }
16206}16206}
1620716207
16208static TypeTableEntry *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) {16208static ZigType *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) {
16209 IrInstruction *value = instruction->value->other;16209 IrInstruction *value = instruction->value->other;
16210 IrInstruction *new_instruction = ir_analyze_union_tag(ira, &instruction->base, value);16210 IrInstruction *new_instruction = ir_analyze_union_tag(ira, &instruction->base, value);
16211 ir_link_new_instruction(new_instruction, &instruction->base);16211 ir_link_new_instruction(new_instruction, &instruction->base);
16212 return new_instruction->value.type;16212 return new_instruction->value.type;
16213}16213}
1621416214
16215static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) {16215static ZigType *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) {
16216 IrInstruction *name_value = import_instruction->name->other;16216 IrInstruction *name_value = import_instruction->name->other;
16217 Buf *import_target_str = ir_resolve_str(ira, name_value);16217 Buf *import_target_str = ir_resolve_str(ira, name_value);
16218 if (!import_target_str)16218 if (!import_target_str)
...@@ -16278,11 +16278,11 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi...@@ -16278,11 +16278,11 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
1627816278
16279}16279}
1628016280
16281static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,16281static ZigType *ir_analyze_instruction_array_len(IrAnalyze *ira,
16282 IrInstructionArrayLen *array_len_instruction)16282 IrInstructionArrayLen *array_len_instruction)
16283{16283{
16284 IrInstruction *array_value = array_len_instruction->array_value->other;16284 IrInstruction *array_value = array_len_instruction->array_value->other;
16285 TypeTableEntry *type_entry = array_value->value.type;16285 ZigType *type_entry = array_value->value.type;
16286 if (type_is_invalid(type_entry)) {16286 if (type_is_invalid(type_entry)) {
16287 return ira->codegen->builtin_types.entry_invalid;16287 return ira->codegen->builtin_types.entry_invalid;
16288 } else if (type_entry->id == TypeTableEntryIdArray) {16288 } else if (type_entry->id == TypeTableEntryIdArray) {
...@@ -16309,13 +16309,13 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,...@@ -16309,13 +16309,13 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira,
16309 }16309 }
16310}16310}
1631116311
16312static TypeTableEntry *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) {16312static ZigType *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) {
16313 IrInstruction *value = ref_instruction->value->other;16313 IrInstruction *value = ref_instruction->value->other;
16314 return ir_analyze_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile);16314 return ir_analyze_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile);
16315}16315}
1631616316
16317static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,16317static ZigType *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,
16318 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)16318 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
16319{16319{
16320 Error err;16320 Error err;
16321 assert(container_type->id == TypeTableEntryIdUnion);16321 assert(container_type->id == TypeTableEntryIdUnion);
...@@ -16380,8 +16380,8 @@ static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, Ir...@@ -16380,8 +16380,8 @@ static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, Ir
16380 return container_type;16380 return container_type;
16381}16381}
1638216382
16383static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,16383static ZigType *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,
16384 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)16384 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)
16385{16385{
16386 Error err;16386 Error err;
16387 if (container_type->id == TypeTableEntryIdUnion) {16387 if (container_type->id == TypeTableEntryIdUnion) {
...@@ -16500,7 +16500,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru...@@ -16500,7 +16500,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
16500 return container_type;16500 return container_type;
16501}16501}
1650216502
16503static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira,16503static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
16504 IrInstructionContainerInitList *instruction)16504 IrInstructionContainerInitList *instruction)
16505{16505{
16506 IrInstruction *container_type_value = instruction->container_type->other;16506 IrInstruction *container_type_value = instruction->container_type->other;
...@@ -16509,7 +16509,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira...@@ -16509,7 +16509,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
1650916509
16510 size_t elem_count = instruction->item_count;16510 size_t elem_count = instruction->item_count;
16511 if (container_type_value->value.type->id == TypeTableEntryIdMetaType) {16511 if (container_type_value->value.type->id == TypeTableEntryIdMetaType) {
16512 TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);16512 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16513 if (type_is_invalid(container_type))16513 if (type_is_invalid(container_type))
16514 return ira->codegen->builtin_types.entry_invalid;16514 return ira->codegen->builtin_types.entry_invalid;
1651516515
...@@ -16518,11 +16518,11 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira...@@ -16518,11 +16518,11 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
16518 0, nullptr);16518 0, nullptr);
16519 } else if (is_slice(container_type) || container_type->id == TypeTableEntryIdArray) {16519 } else if (is_slice(container_type) || container_type->id == TypeTableEntryIdArray) {
16520 // array is same as slice init but we make a compile error if the length is wrong16520 // array is same as slice init but we make a compile error if the length is wrong
16521 TypeTableEntry *child_type;16521 ZigType *child_type;
16522 if (container_type->id == TypeTableEntryIdArray) {16522 if (container_type->id == TypeTableEntryIdArray) {
16523 child_type = container_type->data.array.child_type;16523 child_type = container_type->data.array.child_type;
16524 if (container_type->data.array.len != elem_count) {16524 if (container_type->data.array.len != elem_count) {
16525 TypeTableEntry *literal_type = get_array_type(ira->codegen, child_type, elem_count);16525 ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count);
1652616526
16527 ir_add_error(ira, &instruction->base,16527 ir_add_error(ira, &instruction->base,
16528 buf_sprintf("expected %s literal, found %s literal",16528 buf_sprintf("expected %s literal, found %s literal",
...@@ -16530,12 +16530,12 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira...@@ -16530,12 +16530,12 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
16530 return ira->codegen->builtin_types.entry_invalid;16530 return ira->codegen->builtin_types.entry_invalid;
16531 }16531 }
16532 } else {16532 } else {
16533 TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry;16533 ZigType *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry;
16534 assert(pointer_type->id == TypeTableEntryIdPointer);16534 assert(pointer_type->id == TypeTableEntryIdPointer);
16535 child_type = pointer_type->data.pointer.child_type;16535 child_type = pointer_type->data.pointer.child_type;
16536 }16536 }
1653716537
16538 TypeTableEntry *fixed_size_array_type = get_array_type(ira->codegen, child_type, elem_count);16538 ZigType *fixed_size_array_type = get_array_type(ira->codegen, child_type, elem_count);
1653916539
16540 ConstExprValue const_val = {};16540 ConstExprValue const_val = {};
16541 const_val.special = ConstValSpecialStatic;16541 const_val.special = ConstValSpecialStatic;
...@@ -16618,9 +16618,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira...@@ -16618,9 +16618,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira
16618 }16618 }
16619}16619}
1662016620
16621static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {16621static ZigType *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
16622 IrInstruction *container_type_value = instruction->container_type->other;16622 IrInstruction *container_type_value = instruction->container_type->other;
16623 TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);16623 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16624 if (type_is_invalid(container_type))16624 if (type_is_invalid(container_type))
16625 return ira->codegen->builtin_types.entry_invalid;16625 return ira->codegen->builtin_types.entry_invalid;
1662616626
...@@ -16628,10 +16628,10 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i...@@ -16628,10 +16628,10 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i
16628 instruction->field_count, instruction->fields);16628 instruction->field_count, instruction->fields);
16629}16629}
1663016630
16631static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction,16631static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction,
16632 IrInstruction *target_type_value, bool is_max)16632 IrInstruction *target_type_value, bool is_max)
16633{16633{
16634 TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value);16634 ZigType *target_type = ir_resolve_type(ira, target_type_value);
16635 if (type_is_invalid(target_type))16635 if (type_is_invalid(target_type))
16636 return ira->codegen->builtin_types.entry_invalid;16636 return ira->codegen->builtin_types.entry_invalid;
16637 switch (target_type->id) {16637 switch (target_type->id) {
...@@ -16684,19 +16684,19 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_...@@ -16684,19 +16684,19 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_
16684 zig_unreachable();16684 zig_unreachable();
16685}16685}
1668616686
16687static TypeTableEntry *ir_analyze_instruction_min_value(IrAnalyze *ira,16687static ZigType *ir_analyze_instruction_min_value(IrAnalyze *ira,
16688 IrInstructionMinValue *instruction)16688 IrInstructionMinValue *instruction)
16689{16689{
16690 return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, false);16690 return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, false);
16691}16691}
1669216692
16693static TypeTableEntry *ir_analyze_instruction_max_value(IrAnalyze *ira,16693static ZigType *ir_analyze_instruction_max_value(IrAnalyze *ira,
16694 IrInstructionMaxValue *instruction)16694 IrInstructionMaxValue *instruction)
16695{16695{
16696 return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, true);16696 return ir_analyze_min_max(ira, &instruction->base, instruction->value->other, true);
16697}16697}
1669816698
16699static TypeTableEntry *ir_analyze_instruction_compile_err(IrAnalyze *ira,16699static ZigType *ir_analyze_instruction_compile_err(IrAnalyze *ira,
16700 IrInstructionCompileErr *instruction)16700 IrInstructionCompileErr *instruction)
16701{16701{
16702 IrInstruction *msg_value = instruction->msg->other;16702 IrInstruction *msg_value = instruction->msg->other;
...@@ -16720,7 +16720,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_err(IrAnalyze *ira,...@@ -16720,7 +16720,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_err(IrAnalyze *ira,
16720 return ira->codegen->builtin_types.entry_invalid;16720 return ira->codegen->builtin_types.entry_invalid;
16721}16721}
1672216722
16723static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) {16723static ZigType *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) {
16724 Buf buf = BUF_INIT;16724 Buf buf = BUF_INIT;
16725 fprintf(stderr, "| ");16725 fprintf(stderr, "| ");
16726 for (size_t i = 0; i < instruction->msg_count; i += 1) {16726 for (size_t i = 0; i < instruction->msg_count; i += 1) {
...@@ -16740,7 +16740,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst...@@ -16740,7 +16740,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst
16740 return ira->codegen->builtin_types.entry_void;16740 return ira->codegen->builtin_types.entry_void;
16741}16741}
1674216742
16743static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) {16743static ZigType *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) {
16744 IrInstruction *value = instruction->value->other;16744 IrInstruction *value = instruction->value->other;
16745 if (type_is_invalid(value->value.type))16745 if (type_is_invalid(value->value.type))
16746 return ira->codegen->builtin_types.entry_invalid;16746 return ira->codegen->builtin_types.entry_invalid;
...@@ -16749,9 +16749,9 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc...@@ -16749,9 +16749,9 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc
16749 if (type_is_invalid(casted_value->value.type))16749 if (type_is_invalid(casted_value->value.type))
16750 return ira->codegen->builtin_types.entry_invalid;16750 return ira->codegen->builtin_types.entry_invalid;
1675116751
16752 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,16752 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
16753 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);16753 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
16754 TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type);16754 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
16755 if (casted_value->value.special == ConstValSpecialStatic) {16755 if (casted_value->value.special == ConstValSpecialStatic) {
16756 ErrorTableEntry *err = casted_value->value.data.x_err_set;16756 ErrorTableEntry *err = casted_value->value.data.x_err_set;
16757 if (!err->cached_error_name_val) {16757 if (!err->cached_error_name_val) {
...@@ -16768,7 +16768,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc...@@ -16768,7 +16768,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc
16768 return str_type;16768 return str_type;
16769}16769}
1677016770
16771static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) {16771static ZigType *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) {
16772 Error err;16772 Error err;
16773 IrInstruction *target = instruction->target->other;16773 IrInstruction *target = instruction->target->other;
16774 if (type_is_invalid(target->value.type))16774 if (type_is_invalid(target->value.type))
...@@ -16789,7 +16789,7 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn...@@ -16789,7 +16789,7 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn
16789 IrInstruction *result = ir_build_tag_name(&ira->new_irb, instruction->base.scope,16789 IrInstruction *result = ir_build_tag_name(&ira->new_irb, instruction->base.scope,
16790 instruction->base.source_node, target);16790 instruction->base.source_node, target);
16791 ir_link_new_instruction(result, &instruction->base);16791 ir_link_new_instruction(result, &instruction->base);
16792 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(16792 ZigType *u8_ptr_type = get_pointer_to_type_extra(
16793 ira->codegen, ira->codegen->builtin_types.entry_u8,16793 ira->codegen, ira->codegen->builtin_types.entry_u8,
16794 true, false, PtrLenUnknown,16794 true, false, PtrLenUnknown,
16795 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),16795 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),
...@@ -16798,12 +16798,12 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn...@@ -16798,12 +16798,12 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIn
16798 return result->value.type;16798 return result->value.type;
16799}16799}
1680016800
16801static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,16801static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16802 IrInstructionFieldParentPtr *instruction)16802 IrInstructionFieldParentPtr *instruction)
16803{16803{
16804 Error err;16804 Error err;
16805 IrInstruction *type_value = instruction->type_value->other;16805 IrInstruction *type_value = instruction->type_value->other;
16806 TypeTableEntry *container_type = ir_resolve_type(ira, type_value);16806 ZigType *container_type = ir_resolve_type(ira, type_value);
16807 if (type_is_invalid(container_type))16807 if (type_is_invalid(container_type))
16808 return ira->codegen->builtin_types.entry_invalid;16808 return ira->codegen->builtin_types.entry_invalid;
1680916809
...@@ -16843,7 +16843,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16843,7 +16843,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16843 uint32_t field_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, field->type_entry);16843 uint32_t field_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, field->type_entry);
16844 uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type);16844 uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type);
1684516845
16846 TypeTableEntry *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,16846 ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry,
16847 field_ptr->value.type->data.pointer.is_const,16847 field_ptr->value.type->data.pointer.is_const,
16848 field_ptr->value.type->data.pointer.is_volatile,16848 field_ptr->value.type->data.pointer.is_volatile,
16849 PtrLenSingle,16849 PtrLenSingle,
...@@ -16852,7 +16852,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16852,7 +16852,7 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16852 if (type_is_invalid(casted_field_ptr->value.type))16852 if (type_is_invalid(casted_field_ptr->value.type))
16853 return ira->codegen->builtin_types.entry_invalid;16853 return ira->codegen->builtin_types.entry_invalid;
1685416854
16855 TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, container_type,16855 ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type,
16856 casted_field_ptr->value.type->data.pointer.is_const,16856 casted_field_ptr->value.type->data.pointer.is_const,
16857 casted_field_ptr->value.type->data.pointer.is_volatile,16857 casted_field_ptr->value.type->data.pointer.is_volatile,
16858 PtrLenSingle,16858 PtrLenSingle,
...@@ -16891,12 +16891,12 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16891,12 +16891,12 @@ static TypeTableEntry *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16891 return result_type;16891 return result_type;
16892}16892}
1689316893
16894static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,16894static ZigType *ir_analyze_instruction_offset_of(IrAnalyze *ira,
16895 IrInstructionOffsetOf *instruction)16895 IrInstructionOffsetOf *instruction)
16896{16896{
16897 Error err;16897 Error err;
16898 IrInstruction *type_value = instruction->type_value->other;16898 IrInstruction *type_value = instruction->type_value->other;
16899 TypeTableEntry *container_type = ir_resolve_type(ira, type_value);16899 ZigType *container_type = ir_resolve_type(ira, type_value);
16900 if (type_is_invalid(container_type))16900 if (type_is_invalid(container_type))
16901 return ira->codegen->builtin_types.entry_invalid;16901 return ira->codegen->builtin_types.entry_invalid;
1690216902
...@@ -16934,7 +16934,7 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,...@@ -16934,7 +16934,7 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
16934 return ira->codegen->builtin_types.entry_num_lit_int;16934 return ira->codegen->builtin_types.entry_num_lit_int;
16935}16935}
1693616936
16937static void ensure_field_index(TypeTableEntry *type, const char *field_name, size_t index)16937static void ensure_field_index(ZigType *type, const char *field_name, size_t index)
16938{16938{
16939 Buf *field_name_buf;16939 Buf *field_name_buf;
1694016940
...@@ -16945,10 +16945,10 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz...@@ -16945,10 +16945,10 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz
16945 (buf_deinit(field_name_buf), true));16945 (buf_deinit(field_name_buf), true));
16946}16946}
1694716947
16948static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, TypeTableEntry *root) {16948static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) {
16949 Error err;16949 Error err;
16950 static ConstExprValue *type_info_var = nullptr;16950 static ConstExprValue *type_info_var = nullptr;
16951 static TypeTableEntry *type_info_type = nullptr;16951 static ZigType *type_info_type = nullptr;
16952 if (type_info_var == nullptr) {16952 if (type_info_var == nullptr) {
16953 type_info_var = get_builtin_value(ira->codegen, "TypeInfo");16953 type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
16954 assert(type_info_var->type->id == TypeTableEntryIdMetaType);16954 assert(type_info_var->type->id == TypeTableEntryIdMetaType);
...@@ -16963,7 +16963,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na...@@ -16963,7 +16963,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
16963 else if (type_name == nullptr)16963 else if (type_name == nullptr)
16964 return root;16964 return root;
1696516965
16966 TypeTableEntry *root_type = (root == nullptr) ? type_info_type : root;16966 ZigType *root_type = (root == nullptr) ? type_info_type : root;
1696716967
16968 ScopeDecls *type_info_scope = get_container_scope(root_type);16968 ScopeDecls *type_info_scope = get_container_scope(root_type);
16969 assert(type_info_scope != nullptr);16969 assert(type_info_scope != nullptr);
...@@ -16986,7 +16986,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na...@@ -16986,7 +16986,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
1698616986
16987static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope) {16987static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope) {
16988 Error err;16988 Error err;
16989 TypeTableEntry *type_info_definition_type = ir_type_info_get_type(ira, "Definition", nullptr);16989 ZigType *type_info_definition_type = ir_type_info_get_type(ira, "Definition", nullptr);
16990 if ((err = ensure_complete_type(ira->codegen, type_info_definition_type)))16990 if ((err = ensure_complete_type(ira->codegen, type_info_definition_type)))
16991 return err;16991 return err;
1699216992
...@@ -16994,15 +16994,15 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco...@@ -16994,15 +16994,15 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
16994 ensure_field_index(type_info_definition_type, "is_pub", 1);16994 ensure_field_index(type_info_definition_type, "is_pub", 1);
16995 ensure_field_index(type_info_definition_type, "data", 2);16995 ensure_field_index(type_info_definition_type, "data", 2);
1699616996
16997 TypeTableEntry *type_info_definition_data_type = ir_type_info_get_type(ira, "Data", type_info_definition_type);16997 ZigType *type_info_definition_data_type = ir_type_info_get_type(ira, "Data", type_info_definition_type);
16998 if ((err = ensure_complete_type(ira->codegen, type_info_definition_data_type)))16998 if ((err = ensure_complete_type(ira->codegen, type_info_definition_data_type)))
16999 return err;16999 return err;
1700017000
17001 TypeTableEntry *type_info_fn_def_type = ir_type_info_get_type(ira, "FnDef", type_info_definition_data_type);17001 ZigType *type_info_fn_def_type = ir_type_info_get_type(ira, "FnDef", type_info_definition_data_type);
17002 if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_type)))17002 if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_type)))
17003 return err;17003 return err;
1700417004
17005 TypeTableEntry *type_info_fn_def_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_def_type);17005 ZigType *type_info_fn_def_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_def_type);
17006 if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_inline_type)))17006 if ((err = ensure_complete_type(ira->codegen, type_info_fn_def_inline_type)))
17007 return err;17007 return err;
1700817008
...@@ -17153,7 +17153,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco...@@ -17153,7 +17153,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
17153 // lib_name: ?[]const u817153 // lib_name: ?[]const u8
17154 ensure_field_index(fn_def_val->type, "lib_name", 6);17154 ensure_field_index(fn_def_val->type, "lib_name", 6);
17155 fn_def_fields[6].special = ConstValSpecialStatic;17155 fn_def_fields[6].special = ConstValSpecialStatic;
17156 TypeTableEntry *u8_ptr = get_pointer_to_type_extra(17156 ZigType *u8_ptr = get_pointer_to_type_extra(
17157 ira->codegen, ira->codegen->builtin_types.entry_u8,17157 ira->codegen, ira->codegen->builtin_types.entry_u8,
17158 true, false, PtrLenUnknown,17158 true, false, PtrLenUnknown,
17159 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),17159 get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8),
...@@ -17205,7 +17205,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco...@@ -17205,7 +17205,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
17205 }17205 }
17206 case TldIdContainer:17206 case TldIdContainer:
17207 {17207 {
17208 TypeTableEntry *type_entry = ((TldContainer *)curr_entry->value)->type_entry;17208 ZigType *type_entry = ((TldContainer *)curr_entry->value)->type_entry;
17209 if ((err = ensure_complete_type(ira->codegen, type_entry)))17209 if ((err = ensure_complete_type(ira->codegen, type_entry)))
17210 return ErrorSemanticAnalyzeFail;17210 return ErrorSemanticAnalyzeFail;
1721117211
...@@ -17232,8 +17232,8 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco...@@ -17232,8 +17232,8 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco
17232 return ErrorNone;17232 return ErrorNone;
17233}17233}
1723417234
17235static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry *ptr_type_entry) {17235static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_entry) {
17236 TypeTableEntry *attrs_type;17236 ZigType *attrs_type;
17237 uint32_t size_enum_index;17237 uint32_t size_enum_index;
17238 if (is_slice(ptr_type_entry)) {17238 if (is_slice(ptr_type_entry)) {
17239 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;17239 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;
...@@ -17245,7 +17245,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry...@@ -17245,7 +17245,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
17245 zig_unreachable();17245 zig_unreachable();
17246 }17246 }
1724717247
17248 TypeTableEntry *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);17248 ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
17249 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_type));17249 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_type));
1725017250
17251 ConstExprValue *result = create_const_vals(1);17251 ConstExprValue *result = create_const_vals(1);
...@@ -17257,7 +17257,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry...@@ -17257,7 +17257,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
1725717257
17258 // size: Size17258 // size: Size
17259 ensure_field_index(result->type, "size", 0);17259 ensure_field_index(result->type, "size", 0);
17260 TypeTableEntry *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);17260 ZigType *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
17261 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_size_type));17261 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_size_type));
17262 fields[0].special = ConstValSpecialStatic;17262 fields[0].special = ConstValSpecialStatic;
17263 fields[0].type = type_info_pointer_size_type;17263 fields[0].type = type_info_pointer_size_type;
...@@ -17288,7 +17288,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry...@@ -17288,7 +17288,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry
17288};17288};
1728917289
17290static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field,17290static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, TypeEnumField *enum_field,
17291 TypeTableEntry *type_info_enum_field_type)17291 ZigType *type_info_enum_field_type)
17292{17292{
17293 enum_field_val->special = ConstValSpecialStatic;17293 enum_field_val->special = ConstValSpecialStatic;
17294 enum_field_val->type = type_info_enum_field_type;17294 enum_field_val->type = type_info_enum_field_type;
...@@ -17305,7 +17305,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val,...@@ -17305,7 +17305,7 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val,
17305 enum_field_val->data.x_struct.fields = inner_fields;17305 enum_field_val->data.x_struct.fields = inner_fields;
17306}17306}
1730717307
17308static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry, ConstExprValue **out) {17308static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstExprValue **out) {
17309 Error err;17309 Error err;
17310 assert(type_entry != nullptr);17310 assert(type_entry != nullptr);
17311 assert(!type_is_invalid(type_entry));17311 assert(!type_is_invalid(type_entry));
...@@ -17478,7 +17478,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17478,7 +17478,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17478 // fields: []TypeInfo.EnumField17478 // fields: []TypeInfo.EnumField
17479 ensure_field_index(result->type, "fields", 2);17479 ensure_field_index(result->type, "fields", 2);
1748017480
17481 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);17481 ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
17482 uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;17482 uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;
1748317483
17484 ConstExprValue *enum_field_array = create_const_vals(1);17484 ConstExprValue *enum_field_array = create_const_vals(1);
...@@ -17518,7 +17518,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17518,7 +17518,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17518 // errors: []TypeInfo.Error17518 // errors: []TypeInfo.Error
17519 ensure_field_index(result->type, "errors", 0);17519 ensure_field_index(result->type, "errors", 0);
1752017520
17521 TypeTableEntry *type_info_error_type = ir_type_info_get_type(ira, "Error", nullptr);17521 ZigType *type_info_error_type = ir_type_info_get_type(ira, "Error", nullptr);
17522 uint32_t error_count = type_entry->data.error_set.err_count;17522 uint32_t error_count = type_entry->data.error_set.err_count;
17523 ConstExprValue *error_array = create_const_vals(1);17523 ConstExprValue *error_array = create_const_vals(1);
17524 error_array->special = ConstValSpecialStatic;17524 error_array->special = ConstValSpecialStatic;
...@@ -17612,7 +17612,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17612,7 +17612,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17612 // fields: []TypeInfo.UnionField17612 // fields: []TypeInfo.UnionField
17613 ensure_field_index(result->type, "fields", 2);17613 ensure_field_index(result->type, "fields", 2);
1761417614
17615 TypeTableEntry *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);17615 ZigType *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);
17616 uint32_t union_field_count = type_entry->data.unionation.src_field_count;17616 uint32_t union_field_count = type_entry->data.unionation.src_field_count;
1761717617
17618 ConstExprValue *union_field_array = create_const_vals(1);17618 ConstExprValue *union_field_array = create_const_vals(1);
...@@ -17624,7 +17624,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17624,7 +17624,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
1762417624
17625 init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);17625 init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);
1762617626
17627 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);17627 ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
1762817628
17629 for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {17629 for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {
17630 TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index];17630 TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index];
...@@ -17685,7 +17685,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17685,7 +17685,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17685 // fields: []TypeInfo.StructField17685 // fields: []TypeInfo.StructField
17686 ensure_field_index(result->type, "fields", 1);17686 ensure_field_index(result->type, "fields", 1);
1768717687
17688 TypeTableEntry *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);17688 ZigType *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);
17689 uint32_t struct_field_count = type_entry->data.structure.src_field_count;17689 uint32_t struct_field_count = type_entry->data.structure.src_field_count;
1769017690
17691 ConstExprValue *struct_field_array = create_const_vals(1);17691 ConstExprValue *struct_field_array = create_const_vals(1);
...@@ -17790,7 +17790,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17790,7 +17790,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17790 fields[4].data.x_optional = async_alloc_type;17790 fields[4].data.x_optional = async_alloc_type;
17791 }17791 }
17792 // args: []TypeInfo.FnArg17792 // args: []TypeInfo.FnArg
17793 TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);17793 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
17794 size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -17794 size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -
17795 (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);17795 (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);
1779617796
...@@ -17844,7 +17844,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17844,7 +17844,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17844 }17844 }
17845 case TypeTableEntryIdBoundFn:17845 case TypeTableEntryIdBoundFn:
17846 {17846 {
17847 TypeTableEntry *fn_type = type_entry->data.bound_fn.fn_type;17847 ZigType *fn_type = type_entry->data.bound_fn.fn_type;
17848 assert(fn_type->id == TypeTableEntryIdFn);17848 assert(fn_type->id == TypeTableEntryIdFn);
17849 if ((err = ir_make_type_info_value(ira, fn_type, &result)))17849 if ((err = ir_make_type_info_value(ira, fn_type, &result)))
17850 return err;17850 return err;
...@@ -17859,16 +17859,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,...@@ -17859,16 +17859,16 @@ static Error ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry,
17859 return ErrorNone;17859 return ErrorNone;
17860}17860}
1786117861
17862static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,17862static ZigType *ir_analyze_instruction_type_info(IrAnalyze *ira,
17863 IrInstructionTypeInfo *instruction)17863 IrInstructionTypeInfo *instruction)
17864{17864{
17865 Error err;17865 Error err;
17866 IrInstruction *type_value = instruction->type_value->other;17866 IrInstruction *type_value = instruction->type_value->other;
17867 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);17867 ZigType *type_entry = ir_resolve_type(ira, type_value);
17868 if (type_is_invalid(type_entry))17868 if (type_is_invalid(type_entry))
17869 return ira->codegen->builtin_types.entry_invalid;17869 return ira->codegen->builtin_types.entry_invalid;
1787017870
17871 TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr, nullptr);17871 ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr);
1787217872
17873 ConstExprValue *payload;17873 ConstExprValue *payload;
17874 if ((err = ir_make_type_info_value(ira, type_entry, &payload)))17874 if ((err = ir_make_type_info_value(ira, type_entry, &payload)))
...@@ -17888,24 +17888,24 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -17888,24 +17888,24 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
17888 return result_type;17888 return result_type;
17889}17889}
1789017890
17891static TypeTableEntry *ir_analyze_instruction_type_id(IrAnalyze *ira,17891static ZigType *ir_analyze_instruction_type_id(IrAnalyze *ira,
17892 IrInstructionTypeId *instruction)17892 IrInstructionTypeId *instruction)
17893{17893{
17894 IrInstruction *type_value = instruction->type_value->other;17894 IrInstruction *type_value = instruction->type_value->other;
17895 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);17895 ZigType *type_entry = ir_resolve_type(ira, type_value);
17896 if (type_is_invalid(type_entry))17896 if (type_is_invalid(type_entry))
17897 return ira->codegen->builtin_types.entry_invalid;17897 return ira->codegen->builtin_types.entry_invalid;
1789817898
17899 ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId");17899 ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId");
17900 assert(var_value->type->id == TypeTableEntryIdMetaType);17900 assert(var_value->type->id == TypeTableEntryIdMetaType);
17901 TypeTableEntry *result_type = var_value->data.x_type;17901 ZigType *result_type = var_value->data.x_type;
1790217902
17903 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);17903 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
17904 bigint_init_unsigned(&out_val->data.x_enum_tag, type_id_index(type_entry));17904 bigint_init_unsigned(&out_val->data.x_enum_tag, type_id_index(type_entry));
17905 return result_type;17905 return result_type;
17906}17906}
1790717907
17908static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,17908static ZigType *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
17909 IrInstructionSetEvalBranchQuota *instruction)17909 IrInstructionSetEvalBranchQuota *instruction)
17910{17910{
17911 if (ira->new_irb.exec->parent_exec != nullptr && !ira->new_irb.exec->is_generic_instantiation) {17911 if (ira->new_irb.exec->parent_exec != nullptr && !ira->new_irb.exec->is_generic_instantiation) {
...@@ -17926,9 +17926,9 @@ static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *i...@@ -17926,9 +17926,9 @@ static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *i
17926 return ira->codegen->builtin_types.entry_void;17926 return ira->codegen->builtin_types.entry_void;
17927}17927}
1792817928
17929static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {17929static ZigType *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
17930 IrInstruction *type_value = instruction->type_value->other;17930 IrInstruction *type_value = instruction->type_value->other;
17931 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);17931 ZigType *type_entry = ir_resolve_type(ira, type_value);
17932 if (type_is_invalid(type_entry))17932 if (type_is_invalid(type_entry))
17933 return ira->codegen->builtin_types.entry_invalid;17933 return ira->codegen->builtin_types.entry_invalid;
1793417934
...@@ -17940,7 +17940,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru...@@ -17940,7 +17940,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru
17940 return out_val->type;17940 return out_val->type;
17941}17941}
1794217942
17943static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) {17943static ZigType *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) {
17944 AstNode *node = instruction->base.source_node;17944 AstNode *node = instruction->base.source_node;
17945 assert(node->type == NodeTypeFnCallExpr);17945 assert(node->type == NodeTypeFnCallExpr);
17946 AstNode *block_node = node->data.fn_call_expr.params.at(0);17946 AstNode *block_node = node->data.fn_call_expr.params.at(0);
...@@ -17948,7 +17948,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc...@@ -17948,7 +17948,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
17948 ScopeCImport *cimport_scope = create_cimport_scope(node, instruction->base.scope);17948 ScopeCImport *cimport_scope = create_cimport_scope(node, instruction->base.scope);
1794917949
17950 // Execute the C import block like an inline function17950 // Execute the C import block like an inline function
17951 TypeTableEntry *void_type = ira->codegen->builtin_types.entry_void;17951 ZigType *void_type = ira->codegen->builtin_types.entry_void;
17952 IrInstruction *result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type,17952 IrInstruction *result = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, void_type,
17953 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,17953 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,
17954 &cimport_scope->buf, block_node, nullptr, nullptr);17954 &cimport_scope->buf, block_node, nullptr, nullptr);
...@@ -17999,7 +17999,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc...@@ -17999,7 +17999,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc
17999 return ira->codegen->builtin_types.entry_namespace;17999 return ira->codegen->builtin_types.entry_namespace;
18000}18000}
1800118001
18002static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) {18002static ZigType *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) {
18003 IrInstruction *name_value = instruction->name->other;18003 IrInstruction *name_value = instruction->name->other;
18004 if (type_is_invalid(name_value->value.type))18004 if (type_is_invalid(name_value->value.type))
18005 return ira->codegen->builtin_types.entry_invalid;18005 return ira->codegen->builtin_types.entry_invalid;
...@@ -18018,7 +18018,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru...@@ -18018,7 +18018,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru
18018 return ira->codegen->builtin_types.entry_void;18018 return ira->codegen->builtin_types.entry_void;
18019}18019}
1802018020
18021static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) {18021static ZigType *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) {
18022 IrInstruction *name = instruction->name->other;18022 IrInstruction *name = instruction->name->other;
18023 if (type_is_invalid(name->value.type))18023 if (type_is_invalid(name->value.type))
18024 return ira->codegen->builtin_types.entry_invalid;18024 return ira->codegen->builtin_types.entry_invalid;
...@@ -18045,7 +18045,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc...@@ -18045,7 +18045,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc
18045 return ira->codegen->builtin_types.entry_void;18045 return ira->codegen->builtin_types.entry_void;
18046}18046}
1804718047
18048static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) {18048static ZigType *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) {
18049 IrInstruction *name = instruction->name->other;18049 IrInstruction *name = instruction->name->other;
18050 if (type_is_invalid(name->value.type))18050 if (type_is_invalid(name->value.type))
18051 return ira->codegen->builtin_types.entry_invalid;18051 return ira->codegen->builtin_types.entry_invalid;
...@@ -18064,7 +18064,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct...@@ -18064,7 +18064,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct
18064 return ira->codegen->builtin_types.entry_void;18064 return ira->codegen->builtin_types.entry_void;
18065}18065}
1806618066
18067static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) {18067static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) {
18068 IrInstruction *name = instruction->name->other;18068 IrInstruction *name = instruction->name->other;
18069 if (type_is_invalid(name->value.type))18069 if (type_is_invalid(name->value.type))
18070 return ira->codegen->builtin_types.entry_invalid;18070 return ira->codegen->builtin_types.entry_invalid;
...@@ -18106,8 +18106,8 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr...@@ -18106,8 +18106,8 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
18106 return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(file_contents));18106 return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(file_contents));
18107}18107}
1810818108
18109static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) {18109static ZigType *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchg *instruction) {
18110 TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->other);18110 ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->other);
18111 if (type_is_invalid(operand_type))18111 if (type_is_invalid(operand_type))
18112 return ira->codegen->builtin_types.entry_invalid;18112 return ira->codegen->builtin_types.entry_invalid;
1811318113
...@@ -18116,7 +18116,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct...@@ -18116,7 +18116,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct
18116 return ira->codegen->builtin_types.entry_invalid;18116 return ira->codegen->builtin_types.entry_invalid;
1811718117
18118 // TODO let this be volatile18118 // TODO let this be volatile
18119 TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);18119 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
18120 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);18120 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type);
18121 if (type_is_invalid(casted_ptr->value.type))18121 if (type_is_invalid(casted_ptr->value.type))
18122 return ira->codegen->builtin_types.entry_invalid;18122 return ira->codegen->builtin_types.entry_invalid;
...@@ -18187,7 +18187,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct...@@ -18187,7 +18187,7 @@ static TypeTableEntry *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstruct
18187 return result->value.type;18187 return result->value.type;
18188}18188}
1818918189
18190static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) {18190static ZigType *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) {
18191 IrInstruction *order_value = instruction->order_value->other;18191 IrInstruction *order_value = instruction->order_value->other;
18192 if (type_is_invalid(order_value->value.type))18192 if (type_is_invalid(order_value->value.type))
18193 return ira->codegen->builtin_types.entry_invalid;18193 return ira->codegen->builtin_types.entry_invalid;
...@@ -18200,9 +18200,9 @@ static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructio...@@ -18200,9 +18200,9 @@ static TypeTableEntry *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructio
18200 return ira->codegen->builtin_types.entry_void;18200 return ira->codegen->builtin_types.entry_void;
18201}18201}
1820218202
18203static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {18203static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
18204 IrInstruction *dest_type_value = instruction->dest_type->other;18204 IrInstruction *dest_type_value = instruction->dest_type->other;
18205 TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);18205 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
18206 if (type_is_invalid(dest_type))18206 if (type_is_invalid(dest_type))
18207 return ira->codegen->builtin_types.entry_invalid;18207 return ira->codegen->builtin_types.entry_invalid;
1820818208
...@@ -18214,7 +18214,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc...@@ -18214,7 +18214,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
18214 }18214 }
1821518215
18216 IrInstruction *target = instruction->target->other;18216 IrInstruction *target = instruction->target->other;
18217 TypeTableEntry *src_type = target->value.type;18217 ZigType *src_type = target->value.type;
18218 if (type_is_invalid(src_type))18218 if (type_is_invalid(src_type))
18219 return ira->codegen->builtin_types.entry_invalid;18219 return ira->codegen->builtin_types.entry_invalid;
1822018220
...@@ -18248,8 +18248,8 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc...@@ -18248,8 +18248,8 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
18248 return dest_type;18248 return dest_type;
18249}18249}
1825018250
18251static TypeTableEntry *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {18251static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {
18252 TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);18252 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
18253 if (type_is_invalid(dest_type))18253 if (type_is_invalid(dest_type))
18254 return ira->codegen->builtin_types.entry_invalid;18254 return ira->codegen->builtin_types.entry_invalid;
1825518255
...@@ -18289,8 +18289,8 @@ static TypeTableEntry *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruc...@@ -18289,8 +18289,8 @@ static TypeTableEntry *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruc
18289 return dest_type;18289 return dest_type;
18290}18290}
1829118291
18292static TypeTableEntry *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {18292static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {
18293 TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);18293 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
18294 if (type_is_invalid(dest_type))18294 if (type_is_invalid(dest_type))
18295 return ira->codegen->builtin_types.entry_invalid;18295 return ira->codegen->builtin_types.entry_invalid;
1829618296
...@@ -18337,8 +18337,8 @@ static TypeTableEntry *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstr...@@ -18337,8 +18337,8 @@ static TypeTableEntry *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstr
18337 return dest_type;18337 return dest_type;
18338}18338}
1833918339
18340static TypeTableEntry *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {18340static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {
18341 TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);18341 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
18342 if (type_is_invalid(dest_type))18342 if (type_is_invalid(dest_type))
18343 return ira->codegen->builtin_types.entry_invalid;18343 return ira->codegen->builtin_types.entry_invalid;
1834418344
...@@ -18365,8 +18365,8 @@ static TypeTableEntry *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrIns...@@ -18365,8 +18365,8 @@ static TypeTableEntry *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrIns
18365 return dest_type;18365 return dest_type;
18366}18366}
1836718367
18368static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {18368static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
18369 TypeTableEntry *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->other);18369 ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->other);
18370 if (type_is_invalid(dest_child_type))18370 if (type_is_invalid(dest_child_type))
18371 return ira->codegen->builtin_types.entry_invalid;18371 return ira->codegen->builtin_types.entry_invalid;
1837218372
...@@ -18382,7 +18382,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr...@@ -18382,7 +18382,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
18382 src_ptr_volatile = target->value.type->data.pointer.is_volatile;18382 src_ptr_volatile = target->value.type->data.pointer.is_volatile;
18383 src_ptr_align = target->value.type->data.pointer.alignment;18383 src_ptr_align = target->value.type->data.pointer.alignment;
18384 } else if (is_slice(target->value.type)) {18384 } else if (is_slice(target->value.type)) {
18385 TypeTableEntry *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;18385 ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
18386 src_ptr_const = src_ptr_type->data.pointer.is_const;18386 src_ptr_const = src_ptr_type->data.pointer.is_const;
18387 src_ptr_volatile = src_ptr_type->data.pointer.is_volatile;18387 src_ptr_volatile = src_ptr_type->data.pointer.is_volatile;
18388 src_ptr_align = src_ptr_type->data.pointer.alignment;18388 src_ptr_align = src_ptr_type->data.pointer.alignment;
...@@ -18392,15 +18392,15 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr...@@ -18392,15 +18392,15 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
18392 src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);18392 src_ptr_align = get_abi_alignment(ira->codegen, target->value.type);
18393 }18393 }
1839418394
18395 TypeTableEntry *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,18395 ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
18396 src_ptr_const, src_ptr_volatile, PtrLenUnknown,18396 src_ptr_const, src_ptr_volatile, PtrLenUnknown,
18397 src_ptr_align, 0, 0);18397 src_ptr_align, 0, 0);
18398 TypeTableEntry *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);18398 ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
1839918399
18400 TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,18400 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
18401 src_ptr_const, src_ptr_volatile, PtrLenUnknown,18401 src_ptr_const, src_ptr_volatile, PtrLenUnknown,
18402 src_ptr_align, 0, 0);18402 src_ptr_align, 0, 0);
18403 TypeTableEntry *u8_slice = get_slice_type(ira->codegen, u8_ptr);18403 ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
1840418404
18405 IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice);18405 IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice);
18406 if (type_is_invalid(casted_value->value.type))18406 if (type_is_invalid(casted_value->value.type))
...@@ -18445,7 +18445,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr...@@ -18445,7 +18445,7 @@ static TypeTableEntry *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstr
18445 return dest_slice_type;18445 return dest_slice_type;
18446}18446}
1844718447
18448static TypeTableEntry *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) {18448static ZigType *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) {
18449 IrInstruction *target = instruction->target->other;18449 IrInstruction *target = instruction->target->other;
18450 if (type_is_invalid(target->value.type))18450 if (type_is_invalid(target->value.type))
18451 return ira->codegen->builtin_types.entry_invalid;18451 return ira->codegen->builtin_types.entry_invalid;
...@@ -18456,20 +18456,20 @@ static TypeTableEntry *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruc...@@ -18456,20 +18456,20 @@ static TypeTableEntry *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruc
18456 return ira->codegen->builtin_types.entry_invalid;18456 return ira->codegen->builtin_types.entry_invalid;
18457 }18457 }
1845818458
18459 TypeTableEntry *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;18459 ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index].type_entry;
1846018460
18461 TypeTableEntry *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,18461 ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
18462 src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown,18462 src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown,
18463 src_ptr_type->data.pointer.alignment, 0, 0);18463 src_ptr_type->data.pointer.alignment, 0, 0);
18464 TypeTableEntry *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);18464 ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
1846518465
18466 IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_slice_type, CastOpResizeSlice, true);18466 IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_slice_type, CastOpResizeSlice, true);
18467 ir_link_new_instruction(result, &instruction->base);18467 ir_link_new_instruction(result, &instruction->base);
18468 return dest_slice_type;18468 return dest_slice_type;
18469}18469}
1847018470
18471static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {18471static ZigType *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {
18472 TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);18472 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
18473 if (type_is_invalid(dest_type))18473 if (type_is_invalid(dest_type))
18474 return ira->codegen->builtin_types.entry_invalid;18474 return ira->codegen->builtin_types.entry_invalid;
1847518475
...@@ -18488,8 +18488,8 @@ static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrIns...@@ -18488,8 +18488,8 @@ static TypeTableEntry *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrIns
18488 return dest_type;18488 return dest_type;
18489}18489}
1849018490
18491static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {18491static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {
18492 TypeTableEntry *dest_type = ir_resolve_type(ira, instruction->dest_type->other);18492 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->other);
18493 if (type_is_invalid(dest_type))18493 if (type_is_invalid(dest_type))
18494 return ira->codegen->builtin_types.entry_invalid;18494 return ira->codegen->builtin_types.entry_invalid;
1849518495
...@@ -18516,7 +18516,7 @@ static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrIns...@@ -18516,7 +18516,7 @@ static TypeTableEntry *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrIns
18516 return dest_type;18516 return dest_type;
18517}18517}
1851818518
18519static TypeTableEntry *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) {18519static ZigType *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) {
18520 IrInstruction *target = instruction->target->other;18520 IrInstruction *target = instruction->target->other;
18521 if (type_is_invalid(target->value.type))18521 if (type_is_invalid(target->value.type))
18522 return ira->codegen->builtin_types.entry_invalid;18522 return ira->codegen->builtin_types.entry_invalid;
...@@ -18535,7 +18535,7 @@ static TypeTableEntry *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstr...@@ -18535,7 +18535,7 @@ static TypeTableEntry *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstr
18535 return result->value.type;18535 return result->value.type;
18536}18536}
1853718537
18538static TypeTableEntry *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) {18538static ZigType *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) {
18539 IrInstruction *target = instruction->target->other;18539 IrInstruction *target = instruction->target->other;
18540 if (type_is_invalid(target->value.type))18540 if (type_is_invalid(target->value.type))
18541 return ira->codegen->builtin_types.entry_invalid;18541 return ira->codegen->builtin_types.entry_invalid;
...@@ -18549,7 +18549,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstr...@@ -18549,7 +18549,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstr
18549 return result->value.type;18549 return result->value.type;
18550}18550}
1855118551
18552static TypeTableEntry *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) {18552static ZigType *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) {
18553 IrInstruction *target = instruction->target->other;18553 IrInstruction *target = instruction->target->other;
18554 if (type_is_invalid(target->value.type))18554 if (type_is_invalid(target->value.type))
18555 return ira->codegen->builtin_types.entry_invalid;18555 return ira->codegen->builtin_types.entry_invalid;
...@@ -18570,13 +18570,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInst...@@ -18570,13 +18570,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInst
18570 return ira->codegen->builtin_types.entry_num_lit_int;18570 return ira->codegen->builtin_types.entry_num_lit_int;
18571 }18571 }
1857218572
18573 TypeTableEntry *u1_type = get_int_type(ira->codegen, false, 1);18573 ZigType *u1_type = get_int_type(ira->codegen, false, 1);
18574 IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt, false);18574 IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt, false);
18575 ir_link_new_instruction(result, &instruction->base);18575 ir_link_new_instruction(result, &instruction->base);
18576 return u1_type;18576 return u1_type;
18577}18577}
1857818578
18579static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) {18579static ZigType *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) {
18580 IrInstruction *is_signed_value = instruction->is_signed->other;18580 IrInstruction *is_signed_value = instruction->is_signed->other;
18581 bool is_signed;18581 bool is_signed;
18582 if (!ir_resolve_bool(ira, is_signed_value, &is_signed))18582 if (!ir_resolve_bool(ira, is_signed_value, &is_signed))
...@@ -18592,12 +18592,12 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc...@@ -18592,12 +18592,12 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc
18592 return ira->codegen->builtin_types.entry_type;18592 return ira->codegen->builtin_types.entry_type;
18593}18593}
1859418594
18595static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) {18595static ZigType *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) {
18596 IrInstruction *value = instruction->value->other;18596 IrInstruction *value = instruction->value->other;
18597 if (type_is_invalid(value->value.type))18597 if (type_is_invalid(value->value.type))
18598 return ira->codegen->builtin_types.entry_invalid;18598 return ira->codegen->builtin_types.entry_invalid;
1859918599
18600 TypeTableEntry *bool_type = ira->codegen->builtin_types.entry_bool;18600 ZigType *bool_type = ira->codegen->builtin_types.entry_bool;
1860118601
18602 IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type);18602 IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type);
18603 if (type_is_invalid(casted_value->value.type))18603 if (type_is_invalid(casted_value->value.type))
...@@ -18617,7 +18617,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc...@@ -18617,7 +18617,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc
18617 return bool_type;18617 return bool_type;
18618}18618}
1861918619
18620static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) {18620static ZigType *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) {
18621 IrInstruction *dest_ptr = instruction->dest_ptr->other;18621 IrInstruction *dest_ptr = instruction->dest_ptr->other;
18622 if (type_is_invalid(dest_ptr->value.type))18622 if (type_is_invalid(dest_ptr->value.type))
18623 return ira->codegen->builtin_types.entry_invalid;18623 return ira->codegen->builtin_types.entry_invalid;
...@@ -18630,15 +18630,15 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi...@@ -18630,15 +18630,15 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
18630 if (type_is_invalid(count_value->value.type))18630 if (type_is_invalid(count_value->value.type))
18631 return ira->codegen->builtin_types.entry_invalid;18631 return ira->codegen->builtin_types.entry_invalid;
1863218632
18633 TypeTableEntry *dest_uncasted_type = dest_ptr->value.type;18633 ZigType *dest_uncasted_type = dest_ptr->value.type;
18634 bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&18634 bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
18635 dest_uncasted_type->data.pointer.is_volatile;18635 dest_uncasted_type->data.pointer.is_volatile;
1863618636
18637 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;18637 ZigType *usize = ira->codegen->builtin_types.entry_usize;
18638 TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;18638 ZigType *u8 = ira->codegen->builtin_types.entry_u8;
18639 uint32_t dest_align = (dest_uncasted_type->id == TypeTableEntryIdPointer) ?18639 uint32_t dest_align = (dest_uncasted_type->id == TypeTableEntryIdPointer) ?
18640 dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);18640 dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);
18641 TypeTableEntry *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,18641 ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
18642 PtrLenUnknown, dest_align, 0, 0);18642 PtrLenUnknown, dest_align, 0, 0);
1864318643
18644 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);18644 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);
...@@ -18709,7 +18709,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi...@@ -18709,7 +18709,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
18709 return ira->codegen->builtin_types.entry_void;18709 return ira->codegen->builtin_types.entry_void;
18710}18710}
1871118711
18712static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) {18712static ZigType *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) {
18713 IrInstruction *dest_ptr = instruction->dest_ptr->other;18713 IrInstruction *dest_ptr = instruction->dest_ptr->other;
18714 if (type_is_invalid(dest_ptr->value.type))18714 if (type_is_invalid(dest_ptr->value.type))
18715 return ira->codegen->builtin_types.entry_invalid;18715 return ira->codegen->builtin_types.entry_invalid;
...@@ -18722,9 +18722,9 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi...@@ -18722,9 +18722,9 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
18722 if (type_is_invalid(count_value->value.type))18722 if (type_is_invalid(count_value->value.type))
18723 return ira->codegen->builtin_types.entry_invalid;18723 return ira->codegen->builtin_types.entry_invalid;
1872418724
18725 TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;18725 ZigType *u8 = ira->codegen->builtin_types.entry_u8;
18726 TypeTableEntry *dest_uncasted_type = dest_ptr->value.type;18726 ZigType *dest_uncasted_type = dest_ptr->value.type;
18727 TypeTableEntry *src_uncasted_type = src_ptr->value.type;18727 ZigType *src_uncasted_type = src_ptr->value.type;
18728 bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&18728 bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
18729 dest_uncasted_type->data.pointer.is_volatile;18729 dest_uncasted_type->data.pointer.is_volatile;
18730 bool src_is_volatile = (src_uncasted_type->id == TypeTableEntryIdPointer) &&18730 bool src_is_volatile = (src_uncasted_type->id == TypeTableEntryIdPointer) &&
...@@ -18734,10 +18734,10 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi...@@ -18734,10 +18734,10 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
18734 uint32_t src_align = (src_uncasted_type->id == TypeTableEntryIdPointer) ?18734 uint32_t src_align = (src_uncasted_type->id == TypeTableEntryIdPointer) ?
18735 src_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);18735 src_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8);
1873618736
18737 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;18737 ZigType *usize = ira->codegen->builtin_types.entry_usize;
18738 TypeTableEntry *u8_ptr_mut = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,18738 ZigType *u8_ptr_mut = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile,
18739 PtrLenUnknown, dest_align, 0, 0);18739 PtrLenUnknown, dest_align, 0, 0);
18740 TypeTableEntry *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,18740 ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile,
18741 PtrLenUnknown, src_align, 0, 0);18741 PtrLenUnknown, src_align, 0, 0);
1874218742
18743 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);18743 IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);
...@@ -18844,20 +18844,20 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi...@@ -18844,20 +18844,20 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
18844 return ira->codegen->builtin_types.entry_void;18844 return ira->codegen->builtin_types.entry_void;
18845}18845}
1884618846
18847static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice *instruction) {18847static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice *instruction) {
18848 IrInstruction *ptr_ptr = instruction->ptr->other;18848 IrInstruction *ptr_ptr = instruction->ptr->other;
18849 if (type_is_invalid(ptr_ptr->value.type))18849 if (type_is_invalid(ptr_ptr->value.type))
18850 return ira->codegen->builtin_types.entry_invalid;18850 return ira->codegen->builtin_types.entry_invalid;
1885118851
18852 TypeTableEntry *ptr_type = ptr_ptr->value.type;18852 ZigType *ptr_type = ptr_ptr->value.type;
18853 assert(ptr_type->id == TypeTableEntryIdPointer);18853 assert(ptr_type->id == TypeTableEntryIdPointer);
18854 TypeTableEntry *array_type = ptr_type->data.pointer.child_type;18854 ZigType *array_type = ptr_type->data.pointer.child_type;
1885518855
18856 IrInstruction *start = instruction->start->other;18856 IrInstruction *start = instruction->start->other;
18857 if (type_is_invalid(start->value.type))18857 if (type_is_invalid(start->value.type))
18858 return ira->codegen->builtin_types.entry_invalid;18858 return ira->codegen->builtin_types.entry_invalid;
1885918859
18860 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;18860 ZigType *usize = ira->codegen->builtin_types.entry_usize;
18861 IrInstruction *casted_start = ir_implicit_cast(ira, start, usize);18861 IrInstruction *casted_start = ir_implicit_cast(ira, start, usize);
18862 if (type_is_invalid(casted_start->value.type))18862 if (type_is_invalid(casted_start->value.type))
18863 return ira->codegen->builtin_types.entry_invalid;18863 return ira->codegen->builtin_types.entry_invalid;
...@@ -18874,7 +18874,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18874,7 +18874,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18874 end = nullptr;18874 end = nullptr;
18875 }18875 }
1887618876
18877 TypeTableEntry *return_type;18877 ZigType *return_type;
1887818878
18879 if (array_type->id == TypeTableEntryIdArray) {18879 if (array_type->id == TypeTableEntryIdArray) {
18880 uint32_t byte_alignment = ptr_type->data.pointer.alignment;18880 uint32_t byte_alignment = ptr_type->data.pointer.alignment;
...@@ -18883,7 +18883,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18883,7 +18883,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18883 }18883 }
18884 bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic &&18884 bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic &&
18885 ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst;18885 ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst;
18886 TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,18886 ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,
18887 ptr_type->data.pointer.is_const || is_comptime_const,18887 ptr_type->data.pointer.is_const || is_comptime_const,
18888 ptr_type->data.pointer.is_volatile,18888 ptr_type->data.pointer.is_volatile,
18889 PtrLenUnknown,18889 PtrLenUnknown,
...@@ -18891,9 +18891,9 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18891,9 +18891,9 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18891 return_type = get_slice_type(ira->codegen, slice_ptr_type);18891 return_type = get_slice_type(ira->codegen, slice_ptr_type);
18892 } else if (array_type->id == TypeTableEntryIdPointer) {18892 } else if (array_type->id == TypeTableEntryIdPointer) {
18893 if (array_type->data.pointer.ptr_len == PtrLenSingle) {18893 if (array_type->data.pointer.ptr_len == PtrLenSingle) {
18894 TypeTableEntry *main_type = array_type->data.pointer.child_type;18894 ZigType *main_type = array_type->data.pointer.child_type;
18895 if (main_type->id == TypeTableEntryIdArray) {18895 if (main_type->id == TypeTableEntryIdArray) {
18896 TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen,18896 ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen,
18897 main_type->data.pointer.child_type,18897 main_type->data.pointer.child_type,
18898 array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,18898 array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,
18899 PtrLenUnknown,18899 PtrLenUnknown,
...@@ -18904,7 +18904,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18904,7 +18904,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18904 return ira->codegen->builtin_types.entry_invalid;18904 return ira->codegen->builtin_types.entry_invalid;
18905 }18905 }
18906 } else {18906 } else {
18907 TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type,18907 ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.pointer.child_type,
18908 array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,18908 array_type->data.pointer.is_const, array_type->data.pointer.is_volatile,
18909 PtrLenUnknown,18909 PtrLenUnknown,
18910 array_type->data.pointer.alignment, 0, 0);18910 array_type->data.pointer.alignment, 0, 0);
...@@ -18915,7 +18915,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18915,7 +18915,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18915 }18915 }
18916 }18916 }
18917 } else if (is_slice(array_type)) {18917 } else if (is_slice(array_type)) {
18918 TypeTableEntry *ptr_type = array_type->data.structure.fields[slice_ptr_index].type_entry;18918 ZigType *ptr_type = array_type->data.structure.fields[slice_ptr_index].type_entry;
18919 return_type = get_slice_type(ira->codegen, ptr_type);18919 return_type = get_slice_type(ira->codegen, ptr_type);
18920 } else {18920 } else {
18921 ir_add_error(ira, &instruction->base,18921 ir_add_error(ira, &instruction->base,
...@@ -18936,7 +18936,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -18936,7 +18936,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
18936 (array_type->id == TypeTableEntryIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))18936 (array_type->id == TypeTableEntryIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))
18937 {18937 {
18938 if (array_type->id == TypeTableEntryIdPointer) {18938 if (array_type->id == TypeTableEntryIdPointer) {
18939 TypeTableEntry *child_array_type = array_type->data.pointer.child_type;18939 ZigType *child_array_type = array_type->data.pointer.child_type;
18940 assert(child_array_type->id == TypeTableEntryIdArray);18940 assert(child_array_type->id == TypeTableEntryIdArray);
18941 parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node);18941 parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node);
18942 if (parent_ptr == nullptr)18942 if (parent_ptr == nullptr)
...@@ -19109,12 +19109,12 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio...@@ -19109,12 +19109,12 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
19109 return return_type;19109 return return_type;
19110}19110}
1911119111
19112static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) {19112static ZigType *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) {
19113 Error err;19113 Error err;
19114 IrInstruction *container = instruction->container->other;19114 IrInstruction *container = instruction->container->other;
19115 if (type_is_invalid(container->value.type))19115 if (type_is_invalid(container->value.type))
19116 return ira->codegen->builtin_types.entry_invalid;19116 return ira->codegen->builtin_types.entry_invalid;
19117 TypeTableEntry *container_type = ir_resolve_type(ira, container);19117 ZigType *container_type = ir_resolve_type(ira, container);
1911819118
19119 if ((err = ensure_complete_type(ira->codegen, container_type)))19119 if ((err = ensure_complete_type(ira->codegen, container_type)))
19120 return ira->codegen->builtin_types.entry_invalid;19120 return ira->codegen->builtin_types.entry_invalid;
...@@ -19147,10 +19147,10 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns...@@ -19147,10 +19147,10 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns
19147 return ira->codegen->builtin_types.entry_num_lit_int;19147 return ira->codegen->builtin_types.entry_num_lit_int;
19148}19148}
1914919149
19150static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {19150static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
19151 Error err;19151 Error err;
19152 IrInstruction *container_type_value = instruction->container_type->other;19152 IrInstruction *container_type_value = instruction->container_type->other;
19153 TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);19153 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19154 if (type_is_invalid(container_type))19154 if (type_is_invalid(container_type))
19155 return ira->codegen->builtin_types.entry_invalid;19155 return ira->codegen->builtin_types.entry_invalid;
1915619156
...@@ -19194,10 +19194,10 @@ static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInst...@@ -19194,10 +19194,10 @@ static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInst
19194 }19194 }
19195}19195}
1919619196
19197static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {19197static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
19198 Error err;19198 Error err;
19199 IrInstruction *container_type_value = instruction->container_type->other;19199 IrInstruction *container_type_value = instruction->container_type->other;
19200 TypeTableEntry *container_type = ir_resolve_type(ira, container_type_value);19200 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19201 if (type_is_invalid(container_type))19201 if (type_is_invalid(container_type))
19202 return ira->codegen->builtin_types.entry_invalid;19202 return ira->codegen->builtin_types.entry_invalid;
1920319203
...@@ -19252,28 +19252,28 @@ static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInst...@@ -19252,28 +19252,28 @@ static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInst
19252 }19252 }
19253}19253}
1925419254
19255static TypeTableEntry *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) {19255static ZigType *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) {
19256 ir_build_breakpoint_from(&ira->new_irb, &instruction->base);19256 ir_build_breakpoint_from(&ira->new_irb, &instruction->base);
19257 return ira->codegen->builtin_types.entry_void;19257 return ira->codegen->builtin_types.entry_void;
19258}19258}
1925919259
19260static TypeTableEntry *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) {19260static ZigType *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) {
19261 ir_build_return_address_from(&ira->new_irb, &instruction->base);19261 ir_build_return_address_from(&ira->new_irb, &instruction->base);
1926219262
19263 TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;19263 ZigType *u8 = ira->codegen->builtin_types.entry_u8;
19264 TypeTableEntry *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);19264 ZigType *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
19265 return u8_ptr_const;19265 return u8_ptr_const;
19266}19266}
1926719267
19268static TypeTableEntry *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) {19268static ZigType *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) {
19269 ir_build_frame_address_from(&ira->new_irb, &instruction->base);19269 ir_build_frame_address_from(&ira->new_irb, &instruction->base);
1927019270
19271 TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;19271 ZigType *u8 = ira->codegen->builtin_types.entry_u8;
19272 TypeTableEntry *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);19272 ZigType *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
19273 return u8_ptr_const;19273 return u8_ptr_const;
19274}19274}
1927519275
19276static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {19276static ZigType *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {
19277 ir_build_handle_from(&ira->new_irb, &instruction->base);19277 ir_build_handle_from(&ira->new_irb, &instruction->base);
1927819278
19279 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);19279 FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec);
...@@ -19281,12 +19281,12 @@ static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructi...@@ -19281,12 +19281,12 @@ static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructi
19281 return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type);19281 return get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type);
19282}19282}
1928319283
19284static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {19284static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {
19285 Error err;19285 Error err;
19286 IrInstruction *type_value = instruction->type_value->other;19286 IrInstruction *type_value = instruction->type_value->other;
19287 if (type_is_invalid(type_value->value.type))19287 if (type_is_invalid(type_value->value.type))
19288 return ira->codegen->builtin_types.entry_invalid;19288 return ira->codegen->builtin_types.entry_invalid;
19289 TypeTableEntry *type_entry = ir_resolve_type(ira, type_value);19289 ZigType *type_entry = ir_resolve_type(ira, type_value);
1929019290
19291 if ((err = type_ensure_zero_bits_known(ira->codegen, type_entry)))19291 if ((err = type_ensure_zero_bits_known(ira->codegen, type_entry)))
19292 return ira->codegen->builtin_types.entry_invalid;19292 return ira->codegen->builtin_types.entry_invalid;
...@@ -19332,12 +19332,12 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc...@@ -19332,12 +19332,12 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc
19332 zig_unreachable();19332 zig_unreachable();
19333}19333}
1933419334
19335static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) {19335static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) {
19336 IrInstruction *type_value = instruction->type_value->other;19336 IrInstruction *type_value = instruction->type_value->other;
19337 if (type_is_invalid(type_value->value.type))19337 if (type_is_invalid(type_value->value.type))
19338 return ira->codegen->builtin_types.entry_invalid;19338 return ira->codegen->builtin_types.entry_invalid;
1933919339
19340 TypeTableEntry *dest_type = ir_resolve_type(ira, type_value);19340 ZigType *dest_type = ir_resolve_type(ira, type_value);
19341 if (type_is_invalid(dest_type))19341 if (type_is_invalid(dest_type))
19342 return ira->codegen->builtin_types.entry_invalid;19342 return ira->codegen->builtin_types.entry_invalid;
1934319343
...@@ -19361,7 +19361,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst...@@ -19361,7 +19361,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
1936119361
19362 IrInstruction *casted_op2;19362 IrInstruction *casted_op2;
19363 if (instruction->op == IrOverflowOpShl) {19363 if (instruction->op == IrOverflowOpShl) {
19364 TypeTableEntry *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,19364 ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen,
19365 dest_type->data.integral.bit_count - 1);19365 dest_type->data.integral.bit_count - 1);
19366 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);19366 casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type);
19367 } else {19367 } else {
...@@ -19374,7 +19374,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst...@@ -19374,7 +19374,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
19374 if (type_is_invalid(result_ptr->value.type))19374 if (type_is_invalid(result_ptr->value.type))
19375 return ira->codegen->builtin_types.entry_invalid;19375 return ira->codegen->builtin_types.entry_invalid;
1937619376
19377 TypeTableEntry *expected_ptr_type;19377 ZigType *expected_ptr_type;
19378 if (result_ptr->value.type->id == TypeTableEntryIdPointer) {19378 if (result_ptr->value.type->id == TypeTableEntryIdPointer) {
19379 expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type,19379 expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type,
19380 false, result_ptr->value.type->data.pointer.is_volatile,19380 false, result_ptr->value.type->data.pointer.is_volatile,
...@@ -19431,12 +19431,12 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst...@@ -19431,12 +19431,12 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst
19431 return ira->codegen->builtin_types.entry_bool;19431 return ira->codegen->builtin_types.entry_bool;
19432}19432}
1943319433
19434static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErr *instruction) {19434static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErr *instruction) {
19435 IrInstruction *value = instruction->value->other;19435 IrInstruction *value = instruction->value->other;
19436 if (type_is_invalid(value->value.type))19436 if (type_is_invalid(value->value.type))
19437 return ira->codegen->builtin_types.entry_invalid;19437 return ira->codegen->builtin_types.entry_invalid;
1943819438
19439 TypeTableEntry *type_entry = value->value.type;19439 ZigType *type_entry = value->value.type;
19440 if (type_is_invalid(type_entry)) {19440 if (type_is_invalid(type_entry)) {
19441 return ira->codegen->builtin_types.entry_invalid;19441 return ira->codegen->builtin_types.entry_invalid;
19442 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {19442 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {
...@@ -19452,7 +19452,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc...@@ -19452,7 +19452,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
19452 }19452 }
19453 }19453 }
1945419454
19455 TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;19455 ZigType *err_set_type = type_entry->data.error_union.err_set_type;
19456 if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {19456 if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {
19457 return ira->codegen->builtin_types.entry_invalid;19457 return ira->codegen->builtin_types.entry_invalid;
19458 }19458 }
...@@ -19478,18 +19478,18 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc...@@ -19478,18 +19478,18 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
19478 }19478 }
19479}19479}
1948019480
19481static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,19481static ZigType *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
19482 IrInstructionUnwrapErrCode *instruction)19482 IrInstructionUnwrapErrCode *instruction)
19483{19483{
19484 IrInstruction *value = instruction->value->other;19484 IrInstruction *value = instruction->value->other;
19485 if (type_is_invalid(value->value.type))19485 if (type_is_invalid(value->value.type))
19486 return ira->codegen->builtin_types.entry_invalid;19486 return ira->codegen->builtin_types.entry_invalid;
19487 TypeTableEntry *ptr_type = value->value.type;19487 ZigType *ptr_type = value->value.type;
1948819488
19489 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.19489 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
19490 assert(ptr_type->id == TypeTableEntryIdPointer);19490 assert(ptr_type->id == TypeTableEntryIdPointer);
1949119491
19492 TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;19492 ZigType *type_entry = ptr_type->data.pointer.child_type;
19493 if (type_is_invalid(type_entry)) {19493 if (type_is_invalid(type_entry)) {
19494 return ira->codegen->builtin_types.entry_invalid;19494 return ira->codegen->builtin_types.entry_invalid;
19495 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {19495 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {
...@@ -19519,27 +19519,27 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,...@@ -19519,27 +19519,27 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira,
19519 }19519 }
19520}19520}
1952119521
19522static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,19522static ZigType *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
19523 IrInstructionUnwrapErrPayload *instruction)19523 IrInstructionUnwrapErrPayload *instruction)
19524{19524{
19525 assert(instruction->value->other);19525 assert(instruction->value->other);
19526 IrInstruction *value = instruction->value->other;19526 IrInstruction *value = instruction->value->other;
19527 if (type_is_invalid(value->value.type))19527 if (type_is_invalid(value->value.type))
19528 return ira->codegen->builtin_types.entry_invalid;19528 return ira->codegen->builtin_types.entry_invalid;
19529 TypeTableEntry *ptr_type = value->value.type;19529 ZigType *ptr_type = value->value.type;
1953019530
19531 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.19531 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
19532 assert(ptr_type->id == TypeTableEntryIdPointer);19532 assert(ptr_type->id == TypeTableEntryIdPointer);
1953319533
19534 TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;19534 ZigType *type_entry = ptr_type->data.pointer.child_type;
19535 if (type_is_invalid(type_entry)) {19535 if (type_is_invalid(type_entry)) {
19536 return ira->codegen->builtin_types.entry_invalid;19536 return ira->codegen->builtin_types.entry_invalid;
19537 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {19537 } else if (type_entry->id == TypeTableEntryIdErrorUnion) {
19538 TypeTableEntry *payload_type = type_entry->data.error_union.payload_type;19538 ZigType *payload_type = type_entry->data.error_union.payload_type;
19539 if (type_is_invalid(payload_type)) {19539 if (type_is_invalid(payload_type)) {
19540 return ira->codegen->builtin_types.entry_invalid;19540 return ira->codegen->builtin_types.entry_invalid;
19541 }19541 }
19542 TypeTableEntry *result_type = get_pointer_to_type_extra(ira->codegen, payload_type,19542 ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type,
19543 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,19543 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
19544 PtrLenSingle,19544 PtrLenSingle,
19545 get_abi_alignment(ira->codegen, payload_type), 0, 0);19545 get_abi_alignment(ira->codegen, payload_type), 0, 0);
...@@ -19575,7 +19575,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,...@@ -19575,7 +19575,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
1957519575
19576}19576}
1957719577
19578static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) {19578static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) {
19579 AstNode *proto_node = instruction->base.source_node;19579 AstNode *proto_node = instruction->base.source_node;
19580 assert(proto_node->type == NodeTypeFnProto);19580 assert(proto_node->type == NodeTypeFnProto);
1958119581
...@@ -19656,7 +19656,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc...@@ -19656,7 +19656,7 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
19656 return ira->codegen->builtin_types.entry_type;19656 return ira->codegen->builtin_types.entry_type;
19657}19657}
1965819658
19659static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) {19659static ZigType *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) {
19660 IrInstruction *value = instruction->value->other;19660 IrInstruction *value = instruction->value->other;
19661 if (type_is_invalid(value->value.type))19661 if (type_is_invalid(value->value.type))
19662 return ira->codegen->builtin_types.entry_invalid;19662 return ira->codegen->builtin_types.entry_invalid;
...@@ -19666,11 +19666,11 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn...@@ -19666,11 +19666,11 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn
19666 return ira->codegen->builtin_types.entry_bool;19666 return ira->codegen->builtin_types.entry_bool;
19667}19667}
1966819668
19669static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,19669static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira,
19670 IrInstructionCheckSwitchProngs *instruction)19670 IrInstructionCheckSwitchProngs *instruction)
19671{19671{
19672 IrInstruction *target_value = instruction->target_value->other;19672 IrInstruction *target_value = instruction->target_value->other;
19673 TypeTableEntry *switch_type = target_value->value.type;19673 ZigType *switch_type = target_value->value.type;
19674 if (type_is_invalid(switch_type))19674 if (type_is_invalid(switch_type))
19675 return ira->codegen->builtin_types.entry_invalid;19675 return ira->codegen->builtin_types.entry_invalid;
1967619676
...@@ -19846,11 +19846,11 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira...@@ -19846,11 +19846,11 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
19846 return ira->codegen->builtin_types.entry_void;19846 return ira->codegen->builtin_types.entry_void;
19847}19847}
1984819848
19849static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,19849static ZigType *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,
19850 IrInstructionCheckStatementIsVoid *instruction)19850 IrInstructionCheckStatementIsVoid *instruction)
19851{19851{
19852 IrInstruction *statement_value = instruction->statement_value->other;19852 IrInstruction *statement_value = instruction->statement_value->other;
19853 TypeTableEntry *statement_type = statement_value->value.type;19853 ZigType *statement_type = statement_value->value.type;
19854 if (type_is_invalid(statement_type))19854 if (type_is_invalid(statement_type))
19855 return ira->codegen->builtin_types.entry_invalid;19855 return ira->codegen->builtin_types.entry_invalid;
1985619856
...@@ -19862,7 +19862,7 @@ static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze...@@ -19862,7 +19862,7 @@ static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze
19862 return ira->codegen->builtin_types.entry_void;19862 return ira->codegen->builtin_types.entry_void;
19863}19863}
1986419864
19865static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) {19865static ZigType *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) {
19866 IrInstruction *msg = instruction->msg->other;19866 IrInstruction *msg = instruction->msg->other;
19867 if (type_is_invalid(msg->value.type))19867 if (type_is_invalid(msg->value.type))
19868 return ir_unreach_error(ira);19868 return ir_unreach_error(ira);
...@@ -19872,9 +19872,9 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio...@@ -19872,9 +19872,9 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio
19872 return ir_unreach_error(ira);19872 return ir_unreach_error(ira);
19873 }19873 }
1987419874
19875 TypeTableEntry *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,19875 ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
19876 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);19876 true, false, PtrLenUnknown, get_abi_alignment(ira->codegen, ira->codegen->builtin_types.entry_u8), 0, 0);
19877 TypeTableEntry *str_type = get_slice_type(ira->codegen, u8_ptr_type);19877 ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type);
19878 IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type);19878 IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type);
19879 if (type_is_invalid(casted_msg->value.type))19879 if (type_is_invalid(casted_msg->value.type))
19880 return ir_unreach_error(ira);19880 return ir_unreach_error(ira);
...@@ -19886,10 +19886,10 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio...@@ -19886,10 +19886,10 @@ static TypeTableEntry *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructio
19886}19886}
1988719887
19888static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) {19888static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) {
19889 TypeTableEntry *target_type = target->value.type;19889 ZigType *target_type = target->value.type;
19890 assert(!type_is_invalid(target_type));19890 assert(!type_is_invalid(target_type));
1989119891
19892 TypeTableEntry *result_type;19892 ZigType *result_type;
19893 uint32_t old_align_bytes;19893 uint32_t old_align_bytes;
1989419894
19895 if (target_type->id == TypeTableEntryIdPointer) {19895 if (target_type->id == TypeTableEntryIdPointer) {
...@@ -19903,9 +19903,9 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3...@@ -19903,9 +19903,9 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
19903 } else if (target_type->id == TypeTableEntryIdOptional &&19903 } else if (target_type->id == TypeTableEntryIdOptional &&
19904 target_type->data.maybe.child_type->id == TypeTableEntryIdPointer)19904 target_type->data.maybe.child_type->id == TypeTableEntryIdPointer)
19905 {19905 {
19906 TypeTableEntry *ptr_type = target_type->data.maybe.child_type;19906 ZigType *ptr_type = target_type->data.maybe.child_type;
19907 old_align_bytes = ptr_type->data.pointer.alignment;19907 old_align_bytes = ptr_type->data.pointer.alignment;
19908 TypeTableEntry *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes);19908 ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes);
1990919909
19910 result_type = get_optional_type(ira->codegen, better_ptr_type);19910 result_type = get_optional_type(ira->codegen, better_ptr_type);
19911 } else if (target_type->id == TypeTableEntryIdOptional &&19911 } else if (target_type->id == TypeTableEntryIdOptional &&
...@@ -19914,12 +19914,12 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3...@@ -19914,12 +19914,12 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
19914 FnTypeId fn_type_id = target_type->data.maybe.child_type->data.fn.fn_type_id;19914 FnTypeId fn_type_id = target_type->data.maybe.child_type->data.fn.fn_type_id;
19915 old_align_bytes = fn_type_id.alignment;19915 old_align_bytes = fn_type_id.alignment;
19916 fn_type_id.alignment = align_bytes;19916 fn_type_id.alignment = align_bytes;
19917 TypeTableEntry *fn_type = get_fn_type(ira->codegen, &fn_type_id);19917 ZigType *fn_type = get_fn_type(ira->codegen, &fn_type_id);
19918 result_type = get_optional_type(ira->codegen, fn_type);19918 result_type = get_optional_type(ira->codegen, fn_type);
19919 } else if (is_slice(target_type)) {19919 } else if (is_slice(target_type)) {
19920 TypeTableEntry *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;19920 ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index].type_entry;
19921 old_align_bytes = slice_ptr_type->data.pointer.alignment;19921 old_align_bytes = slice_ptr_type->data.pointer.alignment;
19922 TypeTableEntry *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes);19922 ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes);
19923 result_type = get_slice_type(ira->codegen, result_ptr_type);19923 result_type = get_slice_type(ira->codegen, result_ptr_type);
19924 } else {19924 } else {
19925 ir_add_error(ira, target,19925 ir_add_error(ira, target,
...@@ -19957,16 +19957,16 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3...@@ -19957,16 +19957,16 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
19957 return result;19957 return result;
19958}19958}
1995919959
19960static TypeTableEntry *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {19960static ZigType *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
19961 Error err;19961 Error err;
1996219962
19963 IrInstruction *dest_type_value = instruction->dest_type->other;19963 IrInstruction *dest_type_value = instruction->dest_type->other;
19964 TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);19964 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
19965 if (type_is_invalid(dest_type))19965 if (type_is_invalid(dest_type))
19966 return ira->codegen->builtin_types.entry_invalid;19966 return ira->codegen->builtin_types.entry_invalid;
1996719967
19968 IrInstruction *ptr = instruction->ptr->other;19968 IrInstruction *ptr = instruction->ptr->other;
19969 TypeTableEntry *src_type = ptr->value.type;19969 ZigType *src_type = ptr->value.type;
19970 if (type_is_invalid(src_type))19970 if (type_is_invalid(src_type))
19971 return ira->codegen->builtin_types.entry_invalid;19971 return ira->codegen->builtin_types.entry_invalid;
1997219972
...@@ -20155,15 +20155,15 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue...@@ -20155,15 +20155,15 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
20155 zig_unreachable();20155 zig_unreachable();
20156}20156}
2015720157
20158static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {20158static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
20159 Error err;20159 Error err;
20160 IrInstruction *dest_type_value = instruction->dest_type->other;20160 IrInstruction *dest_type_value = instruction->dest_type->other;
20161 TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);20161 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20162 if (type_is_invalid(dest_type))20162 if (type_is_invalid(dest_type))
20163 return ira->codegen->builtin_types.entry_invalid;20163 return ira->codegen->builtin_types.entry_invalid;
2016420164
20165 IrInstruction *value = instruction->value->other;20165 IrInstruction *value = instruction->value->other;
20166 TypeTableEntry *src_type = value->value.type;20166 ZigType *src_type = value->value.type;
20167 if (type_is_invalid(src_type))20167 if (type_is_invalid(src_type))
20168 return ira->codegen->builtin_types.entry_invalid;20168 return ira->codegen->builtin_types.entry_invalid;
2016920169
...@@ -20255,10 +20255,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc...@@ -20255,10 +20255,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
20255 return dest_type;20255 return dest_type;
20256}20256}
2025720257
20258static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {20258static ZigType *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
20259 Error err;20259 Error err;
20260 IrInstruction *dest_type_value = instruction->dest_type->other;20260 IrInstruction *dest_type_value = instruction->dest_type->other;
20261 TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);20261 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20262 if (type_is_invalid(dest_type))20262 if (type_is_invalid(dest_type))
20263 return ira->codegen->builtin_types.entry_invalid;20263 return ira->codegen->builtin_types.entry_invalid;
2026420264
...@@ -20300,7 +20300,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstr...@@ -20300,7 +20300,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstr
20300 return dest_type;20300 return dest_type;
20301}20301}
2030220302
20303static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,20303static ZigType *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
20304 IrInstructionDeclRef *instruction)20304 IrInstructionDeclRef *instruction)
20305{20305{
20306 Tld *tld = instruction->tld;20306 Tld *tld = instruction->tld;
...@@ -20361,12 +20361,12 @@ static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,...@@ -20361,12 +20361,12 @@ static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
20361 zig_unreachable();20361 zig_unreachable();
20362}20362}
2036320363
20364static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) {20364static ZigType *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) {
20365 IrInstruction *target = instruction->target->other;20365 IrInstruction *target = instruction->target->other;
20366 if (type_is_invalid(target->value.type))20366 if (type_is_invalid(target->value.type))
20367 return ira->codegen->builtin_types.entry_invalid;20367 return ira->codegen->builtin_types.entry_invalid;
2036820368
20369 TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;20369 ZigType *usize = ira->codegen->builtin_types.entry_usize;
2037020370
20371 if (get_codegen_ptr_type(target->value.type) == nullptr) {20371 if (get_codegen_ptr_type(target->value.type) == nullptr) {
20372 ir_add_error(ira, target,20372 ir_add_error(ira, target,
...@@ -20400,9 +20400,9 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr...@@ -20400,9 +20400,9 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr
20400 return usize;20400 return usize;
20401}20401}
2040220402
20403static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {20403static ZigType *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
20404 Error err;20404 Error err;
20405 TypeTableEntry *child_type = ir_resolve_type(ira, instruction->child_type->other);20405 ZigType *child_type = ir_resolve_type(ira, instruction->child_type->other);
20406 if (type_is_invalid(child_type))20406 if (type_is_invalid(child_type))
20407 return ira->codegen->builtin_types.entry_invalid;20407 return ira->codegen->builtin_types.entry_invalid;
2040820408
...@@ -20433,7 +20433,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruc...@@ -20433,7 +20433,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruc
20433 return ira->codegen->builtin_types.entry_type;20433 return ira->codegen->builtin_types.entry_type;
20434}20434}
2043520435
20436static TypeTableEntry *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) {20436static ZigType *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) {
20437 uint32_t align_bytes;20437 uint32_t align_bytes;
20438 IrInstruction *align_bytes_inst = instruction->align_bytes->other;20438 IrInstruction *align_bytes_inst = instruction->align_bytes->other;
20439 if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))20439 if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))
...@@ -20451,7 +20451,7 @@ static TypeTableEntry *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstr...@@ -20451,7 +20451,7 @@ static TypeTableEntry *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstr
20451 return result->value.type;20451 return result->value.type;
20452}20452}
2045320453
20454static TypeTableEntry *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) {20454static ZigType *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) {
20455 Buf *name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", instruction->base.source_node);20455 Buf *name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", instruction->base.source_node);
20456 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);20456 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
20457 out_val->data.x_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node,20457 out_val->data.x_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node,
...@@ -20459,7 +20459,7 @@ static TypeTableEntry *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInst...@@ -20459,7 +20459,7 @@ static TypeTableEntry *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInst
20459 return ira->codegen->builtin_types.entry_type;20459 return ira->codegen->builtin_types.entry_type;
20460}20460}
2046120461
20462static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) {20462static ZigType *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) {
20463 uint32_t align_bytes;20463 uint32_t align_bytes;
20464 IrInstruction *align_bytes_inst = instruction->align_bytes->other;20464 IrInstruction *align_bytes_inst = instruction->align_bytes->other;
20465 if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))20465 if (!ir_resolve_align(ira, align_bytes_inst, &align_bytes))
...@@ -20499,9 +20499,9 @@ static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, Ir...@@ -20499,9 +20499,9 @@ static TypeTableEntry *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, Ir
20499 return ira->codegen->builtin_types.entry_void;20499 return ira->codegen->builtin_types.entry_void;
20500}20500}
2050120501
20502static TypeTableEntry *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {20502static ZigType *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
20503 IrInstruction *fn_type_inst = instruction->fn_type->other;20503 IrInstruction *fn_type_inst = instruction->fn_type->other;
20504 TypeTableEntry *fn_type = ir_resolve_type(ira, fn_type_inst);20504 ZigType *fn_type = ir_resolve_type(ira, fn_type_inst);
20505 if (type_is_invalid(fn_type))20505 if (type_is_invalid(fn_type))
20506 return ira->codegen->builtin_types.entry_invalid;20506 return ira->codegen->builtin_types.entry_invalid;
2050720507
...@@ -20538,10 +20538,10 @@ static TypeTableEntry *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruc...@@ -20538,10 +20538,10 @@ static TypeTableEntry *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruc
20538 return ira->codegen->builtin_types.entry_type;20538 return ira->codegen->builtin_types.entry_type;
20539}20539}
2054020540
20541static TypeTableEntry *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {20541static ZigType *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
20542 Error err;20542 Error err;
20543 IrInstruction *target_inst = instruction->target->other;20543 IrInstruction *target_inst = instruction->target->other;
20544 TypeTableEntry *enum_type = ir_resolve_type(ira, target_inst);20544 ZigType *enum_type = ir_resolve_type(ira, target_inst);
20545 if (type_is_invalid(enum_type))20545 if (type_is_invalid(enum_type))
20546 return ira->codegen->builtin_types.entry_invalid;20546 return ira->codegen->builtin_types.entry_invalid;
2054720547
...@@ -20576,7 +20576,7 @@ static TypeTableEntry *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruc...@@ -20576,7 +20576,7 @@ static TypeTableEntry *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruc
20576 }20576 }
20577}20577}
2057820578
20579static TypeTableEntry *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) {20579static ZigType *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) {
20580 IrInstruction *target_inst = instruction->target->other;20580 IrInstruction *target_inst = instruction->target->other;
20581 if (type_is_invalid(target_inst->value.type))20581 if (type_is_invalid(target_inst->value.type))
20582 return ira->codegen->builtin_types.entry_invalid;20582 return ira->codegen->builtin_types.entry_invalid;
...@@ -20591,7 +20591,7 @@ static TypeTableEntry *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructi...@@ -20591,7 +20591,7 @@ static TypeTableEntry *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructi
20591 return result->value.type;20591 return result->value.type;
20592}20592}
2059320593
20594static TypeTableEntry *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstructionCoroId *instruction) {20594static ZigType *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstructionCoroId *instruction) {
20595 IrInstruction *promise_ptr = instruction->promise_ptr->other;20595 IrInstruction *promise_ptr = instruction->promise_ptr->other;
20596 if (type_is_invalid(promise_ptr->value.type))20596 if (type_is_invalid(promise_ptr->value.type))
20597 return ira->codegen->builtin_types.entry_invalid;20597 return ira->codegen->builtin_types.entry_invalid;
...@@ -20603,7 +20603,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstruct...@@ -20603,7 +20603,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_id(IrAnalyze *ira, IrInstruct
20603 return result->value.type;20603 return result->value.type;
20604}20604}
2060520605
20606static TypeTableEntry *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstructionCoroAlloc *instruction) {20606static ZigType *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstructionCoroAlloc *instruction) {
20607 IrInstruction *coro_id = instruction->coro_id->other;20607 IrInstruction *coro_id = instruction->coro_id->other;
20608 if (type_is_invalid(coro_id->value.type))20608 if (type_is_invalid(coro_id->value.type))
20609 return ira->codegen->builtin_types.entry_invalid;20609 return ira->codegen->builtin_types.entry_invalid;
...@@ -20615,14 +20615,14 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstr...@@ -20615,14 +20615,14 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc(IrAnalyze *ira, IrInstr
20615 return result->value.type;20615 return result->value.type;
20616}20616}
2061720617
20618static TypeTableEntry *ir_analyze_instruction_coro_size(IrAnalyze *ira, IrInstructionCoroSize *instruction) {20618static ZigType *ir_analyze_instruction_coro_size(IrAnalyze *ira, IrInstructionCoroSize *instruction) {
20619 IrInstruction *result = ir_build_coro_size(&ira->new_irb, instruction->base.scope, instruction->base.source_node);20619 IrInstruction *result = ir_build_coro_size(&ira->new_irb, instruction->base.scope, instruction->base.source_node);
20620 ir_link_new_instruction(result, &instruction->base);20620 ir_link_new_instruction(result, &instruction->base);
20621 result->value.type = ira->codegen->builtin_types.entry_usize;20621 result->value.type = ira->codegen->builtin_types.entry_usize;
20622 return result->value.type;20622 return result->value.type;
20623}20623}
2062420624
20625static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionCoroBegin *instruction) {20625static ZigType *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstructionCoroBegin *instruction) {
20626 IrInstruction *coro_id = instruction->coro_id->other;20626 IrInstruction *coro_id = instruction->coro_id->other;
20627 if (type_is_invalid(coro_id->value.type))20627 if (type_is_invalid(coro_id->value.type))
20628 return ira->codegen->builtin_types.entry_invalid;20628 return ira->codegen->builtin_types.entry_invalid;
...@@ -20640,13 +20640,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstr...@@ -20640,13 +20640,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstr
20640 return result->value.type;20640 return result->value.type;
20641}20641}
2064220642
20643static TypeTableEntry *ir_analyze_instruction_get_implicit_allocator(IrAnalyze *ira, IrInstructionGetImplicitAllocator *instruction) {20643static ZigType *ir_analyze_instruction_get_implicit_allocator(IrAnalyze *ira, IrInstructionGetImplicitAllocator *instruction) {
20644 IrInstruction *result = ir_get_implicit_allocator(ira, &instruction->base, instruction->id);20644 IrInstruction *result = ir_get_implicit_allocator(ira, &instruction->base, instruction->id);
20645 ir_link_new_instruction(result, &instruction->base);20645 ir_link_new_instruction(result, &instruction->base);
20646 return result->value.type;20646 return result->value.type;
20647}20647}
2064820648
20649static TypeTableEntry *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, IrInstructionCoroAllocFail *instruction) {20649static ZigType *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, IrInstructionCoroAllocFail *instruction) {
20650 IrInstruction *err_val = instruction->err_val->other;20650 IrInstruction *err_val = instruction->err_val->other;
20651 if (type_is_invalid(err_val->value.type))20651 if (type_is_invalid(err_val->value.type))
20652 return ir_unreach_error(ira);20652 return ir_unreach_error(ira);
...@@ -20657,7 +20657,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, Ir...@@ -20657,7 +20657,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_fail(IrAnalyze *ira, Ir
20657 return ir_finish_anal(ira, result->value.type);20657 return ir_finish_anal(ira, result->value.type);
20658}20658}
2065920659
20660static TypeTableEntry *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrInstructionCoroSuspend *instruction) {20660static ZigType *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrInstructionCoroSuspend *instruction) {
20661 IrInstruction *save_point = nullptr;20661 IrInstruction *save_point = nullptr;
20662 if (instruction->save_point != nullptr) {20662 if (instruction->save_point != nullptr) {
20663 save_point = instruction->save_point->other;20663 save_point = instruction->save_point->other;
...@@ -20676,7 +20676,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrIns...@@ -20676,7 +20676,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_suspend(IrAnalyze *ira, IrIns
20676 return result->value.type;20676 return result->value.type;
20677}20677}
2067820678
20679static TypeTableEntry *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstructionCoroEnd *instruction) {20679static ZigType *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstructionCoroEnd *instruction) {
20680 IrInstruction *result = ir_build_coro_end(&ira->new_irb, instruction->base.scope,20680 IrInstruction *result = ir_build_coro_end(&ira->new_irb, instruction->base.scope,
20681 instruction->base.source_node);20681 instruction->base.source_node);
20682 ir_link_new_instruction(result, &instruction->base);20682 ir_link_new_instruction(result, &instruction->base);
...@@ -20684,7 +20684,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstruc...@@ -20684,7 +20684,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_end(IrAnalyze *ira, IrInstruc
20684 return result->value.type;20684 return result->value.type;
20685}20685}
2068620686
20687static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstructionCoroFree *instruction) {20687static ZigType *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstructionCoroFree *instruction) {
20688 IrInstruction *coro_id = instruction->coro_id->other;20688 IrInstruction *coro_id = instruction->coro_id->other;
20689 if (type_is_invalid(coro_id->value.type))20689 if (type_is_invalid(coro_id->value.type))
20690 return ira->codegen->builtin_types.entry_invalid;20690 return ira->codegen->builtin_types.entry_invalid;
...@@ -20696,12 +20696,12 @@ static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstru...@@ -20696,12 +20696,12 @@ static TypeTableEntry *ir_analyze_instruction_coro_free(IrAnalyze *ira, IrInstru
20696 IrInstruction *result = ir_build_coro_free(&ira->new_irb, instruction->base.scope,20696 IrInstruction *result = ir_build_coro_free(&ira->new_irb, instruction->base.scope,
20697 instruction->base.source_node, coro_id, coro_handle);20697 instruction->base.source_node, coro_id, coro_handle);
20698 ir_link_new_instruction(result, &instruction->base);20698 ir_link_new_instruction(result, &instruction->base);
20699 TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);20699 ZigType *ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
20700 result->value.type = get_optional_type(ira->codegen, ptr_type);20700 result->value.type = get_optional_type(ira->codegen, ptr_type);
20701 return result->value.type;20701 return result->value.type;
20702}20702}
2070320703
20704static TypeTableEntry *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInstructionCoroResume *instruction) {20704static ZigType *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInstructionCoroResume *instruction) {
20705 IrInstruction *awaiter_handle = instruction->awaiter_handle->other;20705 IrInstruction *awaiter_handle = instruction->awaiter_handle->other;
20706 if (type_is_invalid(awaiter_handle->value.type))20706 if (type_is_invalid(awaiter_handle->value.type))
20707 return ira->codegen->builtin_types.entry_invalid;20707 return ira->codegen->builtin_types.entry_invalid;
...@@ -20717,7 +20717,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInst...@@ -20717,7 +20717,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_resume(IrAnalyze *ira, IrInst
20717 return result->value.type;20717 return result->value.type;
20718}20718}
2071920719
20720static TypeTableEntry *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstructionCoroSave *instruction) {20720static ZigType *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstructionCoroSave *instruction) {
20721 IrInstruction *coro_handle = instruction->coro_handle->other;20721 IrInstruction *coro_handle = instruction->coro_handle->other;
20722 if (type_is_invalid(coro_handle->value.type))20722 if (type_is_invalid(coro_handle->value.type))
20723 return ira->codegen->builtin_types.entry_invalid;20723 return ira->codegen->builtin_types.entry_invalid;
...@@ -20729,7 +20729,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstru...@@ -20729,7 +20729,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_save(IrAnalyze *ira, IrInstru
20729 return result->value.type;20729 return result->value.type;
20730}20730}
2073120731
20732static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructionCoroPromise *instruction) {20732static ZigType *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructionCoroPromise *instruction) {
20733 IrInstruction *coro_handle = instruction->coro_handle->other;20733 IrInstruction *coro_handle = instruction->coro_handle->other;
20734 if (type_is_invalid(coro_handle->value.type))20734 if (type_is_invalid(coro_handle->value.type))
20735 return ira->codegen->builtin_types.entry_invalid;20735 return ira->codegen->builtin_types.entry_invalid;
...@@ -20742,7 +20742,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns...@@ -20742,7 +20742,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns
20742 return ira->codegen->builtin_types.entry_invalid;20742 return ira->codegen->builtin_types.entry_invalid;
20743 }20743 }
2074420744
20745 TypeTableEntry *coro_frame_type = get_promise_frame_type(ira->codegen,20745 ZigType *coro_frame_type = get_promise_frame_type(ira->codegen,
20746 coro_handle->value.type->data.promise.result_type);20746 coro_handle->value.type->data.promise.result_type);
2074720747
20748 IrInstruction *result = ir_build_coro_promise(&ira->new_irb, instruction->base.scope,20748 IrInstruction *result = ir_build_coro_promise(&ira->new_irb, instruction->base.scope,
...@@ -20752,7 +20752,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns...@@ -20752,7 +20752,7 @@ static TypeTableEntry *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrIns
20752 return result->value.type;20752 return result->value.type;
20753}20753}
2075420754
20755static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, IrInstructionCoroAllocHelper *instruction) {20755static ZigType *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, IrInstructionCoroAllocHelper *instruction) {
20756 IrInstruction *alloc_fn = instruction->alloc_fn->other;20756 IrInstruction *alloc_fn = instruction->alloc_fn->other;
20757 if (type_is_invalid(alloc_fn->value.type))20757 if (type_is_invalid(alloc_fn->value.type))
20758 return ira->codegen->builtin_types.entry_invalid;20758 return ira->codegen->builtin_types.entry_invalid;
...@@ -20764,13 +20764,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira,...@@ -20764,13 +20764,13 @@ static TypeTableEntry *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira,
20764 IrInstruction *result = ir_build_coro_alloc_helper(&ira->new_irb, instruction->base.scope,20764 IrInstruction *result = ir_build_coro_alloc_helper(&ira->new_irb, instruction->base.scope,
20765 instruction->base.source_node, alloc_fn, coro_size);20765 instruction->base.source_node, alloc_fn, coro_size);
20766 ir_link_new_instruction(result, &instruction->base);20766 ir_link_new_instruction(result, &instruction->base);
20767 TypeTableEntry *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);20767 ZigType *u8_ptr_type = get_pointer_to_type(ira->codegen, ira->codegen->builtin_types.entry_u8, false);
20768 result->value.type = get_optional_type(ira->codegen, u8_ptr_type);20768 result->value.type = get_optional_type(ira->codegen, u8_ptr_type);
20769 return result->value.type;20769 return result->value.type;
20770}20770}
2077120771
20772static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {20772static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {
20773 TypeTableEntry *operand_type = ir_resolve_type(ira, op);20773 ZigType *operand_type = ir_resolve_type(ira, op);
20774 if (type_is_invalid(operand_type))20774 if (type_is_invalid(operand_type))
20775 return ira->codegen->builtin_types.entry_invalid;20775 return ira->codegen->builtin_types.entry_invalid;
2077620776
...@@ -20801,8 +20801,8 @@ static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruct...@@ -20801,8 +20801,8 @@ static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruct
20801 return operand_type;20801 return operand_type;
20802}20802}
2080320803
20804static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) {20804static ZigType *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) {
20805 TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);20805 ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
20806 if (type_is_invalid(operand_type))20806 if (type_is_invalid(operand_type))
20807 return ira->codegen->builtin_types.entry_invalid;20807 return ira->codegen->builtin_types.entry_invalid;
2080820808
...@@ -20811,7 +20811,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr...@@ -20811,7 +20811,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr
20811 return ira->codegen->builtin_types.entry_invalid;20811 return ira->codegen->builtin_types.entry_invalid;
2081220812
20813 // TODO let this be volatile20813 // TODO let this be volatile
20814 TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);20814 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false);
20815 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);20815 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
20816 if (type_is_invalid(casted_ptr->value.type))20816 if (type_is_invalid(casted_ptr->value.type))
20817 return ira->codegen->builtin_types.entry_invalid;20817 return ira->codegen->builtin_types.entry_invalid;
...@@ -20859,8 +20859,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr...@@ -20859,8 +20859,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstr
20859 return result->value.type;20859 return result->value.type;
20860}20860}
2086120861
20862static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) {20862static ZigType *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) {
20863 TypeTableEntry *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);20863 ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->other);
20864 if (type_is_invalid(operand_type))20864 if (type_is_invalid(operand_type))
20865 return ira->codegen->builtin_types.entry_invalid;20865 return ira->codegen->builtin_types.entry_invalid;
2086620866
...@@ -20868,7 +20868,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst...@@ -20868,7 +20868,7 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst
20868 if (type_is_invalid(ptr_inst->value.type))20868 if (type_is_invalid(ptr_inst->value.type))
20869 return ira->codegen->builtin_types.entry_invalid;20869 return ira->codegen->builtin_types.entry_invalid;
2087020870
20871 TypeTableEntry *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);20871 ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true);
20872 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);20872 IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type);
20873 if (type_is_invalid(casted_ptr->value.type))20873 if (type_is_invalid(casted_ptr->value.type))
20874 return ira->codegen->builtin_types.entry_invalid;20874 return ira->codegen->builtin_types.entry_invalid;
...@@ -20902,8 +20902,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst...@@ -20902,8 +20902,8 @@ static TypeTableEntry *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInst
20902 return result->value.type;20902 return result->value.type;
20903}20903}
2090420904
20905static TypeTableEntry *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {20905static ZigType *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {
20906 TypeTableEntry *promise_type = ir_resolve_type(ira, instruction->promise_type->other);20906 ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->other);
20907 if (type_is_invalid(promise_type))20907 if (type_is_invalid(promise_type))
20908 return ira->codegen->builtin_types.entry_invalid;20908 return ira->codegen->builtin_types.entry_invalid;
2090920909
...@@ -20918,8 +20918,8 @@ static TypeTableEntry *ir_analyze_instruction_promise_result_type(IrAnalyze *ira...@@ -20918,8 +20918,8 @@ static TypeTableEntry *ir_analyze_instruction_promise_result_type(IrAnalyze *ira
20918 return ira->codegen->builtin_types.entry_type;20918 return ira->codegen->builtin_types.entry_type;
20919}20919}
2092020920
20921static TypeTableEntry *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {20921static ZigType *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {
20922 TypeTableEntry *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->other);20922 ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->other);
20923 if (type_is_invalid(promise_result_type))20923 if (type_is_invalid(promise_result_type))
20924 return ira->codegen->builtin_types.entry_invalid;20924 return ira->codegen->builtin_types.entry_invalid;
2092520925
...@@ -20935,7 +20935,7 @@ static TypeTableEntry *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira,...@@ -20935,7 +20935,7 @@ static TypeTableEntry *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira,
20935 return out_val->type;20935 return out_val->type;
20936}20936}
2093720937
20938static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira,20938static ZigType *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira,
20939 IrInstructionMergeErrRetTraces *instruction)20939 IrInstructionMergeErrRetTraces *instruction)
20940{20940{
20941 IrInstruction *coro_promise_ptr = instruction->coro_promise_ptr->other;20941 IrInstruction *coro_promise_ptr = instruction->coro_promise_ptr->other;
...@@ -20943,9 +20943,9 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir...@@ -20943,9 +20943,9 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir
20943 return ira->codegen->builtin_types.entry_invalid;20943 return ira->codegen->builtin_types.entry_invalid;
2094420944
20945 assert(coro_promise_ptr->value.type->id == TypeTableEntryIdPointer);20945 assert(coro_promise_ptr->value.type->id == TypeTableEntryIdPointer);
20946 TypeTableEntry *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type;20946 ZigType *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type;
20947 assert(promise_frame_type->id == TypeTableEntryIdStruct);20947 assert(promise_frame_type->id == TypeTableEntryIdStruct);
20948 TypeTableEntry *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry;20948 ZigType *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry;
2094920949
20950 if (!type_can_fail(promise_result_type)) {20950 if (!type_can_fail(promise_result_type)) {
20951 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);20951 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
...@@ -20968,7 +20968,7 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir...@@ -20968,7 +20968,7 @@ static TypeTableEntry *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ir
20968 return result->value.type;20968 return result->value.type;
20969}20969}
2097020970
20971static TypeTableEntry *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) {20971static ZigType *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) {
20972 IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope,20972 IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope,
20973 instruction->base.source_node);20973 instruction->base.source_node);
20974 ir_link_new_instruction(result, &instruction->base);20974 ir_link_new_instruction(result, &instruction->base);
...@@ -20976,7 +20976,7 @@ static TypeTableEntry *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira,...@@ -20976,7 +20976,7 @@ static TypeTableEntry *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira,
20976 return result->value.type;20976 return result->value.type;
20977}20977}
2097820978
20979static TypeTableEntry *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *ira, IrInstructionMarkErrRetTracePtr *instruction) {20979static ZigType *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *ira, IrInstructionMarkErrRetTracePtr *instruction) {
20980 IrInstruction *err_ret_trace_ptr = instruction->err_ret_trace_ptr->other;20980 IrInstruction *err_ret_trace_ptr = instruction->err_ret_trace_ptr->other;
20981 if (type_is_invalid(err_ret_trace_ptr->value.type))20981 if (type_is_invalid(err_ret_trace_ptr->value.type))
20982 return ira->codegen->builtin_types.entry_invalid;20982 return ira->codegen->builtin_types.entry_invalid;
...@@ -20988,8 +20988,8 @@ static TypeTableEntry *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *...@@ -20988,8 +20988,8 @@ static TypeTableEntry *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *
20988 return result->value.type;20988 return result->value.type;
20989}20989}
2099020990
20991static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {20991static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {
20992 TypeTableEntry *float_type = ir_resolve_type(ira, instruction->type->other);20992 ZigType *float_type = ir_resolve_type(ira, instruction->type->other);
20993 if (type_is_invalid(float_type))20993 if (type_is_invalid(float_type))
20994 return ira->codegen->builtin_types.entry_invalid;20994 return ira->codegen->builtin_types.entry_invalid;
2099520995
...@@ -21055,7 +21055,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction...@@ -21055,7 +21055,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
21055 return result->value.type;21055 return result->value.type;
21056}21056}
2105721057
21058static TypeTableEntry *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) {21058static ZigType *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) {
21059 Error err;21059 Error err;
21060 IrInstruction *target = instruction->target->other;21060 IrInstruction *target = instruction->target->other;
21061 if (type_is_invalid(target->value.type))21061 if (type_is_invalid(target->value.type))
...@@ -21070,17 +21070,17 @@ static TypeTableEntry *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInst...@@ -21070,17 +21070,17 @@ static TypeTableEntry *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInst
21070 if ((err = type_ensure_zero_bits_known(ira->codegen, target->value.type)))21070 if ((err = type_ensure_zero_bits_known(ira->codegen, target->value.type)))
21071 return ira->codegen->builtin_types.entry_invalid;21071 return ira->codegen->builtin_types.entry_invalid;
2107221072
21073 TypeTableEntry *tag_type = target->value.type->data.enumeration.tag_int_type;21073 ZigType *tag_type = target->value.type->data.enumeration.tag_int_type;
2107421074
21075 IrInstruction *result = ir_analyze_enum_to_int(ira, &instruction->base, target, tag_type);21075 IrInstruction *result = ir_analyze_enum_to_int(ira, &instruction->base, target, tag_type);
21076 ir_link_new_instruction(result, &instruction->base);21076 ir_link_new_instruction(result, &instruction->base);
21077 return result->value.type;21077 return result->value.type;
21078}21078}
2107921079
21080static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {21080static ZigType *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
21081 Error err;21081 Error err;
21082 IrInstruction *dest_type_value = instruction->dest_type->other;21082 IrInstruction *dest_type_value = instruction->dest_type->other;
21083 TypeTableEntry *dest_type = ir_resolve_type(ira, dest_type_value);21083 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
21084 if (type_is_invalid(dest_type))21084 if (type_is_invalid(dest_type))
21085 return ira->codegen->builtin_types.entry_invalid;21085 return ira->codegen->builtin_types.entry_invalid;
2108621086
...@@ -21093,7 +21093,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst...@@ -21093,7 +21093,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst
21093 if ((err = type_ensure_zero_bits_known(ira->codegen, dest_type)))21093 if ((err = type_ensure_zero_bits_known(ira->codegen, dest_type)))
21094 return ira->codegen->builtin_types.entry_invalid;21094 return ira->codegen->builtin_types.entry_invalid;
2109521095
21096 TypeTableEntry *tag_type = dest_type->data.enumeration.tag_int_type;21096 ZigType *tag_type = dest_type->data.enumeration.tag_int_type;
2109721097
21098 IrInstruction *target = instruction->target->other;21098 IrInstruction *target = instruction->target->other;
21099 if (type_is_invalid(target->value.type))21099 if (type_is_invalid(target->value.type))
...@@ -21108,7 +21108,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst...@@ -21108,7 +21108,7 @@ static TypeTableEntry *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInst
21108 return result->value.type;21108 return result->value.type;
21109}21109}
2111021110
21111static TypeTableEntry *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) {21111static ZigType *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) {
21112 IrInstruction *block_comptime_inst = instruction->scope_is_comptime->other;21112 IrInstruction *block_comptime_inst = instruction->scope_is_comptime->other;
21113 bool scope_is_comptime;21113 bool scope_is_comptime;
21114 if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime))21114 if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime))
...@@ -21131,7 +21131,7 @@ static TypeTableEntry *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira...@@ -21131,7 +21131,7 @@ static TypeTableEntry *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira
21131 return ira->codegen->builtin_types.entry_void;21131 return ira->codegen->builtin_types.entry_void;
21132}21132}
2113321133
21134static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) {21134static ZigType *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) {
21135 switch (instruction->id) {21135 switch (instruction->id) {
21136 case IrInstructionIdInvalid:21136 case IrInstructionIdInvalid:
21137 case IrInstructionIdWidenOrShorten:21137 case IrInstructionIdWidenOrShorten:
...@@ -21413,8 +21413,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi...@@ -21413,8 +21413,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi
21413 zig_unreachable();21413 zig_unreachable();
21414}21414}
2141521415
21416static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction) {21416static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instruction) {
21417 TypeTableEntry *instruction_type = ir_analyze_instruction_nocast(ira, instruction);21417 ZigType *instruction_type = ir_analyze_instruction_nocast(ira, instruction);
21418 instruction->value.type = instruction_type;21418 instruction->value.type = instruction_type;
2141921419
21420 if (instruction->other) {21420 if (instruction->other) {
...@@ -21430,8 +21430,8 @@ static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *ins...@@ -21430,8 +21430,8 @@ static TypeTableEntry *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *ins
2143021430
21431// This function attempts to evaluate IR code while doing type checking and other analysis.21431// This function attempts to evaluate IR code while doing type checking and other analysis.
21432// It emits a new IrExecutable which is partially evaluated IR code.21432// It emits a new IrExecutable which is partially evaluated IR code.
21433TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec,21433ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec,
21434 TypeTableEntry *expected_type, AstNode *expected_type_source_node)21434 ZigType *expected_type, AstNode *expected_type_source_node)
21435{21435{
21436 assert(!old_exec->invalid);21436 assert(!old_exec->invalid);
21437 assert(expected_type == nullptr || !type_is_invalid(expected_type));21437 assert(expected_type == nullptr || !type_is_invalid(expected_type));
...@@ -21472,7 +21472,7 @@ TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutabl...@@ -21472,7 +21472,7 @@ TypeTableEntry *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutabl
21472 continue;21472 continue;
21473 }21473 }
2147421474
21475 TypeTableEntry *return_type = ir_analyze_instruction(ira, old_instruction);21475 ZigType *return_type = ir_analyze_instruction(ira, old_instruction);
21476 if (type_is_invalid(return_type) && ir_should_inline(new_exec, old_instruction->scope)) {21476 if (type_is_invalid(return_type) && ir_should_inline(new_exec, old_instruction->scope)) {
21477 return ira->codegen->builtin_types.entry_invalid;21477 return ira->codegen->builtin_types.entry_invalid;
21478 }21478 }
src/ir.hpp+3-3
...@@ -14,12 +14,12 @@ bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable...@@ -14,12 +14,12 @@ bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutable *ir_executable
14bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry);14bool ir_gen_fn(CodeGen *g, FnTableEntry *fn_entry);
1515
16IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,16IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
17 TypeTableEntry *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,17 ZigType *expected_type, size_t *backward_branch_count, size_t backward_branch_quota,
18 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,18 FnTableEntry *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
19 IrExecutable *parent_exec);19 IrExecutable *parent_exec);
2020
21TypeTableEntry *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,21ZigType *ir_analyze(CodeGen *g, IrExecutable *old_executable, IrExecutable *new_executable,
22 TypeTableEntry *expected_type, AstNode *expected_type_source_node);22 ZigType *expected_type, AstNode *expected_type_source_node);
2323
24bool ir_has_side_effects(IrInstruction *instruction);24bool ir_has_side_effects(IrInstruction *instruction);
25ConstExprValue *const_ptr_pointee(CodeGen *codegen, ConstExprValue *const_val);25ConstExprValue *const_ptr_pointee(CodeGen *codegen, ConstExprValue *const_val);