@@ -1067,8 +1067,10 @@ struct TypeStructField {
1067
1067
ZigType *type_entry;
1068
1068
size_t src_index;
1069
1069
size_t gen_index;
1070
- uint32_t bit_offset_in_host ; // offset from the memory at gen_index
1070
+ size_t offset ; // byte offset from beginning of struct
1071
1071
AstNode *decl_node;
1072
+ uint32_t bit_offset_in_host; // offset from the memory at gen_index
1073
+ uint32_t host_int_bytes; // size of host integer
1072
1074
};
1073
1075
1074
1076
enum ResolveStatus {
@@ -1077,6 +1079,8 @@ enum ResolveStatus {
1077
1079
ResolveStatusZeroBitsKnown,
1078
1080
ResolveStatusAlignmentKnown,
1079
1081
ResolveStatusSizeKnown,
1082
+ ResolveStatusLLVMFwdDecl,
1083
+ ResolveStatusLLVMFull,
1080
1084
};
1081
1085
1082
1086
struct ZigPackage {
@@ -1101,14 +1105,13 @@ struct ZigTypeStruct {
1101
1105
AstNode *decl_node;
1102
1106
TypeStructField *fields;
1103
1107
ScopeDecls *decls_scope;
1104
- uint64_t size_bytes;
1105
1108
HashMap<Buf *, TypeStructField *, buf_hash, buf_eql_buf> fields_by_name;
1106
1109
RootStruct *root_struct;
1110
+ uint32_t *host_int_bytes; // available for packed structs, indexed by gen_index
1107
1111
1108
1112
uint32_t src_field_count;
1109
1113
uint32_t gen_field_count;
1110
1114
1111
- uint32_t abi_alignment; // known after ResolveStatusAlignmentKnown
1112
1115
ContainerLayout layout;
1113
1116
ResolveStatus resolve_status;
1114
1117
@@ -1164,39 +1167,28 @@ bool type_ptr_eql(const ZigType *a, const ZigType *b);
1164
1167
1165
1168
struct ZigTypeUnion {
1166
1169
AstNode *decl_node;
1167
- ContainerLayout layout;
1168
- uint32_t src_field_count;
1169
- uint32_t gen_field_count;
1170
1170
TypeUnionField *fields;
1171
- bool is_invalid; // true if any fields are invalid
1171
+ ScopeDecls *decls_scope;
1172
+ HashMap<Buf *, TypeUnionField *, buf_hash, buf_eql_buf> fields_by_name;
1172
1173
ZigType *tag_type; // always an enum or null
1173
- LLVMTypeRef union_type_ref;
1174
+ LLVMTypeRef union_llvm_type;
1175
+ ZigType *most_aligned_union_member;
1176
+ size_t gen_union_index;
1177
+ size_t gen_tag_index;
1178
+ size_t union_abi_size;
1174
1179
1175
- ScopeDecls *decls_scope;
1180
+ uint32_t src_field_count;
1181
+ uint32_t gen_field_count;
1176
1182
1177
- // set this flag temporarily to detect infinite loops
1178
- bool embedded_in_current;
1179
- bool reported_infinite_err;
1180
- // whether we've finished resolving it
1181
- bool complete;
1183
+ ContainerLayout layout;
1184
+ ResolveStatus resolve_status;
1182
1185
1186
+ bool have_explicit_tag_type;
1187
+ bool resolve_loop_flag; // set this flag temporarily to detect infinite loops
1188
+ bool reported_infinite_err;
1183
1189
// whether any of the fields require comptime
1184
1190
// the value is not valid until zero_bits_known == true
1185
1191
bool requires_comptime;
1186
-
1187
- bool zero_bits_loop_flag;
1188
- bool zero_bits_known;
1189
- uint32_t abi_alignment; // also figured out with zero_bits pass
1190
-
1191
- size_t gen_union_index;
1192
- size_t gen_tag_index;
1193
-
1194
- bool have_explicit_tag_type;
1195
-
1196
- uint32_t union_size_bytes;
1197
- ZigType *most_aligned_union_member;
1198
-
1199
- HashMap<Buf *, TypeUnionField *, buf_hash, buf_eql_buf> fields_by_name;
1200
1192
};
1201
1193
1202
1194
struct FnGenParamInfo {
@@ -1277,8 +1269,11 @@ struct ZigType {
1277
1269
ZigTypeId id;
1278
1270
Buf name;
1279
1271
1280
- LLVMTypeRef type_ref;
1281
- ZigLLVMDIType *di_type;
1272
+ // These are not supposed to be accessed directly. They're
1273
+ // null during semantic analysis, memoized with get_llvm_type
1274
+ // and get_llvm_di_type
1275
+ LLVMTypeRef llvm_type;
1276
+ ZigLLVMDIType *llvm_di_type;
1282
1277
1283
1278
union {
1284
1279
ZigTypePointer pointer;
@@ -1308,8 +1303,14 @@ struct ZigType {
1308
1303
ConstExprValue *cached_const_name_val;
1309
1304
1310
1305
OnePossibleValue one_possible_value;
1306
+ // Known after ResolveStatusAlignmentKnown.
1307
+ uint32_t abi_align;
1308
+ // The offset in bytes between consecutive array elements of this type. Known
1309
+ // after ResolveStatusSizeKnown.
1310
+ size_t abi_size;
1311
+ // Number of bits of information in this type. Known after ResolveStatusSizeKnown.
1312
+ size_t size_in_bits;
1311
1313
1312
- bool zero_bits; // this is denormalized data
1313
1314
bool gen_h_loop_flag;
1314
1315
};
1315
1316
@@ -1700,11 +1701,9 @@ struct CodeGen {
1700
1701
ZigList<AstNode *> use_queue;
1701
1702
size_t use_queue_index;
1702
1703
ZigList<TimeEvent> timing_events;
1703
- ZigList<ZigLLVMDIType **> error_di_types;
1704
1704
ZigList<AstNode *> tld_ref_source_node_stack;
1705
1705
ZigList<ZigFn *> inline_fns;
1706
1706
ZigList<ZigFn *> test_fns;
1707
- ZigList<ZigLLVMDIEnumerator *> err_enumerators;
1708
1707
ZigList<ErrorTableEntry *> errors_by_index;
1709
1708
ZigList<CacheHash *> caches_to_release;
1710
1709
size_t largest_err_name_len;
@@ -1896,7 +1895,6 @@ struct ZigVar {
1896
1895
AstNode *decl_node;
1897
1896
ZigLLVMDILocalVariable *di_loc_var;
1898
1897
size_t src_arg_index;
1899
- size_t gen_arg_index;
1900
1898
Scope *parent_scope;
1901
1899
Scope *child_scope;
1902
1900
LLVMValueRef param_value_ref;
0 commit comments