| ... | @@ -421,11 +421,11 @@ static bool value_is_comptime(ZigValue *const_val) { | ... | @@ -421,11 +421,11 @@ static bool value_is_comptime(ZigValue *const_val) { |
| 421 | } | 421 | } |
| 422 | | 422 | |
| 423 | static bool instr_is_comptime(IrInstruction *instruction) { | 423 | static bool instr_is_comptime(IrInstruction *instruction) { |
| 424 | return value_is_comptime(&instruction->value); | 424 | return value_is_comptime(instruction->value); |
| 425 | } | 425 | } |
| 426 | | 426 | |
| 427 | static bool instr_is_unreachable(IrInstruction *instruction) { | 427 | static bool instr_is_unreachable(IrInstruction *instruction) { |
| 428 | return instruction->value.type && instruction->value.type->id == ZigTypeIdUnreachable; | 428 | return instruction->value->type && instruction->value->type->id == ZigTypeIdUnreachable; |
| 429 | } | 429 | } |
| 430 | | 430 | |
| 431 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { | 431 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { |
| ... | @@ -1156,7 +1156,8 @@ static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_no | ... | @@ -1156,7 +1156,8 @@ static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_no |
| 1156 | special_instruction->base.source_node = source_node; | 1156 | special_instruction->base.source_node = source_node; |
| 1157 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 1157 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); |
| 1158 | special_instruction->base.owner_bb = irb->current_basic_block; | 1158 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1159 | special_instruction->base.value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs"); | 1159 | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); |
| | 1160 | special_instruction->base.value->global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs"); |
| 1160 | return special_instruction; | 1161 | return special_instruction; |
| 1161 | } | 1162 | } |
| 1162 | | 1163 | |
| ... | @@ -1184,8 +1185,8 @@ static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -1184,8 +1185,8 @@ static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *so |
| 1184 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) | 1185 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) |
| 1185 | { | 1186 | { |
| 1186 | IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node); | 1187 | IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node); |
| 1187 | cond_br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1188 | cond_br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1188 | cond_br_instruction->base.value.special = ConstValSpecialStatic; | 1189 | cond_br_instruction->base.value->special = ConstValSpecialStatic; |
| 1189 | cond_br_instruction->condition = condition; | 1190 | cond_br_instruction->condition = condition; |
| 1190 | cond_br_instruction->then_block = then_block; | 1191 | cond_br_instruction->then_block = then_block; |
| 1191 | cond_br_instruction->else_block = else_block; | 1192 | cond_br_instruction->else_block = else_block; |
| ... | @@ -1203,8 +1204,8 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1203,8 +1204,8 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1203 | IrInstruction *operand) | 1204 | IrInstruction *operand) |
| 1204 | { | 1205 | { |
| 1205 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); | 1206 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); |
| 1206 | return_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1207 | return_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1207 | return_instruction->base.value.special = ConstValSpecialStatic; | 1208 | return_instruction->base.value->special = ConstValSpecialStatic; |
| 1208 | return_instruction->operand = operand; | 1209 | return_instruction->operand = operand; |
| 1209 | | 1210 | |
| 1210 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); | 1211 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); |
| ... | @@ -1214,54 +1215,54 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1214,54 +1215,54 @@ static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1214 | | 1215 | |
| 1215 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1216 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1216 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1217 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1217 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1218 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1218 | const_instruction->base.value.special = ConstValSpecialStatic; | 1219 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1219 | return &const_instruction->base; | 1220 | return &const_instruction->base; |
| 1220 | } | 1221 | } |
| 1221 | | 1222 | |
| 1222 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1223 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1223 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1224 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1224 | const_instruction->base.value.special = ConstValSpecialUndef; | 1225 | const_instruction->base.value->special = ConstValSpecialUndef; |
| 1225 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_undef; | 1226 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_undef; |
| 1226 | return &const_instruction->base; | 1227 | return &const_instruction->base; |
| 1227 | } | 1228 | } |
| 1228 | | 1229 | |
| 1229 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 1230 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1230 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1231 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1231 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_int; | 1232 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1232 | const_instruction->base.value.special = ConstValSpecialStatic; | 1233 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1233 | bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value); | 1234 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); |
| 1234 | return &const_instruction->base; | 1235 | return &const_instruction->base; |
| 1235 | } | 1236 | } |
| 1236 | | 1237 | |
| 1237 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { | 1238 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { |
| 1238 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1239 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1239 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_int; | 1240 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1240 | const_instruction->base.value.special = ConstValSpecialStatic; | 1241 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1241 | bigint_init_bigint(&const_instruction->base.value.data.x_bigint, bigint); | 1242 | bigint_init_bigint(&const_instruction->base.value->data.x_bigint, bigint); |
| 1242 | return &const_instruction->base; | 1243 | return &const_instruction->base; |
| 1243 | } | 1244 | } |
| 1244 | | 1245 | |
| 1245 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { | 1246 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { |
| 1246 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1247 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1247 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_num_lit_float; | 1248 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_float; |
| 1248 | const_instruction->base.value.special = ConstValSpecialStatic; | 1249 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1249 | bigfloat_init_bigfloat(&const_instruction->base.value.data.x_bigfloat, bigfloat); | 1250 | bigfloat_init_bigfloat(&const_instruction->base.value->data.x_bigfloat, bigfloat); |
| 1250 | return &const_instruction->base; | 1251 | return &const_instruction->base; |
| 1251 | } | 1252 | } |
| 1252 | | 1253 | |
| 1253 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1254 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1254 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1255 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1255 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_null; | 1256 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_null; |
| 1256 | const_instruction->base.value.special = ConstValSpecialStatic; | 1257 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1257 | return &const_instruction->base; | 1258 | return &const_instruction->base; |
| 1258 | } | 1259 | } |
| 1259 | | 1260 | |
| 1260 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 1261 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1261 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1262 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1262 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_usize; | 1263 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_usize; |
| 1263 | const_instruction->base.value.special = ConstValSpecialStatic; | 1264 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1264 | bigint_init_unsigned(&const_instruction->base.value.data.x_bigint, value); | 1265 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); |
| 1265 | return &const_instruction->base; | 1266 | return &const_instruction->base; |
| 1266 | } | 1267 | } |
| 1267 | | 1268 | |
| ... | @@ -1269,9 +1270,9 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1269,9 +1270,9 @@ static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode |
| 1269 | ZigType *type_entry) | 1270 | ZigType *type_entry) |
| 1270 | { | 1271 | { |
| 1271 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1272 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1272 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; | 1273 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; |
| 1273 | const_instruction->base.value.special = ConstValSpecialStatic; | 1274 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1274 | const_instruction->base.value.data.x_type = type_entry; | 1275 | const_instruction->base.value->data.x_type = type_entry; |
| 1275 | return &const_instruction->base; | 1276 | return &const_instruction->base; |
| 1276 | } | 1277 | } |
| 1277 | | 1278 | |
| ... | @@ -1285,35 +1286,35 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1285,35 +1286,35 @@ static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode |
| 1285 | | 1286 | |
| 1286 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | 1287 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { |
| 1287 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1288 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1288 | const_instruction->base.value.type = fn_entry->type_entry; | 1289 | const_instruction->base.value->type = fn_entry->type_entry; |
| 1289 | const_instruction->base.value.special = ConstValSpecialStatic; | 1290 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1290 | const_instruction->base.value.data.x_ptr.data.fn.fn_entry = fn_entry; | 1291 | const_instruction->base.value->data.x_ptr.data.fn.fn_entry = fn_entry; |
| 1291 | const_instruction->base.value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 1292 | const_instruction->base.value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 1292 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialFunction; | 1293 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialFunction; |
| 1293 | return &const_instruction->base; | 1294 | return &const_instruction->base; |
| 1294 | } | 1295 | } |
| 1295 | | 1296 | |
| 1296 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { | 1297 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { |
| 1297 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1298 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1298 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; | 1299 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; |
| 1299 | const_instruction->base.value.special = ConstValSpecialStatic; | 1300 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1300 | const_instruction->base.value.data.x_type = import; | 1301 | const_instruction->base.value->data.x_type = import; |
| 1301 | return &const_instruction->base; | 1302 | return &const_instruction->base; |
| 1302 | } | 1303 | } |
| 1303 | | 1304 | |
| 1304 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { | 1305 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { |
| 1305 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1306 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1306 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool; | 1307 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_bool; |
| 1307 | const_instruction->base.value.special = ConstValSpecialStatic; | 1308 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1308 | const_instruction->base.value.data.x_bool = value; | 1309 | const_instruction->base.value->data.x_bool = value; |
| 1309 | return &const_instruction->base; | 1310 | return &const_instruction->base; |
| 1310 | } | 1311 | } |
| 1311 | | 1312 | |
| 1312 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { | 1313 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 1313 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1314 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1314 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_enum_literal; | 1315 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_enum_literal; |
| 1315 | const_instruction->base.value.special = ConstValSpecialStatic; | 1316 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1316 | const_instruction->base.value.data.x_enum_literal = name; | 1317 | const_instruction->base.value->data.x_enum_literal = name; |
| 1317 | return &const_instruction->base; | 1318 | return &const_instruction->base; |
| 1318 | } | 1319 | } |
| 1319 | | 1320 | |
| ... | @@ -1321,19 +1322,20 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN | ... | @@ -1321,19 +1322,20 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN |
| 1321 | ZigFn *fn_entry, IrInstruction *first_arg) | 1322 | ZigFn *fn_entry, IrInstruction *first_arg) |
| 1322 | { | 1323 | { |
| 1323 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 1324 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1324 | const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); | 1325 | const_instruction->base.value->type = get_bound_fn_type(irb->codegen, fn_entry); |
| 1325 | const_instruction->base.value.special = ConstValSpecialStatic; | 1326 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 1326 | const_instruction->base.value.data.x_bound_fn.fn = fn_entry; | 1327 | const_instruction->base.value->data.x_bound_fn.fn = fn_entry; |
| 1327 | const_instruction->base.value.data.x_bound_fn.first_arg = first_arg; | 1328 | const_instruction->base.value->data.x_bound_fn.first_arg = first_arg; |
| 1328 | return &const_instruction->base; | 1329 | return &const_instruction->base; |
| 1329 | } | 1330 | } |
| 1330 | | 1331 | |
| 1331 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 1332 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1332 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 1333 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1333 | init_const_str_lit(irb->codegen, &const_instruction->base.value, str); | 1334 | init_const_str_lit(irb->codegen, const_instruction->base.value, str); |
| 1334 | | 1335 | |
| 1335 | return &const_instruction->base; | 1336 | return &const_instruction->base; |
| 1336 | } | 1337 | } |
| | 1338 | |
| 1337 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 1339 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1338 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); | 1340 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); |
| 1339 | ir_instruction_append(irb->current_basic_block, instruction); | 1341 | ir_instruction_append(irb->current_basic_block, instruction); |
| ... | @@ -1388,7 +1390,7 @@ static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -1388,7 +1390,7 @@ static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *so |
| 1388 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 1390 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 1389 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, | 1391 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, |
| 1390 | source_instruction->scope, source_instruction->source_node); | 1392 | source_instruction->scope, source_instruction->source_node); |
| 1391 | instruction->base.value.type = ty; | 1393 | instruction->base.value->type = ty; |
| 1392 | return &instruction->base; | 1394 | return &instruction->base; |
| 1393 | } | 1395 | } |
| 1394 | | 1396 | |
| ... | @@ -1513,7 +1515,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so | ... | @@ -1513,7 +1515,7 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so |
| 1513 | { | 1515 | { |
| 1514 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, | 1516 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, |
| 1515 | source_instruction->scope, source_instruction->source_node); | 1517 | source_instruction->scope, source_instruction->source_node); |
| 1516 | call_instruction->base.value.type = return_type; | 1518 | call_instruction->base.value->type = return_type; |
| 1517 | call_instruction->fn_entry = fn_entry; | 1519 | call_instruction->fn_entry = fn_entry; |
| 1518 | call_instruction->fn_ref = fn_ref; | 1520 | call_instruction->fn_ref = fn_ref; |
| 1519 | call_instruction->fn_inline = fn_inline; | 1521 | call_instruction->fn_inline = fn_inline; |
| ... | @@ -1558,8 +1560,8 @@ static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -1558,8 +1560,8 @@ static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source |
| 1558 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 1560 | IrBasicBlock *dest_block, IrInstruction *is_comptime) |
| 1559 | { | 1561 | { |
| 1560 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); | 1562 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); |
| 1561 | br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1563 | br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1562 | br_instruction->base.value.special = ConstValSpecialStatic; | 1564 | br_instruction->base.value->special = ConstValSpecialStatic; |
| 1563 | br_instruction->dest_block = dest_block; | 1565 | br_instruction->dest_block = dest_block; |
| 1564 | br_instruction->is_comptime = is_comptime; | 1566 | br_instruction->is_comptime = is_comptime; |
| 1565 | | 1567 | |
| ... | @@ -1659,8 +1661,8 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop | ... | @@ -1659,8 +1661,8 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop |
| 1659 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1661 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 1660 | IrInstructionUnreachable *unreachable_instruction = | 1662 | IrInstructionUnreachable *unreachable_instruction = |
| 1661 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); | 1663 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); |
| 1662 | unreachable_instruction->base.value.special = ConstValSpecialStatic; | 1664 | unreachable_instruction->base.value->special = ConstValSpecialStatic; |
| 1663 | unreachable_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 1665 | unreachable_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 1664 | return &unreachable_instruction->base; | 1666 | return &unreachable_instruction->base; |
| 1665 | } | 1667 | } |
| 1666 | | 1668 | |
| ... | @@ -1668,8 +1670,8 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A | ... | @@ -1668,8 +1670,8 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A |
| 1668 | IrInstruction *ptr, IrInstruction *value) | 1670 | IrInstruction *ptr, IrInstruction *value) |
| 1669 | { | 1671 | { |
| 1670 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); | 1672 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); |
| 1671 | instruction->base.value.special = ConstValSpecialStatic; | 1673 | instruction->base.value->special = ConstValSpecialStatic; |
| 1672 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1674 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1673 | instruction->ptr = ptr; | 1675 | instruction->ptr = ptr; |
| 1674 | instruction->value = value; | 1676 | instruction->value = value; |
| 1675 | | 1677 | |
| ... | @@ -1684,7 +1686,7 @@ static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction * | ... | @@ -1684,7 +1686,7 @@ static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction * |
| 1684 | { | 1686 | { |
| 1685 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( | 1687 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( |
| 1686 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1688 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1687 | inst->base.value.type = ira->codegen->builtin_types.entry_void; | 1689 | inst->base.value->type = ira->codegen->builtin_types.entry_void; |
| 1688 | inst->vector_ptr = vector_ptr; | 1690 | inst->vector_ptr = vector_ptr; |
| 1689 | inst->index = index; | 1691 | inst->index = index; |
| 1690 | inst->value = value; | 1692 | inst->value = value; |
| ... | @@ -1700,8 +1702,8 @@ static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -1700,8 +1702,8 @@ static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNod |
| 1700 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) | 1702 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) |
| 1701 | { | 1703 | { |
| 1702 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); | 1704 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); |
| 1703 | decl_var_instruction->base.value.special = ConstValSpecialStatic; | 1705 | decl_var_instruction->base.value->special = ConstValSpecialStatic; |
| 1704 | decl_var_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1706 | decl_var_instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1705 | decl_var_instruction->var = var; | 1707 | decl_var_instruction->var = var; |
| 1706 | decl_var_instruction->align_value = align_value; | 1708 | decl_var_instruction->align_value = align_value; |
| 1707 | decl_var_instruction->ptr = ptr; | 1709 | decl_var_instruction->ptr = ptr; |
| ... | @@ -1717,8 +1719,8 @@ static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -1717,8 +1719,8 @@ static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *sourc |
| 1717 | { | 1719 | { |
| 1718 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, | 1720 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, |
| 1719 | source_instruction->scope, source_instruction->source_node); | 1721 | source_instruction->scope, source_instruction->source_node); |
| 1720 | decl_var_instruction->base.value.special = ConstValSpecialStatic; | 1722 | decl_var_instruction->base.value->special = ConstValSpecialStatic; |
| 1721 | decl_var_instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 1723 | decl_var_instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 1722 | decl_var_instruction->var = var; | 1724 | decl_var_instruction->var = var; |
| 1723 | decl_var_instruction->var_ptr = var_ptr; | 1725 | decl_var_instruction->var_ptr = var_ptr; |
| 1724 | | 1726 | |
| ... | @@ -1732,7 +1734,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -1732,7 +1734,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc |
| 1732 | { | 1734 | { |
| 1733 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, | 1735 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, |
| 1734 | source_instruction->scope, source_instruction->source_node); | 1736 | source_instruction->scope, source_instruction->source_node); |
| 1735 | instruction->base.value.type = ty; | 1737 | instruction->base.value->type = ty; |
| 1736 | instruction->operand = operand; | 1738 | instruction->operand = operand; |
| 1737 | instruction->result_loc = result_loc; | 1739 | instruction->result_loc = result_loc; |
| 1738 | | 1740 | |
| ... | @@ -1747,8 +1749,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -1747,8 +1749,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou |
| 1747 | { | 1749 | { |
| 1748 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( | 1750 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( |
| 1749 | irb, scope, source_node); | 1751 | irb, scope, source_node); |
| 1750 | export_instruction->base.value.special = ConstValSpecialStatic; | 1752 | export_instruction->base.value->special = ConstValSpecialStatic; |
| 1751 | export_instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 1753 | export_instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 1752 | export_instruction->name = name; | 1754 | export_instruction->name = name; |
| 1753 | export_instruction->target = target; | 1755 | export_instruction->target = target; |
| 1754 | export_instruction->linkage = linkage; | 1756 | export_instruction->linkage = linkage; |
| ... | @@ -1925,7 +1927,7 @@ static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *sour | ... | @@ -1925,7 +1927,7 @@ static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *sour |
| 1925 | { | 1927 | { |
| 1926 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( | 1928 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( |
| 1927 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1929 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1928 | instruction->base.value.type = result_ty; | 1930 | instruction->base.value->type = result_ty; |
| 1929 | instruction->operand = operand; | 1931 | instruction->operand = operand; |
| 1930 | instruction->result_loc = result_loc; | 1932 | instruction->result_loc = result_loc; |
| 1931 | | 1933 | |
| ... | @@ -1940,7 +1942,7 @@ static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *s | ... | @@ -1940,7 +1942,7 @@ static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *s |
| 1940 | { | 1942 | { |
| 1941 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( | 1943 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( |
| 1942 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1944 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1943 | instruction->base.value.type = result_type; | 1945 | instruction->base.value->type = result_type; |
| 1944 | instruction->operand = operand; | 1946 | instruction->operand = operand; |
| 1945 | instruction->result_loc = result_loc; | 1947 | instruction->result_loc = result_loc; |
| 1946 | | 1948 | |
| ... | @@ -1955,7 +1957,7 @@ static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *sour | ... | @@ -1955,7 +1957,7 @@ static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *sour |
| 1955 | { | 1957 | { |
| 1956 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( | 1958 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( |
| 1957 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 1959 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 1958 | instruction->base.value.type = result_type; | 1960 | instruction->base.value->type = result_type; |
| 1959 | instruction->operand = operand; | 1961 | instruction->operand = operand; |
| 1960 | instruction->result_loc = result_loc; | 1962 | instruction->result_loc = result_loc; |
| 1961 | | 1963 | |
| ... | @@ -2025,8 +2027,8 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2025,8 +2027,8 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2025 | IrInstruction *switch_prongs_void) | 2027 | IrInstruction *switch_prongs_void) |
| 2026 | { | 2028 | { |
| 2027 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); | 2029 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); |
| 2028 | instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 2030 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 2029 | instruction->base.value.special = ConstValSpecialStatic; | 2031 | instruction->base.value->special = ConstValSpecialStatic; |
| 2030 | instruction->target_value = target_value; | 2032 | instruction->target_value = target_value; |
| 2031 | instruction->else_block = else_block; | 2033 | instruction->else_block = else_block; |
| 2032 | instruction->case_count = case_count; | 2034 | instruction->case_count = case_count; |
| ... | @@ -2122,7 +2124,7 @@ static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -2122,7 +2124,7 @@ static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_ins |
| 2122 | { | 2124 | { |
| 2123 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, | 2125 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, |
| 2124 | source_instruction->scope, source_instruction->source_node); | 2126 | source_instruction->scope, source_instruction->source_node); |
| 2125 | instruction->base.value.type = result_type; | 2127 | instruction->base.value->type = result_type; |
| 2126 | instruction->operand = operand; | 2128 | instruction->operand = operand; |
| 2127 | instruction->result_loc = result_loc; | 2129 | instruction->result_loc = result_loc; |
| 2128 | | 2130 | |
| ... | @@ -2237,7 +2239,7 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source | ... | @@ -2237,7 +2239,7 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source |
| 2237 | { | 2239 | { |
| 2238 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, | 2240 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, |
| 2239 | source_instruction->scope, source_instruction->source_node); | 2241 | source_instruction->scope, source_instruction->source_node); |
| 2240 | instruction->base.value.type = result_type; | 2242 | instruction->base.value->type = result_type; |
| 2241 | instruction->ptr = ptr; | 2243 | instruction->ptr = ptr; |
| 2242 | instruction->cmp_value = cmp_value; | 2244 | instruction->cmp_value = cmp_value; |
| 2243 | instruction->new_value = new_value; | 2245 | instruction->new_value = new_value; |
| ... | @@ -2482,7 +2484,7 @@ static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -2482,7 +2484,7 @@ static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_i |
| 2482 | { | 2484 | { |
| 2483 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( | 2485 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( |
| 2484 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2486 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2485 | instruction->base.value.type = result_type; | 2487 | instruction->base.value->type = result_type; |
| 2486 | instruction->scalar = scalar; | 2488 | instruction->scalar = scalar; |
| 2487 | | 2489 | |
| 2488 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); | 2490 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); |
| ... | @@ -2495,7 +2497,7 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -2495,7 +2497,7 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i |
| 2495 | { | 2497 | { |
| 2496 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( | 2498 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( |
| 2497 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2499 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2498 | instruction->base.value.type = slice_type; | 2500 | instruction->base.value->type = slice_type; |
| 2499 | instruction->ptr = ptr; | 2501 | instruction->ptr = ptr; |
| 2500 | instruction->start = start; | 2502 | instruction->start = start; |
| 2501 | instruction->end = end; | 2503 | instruction->end = end; |
| ... | @@ -2709,7 +2711,7 @@ static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2709,7 +2711,7 @@ static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2709 | { | 2711 | { |
| 2710 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( | 2712 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( |
| 2711 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2713 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2712 | instruction->base.value.type = ira->codegen->builtin_types.entry_bool; | 2714 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 2713 | instruction->err_union = err_union; | 2715 | instruction->err_union = err_union; |
| 2714 | | 2716 | |
| 2715 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); | 2717 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); |
| ... | @@ -2792,7 +2794,7 @@ static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2792,7 +2794,7 @@ static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2792 | { | 2794 | { |
| 2793 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( | 2795 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( |
| 2794 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2796 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2795 | instruction->base.value.type = ptr_type; | 2797 | instruction->base.value->type = ptr_type; |
| 2796 | instruction->ptr = ptr; | 2798 | instruction->ptr = ptr; |
| 2797 | instruction->safety_check_on = safety_check_on; | 2799 | instruction->safety_check_on = safety_check_on; |
| 2798 | | 2800 | |
| ... | @@ -2806,7 +2808,7 @@ static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2806,7 +2808,7 @@ static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2806 | { | 2808 | { |
| 2807 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( | 2809 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( |
| 2808 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2810 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2809 | instruction->base.value.type = ty; | 2811 | instruction->base.value->type = ty; |
| 2810 | instruction->ptr = ptr; | 2812 | instruction->ptr = ptr; |
| 2811 | instruction->result_loc = result_loc; | 2813 | instruction->result_loc = result_loc; |
| 2812 | | 2814 | |
| ... | @@ -2845,7 +2847,7 @@ static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -2845,7 +2847,7 @@ static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *sourc |
| 2845 | { | 2847 | { |
| 2846 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( | 2848 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( |
| 2847 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2849 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2848 | instruction->base.value.type = ty; | 2850 | instruction->base.value->type = ty; |
| 2849 | instruction->operand = operand; | 2851 | instruction->operand = operand; |
| 2850 | | 2852 | |
| 2851 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 2853 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); |
| ... | @@ -2997,8 +2999,8 @@ static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2997,8 +2999,8 @@ static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *s |
| 2997 | | 2999 | |
| 2998 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 3000 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { |
| 2999 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); | 3001 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); |
| 3000 | instruction->base.value.special = ConstValSpecialStatic; | 3002 | instruction->base.value->special = ConstValSpecialStatic; |
| 3001 | instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; | 3003 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; |
| 3002 | instruction->msg = msg; | 3004 | instruction->msg = msg; |
| 3003 | | 3005 | |
| 3004 | ir_ref_instruction(msg, irb->current_basic_block); | 3006 | ir_ref_instruction(msg, irb->current_basic_block); |
| ... | @@ -3328,7 +3330,7 @@ static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *so | ... | @@ -3328,7 +3330,7 @@ static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *so |
| 3328 | { | 3330 | { |
| 3329 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, | 3331 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, |
| 3330 | source_instruction->scope, source_instruction->source_node); | 3332 | source_instruction->scope, source_instruction->source_node); |
| 3331 | instruction->base.value.type = result_type; | 3333 | instruction->base.value->type = result_type; |
| 3332 | instruction->vector = vector; | 3334 | instruction->vector = vector; |
| 3333 | instruction->result_loc = result_loc; | 3335 | instruction->result_loc = result_loc; |
| 3334 | | 3336 | |
| ... | @@ -3343,7 +3345,7 @@ static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstructi | ... | @@ -3343,7 +3345,7 @@ static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstructi |
| 3343 | { | 3345 | { |
| 3344 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, | 3346 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, |
| 3345 | source_instruction->scope, source_instruction->source_node); | 3347 | source_instruction->scope, source_instruction->source_node); |
| 3346 | instruction->base.value.type = result_type; | 3348 | instruction->base.value->type = result_type; |
| 3347 | instruction->operand = operand; | 3349 | instruction->operand = operand; |
| 3348 | instruction->result_loc = result_loc; | 3350 | instruction->result_loc = result_loc; |
| 3349 | | 3351 | |
| ... | @@ -3358,7 +3360,7 @@ static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *so | ... | @@ -3358,7 +3360,7 @@ static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *so |
| 3358 | { | 3360 | { |
| 3359 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, | 3361 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, |
| 3360 | source_instruction->scope, source_instruction->source_node); | 3362 | source_instruction->scope, source_instruction->source_node); |
| 3361 | instruction->base.value.type = result_type; | 3363 | instruction->base.value->type = result_type; |
| 3362 | instruction->array = array; | 3364 | instruction->array = array; |
| 3363 | | 3365 | |
| 3364 | ir_ref_instruction(array, ira->new_irb.current_basic_block); | 3366 | ir_ref_instruction(array, ira->new_irb.current_basic_block); |
| ... | @@ -3371,7 +3373,7 @@ static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source | ... | @@ -3371,7 +3373,7 @@ static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source |
| 3371 | { | 3373 | { |
| 3372 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, | 3374 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, |
| 3373 | source_instruction->scope, source_instruction->source_node); | 3375 | source_instruction->scope, source_instruction->source_node); |
| 3374 | instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 3376 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3375 | instruction->target = target; | 3377 | instruction->target = target; |
| 3376 | | 3378 | |
| 3377 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 3379 | ir_ref_instruction(target, ira->new_irb.current_basic_block); |
| ... | @@ -3384,7 +3386,7 @@ static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -3384,7 +3386,7 @@ static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *so |
| 3384 | { | 3386 | { |
| 3385 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, | 3387 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, |
| 3386 | source_instruction->scope, source_instruction->source_node); | 3388 | source_instruction->scope, source_instruction->source_node); |
| 3387 | instruction->base.value.type = ira->codegen->builtin_types.entry_void; | 3389 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3388 | instruction->target = target; | 3390 | instruction->target = target; |
| 3389 | | 3391 | |
| 3390 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 3392 | ir_ref_instruction(target, ira->new_irb.current_basic_block); |
| ... | @@ -3433,7 +3435,7 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3433,7 +3435,7 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s |
| 3433 | | 3435 | |
| 3434 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3436 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 3435 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); | 3437 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); |
| 3436 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3438 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3437 | | 3439 | |
| 3438 | return instruction; | 3440 | return instruction; |
| 3439 | } | 3441 | } |
| ... | @@ -3442,7 +3444,7 @@ static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3442,7 +3444,7 @@ static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstN |
| 3442 | IrInstructionSuspendBegin *begin) | 3444 | IrInstructionSuspendBegin *begin) |
| 3443 | { | 3445 | { |
| 3444 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); | 3446 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); |
| 3445 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3447 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3446 | instruction->begin = begin; | 3448 | instruction->begin = begin; |
| 3447 | | 3449 | |
| 3448 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 3450 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| ... | @@ -3467,7 +3469,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * | ... | @@ -3467,7 +3469,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * |
| 3467 | { | 3469 | { |
| 3468 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, | 3470 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, |
| 3469 | source_instruction->scope, source_instruction->source_node); | 3471 | source_instruction->scope, source_instruction->source_node); |
| 3470 | instruction->base.value.type = result_type; | 3472 | instruction->base.value->type = result_type; |
| 3471 | instruction->frame = frame; | 3473 | instruction->frame = frame; |
| 3472 | instruction->result_loc = result_loc; | 3474 | instruction->result_loc = result_loc; |
| 3473 | | 3475 | |
| ... | @@ -3479,7 +3481,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * | ... | @@ -3479,7 +3481,7 @@ static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction * |
| 3479 | | 3481 | |
| 3480 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { | 3482 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { |
| 3481 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); | 3483 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); |
| 3482 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3484 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3483 | instruction->frame = frame; | 3485 | instruction->frame = frame; |
| 3484 | | 3486 | |
| 3485 | ir_ref_instruction(frame, irb->current_basic_block); | 3487 | ir_ref_instruction(frame, irb->current_basic_block); |
| ... | @@ -3491,8 +3493,8 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop | ... | @@ -3491,8 +3493,8 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop |
| 3491 | IrInstruction *operand, SpillId spill_id) | 3493 | IrInstruction *operand, SpillId spill_id) |
| 3492 | { | 3494 | { |
| 3493 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); | 3495 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); |
| 3494 | instruction->base.value.special = ConstValSpecialStatic; | 3496 | instruction->base.value->special = ConstValSpecialStatic; |
| 3495 | instruction->base.value.type = irb->codegen->builtin_types.entry_void; | 3497 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; |
| 3496 | instruction->operand = operand; | 3498 | instruction->operand = operand; |
| 3497 | instruction->spill_id = spill_id; | 3499 | instruction->spill_id = spill_id; |
| 3498 | | 3500 | |
| ... | @@ -3517,7 +3519,7 @@ static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction | ... | @@ -3517,7 +3519,7 @@ static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction |
| 3517 | { | 3519 | { |
| 3518 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( | 3520 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( |
| 3519 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3521 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3520 | instruction->base.value.type = vector->value.type->data.vector.elem_type; | 3522 | instruction->base.value->type = vector->value->type->data.vector.elem_type; |
| 3521 | instruction->vector = vector; | 3523 | instruction->vector = vector; |
| 3522 | instruction->index = index; | 3524 | instruction->index = index; |
| 3523 | | 3525 | |
| ... | @@ -3588,8 +3590,8 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -3588,8 +3590,8 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 3588 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; | 3590 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; |
| 3589 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); | 3591 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); |
| 3590 | if (defer_expr_value != irb->codegen->invalid_instruction) { | 3592 | if (defer_expr_value != irb->codegen->invalid_instruction) { |
| 3591 | if (defer_expr_value->value.type != nullptr && | 3593 | if (defer_expr_value->value->type != nullptr && |
| 3592 | defer_expr_value->value.type->id == ZigTypeIdUnreachable) | 3594 | defer_expr_value->value->type->id == ZigTypeIdUnreachable) |
| 3593 | { | 3595 | { |
| 3594 | is_noreturn = true; | 3596 | is_noreturn = true; |
| 3595 | } else { | 3597 | } else { |
| ... | @@ -4411,7 +4413,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode | ... | @@ -4411,7 +4413,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 4411 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); | 4413 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); |
| 4412 | tld_var->base.resolution = TldResolutionInvalid; | 4414 | tld_var->base.resolution = TldResolutionInvalid; |
| 4413 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, | 4415 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, |
| 4414 | &g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid); | 4416 | g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid); |
| 4415 | scope_decls->decl_table.put(var_name, &tld_var->base); | 4417 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 4416 | } | 4418 | } |
| 4417 | | 4419 | |
| ... | @@ -4424,10 +4426,10 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4424,10 +4426,10 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4424 | if (buf_eql_str(variable_name, "_")) { | 4426 | if (buf_eql_str(variable_name, "_")) { |
| 4425 | if (lval == LValPtr) { | 4427 | if (lval == LValPtr) { |
| 4426 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); | 4428 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); |
| 4427 | const_instruction->base.value.type = get_pointer_to_type(irb->codegen, | 4429 | const_instruction->base.value->type = get_pointer_to_type(irb->codegen, |
| 4428 | irb->codegen->builtin_types.entry_void, false); | 4430 | irb->codegen->builtin_types.entry_void, false); |
| 4429 | const_instruction->base.value.special = ConstValSpecialStatic; | 4431 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 4430 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialDiscard; | 4432 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialDiscard; |
| 4431 | return &const_instruction->base; | 4433 | return &const_instruction->base; |
| 4432 | } else { | 4434 | } else { |
| 4433 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); | 4435 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); |
| ... | @@ -8747,12 +8749,12 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { | ... | @@ -8747,12 +8749,12 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { |
| 8747 | if (instruction->id == IrInstructionIdReturn) { | 8749 | if (instruction->id == IrInstructionIdReturn) { |
| 8748 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; | 8750 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; |
| 8749 | IrInstruction *operand = ret_inst->operand; | 8751 | IrInstruction *operand = ret_inst->operand; |
| 8750 | if (operand->value.special == ConstValSpecialRuntime) { | 8752 | if (operand->value->special == ConstValSpecialRuntime) { |
| 8751 | exec_add_error_node(codegen, exec, operand->source_node, | 8753 | exec_add_error_node(codegen, exec, operand->source_node, |
| 8752 | buf_sprintf("unable to evaluate constant expression")); | 8754 | buf_sprintf("unable to evaluate constant expression")); |
| 8753 | return &codegen->invalid_instruction->value; | 8755 | return codegen->invalid_instruction->value; |
| 8754 | } | 8756 | } |
| 8755 | return &operand->value; | 8757 | return operand->value; |
| 8756 | } else if (ir_has_side_effects(instruction)) { | 8758 | } else if (ir_has_side_effects(instruction)) { |
| 8757 | if (instr_is_comptime(instruction)) { | 8759 | if (instr_is_comptime(instruction)) { |
| 8758 | switch (instruction->id) { | 8760 | switch (instruction->id) { |
| ... | @@ -8769,7 +8771,7 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { | ... | @@ -8769,7 +8771,7 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { |
| 8769 | } | 8771 | } |
| 8770 | exec_add_error_node(codegen, exec, instruction->source_node, | 8772 | exec_add_error_node(codegen, exec, instruction->source_node, |
| 8771 | buf_sprintf("unable to evaluate constant expression")); | 8773 | buf_sprintf("unable to evaluate constant expression")); |
| 8772 | return &codegen->invalid_instruction->value; | 8774 | return codegen->invalid_instruction->value; |
| 8773 | } | 8775 | } |
| 8774 | } | 8776 | } |
| 8775 | zig_unreachable(); | 8777 | zig_unreachable(); |
| ... | @@ -10217,13 +10219,13 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10217,13 +10219,13 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10217 | size_t i = 0; | 10219 | size_t i = 0; |
| 10218 | for (;;) { | 10220 | for (;;) { |
| 10219 | prev_inst = instructions[i]; | 10221 | prev_inst = instructions[i]; |
| 10220 | if (type_is_invalid(prev_inst->value.type)) { | 10222 | if (type_is_invalid(prev_inst->value->type)) { |
| 10221 | return ira->codegen->builtin_types.entry_invalid; | 10223 | return ira->codegen->builtin_types.entry_invalid; |
| 10222 | } | 10224 | } |
| 10223 | if (prev_inst->value.type->id == ZigTypeIdUnreachable) { | 10225 | if (prev_inst->value->type->id == ZigTypeIdUnreachable) { |
| 10224 | i += 1; | 10226 | i += 1; |
| 10225 | if (i == instruction_count) { | 10227 | if (i == instruction_count) { |
| 10226 | return prev_inst->value.type; | 10228 | return prev_inst->value->type; |
| 10227 | } | 10229 | } |
| 10228 | continue; | 10230 | continue; |
| 10229 | } | 10231 | } |
| ... | @@ -10232,14 +10234,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10232,14 +10234,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10232 | ErrorTableEntry **errors = nullptr; | 10234 | ErrorTableEntry **errors = nullptr; |
| 10233 | size_t errors_count = 0; | 10235 | size_t errors_count = 0; |
| 10234 | ZigType *err_set_type = nullptr; | 10236 | ZigType *err_set_type = nullptr; |
| 10235 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { | 10237 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10236 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value.type, prev_inst->source_node)) { | 10238 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->source_node)) { |
| 10237 | return ira->codegen->builtin_types.entry_invalid; | 10239 | return ira->codegen->builtin_types.entry_invalid; |
| 10238 | } | 10240 | } |
| 10239 | if (type_is_global_error_set(prev_inst->value.type)) { | 10241 | if (type_is_global_error_set(prev_inst->value->type)) { |
| 10240 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; | 10242 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; |
| 10241 | } else { | 10243 | } else { |
| 10242 | err_set_type = prev_inst->value.type; | 10244 | err_set_type = prev_inst->value->type; |
| 10243 | update_errors_helper(ira->codegen, &errors, &errors_count); | 10245 | update_errors_helper(ira->codegen, &errors, &errors_count); |
| 10244 | | 10246 | |
| 10245 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { | 10247 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { |
| ... | @@ -10250,12 +10252,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10250,12 +10252,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10250 | } | 10252 | } |
| 10251 | } | 10253 | } |
| 10252 | | 10254 | |
| 10253 | bool any_are_null = (prev_inst->value.type->id == ZigTypeIdNull); | 10255 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); |
| 10254 | bool convert_to_const_slice = false; | 10256 | bool convert_to_const_slice = false; |
| 10255 | for (; i < instruction_count; i += 1) { | 10257 | for (; i < instruction_count; i += 1) { |
| 10256 | IrInstruction *cur_inst = instructions[i]; | 10258 | IrInstruction *cur_inst = instructions[i]; |
| 10257 | ZigType *cur_type = cur_inst->value.type; | 10259 | ZigType *cur_type = cur_inst->value->type; |
| 10258 | ZigType *prev_type = prev_inst->value.type; | 10260 | ZigType *prev_type = prev_inst->value->type; |
| 10259 | | 10261 | |
| 10260 | if (type_is_invalid(cur_type)) { | 10262 | if (type_is_invalid(cur_type)) { |
| 10261 | return cur_type; | 10263 | return cur_type; |
| ... | @@ -10559,20 +10561,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10559,20 +10561,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10559 | } | 10561 | } |
| 10560 | | 10562 | |
| 10561 | if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdEnumLiteral) { | 10563 | if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdEnumLiteral) { |
| 10562 | TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value.data.x_enum_literal); | 10564 | TypeEnumField *field = find_enum_type_field(prev_type, cur_inst->value->data.x_enum_literal); |
| 10563 | if (field != nullptr) { | 10565 | if (field != nullptr) { |
| 10564 | continue; | 10566 | continue; |
| 10565 | } | 10567 | } |
| 10566 | } | 10568 | } |
| 10567 | if (is_tagged_union(prev_type) && cur_type->id == ZigTypeIdEnumLiteral) { | 10569 | if (is_tagged_union(prev_type) && cur_type->id == ZigTypeIdEnumLiteral) { |
| 10568 | TypeUnionField *field = find_union_type_field(prev_type, cur_inst->value.data.x_enum_literal); | 10570 | TypeUnionField *field = find_union_type_field(prev_type, cur_inst->value->data.x_enum_literal); |
| 10569 | if (field != nullptr) { | 10571 | if (field != nullptr) { |
| 10570 | continue; | 10572 | continue; |
| 10571 | } | 10573 | } |
| 10572 | } | 10574 | } |
| 10573 | | 10575 | |
| 10574 | if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdEnumLiteral) { | 10576 | if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdEnumLiteral) { |
| 10575 | TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value.data.x_enum_literal); | 10577 | TypeEnumField *field = find_enum_type_field(cur_type, prev_inst->value->data.x_enum_literal); |
| 10576 | if (field != nullptr) { | 10578 | if (field != nullptr) { |
| 10577 | prev_inst = cur_inst; | 10579 | prev_inst = cur_inst; |
| 10578 | continue; | 10580 | continue; |
| ... | @@ -10580,7 +10582,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10580,7 +10582,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10580 | } | 10582 | } |
| 10581 | | 10583 | |
| 10582 | if (is_tagged_union(cur_type) && prev_type->id == ZigTypeIdEnumLiteral) { | 10584 | if (is_tagged_union(cur_type) && prev_type->id == ZigTypeIdEnumLiteral) { |
| 10583 | TypeUnionField *field = find_union_type_field(cur_type, prev_inst->value.data.x_enum_literal); | 10585 | TypeUnionField *field = find_union_type_field(cur_type, prev_inst->value->data.x_enum_literal); |
| 10584 | if (field != nullptr) { | 10586 | if (field != nullptr) { |
| 10585 | prev_inst = cur_inst; | 10587 | prev_inst = cur_inst; |
| 10586 | continue; | 10588 | continue; |
| ... | @@ -10906,9 +10908,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10906,9 +10908,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10906 | free(errors); | 10908 | free(errors); |
| 10907 | | 10909 | |
| 10908 | if (convert_to_const_slice) { | 10910 | if (convert_to_const_slice) { |
| 10909 | if (prev_inst->value.type->id == ZigTypeIdArray) { | 10911 | if (prev_inst->value->type->id == ZigTypeIdArray) { |
| 10910 | ZigType *ptr_type = get_pointer_to_type_extra( | 10912 | ZigType *ptr_type = get_pointer_to_type_extra( |
| 10911 | ira->codegen, prev_inst->value.type->data.array.child_type, | 10913 | ira->codegen, prev_inst->value->type->data.array.child_type, |
| 10912 | true, false, PtrLenUnknown, | 10914 | true, false, PtrLenUnknown, |
| 10913 | 0, 0, 0, false); | 10915 | 0, 0, 0, false); |
| 10914 | ZigType *slice_type = get_slice_type(ira->codegen, ptr_type); | 10916 | ZigType *slice_type = get_slice_type(ira->codegen, ptr_type); |
| ... | @@ -10917,12 +10919,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10917,12 +10919,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10917 | } else { | 10919 | } else { |
| 10918 | return slice_type; | 10920 | return slice_type; |
| 10919 | } | 10921 | } |
| 10920 | } else if (prev_inst->value.type->id == ZigTypeIdPointer) { | 10922 | } else if (prev_inst->value->type->id == ZigTypeIdPointer) { |
| 10921 | ZigType *array_type = prev_inst->value.type->data.pointer.child_type; | 10923 | ZigType *array_type = prev_inst->value->type->data.pointer.child_type; |
| 10922 | src_assert(array_type->id == ZigTypeIdArray, source_node); | 10924 | src_assert(array_type->id == ZigTypeIdArray, source_node); |
| 10923 | ZigType *ptr_type = get_pointer_to_type_extra2( | 10925 | ZigType *ptr_type = get_pointer_to_type_extra2( |
| 10924 | ira->codegen, array_type->data.array.child_type, | 10926 | ira->codegen, array_type->data.array.child_type, |
| 10925 | prev_inst->value.type->data.pointer.is_const, false, | 10927 | prev_inst->value->type->data.pointer.is_const, false, |
| 10926 | PtrLenUnknown, | 10928 | PtrLenUnknown, |
| 10927 | 0, 0, 0, false, | 10929 | 0, 0, 0, false, |
| 10928 | VECTOR_INDEX_NONE, nullptr, array_type->data.array.sentinel); | 10930 | VECTOR_INDEX_NONE, nullptr, array_type->data.array.sentinel); |
| ... | @@ -10936,10 +10938,10 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10936,10 +10938,10 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10936 | zig_unreachable(); | 10938 | zig_unreachable(); |
| 10937 | } | 10939 | } |
| 10938 | } else if (err_set_type != nullptr) { | 10940 | } else if (err_set_type != nullptr) { |
| 10939 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { | 10941 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10940 | return err_set_type; | 10942 | return err_set_type; |
| 10941 | } else if (prev_inst->value.type->id == ZigTypeIdErrorUnion) { | 10943 | } else if (prev_inst->value->type->id == ZigTypeIdErrorUnion) { |
| 10942 | ZigType *payload_type = prev_inst->value.type->data.error_union.payload_type; | 10944 | ZigType *payload_type = prev_inst->value->type->data.error_union.payload_type; |
| 10943 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) | 10945 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) |
| 10944 | return ira->codegen->builtin_types.entry_invalid; | 10946 | return ira->codegen->builtin_types.entry_invalid; |
| 10945 | return get_error_union_type(ira->codegen, err_set_type, payload_type); | 10947 | return get_error_union_type(ira->codegen, err_set_type, payload_type); |
| ... | @@ -10949,38 +10951,38 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10949,38 +10951,38 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10949 | return ira->codegen->builtin_types.entry_invalid; | 10951 | return ira->codegen->builtin_types.entry_invalid; |
| 10950 | return get_error_union_type(ira->codegen, err_set_type, payload_type); | 10952 | return get_error_union_type(ira->codegen, err_set_type, payload_type); |
| 10951 | } else { | 10953 | } else { |
| 10952 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || | 10954 | if (prev_inst->value->type->id == ZigTypeIdComptimeInt || |
| 10953 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) | 10955 | prev_inst->value->type->id == ZigTypeIdComptimeFloat) |
| 10954 | { | 10956 | { |
| 10955 | ir_add_error_node(ira, source_node, | 10957 | ir_add_error_node(ira, source_node, |
| 10956 | buf_sprintf("unable to make error union out of number literal")); | 10958 | buf_sprintf("unable to make error union out of number literal")); |
| 10957 | return ira->codegen->builtin_types.entry_invalid; | 10959 | return ira->codegen->builtin_types.entry_invalid; |
| 10958 | } else if (prev_inst->value.type->id == ZigTypeIdNull) { | 10960 | } else if (prev_inst->value->type->id == ZigTypeIdNull) { |
| 10959 | ir_add_error_node(ira, source_node, | 10961 | ir_add_error_node(ira, source_node, |
| 10960 | buf_sprintf("unable to make error union out of null literal")); | 10962 | buf_sprintf("unable to make error union out of null literal")); |
| 10961 | return ira->codegen->builtin_types.entry_invalid; | 10963 | return ira->codegen->builtin_types.entry_invalid; |
| 10962 | } else { | 10964 | } else { |
| 10963 | if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown))) | 10965 | if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown))) |
| 10964 | return ira->codegen->builtin_types.entry_invalid; | 10966 | return ira->codegen->builtin_types.entry_invalid; |
| 10965 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type); | 10967 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value->type); |
| 10966 | } | 10968 | } |
| 10967 | } | 10969 | } |
| 10968 | } else if (any_are_null && prev_inst->value.type->id != ZigTypeIdNull) { | 10970 | } else if (any_are_null && prev_inst->value->type->id != ZigTypeIdNull) { |
| 10969 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || | 10971 | if (prev_inst->value->type->id == ZigTypeIdComptimeInt || |
| 10970 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) | 10972 | prev_inst->value->type->id == ZigTypeIdComptimeFloat) |
| 10971 | { | 10973 | { |
| 10972 | ir_add_error_node(ira, source_node, | 10974 | ir_add_error_node(ira, source_node, |
| 10973 | buf_sprintf("unable to make maybe out of number literal")); | 10975 | buf_sprintf("unable to make maybe out of number literal")); |
| 10974 | return ira->codegen->builtin_types.entry_invalid; | 10976 | return ira->codegen->builtin_types.entry_invalid; |
| 10975 | } else if (prev_inst->value.type->id == ZigTypeIdOptional) { | 10977 | } else if (prev_inst->value->type->id == ZigTypeIdOptional) { |
| 10976 | return prev_inst->value.type; | 10978 | return prev_inst->value->type; |
| 10977 | } else { | 10979 | } else { |
| 10978 | if ((err = type_resolve(ira->codegen, prev_inst->value.type, ResolveStatusSizeKnown))) | 10980 | if ((err = type_resolve(ira->codegen, prev_inst->value->type, ResolveStatusSizeKnown))) |
| 10979 | return ira->codegen->builtin_types.entry_invalid; | 10981 | return ira->codegen->builtin_types.entry_invalid; |
| 10980 | return get_optional_type(ira->codegen, prev_inst->value.type); | 10982 | return get_optional_type(ira->codegen, prev_inst->value->type); |
| 10981 | } | 10983 | } |
| 10982 | } else { | 10984 | } else { |
| 10983 | return prev_inst->value.type; | 10985 | return prev_inst->value->type; |
| 10984 | } | 10986 | } |
| 10985 | } | 10987 | } |
| 10986 | | 10988 | |
| ... | @@ -11106,8 +11108,8 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z | ... | @@ -11106,8 +11108,8 @@ static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, Z |
| 11106 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11108 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11107 | old_instruction->scope, old_instruction->source_node); | 11109 | old_instruction->scope, old_instruction->source_node); |
| 11108 | IrInstruction *new_instruction = &const_instruction->base; | 11110 | IrInstruction *new_instruction = &const_instruction->base; |
| 11109 | new_instruction->value.type = ty; | 11111 | new_instruction->value->type = ty; |
| 11110 | new_instruction->value.special = ConstValSpecialStatic; | 11112 | new_instruction->value->special = ConstValSpecialStatic; |
| 11111 | return new_instruction; | 11113 | return new_instruction; |
| 11112 | } | 11114 | } |
| 11113 | | 11115 | |
| ... | @@ -11116,15 +11118,15 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11116,15 +11118,15 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11116 | { | 11118 | { |
| 11117 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { | 11119 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { |
| 11118 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11120 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11119 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, &value->value, value->value.type, | 11121 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, |
| 11120 | &result->value, wanted_type)) | 11122 | result->value, wanted_type)) |
| 11121 | { | 11123 | { |
| 11122 | return ira->codegen->invalid_instruction; | 11124 | return ira->codegen->invalid_instruction; |
| 11123 | } | 11125 | } |
| 11124 | return result; | 11126 | return result; |
| 11125 | } else { | 11127 | } else { |
| 11126 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); | 11128 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); |
| 11127 | result->value.type = wanted_type; | 11129 | result->value->type = wanted_type; |
| 11128 | return result; | 11130 | return result; |
| 11129 | } | 11131 | } |
| 11130 | } | 11132 | } |
| ... | @@ -11132,35 +11134,35 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11132,35 +11134,35 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11132 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 11134 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, |
| 11133 | IrInstruction *value, ZigType *wanted_type) | 11135 | IrInstruction *value, ZigType *wanted_type) |
| 11134 | { | 11136 | { |
| 11135 | assert(value->value.type->id == ZigTypeIdPointer); | 11137 | assert(value->value->type->id == ZigTypeIdPointer); |
| 11136 | | 11138 | |
| 11137 | Error err; | 11139 | Error err; |
| 11138 | | 11140 | |
| 11139 | if ((err = type_resolve(ira->codegen, value->value.type->data.pointer.child_type, | 11141 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, |
| 11140 | ResolveStatusAlignmentKnown))) | 11142 | ResolveStatusAlignmentKnown))) |
| 11141 | { | 11143 | { |
| 11142 | return ira->codegen->invalid_instruction; | 11144 | return ira->codegen->invalid_instruction; |
| 11143 | } | 11145 | } |
| 11144 | | 11146 | |
| 11145 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value.type)); | 11147 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); |
| 11146 | | 11148 | |
| 11147 | if (instr_is_comptime(value)) { | 11149 | if (instr_is_comptime(value)) { |
| 11148 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &value->value, source_instr->source_node); | 11150 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); |
| 11149 | if (pointee == nullptr) | 11151 | if (pointee == nullptr) |
| 11150 | return ira->codegen->invalid_instruction; | 11152 | return ira->codegen->invalid_instruction; |
| 11151 | if (pointee->special != ConstValSpecialRuntime) { | 11153 | if (pointee->special != ConstValSpecialRuntime) { |
| 11152 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11154 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11153 | result->value.data.x_ptr.special = ConstPtrSpecialBaseArray; | 11155 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 11154 | result->value.data.x_ptr.mut = value->value.data.x_ptr.mut; | 11156 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; |
| 11155 | result->value.data.x_ptr.data.base_array.array_val = pointee; | 11157 | result->value->data.x_ptr.data.base_array.array_val = pointee; |
| 11156 | result->value.data.x_ptr.data.base_array.elem_index = 0; | 11158 | result->value->data.x_ptr.data.base_array.elem_index = 0; |
| 11157 | return result; | 11159 | return result; |
| 11158 | } | 11160 | } |
| 11159 | } | 11161 | } |
| 11160 | | 11162 | |
| 11161 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11163 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11162 | wanted_type, value, CastOpBitCast); | 11164 | wanted_type, value, CastOpBitCast); |
| 11163 | result->value.type = wanted_type; | 11165 | result->value->type = wanted_type; |
| 11164 | return result; | 11166 | return result; |
| 11165 | } | 11167 | } |
| 11166 | | 11168 | |
| ... | @@ -11169,28 +11171,28 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11169,28 +11171,28 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11169 | { | 11171 | { |
| 11170 | Error err; | 11172 | Error err; |
| 11171 | | 11173 | |
| 11172 | if ((err = type_resolve(ira->codegen, array_ptr->value.type->data.pointer.child_type, | 11174 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, |
| 11173 | ResolveStatusAlignmentKnown))) | 11175 | ResolveStatusAlignmentKnown))) |
| 11174 | { | 11176 | { |
| 11175 | return ira->codegen->invalid_instruction; | 11177 | return ira->codegen->invalid_instruction; |
| 11176 | } | 11178 | } |
| 11177 | | 11179 | |
| 11178 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value.type)); | 11180 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); |
| 11179 | | 11181 | |
| 11180 | if (instr_is_comptime(array_ptr)) { | 11182 | if (instr_is_comptime(array_ptr)) { |
| 11181 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, &array_ptr->value, source_instr->source_node); | 11183 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr->value, source_instr->source_node); |
| 11182 | if (pointee == nullptr) | 11184 | if (pointee == nullptr) |
| 11183 | return ira->codegen->invalid_instruction; | 11185 | return ira->codegen->invalid_instruction; |
| 11184 | if (pointee->special != ConstValSpecialRuntime) { | 11186 | if (pointee->special != ConstValSpecialRuntime) { |
| 11185 | assert(array_ptr->value.type->id == ZigTypeIdPointer); | 11187 | assert(array_ptr->value->type->id == ZigTypeIdPointer); |
| 11186 | ZigType *array_type = array_ptr->value.type->data.pointer.child_type; | 11188 | ZigType *array_type = array_ptr->value->type->data.pointer.child_type; |
| 11187 | assert(is_slice(wanted_type)); | 11189 | assert(is_slice(wanted_type)); |
| 11188 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; | 11190 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; |
| 11189 | | 11191 | |
| 11190 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11192 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11191 | init_const_slice(ira->codegen, &result->value, pointee, 0, array_type->data.array.len, is_const); | 11193 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const); |
| 11192 | result->value.data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value.data.x_ptr.mut; | 11194 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value->data.x_ptr.mut; |
| 11193 | result->value.type = wanted_type; | 11195 | result->value->type = wanted_type; |
| 11194 | return result; | 11196 | return result; |
| 11195 | } | 11197 | } |
| 11196 | } | 11198 | } |
| ... | @@ -11198,7 +11200,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11198,7 +11200,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11198 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11200 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11199 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, | 11201 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, |
| 11200 | false, true); | 11202 | false, true); |
| 11201 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 11203 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11202 | return result_loc_inst; | 11204 | return result_loc_inst; |
| 11203 | } | 11205 | } |
| 11204 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); | 11206 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); |
| ... | @@ -11403,32 +11405,32 @@ static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -11403,32 +11405,32 @@ static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruc |
| 11403 | } | 11405 | } |
| 11404 | | 11406 | |
| 11405 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { | 11407 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { |
| 11406 | if (instruction->value.type->id == ZigTypeIdUnreachable) | 11408 | if (instruction->value->type->id == ZigTypeIdUnreachable) |
| 11407 | ir_finish_bb(ira); | 11409 | ir_finish_bb(ira); |
| 11408 | return instruction; | 11410 | return instruction; |
| 11409 | } | 11411 | } |
| 11410 | | 11412 | |
| 11411 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 11413 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 11412 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); | 11414 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); |
| 11413 | result->value.data.x_type = ty; | 11415 | result->value->data.x_type = ty; |
| 11414 | return result; | 11416 | return result; |
| 11415 | } | 11417 | } |
| 11416 | | 11418 | |
| 11417 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { | 11419 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { |
| 11418 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); | 11420 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); |
| 11419 | result->value.data.x_bool = value; | 11421 | result->value->data.x_bool = value; |
| 11420 | return result; | 11422 | return result; |
| 11421 | } | 11423 | } |
| 11422 | | 11424 | |
| 11423 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 11425 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { |
| 11424 | IrInstruction *result = ir_const(ira, source_instruction, ty); | 11426 | IrInstruction *result = ir_const(ira, source_instruction, ty); |
| 11425 | result->value.special = ConstValSpecialUndef; | 11427 | result->value->special = ConstValSpecialUndef; |
| 11426 | return result; | 11428 | return result; |
| 11427 | } | 11429 | } |
| 11428 | | 11430 | |
| 11429 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { | 11431 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { |
| 11430 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable); | 11432 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_unreachable); |
| 11431 | result->value.special = ConstValSpecialStatic; | 11433 | result->value->special = ConstValSpecialStatic; |
| 11432 | return result; | 11434 | return result; |
| 11433 | } | 11435 | } |
| 11434 | | 11436 | |
| ... | @@ -11438,7 +11440,7 @@ static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instru | ... | @@ -11438,7 +11440,7 @@ static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instru |
| 11438 | | 11440 | |
| 11439 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { | 11441 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { |
| 11440 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); | 11442 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); |
| 11441 | bigint_init_unsigned(&result->value.data.x_bigint, value); | 11443 | bigint_init_unsigned(&result->value->data.x_bigint, value); |
| 11442 | return result; | 11444 | return result; |
| 11443 | } | 11445 | } |
| 11444 | | 11446 | |
| ... | @@ -11449,7 +11451,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -11449,7 +11451,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio |
| 11449 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, | 11451 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, |
| 11450 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); | 11452 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 11451 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); | 11453 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); |
| 11452 | ZigValue *const_val = &const_instr->value; | 11454 | ZigValue *const_val = const_instr->value; |
| 11453 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 11455 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 11454 | const_val->data.x_ptr.mut = ptr_mut; | 11456 | const_val->data.x_ptr.mut = ptr_mut; |
| 11455 | const_val->data.x_ptr.data.ref.pointee = pointee; | 11457 | const_val->data.x_ptr.data.ref.pointee = pointee; |
| ... | @@ -11493,11 +11495,11 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -11493,11 +11495,11 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 11493 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { | 11495 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { |
| 11494 | Error err; | 11496 | Error err; |
| 11495 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, | 11497 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, |
| 11496 | &value->value, undef_allowed))) | 11498 | value->value, undef_allowed))) |
| 11497 | { | 11499 | { |
| 11498 | return nullptr; | 11500 | return nullptr; |
| 11499 | } | 11501 | } |
| 11500 | return &value->value; | 11502 | return value->value; |
| 11501 | } | 11503 | } |
| 11502 | | 11504 | |
| 11503 | ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 11505 | ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| ... | @@ -11508,7 +11510,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11508,7 +11510,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11508 | Error err; | 11510 | Error err; |
| 11509 | | 11511 | |
| 11510 | if (expected_type != nullptr && type_is_invalid(expected_type)) | 11512 | if (expected_type != nullptr && type_is_invalid(expected_type)) |
| 11511 | return &codegen->invalid_instruction->value; | 11513 | return codegen->invalid_instruction->value; |
| 11512 | | 11514 | |
| 11513 | IrExecutable *ir_executable = allocate<IrExecutable>(1); | 11515 | IrExecutable *ir_executable = allocate<IrExecutable>(1); |
| 11514 | ir_executable->source_node = source_node; | 11516 | ir_executable->source_node = source_node; |
| ... | @@ -11522,7 +11524,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11522,7 +11524,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11522 | | 11524 | |
| 11523 | if (ir_executable->first_err_trace_msg != nullptr) { | 11525 | if (ir_executable->first_err_trace_msg != nullptr) { |
| 11524 | codegen->trace_err = ir_executable->first_err_trace_msg; | 11526 | codegen->trace_err = ir_executable->first_err_trace_msg; |
| 11525 | return &codegen->invalid_instruction->value; | 11527 | return codegen->invalid_instruction->value; |
| 11526 | } | 11528 | } |
| 11527 | | 11529 | |
| 11528 | if (codegen->verbose_ir) { | 11530 | if (codegen->verbose_ir) { |
| ... | @@ -11545,7 +11547,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11545,7 +11547,7 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11545 | analyzed_executable->begin_scope = scope; | 11547 | analyzed_executable->begin_scope = scope; |
| 11546 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); | 11548 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); |
| 11547 | if (type_is_invalid(result_type)) { | 11549 | if (type_is_invalid(result_type)) { |
| 11548 | return &codegen->invalid_instruction->value; | 11550 | return codegen->invalid_instruction->value; |
| 11549 | } | 11551 | } |
| 11550 | | 11552 | |
| 11551 | if (codegen->verbose_ir) { | 11553 | if (codegen->verbose_ir) { |
| ... | @@ -11556,21 +11558,21 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -11556,21 +11558,21 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 11556 | | 11558 | |
| 11557 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); | 11559 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); |
| 11558 | if (type_is_invalid(result->type)) | 11560 | if (type_is_invalid(result->type)) |
| 11559 | return &codegen->invalid_instruction->value; | 11561 | return codegen->invalid_instruction->value; |
| 11560 | | 11562 | |
| 11561 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) | 11563 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) |
| 11562 | return &codegen->invalid_instruction->value; | 11564 | return codegen->invalid_instruction->value; |
| 11563 | | 11565 | |
| 11564 | return result; | 11566 | return result; |
| 11565 | } | 11567 | } |
| 11566 | | 11568 | |
| 11567 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { | 11569 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { |
| 11568 | if (type_is_invalid(err_value->value.type)) | 11570 | if (type_is_invalid(err_value->value->type)) |
| 11569 | return nullptr; | 11571 | return nullptr; |
| 11570 | | 11572 | |
| 11571 | if (err_value->value.type->id != ZigTypeIdErrorSet) { | 11573 | if (err_value->value->type->id != ZigTypeIdErrorSet) { |
| 11572 | ir_add_error(ira, err_value, | 11574 | ir_add_error(ira, err_value, |
| 11573 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value.type->name))); | 11575 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); |
| 11574 | return nullptr; | 11576 | return nullptr; |
| 11575 | } | 11577 | } |
| 11576 | | 11578 | |
| ... | @@ -11594,23 +11596,23 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN | ... | @@ -11594,23 +11596,23 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN |
| 11594 | } | 11596 | } |
| 11595 | | 11597 | |
| 11596 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { | 11598 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { |
| 11597 | if (type_is_invalid(type_value->value.type)) | 11599 | if (type_is_invalid(type_value->value->type)) |
| 11598 | return nullptr; | 11600 | return nullptr; |
| 11599 | | 11601 | |
| 11600 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 11602 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 11601 | ir_add_error(ira, type_value, | 11603 | ir_add_error(ira, type_value, |
| 11602 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); | 11604 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); |
| 11603 | return nullptr; | 11605 | return nullptr; |
| 11604 | } | 11606 | } |
| 11605 | | 11607 | |
| 11606 | Error err; | 11608 | Error err; |
| 11607 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, | 11609 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, |
| 11608 | &type_value->value, LazyOk))) | 11610 | type_value->value, LazyOk))) |
| 11609 | { | 11611 | { |
| 11610 | return nullptr; | 11612 | return nullptr; |
| 11611 | } | 11613 | } |
| 11612 | | 11614 | |
| 11613 | return &type_value->value; | 11615 | return type_value->value; |
| 11614 | } | 11616 | } |
| 11615 | | 11617 | |
| 11616 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 11618 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| ... | @@ -11663,12 +11665,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -11663,12 +11665,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 11663 | } | 11665 | } |
| 11664 | | 11666 | |
| 11665 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { | 11667 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { |
| 11666 | if (type_is_invalid(type_value->value.type)) | 11668 | if (type_is_invalid(type_value->value->type)) |
| 11667 | return ira->codegen->builtin_types.entry_invalid; | 11669 | return ira->codegen->builtin_types.entry_invalid; |
| 11668 | | 11670 | |
| 11669 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 11671 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 11670 | ErrorMsg *msg = ir_add_error(ira, type_value, | 11672 | ErrorMsg *msg = ir_add_error(ira, type_value, |
| 11671 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value.type->name))); | 11673 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); |
| 11672 | add_error_note(ira->codegen, msg, op_source->source_node, | 11674 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 11673 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 11675 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| 11674 | return ira->codegen->builtin_types.entry_invalid; | 11676 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -11694,12 +11696,12 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -11694,12 +11696,12 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 11694 | if (fn_value == ira->codegen->invalid_instruction) | 11696 | if (fn_value == ira->codegen->invalid_instruction) |
| 11695 | return nullptr; | 11697 | return nullptr; |
| 11696 | | 11698 | |
| 11697 | if (type_is_invalid(fn_value->value.type)) | 11699 | if (type_is_invalid(fn_value->value->type)) |
| 11698 | return nullptr; | 11700 | return nullptr; |
| 11699 | | 11701 | |
| 11700 | if (fn_value->value.type->id != ZigTypeIdFn) { | 11702 | if (fn_value->value->type->id != ZigTypeIdFn) { |
| 11701 | ir_add_error_node(ira, fn_value->source_node, | 11703 | ir_add_error_node(ira, fn_value->source_node, |
| 11702 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value.type->name))); | 11704 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); |
| 11703 | return nullptr; | 11705 | return nullptr; |
| 11704 | } | 11706 | } |
| 11705 | | 11707 | |
| ... | @@ -11722,7 +11724,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11722,7 +11724,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11722 | if (instr_is_comptime(value)) { | 11724 | if (instr_is_comptime(value)) { |
| 11723 | ZigType *payload_type = wanted_type->data.maybe.child_type; | 11725 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 11724 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 11726 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11725 | if (type_is_invalid(casted_payload->value.type)) | 11727 | if (type_is_invalid(casted_payload->value->type)) |
| 11726 | return ira->codegen->invalid_instruction; | 11728 | return ira->codegen->invalid_instruction; |
| 11727 | | 11729 | |
| 11728 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 11730 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| ... | @@ -11731,13 +11733,13 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11731,13 +11733,13 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11731 | | 11733 | |
| 11732 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11734 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11733 | source_instr->scope, source_instr->source_node); | 11735 | source_instr->scope, source_instr->source_node); |
| 11734 | const_instruction->base.value.special = ConstValSpecialStatic; | 11736 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11735 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { | 11737 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { |
| 11736 | copy_const_val(&const_instruction->base.value, val, val->data.x_ptr.mut == ConstPtrMutComptimeConst); | 11738 | copy_const_val(const_instruction->base.value, val, val->data.x_ptr.mut == ConstPtrMutComptimeConst); |
| 11737 | } else { | 11739 | } else { |
| 11738 | const_instruction->base.value.data.x_optional = val; | 11740 | const_instruction->base.value->data.x_optional = val; |
| 11739 | } | 11741 | } |
| 11740 | const_instruction->base.value.type = wanted_type; | 11742 | const_instruction->base.value->type = wanted_type; |
| 11741 | return &const_instruction->base; | 11743 | return &const_instruction->base; |
| 11742 | } | 11744 | } |
| 11743 | | 11745 | |
| ... | @@ -11747,12 +11749,12 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -11747,12 +11749,12 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11747 | IrInstruction *result_loc_inst = nullptr; | 11749 | IrInstruction *result_loc_inst = nullptr; |
| 11748 | if (result_loc != nullptr) { | 11750 | if (result_loc != nullptr) { |
| 11749 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11751 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 11750 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 11752 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11751 | return result_loc_inst; | 11753 | return result_loc_inst; |
| 11752 | } | 11754 | } |
| 11753 | } | 11755 | } |
| 11754 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); | 11756 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11755 | result->value.data.rh_maybe = RuntimeHintOptionalNonNull; | 11757 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; |
| 11756 | return result; | 11758 | return result; |
| 11757 | } | 11759 | } |
| 11758 | | 11760 | |
| ... | @@ -11765,7 +11767,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11765,7 +11767,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11765 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; | 11767 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 11766 | if (instr_is_comptime(value)) { | 11768 | if (instr_is_comptime(value)) { |
| 11767 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 11769 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11768 | if (type_is_invalid(casted_payload->value.type)) | 11770 | if (type_is_invalid(casted_payload->value->type)) |
| 11769 | return ira->codegen->invalid_instruction; | 11771 | return ira->codegen->invalid_instruction; |
| 11770 | | 11772 | |
| 11771 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); | 11773 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| ... | @@ -11779,10 +11781,10 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11779,10 +11781,10 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11779 | | 11781 | |
| 11780 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11782 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11781 | source_instr->scope, source_instr->source_node); | 11783 | source_instr->scope, source_instr->source_node); |
| 11782 | const_instruction->base.value.type = wanted_type; | 11784 | const_instruction->base.value->type = wanted_type; |
| 11783 | const_instruction->base.value.special = ConstValSpecialStatic; | 11785 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11784 | const_instruction->base.value.data.x_err_union.error_set = err_set_val; | 11786 | const_instruction->base.value->data.x_err_union.error_set = err_set_val; |
| 11785 | const_instruction->base.value.data.x_err_union.payload = val; | 11787 | const_instruction->base.value->data.x_err_union.payload = val; |
| 11786 | return &const_instruction->base; | 11788 | return &const_instruction->base; |
| 11787 | } | 11789 | } |
| 11788 | | 11790 | |
| ... | @@ -11790,7 +11792,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11790,7 +11792,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11790 | if (handle_is_ptr(wanted_type)) { | 11792 | if (handle_is_ptr(wanted_type)) { |
| 11791 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11793 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11792 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11794 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 11793 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 11795 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11794 | return result_loc_inst; | 11796 | return result_loc_inst; |
| 11795 | } | 11797 | } |
| 11796 | } else { | 11798 | } else { |
| ... | @@ -11798,14 +11800,14 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -11798,14 +11800,14 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11798 | } | 11800 | } |
| 11799 | | 11801 | |
| 11800 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); | 11802 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11801 | result->value.data.rh_error_union = RuntimeHintErrorUnionNonError; | 11803 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; |
| 11802 | return result; | 11804 | return result; |
| 11803 | } | 11805 | } |
| 11804 | | 11806 | |
| 11805 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 11807 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 11806 | ZigType *wanted_type) | 11808 | ZigType *wanted_type) |
| 11807 | { | 11809 | { |
| 11808 | assert(value->value.type->id == ZigTypeIdErrorSet); | 11810 | assert(value->value->type->id == ZigTypeIdErrorSet); |
| 11809 | assert(wanted_type->id == ZigTypeIdErrorSet); | 11811 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 11810 | | 11812 | |
| 11811 | if (instr_is_comptime(value)) { | 11813 | if (instr_is_comptime(value)) { |
| ... | @@ -11834,14 +11836,14 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -11834,14 +11836,14 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 11834 | | 11836 | |
| 11835 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11837 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11836 | source_instr->scope, source_instr->source_node); | 11838 | source_instr->scope, source_instr->source_node); |
| 11837 | const_instruction->base.value.type = wanted_type; | 11839 | const_instruction->base.value->type = wanted_type; |
| 11838 | const_instruction->base.value.special = ConstValSpecialStatic; | 11840 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11839 | const_instruction->base.value.data.x_err_set = val->data.x_err_set; | 11841 | const_instruction->base.value->data.x_err_set = val->data.x_err_set; |
| 11840 | return &const_instruction->base; | 11842 | return &const_instruction->base; |
| 11841 | } | 11843 | } |
| 11842 | | 11844 | |
| 11843 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet); | 11845 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet); |
| 11844 | result->value.type = wanted_type; | 11846 | result->value->type = wanted_type; |
| 11845 | return result; | 11847 | return result; |
| 11846 | } | 11848 | } |
| 11847 | | 11849 | |
| ... | @@ -11861,7 +11863,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -11861,7 +11863,7 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 11861 | | 11863 | |
| 11862 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11864 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11863 | wanted_type, frame_ptr, CastOpBitCast); | 11865 | wanted_type, frame_ptr, CastOpBitCast); |
| 11864 | result->value.type = wanted_type; | 11866 | result->value->type = wanted_type; |
| 11865 | return result; | 11867 | return result; |
| 11866 | } | 11868 | } |
| 11867 | | 11869 | |
| ... | @@ -11874,7 +11876,7 @@ static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruct | ... | @@ -11874,7 +11876,7 @@ static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruct |
| 11874 | | 11876 | |
| 11875 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 11877 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 11876 | wanted_type, value, CastOpBitCast); | 11878 | wanted_type, value, CastOpBitCast); |
| 11877 | result->value.type = wanted_type; | 11879 | result->value->type = wanted_type; |
| 11878 | return result; | 11880 | return result; |
| 11879 | } | 11881 | } |
| 11880 | | 11882 | |
| ... | @@ -11898,10 +11900,10 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11898,10 +11900,10 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11898 | | 11900 | |
| 11899 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 11901 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 11900 | source_instr->scope, source_instr->source_node); | 11902 | source_instr->scope, source_instr->source_node); |
| 11901 | const_instruction->base.value.type = wanted_type; | 11903 | const_instruction->base.value->type = wanted_type; |
| 11902 | const_instruction->base.value.special = ConstValSpecialStatic; | 11904 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 11903 | const_instruction->base.value.data.x_err_union.error_set = err_set_val; | 11905 | const_instruction->base.value->data.x_err_union.error_set = err_set_val; |
| 11904 | const_instruction->base.value.data.x_err_union.payload = nullptr; | 11906 | const_instruction->base.value->data.x_err_union.payload = nullptr; |
| 11905 | return &const_instruction->base; | 11907 | return &const_instruction->base; |
| 11906 | } | 11908 | } |
| 11907 | | 11909 | |
| ... | @@ -11909,7 +11911,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11909,7 +11911,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11909 | if (handle_is_ptr(wanted_type)) { | 11911 | if (handle_is_ptr(wanted_type)) { |
| 11910 | if (result_loc == nullptr) result_loc = no_result_loc(); | 11912 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11911 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 11913 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 11912 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 11914 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 11913 | return result_loc_inst; | 11915 | return result_loc_inst; |
| 11914 | } | 11916 | } |
| 11915 | } else { | 11917 | } else { |
| ... | @@ -11918,7 +11920,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -11918,7 +11920,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11918 | | 11920 | |
| 11919 | | 11921 | |
| 11920 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); | 11922 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); |
| 11921 | result->value.data.rh_error_union = RuntimeHintErrorUnionError; | 11923 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; |
| 11922 | return result; | 11924 | return result; |
| 11923 | } | 11925 | } |
| 11924 | | 11926 | |
| ... | @@ -11930,13 +11932,13 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -11930,13 +11932,13 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 11930 | assert(val != nullptr); | 11932 | assert(val != nullptr); |
| 11931 | | 11933 | |
| 11932 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11934 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11933 | result->value.special = ConstValSpecialStatic; | 11935 | result->value->special = ConstValSpecialStatic; |
| 11934 | if (get_codegen_ptr_type(wanted_type) != nullptr) { | 11936 | if (get_codegen_ptr_type(wanted_type) != nullptr) { |
| 11935 | result->value.data.x_ptr.special = ConstPtrSpecialNull; | 11937 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 11936 | } else if (is_opt_err_set(wanted_type)) { | 11938 | } else if (is_opt_err_set(wanted_type)) { |
| 11937 | result->value.data.x_err_set = nullptr; | 11939 | result->value->data.x_err_set = nullptr; |
| 11938 | } else { | 11940 | } else { |
| 11939 | result->value.data.x_optional = nullptr; | 11941 | result->value->data.x_optional = nullptr; |
| 11940 | } | 11942 | } |
| 11941 | return result; | 11943 | return result; |
| 11942 | } | 11944 | } |
| ... | @@ -11952,8 +11954,8 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction | ... | @@ -11952,8 +11954,8 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction |
| 11952 | assert(val != nullptr); | 11954 | assert(val != nullptr); |
| 11953 | | 11955 | |
| 11954 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 11956 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 11955 | result->value.data.x_ptr.special = ConstPtrSpecialNull; | 11957 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 11956 | result->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 11958 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 11957 | return result; | 11959 | return result; |
| 11958 | } | 11960 | } |
| 11959 | | 11961 | |
| ... | @@ -11962,36 +11964,36 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -11962,36 +11964,36 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 11962 | { | 11964 | { |
| 11963 | Error err; | 11965 | Error err; |
| 11964 | | 11966 | |
| 11965 | if (type_is_invalid(value->value.type)) | 11967 | if (type_is_invalid(value->value->type)) |
| 11966 | return ira->codegen->invalid_instruction; | 11968 | return ira->codegen->invalid_instruction; |
| 11967 | | 11969 | |
| 11968 | if ((err = type_resolve(ira->codegen, value->value.type, ResolveStatusZeroBitsKnown))) | 11970 | if ((err = type_resolve(ira->codegen, value->value->type, ResolveStatusZeroBitsKnown))) |
| 11969 | return ira->codegen->invalid_instruction; | 11971 | return ira->codegen->invalid_instruction; |
| 11970 | | 11972 | |
| 11971 | if (instr_is_comptime(value)) { | 11973 | if (instr_is_comptime(value)) { |
| 11972 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); | 11974 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); |
| 11973 | if (!val) | 11975 | if (!val) |
| 11974 | return ira->codegen->invalid_instruction; | 11976 | return ira->codegen->invalid_instruction; |
| 11975 | return ir_get_const_ptr(ira, source_instruction, val, value->value.type, | 11977 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, |
| 11976 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); | 11978 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); |
| 11977 | } | 11979 | } |
| 11978 | | 11980 | |
| 11979 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value.type, | 11981 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value->value->type, |
| 11980 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 11982 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 11981 | | 11983 | |
| 11982 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) | 11984 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) |
| 11983 | return ira->codegen->invalid_instruction; | 11985 | return ira->codegen->invalid_instruction; |
| 11984 | | 11986 | |
| 11985 | IrInstruction *result_loc; | 11987 | IrInstruction *result_loc; |
| 11986 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value.type)) { | 11988 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) { |
| 11987 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value.type, nullptr, true, | 11989 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, nullptr, true, |
| 11988 | false, true); | 11990 | false, true); |
| 11989 | } else { | 11991 | } else { |
| 11990 | result_loc = nullptr; | 11992 | result_loc = nullptr; |
| 11991 | } | 11993 | } |
| 11992 | | 11994 | |
| 11993 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); | 11995 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); |
| 11994 | new_instruction->value.data.rh_ptr = RuntimeHintPtrStack; | 11996 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; |
| 11995 | return new_instruction; | 11997 | return new_instruction; |
| 11996 | } | 11998 | } |
| 11997 | | 11999 | |
| ... | @@ -12004,39 +12006,39 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s | ... | @@ -12004,39 +12006,39 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s |
| 12004 | | 12006 | |
| 12005 | IrInstruction *array_ptr = nullptr; | 12007 | IrInstruction *array_ptr = nullptr; |
| 12006 | IrInstruction *array; | 12008 | IrInstruction *array; |
| 12007 | if (array_arg->value.type->id == ZigTypeIdPointer) { | 12009 | if (array_arg->value->type->id == ZigTypeIdPointer) { |
| 12008 | array = ir_get_deref(ira, source_instr, array_arg, nullptr); | 12010 | array = ir_get_deref(ira, source_instr, array_arg, nullptr); |
| 12009 | array_ptr = array_arg; | 12011 | array_ptr = array_arg; |
| 12010 | } else { | 12012 | } else { |
| 12011 | array = array_arg; | 12013 | array = array_arg; |
| 12012 | } | 12014 | } |
| 12013 | ZigType *array_type = array->value.type; | 12015 | ZigType *array_type = array->value->type; |
| 12014 | assert(array_type->id == ZigTypeIdArray); | 12016 | assert(array_type->id == ZigTypeIdArray); |
| 12015 | | 12017 | |
| 12016 | if (instr_is_comptime(array) || array_type->data.array.len == 0) { | 12018 | if (instr_is_comptime(array) || array_type->data.array.len == 0) { |
| 12017 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12019 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12018 | init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true); | 12020 | init_const_slice(ira->codegen, result->value, array->value, 0, array_type->data.array.len, true); |
| 12019 | result->value.type = wanted_type; | 12021 | result->value->type = wanted_type; |
| 12020 | return result; | 12022 | return result; |
| 12021 | } | 12023 | } |
| 12022 | | 12024 | |
| 12023 | IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | 12025 | IrInstruction *start = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); |
| 12024 | init_const_usize(ira->codegen, &start->value, 0); | 12026 | init_const_usize(ira->codegen, start->value, 0); |
| 12025 | | 12027 | |
| 12026 | IrInstruction *end = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); | 12028 | IrInstruction *end = ir_const(ira, source_instr, ira->codegen->builtin_types.entry_usize); |
| 12027 | init_const_usize(ira->codegen, &end->value, array_type->data.array.len); | 12029 | init_const_usize(ira->codegen, end->value, array_type->data.array.len); |
| 12028 | | 12030 | |
| 12029 | if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false); | 12031 | if (!array_ptr) array_ptr = ir_get_ref(ira, source_instr, array, true, false); |
| 12030 | | 12032 | |
| 12031 | if (result_loc == nullptr) result_loc = no_result_loc(); | 12033 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12032 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, | 12034 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, |
| 12033 | true, false, true); | 12035 | true, false, true); |
| 12034 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 12036 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 12035 | return result_loc_inst; | 12037 | return result_loc_inst; |
| 12036 | } | 12038 | } |
| 12037 | IrInstruction *result = ir_build_slice_gen(ira, source_instr, wanted_type, array_ptr, start, end, false, result_loc_inst); | 12039 | IrInstruction *result = ir_build_slice_gen(ira, source_instr, wanted_type, array_ptr, start, end, false, result_loc_inst); |
| 12038 | result->value.data.rh_slice.id = RuntimeHintSliceIdLen; | 12040 | result->value->data.rh_slice.id = RuntimeHintSliceIdLen; |
| 12039 | result->value.data.rh_slice.len = array_type->data.array.len; | 12041 | result->value->data.rh_slice.len = array_type->data.array.len; |
| 12040 | | 12042 | |
| 12041 | return result; | 12043 | return result; |
| 12042 | } | 12044 | } |
| ... | @@ -12065,19 +12067,19 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12065,19 +12067,19 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12065 | | 12067 | |
| 12066 | IrInstruction *enum_target; | 12068 | IrInstruction *enum_target; |
| 12067 | ZigType *enum_type; | 12069 | ZigType *enum_type; |
| 12068 | if (target->value.type->id == ZigTypeIdUnion) { | 12070 | if (target->value->type->id == ZigTypeIdUnion) { |
| 12069 | enum_type = ir_resolve_union_tag_type(ira, target, target->value.type); | 12071 | enum_type = ir_resolve_union_tag_type(ira, target, target->value->type); |
| 12070 | if (type_is_invalid(enum_type)) | 12072 | if (type_is_invalid(enum_type)) |
| 12071 | return ira->codegen->invalid_instruction; | 12073 | return ira->codegen->invalid_instruction; |
| 12072 | enum_target = ir_implicit_cast(ira, target, enum_type); | 12074 | enum_target = ir_implicit_cast(ira, target, enum_type); |
| 12073 | if (type_is_invalid(enum_target->value.type)) | 12075 | if (type_is_invalid(enum_target->value->type)) |
| 12074 | return ira->codegen->invalid_instruction; | 12076 | return ira->codegen->invalid_instruction; |
| 12075 | } else if (target->value.type->id == ZigTypeIdEnum) { | 12077 | } else if (target->value->type->id == ZigTypeIdEnum) { |
| 12076 | enum_target = target; | 12078 | enum_target = target; |
| 12077 | enum_type = target->value.type; | 12079 | enum_type = target->value->type; |
| 12078 | } else { | 12080 | } else { |
| 12079 | ir_add_error(ira, target, | 12081 | ir_add_error(ira, target, |
| 12080 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); | 12082 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); |
| 12081 | return ira->codegen->invalid_instruction; | 12083 | return ira->codegen->invalid_instruction; |
| 12082 | } | 12084 | } |
| 12083 | | 12085 | |
| ... | @@ -12092,7 +12094,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12092,7 +12094,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12092 | enum_type->data.enumeration.src_field_count == 1) | 12094 | enum_type->data.enumeration.src_field_count == 1) |
| 12093 | { | 12095 | { |
| 12094 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 12096 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 12095 | init_const_bigint(&result->value, tag_type, | 12097 | init_const_bigint(result->value, tag_type, |
| 12096 | &enum_type->data.enumeration.fields[0].value); | 12098 | &enum_type->data.enumeration.fields[0].value); |
| 12097 | return result; | 12099 | return result; |
| 12098 | } | 12100 | } |
| ... | @@ -12102,31 +12104,31 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12102,31 +12104,31 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12102 | if (!val) | 12104 | if (!val) |
| 12103 | return ira->codegen->invalid_instruction; | 12105 | return ira->codegen->invalid_instruction; |
| 12104 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 12106 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 12105 | init_const_bigint(&result->value, tag_type, &val->data.x_enum_tag); | 12107 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); |
| 12106 | return result; | 12108 | return result; |
| 12107 | } | 12109 | } |
| 12108 | | 12110 | |
| 12109 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 12111 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, |
| 12110 | source_instr->source_node, enum_target); | 12112 | source_instr->source_node, enum_target); |
| 12111 | result->value.type = tag_type; | 12113 | result->value->type = tag_type; |
| 12112 | return result; | 12114 | return result; |
| 12113 | } | 12115 | } |
| 12114 | | 12116 | |
| 12115 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, | 12117 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, |
| 12116 | IrInstruction *target, ZigType *wanted_type) | 12118 | IrInstruction *target, ZigType *wanted_type) |
| 12117 | { | 12119 | { |
| 12118 | assert(target->value.type->id == ZigTypeIdUnion); | 12120 | assert(target->value->type->id == ZigTypeIdUnion); |
| 12119 | assert(wanted_type->id == ZigTypeIdEnum); | 12121 | assert(wanted_type->id == ZigTypeIdEnum); |
| 12120 | assert(wanted_type == target->value.type->data.unionation.tag_type); | 12122 | assert(wanted_type == target->value->type->data.unionation.tag_type); |
| 12121 | | 12123 | |
| 12122 | if (instr_is_comptime(target)) { | 12124 | if (instr_is_comptime(target)) { |
| 12123 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 12125 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12124 | if (!val) | 12126 | if (!val) |
| 12125 | return ira->codegen->invalid_instruction; | 12127 | return ira->codegen->invalid_instruction; |
| 12126 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12128 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12127 | result->value.special = ConstValSpecialStatic; | 12129 | result->value->special = ConstValSpecialStatic; |
| 12128 | result->value.type = wanted_type; | 12130 | result->value->type = wanted_type; |
| 12129 | bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_union.tag); | 12131 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); |
| 12130 | return result; | 12132 | return result; |
| 12131 | } | 12133 | } |
| 12132 | | 12134 | |
| ... | @@ -12135,16 +12137,16 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12135,16 +12137,16 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12135 | wanted_type->data.enumeration.src_field_count == 1) | 12137 | wanted_type->data.enumeration.src_field_count == 1) |
| 12136 | { | 12138 | { |
| 12137 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12139 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12138 | result->value.special = ConstValSpecialStatic; | 12140 | result->value->special = ConstValSpecialStatic; |
| 12139 | result->value.type = wanted_type; | 12141 | result->value->type = wanted_type; |
| 12140 | TypeEnumField *enum_field = target->value.type->data.unionation.fields[0].enum_field; | 12142 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; |
| 12141 | bigint_init_bigint(&result->value.data.x_enum_tag, &enum_field->value); | 12143 | bigint_init_bigint(&result->value->data.x_enum_tag, &enum_field->value); |
| 12142 | return result; | 12144 | return result; |
| 12143 | } | 12145 | } |
| 12144 | | 12146 | |
| 12145 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, | 12147 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, |
| 12146 | source_instr->source_node, target); | 12148 | source_instr->source_node, target); |
| 12147 | result->value.type = wanted_type; | 12149 | result->value->type = wanted_type; |
| 12148 | return result; | 12150 | return result; |
| 12149 | } | 12151 | } |
| 12150 | | 12152 | |
| ... | @@ -12152,7 +12154,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc | ... | @@ -12152,7 +12154,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc |
| 12152 | IrInstruction *target, ZigType *wanted_type) | 12154 | IrInstruction *target, ZigType *wanted_type) |
| 12153 | { | 12155 | { |
| 12154 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12156 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12155 | result->value.special = ConstValSpecialUndef; | 12157 | result->value->special = ConstValSpecialUndef; |
| 12156 | return result; | 12158 | return result; |
| 12157 | } | 12159 | } |
| 12158 | | 12160 | |
| ... | @@ -12166,7 +12168,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12166,7 +12168,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12166 | return ira->codegen->invalid_instruction; | 12168 | return ira->codegen->invalid_instruction; |
| 12167 | | 12169 | |
| 12168 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | 12170 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12169 | if (type_is_invalid(target->value.type)) | 12171 | if (type_is_invalid(target->value->type)) |
| 12170 | return ira->codegen->invalid_instruction; | 12172 | return ira->codegen->invalid_instruction; |
| 12171 | | 12173 | |
| 12172 | if (instr_is_comptime(target)) { | 12174 | if (instr_is_comptime(target)) { |
| ... | @@ -12201,12 +12203,12 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12201,12 +12203,12 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12201 | } | 12203 | } |
| 12202 | | 12204 | |
| 12203 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12205 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12204 | result->value.special = ConstValSpecialStatic; | 12206 | result->value->special = ConstValSpecialStatic; |
| 12205 | result->value.type = wanted_type; | 12207 | result->value->type = wanted_type; |
| 12206 | bigint_init_bigint(&result->value.data.x_union.tag, &val->data.x_enum_tag); | 12208 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); |
| 12207 | result->value.data.x_union.payload = create_const_vals(1); | 12209 | result->value->data.x_union.payload = create_const_vals(1); |
| 12208 | result->value.data.x_union.payload->special = ConstValSpecialStatic; | 12210 | result->value->data.x_union.payload->special = ConstValSpecialStatic; |
| 12209 | result->value.data.x_union.payload->type = field_type; | 12211 | result->value->data.x_union.payload->type = field_type; |
| 12210 | return result; | 12212 | return result; |
| 12211 | } | 12213 | } |
| 12212 | | 12214 | |
| ... | @@ -12214,7 +12216,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12214,7 +12216,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12214 | // and in fact it's a noop cast because the union value is just the enum value | 12216 | // and in fact it's a noop cast because the union value is just the enum value |
| 12215 | if (wanted_type->data.unionation.gen_field_count == 0) { | 12217 | if (wanted_type->data.unionation.gen_field_count == 0) { |
| 12216 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); | 12218 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); |
| 12217 | result->value.type = wanted_type; | 12219 | result->value->type = wanted_type; |
| 12218 | return result; | 12220 | return result; |
| 12219 | } | 12221 | } |
| 12220 | | 12222 | |
| ... | @@ -12259,16 +12261,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12259,16 +12261,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12259 | { | 12261 | { |
| 12260 | ir_add_error(ira, source_instr, | 12262 | ir_add_error(ira, source_instr, |
| 12261 | buf_sprintf("cast from '%s' to '%s' truncates bits", | 12263 | buf_sprintf("cast from '%s' to '%s' truncates bits", |
| 12262 | buf_ptr(&target->value.type->name), buf_ptr(&wanted_type->name))); | 12264 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); |
| 12263 | return ira->codegen->invalid_instruction; | 12265 | return ira->codegen->invalid_instruction; |
| 12264 | } | 12266 | } |
| 12265 | } | 12267 | } |
| 12266 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12268 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12267 | result->value.type = wanted_type; | 12269 | result->value->type = wanted_type; |
| 12268 | if (wanted_type->id == ZigTypeIdInt) { | 12270 | if (wanted_type->id == ZigTypeIdInt) { |
| 12269 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 12271 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| 12270 | } else { | 12272 | } else { |
| 12271 | float_init_float(&result->value, val); | 12273 | float_init_float(result->value, val); |
| 12272 | } | 12274 | } |
| 12273 | return result; | 12275 | return result; |
| 12274 | } | 12276 | } |
| ... | @@ -12278,16 +12280,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12278,16 +12280,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12278 | // the target is zero. | 12280 | // the target is zero. |
| 12279 | if (!type_has_bits(wanted_type)) { | 12281 | if (!type_has_bits(wanted_type)) { |
| 12280 | assert(wanted_type->id == ZigTypeIdInt); | 12282 | assert(wanted_type->id == ZigTypeIdInt); |
| 12281 | assert(type_has_bits(target->value.type)); | 12283 | assert(type_has_bits(target->value->type)); |
| 12282 | ir_build_assert_zero(ira, source_instr, target); | 12284 | ir_build_assert_zero(ira, source_instr, target); |
| 12283 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); | 12285 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); |
| 12284 | result->value.type = wanted_type; | 12286 | result->value->type = wanted_type; |
| 12285 | return result; | 12287 | return result; |
| 12286 | } | 12288 | } |
| 12287 | | 12289 | |
| 12288 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 12290 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, |
| 12289 | source_instr->source_node, target); | 12291 | source_instr->source_node, target); |
| 12290 | result->value.type = wanted_type; | 12292 | result->value->type = wanted_type; |
| 12291 | return result; | 12293 | return result; |
| 12292 | } | 12294 | } |
| 12293 | | 12295 | |
| ... | @@ -12297,7 +12299,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12297,7 +12299,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12297 | Error err; | 12299 | Error err; |
| 12298 | assert(wanted_type->id == ZigTypeIdEnum); | 12300 | assert(wanted_type->id == ZigTypeIdEnum); |
| 12299 | | 12301 | |
| 12300 | ZigType *actual_type = target->value.type; | 12302 | ZigType *actual_type = target->value->type; |
| 12301 | | 12303 | |
| 12302 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) | 12304 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) |
| 12303 | return ira->codegen->invalid_instruction; | 12305 | return ira->codegen->invalid_instruction; |
| ... | @@ -12330,13 +12332,13 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12330,13 +12332,13 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12330 | } | 12332 | } |
| 12331 | | 12333 | |
| 12332 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12334 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12333 | bigint_init_bigint(&result->value.data.x_enum_tag, &val->data.x_bigint); | 12335 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); |
| 12334 | return result; | 12336 | return result; |
| 12335 | } | 12337 | } |
| 12336 | | 12338 | |
| 12337 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, | 12339 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, |
| 12338 | source_instr->source_node, nullptr, target); | 12340 | source_instr->source_node, nullptr, target); |
| 12339 | result->value.type = wanted_type; | 12341 | result->value->type = wanted_type; |
| 12340 | return result; | 12342 | return result; |
| 12341 | } | 12343 | } |
| 12342 | | 12344 | |
| ... | @@ -12349,9 +12351,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -12349,9 +12351,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 12349 | | 12351 | |
| 12350 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12352 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12351 | if (wanted_type->id == ZigTypeIdComptimeFloat) { | 12353 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 12352 | float_init_float(&result->value, val); | 12354 | float_init_float(result->value, val); |
| 12353 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { | 12355 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| 12354 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 12356 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| 12355 | } else { | 12357 | } else { |
| 12356 | zig_unreachable(); | 12358 | zig_unreachable(); |
| 12357 | } | 12359 | } |
| ... | @@ -12361,8 +12363,8 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -12361,8 +12363,8 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 12361 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 12363 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 12362 | ZigType *wanted_type) | 12364 | ZigType *wanted_type) |
| 12363 | { | 12365 | { |
| 12364 | assert(target->value.type->id == ZigTypeIdInt); | 12366 | assert(target->value->type->id == ZigTypeIdInt); |
| 12365 | assert(!target->value.type->data.integral.is_signed); | 12367 | assert(!target->value->type->data.integral.is_signed); |
| 12366 | assert(wanted_type->id == ZigTypeIdErrorSet); | 12368 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 12367 | | 12369 | |
| 12368 | if (instr_is_comptime(target)) { | 12370 | if (instr_is_comptime(target)) { |
| ... | @@ -12389,7 +12391,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12389,7 +12391,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12389 | } | 12391 | } |
| 12390 | | 12392 | |
| 12391 | size_t index = bigint_as_usize(&val->data.x_bigint); | 12393 | size_t index = bigint_as_usize(&val->data.x_bigint); |
| 12392 | result->value.data.x_err_set = ira->codegen->errors_by_index.at(index); | 12394 | result->value->data.x_err_set = ira->codegen->errors_by_index.at(index); |
| 12393 | return result; | 12395 | return result; |
| 12394 | } else { | 12396 | } else { |
| 12395 | ErrorTableEntry *err = nullptr; | 12397 | ErrorTableEntry *err = nullptr; |
| ... | @@ -12412,13 +12414,13 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12412,13 +12414,13 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12412 | return ira->codegen->invalid_instruction; | 12414 | return ira->codegen->invalid_instruction; |
| 12413 | } | 12415 | } |
| 12414 | | 12416 | |
| 12415 | result->value.data.x_err_set = err; | 12417 | result->value->data.x_err_set = err; |
| 12416 | return result; | 12418 | return result; |
| 12417 | } | 12419 | } |
| 12418 | } | 12420 | } |
| 12419 | | 12421 | |
| 12420 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 12422 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); |
| 12421 | result->value.type = wanted_type; | 12423 | result->value->type = wanted_type; |
| 12422 | return result; | 12424 | return result; |
| 12423 | } | 12425 | } |
| 12424 | | 12426 | |
| ... | @@ -12427,7 +12429,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12427,7 +12429,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12427 | { | 12429 | { |
| 12428 | assert(wanted_type->id == ZigTypeIdInt); | 12430 | assert(wanted_type->id == ZigTypeIdInt); |
| 12429 | | 12431 | |
| 12430 | ZigType *err_type = target->value.type; | 12432 | ZigType *err_type = target->value->type; |
| 12431 | | 12433 | |
| 12432 | if (instr_is_comptime(target)) { | 12434 | if (instr_is_comptime(target)) { |
| 12433 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 12435 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| ... | @@ -12444,11 +12446,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12444,11 +12446,11 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12444 | } else { | 12446 | } else { |
| 12445 | zig_unreachable(); | 12447 | zig_unreachable(); |
| 12446 | } | 12448 | } |
| 12447 | result->value.type = wanted_type; | 12449 | result->value->type = wanted_type; |
| 12448 | uint64_t err_value = err ? err->value : 0; | 12450 | uint64_t err_value = err ? err->value : 0; |
| 12449 | bigint_init_unsigned(&result->value.data.x_bigint, err_value); | 12451 | bigint_init_unsigned(&result->value->data.x_bigint, err_value); |
| 12450 | | 12452 | |
| 12451 | if (!bigint_fits_in_bits(&result->value.data.x_bigint, | 12453 | if (!bigint_fits_in_bits(&result->value->data.x_bigint, |
| 12452 | wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) | 12454 | wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) |
| 12453 | { | 12455 | { |
| 12454 | ir_add_error_node(ira, source_instr->source_node, | 12456 | ir_add_error_node(ira, source_instr->source_node, |
| ... | @@ -12474,12 +12476,12 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12474,12 +12476,12 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12474 | } | 12476 | } |
| 12475 | if (err_set_type->data.error_set.err_count == 0) { | 12477 | if (err_set_type->data.error_set.err_count == 0) { |
| 12476 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12478 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12477 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 12479 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 12478 | return result; | 12480 | return result; |
| 12479 | } else if (err_set_type->data.error_set.err_count == 1) { | 12481 | } else if (err_set_type->data.error_set.err_count == 1) { |
| 12480 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12482 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 12481 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; | 12483 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; |
| 12482 | bigint_init_unsigned(&result->value.data.x_bigint, err->value); | 12484 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); |
| 12483 | return result; | 12485 | return result; |
| 12484 | } | 12486 | } |
| 12485 | } | 12487 | } |
| ... | @@ -12493,7 +12495,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12493,7 +12495,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12493 | } | 12495 | } |
| 12494 | | 12496 | |
| 12495 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 12497 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); |
| 12496 | result->value.type = wanted_type; | 12498 | result->value->type = wanted_type; |
| 12497 | return result; | 12499 | return result; |
| 12498 | } | 12500 | } |
| 12499 | | 12501 | |
| ... | @@ -12502,10 +12504,10 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12502,10 +12504,10 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12502 | { | 12504 | { |
| 12503 | assert(wanted_type->id == ZigTypeIdPointer); | 12505 | assert(wanted_type->id == ZigTypeIdPointer); |
| 12504 | Error err; | 12506 | Error err; |
| 12505 | if ((err = type_resolve(ira->codegen, target->value.type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 12507 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 12506 | return ira->codegen->invalid_instruction; | 12508 | return ira->codegen->invalid_instruction; |
| 12507 | assert((wanted_type->data.pointer.is_const && target->value.type->data.pointer.is_const) || !target->value.type->data.pointer.is_const); | 12509 | assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const); |
| 12508 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value.type)); | 12510 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); |
| 12509 | ZigType *array_type = wanted_type->data.pointer.child_type; | 12511 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| 12510 | assert(array_type->id == ZigTypeIdArray); | 12512 | assert(array_type->id == ZigTypeIdArray); |
| 12511 | assert(array_type->data.array.len == 1); | 12513 | assert(array_type->data.array.len == 1); |
| ... | @@ -12530,11 +12532,11 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12530,11 +12532,11 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12530 | | 12532 | |
| 12531 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 12533 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 12532 | source_instr->scope, source_instr->source_node); | 12534 | source_instr->scope, source_instr->source_node); |
| 12533 | const_instruction->base.value.type = wanted_type; | 12535 | const_instruction->base.value->type = wanted_type; |
| 12534 | const_instruction->base.value.special = ConstValSpecialStatic; | 12536 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 12535 | const_instruction->base.value.data.x_ptr.special = ConstPtrSpecialRef; | 12537 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 12536 | const_instruction->base.value.data.x_ptr.data.ref.pointee = array_val; | 12538 | const_instruction->base.value->data.x_ptr.data.ref.pointee = array_val; |
| 12537 | const_instruction->base.value.data.x_ptr.mut = val->data.x_ptr.mut; | 12539 | const_instruction->base.value->data.x_ptr.mut = val->data.x_ptr.mut; |
| 12538 | return &const_instruction->base; | 12540 | return &const_instruction->base; |
| 12539 | } | 12541 | } |
| 12540 | } | 12542 | } |
| ... | @@ -12542,7 +12544,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12542,7 +12544,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 12542 | // pointer to array and pointer to single item are represented the same way at runtime | 12544 | // pointer to array and pointer to single item are represented the same way at runtime |
| 12543 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, | 12545 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, |
| 12544 | wanted_type, target, CastOpBitCast); | 12546 | wanted_type, target, CastOpBitCast); |
| 12545 | result->value.type = wanted_type; | 12547 | result->value->type = wanted_type; |
| 12546 | return result; | 12548 | return result; |
| 12547 | } | 12549 | } |
| 12548 | | 12550 | |
| ... | @@ -12726,8 +12728,8 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * | ... | @@ -12726,8 +12728,8 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * |
| 12726 | if (instr_is_comptime(array)) { | 12728 | if (instr_is_comptime(array)) { |
| 12727 | // arrays and vectors have the same ZigValue representation | 12729 | // arrays and vectors have the same ZigValue representation |
| 12728 | IrInstruction *result = ir_const(ira, source_instr, vector_type); | 12730 | IrInstruction *result = ir_const(ira, source_instr, vector_type); |
| 12729 | copy_const_val(&result->value, &array->value, false); | 12731 | copy_const_val(result->value, array->value, false); |
| 12730 | result->value.type = vector_type; | 12732 | result->value->type = vector_type; |
| 12731 | return result; | 12733 | return result; |
| 12732 | } | 12734 | } |
| 12733 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); | 12735 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); |
| ... | @@ -12739,8 +12741,8 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -12739,8 +12741,8 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 12739 | if (instr_is_comptime(vector)) { | 12741 | if (instr_is_comptime(vector)) { |
| 12740 | // arrays and vectors have the same ZigValue representation | 12742 | // arrays and vectors have the same ZigValue representation |
| 12741 | IrInstruction *result = ir_const(ira, source_instr, array_type); | 12743 | IrInstruction *result = ir_const(ira, source_instr, array_type); |
| 12742 | copy_const_val(&result->value, &vector->value, false); | 12744 | copy_const_val(result->value, vector->value, false); |
| 12743 | result->value.type = array_type; | 12745 | result->value->type = array_type; |
| 12744 | return result; | 12746 | return result; |
| 12745 | } | 12747 | } |
| 12746 | if (result_loc == nullptr) { | 12748 | if (result_loc == nullptr) { |
| ... | @@ -12748,7 +12750,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -12748,7 +12750,7 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 12748 | } | 12750 | } |
| 12749 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, | 12751 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, |
| 12750 | true, false, true); | 12752 | true, false, true); |
| 12751 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 12753 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 12752 | return result_loc_inst; | 12754 | return result_loc_inst; |
| 12753 | } | 12755 | } |
| 12754 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); | 12756 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); |
| ... | @@ -12761,23 +12763,23 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12761,23 +12763,23 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 12761 | if (instr_is_comptime(integer)) { | 12763 | if (instr_is_comptime(integer)) { |
| 12762 | unsigned_integer = integer; | 12764 | unsigned_integer = integer; |
| 12763 | } else { | 12765 | } else { |
| 12764 | assert(integer->value.type->id == ZigTypeIdInt); | 12766 | assert(integer->value->type->id == ZigTypeIdInt); |
| 12765 | | 12767 | |
| 12766 | if (integer->value.type->data.integral.bit_count > | 12768 | if (integer->value->type->data.integral.bit_count > |
| 12767 | ira->codegen->builtin_types.entry_usize->data.integral.bit_count) | 12769 | ira->codegen->builtin_types.entry_usize->data.integral.bit_count) |
| 12768 | { | 12770 | { |
| 12769 | ir_add_error(ira, source_instr, | 12771 | ir_add_error(ira, source_instr, |
| 12770 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", | 12772 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", |
| 12771 | buf_ptr(&integer->value.type->name), | 12773 | buf_ptr(&integer->value->type->name), |
| 12772 | buf_ptr(&dest_type->name))); | 12774 | buf_ptr(&dest_type->name))); |
| 12773 | return ira->codegen->invalid_instruction; | 12775 | return ira->codegen->invalid_instruction; |
| 12774 | } | 12776 | } |
| 12775 | | 12777 | |
| 12776 | if (integer->value.type->data.integral.is_signed) { | 12778 | if (integer->value->type->data.integral.is_signed) { |
| 12777 | ZigType *unsigned_int_type = get_int_type(ira->codegen, false, | 12779 | ZigType *unsigned_int_type = get_int_type(ira->codegen, false, |
| 12778 | integer->value.type->data.integral.bit_count); | 12780 | integer->value->type->data.integral.bit_count); |
| 12779 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); | 12781 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); |
| 12780 | if (type_is_invalid(unsigned_integer->value.type)) | 12782 | if (type_is_invalid(unsigned_integer->value->type)) |
| 12781 | return ira->codegen->invalid_instruction; | 12783 | return ira->codegen->invalid_instruction; |
| 12782 | } else { | 12784 | } else { |
| 12783 | unsigned_integer = integer; | 12785 | unsigned_integer = integer; |
| ... | @@ -12807,16 +12809,16 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12807,16 +12809,16 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou |
| 12807 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) | 12809 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) |
| 12808 | return ira->codegen->invalid_instruction; | 12810 | return ira->codegen->invalid_instruction; |
| 12809 | | 12811 | |
| 12810 | TypeEnumField *field = find_enum_type_field(enum_type, value->value.data.x_enum_literal); | 12812 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); |
| 12811 | if (field == nullptr) { | 12813 | if (field == nullptr) { |
| 12812 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'", | 12814 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("enum '%s' has no field named '%s'", |
| 12813 | buf_ptr(&enum_type->name), buf_ptr(value->value.data.x_enum_literal))); | 12815 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); |
| 12814 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, | 12816 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, |
| 12815 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); | 12817 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); |
| 12816 | return ira->codegen->invalid_instruction; | 12818 | return ira->codegen->invalid_instruction; |
| 12817 | } | 12819 | } |
| 12818 | IrInstruction *result = ir_const(ira, source_instr, enum_type); | 12820 | IrInstruction *result = ir_const(ira, source_instr, enum_type); |
| 12819 | bigint_init_bigint(&result->value.data.x_enum_tag, &field->value); | 12821 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); |
| 12820 | | 12822 | |
| 12821 | return result; | 12823 | return result; |
| 12822 | } | 12824 | } |
| ... | @@ -12885,7 +12887,7 @@ static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst | ... | @@ -12885,7 +12887,7 @@ static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst |
| 12885 | { | 12887 | { |
| 12886 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); | 12888 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); |
| 12887 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, | 12889 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, |
| 12888 | struct_operand->value.type, false); | 12890 | struct_operand->value->type, false); |
| 12889 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); | 12891 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); |
| 12890 | } | 12892 | } |
| 12891 | | 12893 | |
| ... | @@ -12893,7 +12895,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12893,7 +12895,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12893 | ZigType *wanted_type, IrInstruction *value) | 12895 | ZigType *wanted_type, IrInstruction *value) |
| 12894 | { | 12896 | { |
| 12895 | Error err; | 12897 | Error err; |
| 12896 | ZigType *actual_type = value->value.type; | 12898 | ZigType *actual_type = value->value->type; |
| 12897 | AstNode *source_node = source_instr->source_node; | 12899 | AstNode *source_node = source_instr->source_node; |
| 12898 | | 12900 | |
| 12899 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { | 12901 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { |
| ... | @@ -12915,13 +12917,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12915,13 +12917,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12915 | } | 12917 | } |
| 12916 | | 12918 | |
| 12917 | if (const_cast_result.id == ConstCastResultIdFnCC) { | 12919 | if (const_cast_result.id == ConstCastResultIdFnCC) { |
| 12918 | ir_assert(value->value.type->id == ZigTypeIdFn, source_instr); | 12920 | ir_assert(value->value->type->id == ZigTypeIdFn, source_instr); |
| 12919 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. | 12921 | // ConstCastResultIdFnCC is guaranteed to be the last one reported, meaning everything else is ok. |
| 12920 | if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync && | 12922 | if (wanted_type->data.fn.fn_type_id.cc == CallingConventionAsync && |
| 12921 | actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified) | 12923 | actual_type->data.fn.fn_type_id.cc == CallingConventionUnspecified) |
| 12922 | { | 12924 | { |
| 12923 | ir_assert(value->value.data.x_ptr.special == ConstPtrSpecialFunction, source_instr); | 12925 | ir_assert(value->value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| 12924 | ZigFn *fn = value->value.data.x_ptr.data.fn.fn_entry; | 12926 | ZigFn *fn = value->value->data.x_ptr.data.fn.fn_entry; |
| 12925 | if (fn->inferred_async_node == nullptr) { | 12927 | if (fn->inferred_async_node == nullptr) { |
| 12926 | fn->inferred_async_node = source_instr->source_node; | 12928 | fn->inferred_async_node = source_instr->source_node; |
| 12927 | } | 12929 | } |
| ... | @@ -12963,7 +12965,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12963,7 +12965,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12963 | { | 12965 | { |
| 12964 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, | 12966 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, |
| 12965 | wanted_child_type); | 12967 | wanted_child_type); |
| 12966 | if (type_is_invalid(cast1->value.type)) | 12968 | if (type_is_invalid(cast1->value->type)) |
| 12967 | return ira->codegen->invalid_instruction; | 12969 | return ira->codegen->invalid_instruction; |
| 12968 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); | 12970 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); |
| 12969 | } | 12971 | } |
| ... | @@ -12999,11 +13001,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -12999,11 +13001,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12999 | actual_type->id == ZigTypeIdComptimeFloat) | 13001 | actual_type->id == ZigTypeIdComptimeFloat) |
| 13000 | { | 13002 | { |
| 13001 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 13003 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13002 | if (type_is_invalid(cast1->value.type)) | 13004 | if (type_is_invalid(cast1->value->type)) |
| 13003 | return ira->codegen->invalid_instruction; | 13005 | return ira->codegen->invalid_instruction; |
| 13004 | | 13006 | |
| 13005 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13007 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13006 | if (type_is_invalid(cast2->value.type)) | 13008 | if (type_is_invalid(cast2->value->type)) |
| 13007 | return ira->codegen->invalid_instruction; | 13009 | return ira->codegen->invalid_instruction; |
| 13008 | | 13010 | |
| 13009 | return cast2; | 13011 | return cast2; |
| ... | @@ -13018,29 +13020,29 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13018,29 +13020,29 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13018 | (wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdComptimeInt || | 13020 | (wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdComptimeInt || |
| 13019 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) | 13021 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) |
| 13020 | { | 13022 | { |
| 13021 | if (value->value.special == ConstValSpecialUndef) { | 13023 | if (value->value->special == ConstValSpecialUndef) { |
| 13022 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13024 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13023 | result->value.special = ConstValSpecialUndef; | 13025 | result->value->special = ConstValSpecialUndef; |
| 13024 | return result; | 13026 | return result; |
| 13025 | } | 13027 | } |
| 13026 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { | 13028 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 13027 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { | 13029 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 13028 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13030 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13029 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 13031 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13030 | copy_const_val(&result->value, &value->value, false); | 13032 | copy_const_val(result->value, value->value, false); |
| 13031 | result->value.type = wanted_type; | 13033 | result->value->type = wanted_type; |
| 13032 | } else { | 13034 | } else { |
| 13033 | float_init_bigint(&result->value.data.x_bigint, &value->value); | 13035 | float_init_bigint(&result->value->data.x_bigint, value->value); |
| 13034 | } | 13036 | } |
| 13035 | return result; | 13037 | return result; |
| 13036 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { | 13038 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { |
| 13037 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13039 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 13038 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 13040 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13039 | BigFloat bf; | 13041 | BigFloat bf; |
| 13040 | bigfloat_init_bigint(&bf, &value->value.data.x_bigint); | 13042 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); |
| 13041 | float_init_bigfloat(&result->value, &bf); | 13043 | float_init_bigfloat(result->value, &bf); |
| 13042 | } else { | 13044 | } else { |
| 13043 | float_init_float(&result->value, &value->value); | 13045 | float_init_float(result->value, value->value); |
| 13044 | } | 13046 | } |
| 13045 | return result; | 13047 | return result; |
| 13046 | } | 13048 | } |
| ... | @@ -13102,11 +13104,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13102,11 +13104,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13102 | source_node, false).id == ConstCastResultIdOk) | 13104 | source_node, false).id == ConstCastResultIdOk) |
| 13103 | { | 13105 | { |
| 13104 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 13106 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13105 | if (type_is_invalid(cast1->value.type)) | 13107 | if (type_is_invalid(cast1->value->type)) |
| 13106 | return ira->codegen->invalid_instruction; | 13108 | return ira->codegen->invalid_instruction; |
| 13107 | | 13109 | |
| 13108 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13110 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13109 | if (type_is_invalid(cast2->value.type)) | 13111 | if (type_is_invalid(cast2->value->type)) |
| 13110 | return ira->codegen->invalid_instruction; | 13112 | return ira->codegen->invalid_instruction; |
| 13111 | | 13113 | |
| 13112 | return cast2; | 13114 | return cast2; |
| ... | @@ -13121,11 +13123,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13121,11 +13123,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13121 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 13123 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13122 | { | 13124 | { |
| 13123 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 13125 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13124 | if (type_is_invalid(cast1->value.type)) | 13126 | if (type_is_invalid(cast1->value->type)) |
| 13125 | return ira->codegen->invalid_instruction; | 13127 | return ira->codegen->invalid_instruction; |
| 13126 | | 13128 | |
| 13127 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13129 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13128 | if (type_is_invalid(cast2->value.type)) | 13130 | if (type_is_invalid(cast2->value->type)) |
| 13129 | return ira->codegen->invalid_instruction; | 13131 | return ira->codegen->invalid_instruction; |
| 13130 | | 13132 | |
| 13131 | return cast2; | 13133 | return cast2; |
| ... | @@ -13202,11 +13204,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13202,11 +13204,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13202 | if (ok_align) { | 13204 | if (ok_align) { |
| 13203 | if (wanted_type->id == ZigTypeIdErrorUnion) { | 13205 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 13204 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); | 13206 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); |
| 13205 | if (type_is_invalid(cast1->value.type)) | 13207 | if (type_is_invalid(cast1->value->type)) |
| 13206 | return ira->codegen->invalid_instruction; | 13208 | return ira->codegen->invalid_instruction; |
| 13207 | | 13209 | |
| 13208 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13210 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13209 | if (type_is_invalid(cast2->value.type)) | 13211 | if (type_is_invalid(cast2->value->type)) |
| 13210 | return ira->codegen->invalid_instruction; | 13212 | return ira->codegen->invalid_instruction; |
| 13211 | | 13213 | |
| 13212 | return cast2; | 13214 | return cast2; |
| ... | @@ -13309,11 +13311,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13309,11 +13311,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13309 | source_node, false).id == ConstCastResultIdOk) | 13311 | source_node, false).id == ConstCastResultIdOk) |
| 13310 | { | 13312 | { |
| 13311 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 13313 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13312 | if (type_is_invalid(cast1->value.type)) | 13314 | if (type_is_invalid(cast1->value->type)) |
| 13313 | return ira->codegen->invalid_instruction; | 13315 | return ira->codegen->invalid_instruction; |
| 13314 | | 13316 | |
| 13315 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 13317 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13316 | if (type_is_invalid(cast2->value.type)) | 13318 | if (type_is_invalid(cast2->value->type)) |
| 13317 | return ira->codegen->invalid_instruction; | 13319 | return ira->codegen->invalid_instruction; |
| 13318 | | 13320 | |
| 13319 | return cast2; | 13321 | return cast2; |
| ... | @@ -13529,13 +13531,13 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou | ... | @@ -13529,13 +13531,13 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou |
| 13529 | assert(value); | 13531 | assert(value); |
| 13530 | assert(value != ira->codegen->invalid_instruction); | 13532 | assert(value != ira->codegen->invalid_instruction); |
| 13531 | assert(!expected_type || !type_is_invalid(expected_type)); | 13533 | assert(!expected_type || !type_is_invalid(expected_type)); |
| 13532 | assert(value->value.type); | 13534 | assert(value->value->type); |
| 13533 | assert(!type_is_invalid(value->value.type)); | 13535 | assert(!type_is_invalid(value->value->type)); |
| 13534 | if (expected_type == nullptr) | 13536 | if (expected_type == nullptr) |
| 13535 | return value; // anything will do | 13537 | return value; // anything will do |
| 13536 | if (expected_type == value->value.type) | 13538 | if (expected_type == value->value->type) |
| 13537 | return value; // match | 13539 | return value; // match |
| 13538 | if (value->value.type->id == ZigTypeIdUnreachable) | 13540 | if (value->value->type->id == ZigTypeIdUnreachable) |
| 13539 | return value; | 13541 | return value; |
| 13540 | | 13542 | |
| 13541 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); | 13543 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); |
| ... | @@ -13549,7 +13551,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13549,7 +13551,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13549 | ResultLoc *result_loc) | 13551 | ResultLoc *result_loc) |
| 13550 | { | 13552 | { |
| 13551 | Error err; | 13553 | Error err; |
| 13552 | ZigType *ptr_type = ptr->value.type; | 13554 | ZigType *ptr_type = ptr->value->type; |
| 13553 | if (type_is_invalid(ptr_type)) | 13555 | if (type_is_invalid(ptr_type)) |
| 13554 | return ira->codegen->invalid_instruction; | 13556 | return ira->codegen->invalid_instruction; |
| 13555 | | 13557 | |
| ... | @@ -13571,24 +13573,24 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13571,24 +13573,24 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13571 | break; | 13573 | break; |
| 13572 | } | 13574 | } |
| 13573 | if (instr_is_comptime(ptr)) { | 13575 | if (instr_is_comptime(ptr)) { |
| 13574 | if (ptr->value.special == ConstValSpecialUndef) { | 13576 | if (ptr->value->special == ConstValSpecialUndef) { |
| 13575 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); | 13577 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); |
| 13576 | return ira->codegen->invalid_instruction; | 13578 | return ira->codegen->invalid_instruction; |
| 13577 | } | 13579 | } |
| 13578 | if (ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 13580 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 13579 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 13581 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 13580 | if (child_type == ira->codegen->builtin_types.entry_var) { | 13582 | if (child_type == ira->codegen->builtin_types.entry_var) { |
| 13581 | child_type = pointee->type; | 13583 | child_type = pointee->type; |
| 13582 | } | 13584 | } |
| 13583 | if (pointee->special != ConstValSpecialRuntime) { | 13585 | if (pointee->special != ConstValSpecialRuntime) { |
| 13584 | IrInstruction *result = ir_const(ira, source_instruction, child_type); | 13586 | IrInstruction *result = ir_const(ira, source_instruction, child_type); |
| 13585 | | 13587 | |
| 13586 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, &result->value, | 13588 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, |
| 13587 | &ptr->value))) | 13589 | ptr->value))) |
| 13588 | { | 13590 | { |
| 13589 | return ira->codegen->invalid_instruction; | 13591 | return ira->codegen->invalid_instruction; |
| 13590 | } | 13592 | } |
| 13591 | result->value.type = child_type; | 13593 | result->value->type = child_type; |
| 13592 | return result; | 13594 | return result; |
| 13593 | } | 13595 | } |
| 13594 | } | 13596 | } |
| ... | @@ -13626,7 +13628,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -13626,7 +13628,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 13626 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13628 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 13627 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, | 13629 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, |
| 13628 | true, false, true); | 13630 | true, false, true); |
| 13629 | if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) { | 13631 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { |
| 13630 | return result_loc_inst; | 13632 | return result_loc_inst; |
| 13631 | } | 13633 | } |
| 13632 | } else { | 13634 | } else { |
| ... | @@ -13660,15 +13662,15 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -13660,15 +13662,15 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 13660 | } | 13662 | } |
| 13661 | | 13663 | |
| 13662 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { | 13664 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { |
| 13663 | if (type_is_invalid(value->value.type)) | 13665 | if (type_is_invalid(value->value->type)) |
| 13664 | return false; | 13666 | return false; |
| 13665 | | 13667 | |
| 13666 | // Look for this pattern: `*align(@alignOf(T)) T`. | 13668 | // Look for this pattern: `*align(@alignOf(T)) T`. |
| 13667 | // This can be resolved to be `*out = 0` without resolving any alignment. | 13669 | // This can be resolved to be `*out = 0` without resolving any alignment. |
| 13668 | if (elem_type != nullptr && value->value.special == ConstValSpecialLazy && | 13670 | if (elem_type != nullptr && value->value->special == ConstValSpecialLazy && |
| 13669 | value->value.data.x_lazy->id == LazyValueIdAlignOf) | 13671 | value->value->data.x_lazy->id == LazyValueIdAlignOf) |
| 13670 | { | 13672 | { |
| 13671 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value.data.x_lazy); | 13673 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(value->value->data.x_lazy); |
| 13672 | | 13674 | |
| 13673 | ZigType *lazy_elem_type = ir_resolve_type(lazy_align_of->ira, lazy_align_of->target_type); | 13675 | ZigType *lazy_elem_type = ir_resolve_type(lazy_align_of->ira, lazy_align_of->target_type); |
| 13674 | if (type_is_invalid(lazy_elem_type)) | 13676 | if (type_is_invalid(lazy_elem_type)) |
| ... | @@ -13681,19 +13683,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem | ... | @@ -13681,19 +13683,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem |
| 13681 | } | 13683 | } |
| 13682 | | 13684 | |
| 13683 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | 13685 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); |
| 13684 | if (type_is_invalid(casted_value->value.type)) | 13686 | if (type_is_invalid(casted_value->value->type)) |
| 13685 | return false; | 13687 | return false; |
| 13686 | | 13688 | |
| 13687 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, | 13689 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, |
| 13688 | &casted_value->value, out); | 13690 | casted_value->value, out); |
| 13689 | } | 13691 | } |
| 13690 | | 13692 | |
| 13691 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { | 13693 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { |
| 13692 | if (type_is_invalid(value->value.type)) | 13694 | if (type_is_invalid(value->value->type)) |
| 13693 | return false; | 13695 | return false; |
| 13694 | | 13696 | |
| 13695 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); | 13697 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); |
| 13696 | if (type_is_invalid(casted_value->value.type)) | 13698 | if (type_is_invalid(casted_value->value->type)) |
| 13697 | return false; | 13699 | return false; |
| 13698 | | 13700 | |
| 13699 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13701 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13709,11 +13711,11 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out | ... | @@ -13709,11 +13711,11 @@ static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out |
| 13709 | } | 13711 | } |
| 13710 | | 13712 | |
| 13711 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | 13713 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 13712 | if (type_is_invalid(value->value.type)) | 13714 | if (type_is_invalid(value->value->type)) |
| 13713 | return false; | 13715 | return false; |
| 13714 | | 13716 | |
| 13715 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | 13717 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 13716 | if (type_is_invalid(casted_value->value.type)) | 13718 | if (type_is_invalid(casted_value->value->type)) |
| 13717 | return false; | 13719 | return false; |
| 13718 | | 13720 | |
| 13719 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13721 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13733,7 +13735,7 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) | ... | @@ -13733,7 +13735,7 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 13733 | } | 13735 | } |
| 13734 | | 13736 | |
| 13735 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { | 13737 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { |
| 13736 | if (type_is_invalid(value->value.type)) | 13738 | if (type_is_invalid(value->value->type)) |
| 13737 | return false; | 13739 | return false; |
| 13738 | | 13740 | |
| 13739 | ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); | 13741 | ZigValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); |
| ... | @@ -13741,7 +13743,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -13741,7 +13743,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13741 | ZigType *atomic_order_type = atomic_order_val->data.x_type; | 13743 | ZigType *atomic_order_type = atomic_order_val->data.x_type; |
| 13742 | | 13744 | |
| 13743 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | 13745 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 13744 | if (type_is_invalid(casted_value->value.type)) | 13746 | if (type_is_invalid(casted_value->value->type)) |
| 13745 | return false; | 13747 | return false; |
| 13746 | | 13748 | |
| 13747 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13749 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13753,7 +13755,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -13753,7 +13755,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13753 | } | 13755 | } |
| 13754 | | 13756 | |
| 13755 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { | 13757 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { |
| 13756 | if (type_is_invalid(value->value.type)) | 13758 | if (type_is_invalid(value->value->type)) |
| 13757 | return false; | 13759 | return false; |
| 13758 | | 13760 | |
| 13759 | ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); | 13761 | ZigValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); |
| ... | @@ -13761,7 +13763,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -13761,7 +13763,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13761 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; | 13763 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; |
| 13762 | | 13764 | |
| 13763 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | 13765 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| 13764 | if (type_is_invalid(casted_value->value.type)) | 13766 | if (type_is_invalid(casted_value->value->type)) |
| 13765 | return false; | 13767 | return false; |
| 13766 | | 13768 | |
| 13767 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13769 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13773,7 +13775,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -13773,7 +13775,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13773 | } | 13775 | } |
| 13774 | | 13776 | |
| 13775 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { | 13777 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { |
| 13776 | if (type_is_invalid(value->value.type)) | 13778 | if (type_is_invalid(value->value->type)) |
| 13777 | return false; | 13779 | return false; |
| 13778 | | 13780 | |
| 13779 | ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); | 13781 | ZigValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); |
| ... | @@ -13781,7 +13783,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -13781,7 +13783,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13781 | ZigType *global_linkage_type = global_linkage_val->data.x_type; | 13783 | ZigType *global_linkage_type = global_linkage_val->data.x_type; |
| 13782 | | 13784 | |
| 13783 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | 13785 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 13784 | if (type_is_invalid(casted_value->value.type)) | 13786 | if (type_is_invalid(casted_value->value->type)) |
| 13785 | return false; | 13787 | return false; |
| 13786 | | 13788 | |
| 13787 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13789 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13793,7 +13795,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -13793,7 +13795,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13793 | } | 13795 | } |
| 13794 | | 13796 | |
| 13795 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { | 13797 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { |
| 13796 | if (type_is_invalid(value->value.type)) | 13798 | if (type_is_invalid(value->value->type)) |
| 13797 | return false; | 13799 | return false; |
| 13798 | | 13800 | |
| 13799 | ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); | 13801 | ZigValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); |
| ... | @@ -13801,7 +13803,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -13801,7 +13803,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13801 | ZigType *float_mode_type = float_mode_val->data.x_type; | 13803 | ZigType *float_mode_type = float_mode_val->data.x_type; |
| 13802 | | 13804 | |
| 13803 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); | 13805 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| 13804 | if (type_is_invalid(casted_value->value.type)) | 13806 | if (type_is_invalid(casted_value->value->type)) |
| 13805 | return false; | 13807 | return false; |
| 13806 | | 13808 | |
| 13807 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13809 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13813,14 +13815,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -13813,14 +13815,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13813 | } | 13815 | } |
| 13814 | | 13816 | |
| 13815 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | 13817 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13816 | if (type_is_invalid(value->value.type)) | 13818 | if (type_is_invalid(value->value->type)) |
| 13817 | return nullptr; | 13819 | return nullptr; |
| 13818 | | 13820 | |
| 13819 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 13821 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 13820 | true, false, PtrLenUnknown, 0, 0, 0, false); | 13822 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 13821 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); | 13823 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 13822 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); | 13824 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); |
| 13823 | if (type_is_invalid(casted_value->value.type)) | 13825 | if (type_is_invalid(casted_value->value->type)) |
| 13824 | return nullptr; | 13826 | return nullptr; |
| 13825 | | 13827 | |
| 13826 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); | 13828 | ZigValue *const_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -13858,7 +13860,7 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -13858,7 +13860,7 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 13858 | IrInstructionAddImplicitReturnType *instruction) | 13860 | IrInstructionAddImplicitReturnType *instruction) |
| 13859 | { | 13861 | { |
| 13860 | IrInstruction *value = instruction->value->child; | 13862 | IrInstruction *value = instruction->value->child; |
| 13861 | if (type_is_invalid(value->value.type)) | 13863 | if (type_is_invalid(value->value->type)) |
| 13862 | return ir_unreach_error(ira); | 13864 | return ir_unreach_error(ira); |
| 13863 | | 13865 | |
| 13864 | if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) { | 13866 | if (instruction->result_loc_ret == nullptr || !instruction->result_loc_ret->implicit_return_type_done) { |
| ... | @@ -13870,11 +13872,11 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -13870,11 +13872,11 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 13870 | | 13872 | |
| 13871 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { | 13873 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { |
| 13872 | IrInstruction *operand = instruction->operand->child; | 13874 | IrInstruction *operand = instruction->operand->child; |
| 13873 | if (type_is_invalid(operand->value.type)) | 13875 | if (type_is_invalid(operand->value->type)) |
| 13874 | return ir_unreach_error(ira); | 13876 | return ir_unreach_error(ira); |
| 13875 | | 13877 | |
| 13876 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | 13878 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); |
| 13877 | if (type_is_invalid(casted_operand->value.type)) { | 13879 | if (type_is_invalid(casted_operand->value->type)) { |
| 13878 | AstNode *source_node = ira->explicit_return_type_source_node; | 13880 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 13879 | if (source_node != nullptr) { | 13881 | if (source_node != nullptr) { |
| 13880 | ErrorMsg *msg = ira->codegen->errors.last(); | 13882 | ErrorMsg *msg = ira->codegen->errors.last(); |
| ... | @@ -13890,13 +13892,13 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -13890,13 +13892,13 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 13890 | // result location mechanism took care of it. | 13892 | // result location mechanism took care of it. |
| 13891 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 13893 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, |
| 13892 | instruction->base.source_node, nullptr); | 13894 | instruction->base.source_node, nullptr); |
| 13893 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 13895 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 13894 | return ir_finish_anal(ira, result); | 13896 | return ir_finish_anal(ira, result); |
| 13895 | } | 13897 | } |
| 13896 | | 13898 | |
| 13897 | if (casted_operand->value.special == ConstValSpecialRuntime && | 13899 | if (casted_operand->value->special == ConstValSpecialRuntime && |
| 13898 | casted_operand->value.type->id == ZigTypeIdPointer && | 13900 | casted_operand->value->type->id == ZigTypeIdPointer && |
| 13899 | casted_operand->value.data.rh_ptr == RuntimeHintPtrStack) | 13901 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) |
| 13900 | { | 13902 | { |
| 13901 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); | 13903 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); |
| 13902 | return ir_unreach_error(ira); | 13904 | return ir_unreach_error(ira); |
| ... | @@ -13904,23 +13906,23 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -13904,23 +13906,23 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 13904 | | 13906 | |
| 13905 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 13907 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, |
| 13906 | instruction->base.source_node, casted_operand); | 13908 | instruction->base.source_node, casted_operand); |
| 13907 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 13909 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 13908 | return ir_finish_anal(ira, result); | 13910 | return ir_finish_anal(ira, result); |
| 13909 | } | 13911 | } |
| 13910 | | 13912 | |
| 13911 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { | 13913 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { |
| 13912 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 13914 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 13913 | copy_const_val(&result->value, &instruction->base.value, true); | 13915 | copy_const_val(result->value, instruction->base.value, true); |
| 13914 | return result; | 13916 | return result; |
| 13915 | } | 13917 | } |
| 13916 | | 13918 | |
| 13917 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 13919 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| 13918 | IrInstruction *op1 = bin_op_instruction->op1->child; | 13920 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 13919 | if (type_is_invalid(op1->value.type)) | 13921 | if (type_is_invalid(op1->value->type)) |
| 13920 | return ira->codegen->invalid_instruction; | 13922 | return ira->codegen->invalid_instruction; |
| 13921 | | 13923 | |
| 13922 | IrInstruction *op2 = bin_op_instruction->op2->child; | 13924 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 13923 | if (type_is_invalid(op2->value.type)) | 13925 | if (type_is_invalid(op2->value->type)) |
| 13924 | return ira->codegen->invalid_instruction; | 13926 | return ira->codegen->invalid_instruction; |
| 13925 | | 13927 | |
| 13926 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 13928 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| ... | @@ -13942,8 +13944,8 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -13942,8 +13944,8 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13942 | if (op2_val == nullptr) | 13944 | if (op2_val == nullptr) |
| 13943 | return ira->codegen->invalid_instruction; | 13945 | return ira->codegen->invalid_instruction; |
| 13944 | | 13946 | |
| 13945 | assert(casted_op1->value.type->id == ZigTypeIdBool); | 13947 | assert(casted_op1->value->type->id == ZigTypeIdBool); |
| 13946 | assert(casted_op2->value.type->id == ZigTypeIdBool); | 13948 | assert(casted_op2->value->type->id == ZigTypeIdBool); |
| 13947 | bool result_bool; | 13949 | bool result_bool; |
| 13948 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { | 13950 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { |
| 13949 | result_bool = op1_val->data.x_bool || op2_val->data.x_bool; | 13951 | result_bool = op1_val->data.x_bool || op2_val->data.x_bool; |
| ... | @@ -13958,7 +13960,7 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -13958,7 +13960,7 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13958 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 13960 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 13959 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 13961 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 13960 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 13962 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 13961 | result->value.type = bool_type; | 13963 | result->value->type = bool_type; |
| 13962 | return result; | 13964 | return result; |
| 13963 | } | 13965 | } |
| 13964 | | 13966 | |
| ... | @@ -14079,7 +14081,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { | ... | @@ -14079,7 +14081,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { |
| 14079 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); | 14081 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); |
| 14080 | IrAnalyze *ira = lazy_size_of->ira; | 14082 | IrAnalyze *ira = lazy_size_of->ira; |
| 14081 | bool is_zero_bits; | 14083 | bool is_zero_bits; |
| 14082 | if ((err = type_val_resolve_zero_bits(ira->codegen, &lazy_size_of->target_type->value, | 14084 | if ((err = type_val_resolve_zero_bits(ira->codegen, lazy_size_of->target_type->value, |
| 14083 | nullptr, nullptr, &is_zero_bits))) | 14085 | nullptr, nullptr, &is_zero_bits))) |
| 14084 | { | 14086 | { |
| 14085 | return err; | 14087 | return err; |
| ... | @@ -14098,27 +14100,27 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14098,27 +14100,27 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14098 | Error err; | 14100 | Error err; |
| 14099 | | 14101 | |
| 14100 | IrInstruction *op1 = bin_op_instruction->op1->child; | 14102 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 14101 | if (type_is_invalid(op1->value.type)) | 14103 | if (type_is_invalid(op1->value->type)) |
| 14102 | return ira->codegen->invalid_instruction; | 14104 | return ira->codegen->invalid_instruction; |
| 14103 | | 14105 | |
| 14104 | IrInstruction *op2 = bin_op_instruction->op2->child; | 14106 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 14105 | if (type_is_invalid(op2->value.type)) | 14107 | if (type_is_invalid(op2->value->type)) |
| 14106 | return ira->codegen->invalid_instruction; | 14108 | return ira->codegen->invalid_instruction; |
| 14107 | | 14109 | |
| 14108 | AstNode *source_node = bin_op_instruction->base.source_node; | 14110 | AstNode *source_node = bin_op_instruction->base.source_node; |
| 14109 | | 14111 | |
| 14110 | IrBinOp op_id = bin_op_instruction->op_id; | 14112 | IrBinOp op_id = bin_op_instruction->op_id; |
| 14111 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); | 14113 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); |
| 14112 | if (is_equality_cmp && op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdNull) { | 14114 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { |
| 14113 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); | 14115 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); |
| 14114 | } else if (is_equality_cmp && | 14116 | } else if (is_equality_cmp && |
| 14115 | ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdOptional) || | 14117 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || |
| 14116 | (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdOptional))) | 14118 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) |
| 14117 | { | 14119 | { |
| 14118 | IrInstruction *maybe_op; | 14120 | IrInstruction *maybe_op; |
| 14119 | if (op1->value.type->id == ZigTypeIdNull) { | 14121 | if (op1->value->type->id == ZigTypeIdNull) { |
| 14120 | maybe_op = op2; | 14122 | maybe_op = op2; |
| 14121 | } else if (op2->value.type->id == ZigTypeIdNull) { | 14123 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| 14122 | maybe_op = op1; | 14124 | maybe_op = op1; |
| 14123 | } else { | 14125 | } else { |
| 14124 | zig_unreachable(); | 14126 | zig_unreachable(); |
| ... | @@ -14134,26 +14136,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14134,26 +14136,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14134 | | 14136 | |
| 14135 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 14137 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, |
| 14136 | source_node, maybe_op); | 14138 | source_node, maybe_op); |
| 14137 | is_non_null->value.type = ira->codegen->builtin_types.entry_bool; | 14139 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; |
| 14138 | | 14140 | |
| 14139 | if (op_id == IrBinOpCmpEq) { | 14141 | if (op_id == IrBinOpCmpEq) { |
| 14140 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 14142 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, |
| 14141 | bin_op_instruction->base.source_node, is_non_null); | 14143 | bin_op_instruction->base.source_node, is_non_null); |
| 14142 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14144 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14143 | return result; | 14145 | return result; |
| 14144 | } else { | 14146 | } else { |
| 14145 | return is_non_null; | 14147 | return is_non_null; |
| 14146 | } | 14148 | } |
| 14147 | } else if (is_equality_cmp && | 14149 | } else if (is_equality_cmp && |
| 14148 | ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdPointer && | 14150 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdPointer && |
| 14149 | op2->value.type->data.pointer.ptr_len == PtrLenC) || | 14151 | op2->value->type->data.pointer.ptr_len == PtrLenC) || |
| 14150 | (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdPointer && | 14152 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && |
| 14151 | op1->value.type->data.pointer.ptr_len == PtrLenC))) | 14153 | op1->value->type->data.pointer.ptr_len == PtrLenC))) |
| 14152 | { | 14154 | { |
| 14153 | IrInstruction *c_ptr_op; | 14155 | IrInstruction *c_ptr_op; |
| 14154 | if (op1->value.type->id == ZigTypeIdNull) { | 14156 | if (op1->value->type->id == ZigTypeIdNull) { |
| 14155 | c_ptr_op = op2; | 14157 | c_ptr_op = op2; |
| 14156 | } else if (op2->value.type->id == ZigTypeIdNull) { | 14158 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| 14157 | c_ptr_op = op1; | 14159 | c_ptr_op = op1; |
| 14158 | } else { | 14160 | } else { |
| 14159 | zig_unreachable(); | 14161 | zig_unreachable(); |
| ... | @@ -14172,38 +14174,38 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14172,38 +14174,38 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14172 | } | 14174 | } |
| 14173 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 14175 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, |
| 14174 | source_node, c_ptr_op); | 14176 | source_node, c_ptr_op); |
| 14175 | is_non_null->value.type = ira->codegen->builtin_types.entry_bool; | 14177 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; |
| 14176 | | 14178 | |
| 14177 | if (op_id == IrBinOpCmpEq) { | 14179 | if (op_id == IrBinOpCmpEq) { |
| 14178 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 14180 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, |
| 14179 | bin_op_instruction->base.source_node, is_non_null); | 14181 | bin_op_instruction->base.source_node, is_non_null); |
| 14180 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14182 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14181 | return result; | 14183 | return result; |
| 14182 | } else { | 14184 | } else { |
| 14183 | return is_non_null; | 14185 | return is_non_null; |
| 14184 | } | 14186 | } |
| 14185 | } else if (op1->value.type->id == ZigTypeIdNull || op2->value.type->id == ZigTypeIdNull) { | 14187 | } else if (op1->value->type->id == ZigTypeIdNull || op2->value->type->id == ZigTypeIdNull) { |
| 14186 | ZigType *non_null_type = (op1->value.type->id == ZigTypeIdNull) ? op2->value.type : op1->value.type; | 14188 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; |
| 14187 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", | 14189 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", |
| 14188 | buf_ptr(&non_null_type->name))); | 14190 | buf_ptr(&non_null_type->name))); |
| 14189 | return ira->codegen->invalid_instruction; | 14191 | return ira->codegen->invalid_instruction; |
| 14190 | } else if (is_equality_cmp && ( | 14192 | } else if (is_equality_cmp && ( |
| 14191 | (op1->value.type->id == ZigTypeIdEnumLiteral && op2->value.type->id == ZigTypeIdUnion) || | 14193 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || |
| 14192 | (op2->value.type->id == ZigTypeIdEnumLiteral && op1->value.type->id == ZigTypeIdUnion))) | 14194 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) |
| 14193 | { | 14195 | { |
| 14194 | // Support equality comparison between a union's tag value and a enum literal | 14196 | // Support equality comparison between a union's tag value and a enum literal |
| 14195 | IrInstruction *union_val = op1->value.type->id == ZigTypeIdUnion ? op1 : op2; | 14197 | IrInstruction *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; |
| 14196 | IrInstruction *enum_val = op1->value.type->id == ZigTypeIdUnion ? op2 : op1; | 14198 | IrInstruction *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; |
| 14197 | | 14199 | |
| 14198 | ZigType *tag_type = union_val->value.type->data.unionation.tag_type; | 14200 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 14199 | assert(tag_type != nullptr); | 14201 | assert(tag_type != nullptr); |
| 14200 | | 14202 | |
| 14201 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); | 14203 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); |
| 14202 | if (type_is_invalid(casted_union->value.type)) | 14204 | if (type_is_invalid(casted_union->value->type)) |
| 14203 | return ira->codegen->invalid_instruction; | 14205 | return ira->codegen->invalid_instruction; |
| 14204 | | 14206 | |
| 14205 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | 14207 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); |
| 14206 | if (type_is_invalid(casted_val->value.type)) | 14208 | if (type_is_invalid(casted_val->value->type)) |
| 14207 | return ira->codegen->invalid_instruction; | 14209 | return ira->codegen->invalid_instruction; |
| 14208 | | 14210 | |
| 14209 | if (instr_is_comptime(casted_union)) { | 14211 | if (instr_is_comptime(casted_union)) { |
| ... | @@ -14224,17 +14226,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14224,17 +14226,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14224 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 14226 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 14225 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14227 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14226 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); | 14228 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); |
| 14227 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14229 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14228 | | 14230 | |
| 14229 | return result; | 14231 | return result; |
| 14230 | } | 14232 | } |
| 14231 | | 14233 | |
| 14232 | if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) { | 14234 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { |
| 14233 | if (!is_equality_cmp) { | 14235 | if (!is_equality_cmp) { |
| 14234 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); | 14236 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); |
| 14235 | return ira->codegen->invalid_instruction; | 14237 | return ira->codegen->invalid_instruction; |
| 14236 | } | 14238 | } |
| 14237 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value.type, op2->value.type, source_node); | 14239 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); |
| 14238 | if (type_is_invalid(intersect_type)) { | 14240 | if (type_is_invalid(intersect_type)) { |
| 14239 | return ira->codegen->invalid_instruction; | 14241 | return ira->codegen->invalid_instruction; |
| 14240 | } | 14242 | } |
| ... | @@ -14247,7 +14249,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14247,7 +14249,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14247 | // (and make it comptime known) | 14249 | // (and make it comptime known) |
| 14248 | // this is a function which is evaluated at comptime and returns an inferred error set will have an empty | 14250 | // this is a function which is evaluated at comptime and returns an inferred error set will have an empty |
| 14249 | // error set. | 14251 | // error set. |
| 14250 | if (op1->value.type->data.error_set.err_count == 0 || op2->value.type->data.error_set.err_count == 0) { | 14252 | if (op1->value->type->data.error_set.err_count == 0 || op2->value->type->data.error_set.err_count == 0) { |
| 14251 | bool are_equal = false; | 14253 | bool are_equal = false; |
| 14252 | bool answer; | 14254 | bool answer; |
| 14253 | if (op_id == IrBinOpCmpEq) { | 14255 | if (op_id == IrBinOpCmpEq) { |
| ... | @@ -14264,10 +14266,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14264,10 +14266,10 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14264 | if (intersect_type->data.error_set.err_count == 0) { | 14266 | if (intersect_type->data.error_set.err_count == 0) { |
| 14265 | ir_add_error_node(ira, source_node, | 14267 | ir_add_error_node(ira, source_node, |
| 14266 | buf_sprintf("error sets '%s' and '%s' have no common errors", | 14268 | buf_sprintf("error sets '%s' and '%s' have no common errors", |
| 14267 | buf_ptr(&op1->value.type->name), buf_ptr(&op2->value.type->name))); | 14269 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 14268 | return ira->codegen->invalid_instruction; | 14270 | return ira->codegen->invalid_instruction; |
| 14269 | } | 14271 | } |
| 14270 | if (op1->value.type->data.error_set.err_count == 1 && op2->value.type->data.error_set.err_count == 1) { | 14272 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { |
| 14271 | bool are_equal = true; | 14273 | bool are_equal = true; |
| 14272 | bool answer; | 14274 | bool answer; |
| 14273 | if (op_id == IrBinOpCmpEq) { | 14275 | if (op_id == IrBinOpCmpEq) { |
| ... | @@ -14305,7 +14307,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14305,7 +14307,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14305 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 14307 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 14306 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14308 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14307 | op_id, op1, op2, bin_op_instruction->safety_check_on); | 14309 | op_id, op1, op2, bin_op_instruction->safety_check_on); |
| 14308 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14310 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14309 | return result; | 14311 | return result; |
| 14310 | } | 14312 | } |
| 14311 | | 14313 | |
| ... | @@ -14390,12 +14392,12 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14390,12 +14392,12 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14390 | // Before resolving the values, we special case comparisons against zero. These can often be done | 14392 | // Before resolving the values, we special case comparisons against zero. These can often be done |
| 14391 | // without resolving lazy values, preventing potential dependency loops. | 14393 | // without resolving lazy values, preventing potential dependency loops. |
| 14392 | Cmp op1_cmp_zero; | 14394 | Cmp op1_cmp_zero; |
| 14393 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op1->value, &op1_cmp_zero))) { | 14395 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op1->value, &op1_cmp_zero))) { |
| 14394 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; | 14396 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; |
| 14395 | return ira->codegen->invalid_instruction; | 14397 | return ira->codegen->invalid_instruction; |
| 14396 | } | 14398 | } |
| 14397 | Cmp op2_cmp_zero; | 14399 | Cmp op2_cmp_zero; |
| 14398 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, &casted_op2->value, &op2_cmp_zero))) { | 14400 | if ((err = lazy_cmp_zero(bin_op_instruction->base.source_node, casted_op2->value, &op2_cmp_zero))) { |
| 14399 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; | 14401 | if (err == ErrorNotLazy) goto never_mind_just_calculate_it_normally; |
| 14400 | return ira->codegen->invalid_instruction; | 14402 | return ira->codegen->invalid_instruction; |
| 14401 | } | 14403 | } |
| ... | @@ -14430,26 +14432,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -14430,26 +14432,26 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14430 | } | 14432 | } |
| 14431 | never_mind_just_calculate_it_normally: | 14433 | never_mind_just_calculate_it_normally: |
| 14432 | | 14434 | |
| 14433 | ZigValue *op1_val = one_possible_value ? &casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); | 14435 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); |
| 14434 | if (op1_val == nullptr) | 14436 | if (op1_val == nullptr) |
| 14435 | return ira->codegen->invalid_instruction; | 14437 | return ira->codegen->invalid_instruction; |
| 14436 | ZigValue *op2_val = one_possible_value ? &casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); | 14438 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); |
| 14437 | if (op2_val == nullptr) | 14439 | if (op2_val == nullptr) |
| 14438 | return ira->codegen->invalid_instruction; | 14440 | return ira->codegen->invalid_instruction; |
| 14439 | if (resolved_type->id != ZigTypeIdVector) | 14441 | if (resolved_type->id != ZigTypeIdVector) |
| 14440 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); | 14442 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); |
| 14441 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, | 14443 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, |
| 14442 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); | 14444 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); |
| 14443 | result->value.data.x_array.data.s_none.elements = | 14445 | result->value->data.x_array.data.s_none.elements = |
| 14444 | create_const_vals(resolved_type->data.vector.len); | 14446 | create_const_vals(resolved_type->data.vector.len); |
| 14445 | | 14447 | |
| 14446 | expand_undef_array(ira->codegen, &result->value); | 14448 | expand_undef_array(ira->codegen, result->value); |
| 14447 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { | 14449 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| 14448 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | 14450 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, |
| 14449 | &op1_val->data.x_array.data.s_none.elements[i], | 14451 | &op1_val->data.x_array.data.s_none.elements[i], |
| 14450 | &op2_val->data.x_array.data.s_none.elements[i], | 14452 | &op2_val->data.x_array.data.s_none.elements[i], |
| 14451 | bin_op_instruction, op_id, one_possible_value); | 14453 | bin_op_instruction, op_id, one_possible_value); |
| 14452 | copy_const_val(&result->value.data.x_array.data.s_none.elements[i], &cur_res->value, false); | 14454 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], cur_res->value, false); |
| 14453 | } | 14455 | } |
| 14454 | return result; | 14456 | return result; |
| 14455 | } | 14457 | } |
| ... | @@ -14495,10 +14497,10 @@ never_mind_just_calculate_it_normally: | ... | @@ -14495,10 +14497,10 @@ never_mind_just_calculate_it_normally: |
| 14495 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 14497 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 14496 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 14498 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14497 | if (resolved_type->id == ZigTypeIdVector) { | 14499 | if (resolved_type->id == ZigTypeIdVector) { |
| 14498 | result->value.type = get_vector_type(ira->codegen, resolved_type->data.vector.len, | 14500 | result->value->type = get_vector_type(ira->codegen, resolved_type->data.vector.len, |
| 14499 | ira->codegen->builtin_types.entry_bool); | 14501 | ira->codegen->builtin_types.entry_bool); |
| 14500 | } else { | 14502 | } else { |
| 14501 | result->value.type = ira->codegen->builtin_types.entry_bool; | 14503 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 14502 | } | 14504 | } |
| 14503 | return result; | 14505 | return result; |
| 14504 | } | 14506 | } |
| ... | @@ -14687,7 +14689,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -14687,7 +14689,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14687 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) | 14689 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 14688 | { | 14690 | { |
| 14689 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); | 14691 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); |
| 14690 | ZigValue *out_val = &result_instruction->value; | 14692 | ZigValue *out_val = result_instruction->value; |
| 14691 | if (type_entry->id == ZigTypeIdVector) { | 14693 | if (type_entry->id == ZigTypeIdVector) { |
| 14692 | expand_undef_array(ira->codegen, op1_val); | 14694 | expand_undef_array(ira->codegen, op1_val); |
| 14693 | expand_undef_array(ira->codegen, op2_val); | 14695 | expand_undef_array(ira->codegen, op2_val); |
| ... | @@ -14722,52 +14724,52 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -14722,52 +14724,52 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14722 | | 14724 | |
| 14723 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 14725 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| 14724 | IrInstruction *op1 = bin_op_instruction->op1->child; | 14726 | IrInstruction *op1 = bin_op_instruction->op1->child; |
| 14725 | if (type_is_invalid(op1->value.type)) | 14727 | if (type_is_invalid(op1->value->type)) |
| 14726 | return ira->codegen->invalid_instruction; | 14728 | return ira->codegen->invalid_instruction; |
| 14727 | | 14729 | |
| 14728 | if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) { | 14730 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { |
| 14729 | ir_add_error(ira, bin_op_instruction->op1, | 14731 | ir_add_error(ira, bin_op_instruction->op1, |
| 14730 | buf_sprintf("bit shifting operation expected integer type, found '%s'", | 14732 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 14731 | buf_ptr(&op1->value.type->name))); | 14733 | buf_ptr(&op1->value->type->name))); |
| 14732 | return ira->codegen->invalid_instruction; | 14734 | return ira->codegen->invalid_instruction; |
| 14733 | } | 14735 | } |
| 14734 | | 14736 | |
| 14735 | IrInstruction *op2 = bin_op_instruction->op2->child; | 14737 | IrInstruction *op2 = bin_op_instruction->op2->child; |
| 14736 | if (type_is_invalid(op2->value.type)) | 14738 | if (type_is_invalid(op2->value->type)) |
| 14737 | return ira->codegen->invalid_instruction; | 14739 | return ira->codegen->invalid_instruction; |
| 14738 | | 14740 | |
| 14739 | if (op2->value.type->id != ZigTypeIdInt && op2->value.type->id != ZigTypeIdComptimeInt) { | 14741 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { |
| 14740 | ir_add_error(ira, bin_op_instruction->op2, | 14742 | ir_add_error(ira, bin_op_instruction->op2, |
| 14741 | buf_sprintf("shift amount has to be an integer type, but found '%s'", | 14743 | buf_sprintf("shift amount has to be an integer type, but found '%s'", |
| 14742 | buf_ptr(&op2->value.type->name))); | 14744 | buf_ptr(&op2->value->type->name))); |
| 14743 | return ira->codegen->invalid_instruction; | 14745 | return ira->codegen->invalid_instruction; |
| 14744 | } | 14746 | } |
| 14745 | | 14747 | |
| 14746 | IrInstruction *casted_op2; | 14748 | IrInstruction *casted_op2; |
| 14747 | IrBinOp op_id = bin_op_instruction->op_id; | 14749 | IrBinOp op_id = bin_op_instruction->op_id; |
| 14748 | if (op1->value.type->id == ZigTypeIdComptimeInt) { | 14750 | if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 14749 | casted_op2 = op2; | 14751 | casted_op2 = op2; |
| 14750 | | 14752 | |
| 14751 | if (op_id == IrBinOpBitShiftLeftLossy) { | 14753 | if (op_id == IrBinOpBitShiftLeftLossy) { |
| 14752 | op_id = IrBinOpBitShiftLeftExact; | 14754 | op_id = IrBinOpBitShiftLeftExact; |
| 14753 | } | 14755 | } |
| 14754 | | 14756 | |
| 14755 | if (casted_op2->value.data.x_bigint.is_negative) { | 14757 | if (casted_op2->value->data.x_bigint.is_negative) { |
| 14756 | Buf *val_buf = buf_alloc(); | 14758 | Buf *val_buf = buf_alloc(); |
| 14757 | bigint_append_buf(val_buf, &casted_op2->value.data.x_bigint, 10); | 14759 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); |
| 14758 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); | 14760 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 14759 | return ira->codegen->invalid_instruction; | 14761 | return ira->codegen->invalid_instruction; |
| 14760 | } | 14762 | } |
| 14761 | } else { | 14763 | } else { |
| 14762 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 14764 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 14763 | op1->value.type->data.integral.bit_count - 1); | 14765 | op1->value->type->data.integral.bit_count - 1); |
| 14764 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && | 14766 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && |
| 14765 | op2->value.type->id == ZigTypeIdComptimeInt) { | 14767 | op2->value->type->id == ZigTypeIdComptimeInt) { |
| 14766 | if (!bigint_fits_in_bits(&op2->value.data.x_bigint, | 14768 | if (!bigint_fits_in_bits(&op2->value->data.x_bigint, |
| 14767 | shift_amt_type->data.integral.bit_count, | 14769 | shift_amt_type->data.integral.bit_count, |
| 14768 | op2->value.data.x_bigint.is_negative)) { | 14770 | op2->value->data.x_bigint.is_negative)) { |
| 14769 | Buf *val_buf = buf_alloc(); | 14771 | Buf *val_buf = buf_alloc(); |
| 14770 | bigint_append_buf(val_buf, &op2->value.data.x_bigint, 10); | 14772 | bigint_append_buf(val_buf, &op2->value->data.x_bigint, 10); |
| 14771 | ErrorMsg* msg = ir_add_error(ira, | 14773 | ErrorMsg* msg = ir_add_error(ira, |
| 14772 | &bin_op_instruction->base, | 14774 | &bin_op_instruction->base, |
| 14773 | buf_sprintf("RHS of shift is too large for LHS type")); | 14775 | buf_sprintf("RHS of shift is too large for LHS type")); |
| ... | @@ -14796,22 +14798,22 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -14796,22 +14798,22 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 14796 | if (op2_val == nullptr) | 14798 | if (op2_val == nullptr) |
| 14797 | return ira->codegen->invalid_instruction; | 14799 | return ira->codegen->invalid_instruction; |
| 14798 | | 14800 | |
| 14799 | return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value.type, op1_val, op_id, op2_val); | 14801 | return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value->type, op1_val, op_id, op2_val); |
| 14800 | } else if (op1->value.type->id == ZigTypeIdComptimeInt) { | 14802 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 14801 | ir_add_error(ira, &bin_op_instruction->base, | 14803 | ir_add_error(ira, &bin_op_instruction->base, |
| 14802 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); | 14804 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 14803 | return ira->codegen->invalid_instruction; | 14805 | return ira->codegen->invalid_instruction; |
| 14804 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value.data.x_bigint) == CmpEQ) { | 14806 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { |
| 14805 | IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, | 14807 | IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, |
| 14806 | bin_op_instruction->base.source_node, op1->value.type, op1, CastOpNoop); | 14808 | bin_op_instruction->base.source_node, op1->value->type, op1, CastOpNoop); |
| 14807 | result->value.type = op1->value.type; | 14809 | result->value->type = op1->value->type; |
| 14808 | return result; | 14810 | return result; |
| 14809 | } | 14811 | } |
| 14810 | | 14812 | |
| 14811 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, | 14813 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, |
| 14812 | bin_op_instruction->base.source_node, op_id, | 14814 | bin_op_instruction->base.source_node, op_id, |
| 14813 | op1, casted_op2, bin_op_instruction->safety_check_on); | 14815 | op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14814 | result->value.type = op1->value.type; | 14816 | result->value->type = op1->value->type; |
| 14815 | return result; | 14817 | return result; |
| 14816 | } | 14818 | } |
| 14817 | | 14819 | |
| ... | @@ -14880,19 +14882,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14880,19 +14882,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14880 | Error err; | 14882 | Error err; |
| 14881 | | 14883 | |
| 14882 | IrInstruction *op1 = instruction->op1->child; | 14884 | IrInstruction *op1 = instruction->op1->child; |
| 14883 | if (type_is_invalid(op1->value.type)) | 14885 | if (type_is_invalid(op1->value->type)) |
| 14884 | return ira->codegen->invalid_instruction; | 14886 | return ira->codegen->invalid_instruction; |
| 14885 | | 14887 | |
| 14886 | IrInstruction *op2 = instruction->op2->child; | 14888 | IrInstruction *op2 = instruction->op2->child; |
| 14887 | if (type_is_invalid(op2->value.type)) | 14889 | if (type_is_invalid(op2->value->type)) |
| 14888 | return ira->codegen->invalid_instruction; | 14890 | return ira->codegen->invalid_instruction; |
| 14889 | | 14891 | |
| 14890 | IrBinOp op_id = instruction->op_id; | 14892 | IrBinOp op_id = instruction->op_id; |
| 14891 | | 14893 | |
| 14892 | // look for pointer math | 14894 | // look for pointer math |
| 14893 | if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) { | 14895 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { |
| 14894 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | 14896 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| 14895 | if (type_is_invalid(casted_op2->value.type)) | 14897 | if (type_is_invalid(casted_op2->value->type)) |
| 14896 | return ira->codegen->invalid_instruction; | 14898 | return ira->codegen->invalid_instruction; |
| 14897 | | 14899 | |
| 14898 | // If either operand is undef, result is undef. | 14900 | // If either operand is undef, result is undef. |
| ... | @@ -14903,19 +14905,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14903,19 +14905,19 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14903 | if (op1_val == nullptr) | 14905 | if (op1_val == nullptr) |
| 14904 | return ira->codegen->invalid_instruction; | 14906 | return ira->codegen->invalid_instruction; |
| 14905 | if (op1_val->special == ConstValSpecialUndef) | 14907 | if (op1_val->special == ConstValSpecialUndef) |
| 14906 | return ir_const_undef(ira, &instruction->base, op1->value.type); | 14908 | return ir_const_undef(ira, &instruction->base, op1->value->type); |
| 14907 | } | 14909 | } |
| 14908 | if (instr_is_comptime(casted_op2)) { | 14910 | if (instr_is_comptime(casted_op2)) { |
| 14909 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); | 14911 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); |
| 14910 | if (op2_val == nullptr) | 14912 | if (op2_val == nullptr) |
| 14911 | return ira->codegen->invalid_instruction; | 14913 | return ira->codegen->invalid_instruction; |
| 14912 | if (op2_val->special == ConstValSpecialUndef) | 14914 | if (op2_val->special == ConstValSpecialUndef) |
| 14913 | return ir_const_undef(ira, &instruction->base, op1->value.type); | 14915 | return ir_const_undef(ira, &instruction->base, op1->value->type); |
| 14914 | } | 14916 | } |
| 14915 | | 14917 | |
| 14916 | if (op2_val != nullptr && op1_val != nullptr && | 14918 | if (op2_val != nullptr && op1_val != nullptr && |
| 14917 | (op1->value.data.x_ptr.special == ConstPtrSpecialHardCodedAddr || | 14919 | (op1->value->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || |
| 14918 | op1->value.data.x_ptr.special == ConstPtrSpecialNull)) | 14920 | op1->value->data.x_ptr.special == ConstPtrSpecialNull)) |
| 14919 | { | 14921 | { |
| 14920 | uint64_t start_addr = (op1_val->data.x_ptr.special == ConstPtrSpecialNull) ? | 14922 | uint64_t start_addr = (op1_val->data.x_ptr.special == ConstPtrSpecialNull) ? |
| 14921 | 0 : op1_val->data.x_ptr.data.hard_coded_addr.addr; | 14923 | 0 : op1_val->data.x_ptr.data.hard_coded_addr.addr; |
| ... | @@ -14935,15 +14937,15 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14935,15 +14937,15 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14935 | zig_unreachable(); | 14937 | zig_unreachable(); |
| 14936 | } | 14938 | } |
| 14937 | IrInstruction *result = ir_const(ira, &instruction->base, op1_val->type); | 14939 | IrInstruction *result = ir_const(ira, &instruction->base, op1_val->type); |
| 14938 | result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 14940 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 14939 | result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar; | 14941 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 14940 | result->value.data.x_ptr.data.hard_coded_addr.addr = new_addr; | 14942 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; |
| 14941 | return result; | 14943 | return result; |
| 14942 | } | 14944 | } |
| 14943 | | 14945 | |
| 14944 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 14946 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, |
| 14945 | instruction->base.source_node, op_id, op1, casted_op2, true); | 14947 | instruction->base.source_node, op_id, op1, casted_op2, true); |
| 14946 | result->value.type = op1->value.type; | 14948 | result->value->type = op1->value->type; |
| 14947 | return result; | 14949 | return result; |
| 14948 | } | 14950 | } |
| 14949 | | 14951 | |
| ... | @@ -14958,11 +14960,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14958,11 +14960,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14958 | (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || | 14960 | (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || |
| 14959 | resolved_type->id == ZigTypeIdFloat || | 14961 | resolved_type->id == ZigTypeIdFloat || |
| 14960 | (resolved_type->id == ZigTypeIdComptimeFloat && | 14962 | (resolved_type->id == ZigTypeIdComptimeFloat && |
| 14961 | ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) != | 14963 | ((bigfloat_cmp_zero(&op1->value->data.x_bigfloat) != CmpGT) != |
| 14962 | (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) || | 14964 | (bigfloat_cmp_zero(&op2->value->data.x_bigfloat) != CmpGT))) || |
| 14963 | (resolved_type->id == ZigTypeIdComptimeInt && | 14965 | (resolved_type->id == ZigTypeIdComptimeInt && |
| 14964 | ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) != | 14966 | ((bigint_cmp_zero(&op1->value->data.x_bigint) != CmpGT) != |
| 14965 | (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT))) | 14967 | (bigint_cmp_zero(&op2->value->data.x_bigint) != CmpGT))) |
| 14966 | ); | 14968 | ); |
| 14967 | if (op_id == IrBinOpDivUnspecified && is_int) { | 14969 | if (op_id == IrBinOpDivUnspecified && is_int) { |
| 14968 | if (is_signed_div) { | 14970 | if (is_signed_div) { |
| ... | @@ -14995,8 +14997,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14995,8 +14997,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14995 | if (!ok) { | 14997 | if (!ok) { |
| 14996 | ir_add_error(ira, &instruction->base, | 14998 | ir_add_error(ira, &instruction->base, |
| 14997 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", | 14999 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", |
| 14998 | buf_ptr(&op1->value.type->name), | 15000 | buf_ptr(&op1->value->type->name), |
| 14999 | buf_ptr(&op2->value.type->name))); | 15001 | buf_ptr(&op2->value->type->name))); |
| 15000 | return ira->codegen->invalid_instruction; | 15002 | return ira->codegen->invalid_instruction; |
| 15001 | } | 15003 | } |
| 15002 | } else { | 15004 | } else { |
| ... | @@ -15015,7 +15017,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15015,7 +15017,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15015 | if (op2_val == nullptr) | 15017 | if (op2_val == nullptr) |
| 15016 | return ira->codegen->invalid_instruction; | 15018 | return ira->codegen->invalid_instruction; |
| 15017 | | 15019 | |
| 15018 | if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) { | 15020 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { |
| 15019 | // the division by zero error will be caught later, but we don't | 15021 | // the division by zero error will be caught later, but we don't |
| 15020 | // have a remainder function ambiguity problem | 15022 | // have a remainder function ambiguity problem |
| 15021 | ok = true; | 15023 | ok = true; |
| ... | @@ -15035,7 +15037,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15035,7 +15037,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15035 | if (op2_val == nullptr) | 15037 | if (op2_val == nullptr) |
| 15036 | return ira->codegen->invalid_instruction; | 15038 | return ira->codegen->invalid_instruction; |
| 15037 | | 15039 | |
| 15038 | if (float_cmp_zero(&casted_op2->value) == CmpEQ) { | 15040 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { |
| 15039 | // the division by zero error will be caught later, but we don't | 15041 | // the division by zero error will be caught later, but we don't |
| 15040 | // have a remainder function ambiguity problem | 15042 | // have a remainder function ambiguity problem |
| 15041 | ok = true; | 15043 | ok = true; |
| ... | @@ -15051,8 +15053,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15051,8 +15053,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15051 | if (!ok) { | 15053 | if (!ok) { |
| 15052 | ir_add_error(ira, &instruction->base, | 15054 | ir_add_error(ira, &instruction->base, |
| 15053 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", | 15055 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", |
| 15054 | buf_ptr(&op1->value.type->name), | 15056 | buf_ptr(&op1->value->type->name), |
| 15055 | buf_ptr(&op2->value.type->name))); | 15057 | buf_ptr(&op2->value->type->name))); |
| 15056 | return ira->codegen->invalid_instruction; | 15058 | return ira->codegen->invalid_instruction; |
| 15057 | } | 15059 | } |
| 15058 | } | 15060 | } |
| ... | @@ -15076,8 +15078,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15076,8 +15078,8 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15076 | AstNode *source_node = instruction->base.source_node; | 15078 | AstNode *source_node = instruction->base.source_node; |
| 15077 | ir_add_error_node(ira, source_node, | 15079 | ir_add_error_node(ira, source_node, |
| 15078 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", | 15080 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", |
| 15079 | buf_ptr(&op1->value.type->name), | 15081 | buf_ptr(&op1->value->type->name), |
| 15080 | buf_ptr(&op2->value.type->name))); | 15082 | buf_ptr(&op2->value->type->name))); |
| 15081 | return ira->codegen->invalid_instruction; | 15083 | return ira->codegen->invalid_instruction; |
| 15082 | } | 15084 | } |
| 15083 | | 15085 | |
| ... | @@ -15112,18 +15114,18 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15112,18 +15114,18 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15112 | | 15114 | |
| 15113 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 15115 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, |
| 15114 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); | 15116 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); |
| 15115 | result->value.type = resolved_type; | 15117 | result->value->type = resolved_type; |
| 15116 | return result; | 15118 | return result; |
| 15117 | } | 15119 | } |
| 15118 | | 15120 | |
| 15119 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 15121 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 15120 | IrInstruction *op1 = instruction->op1->child; | 15122 | IrInstruction *op1 = instruction->op1->child; |
| 15121 | ZigType *op1_type = op1->value.type; | 15123 | ZigType *op1_type = op1->value->type; |
| 15122 | if (type_is_invalid(op1_type)) | 15124 | if (type_is_invalid(op1_type)) |
| 15123 | return ira->codegen->invalid_instruction; | 15125 | return ira->codegen->invalid_instruction; |
| 15124 | | 15126 | |
| 15125 | IrInstruction *op2 = instruction->op2->child; | 15127 | IrInstruction *op2 = instruction->op2->child; |
| 15126 | ZigType *op2_type = op2->value.type; | 15128 | ZigType *op2_type = op2->value->type; |
| 15127 | if (type_is_invalid(op2_type)) | 15129 | if (type_is_invalid(op2_type)) |
| 15128 | return ira->codegen->invalid_instruction; | 15130 | return ira->codegen->invalid_instruction; |
| 15129 | | 15131 | |
| ... | @@ -15178,8 +15180,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15178,8 +15180,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15178 | op1_array_end = array_type->data.array.len; | 15180 | op1_array_end = array_type->data.array.len; |
| 15179 | sentinel1 = array_type->data.array.sentinel; | 15181 | sentinel1 = array_type->data.array.sentinel; |
| 15180 | } else { | 15182 | } else { |
| 15181 | ir_add_error(ira, op1, | 15183 | ir_add_error(ira, op1, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); |
| 15182 | buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value.type->name))); | | |
| 15183 | return ira->codegen->invalid_instruction; | 15184 | return ira->codegen->invalid_instruction; |
| 15184 | } | 15185 | } |
| 15185 | | 15186 | |
| ... | @@ -15229,13 +15230,13 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15229,13 +15230,13 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15229 | sentinel2 = array_type->data.array.sentinel; | 15230 | sentinel2 = array_type->data.array.sentinel; |
| 15230 | } else { | 15231 | } else { |
| 15231 | ir_add_error(ira, op2, | 15232 | ir_add_error(ira, op2, |
| 15232 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name))); | 15233 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); |
| 15233 | return ira->codegen->invalid_instruction; | 15234 | return ira->codegen->invalid_instruction; |
| 15234 | } | 15235 | } |
| 15235 | if (!op2_type_valid) { | 15236 | if (!op2_type_valid) { |
| 15236 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 15237 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 15237 | buf_ptr(&child_type->name), | 15238 | buf_ptr(&child_type->name), |
| 15238 | buf_ptr(&op2->value.type->name))); | 15239 | buf_ptr(&op2->value->type->name))); |
| 15239 | return ira->codegen->invalid_instruction; | 15240 | return ira->codegen->invalid_instruction; |
| 15240 | } | 15241 | } |
| 15241 | | 15242 | |
| ... | @@ -15254,13 +15255,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15254,13 +15255,12 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15254 | | 15255 | |
| 15255 | // The type of result is populated in the following if blocks | 15256 | // The type of result is populated in the following if blocks |
| 15256 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 15257 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 15257 | ZigValue *out_val = &result->value; | 15258 | ZigValue *out_val = result->value; |
| 15258 | | 15259 | |
| 15259 | ZigValue *out_array_val; | 15260 | ZigValue *out_array_val; |
| 15260 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); | 15261 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); |
| 15261 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { | 15262 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { |
| 15262 | result->value.type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15263 | result->value->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| 15263 | | | |
| 15264 | out_array_val = out_val; | 15264 | out_array_val = out_val; |
| 15265 | } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { | 15265 | } else if (op1_type->id == ZigTypeIdPointer || op2_type->id == ZigTypeIdPointer) { |
| 15266 | out_array_val = create_const_vals(1); | 15266 | out_array_val = create_const_vals(1); |
| ... | @@ -15274,7 +15274,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15274,7 +15274,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15274 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, child_type, | 15274 | ZigType *ptr_type = get_pointer_to_type_extra2(ira->codegen, child_type, |
| 15275 | true, false, PtrLenUnknown, 0, 0, 0, false, | 15275 | true, false, PtrLenUnknown, 0, 0, 0, false, |
| 15276 | VECTOR_INDEX_NONE, nullptr, sentinel); | 15276 | VECTOR_INDEX_NONE, nullptr, sentinel); |
| 15277 | result->value.type = get_slice_type(ira->codegen, ptr_type); | 15277 | result->value->type = get_slice_type(ira->codegen, ptr_type); |
| 15278 | out_array_val = create_const_vals(1); | 15278 | out_array_val = create_const_vals(1); |
| 15279 | out_array_val->special = ConstValSpecialStatic; | 15279 | out_array_val->special = ConstValSpecialStatic; |
| 15280 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15280 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | @@ -15291,9 +15291,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15291,9 +15291,8 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15291 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; | 15291 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; |
| 15292 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); | 15292 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); |
| 15293 | } else { | 15293 | } else { |
| 15294 | result->value.type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, | 15294 | result->value->type = get_pointer_to_type_extra2(ira->codegen, child_type, true, false, PtrLenUnknown, |
| 15295 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); | 15295 | 0, 0, 0, false, VECTOR_INDEX_NONE, nullptr, sentinel); |
| 15296 | | | |
| 15297 | out_array_val = create_const_vals(1); | 15296 | out_array_val = create_const_vals(1); |
| 15298 | out_array_val->special = ConstValSpecialStatic; | 15297 | out_array_val->special = ConstValSpecialStatic; |
| 15299 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); | 15298 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len, sentinel); |
| ... | @@ -15345,34 +15344,34 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -15345,34 +15344,34 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 15345 | | 15344 | |
| 15346 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 15345 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 15347 | IrInstruction *op1 = instruction->op1->child; | 15346 | IrInstruction *op1 = instruction->op1->child; |
| 15348 | if (type_is_invalid(op1->value.type)) | 15347 | if (type_is_invalid(op1->value->type)) |
| 15349 | return ira->codegen->invalid_instruction; | 15348 | return ira->codegen->invalid_instruction; |
| 15350 | | 15349 | |
| 15351 | IrInstruction *op2 = instruction->op2->child; | 15350 | IrInstruction *op2 = instruction->op2->child; |
| 15352 | if (type_is_invalid(op2->value.type)) | 15351 | if (type_is_invalid(op2->value->type)) |
| 15353 | return ira->codegen->invalid_instruction; | 15352 | return ira->codegen->invalid_instruction; |
| 15354 | | 15353 | |
| 15355 | bool want_ptr_to_array = false; | 15354 | bool want_ptr_to_array = false; |
| 15356 | ZigType *array_type; | 15355 | ZigType *array_type; |
| 15357 | ZigValue *array_val; | 15356 | ZigValue *array_val; |
| 15358 | if (op1->value.type->id == ZigTypeIdArray) { | 15357 | if (op1->value->type->id == ZigTypeIdArray) { |
| 15359 | array_type = op1->value.type; | 15358 | array_type = op1->value->type; |
| 15360 | array_val = ir_resolve_const(ira, op1, UndefOk); | 15359 | array_val = ir_resolve_const(ira, op1, UndefOk); |
| 15361 | if (array_val == nullptr) | 15360 | if (array_val == nullptr) |
| 15362 | return ira->codegen->invalid_instruction; | 15361 | return ira->codegen->invalid_instruction; |
| 15363 | } else if (op1->value.type->id == ZigTypeIdPointer && op1->value.type->data.pointer.ptr_len == PtrLenSingle && | 15362 | } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 15364 | op1->value.type->data.pointer.child_type->id == ZigTypeIdArray) | 15363 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) |
| 15365 | { | 15364 | { |
| 15366 | array_type = op1->value.type->data.pointer.child_type; | 15365 | array_type = op1->value->type->data.pointer.child_type; |
| 15367 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); | 15366 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); |
| 15368 | if (type_is_invalid(array_inst->value.type)) | 15367 | if (type_is_invalid(array_inst->value->type)) |
| 15369 | return ira->codegen->invalid_instruction; | 15368 | return ira->codegen->invalid_instruction; |
| 15370 | array_val = ir_resolve_const(ira, array_inst, UndefOk); | 15369 | array_val = ir_resolve_const(ira, array_inst, UndefOk); |
| 15371 | if (array_val == nullptr) | 15370 | if (array_val == nullptr) |
| 15372 | return ira->codegen->invalid_instruction; | 15371 | return ira->codegen->invalid_instruction; |
| 15373 | want_ptr_to_array = true; | 15372 | want_ptr_to_array = true; |
| 15374 | } else { | 15373 | } else { |
| 15375 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name))); | 15374 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); |
| 15376 | return ira->codegen->invalid_instruction; | 15375 | return ira->codegen->invalid_instruction; |
| 15377 | } | 15376 | } |
| 15378 | | 15377 | |
| ... | @@ -15397,7 +15396,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15397,7 +15396,7 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 15397 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); | 15396 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); |
| 15398 | } else { | 15397 | } else { |
| 15399 | array_result = ir_const(ira, &instruction->base, result_array_type); | 15398 | array_result = ir_const(ira, &instruction->base, result_array_type); |
| 15400 | ZigValue *out_val = &array_result->value; | 15399 | ZigValue *out_val = array_result->value; |
| 15401 | | 15400 | |
| 15402 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { | 15401 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { |
| 15403 | case OnePossibleValueInvalid: | 15402 | case OnePossibleValueInvalid: |
| ... | @@ -15554,16 +15553,16 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15554,16 +15553,16 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15554 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; | 15553 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; |
| 15555 | // if this is null, a compiler error happened and did not initialize the variable. | 15554 | // if this is null, a compiler error happened and did not initialize the variable. |
| 15556 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. | 15555 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. |
| 15557 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value.type)) { | 15556 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { |
| 15558 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); | 15557 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); |
| 15559 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 15558 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 15560 | return ira->codegen->invalid_instruction; | 15559 | return ira->codegen->invalid_instruction; |
| 15561 | } | 15560 | } |
| 15562 | | 15561 | |
| 15563 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. | 15562 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. |
| 15564 | ir_assert(var_ptr->value.type->id == ZigTypeIdPointer, &decl_var_instruction->base); | 15563 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base); |
| 15565 | | 15564 | |
| 15566 | ZigType *result_type = var_ptr->value.type->data.pointer.child_type; | 15565 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; |
| 15567 | if (type_is_invalid(result_type)) { | 15566 | if (type_is_invalid(result_type)) { |
| 15568 | result_type = ira->codegen->builtin_types.entry_invalid; | 15567 | result_type = ira->codegen->builtin_types.entry_invalid; |
| 15569 | } else if (result_type->id == ZigTypeIdUnreachable || result_type->id == ZigTypeIdOpaque) { | 15568 | } else if (result_type->id == ZigTypeIdUnreachable || result_type->id == ZigTypeIdOpaque) { |
| ... | @@ -15571,8 +15570,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15571,8 +15570,8 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15571 | } | 15570 | } |
| 15572 | | 15571 | |
| 15573 | ZigValue *init_val = nullptr; | 15572 | ZigValue *init_val = nullptr; |
| 15574 | if (instr_is_comptime(var_ptr) && var_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15573 | if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 15575 | init_val = const_ptr_pointee(ira, ira->codegen, &var_ptr->value, decl_var_instruction->base.source_node); | 15574 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.source_node); |
| 15576 | if (is_comptime_var) { | 15575 | if (is_comptime_var) { |
| 15577 | if (var->gen_is_const) { | 15576 | if (var->gen_is_const) { |
| 15578 | var->const_value = init_val; | 15577 | var->const_value = init_val; |
| ... | @@ -15665,23 +15664,23 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -15665,23 +15664,23 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 15665 | if (init_val != nullptr && value_is_comptime(init_val)) { | 15664 | if (init_val != nullptr && value_is_comptime(init_val)) { |
| 15666 | // Resolve ConstPtrMutInfer | 15665 | // Resolve ConstPtrMutInfer |
| 15667 | if (var->gen_is_const) { | 15666 | if (var->gen_is_const) { |
| 15668 | var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 15667 | var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 15669 | } else if (is_comptime_var) { | 15668 | } else if (is_comptime_var) { |
| 15670 | var_ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar; | 15669 | var_ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15671 | } else { | 15670 | } else { |
| 15672 | // we need a runtime ptr but we have a comptime val. | 15671 | // we need a runtime ptr but we have a comptime val. |
| 15673 | // since it's a comptime val there are no instructions for it. | 15672 | // since it's a comptime val there are no instructions for it. |
| 15674 | // we memcpy the init value here | 15673 | // we memcpy the init value here |
| 15675 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); | 15674 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); |
| 15676 | if (type_is_invalid(deref->value.type)) { | 15675 | if (type_is_invalid(deref->value->type)) { |
| 15677 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 15676 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 15678 | return ira->codegen->invalid_instruction; | 15677 | return ira->codegen->invalid_instruction; |
| 15679 | } | 15678 | } |
| 15680 | // If this assertion trips, something is wrong with the IR instructions, because | 15679 | // If this assertion trips, something is wrong with the IR instructions, because |
| 15681 | // we expected the above deref to return a constant value, but it created a runtime | 15680 | // we expected the above deref to return a constant value, but it created a runtime |
| 15682 | // instruction. | 15681 | // instruction. |
| 15683 | assert(deref->value.special != ConstValSpecialRuntime); | 15682 | assert(deref->value->special != ConstValSpecialRuntime); |
| 15684 | var_ptr->value.special = ConstValSpecialRuntime; | 15683 | var_ptr->value->special = ConstValSpecialRuntime; |
| 15685 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); | 15684 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); |
| 15686 | } | 15685 | } |
| 15687 | | 15686 | |
| ... | @@ -15718,7 +15717,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15718,7 +15717,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15718 | } | 15717 | } |
| 15719 | | 15718 | |
| 15720 | IrInstruction *target = instruction->target->child; | 15719 | IrInstruction *target = instruction->target->child; |
| 15721 | if (type_is_invalid(target->value.type)) { | 15720 | if (type_is_invalid(target->value->type)) { |
| 15722 | return ira->codegen->invalid_instruction; | 15721 | return ira->codegen->invalid_instruction; |
| 15723 | } | 15722 | } |
| 15724 | | 15723 | |
| ... | @@ -15748,13 +15747,13 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15748,13 +15747,13 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15748 | } | 15747 | } |
| 15749 | | 15748 | |
| 15750 | bool want_var_export = false; | 15749 | bool want_var_export = false; |
| 15751 | switch (target->value.type->id) { | 15750 | switch (target->value->type->id) { |
| 15752 | case ZigTypeIdInvalid: | 15751 | case ZigTypeIdInvalid: |
| 15753 | case ZigTypeIdUnreachable: | 15752 | case ZigTypeIdUnreachable: |
| 15754 | zig_unreachable(); | 15753 | zig_unreachable(); |
| 15755 | case ZigTypeIdFn: { | 15754 | case ZigTypeIdFn: { |
| 15756 | assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); | 15755 | assert(target->value->data.x_ptr.special == ConstPtrSpecialFunction); |
| 15757 | ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; | 15756 | ZigFn *fn_entry = target->value->data.x_ptr.data.fn.fn_entry; |
| 15758 | tld_fn->fn_entry = fn_entry; | 15757 | tld_fn->fn_entry = fn_entry; |
| 15759 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 15758 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| 15760 | switch (cc) { | 15759 | switch (cc) { |
| ... | @@ -15778,51 +15777,51 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15778,51 +15777,51 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15778 | } | 15777 | } |
| 15779 | } break; | 15778 | } break; |
| 15780 | case ZigTypeIdStruct: | 15779 | case ZigTypeIdStruct: |
| 15781 | if (is_slice(target->value.type)) { | 15780 | if (is_slice(target->value->type)) { |
| 15782 | ir_add_error(ira, target, | 15781 | ir_add_error(ira, target, |
| 15783 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value.type->name))); | 15782 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name))); |
| 15784 | } else if (target->value.type->data.structure.layout != ContainerLayoutExtern) { | 15783 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { |
| 15785 | ErrorMsg *msg = ir_add_error(ira, target, | 15784 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15786 | buf_sprintf("exported struct value must be declared extern")); | 15785 | buf_sprintf("exported struct value must be declared extern")); |
| 15787 | add_error_note(ira->codegen, msg, target->value.type->data.structure.decl_node, buf_sprintf("declared here")); | 15786 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); |
| 15788 | } else { | 15787 | } else { |
| 15789 | want_var_export = true; | 15788 | want_var_export = true; |
| 15790 | } | 15789 | } |
| 15791 | break; | 15790 | break; |
| 15792 | case ZigTypeIdUnion: | 15791 | case ZigTypeIdUnion: |
| 15793 | if (target->value.type->data.unionation.layout != ContainerLayoutExtern) { | 15792 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { |
| 15794 | ErrorMsg *msg = ir_add_error(ira, target, | 15793 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15795 | buf_sprintf("exported union value must be declared extern")); | 15794 | buf_sprintf("exported union value must be declared extern")); |
| 15796 | add_error_note(ira->codegen, msg, target->value.type->data.unionation.decl_node, buf_sprintf("declared here")); | 15795 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); |
| 15797 | } else { | 15796 | } else { |
| 15798 | want_var_export = true; | 15797 | want_var_export = true; |
| 15799 | } | 15798 | } |
| 15800 | break; | 15799 | break; |
| 15801 | case ZigTypeIdEnum: | 15800 | case ZigTypeIdEnum: |
| 15802 | if (target->value.type->data.enumeration.layout != ContainerLayoutExtern) { | 15801 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { |
| 15803 | ErrorMsg *msg = ir_add_error(ira, target, | 15802 | ErrorMsg *msg = ir_add_error(ira, target, |
| 15804 | buf_sprintf("exported enum value must be declared extern")); | 15803 | buf_sprintf("exported enum value must be declared extern")); |
| 15805 | add_error_note(ira->codegen, msg, target->value.type->data.enumeration.decl_node, buf_sprintf("declared here")); | 15804 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 15806 | } else { | 15805 | } else { |
| 15807 | want_var_export = true; | 15806 | want_var_export = true; |
| 15808 | } | 15807 | } |
| 15809 | break; | 15808 | break; |
| 15810 | case ZigTypeIdArray: { | 15809 | case ZigTypeIdArray: { |
| 15811 | bool ok_type; | 15810 | bool ok_type; |
| 15812 | if ((err = type_allowed_in_extern(ira->codegen, target->value.type->data.array.child_type, &ok_type))) | 15811 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) |
| 15813 | return ira->codegen->invalid_instruction; | 15812 | return ira->codegen->invalid_instruction; |
| 15814 | | 15813 | |
| 15815 | if (!ok_type) { | 15814 | if (!ok_type) { |
| 15816 | ir_add_error(ira, target, | 15815 | ir_add_error(ira, target, |
| 15817 | buf_sprintf("array element type '%s' not extern-compatible", | 15816 | buf_sprintf("array element type '%s' not extern-compatible", |
| 15818 | buf_ptr(&target->value.type->data.array.child_type->name))); | 15817 | buf_ptr(&target->value->type->data.array.child_type->name))); |
| 15819 | } else { | 15818 | } else { |
| 15820 | want_var_export = true; | 15819 | want_var_export = true; |
| 15821 | } | 15820 | } |
| 15822 | break; | 15821 | break; |
| 15823 | } | 15822 | } |
| 15824 | case ZigTypeIdMetaType: { | 15823 | case ZigTypeIdMetaType: { |
| 15825 | ZigType *type_value = target->value.data.x_type; | 15824 | ZigType *type_value = target->value->data.x_type; |
| 15826 | switch (type_value->id) { | 15825 | switch (type_value->id) { |
| 15827 | case ZigTypeIdInvalid: | 15826 | case ZigTypeIdInvalid: |
| 15828 | zig_unreachable(); | 15827 | zig_unreachable(); |
| ... | @@ -15898,7 +15897,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15898,7 +15897,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15898 | case ZigTypeIdErrorUnion: | 15897 | case ZigTypeIdErrorUnion: |
| 15899 | case ZigTypeIdErrorSet: | 15898 | case ZigTypeIdErrorSet: |
| 15900 | case ZigTypeIdVector: | 15899 | case ZigTypeIdVector: |
| 15901 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name)); | 15900 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value->type->name)); |
| 15902 | case ZigTypeIdBoundFn: | 15901 | case ZigTypeIdBoundFn: |
| 15903 | case ZigTypeIdArgTuple: | 15902 | case ZigTypeIdArgTuple: |
| 15904 | case ZigTypeIdOpaque: | 15903 | case ZigTypeIdOpaque: |
| ... | @@ -15906,7 +15905,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -15906,7 +15905,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 15906 | case ZigTypeIdFnFrame: | 15905 | case ZigTypeIdFnFrame: |
| 15907 | case ZigTypeIdAnyFrame: | 15906 | case ZigTypeIdAnyFrame: |
| 15908 | ir_add_error(ira, target, | 15907 | ir_add_error(ira, target, |
| 15909 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); | 15908 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); |
| 15910 | break; | 15909 | break; |
| 15911 | } | 15910 | } |
| 15912 | | 15911 | |
| ... | @@ -15936,7 +15935,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | ... | @@ -15936,7 +15935,7 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 15936 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); | 15935 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); |
| 15937 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { | 15936 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { |
| 15938 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); | 15937 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); |
| 15939 | ZigValue *out_val = &result->value; | 15938 | ZigValue *out_val = result->value; |
| 15940 | assert(get_codegen_ptr_type(optional_type) != nullptr); | 15939 | assert(get_codegen_ptr_type(optional_type) != nullptr); |
| 15941 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 15940 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 15942 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; | 15941 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; |
| ... | @@ -15944,13 +15943,13 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | ... | @@ -15944,13 +15943,13 @@ static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 15944 | } | 15943 | } |
| 15945 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 15944 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, |
| 15946 | instruction->base.source_node, instruction->optional); | 15945 | instruction->base.source_node, instruction->optional); |
| 15947 | new_instruction->value.type = optional_type; | 15946 | new_instruction->value->type = optional_type; |
| 15948 | return new_instruction; | 15947 | return new_instruction; |
| 15949 | } else { | 15948 | } else { |
| 15950 | assert(ira->codegen->have_err_ret_tracing); | 15949 | assert(ira->codegen->have_err_ret_tracing); |
| 15951 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 15950 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, |
| 15952 | instruction->base.source_node, instruction->optional); | 15951 | instruction->base.source_node, instruction->optional); |
| 15953 | new_instruction->value.type = ptr_to_stack_trace_type; | 15952 | new_instruction->value->type = ptr_to_stack_trace_type; |
| 15954 | return new_instruction; | 15953 | return new_instruction; |
| 15955 | } | 15954 | } |
| 15956 | } | 15955 | } |
| ... | @@ -15959,11 +15958,11 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -15959,11 +15958,11 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 15959 | IrInstructionErrorUnion *instruction) | 15958 | IrInstructionErrorUnion *instruction) |
| 15960 | { | 15959 | { |
| 15961 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 15960 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 15962 | result->value.special = ConstValSpecialLazy; | 15961 | result->value->special = ConstValSpecialLazy; |
| 15963 | | 15962 | |
| 15964 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1); | 15963 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1); |
| 15965 | lazy_err_union_type->ira = ira; | 15964 | lazy_err_union_type->ira = ira; |
| 15966 | result->value.data.x_lazy = &lazy_err_union_type->base; | 15965 | result->value->data.x_lazy = &lazy_err_union_type->base; |
| 15967 | lazy_err_union_type->base.id = LazyValueIdErrUnionType; | 15966 | lazy_err_union_type->base.id = LazyValueIdErrUnionType; |
| 15968 | | 15967 | |
| 15969 | lazy_err_union_type->err_set_type = instruction->err_set->child; | 15968 | lazy_err_union_type->err_set_type = instruction->err_set->child; |
| ... | @@ -15986,10 +15985,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -15986,10 +15985,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 15986 | pointee->special = ConstValSpecialUndef; | 15985 | pointee->special = ConstValSpecialUndef; |
| 15987 | | 15986 | |
| 15988 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); | 15987 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); |
| 15989 | result->base.value.special = ConstValSpecialStatic; | 15988 | result->base.value->special = ConstValSpecialStatic; |
| 15990 | result->base.value.data.x_ptr.special = ConstPtrSpecialRef; | 15989 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 15991 | result->base.value.data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; | 15990 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; |
| 15992 | result->base.value.data.x_ptr.data.ref.pointee = pointee; | 15991 | result->base.value->data.x_ptr.data.ref.pointee = pointee; |
| 15993 | | 15992 | |
| 15994 | bool var_type_has_bits; | 15993 | bool var_type_has_bits; |
| 15995 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) | 15994 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) |
| ... | @@ -16004,10 +16003,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -16004,10 +16003,10 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 16004 | return ira->codegen->invalid_instruction; | 16003 | return ira->codegen->invalid_instruction; |
| 16005 | } | 16004 | } |
| 16006 | } | 16005 | } |
| 16007 | assert(result->base.value.data.x_ptr.special != ConstPtrSpecialInvalid); | 16006 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); |
| 16008 | | 16007 | |
| 16009 | pointee->type = var_type; | 16008 | pointee->type = var_type; |
| 16010 | result->base.value.type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, | 16009 | result->base.value->type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, |
| 16011 | PtrLenSingle, align, 0, 0, false); | 16010 | PtrLenSingle, align, 0, 0, false); |
| 16012 | | 16011 | |
| 16013 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 16012 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| ... | @@ -16031,7 +16030,7 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16031,7 +16030,7 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspe |
| 16031 | case ResultLocIdCast: | 16030 | case ResultLocIdCast: |
| 16032 | return nullptr; | 16031 | return nullptr; |
| 16033 | case ResultLocIdInstruction: | 16032 | case ResultLocIdInstruction: |
| 16034 | return result_loc->source_instruction->child->value.type; | 16033 | return result_loc->source_instruction->child->value->type; |
| 16035 | case ResultLocIdReturn: | 16034 | case ResultLocIdReturn: |
| 16036 | return ira->explicit_return_type; | 16035 | return ira->explicit_return_type; |
| 16037 | case ResultLocIdPeer: | 16036 | case ResultLocIdPeer: |
| ... | @@ -16064,12 +16063,12 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -16064,12 +16063,12 @@ static bool type_can_bit_cast(ZigType *t) { |
| 16064 | | 16063 | |
| 16065 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { | 16064 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { |
| 16066 | ZigValue *undef_child = create_const_vals(1); | 16065 | ZigValue *undef_child = create_const_vals(1); |
| 16067 | undef_child->type = ptr->value.type->data.pointer.child_type; | 16066 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 16068 | undef_child->special = ConstValSpecialUndef; | 16067 | undef_child->special = ConstValSpecialUndef; |
| 16069 | ptr->value.special = ConstValSpecialStatic; | 16068 | ptr->value->special = ConstValSpecialStatic; |
| 16070 | ptr->value.data.x_ptr.mut = ConstPtrMutInfer; | 16069 | ptr->value->data.x_ptr.mut = ConstPtrMutInfer; |
| 16071 | ptr->value.data.x_ptr.special = ConstPtrSpecialRef; | 16070 | ptr->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16072 | ptr->value.data.x_ptr.data.ref.pointee = undef_child; | 16071 | ptr->value->data.x_ptr.data.ref.pointee = undef_child; |
| 16073 | } | 16072 | } |
| 16074 | | 16073 | |
| 16075 | static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out) { | 16074 | static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out) { |
| ... | @@ -16105,7 +16104,7 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su | ... | @@ -16105,7 +16104,7 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su |
| 16105 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) | 16104 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) |
| 16106 | { | 16105 | { |
| 16107 | IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); | 16106 | IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); |
| 16108 | alloca_gen->base.value.type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, | 16107 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 16109 | PtrLenSingle, 0, 0, 0, false); | 16108 | PtrLenSingle, 0, 0, 0, false); |
| 16110 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); | 16109 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); |
| 16111 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 16110 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| ... | @@ -16158,7 +16157,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16158,7 +16157,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16158 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) | 16157 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) |
| 16159 | return ira->codegen->invalid_instruction; | 16158 | return ira->codegen->invalid_instruction; |
| 16160 | bool is_comptime = force_comptime || (value != nullptr && | 16159 | bool is_comptime = force_comptime || (value != nullptr && |
| 16161 | value->value.special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); | 16160 | value->value->special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); |
| 16162 | | 16161 | |
| 16163 | if (alloca_src->base.child == nullptr || is_comptime) { | 16162 | if (alloca_src->base.child == nullptr || is_comptime) { |
| 16164 | uint32_t align = 0; | 16163 | uint32_t align = 0; |
| ... | @@ -16167,8 +16166,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16167,8 +16166,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16167 | } | 16166 | } |
| 16168 | IrInstruction *alloca_gen; | 16167 | IrInstruction *alloca_gen; |
| 16169 | if (is_comptime && value != nullptr) { | 16168 | if (is_comptime && value != nullptr) { |
| 16170 | if (align > value->value.global_refs->align) { | 16169 | if (align > value->value->global_refs->align) { |
| 16171 | value->value.global_refs->align = align; | 16170 | value->value->global_refs->align = align; |
| 16172 | } | 16171 | } |
| 16173 | alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false); | 16172 | alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false); |
| 16174 | } else { | 16173 | } else { |
| ... | @@ -16191,7 +16190,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16191,7 +16190,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16191 | } | 16190 | } |
| 16192 | case ResultLocIdReturn: { | 16191 | case ResultLocIdReturn: { |
| 16193 | if (!non_null_comptime) { | 16192 | if (!non_null_comptime) { |
| 16194 | bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime; | 16193 | bool is_comptime = value != nullptr && value->value->special != ConstValSpecialRuntime; |
| 16195 | if (is_comptime) | 16194 | if (is_comptime) |
| 16196 | return nullptr; | 16195 | return nullptr; |
| 16197 | } | 16196 | } |
| ... | @@ -16222,8 +16221,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16222,8 +16221,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16222 | value_type, value, force_runtime, non_null_comptime, true); | 16221 | value_type, value, force_runtime, non_null_comptime, true); |
| 16223 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; | 16222 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; |
| 16224 | result_peer->suspend_pos.instruction_index = SIZE_MAX; | 16223 | result_peer->suspend_pos.instruction_index = SIZE_MAX; |
| 16225 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16224 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16226 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16225 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16227 | { | 16226 | { |
| 16228 | return parent_result_loc; | 16227 | return parent_result_loc; |
| 16229 | } | 16228 | } |
| ... | @@ -16270,19 +16269,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16270,19 +16269,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16270 | | 16269 | |
| 16271 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 16270 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 16272 | peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true); | 16271 | peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true); |
| 16273 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16272 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16274 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16273 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16275 | { | 16274 | { |
| 16276 | return parent_result_loc; | 16275 | return parent_result_loc; |
| 16277 | } | 16276 | } |
| 16278 | // because is_comptime is false, we mark this a runtime pointer | 16277 | // because is_comptime is false, we mark this a runtime pointer |
| 16279 | parent_result_loc->value.special = ConstValSpecialRuntime; | 16278 | parent_result_loc->value->special = ConstValSpecialRuntime; |
| 16280 | result_loc->written = true; | 16279 | result_loc->written = true; |
| 16281 | result_loc->resolved_loc = parent_result_loc; | 16280 | result_loc->resolved_loc = parent_result_loc; |
| 16282 | return result_loc->resolved_loc; | 16281 | return result_loc->resolved_loc; |
| 16283 | } | 16282 | } |
| 16284 | case ResultLocIdCast: { | 16283 | case ResultLocIdCast: { |
| 16285 | if (value != nullptr && value->value.special != ConstValSpecialRuntime) | 16284 | if (value != nullptr && value->value->special != ConstValSpecialRuntime) |
| 16286 | return nullptr; | 16285 | return nullptr; |
| 16287 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); | 16286 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); |
| 16288 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); | 16287 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| ... | @@ -16313,19 +16312,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16313,19 +16312,19 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16313 | casted_value = nullptr; | 16312 | casted_value = nullptr; |
| 16314 | } | 16313 | } |
| 16315 | | 16314 | |
| 16316 | if (casted_value != nullptr && type_is_invalid(casted_value->value.type)) { | 16315 | if (casted_value != nullptr && type_is_invalid(casted_value->value->type)) { |
| 16317 | return casted_value; | 16316 | return casted_value; |
| 16318 | } | 16317 | } |
| 16319 | | 16318 | |
| 16320 | bool old_parent_result_loc_written = result_cast->parent->written; | 16319 | bool old_parent_result_loc_written = result_cast->parent->written; |
| 16321 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | 16320 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, |
| 16322 | dest_type, casted_value, force_runtime, non_null_comptime, true); | 16321 | dest_type, casted_value, force_runtime, non_null_comptime, true); |
| 16323 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16322 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16324 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16323 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16325 | { | 16324 | { |
| 16326 | return parent_result_loc; | 16325 | return parent_result_loc; |
| 16327 | } | 16326 | } |
| 16328 | ZigType *parent_ptr_type = parent_result_loc->value.type; | 16327 | ZigType *parent_ptr_type = parent_result_loc->value->type; |
| 16329 | assert(parent_ptr_type->id == ZigTypeIdPointer); | 16328 | assert(parent_ptr_type->id == ZigTypeIdPointer); |
| 16330 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 16329 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 16331 | ResolveStatusAlignmentKnown))) | 16330 | ResolveStatusAlignmentKnown))) |
| ... | @@ -16358,7 +16357,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16358,7 +16357,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16358 | { | 16357 | { |
| 16359 | // we also need to check that this cast is OK. | 16358 | // we also need to check that this cast is OK. |
| 16360 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | 16359 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, |
| 16361 | parent_result_loc->value.type, ptr_type, | 16360 | parent_result_loc->value->type, ptr_type, |
| 16362 | result_cast->base.source_instruction->source_node, false); | 16361 | result_cast->base.source_instruction->source_node, false); |
| 16363 | if (const_cast_result.id == ConstCastResultIdInvalid) | 16362 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 16364 | return ira->codegen->invalid_instruction; | 16363 | return ira->codegen->invalid_instruction; |
| ... | @@ -16413,18 +16412,18 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -16413,18 +16412,18 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16413 | bitcasted_value = nullptr; | 16412 | bitcasted_value = nullptr; |
| 16414 | } | 16413 | } |
| 16415 | | 16414 | |
| 16416 | if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value.type)) { | 16415 | if (bitcasted_value == nullptr || type_is_invalid(bitcasted_value->value->type)) { |
| 16417 | return bitcasted_value; | 16416 | return bitcasted_value; |
| 16418 | } | 16417 | } |
| 16419 | | 16418 | |
| 16420 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | 16419 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, |
| 16421 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); | 16420 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); |
| 16422 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value.type) || | 16421 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 16423 | parent_result_loc->value.type->id == ZigTypeIdUnreachable) | 16422 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| 16424 | { | 16423 | { |
| 16425 | return parent_result_loc; | 16424 | return parent_result_loc; |
| 16426 | } | 16425 | } |
| 16427 | ZigType *parent_ptr_type = parent_result_loc->value.type; | 16426 | ZigType *parent_ptr_type = parent_result_loc->value->type; |
| 16428 | assert(parent_ptr_type->id == ZigTypeIdPointer); | 16427 | assert(parent_ptr_type->id == ZigTypeIdPointer); |
| 16429 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 16428 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 16430 | ResolveStatusAlignmentKnown))) | 16429 | ResolveStatusAlignmentKnown))) |
| ... | @@ -16454,24 +16453,24 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -16454,24 +16453,24 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 16454 | { | 16453 | { |
| 16455 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && | 16454 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && |
| 16456 | instr_is_comptime(result_loc_pass1->source_instruction) && | 16455 | instr_is_comptime(result_loc_pass1->source_instruction) && |
| 16457 | result_loc_pass1->source_instruction->value.type->id == ZigTypeIdPointer && | 16456 | result_loc_pass1->source_instruction->value->type->id == ZigTypeIdPointer && |
| 16458 | result_loc_pass1->source_instruction->value.data.x_ptr.special == ConstPtrSpecialDiscard) | 16457 | result_loc_pass1->source_instruction->value->data.x_ptr.special == ConstPtrSpecialDiscard) |
| 16459 | { | 16458 | { |
| 16460 | result_loc_pass1 = no_result_loc(); | 16459 | result_loc_pass1 = no_result_loc(); |
| 16461 | } | 16460 | } |
| 16462 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | 16461 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 16463 | value, force_runtime, non_null_comptime); | 16462 | value, force_runtime, non_null_comptime); |
| 16464 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value.type))) | 16463 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) |
| 16465 | return result_loc; | 16464 | return result_loc; |
| 16466 | | 16465 | |
| 16467 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && | 16466 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && |
| 16468 | result_loc_pass1->written && result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) | 16467 | result_loc_pass1->written && result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) |
| 16469 | { | 16468 | { |
| 16470 | result_loc->value.special = ConstValSpecialRuntime; | 16469 | result_loc->value->special = ConstValSpecialRuntime; |
| 16471 | } | 16470 | } |
| 16472 | | 16471 | |
| 16473 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, suspend_source_instr); | 16472 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, suspend_source_instr); |
| 16474 | ZigType *actual_elem_type = result_loc->value.type->data.pointer.child_type; | 16473 | ZigType *actual_elem_type = result_loc->value->type->data.pointer.child_type; |
| 16475 | if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && | 16474 | if (actual_elem_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| 16476 | value_type->id != ZigTypeIdNull) | 16475 | value_type->id != ZigTypeIdNull) |
| 16477 | { | 16476 | { |
| ... | @@ -16544,18 +16543,18 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -16544,18 +16543,18 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 16544 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), | 16543 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), |
| 16545 | implicit_elem_type, nullptr, false, true, true); | 16544 | implicit_elem_type, nullptr, false, true, true); |
| 16546 | if (result_loc != nullptr && | 16545 | if (result_loc != nullptr && |
| 16547 | (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 16546 | (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 16548 | { | 16547 | { |
| 16549 | return result_loc; | 16548 | return result_loc; |
| 16550 | } | 16549 | } |
| 16551 | result_loc->value.special = ConstValSpecialRuntime; | 16550 | result_loc->value->special = ConstValSpecialRuntime; |
| 16552 | return result_loc; | 16551 | return result_loc; |
| 16553 | } | 16552 | } |
| 16554 | | 16553 | |
| 16555 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); | 16554 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); |
| 16556 | result->value.special = ConstValSpecialUndef; | 16555 | result->value->special = ConstValSpecialUndef; |
| 16557 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); | 16556 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); |
| 16558 | ptr->value.data.x_ptr.mut = ConstPtrMutComptimeVar; | 16557 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16559 | return ptr; | 16558 | return ptr; |
| 16560 | } | 16559 | } |
| 16561 | | 16560 | |
| ... | @@ -16605,9 +16604,9 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal | ... | @@ -16605,9 +16604,9 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal |
| 16605 | { | 16604 | { |
| 16606 | ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base); | 16605 | ir_assert(call_instruction->is_async_call_builtin, &call_instruction->base); |
| 16607 | IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child; | 16606 | IrInstruction *ret_ptr_uncasted = call_instruction->args[call_instruction->arg_count]->child; |
| 16608 | if (type_is_invalid(ret_ptr_uncasted->value.type)) | 16607 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| 16609 | return ira->codegen->invalid_instruction; | 16608 | return ira->codegen->invalid_instruction; |
| 16610 | if (ret_ptr_uncasted->value.type->id == ZigTypeIdVoid) { | 16609 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { |
| 16611 | // Result location will be inside the async frame. | 16610 | // Result location will be inside the async frame. |
| 16612 | return nullptr; | 16611 | return nullptr; |
| 16613 | } | 16612 | } |
| ... | @@ -16632,7 +16631,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc | ... | @@ -16632,7 +16631,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc |
| 16632 | if (casted_new_stack != nullptr) { | 16631 | if (casted_new_stack != nullptr) { |
| 16633 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; | 16632 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 16634 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, call_instruction, fn_ret_type); | 16633 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, call_instruction, fn_ret_type); |
| 16635 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value.type)) | 16634 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) |
| 16636 | return ira->codegen->invalid_instruction; | 16635 | return ira->codegen->invalid_instruction; |
| 16637 | | 16636 | |
| 16638 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); | 16637 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| ... | @@ -16645,11 +16644,11 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc | ... | @@ -16645,11 +16644,11 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc |
| 16645 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); | 16644 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 16646 | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 16645 | IrInstruction *result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 16647 | frame_type, nullptr, true, true, false); | 16646 | frame_type, nullptr, true, true, false); |
| 16648 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 16647 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 16649 | return result_loc; | 16648 | return result_loc; |
| 16650 | } | 16649 | } |
| 16651 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); | 16650 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 16652 | if (type_is_invalid(result_loc->value.type)) | 16651 | if (type_is_invalid(result_loc->value->type)) |
| 16653 | return ira->codegen->invalid_instruction; | 16652 | return ira->codegen->invalid_instruction; |
| 16654 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, | 16653 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, |
| 16655 | casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack, | 16654 | casted_args, FnInlineAuto, CallModifierAsync, casted_new_stack, |
| ... | @@ -16670,7 +16669,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -16670,7 +16669,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 16670 | return false; | 16669 | return false; |
| 16671 | | 16670 | |
| 16672 | casted_arg = ir_implicit_cast(ira, arg, param_type); | 16671 | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16673 | if (type_is_invalid(casted_arg->value.type)) | 16672 | if (type_is_invalid(casted_arg->value->type)) |
| 16674 | return false; | 16673 | return false; |
| 16675 | } else { | 16674 | } else { |
| 16676 | casted_arg = arg; | 16675 | casted_arg = arg; |
| ... | @@ -16710,7 +16709,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16710,7 +16709,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16710 | return false; | 16709 | return false; |
| 16711 | | 16710 | |
| 16712 | casted_arg = ir_implicit_cast(ira, arg, param_type); | 16711 | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16713 | if (type_is_invalid(casted_arg->value.type)) | 16712 | if (type_is_invalid(casted_arg->value->type)) |
| 16714 | return false; | 16713 | return false; |
| 16715 | } else { | 16714 | } else { |
| 16716 | arg_part_of_generic_id = true; | 16715 | arg_part_of_generic_id = true; |
| ... | @@ -16719,7 +16718,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16719,7 +16718,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16719 | } | 16718 | } |
| 16720 | | 16719 | |
| 16721 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || | 16720 | bool comptime_arg = param_decl_node->data.param_decl.is_comptime || |
| 16722 | casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat; | 16721 | casted_arg->value->type->id == ZigTypeIdComptimeInt || casted_arg->value->type->id == ZigTypeIdComptimeFloat; |
| 16723 | | 16722 | |
| 16724 | ZigValue *arg_val; | 16723 | ZigValue *arg_val; |
| 16725 | | 16724 | |
| ... | @@ -16729,7 +16728,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16729,7 +16728,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16729 | if (!arg_val) | 16728 | if (!arg_val) |
| 16730 | return false; | 16729 | return false; |
| 16731 | } else { | 16730 | } else { |
| 16732 | arg_val = create_const_runtime(casted_arg->value.type); | 16731 | arg_val = create_const_runtime(casted_arg->value->type); |
| 16733 | } | 16732 | } |
| 16734 | if (arg_part_of_generic_id) { | 16733 | if (arg_part_of_generic_id) { |
| 16735 | copy_const_val(&generic_id->params[generic_id->param_count], arg_val, true); | 16734 | copy_const_val(&generic_id->params[generic_id->param_count], arg_val, true); |
| ... | @@ -16745,8 +16744,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16745,8 +16744,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16745 | var->shadowable = !comptime_arg; | 16744 | var->shadowable = !comptime_arg; |
| 16746 | | 16745 | |
| 16747 | *next_proto_i += 1; | 16746 | *next_proto_i += 1; |
| 16748 | } else if (casted_arg->value.type->id == ZigTypeIdComptimeInt || | 16747 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || |
| 16749 | casted_arg->value.type->id == ZigTypeIdComptimeFloat) | 16748 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) |
| 16750 | { | 16749 | { |
| 16751 | ir_add_error(ira, casted_arg, | 16750 | ir_add_error(ira, casted_arg, |
| 16752 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); | 16751 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| ... | @@ -16754,10 +16753,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16754,10 +16753,10 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16754 | } | 16753 | } |
| 16755 | | 16754 | |
| 16756 | if (!comptime_arg) { | 16755 | if (!comptime_arg) { |
| 16757 | switch (type_requires_comptime(ira->codegen, casted_arg->value.type)) { | 16756 | switch (type_requires_comptime(ira->codegen, casted_arg->value->type)) { |
| 16758 | case ReqCompTimeYes: | 16757 | case ReqCompTimeYes: |
| 16759 | ir_add_error(ira, casted_arg, | 16758 | ir_add_error(ira, casted_arg, |
| 16760 | buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value.type->name))); | 16759 | buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value->type->name))); |
| 16761 | return false; | 16760 | return false; |
| 16762 | case ReqCompTimeInvalid: | 16761 | case ReqCompTimeInvalid: |
| 16763 | return false; | 16762 | return false; |
| ... | @@ -16767,7 +16766,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -16767,7 +16766,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16767 | | 16766 | |
| 16768 | casted_args[fn_type_id->param_count] = casted_arg; | 16767 | casted_args[fn_type_id->param_count] = casted_arg; |
| 16769 | FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count]; | 16768 | FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count]; |
| 16770 | param_info->type = casted_arg->value.type; | 16769 | param_info->type = casted_arg->value->type; |
| 16771 | param_info->is_noalias = param_decl_node->data.param_decl.is_noalias; | 16770 | param_info->is_noalias = param_decl_node->data.param_decl.is_noalias; |
| 16772 | impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node; | 16771 | impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node; |
| 16773 | fn_type_id->param_count += 1; | 16772 | fn_type_id->param_count += 1; |
| ... | @@ -16813,7 +16812,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16813,7 +16812,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16813 | | 16812 | |
| 16814 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, | 16813 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, |
| 16815 | instruction->scope, instruction->source_node, var); | 16814 | instruction->scope, instruction->source_node, var); |
| 16816 | result->value.type = get_pointer_to_type_extra(ira->codegen, var->var_type, | 16815 | result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type, |
| 16817 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); | 16816 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); |
| 16818 | | 16817 | |
| 16819 | if (linkage_makes_it_runtime) | 16818 | if (linkage_makes_it_runtime) |
| ... | @@ -16846,10 +16845,10 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16846,10 +16845,10 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16846 | assert(!comptime_var_mem); | 16845 | assert(!comptime_var_mem); |
| 16847 | ptr_mut = ConstPtrMutRuntimeVar; | 16846 | ptr_mut = ConstPtrMutRuntimeVar; |
| 16848 | } | 16847 | } |
| 16849 | result->value.special = ConstValSpecialStatic; | 16848 | result->value->special = ConstValSpecialStatic; |
| 16850 | result->value.data.x_ptr.mut = ptr_mut; | 16849 | result->value->data.x_ptr.mut = ptr_mut; |
| 16851 | result->value.data.x_ptr.special = ConstPtrSpecialRef; | 16850 | result->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16852 | result->value.data.x_ptr.data.ref.pointee = mem_slot; | 16851 | result->value->data.x_ptr.data.ref.pointee = mem_slot; |
| 16853 | return result; | 16852 | return result; |
| 16854 | } | 16853 | } |
| 16855 | } | 16854 | } |
| ... | @@ -16859,7 +16858,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -16859,7 +16858,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 16859 | no_mem_slot: | 16858 | no_mem_slot: |
| 16860 | | 16859 | |
| 16861 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); | 16860 | bool in_fn_scope = (scope_fn_entry(var->parent_scope) != nullptr); |
| 16862 | result->value.data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; | 16861 | result->value->data.rh_ptr = in_fn_scope ? RuntimeHintPtrStack : RuntimeHintPtrNonStack; |
| 16863 | | 16862 | |
| 16864 | return result; | 16863 | return result; |
| 16865 | } | 16864 | } |
| ... | @@ -16881,11 +16880,11 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -16881,11 +16880,11 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins |
| 16881 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 16880 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, |
| 16882 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) | 16881 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) |
| 16883 | { | 16882 | { |
| 16884 | assert(ptr->value.type->id == ZigTypeIdPointer); | 16883 | assert(ptr->value->type->id == ZigTypeIdPointer); |
| 16885 | | 16884 | |
| 16886 | if (ptr->value.data.x_ptr.special == ConstPtrSpecialDiscard) { | 16885 | if (ptr->value->data.x_ptr.special == ConstPtrSpecialDiscard) { |
| 16887 | if (uncasted_value->value.type->id == ZigTypeIdErrorUnion || | 16886 | if (uncasted_value->value->type->id == ZigTypeIdErrorUnion || |
| 16888 | uncasted_value->value.type->id == ZigTypeIdErrorSet) | 16887 | uncasted_value->value->type->id == ZigTypeIdErrorSet) |
| 16889 | { | 16888 | { |
| 16890 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); | 16889 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); |
| 16891 | return ira->codegen->invalid_instruction; | 16890 | return ira->codegen->invalid_instruction; |
| ... | @@ -16893,7 +16892,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16893,7 +16892,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16893 | return ir_const_void(ira, source_instr); | 16892 | return ir_const_void(ira, source_instr); |
| 16894 | } | 16893 | } |
| 16895 | | 16894 | |
| 16896 | InferredStructField *isf = ptr->value.type->data.pointer.inferred_struct_field; | 16895 | InferredStructField *isf = ptr->value->type->data.pointer.inferred_struct_field; |
| 16897 | if (allow_write_through_const && isf != nullptr) { | 16896 | if (allow_write_through_const && isf != nullptr) { |
| 16898 | // Now it's time to add the field to the struct type. | 16897 | // Now it's time to add the field to the struct type. |
| 16899 | uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count; | 16898 | uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count; |
| ... | @@ -16904,7 +16903,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16904,7 +16903,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16904 | | 16903 | |
| 16905 | TypeStructField *field = isf->inferred_struct_type->data.structure.fields[old_field_count]; | 16904 | TypeStructField *field = isf->inferred_struct_type->data.structure.fields[old_field_count]; |
| 16906 | field->name = isf->field_name; | 16905 | field->name = isf->field_name; |
| 16907 | field->type_entry = uncasted_value->value.type; | 16906 | field->type_entry = uncasted_value->value->type; |
| 16908 | field->type_val = create_const_type(ira->codegen, field->type_entry); | 16907 | field->type_val = create_const_type(ira->codegen, field->type_entry); |
| 16909 | field->src_index = old_field_count; | 16908 | field->src_index = old_field_count; |
| 16910 | field->decl_node = uncasted_value->source_node; | 16909 | field->decl_node = uncasted_value->source_node; |
| ... | @@ -16913,12 +16912,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16913,12 +16912,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16913 | IrInstruction *casted_ptr; | 16912 | IrInstruction *casted_ptr; |
| 16914 | if (instr_is_comptime(ptr)) { | 16913 | if (instr_is_comptime(ptr)) { |
| 16915 | casted_ptr = ir_const(ira, source_instr, struct_ptr_type); | 16914 | casted_ptr = ir_const(ira, source_instr, struct_ptr_type); |
| 16916 | copy_const_val(&casted_ptr->value, &ptr->value, false); | 16915 | copy_const_val(casted_ptr->value, ptr->value, false); |
| 16917 | casted_ptr->value.type = struct_ptr_type; | 16916 | casted_ptr->value->type = struct_ptr_type; |
| 16918 | } else { | 16917 | } else { |
| 16919 | casted_ptr = ir_build_cast(&ira->new_irb, source_instr->scope, | 16918 | casted_ptr = ir_build_cast(&ira->new_irb, source_instr->scope, |
| 16920 | source_instr->source_node, struct_ptr_type, ptr, CastOpNoop); | 16919 | source_instr->source_node, struct_ptr_type, ptr, CastOpNoop); |
| 16921 | casted_ptr->value.type = struct_ptr_type; | 16920 | casted_ptr->value->type = struct_ptr_type; |
| 16922 | } | 16921 | } |
| 16923 | if (instr_is_comptime(casted_ptr)) { | 16922 | if (instr_is_comptime(casted_ptr)) { |
| 16924 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); | 16923 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); |
| ... | @@ -16944,12 +16943,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16944,12 +16943,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16944 | isf->inferred_struct_type, true); | 16943 | isf->inferred_struct_type, true); |
| 16945 | } | 16944 | } |
| 16946 | | 16945 | |
| 16947 | if (ptr->value.type->data.pointer.is_const && !allow_write_through_const) { | 16946 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { |
| 16948 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 16947 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 16949 | return ira->codegen->invalid_instruction; | 16948 | return ira->codegen->invalid_instruction; |
| 16950 | } | 16949 | } |
| 16951 | | 16950 | |
| 16952 | ZigType *child_type = ptr->value.type->data.pointer.child_type; | 16951 | ZigType *child_type = ptr->value->type->data.pointer.child_type; |
| 16953 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); | 16952 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); |
| 16954 | if (value == ira->codegen->invalid_instruction) | 16953 | if (value == ira->codegen->invalid_instruction) |
| 16955 | return ira->codegen->invalid_instruction; | 16954 | return ira->codegen->invalid_instruction; |
| ... | @@ -16963,16 +16962,16 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16963,16 +16962,16 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16963 | break; | 16962 | break; |
| 16964 | } | 16963 | } |
| 16965 | | 16964 | |
| 16966 | if (instr_is_comptime(ptr) && ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 16965 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 16967 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst) { | 16966 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { |
| 16968 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 16967 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 16969 | return ira->codegen->invalid_instruction; | 16968 | return ira->codegen->invalid_instruction; |
| 16970 | } | 16969 | } |
| 16971 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar || | 16970 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || |
| 16972 | ptr->value.data.x_ptr.mut == ConstPtrMutInfer) | 16971 | ptr->value->data.x_ptr.mut == ConstPtrMutInfer) |
| 16973 | { | 16972 | { |
| 16974 | if (instr_is_comptime(value)) { | 16973 | if (instr_is_comptime(value)) { |
| 16975 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, &ptr->value, source_instr->source_node); | 16974 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); |
| 16976 | if (dest_val == nullptr) | 16975 | if (dest_val == nullptr) |
| 16977 | return ira->codegen->invalid_instruction; | 16976 | return ira->codegen->invalid_instruction; |
| 16978 | if (dest_val->special != ConstValSpecialRuntime) { | 16977 | if (dest_val->special != ConstValSpecialRuntime) { |
| ... | @@ -16982,9 +16981,9 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16982,9 +16981,9 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16982 | // * "string literal used as comptime slice is memoized" | 16981 | // * "string literal used as comptime slice is memoized" |
| 16983 | // * "comptime modification of const struct field" - except modified to avoid | 16982 | // * "comptime modification of const struct field" - except modified to avoid |
| 16984 | // ConstPtrMutComptimeVar, thus defeating the logic below. | 16983 | // ConstPtrMutComptimeVar, thus defeating the logic below. |
| 16985 | bool same_global_refs = ptr->value.data.x_ptr.mut != ConstPtrMutComptimeVar; | 16984 | bool same_global_refs = ptr->value->data.x_ptr.mut != ConstPtrMutComptimeVar; |
| 16986 | copy_const_val(dest_val, &value->value, same_global_refs); | 16985 | copy_const_val(dest_val, value->value, same_global_refs); |
| 16987 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar && | 16986 | if (ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar && |
| 16988 | !ira->new_irb.current_basic_block->must_be_comptime_source_instr) | 16987 | !ira->new_irb.current_basic_block->must_be_comptime_source_instr) |
| 16989 | { | 16988 | { |
| 16990 | ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr; | 16989 | ira->new_irb.current_basic_block->must_be_comptime_source_instr = source_instr; |
| ... | @@ -16992,12 +16991,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16992,12 +16991,12 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16992 | return ir_const_void(ira, source_instr); | 16991 | return ir_const_void(ira, source_instr); |
| 16993 | } | 16992 | } |
| 16994 | } | 16993 | } |
| 16995 | if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) { | 16994 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 16996 | ptr->value.special = ConstValSpecialRuntime; | 16995 | ptr->value->special = ConstValSpecialRuntime; |
| 16997 | } else { | 16996 | } else { |
| 16998 | ir_add_error(ira, source_instr, | 16997 | ir_add_error(ira, source_instr, |
| 16999 | buf_sprintf("cannot store runtime value in compile time variable")); | 16998 | buf_sprintf("cannot store runtime value in compile time variable")); |
| 17000 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, &ptr->value); | 16999 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 17001 | dest_val->type = ira->codegen->builtin_types.entry_invalid; | 17000 | dest_val->type = ira->codegen->builtin_types.entry_invalid; |
| 17002 | | 17001 | |
| 17003 | return ira->codegen->invalid_instruction; | 17002 | return ira->codegen->invalid_instruction; |
| ... | @@ -17009,7 +17008,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17009,7 +17008,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17009 | case ReqCompTimeInvalid: | 17008 | case ReqCompTimeInvalid: |
| 17010 | return ira->codegen->invalid_instruction; | 17009 | return ira->codegen->invalid_instruction; |
| 17011 | case ReqCompTimeYes: | 17010 | case ReqCompTimeYes: |
| 17012 | switch (type_has_one_possible_value(ira->codegen, ptr->value.type)) { | 17011 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { |
| 17013 | case OnePossibleValueInvalid: | 17012 | case OnePossibleValueInvalid: |
| 17014 | return ira->codegen->invalid_instruction; | 17013 | return ira->codegen->invalid_instruction; |
| 17015 | case OnePossibleValueNo: | 17014 | case OnePossibleValueNo: |
| ... | @@ -17025,7 +17024,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17025,7 +17024,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17025 | } | 17024 | } |
| 17026 | | 17025 | |
| 17027 | if (instr_is_comptime(value)) { | 17026 | if (instr_is_comptime(value)) { |
| 17028 | mark_comptime_value_escape(ira, source_instr, &value->value); | 17027 | mark_comptime_value_escape(ira, source_instr, value->value); |
| 17029 | } | 17028 | } |
| 17030 | | 17029 | |
| 17031 | // If this is a store to a pointer with a runtime-known vector index, | 17030 | // If this is a store to a pointer with a runtime-known vector index, |
| ... | @@ -17034,7 +17033,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17034,7 +17033,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17034 | // explaining why it is impossible for this store to work. Which is that | 17033 | // explaining why it is impossible for this store to work. Which is that |
| 17035 | // the pointer address is of the vector; without the element index being known | 17034 | // the pointer address is of the vector; without the element index being known |
| 17036 | // we cannot properly perform the insertion. | 17035 | // we cannot properly perform the insertion. |
| 17037 | if (ptr->value.type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 17036 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 17038 | if (ptr->id == IrInstructionIdElemPtr) { | 17037 | if (ptr->id == IrInstructionIdElemPtr) { |
| 17039 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 17038 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; |
| 17040 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, | 17039 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, |
| ... | @@ -17042,7 +17041,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -17042,7 +17041,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 17042 | } | 17041 | } |
| 17043 | ir_add_error(ira, ptr, | 17042 | ir_add_error(ira, ptr, |
| 17044 | buf_sprintf("unable to determine vector element index of type '%s'", | 17043 | buf_sprintf("unable to determine vector element index of type '%s'", |
| 17045 | buf_ptr(&ptr->value.type->name))); | 17044 | buf_ptr(&ptr->value->type->name))); |
| 17046 | return ira->codegen->invalid_instruction; | 17045 | return ira->codegen->invalid_instruction; |
| 17047 | } | 17046 | } |
| 17048 | | 17047 | |
| ... | @@ -17058,12 +17057,12 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall | ... | @@ -17058,12 +17057,12 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall |
| 17058 | return nullptr; | 17057 | return nullptr; |
| 17059 | | 17058 | |
| 17060 | IrInstruction *new_stack = call_instruction->new_stack->child; | 17059 | IrInstruction *new_stack = call_instruction->new_stack->child; |
| 17061 | if (type_is_invalid(new_stack->value.type)) | 17060 | if (type_is_invalid(new_stack->value->type)) |
| 17062 | return ira->codegen->invalid_instruction; | 17061 | return ira->codegen->invalid_instruction; |
| 17063 | | 17062 | |
| 17064 | if (call_instruction->is_async_call_builtin && | 17063 | if (call_instruction->is_async_call_builtin && |
| 17065 | fn_entry != nullptr && new_stack->value.type->id == ZigTypeIdPointer && | 17064 | fn_entry != nullptr && new_stack->value->type->id == ZigTypeIdPointer && |
| 17066 | new_stack->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 17065 | new_stack->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 17067 | { | 17066 | { |
| 17068 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, | 17067 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, |
| 17069 | get_fn_frame_type(ira->codegen, fn_entry), false); | 17068 | get_fn_frame_type(ira->codegen, fn_entry), false); |
| ... | @@ -17097,7 +17096,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17097,7 +17096,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17097 | | 17096 | |
| 17098 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; | 17097 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; |
| 17099 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { | 17098 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 17100 | ZigValue *arg_tuple_value = &call_instruction->args[i]->child->value; | 17099 | ZigValue *arg_tuple_value = call_instruction->args[i]->child->value; |
| 17101 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { | 17100 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { |
| 17102 | call_param_count -= 1; | 17101 | call_param_count -= 1; |
| 17103 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - | 17102 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - |
| ... | @@ -17152,7 +17151,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17152,7 +17151,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17152 | | 17151 | |
| 17153 | size_t next_proto_i = 0; | 17152 | size_t next_proto_i = 0; |
| 17154 | if (first_arg_ptr) { | 17153 | if (first_arg_ptr) { |
| 17155 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17154 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17156 | | 17155 | |
| 17157 | bool first_arg_known_bare = false; | 17156 | bool first_arg_known_bare = false; |
| 17158 | if (fn_type_id->next_param_index >= 1) { | 17157 | if (fn_type_id->next_param_index >= 1) { |
| ... | @@ -17163,11 +17162,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17163,11 +17162,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17163 | } | 17162 | } |
| 17164 | | 17163 | |
| 17165 | IrInstruction *first_arg; | 17164 | IrInstruction *first_arg; |
| 17166 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) { | 17165 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 17167 | first_arg = first_arg_ptr; | 17166 | first_arg = first_arg_ptr; |
| 17168 | } else { | 17167 | } else { |
| 17169 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17168 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17170 | if (type_is_invalid(first_arg->value.type)) | 17169 | if (type_is_invalid(first_arg->value->type)) |
| 17171 | return ira->codegen->invalid_instruction; | 17170 | return ira->codegen->invalid_instruction; |
| 17172 | } | 17171 | } |
| 17173 | | 17172 | |
| ... | @@ -17184,7 +17183,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17184,7 +17183,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17184 | | 17183 | |
| 17185 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17184 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17186 | IrInstruction *old_arg = call_instruction->args[call_i]->child; | 17185 | IrInstruction *old_arg = call_instruction->args[call_i]->child; |
| 17187 | if (type_is_invalid(old_arg->value.type)) | 17186 | if (type_is_invalid(old_arg->value->type)) |
| 17188 | return ira->codegen->invalid_instruction; | 17187 | return ira->codegen->invalid_instruction; |
| 17189 | | 17188 | |
| 17190 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) | 17189 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| ... | @@ -17250,8 +17249,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17250,8 +17249,8 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17250 | } | 17249 | } |
| 17251 | | 17250 | |
| 17252 | IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type); | 17251 | IrInstruction *new_instruction = ir_const(ira, &call_instruction->base, result->type); |
| 17253 | copy_const_val(&new_instruction->value, result, true); | 17252 | copy_const_val(new_instruction->value, result, true); |
| 17254 | new_instruction->value.type = return_type; | 17253 | new_instruction->value->type = return_type; |
| 17255 | return ir_finish_anal(ira, new_instruction); | 17254 | return ir_finish_anal(ira, new_instruction); |
| 17256 | } | 17255 | } |
| 17257 | | 17256 | |
| ... | @@ -17266,11 +17265,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17266,11 +17265,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17266 | size_t new_fn_arg_count = first_arg_1_or_0; | 17265 | size_t new_fn_arg_count = first_arg_1_or_0; |
| 17267 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17266 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17268 | IrInstruction *arg = call_instruction->args[call_i]->child; | 17267 | IrInstruction *arg = call_instruction->args[call_i]->child; |
| 17269 | if (type_is_invalid(arg->value.type)) | 17268 | if (type_is_invalid(arg->value->type)) |
| 17270 | return ira->codegen->invalid_instruction; | 17269 | return ira->codegen->invalid_instruction; |
| 17271 | | 17270 | |
| 17272 | if (arg->value.type->id == ZigTypeIdArgTuple) { | 17271 | if (arg->value->type->id == ZigTypeIdArgTuple) { |
| 17273 | new_fn_arg_count += arg->value.data.x_arg_tuple.end_index - arg->value.data.x_arg_tuple.start_index; | 17272 | new_fn_arg_count += arg->value->data.x_arg_tuple.end_index - arg->value->data.x_arg_tuple.start_index; |
| 17274 | } else { | 17273 | } else { |
| 17275 | new_fn_arg_count += 1; | 17274 | new_fn_arg_count += 1; |
| 17276 | } | 17275 | } |
| ... | @@ -17299,7 +17298,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17299,7 +17298,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17299 | size_t next_proto_i = 0; | 17298 | size_t next_proto_i = 0; |
| 17300 | | 17299 | |
| 17301 | if (first_arg_ptr) { | 17300 | if (first_arg_ptr) { |
| 17302 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17301 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17303 | | 17302 | |
| 17304 | bool first_arg_known_bare = false; | 17303 | bool first_arg_known_bare = false; |
| 17305 | if (fn_type_id->next_param_index >= 1) { | 17304 | if (fn_type_id->next_param_index >= 1) { |
| ... | @@ -17310,11 +17309,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17310,11 +17309,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17310 | } | 17309 | } |
| 17311 | | 17310 | |
| 17312 | IrInstruction *first_arg; | 17311 | IrInstruction *first_arg; |
| 17313 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) { | 17312 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 17314 | first_arg = first_arg_ptr; | 17313 | first_arg = first_arg_ptr; |
| 17315 | } else { | 17314 | } else { |
| 17316 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17315 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17317 | if (type_is_invalid(first_arg->value.type)) | 17316 | if (type_is_invalid(first_arg->value->type)) |
| 17318 | return ira->codegen->invalid_instruction; | 17317 | return ira->codegen->invalid_instruction; |
| 17319 | } | 17318 | } |
| 17320 | | 17319 | |
| ... | @@ -17332,12 +17331,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17332,12 +17331,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17332 | assert(parent_fn_entry); | 17331 | assert(parent_fn_entry); |
| 17333 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17332 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17334 | IrInstruction *arg = call_instruction->args[call_i]->child; | 17333 | IrInstruction *arg = call_instruction->args[call_i]->child; |
| 17335 | if (type_is_invalid(arg->value.type)) | 17334 | if (type_is_invalid(arg->value->type)) |
| 17336 | return ira->codegen->invalid_instruction; | 17335 | return ira->codegen->invalid_instruction; |
| 17337 | | 17336 | |
| 17338 | if (arg->value.type->id == ZigTypeIdArgTuple) { | 17337 | if (arg->value->type->id == ZigTypeIdArgTuple) { |
| 17339 | for (size_t arg_tuple_i = arg->value.data.x_arg_tuple.start_index; | 17338 | for (size_t arg_tuple_i = arg->value->data.x_arg_tuple.start_index; |
| 17340 | arg_tuple_i < arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1) | 17339 | arg_tuple_i < arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1) |
| 17341 | { | 17340 | { |
| 17342 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); | 17341 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 17343 | assert(param_decl_node->type == NodeTypeParamDecl); | 17342 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | @@ -17354,11 +17353,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17354,11 +17353,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17354 | return ira->codegen->invalid_instruction; | 17353 | return ira->codegen->invalid_instruction; |
| 17355 | } | 17354 | } |
| 17356 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var); | 17355 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var); |
| 17357 | if (type_is_invalid(arg_var_ptr_inst->value.type)) | 17356 | if (type_is_invalid(arg_var_ptr_inst->value->type)) |
| 17358 | return ira->codegen->invalid_instruction; | 17357 | return ira->codegen->invalid_instruction; |
| 17359 | | 17358 | |
| 17360 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, arg, arg_var_ptr_inst, nullptr); | 17359 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, arg, arg_var_ptr_inst, nullptr); |
| 17361 | if (type_is_invalid(arg_tuple_arg->value.type)) | 17360 | if (type_is_invalid(arg_tuple_arg->value->type)) |
| 17362 | return ira->codegen->invalid_instruction; | 17361 | return ira->codegen->invalid_instruction; |
| 17363 | | 17362 | |
| 17364 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg_tuple_arg, &impl_fn->child_scope, | 17363 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg_tuple_arg, &impl_fn->child_scope, |
| ... | @@ -17407,7 +17406,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17407,7 +17406,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17407 | nullptr, UndefBad); | 17406 | nullptr, UndefBad); |
| 17408 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 17407 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 17409 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); | 17408 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 17410 | copy_const_val(&const_instruction->base.value, align_result, true); | 17409 | copy_const_val(const_instruction->base.value, align_result, true); |
| 17411 | | 17410 | |
| 17412 | uint32_t align_bytes = 0; | 17411 | uint32_t align_bytes = 0; |
| 17413 | ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes); | 17412 | ir_resolve_align(ira, &const_instruction->base, nullptr, &align_bytes); |
| ... | @@ -17468,7 +17467,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17468,7 +17467,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17468 | } | 17467 | } |
| 17469 | | 17468 | |
| 17470 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, impl_fn); | 17469 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, impl_fn); |
| 17471 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type)) | 17470 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 17472 | return ira->codegen->invalid_instruction; | 17471 | return ira->codegen->invalid_instruction; |
| 17473 | | 17472 | |
| 17474 | size_t impl_param_count = impl_fn_type_id->param_count; | 17473 | size_t impl_param_count = impl_fn_type_id->param_count; |
| ... | @@ -17483,17 +17482,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17483,17 +17482,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17483 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 17482 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 17484 | impl_fn_type_id->return_type, nullptr, true, true, false); | 17483 | impl_fn_type_id->return_type, nullptr, true, true, false); |
| 17485 | if (result_loc != nullptr) { | 17484 | if (result_loc != nullptr) { |
| 17486 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 17485 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 17487 | return result_loc; | 17486 | return result_loc; |
| 17488 | } | 17487 | } |
| 17489 | if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) { | 17488 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17490 | ir_reset_result(call_instruction->result_loc); | 17489 | ir_reset_result(call_instruction->result_loc); |
| 17491 | result_loc = nullptr; | 17490 | result_loc = nullptr; |
| 17492 | } | 17491 | } |
| 17493 | } | 17492 | } |
| 17494 | } else if (call_instruction->is_async_call_builtin) { | 17493 | } else if (call_instruction->is_async_call_builtin) { |
| 17495 | result_loc = get_async_call_result_loc(ira, call_instruction, impl_fn_type_id->return_type); | 17494 | result_loc = get_async_call_result_loc(ira, call_instruction, impl_fn_type_id->return_type); |
| 17496 | if (result_loc != nullptr && type_is_invalid(result_loc->value.type)) | 17495 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 17497 | return ira->codegen->invalid_instruction; | 17496 | return ira->codegen->invalid_instruction; |
| 17498 | } else { | 17497 | } else { |
| 17499 | result_loc = nullptr; | 17498 | result_loc = nullptr; |
| ... | @@ -17530,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17530,7 +17529,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17530 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); | 17529 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); |
| 17531 | size_t next_arg_index = 0; | 17530 | size_t next_arg_index = 0; |
| 17532 | if (first_arg_ptr) { | 17531 | if (first_arg_ptr) { |
| 17533 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); | 17532 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 17534 | | 17533 | |
| 17535 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 17534 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 17536 | if (type_is_invalid(param_type)) | 17535 | if (type_is_invalid(param_type)) |
| ... | @@ -17538,17 +17537,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17538,17 +17537,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17538 | | 17537 | |
| 17539 | IrInstruction *first_arg; | 17538 | IrInstruction *first_arg; |
| 17540 | if (param_type->id == ZigTypeIdPointer && | 17539 | if (param_type->id == ZigTypeIdPointer && |
| 17541 | handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) | 17540 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) |
| 17542 | { | 17541 | { |
| 17543 | first_arg = first_arg_ptr; | 17542 | first_arg = first_arg_ptr; |
| 17544 | } else { | 17543 | } else { |
| 17545 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 17544 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); |
| 17546 | if (type_is_invalid(first_arg->value.type)) | 17545 | if (type_is_invalid(first_arg->value->type)) |
| 17547 | return ira->codegen->invalid_instruction; | 17546 | return ira->codegen->invalid_instruction; |
| 17548 | } | 17547 | } |
| 17549 | | 17548 | |
| 17550 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); | 17549 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 17551 | if (type_is_invalid(casted_arg->value.type)) | 17550 | if (type_is_invalid(casted_arg->value->type)) |
| 17552 | return ira->codegen->invalid_instruction; | 17551 | return ira->codegen->invalid_instruction; |
| 17553 | | 17552 | |
| 17554 | casted_args[next_arg_index] = casted_arg; | 17553 | casted_args[next_arg_index] = casted_arg; |
| ... | @@ -17556,12 +17555,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17556,12 +17555,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17556 | } | 17555 | } |
| 17557 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { | 17556 | for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) { |
| 17558 | IrInstruction *old_arg = call_instruction->args[call_i]->child; | 17557 | IrInstruction *old_arg = call_instruction->args[call_i]->child; |
| 17559 | if (type_is_invalid(old_arg->value.type)) | 17558 | if (type_is_invalid(old_arg->value->type)) |
| 17560 | return ira->codegen->invalid_instruction; | 17559 | return ira->codegen->invalid_instruction; |
| 17561 | | 17560 | |
| 17562 | if (old_arg->value.type->id == ZigTypeIdArgTuple) { | 17561 | if (old_arg->value->type->id == ZigTypeIdArgTuple) { |
| 17563 | for (size_t arg_tuple_i = old_arg->value.data.x_arg_tuple.start_index; | 17562 | for (size_t arg_tuple_i = old_arg->value->data.x_arg_tuple.start_index; |
| 17564 | arg_tuple_i < old_arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1) | 17563 | arg_tuple_i < old_arg->value->data.x_arg_tuple.end_index; arg_tuple_i += 1) |
| 17565 | { | 17564 | { |
| 17566 | ZigVar *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i); | 17565 | ZigVar *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i); |
| 17567 | if (arg_var == nullptr) { | 17566 | if (arg_var == nullptr) { |
| ... | @@ -17570,11 +17569,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17570,11 +17569,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17570 | return ira->codegen->invalid_instruction; | 17569 | return ira->codegen->invalid_instruction; |
| 17571 | } | 17570 | } |
| 17572 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, old_arg, arg_var); | 17571 | IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, old_arg, arg_var); |
| 17573 | if (type_is_invalid(arg_var_ptr_inst->value.type)) | 17572 | if (type_is_invalid(arg_var_ptr_inst->value->type)) |
| 17574 | return ira->codegen->invalid_instruction; | 17573 | return ira->codegen->invalid_instruction; |
| 17575 | | 17574 | |
| 17576 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, old_arg, arg_var_ptr_inst, nullptr); | 17575 | IrInstruction *arg_tuple_arg = ir_get_deref(ira, old_arg, arg_var_ptr_inst, nullptr); |
| 17577 | if (type_is_invalid(arg_tuple_arg->value.type)) | 17576 | if (type_is_invalid(arg_tuple_arg->value->type)) |
| 17578 | return ira->codegen->invalid_instruction; | 17577 | return ira->codegen->invalid_instruction; |
| 17579 | | 17578 | |
| 17580 | IrInstruction *casted_arg; | 17579 | IrInstruction *casted_arg; |
| ... | @@ -17583,7 +17582,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17583,7 +17582,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17583 | if (type_is_invalid(param_type)) | 17582 | if (type_is_invalid(param_type)) |
| 17584 | return ira->codegen->invalid_instruction; | 17583 | return ira->codegen->invalid_instruction; |
| 17585 | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type); | 17584 | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type); |
| 17586 | if (type_is_invalid(casted_arg->value.type)) | 17585 | if (type_is_invalid(casted_arg->value->type)) |
| 17587 | return ira->codegen->invalid_instruction; | 17586 | return ira->codegen->invalid_instruction; |
| 17588 | } else { | 17587 | } else { |
| 17589 | casted_arg = arg_tuple_arg; | 17588 | casted_arg = arg_tuple_arg; |
| ... | @@ -17599,7 +17598,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17599,7 +17598,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17599 | if (type_is_invalid(param_type)) | 17598 | if (type_is_invalid(param_type)) |
| 17600 | return ira->codegen->invalid_instruction; | 17599 | return ira->codegen->invalid_instruction; |
| 17601 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); | 17600 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 17602 | if (type_is_invalid(casted_arg->value.type)) | 17601 | if (type_is_invalid(casted_arg->value->type)) |
| 17603 | return ira->codegen->invalid_instruction; | 17602 | return ira->codegen->invalid_instruction; |
| 17604 | } else { | 17603 | } else { |
| 17605 | casted_arg = old_arg; | 17604 | casted_arg = old_arg; |
| ... | @@ -17623,7 +17622,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17623,7 +17622,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17623 | } | 17622 | } |
| 17624 | | 17623 | |
| 17625 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, fn_entry); | 17624 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, call_instruction, fn_entry); |
| 17626 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value.type)) | 17625 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 17627 | return ira->codegen->invalid_instruction; | 17626 | return ira->codegen->invalid_instruction; |
| 17628 | | 17627 | |
| 17629 | if (call_instruction->modifier == CallModifierAsync) { | 17628 | if (call_instruction->modifier == CallModifierAsync) { |
| ... | @@ -17645,17 +17644,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17645,17 +17644,17 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17645 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, | 17644 | result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc, |
| 17646 | return_type, nullptr, true, true, false); | 17645 | return_type, nullptr, true, true, false); |
| 17647 | if (result_loc != nullptr) { | 17646 | if (result_loc != nullptr) { |
| 17648 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 17647 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 17649 | return result_loc; | 17648 | return result_loc; |
| 17650 | } | 17649 | } |
| 17651 | if (!handle_is_ptr(result_loc->value.type->data.pointer.child_type)) { | 17650 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17652 | ir_reset_result(call_instruction->result_loc); | 17651 | ir_reset_result(call_instruction->result_loc); |
| 17653 | result_loc = nullptr; | 17652 | result_loc = nullptr; |
| 17654 | } | 17653 | } |
| 17655 | } | 17654 | } |
| 17656 | } else if (call_instruction->is_async_call_builtin) { | 17655 | } else if (call_instruction->is_async_call_builtin) { |
| 17657 | result_loc = get_async_call_result_loc(ira, call_instruction, return_type); | 17656 | result_loc = get_async_call_result_loc(ira, call_instruction, return_type); |
| 17658 | if (result_loc != nullptr && type_is_invalid(result_loc->value.type)) | 17657 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 17659 | return ira->codegen->invalid_instruction; | 17658 | return ira->codegen->invalid_instruction; |
| 17660 | } else { | 17659 | } else { |
| 17661 | result_loc = nullptr; | 17660 | result_loc = nullptr; |
| ... | @@ -17672,14 +17671,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c | ... | @@ -17672,14 +17671,14 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17672 | | 17671 | |
| 17673 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { | 17672 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { |
| 17674 | IrInstruction *fn_ref = call_instruction->fn_ref->child; | 17673 | IrInstruction *fn_ref = call_instruction->fn_ref->child; |
| 17675 | if (type_is_invalid(fn_ref->value.type)) | 17674 | if (type_is_invalid(fn_ref->value->type)) |
| 17676 | return ira->codegen->invalid_instruction; | 17675 | return ira->codegen->invalid_instruction; |
| 17677 | | 17676 | |
| 17678 | bool is_comptime = call_instruction->is_comptime || | 17677 | bool is_comptime = call_instruction->is_comptime || |
| 17679 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); | 17678 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); |
| 17680 | | 17679 | |
| 17681 | if (is_comptime || instr_is_comptime(fn_ref)) { | 17680 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 17682 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { | 17681 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { |
| 17683 | ZigType *ty = ir_resolve_type(ira, fn_ref); | 17682 | ZigType *ty = ir_resolve_type(ira, fn_ref); |
| 17684 | if (ty == nullptr) | 17683 | if (ty == nullptr) |
| 17685 | return ira->codegen->invalid_instruction; | 17684 | return ira->codegen->invalid_instruction; |
| ... | @@ -17688,30 +17687,30 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -17688,30 +17687,30 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 17688 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, | 17687 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, |
| 17689 | buf_sprintf("use @as builtin for type coercion")); | 17688 | buf_sprintf("use @as builtin for type coercion")); |
| 17690 | return ira->codegen->invalid_instruction; | 17689 | return ira->codegen->invalid_instruction; |
| 17691 | } else if (fn_ref->value.type->id == ZigTypeIdFn) { | 17690 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 17692 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); | 17691 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); |
| 17693 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value.type; | 17692 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; |
| 17694 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type, | 17693 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type, |
| 17695 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); | 17694 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); |
| 17696 | } else if (fn_ref->value.type->id == ZigTypeIdBoundFn) { | 17695 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 17697 | assert(fn_ref->value.special == ConstValSpecialStatic); | 17696 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 17698 | ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; | 17697 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; |
| 17699 | IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; | 17698 | IrInstruction *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 17700 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 17699 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 17701 | fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); | 17700 | fn_ref, first_arg_ptr, is_comptime, call_instruction->fn_inline); |
| 17702 | } else { | 17701 | } else { |
| 17703 | ir_add_error_node(ira, fn_ref->source_node, | 17702 | ir_add_error_node(ira, fn_ref->source_node, |
| 17704 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name))); | 17703 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 17705 | return ira->codegen->invalid_instruction; | 17704 | return ira->codegen->invalid_instruction; |
| 17706 | } | 17705 | } |
| 17707 | } | 17706 | } |
| 17708 | | 17707 | |
| 17709 | if (fn_ref->value.type->id == ZigTypeIdFn) { | 17708 | if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 17710 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type, | 17709 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value->type, |
| 17711 | fn_ref, nullptr, false, call_instruction->fn_inline); | 17710 | fn_ref, nullptr, false, call_instruction->fn_inline); |
| 17712 | } else { | 17711 | } else { |
| 17713 | ir_add_error_node(ira, fn_ref->source_node, | 17712 | ir_add_error_node(ira, fn_ref->source_node, |
| 17714 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name))); | 17713 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 17715 | return ira->codegen->invalid_instruction; | 17714 | return ira->codegen->invalid_instruction; |
| 17716 | } | 17715 | } |
| 17717 | } | 17716 | } |
| ... | @@ -17803,11 +17802,11 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -17803,11 +17802,11 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 17803 | | 17802 | |
| 17804 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17803 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17805 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 17804 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 17806 | result->value.special = ConstValSpecialLazy; | 17805 | result->value->special = ConstValSpecialLazy; |
| 17807 | | 17806 | |
| 17808 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); | 17807 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); |
| 17809 | lazy_opt_type->ira = ira; | 17808 | lazy_opt_type->ira = ira; |
| 17810 | result->value.data.x_lazy = &lazy_opt_type->base; | 17809 | result->value->data.x_lazy = &lazy_opt_type->base; |
| 17811 | lazy_opt_type->base.id = LazyValueIdOptType; | 17810 | lazy_opt_type->base.id = LazyValueIdOptType; |
| 17812 | | 17811 | |
| 17813 | lazy_opt_type->payload_type = instruction->value->child; | 17812 | lazy_opt_type->payload_type = instruction->value->child; |
| ... | @@ -17854,7 +17853,7 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -17854,7 +17853,7 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i |
| 17854 | | 17853 | |
| 17855 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17854 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17856 | IrInstruction *value = instruction->value->child; | 17855 | IrInstruction *value = instruction->value->child; |
| 17857 | ZigType *expr_type = value->value.type; | 17856 | ZigType *expr_type = value->value->type; |
| 17858 | if (type_is_invalid(expr_type)) | 17857 | if (type_is_invalid(expr_type)) |
| 17859 | return ira->codegen->invalid_instruction; | 17858 | return ira->codegen->invalid_instruction; |
| 17860 | | 17859 | |
| ... | @@ -17877,7 +17876,7 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -17877,7 +17876,7 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 17877 | return ira->codegen->invalid_instruction; | 17876 | return ira->codegen->invalid_instruction; |
| 17878 | | 17877 | |
| 17879 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); | 17878 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); |
| 17880 | ZigValue *out_val = &result_instruction->value; | 17879 | ZigValue *out_val = result_instruction->value; |
| 17881 | if (expr_type->id == ZigTypeIdVector) { | 17880 | if (expr_type->id == ZigTypeIdVector) { |
| 17882 | expand_undef_array(ira->codegen, operand_val); | 17881 | expand_undef_array(ira->codegen, operand_val); |
| 17883 | out_val->special = ConstValSpecialUndef; | 17882 | out_val->special = ConstValSpecialUndef; |
| ... | @@ -17911,13 +17910,13 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -17911,13 +17910,13 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 17911 | IrInstruction *result = ir_build_un_op(&ira->new_irb, | 17910 | IrInstruction *result = ir_build_un_op(&ira->new_irb, |
| 17912 | instruction->base.scope, instruction->base.source_node, | 17911 | instruction->base.scope, instruction->base.source_node, |
| 17913 | instruction->op_id, value); | 17912 | instruction->op_id, value); |
| 17914 | result->value.type = expr_type; | 17913 | result->value->type = expr_type; |
| 17915 | return result; | 17914 | return result; |
| 17916 | } | 17915 | } |
| 17917 | | 17916 | |
| 17918 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 17917 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { |
| 17919 | IrInstruction *value = instruction->value->child; | 17918 | IrInstruction *value = instruction->value->child; |
| 17920 | ZigType *expr_type = value->value.type; | 17919 | ZigType *expr_type = value->value->type; |
| 17921 | if (type_is_invalid(expr_type)) | 17920 | if (type_is_invalid(expr_type)) |
| 17922 | return ira->codegen->invalid_instruction; | 17921 | return ira->codegen->invalid_instruction; |
| 17923 | | 17922 | |
| ... | @@ -17928,14 +17927,14 @@ static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *inst | ... | @@ -17928,14 +17927,14 @@ static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *inst |
| 17928 | return ira->codegen->invalid_instruction; | 17927 | return ira->codegen->invalid_instruction; |
| 17929 | | 17928 | |
| 17930 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 17929 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 17931 | bigint_not(&result->value.data.x_bigint, &target_const_val->data.x_bigint, | 17930 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, |
| 17932 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); | 17931 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 17933 | return result; | 17932 | return result; |
| 17934 | } | 17933 | } |
| 17935 | | 17934 | |
| 17936 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, | 17935 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, |
| 17937 | instruction->base.source_node, IrUnOpBinNot, value); | 17936 | instruction->base.source_node, IrUnOpBinNot, value); |
| 17938 | result->value.type = expr_type; | 17937 | result->value->type = expr_type; |
| 17939 | return result; | 17938 | return result; |
| 17940 | } | 17939 | } |
| 17941 | | 17940 | |
| ... | @@ -17956,9 +17955,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -17956,9 +17955,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 17956 | return ir_analyze_negation(ira, instruction); | 17955 | return ir_analyze_negation(ira, instruction); |
| 17957 | case IrUnOpDereference: { | 17956 | case IrUnOpDereference: { |
| 17958 | IrInstruction *ptr = instruction->value->child; | 17957 | IrInstruction *ptr = instruction->value->child; |
| 17959 | if (type_is_invalid(ptr->value.type)) | 17958 | if (type_is_invalid(ptr->value->type)) |
| 17960 | return ira->codegen->invalid_instruction; | 17959 | return ira->codegen->invalid_instruction; |
| 17961 | ZigType *ptr_type = ptr->value.type; | 17960 | ZigType *ptr_type = ptr->value->type; |
| 17962 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { | 17961 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { |
| 17963 | ir_add_error_node(ira, instruction->base.source_node, | 17962 | ir_add_error_node(ira, instruction->base.source_node, |
| 17964 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", | 17963 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", |
| ... | @@ -17971,9 +17970,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -17971,9 +17970,9 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 17971 | return ira->codegen->invalid_instruction; | 17970 | return ira->codegen->invalid_instruction; |
| 17972 | | 17971 | |
| 17973 | // If the result needs to be an lvalue, type check it | 17972 | // If the result needs to be an lvalue, type check it |
| 17974 | if (instruction->lval == LValPtr && result->value.type->id != ZigTypeIdPointer) { | 17973 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { |
| 17975 | ir_add_error(ira, &instruction->base, | 17974 | ir_add_error(ira, &instruction->base, |
| 17976 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value.type->name))); | 17975 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); |
| 17977 | return ira->codegen->invalid_instruction; | 17976 | return ira->codegen->invalid_instruction; |
| 17978 | } | 17977 | } |
| 17979 | | 17978 | |
| ... | @@ -18016,13 +18015,13 @@ static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr | ... | @@ -18016,13 +18015,13 @@ static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr |
| 18016 | | 18015 | |
| 18017 | IrInstruction *result = ir_build_br(&ira->new_irb, | 18016 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 18018 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); | 18017 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); |
| 18019 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18018 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18020 | return ir_finish_anal(ira, result); | 18019 | return ir_finish_anal(ira, result); |
| 18021 | } | 18020 | } |
| 18022 | | 18021 | |
| 18023 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { | 18022 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { |
| 18024 | IrInstruction *condition = cond_br_instruction->condition->child; | 18023 | IrInstruction *condition = cond_br_instruction->condition->child; |
| 18025 | if (type_is_invalid(condition->value.type)) | 18024 | if (type_is_invalid(condition->value->type)) |
| 18026 | return ir_unreach_error(ira); | 18025 | return ir_unreach_error(ira); |
| 18027 | | 18026 | |
| 18028 | bool is_comptime; | 18027 | bool is_comptime; |
| ... | @@ -18031,7 +18030,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18031,7 +18030,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18031 | | 18030 | |
| 18032 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 18031 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 18033 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); | 18032 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); |
| 18034 | if (type_is_invalid(casted_condition->value.type)) | 18033 | if (type_is_invalid(casted_condition->value->type)) |
| 18035 | return ir_unreach_error(ira); | 18034 | return ir_unreach_error(ira); |
| 18036 | | 18035 | |
| 18037 | if (is_comptime || instr_is_comptime(casted_condition)) { | 18036 | if (is_comptime || instr_is_comptime(casted_condition)) { |
| ... | @@ -18053,7 +18052,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18053,7 +18052,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18053 | | 18052 | |
| 18054 | IrInstruction *result = ir_build_br(&ira->new_irb, | 18053 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 18055 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr); | 18054 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr); |
| 18056 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18055 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18057 | return ir_finish_anal(ira, result); | 18056 | return ir_finish_anal(ira, result); |
| 18058 | } | 18057 | } |
| 18059 | | 18058 | |
| ... | @@ -18072,7 +18071,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -18072,7 +18071,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 18072 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, | 18071 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, |
| 18073 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, | 18072 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, |
| 18074 | casted_condition, new_then_block, new_else_block, nullptr); | 18073 | casted_condition, new_then_block, new_else_block, nullptr); |
| 18075 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18074 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18076 | return ir_finish_anal(ira, result); | 18075 | return ir_finish_anal(ira, result); |
| 18077 | } | 18076 | } |
| 18078 | | 18077 | |
| ... | @@ -18081,7 +18080,7 @@ static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, | ... | @@ -18081,7 +18080,7 @@ static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, |
| 18081 | { | 18080 | { |
| 18082 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 18081 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, |
| 18083 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); | 18082 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); |
| 18084 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18083 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18085 | return ir_finish_anal(ira, result); | 18084 | return ir_finish_anal(ira, result); |
| 18086 | } | 18085 | } |
| 18087 | | 18086 | |
| ... | @@ -18094,13 +18093,13 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18094,13 +18093,13 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18094 | if (predecessor != ira->const_predecessor_bb) | 18093 | if (predecessor != ira->const_predecessor_bb) |
| 18095 | continue; | 18094 | continue; |
| 18096 | IrInstruction *value = phi_instruction->incoming_values[i]->child; | 18095 | IrInstruction *value = phi_instruction->incoming_values[i]->child; |
| 18097 | assert(value->value.type); | 18096 | assert(value->value->type); |
| 18098 | if (type_is_invalid(value->value.type)) | 18097 | if (type_is_invalid(value->value->type)) |
| 18099 | return ira->codegen->invalid_instruction; | 18098 | return ira->codegen->invalid_instruction; |
| 18100 | | 18099 | |
| 18101 | if (value->value.special != ConstValSpecialRuntime) { | 18100 | if (value->value->special != ConstValSpecialRuntime) { |
| 18102 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); | 18101 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); |
| 18103 | copy_const_val(&result->value, &value->value, true); | 18102 | copy_const_val(result->value, value->value, true); |
| 18104 | return result; | 18103 | return result; |
| 18105 | } else { | 18104 | } else { |
| 18106 | return value; | 18105 | return value; |
| ... | @@ -18126,7 +18125,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18126,7 +18125,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18126 | } else { | 18125 | } else { |
| 18127 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, | 18126 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, |
| 18128 | this_peer->base.implicit_elem_type); | 18127 | this_peer->base.implicit_elem_type); |
| 18129 | instructions[i]->value.special = ConstValSpecialRuntime; | 18128 | instructions[i]->value->special = ConstValSpecialRuntime; |
| 18130 | } | 18129 | } |
| 18131 | } else { | 18130 | } else { |
| 18132 | instructions[i] = gen_instruction; | 18131 | instructions[i] = gen_instruction; |
| ... | @@ -18147,7 +18146,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18147,7 +18146,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18147 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | 18146 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, |
| 18148 | peer_parent->resolved_type, nullptr, false, false, true); | 18147 | peer_parent->resolved_type, nullptr, false, false, true); |
| 18149 | if (parent_result_loc != nullptr && | 18148 | if (parent_result_loc != nullptr && |
| 18150 | (type_is_invalid(parent_result_loc->value.type) || instr_is_unreachable(parent_result_loc))) | 18149 | (type_is_invalid(parent_result_loc->value->type) || instr_is_unreachable(parent_result_loc))) |
| 18151 | { | 18150 | { |
| 18152 | return parent_result_loc; | 18151 | return parent_result_loc; |
| 18153 | } | 18152 | } |
| ... | @@ -18160,7 +18159,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18160,7 +18159,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18160 | if (instrs_to_move.length != 0) { | 18159 | if (instrs_to_move.length != 0) { |
| 18161 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; | 18160 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; |
| 18162 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 18161 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); |
| 18163 | ir_assert(branch_instruction->value.type->id == ZigTypeIdUnreachable, &phi_instruction->base); | 18162 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base); |
| 18164 | while (instrs_to_move.length != 0) { | 18163 | while (instrs_to_move.length != 0) { |
| 18165 | predecessor->instruction_list.append(instrs_to_move.pop()); | 18164 | predecessor->instruction_list.append(instrs_to_move.pop()); |
| 18166 | } | 18165 | } |
| ... | @@ -18197,10 +18196,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18197,10 +18196,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18197 | IrInstruction *old_value = phi_instruction->incoming_values[i]; | 18196 | IrInstruction *old_value = phi_instruction->incoming_values[i]; |
| 18198 | assert(old_value); | 18197 | assert(old_value); |
| 18199 | IrInstruction *new_value = old_value->child; | 18198 | IrInstruction *new_value = old_value->child; |
| 18200 | if (!new_value || new_value->value.type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) | 18199 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) |
| 18201 | continue; | 18200 | continue; |
| 18202 | | 18201 | |
| 18203 | if (type_is_invalid(new_value->value.type)) | 18202 | if (type_is_invalid(new_value->value->type)) |
| 18204 | return ira->codegen->invalid_instruction; | 18203 | return ira->codegen->invalid_instruction; |
| 18205 | | 18204 | |
| 18206 | | 18205 | |
| ... | @@ -18212,7 +18211,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18212,7 +18211,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18212 | if (new_incoming_blocks.length == 0) { | 18211 | if (new_incoming_blocks.length == 0) { |
| 18213 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 18212 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, |
| 18214 | phi_instruction->base.scope, phi_instruction->base.source_node); | 18213 | phi_instruction->base.scope, phi_instruction->base.source_node); |
| 18215 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 18214 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 18216 | return ir_finish_anal(ira, result); | 18215 | return ir_finish_anal(ira, result); |
| 18217 | } | 18216 | } |
| 18218 | | 18217 | |
| ... | @@ -18233,7 +18232,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -18233,7 +18232,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 18233 | if (type_is_invalid(resolved_type)) | 18232 | if (type_is_invalid(resolved_type)) |
| 18234 | return ira->codegen->invalid_instruction; | 18233 | return ira->codegen->invalid_instruction; |
| 18235 | } else { | 18234 | } else { |
| 18236 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value.type; | 18235 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; |
| 18237 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); | 18236 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); |
| 18238 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; | 18237 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; |
| 18239 | } | 18238 | } |
| ... | @@ -18281,14 +18280,14 @@ skip_resolve_peer_types: | ... | @@ -18281,14 +18280,14 @@ skip_resolve_peer_types: |
| 18281 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 18280 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); |
| 18282 | ir_set_cursor_at_end(&ira->new_irb, predecessor); | 18281 | ir_set_cursor_at_end(&ira->new_irb, predecessor); |
| 18283 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | 18282 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 18284 | if (type_is_invalid(casted_value->value.type)) { | 18283 | if (type_is_invalid(casted_value->value->type)) { |
| 18285 | return ira->codegen->invalid_instruction; | 18284 | return ira->codegen->invalid_instruction; |
| 18286 | } | 18285 | } |
| 18287 | new_incoming_values.items[i] = casted_value; | 18286 | new_incoming_values.items[i] = casted_value; |
| 18288 | predecessor->instruction_list.append(branch_instruction); | 18287 | predecessor->instruction_list.append(branch_instruction); |
| 18289 | | 18288 | |
| 18290 | if (all_stack_ptrs && (casted_value->value.special != ConstValSpecialRuntime || | 18289 | if (all_stack_ptrs && (casted_value->value->special != ConstValSpecialRuntime || |
| 18291 | casted_value->value.data.rh_ptr != RuntimeHintPtrStack)) | 18290 | casted_value->value->data.rh_ptr != RuntimeHintPtrStack)) |
| 18292 | { | 18291 | { |
| 18293 | all_stack_ptrs = false; | 18292 | all_stack_ptrs = false; |
| 18294 | } | 18293 | } |
| ... | @@ -18298,11 +18297,11 @@ skip_resolve_peer_types: | ... | @@ -18298,11 +18297,11 @@ skip_resolve_peer_types: |
| 18298 | IrInstruction *result = ir_build_phi(&ira->new_irb, | 18297 | IrInstruction *result = ir_build_phi(&ira->new_irb, |
| 18299 | phi_instruction->base.scope, phi_instruction->base.source_node, | 18298 | phi_instruction->base.scope, phi_instruction->base.source_node, |
| 18300 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); | 18299 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); |
| 18301 | result->value.type = resolved_type; | 18300 | result->value->type = resolved_type; |
| 18302 | | 18301 | |
| 18303 | if (all_stack_ptrs) { | 18302 | if (all_stack_ptrs) { |
| 18304 | assert(result->value.special == ConstValSpecialRuntime); | 18303 | assert(result->value->special == ConstValSpecialRuntime); |
| 18305 | result->value.data.rh_ptr = RuntimeHintPtrStack; | 18304 | result->value->data.rh_ptr = RuntimeHintPtrStack; |
| 18306 | } | 18305 | } |
| 18307 | | 18306 | |
| 18308 | return result; | 18307 | return result; |
| ... | @@ -18358,13 +18357,13 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { | ... | @@ -18358,13 +18357,13 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { |
| 18358 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { | 18357 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { |
| 18359 | Error err; | 18358 | Error err; |
| 18360 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; | 18359 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; |
| 18361 | if (type_is_invalid(array_ptr->value.type)) | 18360 | if (type_is_invalid(array_ptr->value->type)) |
| 18362 | return ira->codegen->invalid_instruction; | 18361 | return ira->codegen->invalid_instruction; |
| 18363 | | 18362 | |
| 18364 | ZigValue *orig_array_ptr_val = &array_ptr->value; | 18363 | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 18365 | | 18364 | |
| 18366 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; | 18365 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; |
| 18367 | if (type_is_invalid(elem_index->value.type)) | 18366 | if (type_is_invalid(elem_index->value->type)) |
| 18368 | return ira->codegen->invalid_instruction; | 18367 | return ira->codegen->invalid_instruction; |
| 18369 | | 18368 | |
| 18370 | ZigType *ptr_type = orig_array_ptr_val->type; | 18369 | ZigType *ptr_type = orig_array_ptr_val->type; |
| ... | @@ -18471,7 +18470,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18471,7 +18470,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18471 | return ira->codegen->invalid_instruction; | 18470 | return ira->codegen->invalid_instruction; |
| 18472 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); | 18471 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); |
| 18473 | Buf *field_name = buf_alloc(); | 18472 | Buf *field_name = buf_alloc(); |
| 18474 | bigint_append_buf(field_name, &casted_elem_index->value.data.x_bigint, 10); | 18473 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); |
| 18475 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, | 18474 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, |
| 18476 | array_ptr, array_type); | 18475 | array_ptr, array_type); |
| 18477 | } else { | 18476 | } else { |
| ... | @@ -18487,13 +18486,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18487,13 +18486,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18487 | | 18486 | |
| 18488 | bool safety_check_on = elem_ptr_instruction->safety_check_on; | 18487 | bool safety_check_on = elem_ptr_instruction->safety_check_on; |
| 18489 | if (instr_is_comptime(casted_elem_index)) { | 18488 | if (instr_is_comptime(casted_elem_index)) { |
| 18490 | uint64_t index = bigint_as_u64(&casted_elem_index->value.data.x_bigint); | 18489 | uint64_t index = bigint_as_u64(&casted_elem_index->value->data.x_bigint); |
| 18491 | if (array_type->id == ZigTypeIdArray) { | 18490 | if (array_type->id == ZigTypeIdArray) { |
| 18492 | uint64_t array_len = array_type->data.array.len; | 18491 | uint64_t array_len = array_type->data.array.len; |
| 18493 | if (index == array_len && array_type->data.array.sentinel != nullptr) { | 18492 | if (index == array_len && array_type->data.array.sentinel != nullptr) { |
| 18494 | ZigType *elem_type = array_type->data.array.child_type; | 18493 | ZigType *elem_type = array_type->data.array.child_type; |
| 18495 | IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type); | 18494 | IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type); |
| 18496 | copy_const_val(&sentinel_elem->value, array_type->data.array.sentinel, false); | 18495 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel, false); |
| 18497 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); | 18496 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); |
| 18498 | } | 18497 | } |
| 18499 | if (index >= array_len) { | 18498 | if (index >= array_len) { |
| ... | @@ -18565,8 +18564,8 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18565,8 +18564,8 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18565 | elem_val->parent.data.p_array.elem_index = i; | 18564 | elem_val->parent.data.p_array.elem_index = i; |
| 18566 | } | 18565 | } |
| 18567 | } else if (is_slice(array_type)) { | 18566 | } else if (is_slice(array_type)) { |
| 18568 | ir_assert(array_ptr->value.type->id == ZigTypeIdPointer, &elem_ptr_instruction->base); | 18567 | ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base); |
| 18569 | ZigType *actual_array_type = array_ptr->value.type->data.pointer.child_type; | 18568 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; |
| 18570 | | 18569 | |
| 18571 | if (type_is_invalid(actual_array_type)) | 18570 | if (type_is_invalid(actual_array_type)) |
| 18572 | return ira->codegen->invalid_instruction; | 18571 | return ira->codegen->invalid_instruction; |
| ... | @@ -18608,7 +18607,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18608,7 +18607,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18608 | { | 18607 | { |
| 18609 | if (array_type->id == ZigTypeIdPointer) { | 18608 | if (array_type->id == ZigTypeIdPointer) { |
| 18610 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18609 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18611 | ZigValue *out_val = &result->value; | 18610 | ZigValue *out_val = result->value; |
| 18612 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 18611 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 18613 | size_t new_index; | 18612 | size_t new_index; |
| 18614 | size_t mem_size; | 18613 | size_t mem_size; |
| ... | @@ -18688,12 +18687,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18688,12 +18687,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18688 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18687 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18689 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, | 18688 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, |
| 18690 | elem_ptr_instruction->ptr_len, nullptr); | 18689 | elem_ptr_instruction->ptr_len, nullptr); |
| 18691 | result->value.type = return_type; | 18690 | result->value->type = return_type; |
| 18692 | return result; | 18691 | return result; |
| 18693 | } | 18692 | } |
| 18694 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; | 18693 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 18695 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18694 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18696 | ZigValue *out_val = &result->value; | 18695 | ZigValue *out_val = result->value; |
| 18697 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; | 18696 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 18698 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); | 18697 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 18699 | uint64_t full_slice_len = slice_len + | 18698 | uint64_t full_slice_len = slice_len + |
| ... | @@ -18752,12 +18751,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18752,12 +18751,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18752 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18751 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18753 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, | 18752 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, |
| 18754 | false, elem_ptr_instruction->ptr_len, nullptr); | 18753 | false, elem_ptr_instruction->ptr_len, nullptr); |
| 18755 | result->value.type = return_type; | 18754 | result->value->type = return_type; |
| 18756 | result->value.special = ConstValSpecialStatic; | 18755 | result->value->special = ConstValSpecialStatic; |
| 18757 | } else { | 18756 | } else { |
| 18758 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18757 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18759 | } | 18758 | } |
| 18760 | ZigValue *out_val = &result->value; | 18759 | ZigValue *out_val = result->value; |
| 18761 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 18760 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 18762 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; | 18761 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; |
| 18763 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; | 18762 | out_val->data.x_ptr.data.base_array.array_val = array_ptr_val; |
| ... | @@ -18814,7 +18813,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18814,7 +18813,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18814 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18813 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| 18815 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, | 18814 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, |
| 18816 | elem_ptr_instruction->ptr_len, nullptr); | 18815 | elem_ptr_instruction->ptr_len, nullptr); |
| 18817 | result->value.type = return_type; | 18816 | result->value->type = return_type; |
| 18818 | return result; | 18817 | return result; |
| 18819 | } | 18818 | } |
| 18820 | | 18819 | |
| ... | @@ -18892,8 +18891,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18892,8 +18891,8 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18892 | case OnePossibleValueNo: | 18891 | case OnePossibleValueNo: |
| 18893 | break; | 18892 | break; |
| 18894 | } | 18893 | } |
| 18895 | bool is_const = struct_ptr->value.type->data.pointer.is_const; | 18894 | bool is_const = struct_ptr->value->type->data.pointer.is_const; |
| 18896 | bool is_volatile = struct_ptr->value.type->data.pointer.is_volatile; | 18895 | bool is_volatile = struct_ptr->value->type->data.pointer.is_volatile; |
| 18897 | ZigType *ptr_type; | 18896 | ZigType *ptr_type; |
| 18898 | if (struct_type->data.structure.is_inferred) { | 18897 | if (struct_type->data.structure.is_inferred) { |
| 18899 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 18898 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| ... | @@ -18904,9 +18903,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18904,9 +18903,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18904 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; | 18903 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; |
| 18905 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) | 18904 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) |
| 18906 | return ira->codegen->invalid_instruction; | 18905 | return ira->codegen->invalid_instruction; |
| 18907 | assert(struct_ptr->value.type->id == ZigTypeIdPointer); | 18906 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); |
| 18908 | uint32_t ptr_bit_offset = struct_ptr->value.type->data.pointer.bit_offset_in_host; | 18907 | uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host; |
| 18909 | uint32_t ptr_host_int_bytes = struct_ptr->value.type->data.pointer.host_int_bytes; | 18908 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; |
| 18910 | uint32_t host_int_bytes_for_result_type = (ptr_host_int_bytes == 0) ? | 18909 | uint32_t host_int_bytes_for_result_type = (ptr_host_int_bytes == 0) ? |
| 18911 | get_host_int_bytes(ira->codegen, struct_type, field) : ptr_host_int_bytes; | 18910 | get_host_int_bytes(ira->codegen, struct_type, field) : ptr_host_int_bytes; |
| 18912 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 18911 | ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| ... | @@ -18942,12 +18941,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18942,12 +18941,12 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18942 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 18941 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 18943 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, | 18942 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, |
| 18944 | source_instr->source_node, struct_ptr, field); | 18943 | source_instr->source_node, struct_ptr, field); |
| 18945 | result->value.type = ptr_type; | 18944 | result->value->type = ptr_type; |
| 18946 | result->value.special = ConstValSpecialStatic; | 18945 | result->value->special = ConstValSpecialStatic; |
| 18947 | } else { | 18946 | } else { |
| 18948 | result = ir_const(ira, source_instr, ptr_type); | 18947 | result = ir_const(ira, source_instr, ptr_type); |
| 18949 | } | 18948 | } |
| 18950 | ZigValue *const_val = &result->value; | 18949 | ZigValue *const_val = result->value; |
| 18951 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; | 18950 | const_val->data.x_ptr.special = ConstPtrSpecialBaseStruct; |
| 18952 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 18951 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 18953 | const_val->data.x_ptr.data.base_struct.struct_val = struct_val; | 18952 | const_val->data.x_ptr.data.base_struct.struct_val = struct_val; |
| ... | @@ -18957,7 +18956,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18957,7 +18956,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18957 | } | 18956 | } |
| 18958 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, | 18957 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, |
| 18959 | struct_ptr, field); | 18958 | struct_ptr, field); |
| 18960 | result->value.type = ptr_type; | 18959 | result->value->type = ptr_type; |
| 18961 | return result; | 18960 | return result; |
| 18962 | } | 18961 | } |
| 18963 | | 18962 | |
| ... | @@ -18970,7 +18969,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -18970,7 +18969,7 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 18970 | // the field type will then be available, and the field will be added to the inferred | 18969 | // the field type will then be available, and the field will be added to the inferred |
| 18971 | // struct. | 18970 | // struct. |
| 18972 | | 18971 | |
| 18973 | ZigType *container_ptr_type = container_ptr->value.type; | 18972 | ZigType *container_ptr_type = container_ptr->value->type; |
| 18974 | ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr); | 18973 | ir_assert(container_ptr_type->id == ZigTypeIdPointer, source_instr); |
| 18975 | | 18974 | |
| 18976 | InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField"); | 18975 | InferredStructField *inferred_struct_field = allocate<InferredStructField>(1, "InferredStructField"); |
| ... | @@ -18984,14 +18983,14 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -18984,14 +18983,14 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 18984 | | 18983 | |
| 18985 | if (instr_is_comptime(container_ptr)) { | 18984 | if (instr_is_comptime(container_ptr)) { |
| 18986 | IrInstruction *result = ir_const(ira, source_instr, field_ptr_type); | 18985 | IrInstruction *result = ir_const(ira, source_instr, field_ptr_type); |
| 18987 | copy_const_val(&result->value, &container_ptr->value, false); | 18986 | copy_const_val(result->value, container_ptr->value, false); |
| 18988 | result->value.type = field_ptr_type; | 18987 | result->value->type = field_ptr_type; |
| 18989 | return result; | 18988 | return result; |
| 18990 | } | 18989 | } |
| 18991 | | 18990 | |
| 18992 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, | 18991 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, |
| 18993 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); | 18992 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); |
| 18994 | result->value.type = field_ptr_type; | 18993 | result->value->type = field_ptr_type; |
| 18995 | return result; | 18994 | return result; |
| 18996 | } | 18995 | } |
| 18997 | | 18996 | |
| ... | @@ -19011,7 +19010,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19011,7 +19010,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19011 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) | 19010 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) |
| 19012 | return ira->codegen->invalid_instruction; | 19011 | return ira->codegen->invalid_instruction; |
| 19013 | | 19012 | |
| 19014 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19013 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19015 | if (bare_type->id == ZigTypeIdStruct) { | 19014 | if (bare_type->id == ZigTypeIdStruct) { |
| 19016 | TypeStructField *field = find_struct_type_field(bare_type, field_name); | 19015 | TypeStructField *field = find_struct_type_field(bare_type, field_name); |
| 19017 | if (field != nullptr) { | 19016 | if (field != nullptr) { |
| ... | @@ -19028,8 +19027,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19028,8 +19027,8 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19028 | } | 19027 | } |
| 19029 | | 19028 | |
| 19030 | if (bare_type->id == ZigTypeIdUnion) { | 19029 | if (bare_type->id == ZigTypeIdUnion) { |
| 19031 | bool is_const = container_ptr->value.type->data.pointer.is_const; | 19030 | bool is_const = container_ptr->value->type->data.pointer.is_const; |
| 19032 | bool is_volatile = container_ptr->value.type->data.pointer.is_volatile; | 19031 | bool is_volatile = container_ptr->value->type->data.pointer.is_volatile; |
| 19033 | | 19032 | |
| 19034 | TypeUnionField *field = find_union_type_field(bare_type, field_name); | 19033 | TypeUnionField *field = find_union_type_field(bare_type, field_name); |
| 19035 | if (field == nullptr) { | 19034 | if (field == nullptr) { |
| ... | @@ -19085,14 +19084,14 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19085,14 +19084,14 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19085 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 19084 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 19086 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 19085 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, |
| 19087 | source_instr->source_node, container_ptr, field, true, initializing); | 19086 | source_instr->source_node, container_ptr, field, true, initializing); |
| 19088 | result->value.type = ptr_type; | 19087 | result->value->type = ptr_type; |
| 19089 | result->value.special = ConstValSpecialStatic; | 19088 | result->value->special = ConstValSpecialStatic; |
| 19090 | } else { | 19089 | } else { |
| 19091 | result = ir_const(ira, source_instr, ptr_type); | 19090 | result = ir_const(ira, source_instr, ptr_type); |
| 19092 | } | 19091 | } |
| 19093 | ZigValue *const_val = &result->value; | 19092 | ZigValue *const_val = result->value; |
| 19094 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 19093 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 19095 | const_val->data.x_ptr.mut = container_ptr->value.data.x_ptr.mut; | 19094 | const_val->data.x_ptr.mut = container_ptr->value->data.x_ptr.mut; |
| 19096 | const_val->data.x_ptr.data.ref.pointee = payload_val; | 19095 | const_val->data.x_ptr.data.ref.pointee = payload_val; |
| 19097 | return result; | 19096 | return result; |
| 19098 | } | 19097 | } |
| ... | @@ -19100,7 +19099,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -19100,7 +19099,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 19100 | | 19099 | |
| 19101 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 19100 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, |
| 19102 | source_instr->source_node, container_ptr, field, true, initializing); | 19101 | source_instr->source_node, container_ptr, field, true, initializing); |
| 19103 | result->value.type = ptr_type; | 19102 | result->value->type = ptr_type; |
| 19104 | return result; | 19103 | return result; |
| 19105 | } | 19104 | } |
| 19106 | | 19105 | |
| ... | @@ -19205,10 +19204,10 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n | ... | @@ -19205,10 +19204,10 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n |
| 19205 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { | 19204 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { |
| 19206 | Error err; | 19205 | Error err; |
| 19207 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; | 19206 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; |
| 19208 | if (type_is_invalid(container_ptr->value.type)) | 19207 | if (type_is_invalid(container_ptr->value->type)) |
| 19209 | return ira->codegen->invalid_instruction; | 19208 | return ira->codegen->invalid_instruction; |
| 19210 | | 19209 | |
| 19211 | ZigType *container_type = container_ptr->value.type->data.pointer.child_type; | 19210 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; |
| 19212 | | 19211 | |
| 19213 | Buf *field_name = field_ptr_instruction->field_name_buffer; | 19212 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 19214 | if (!field_name) { | 19213 | if (!field_name) { |
| ... | @@ -19224,7 +19223,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19224,7 +19223,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19224 | if (type_is_invalid(container_type)) { | 19223 | if (type_is_invalid(container_type)) { |
| 19225 | return ira->codegen->invalid_instruction; | 19224 | return ira->codegen->invalid_instruction; |
| 19226 | } else if (is_slice(container_type) || is_container_ref(container_type)) { | 19225 | } else if (is_slice(container_type) || is_container_ref(container_type)) { |
| 19227 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19226 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19228 | if (container_type->id == ZigTypeIdPointer) { | 19227 | if (container_type->id == ZigTypeIdPointer) { |
| 19229 | ZigType *bare_type = container_ref_type(container_type); | 19228 | ZigType *bare_type = container_ref_type(container_type); |
| 19230 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); | 19229 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); |
| ... | @@ -19259,7 +19258,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19259,7 +19258,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19259 | if (!container_ptr_val) | 19258 | if (!container_ptr_val) |
| 19260 | return ira->codegen->invalid_instruction; | 19259 | return ira->codegen->invalid_instruction; |
| 19261 | | 19260 | |
| 19262 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19261 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19263 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19262 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19264 | if (child_val == nullptr) | 19263 | if (child_val == nullptr) |
| 19265 | return ira->codegen->invalid_instruction; | 19264 | return ira->codegen->invalid_instruction; |
| ... | @@ -19285,7 +19284,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19285,7 +19284,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19285 | if (!container_ptr_val) | 19284 | if (!container_ptr_val) |
| 19286 | return ira->codegen->invalid_instruction; | 19285 | return ira->codegen->invalid_instruction; |
| 19287 | | 19286 | |
| 19288 | assert(container_ptr->value.type->id == ZigTypeIdPointer); | 19287 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 19289 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 19288 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 19290 | if (child_val == nullptr) | 19289 | if (child_val == nullptr) |
| 19291 | return ira->codegen->invalid_instruction; | 19290 | return ira->codegen->invalid_instruction; |
| ... | @@ -19567,11 +19566,11 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19567,11 +19566,11 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 19567 | | 19566 | |
| 19568 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { | 19567 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { |
| 19569 | IrInstruction *ptr = instruction->ptr->child; | 19568 | IrInstruction *ptr = instruction->ptr->child; |
| 19570 | if (type_is_invalid(ptr->value.type)) | 19569 | if (type_is_invalid(ptr->value->type)) |
| 19571 | return ira->codegen->invalid_instruction; | 19570 | return ira->codegen->invalid_instruction; |
| 19572 | | 19571 | |
| 19573 | IrInstruction *value = instruction->value->child; | 19572 | IrInstruction *value = instruction->value->child; |
| 19574 | if (type_is_invalid(value->value.type)) | 19573 | if (type_is_invalid(value->value->type)) |
| 19575 | return ira->codegen->invalid_instruction; | 19574 | return ira->codegen->invalid_instruction; |
| 19576 | | 19575 | |
| 19577 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); | 19576 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); |
| ... | @@ -19579,14 +19578,14 @@ static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -19579,14 +19578,14 @@ static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstruc |
| 19579 | | 19578 | |
| 19580 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { | 19579 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { |
| 19581 | IrInstruction *ptr = instruction->ptr->child; | 19580 | IrInstruction *ptr = instruction->ptr->child; |
| 19582 | if (type_is_invalid(ptr->value.type)) | 19581 | if (type_is_invalid(ptr->value->type)) |
| 19583 | return ira->codegen->invalid_instruction; | 19582 | return ira->codegen->invalid_instruction; |
| 19584 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); | 19583 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); |
| 19585 | } | 19584 | } |
| 19586 | | 19585 | |
| 19587 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { | 19586 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { |
| 19588 | IrInstruction *expr_value = typeof_instruction->value->child; | 19587 | IrInstruction *expr_value = typeof_instruction->value->child; |
| 19589 | ZigType *type_entry = expr_value->value.type; | 19588 | ZigType *type_entry = expr_value->value->type; |
| 19590 | if (type_is_invalid(type_entry)) | 19589 | if (type_is_invalid(type_entry)) |
| 19591 | return ira->codegen->invalid_instruction; | 19590 | return ira->codegen->invalid_instruction; |
| 19592 | return ir_const_type(ira, &typeof_instruction->base, type_entry); | 19591 | return ir_const_type(ira, &typeof_instruction->base, type_entry); |
| ... | @@ -19749,11 +19748,11 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -19749,11 +19748,11 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 19749 | IrInstructionSliceType *slice_type_instruction) | 19748 | IrInstructionSliceType *slice_type_instruction) |
| 19750 | { | 19749 | { |
| 19751 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); | 19750 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); |
| 19752 | result->value.special = ConstValSpecialLazy; | 19751 | result->value->special = ConstValSpecialLazy; |
| 19753 | | 19752 | |
| 19754 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); | 19753 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); |
| 19755 | lazy_slice_type->ira = ira; | 19754 | lazy_slice_type->ira = ira; |
| 19756 | result->value.data.x_lazy = &lazy_slice_type->base; | 19755 | result->value->data.x_lazy = &lazy_slice_type->base; |
| 19757 | lazy_slice_type->base.id = LazyValueIdSliceType; | 19756 | lazy_slice_type->base.id = LazyValueIdSliceType; |
| 19758 | | 19757 | |
| 19759 | if (slice_type_instruction->align_value != nullptr) { | 19758 | if (slice_type_instruction->align_value != nullptr) { |
| ... | @@ -19812,14 +19811,14 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -19812,14 +19811,14 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 19812 | | 19811 | |
| 19813 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 19812 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 19814 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; | 19813 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; |
| 19815 | if (type_is_invalid(input_value->value.type)) | 19814 | if (type_is_invalid(input_value->value->type)) |
| 19816 | return ira->codegen->invalid_instruction; | 19815 | return ira->codegen->invalid_instruction; |
| 19817 | | 19816 | |
| 19818 | if (instr_is_comptime(input_value) && | 19817 | if (instr_is_comptime(input_value) && |
| 19819 | (input_value->value.type->id == ZigTypeIdComptimeInt || | 19818 | (input_value->value->type->id == ZigTypeIdComptimeInt || |
| 19820 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { | 19819 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { |
| 19821 | ir_add_error_node(ira, input_value->source_node, | 19820 | ir_add_error_node(ira, input_value->source_node, |
| 19822 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name))); | 19821 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); |
| 19823 | return ira->codegen->invalid_instruction; | 19822 | return ira->codegen->invalid_instruction; |
| 19824 | } | 19823 | } |
| 19825 | | 19824 | |
| ... | @@ -19831,7 +19830,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -19831,7 +19830,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 19831 | asm_instruction->asm_template, asm_instruction->token_list, asm_instruction->token_list_len, | 19830 | asm_instruction->asm_template, asm_instruction->token_list, asm_instruction->token_list_len, |
| 19832 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, | 19831 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, |
| 19833 | asm_instruction->has_side_effects); | 19832 | asm_instruction->has_side_effects); |
| 19834 | result->value.type = return_type; | 19833 | result->value->type = return_type; |
| 19835 | return result; | 19834 | return result; |
| 19836 | } | 19835 | } |
| 19837 | | 19836 | |
| ... | @@ -19853,10 +19852,10 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -19853,10 +19852,10 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19853 | ZigValue *sentinel_val; | 19852 | ZigValue *sentinel_val; |
| 19854 | if (array_type_instruction->sentinel != nullptr) { | 19853 | if (array_type_instruction->sentinel != nullptr) { |
| 19855 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; | 19854 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; |
| 19856 | if (type_is_invalid(uncasted_sentinel->value.type)) | 19855 | if (type_is_invalid(uncasted_sentinel->value->type)) |
| 19857 | return ira->codegen->invalid_instruction; | 19856 | return ira->codegen->invalid_instruction; |
| 19858 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type); | 19857 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type); |
| 19859 | if (type_is_invalid(sentinel->value.type)) | 19858 | if (type_is_invalid(sentinel->value->type)) |
| 19860 | return ira->codegen->invalid_instruction; | 19859 | return ira->codegen->invalid_instruction; |
| 19861 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 19860 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 19862 | if (sentinel_val == nullptr) | 19861 | if (sentinel_val == nullptr) |
| ... | @@ -19909,11 +19908,11 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -19909,11 +19908,11 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19909 | | 19908 | |
| 19910 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { | 19909 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { |
| 19911 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 19910 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 19912 | result->value.special = ConstValSpecialLazy; | 19911 | result->value->special = ConstValSpecialLazy; |
| 19913 | | 19912 | |
| 19914 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1); | 19913 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1); |
| 19915 | lazy_size_of->ira = ira; | 19914 | lazy_size_of->ira = ira; |
| 19916 | result->value.data.x_lazy = &lazy_size_of->base; | 19915 | result->value->data.x_lazy = &lazy_size_of->base; |
| 19917 | lazy_size_of->base.id = LazyValueIdSizeOf; | 19916 | lazy_size_of->base.id = LazyValueIdSizeOf; |
| 19918 | | 19917 | |
| 19919 | lazy_size_of->target_type = instruction->type_value->child; | 19918 | lazy_size_of->target_type = instruction->type_value->child; |
| ... | @@ -19924,7 +19923,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi | ... | @@ -19924,7 +19923,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi |
| 19924 | } | 19923 | } |
| 19925 | | 19924 | |
| 19926 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { | 19925 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { |
| 19927 | ZigType *type_entry = value->value.type; | 19926 | ZigType *type_entry = value->value->type; |
| 19928 | | 19927 | |
| 19929 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { | 19928 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| 19930 | if (instr_is_comptime(value)) { | 19929 | if (instr_is_comptime(value)) { |
| ... | @@ -19941,7 +19940,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19941,7 +19940,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19941 | | 19940 | |
| 19942 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 19941 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, |
| 19943 | source_inst->scope, source_inst->source_node, value); | 19942 | source_inst->scope, source_inst->source_node, value); |
| 19944 | result->value.type = ira->codegen->builtin_types.entry_bool; | 19943 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 19945 | return result; | 19944 | return result; |
| 19946 | } else if (type_entry->id == ZigTypeIdOptional) { | 19945 | } else if (type_entry->id == ZigTypeIdOptional) { |
| 19947 | if (instr_is_comptime(value)) { | 19946 | if (instr_is_comptime(value)) { |
| ... | @@ -19956,7 +19955,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19956,7 +19955,7 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19956 | | 19955 | |
| 19957 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 19956 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, |
| 19958 | source_inst->scope, source_inst->source_node, value); | 19957 | source_inst->scope, source_inst->source_node, value); |
| 19959 | result->value.type = ira->codegen->builtin_types.entry_bool; | 19958 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 19960 | return result; | 19959 | return result; |
| 19961 | } else if (type_entry->id == ZigTypeIdNull) { | 19960 | } else if (type_entry->id == ZigTypeIdNull) { |
| 19962 | return ir_const_bool(ira, source_inst, false); | 19961 | return ir_const_bool(ira, source_inst, false); |
| ... | @@ -19967,23 +19966,23 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -19967,23 +19966,23 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 19967 | | 19966 | |
| 19968 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { | 19967 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { |
| 19969 | IrInstruction *value = instruction->value->child; | 19968 | IrInstruction *value = instruction->value->child; |
| 19970 | if (type_is_invalid(value->value.type)) | 19969 | if (type_is_invalid(value->value->type)) |
| 19971 | return ira->codegen->invalid_instruction; | 19970 | return ira->codegen->invalid_instruction; |
| 19972 | | 19971 | |
| 19973 | return ir_analyze_test_non_null(ira, &instruction->base, value); | 19972 | return ir_analyze_test_non_null(ira, &instruction->base, value); |
| 19974 | } | 19973 | } |
| 19975 | | 19974 | |
| 19976 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | 19975 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { |
| 19977 | ir_assert(ptr->value.type->id == ZigTypeIdPointer, ptr); | 19976 | ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 19978 | ZigType *elem_type = ptr->value.type->data.pointer.child_type; | 19977 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 19979 | if (elem_type != g->builtin_types.entry_var) | 19978 | if (elem_type != g->builtin_types.entry_var) |
| 19980 | return elem_type; | 19979 | return elem_type; |
| 19981 | | 19980 | |
| 19982 | if (ir_resolve_lazy(g, ptr->source_node, &ptr->value)) | 19981 | if (ir_resolve_lazy(g, ptr->source_node, ptr->value)) |
| 19983 | return g->builtin_types.entry_invalid; | 19982 | return g->builtin_types.entry_invalid; |
| 19984 | | 19983 | |
| 19985 | assert(value_is_comptime(&ptr->value)); | 19984 | assert(value_is_comptime(ptr->value)); |
| 19986 | ZigValue *pointee = const_ptr_pointee_unchecked(g, &ptr->value); | 19985 | ZigValue *pointee = const_ptr_pointee_unchecked(g, ptr->value); |
| 19987 | return pointee->type; | 19986 | return pointee->type; |
| 19988 | } | 19987 | } |
| 19989 | | 19988 | |
| ... | @@ -20028,7 +20027,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20028,7 +20027,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20028 | | 20027 | |
| 20029 | ZigType *child_type = type_entry->data.maybe.child_type; | 20028 | ZigType *child_type = type_entry->data.maybe.child_type; |
| 20030 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type, | 20029 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, child_type, |
| 20031 | base_ptr->value.type->data.pointer.is_const, base_ptr->value.type->data.pointer.is_volatile, | 20030 | base_ptr->value->type->data.pointer.is_const, base_ptr->value->type->data.pointer.is_volatile, |
| 20032 | PtrLenSingle, 0, 0, 0, false); | 20031 | PtrLenSingle, 0, 0, 0, false); |
| 20033 | | 20032 | |
| 20034 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); | 20033 | bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, child_type, type_entry); |
| ... | @@ -20079,12 +20078,12 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20079,12 +20078,12 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20079 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 20078 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20080 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 20079 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, |
| 20081 | source_instr->source_node, base_ptr, false, initializing); | 20080 | source_instr->source_node, base_ptr, false, initializing); |
| 20082 | result->value.type = result_type; | 20081 | result->value->type = result_type; |
| 20083 | result->value.special = ConstValSpecialStatic; | 20082 | result->value->special = ConstValSpecialStatic; |
| 20084 | } else { | 20083 | } else { |
| 20085 | result = ir_const(ira, source_instr, result_type); | 20084 | result = ir_const(ira, source_instr, result_type); |
| 20086 | } | 20085 | } |
| 20087 | ZigValue *result_val = &result->value; | 20086 | ZigValue *result_val = result->value; |
| 20088 | result_val->data.x_ptr.special = ConstPtrSpecialRef; | 20087 | result_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20089 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 20088 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 20090 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 20089 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| ... | @@ -20109,7 +20108,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -20109,7 +20108,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 20109 | | 20108 | |
| 20110 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 20109 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, |
| 20111 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 20110 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 20112 | result->value.type = result_type; | 20111 | result->value->type = result_type; |
| 20113 | return result; | 20112 | return result; |
| 20114 | } | 20113 | } |
| 20115 | | 20114 | |
| ... | @@ -20117,7 +20116,7 @@ static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | ... | @@ -20117,7 +20116,7 @@ static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, |
| 20117 | IrInstructionOptionalUnwrapPtr *instruction) | 20116 | IrInstructionOptionalUnwrapPtr *instruction) |
| 20118 | { | 20117 | { |
| 20119 | IrInstruction *base_ptr = instruction->base_ptr->child; | 20118 | IrInstruction *base_ptr = instruction->base_ptr->child; |
| 20120 | if (type_is_invalid(base_ptr->value.type)) | 20119 | if (type_is_invalid(base_ptr->value->type)) |
| 20121 | return ira->codegen->invalid_instruction; | 20120 | return ira->codegen->invalid_instruction; |
| 20122 | | 20121 | |
| 20123 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, | 20122 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, |
| ... | @@ -20130,7 +20129,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt | ... | @@ -20130,7 +20129,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt |
| 20130 | return ira->codegen->invalid_instruction; | 20129 | return ira->codegen->invalid_instruction; |
| 20131 | | 20130 | |
| 20132 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20131 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20133 | if (type_is_invalid(op->value.type)) | 20132 | if (type_is_invalid(op->value->type)) |
| 20134 | return ira->codegen->invalid_instruction; | 20133 | return ira->codegen->invalid_instruction; |
| 20135 | | 20134 | |
| 20136 | if (int_type->data.integral.bit_count == 0) | 20135 | if (int_type->data.integral.bit_count == 0) |
| ... | @@ -20142,14 +20141,14 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt | ... | @@ -20142,14 +20141,14 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt |
| 20142 | return ira->codegen->invalid_instruction; | 20141 | return ira->codegen->invalid_instruction; |
| 20143 | if (val->special == ConstValSpecialUndef) | 20142 | if (val->special == ConstValSpecialUndef) |
| 20144 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 20143 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 20145 | size_t result_usize = bigint_ctz(&op->value.data.x_bigint, int_type->data.integral.bit_count); | 20144 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 20146 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 20145 | return ir_const_unsigned(ira, &instruction->base, result_usize); |
| 20147 | } | 20146 | } |
| 20148 | | 20147 | |
| 20149 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20148 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20150 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, | 20149 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, |
| 20151 | instruction->base.source_node, nullptr, op); | 20150 | instruction->base.source_node, nullptr, op); |
| 20152 | result->value.type = return_type; | 20151 | result->value->type = return_type; |
| 20153 | return result; | 20152 | return result; |
| 20154 | } | 20153 | } |
| 20155 | | 20154 | |
| ... | @@ -20159,7 +20158,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl | ... | @@ -20159,7 +20158,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl |
| 20159 | return ira->codegen->invalid_instruction; | 20158 | return ira->codegen->invalid_instruction; |
| 20160 | | 20159 | |
| 20161 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20160 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20162 | if (type_is_invalid(op->value.type)) | 20161 | if (type_is_invalid(op->value->type)) |
| 20163 | return ira->codegen->invalid_instruction; | 20162 | return ira->codegen->invalid_instruction; |
| 20164 | | 20163 | |
| 20165 | if (int_type->data.integral.bit_count == 0) | 20164 | if (int_type->data.integral.bit_count == 0) |
| ... | @@ -20171,14 +20170,14 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl | ... | @@ -20171,14 +20170,14 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl |
| 20171 | return ira->codegen->invalid_instruction; | 20170 | return ira->codegen->invalid_instruction; |
| 20172 | if (val->special == ConstValSpecialUndef) | 20171 | if (val->special == ConstValSpecialUndef) |
| 20173 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 20172 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 20174 | size_t result_usize = bigint_clz(&op->value.data.x_bigint, int_type->data.integral.bit_count); | 20173 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 20175 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 20174 | return ir_const_unsigned(ira, &instruction->base, result_usize); |
| 20176 | } | 20175 | } |
| 20177 | | 20176 | |
| 20178 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20177 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20179 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, | 20178 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, |
| 20180 | instruction->base.source_node, nullptr, op); | 20179 | instruction->base.source_node, nullptr, op); |
| 20181 | result->value.type = return_type; | 20180 | result->value->type = return_type; |
| 20182 | return result; | 20181 | return result; |
| 20183 | } | 20182 | } |
| 20184 | | 20183 | |
| ... | @@ -20188,7 +20187,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc | ... | @@ -20188,7 +20187,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20188 | return ira->codegen->invalid_instruction; | 20187 | return ira->codegen->invalid_instruction; |
| 20189 | | 20188 | |
| 20190 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 20189 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20191 | if (type_is_invalid(op->value.type)) | 20190 | if (type_is_invalid(op->value->type)) |
| 20192 | return ira->codegen->invalid_instruction; | 20191 | return ira->codegen->invalid_instruction; |
| 20193 | | 20192 | |
| 20194 | if (int_type->data.integral.bit_count == 0) | 20193 | if (int_type->data.integral.bit_count == 0) |
| ... | @@ -20212,33 +20211,33 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc | ... | @@ -20212,33 +20211,33 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20212 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 20211 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 20213 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, | 20212 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, |
| 20214 | instruction->base.source_node, nullptr, op); | 20213 | instruction->base.source_node, nullptr, op); |
| 20215 | result->value.type = return_type; | 20214 | result->value->type = return_type; |
| 20216 | return result; | 20215 | return result; |
| 20217 | } | 20216 | } |
| 20218 | | 20217 | |
| 20219 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { | 20218 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { |
| 20220 | if (type_is_invalid(value->value.type)) | 20219 | if (type_is_invalid(value->value->type)) |
| 20221 | return ira->codegen->invalid_instruction; | 20220 | return ira->codegen->invalid_instruction; |
| 20222 | | 20221 | |
| 20223 | if (value->value.type->id == ZigTypeIdEnum) { | 20222 | if (value->value->type->id == ZigTypeIdEnum) { |
| 20224 | return value; | 20223 | return value; |
| 20225 | } | 20224 | } |
| 20226 | | 20225 | |
| 20227 | if (value->value.type->id != ZigTypeIdUnion) { | 20226 | if (value->value->type->id != ZigTypeIdUnion) { |
| 20228 | ir_add_error(ira, value, | 20227 | ir_add_error(ira, value, |
| 20229 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name))); | 20228 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); |
| 20230 | return ira->codegen->invalid_instruction; | 20229 | return ira->codegen->invalid_instruction; |
| 20231 | } | 20230 | } |
| 20232 | if (!value->value.type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { | 20231 | if (!value->value->type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { |
| 20233 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); | 20232 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); |
| 20234 | if (value->value.type->data.unionation.decl_node != nullptr) { | 20233 | if (value->value->type->data.unionation.decl_node != nullptr) { |
| 20235 | add_error_note(ira->codegen, msg, value->value.type->data.unionation.decl_node, | 20234 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, |
| 20236 | buf_sprintf("declared here")); | 20235 | buf_sprintf("declared here")); |
| 20237 | } | 20236 | } |
| 20238 | return ira->codegen->invalid_instruction; | 20237 | return ira->codegen->invalid_instruction; |
| 20239 | } | 20238 | } |
| 20240 | | 20239 | |
| 20241 | ZigType *tag_type = value->value.type->data.unionation.tag_type; | 20240 | ZigType *tag_type = value->value->type->data.unionation.tag_type; |
| 20242 | assert(tag_type->id == ZigTypeIdEnum); | 20241 | assert(tag_type->id == ZigTypeIdEnum); |
| 20243 | | 20242 | |
| 20244 | if (instr_is_comptime(value)) { | 20243 | if (instr_is_comptime(value)) { |
| ... | @@ -20248,14 +20247,14 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -20248,14 +20247,14 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 20248 | | 20247 | |
| 20249 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 20248 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 20250 | source_instr->scope, source_instr->source_node); | 20249 | source_instr->scope, source_instr->source_node); |
| 20251 | const_instruction->base.value.type = tag_type; | 20250 | const_instruction->base.value->type = tag_type; |
| 20252 | const_instruction->base.value.special = ConstValSpecialStatic; | 20251 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 20253 | bigint_init_bigint(&const_instruction->base.value.data.x_enum_tag, &val->data.x_union.tag); | 20252 | bigint_init_bigint(&const_instruction->base.value->data.x_enum_tag, &val->data.x_union.tag); |
| 20254 | return &const_instruction->base; | 20253 | return &const_instruction->base; |
| 20255 | } | 20254 | } |
| 20256 | | 20255 | |
| 20257 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); | 20256 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); |
| 20258 | result->value.type = tag_type; | 20257 | result->value->type = tag_type; |
| 20259 | return result; | 20258 | return result; |
| 20260 | } | 20259 | } |
| 20261 | | 20260 | |
| ... | @@ -20263,11 +20262,11 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20263,11 +20262,11 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20263 | IrInstructionSwitchBr *switch_br_instruction) | 20262 | IrInstructionSwitchBr *switch_br_instruction) |
| 20264 | { | 20263 | { |
| 20265 | IrInstruction *target_value = switch_br_instruction->target_value->child; | 20264 | IrInstruction *target_value = switch_br_instruction->target_value->child; |
| 20266 | if (type_is_invalid(target_value->value.type)) | 20265 | if (type_is_invalid(target_value->value->type)) |
| 20267 | return ir_unreach_error(ira); | 20266 | return ir_unreach_error(ira); |
| 20268 | | 20267 | |
| 20269 | if (switch_br_instruction->switch_prongs_void != nullptr) { | 20268 | if (switch_br_instruction->switch_prongs_void != nullptr) { |
| 20270 | if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value.type)) { | 20269 | if (type_is_invalid(switch_br_instruction->switch_prongs_void->child->value->type)) { |
| 20271 | return ir_unreach_error(ira); | 20270 | return ir_unreach_error(ira); |
| 20272 | } | 20271 | } |
| 20273 | } | 20272 | } |
| ... | @@ -20288,17 +20287,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20288,17 +20287,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20288 | for (size_t i = 0; i < case_count; i += 1) { | 20287 | for (size_t i = 0; i < case_count; i += 1) { |
| 20289 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 20288 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 20290 | IrInstruction *case_value = old_case->value->child; | 20289 | IrInstruction *case_value = old_case->value->child; |
| 20291 | if (type_is_invalid(case_value->value.type)) | 20290 | if (type_is_invalid(case_value->value->type)) |
| 20292 | return ir_unreach_error(ira); | 20291 | return ir_unreach_error(ira); |
| 20293 | | 20292 | |
| 20294 | if (case_value->value.type->id == ZigTypeIdEnum) { | 20293 | if (case_value->value->type->id == ZigTypeIdEnum) { |
| 20295 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); | 20294 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); |
| 20296 | if (type_is_invalid(case_value->value.type)) | 20295 | if (type_is_invalid(case_value->value->type)) |
| 20297 | return ir_unreach_error(ira); | 20296 | return ir_unreach_error(ira); |
| 20298 | } | 20297 | } |
| 20299 | | 20298 | |
| 20300 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type); | 20299 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); |
| 20301 | if (type_is_invalid(casted_case_value->value.type)) | 20300 | if (type_is_invalid(casted_case_value->value->type)) |
| 20302 | return ir_unreach_error(ira); | 20301 | return ir_unreach_error(ira); |
| 20303 | | 20302 | |
| 20304 | ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); | 20303 | ZigValue *case_val = ir_resolve_const(ira, casted_case_value, UndefBad); |
| ... | @@ -20318,7 +20317,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20318,7 +20317,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20318 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20317 | IrInstruction *result = ir_build_br(&ira->new_irb, |
| 20319 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 20318 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, |
| 20320 | new_dest_block, nullptr); | 20319 | new_dest_block, nullptr); |
| 20321 | result->value.type = ira->codegen->builtin_types.entry_unreachable; | 20320 | result->value->type = ira->codegen->builtin_types.entry_unreachable; |
| 20322 | return ir_finish_anal(ira, result); | 20321 | return ir_finish_anal(ira, result); |
| 20323 | } | 20322 | } |
| 20324 | } | 20323 | } |
| ... | @@ -20338,17 +20337,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20338,17 +20337,17 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20338 | | 20337 | |
| 20339 | IrInstruction *old_value = old_case->value; | 20338 | IrInstruction *old_value = old_case->value; |
| 20340 | IrInstruction *new_value = old_value->child; | 20339 | IrInstruction *new_value = old_value->child; |
| 20341 | if (type_is_invalid(new_value->value.type)) | 20340 | if (type_is_invalid(new_value->value->type)) |
| 20342 | continue; | 20341 | continue; |
| 20343 | | 20342 | |
| 20344 | if (new_value->value.type->id == ZigTypeIdEnum) { | 20343 | if (new_value->value->type->id == ZigTypeIdEnum) { |
| 20345 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); | 20344 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); |
| 20346 | if (type_is_invalid(new_value->value.type)) | 20345 | if (type_is_invalid(new_value->value->type)) |
| 20347 | continue; | 20346 | continue; |
| 20348 | } | 20347 | } |
| 20349 | | 20348 | |
| 20350 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type); | 20349 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); |
| 20351 | if (type_is_invalid(casted_new_value->value.type)) | 20350 | if (type_is_invalid(casted_new_value->value->type)) |
| 20352 | continue; | 20351 | continue; |
| 20353 | | 20352 | |
| 20354 | if (!ir_resolve_const(ira, casted_new_value, UndefBad)) | 20353 | if (!ir_resolve_const(ira, casted_new_value, UndefBad)) |
| ... | @@ -20368,7 +20367,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -20368,7 +20367,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20368 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, | 20367 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, |
| 20369 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 20368 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, |
| 20370 | target_value, new_else_block, case_count, cases, nullptr, nullptr); | 20369 | target_value, new_else_block, case_count, cases, nullptr, nullptr); |
| 20371 | switch_br->base.value.type = ira->codegen->builtin_types.entry_unreachable; | 20370 | switch_br->base.value->type = ira->codegen->builtin_types.entry_unreachable; |
| 20372 | return ir_finish_anal(ira, &switch_br->base); | 20371 | return ir_finish_anal(ira, &switch_br->base); |
| 20373 | } | 20372 | } |
| 20374 | | 20373 | |
| ... | @@ -20377,20 +20376,20 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20377,20 +20376,20 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20377 | { | 20376 | { |
| 20378 | Error err; | 20377 | Error err; |
| 20379 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; | 20378 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; |
| 20380 | if (type_is_invalid(target_value_ptr->value.type)) | 20379 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20381 | return ira->codegen->invalid_instruction; | 20380 | return ira->codegen->invalid_instruction; |
| 20382 | | 20381 | |
| 20383 | if (target_value_ptr->value.type->id == ZigTypeIdMetaType) { | 20382 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { |
| 20384 | assert(instr_is_comptime(target_value_ptr)); | 20383 | assert(instr_is_comptime(target_value_ptr)); |
| 20385 | ZigType *ptr_type = target_value_ptr->value.data.x_type; | 20384 | ZigType *ptr_type = target_value_ptr->value->data.x_type; |
| 20386 | assert(ptr_type->id == ZigTypeIdPointer); | 20385 | assert(ptr_type->id == ZigTypeIdPointer); |
| 20387 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); | 20386 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); |
| 20388 | } | 20387 | } |
| 20389 | | 20388 | |
| 20390 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20389 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20391 | ZigValue *pointee_val = nullptr; | 20390 | ZigValue *pointee_val = nullptr; |
| 20392 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20391 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20393 | pointee_val = const_ptr_pointee(ira, ira->codegen, &target_value_ptr->value, target_value_ptr->source_node); | 20392 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->source_node); |
| 20394 | if (pointee_val == nullptr) | 20393 | if (pointee_val == nullptr) |
| 20395 | return ira->codegen->invalid_instruction; | 20394 | return ira->codegen->invalid_instruction; |
| 20396 | | 20395 | |
| ... | @@ -20416,13 +20415,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20416,13 +20415,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20416 | case ZigTypeIdErrorSet: { | 20415 | case ZigTypeIdErrorSet: { |
| 20417 | if (pointee_val) { | 20416 | if (pointee_val) { |
| 20418 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); | 20417 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); |
| 20419 | copy_const_val(&result->value, pointee_val, true); | 20418 | copy_const_val(result->value, pointee_val, true); |
| 20420 | result->value.type = target_type; | 20419 | result->value->type = target_type; |
| 20421 | return result; | 20420 | return result; |
| 20422 | } | 20421 | } |
| 20423 | | 20422 | |
| 20424 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20423 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20425 | result->value.type = target_type; | 20424 | result->value->type = target_type; |
| 20426 | return result; | 20425 | return result; |
| 20427 | } | 20426 | } |
| 20428 | case ZigTypeIdUnion: { | 20427 | case ZigTypeIdUnion: { |
| ... | @@ -20441,22 +20440,22 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20441,22 +20440,22 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20441 | assert(tag_type->id == ZigTypeIdEnum); | 20440 | assert(tag_type->id == ZigTypeIdEnum); |
| 20442 | if (pointee_val) { | 20441 | if (pointee_val) { |
| 20443 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 20442 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); |
| 20444 | bigint_init_bigint(&result->value.data.x_enum_tag, &pointee_val->data.x_union.tag); | 20443 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| 20445 | return result; | 20444 | return result; |
| 20446 | } | 20445 | } |
| 20447 | if (tag_type->data.enumeration.src_field_count == 1) { | 20446 | if (tag_type->data.enumeration.src_field_count == 1) { |
| 20448 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 20447 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); |
| 20449 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; | 20448 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; |
| 20450 | bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value); | 20449 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 20451 | return result; | 20450 | return result; |
| 20452 | } | 20451 | } |
| 20453 | | 20452 | |
| 20454 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20453 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20455 | union_value->value.type = target_type; | 20454 | union_value->value->type = target_type; |
| 20456 | | 20455 | |
| 20457 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, | 20456 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, |
| 20458 | switch_target_instruction->base.source_node, union_value); | 20457 | switch_target_instruction->base.source_node, union_value); |
| 20459 | union_tag_inst->value.type = tag_type; | 20458 | union_tag_inst->value->type = tag_type; |
| 20460 | return union_tag_inst; | 20459 | return union_tag_inst; |
| 20461 | } | 20460 | } |
| 20462 | case ZigTypeIdEnum: { | 20461 | case ZigTypeIdEnum: { |
| ... | @@ -20465,18 +20464,18 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20465,18 +20464,18 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20465 | if (target_type->data.enumeration.src_field_count < 2) { | 20464 | if (target_type->data.enumeration.src_field_count < 2) { |
| 20466 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; | 20465 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 20467 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 20466 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); |
| 20468 | bigint_init_bigint(&result->value.data.x_enum_tag, &only_field->value); | 20467 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 20469 | return result; | 20468 | return result; |
| 20470 | } | 20469 | } |
| 20471 | | 20470 | |
| 20472 | if (pointee_val) { | 20471 | if (pointee_val) { |
| 20473 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 20472 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); |
| 20474 | bigint_init_bigint(&result->value.data.x_enum_tag, &pointee_val->data.x_enum_tag); | 20473 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); |
| 20475 | return result; | 20474 | return result; |
| 20476 | } | 20475 | } |
| 20477 | | 20476 | |
| 20478 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 20477 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); |
| 20479 | enum_value->value.type = target_type; | 20478 | enum_value->value->type = target_type; |
| 20480 | return enum_value; | 20479 | return enum_value; |
| 20481 | } | 20480 | } |
| 20482 | case ZigTypeIdErrorUnion: | 20481 | case ZigTypeIdErrorUnion: |
| ... | @@ -20501,12 +20500,12 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -20501,12 +20500,12 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 20501 | | 20500 | |
| 20502 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { | 20501 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { |
| 20503 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 20502 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; |
| 20504 | if (type_is_invalid(target_value_ptr->value.type)) | 20503 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20505 | return ira->codegen->invalid_instruction; | 20504 | return ira->codegen->invalid_instruction; |
| 20506 | | 20505 | |
| 20507 | ZigType *ref_type = target_value_ptr->value.type; | 20506 | ZigType *ref_type = target_value_ptr->value->type; |
| 20508 | assert(ref_type->id == ZigTypeIdPointer); | 20507 | assert(ref_type->id == ZigTypeIdPointer); |
| 20509 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20508 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20510 | if (target_type->id == ZigTypeIdUnion) { | 20509 | if (target_type->id == ZigTypeIdUnion) { |
| 20511 | ZigType *enum_type = target_type->data.unionation.tag_type; | 20510 | ZigType *enum_type = target_type->data.unionation.tag_type; |
| 20512 | assert(enum_type != nullptr); | 20511 | assert(enum_type != nullptr); |
| ... | @@ -20514,11 +20513,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20514,11 +20513,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20514 | assert(instruction->prongs_len > 0); | 20513 | assert(instruction->prongs_len > 0); |
| 20515 | | 20514 | |
| 20516 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; | 20515 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; |
| 20517 | if (type_is_invalid(first_prong_value->value.type)) | 20516 | if (type_is_invalid(first_prong_value->value->type)) |
| 20518 | return ira->codegen->invalid_instruction; | 20517 | return ira->codegen->invalid_instruction; |
| 20519 | | 20518 | |
| 20520 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | 20519 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); |
| 20521 | if (type_is_invalid(first_casted_prong_value->value.type)) | 20520 | if (type_is_invalid(first_casted_prong_value->value->type)) |
| 20522 | return ira->codegen->invalid_instruction; | 20521 | return ira->codegen->invalid_instruction; |
| 20523 | | 20522 | |
| 20524 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); | 20523 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); |
| ... | @@ -20530,11 +20529,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20530,11 +20529,11 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20530 | ErrorMsg *invalid_payload_msg = nullptr; | 20529 | ErrorMsg *invalid_payload_msg = nullptr; |
| 20531 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { | 20530 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { |
| 20532 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | 20531 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; |
| 20533 | if (type_is_invalid(this_prong_inst->value.type)) | 20532 | if (type_is_invalid(this_prong_inst->value->type)) |
| 20534 | return ira->codegen->invalid_instruction; | 20533 | return ira->codegen->invalid_instruction; |
| 20535 | | 20534 | |
| 20536 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | 20535 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); |
| 20537 | if (type_is_invalid(this_casted_prong_value->value.type)) | 20536 | if (type_is_invalid(this_casted_prong_value->value->type)) |
| 20538 | return ira->codegen->invalid_instruction; | 20537 | return ira->codegen->invalid_instruction; |
| 20539 | | 20538 | |
| 20540 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); | 20539 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); |
| ... | @@ -20571,7 +20570,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20571,7 +20570,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20571 | IrInstruction *result = ir_const(ira, &instruction->base, | 20570 | IrInstruction *result = ir_const(ira, &instruction->base, |
| 20572 | get_pointer_to_type(ira->codegen, first_field->type_entry, | 20571 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 20573 | target_val_ptr->type->data.pointer.is_const)); | 20572 | target_val_ptr->type->data.pointer.is_const)); |
| 20574 | ZigValue *out_val = &result->value; | 20573 | ZigValue *out_val = result->value; |
| 20575 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 20574 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 20576 | out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut; | 20575 | out_val->data.x_ptr.mut = target_val_ptr->data.x_ptr.mut; |
| 20577 | out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload; | 20576 | out_val->data.x_ptr.data.ref.pointee = pointee_val->data.x_union.payload; |
| ... | @@ -20580,8 +20579,8 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -20580,8 +20579,8 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20580 | | 20579 | |
| 20581 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, | 20580 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, |
| 20582 | instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false); | 20581 | instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false); |
| 20583 | result->value.type = get_pointer_to_type(ira->codegen, first_field->type_entry, | 20582 | result->value->type = get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 20584 | target_value_ptr->value.type->data.pointer.is_const); | 20583 | target_value_ptr->value->type->data.pointer.is_const); |
| 20585 | return result; | 20584 | return result; |
| 20586 | } else if (target_type->id == ZigTypeIdErrorSet) { | 20585 | } else if (target_type->id == ZigTypeIdErrorSet) { |
| 20587 | // construct an error set from the prong values | 20586 | // construct an error set from the prong values |
| ... | @@ -20624,12 +20623,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -20624,12 +20623,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 20624 | IrInstructionSwitchElseVar *instruction) | 20623 | IrInstructionSwitchElseVar *instruction) |
| 20625 | { | 20624 | { |
| 20626 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 20625 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; |
| 20627 | if (type_is_invalid(target_value_ptr->value.type)) | 20626 | if (type_is_invalid(target_value_ptr->value->type)) |
| 20628 | return ira->codegen->invalid_instruction; | 20627 | return ira->codegen->invalid_instruction; |
| 20629 | | 20628 | |
| 20630 | ZigType *ref_type = target_value_ptr->value.type; | 20629 | ZigType *ref_type = target_value_ptr->value->type; |
| 20631 | assert(ref_type->id == ZigTypeIdPointer); | 20630 | assert(ref_type->id == ZigTypeIdPointer); |
| 20632 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 20631 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 20633 | if (target_type->id == ZigTypeIdErrorSet) { | 20632 | if (target_type->id == ZigTypeIdErrorSet) { |
| 20634 | // make a new set that has the other cases removed | 20633 | // make a new set that has the other cases removed |
| 20635 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { | 20634 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { |
| ... | @@ -20645,12 +20644,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -20645,12 +20644,12 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 20645 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { | 20644 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { |
| 20646 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | 20645 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; |
| 20647 | IrInstruction *case_expr = br_case->value->child; | 20646 | IrInstruction *case_expr = br_case->value->child; |
| 20648 | if (case_expr->value.type->id == ZigTypeIdErrorSet) { | 20647 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { |
| 20649 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); | 20648 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); |
| 20650 | if (err == nullptr) | 20649 | if (err == nullptr) |
| 20651 | return ira->codegen->invalid_instruction; | 20650 | return ira->codegen->invalid_instruction; |
| 20652 | errors[err->value] = err; | 20651 | errors[err->value] = err; |
| 20653 | } else if (case_expr->value.type->id == ZigTypeIdMetaType) { | 20652 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { |
| 20654 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); | 20653 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); |
| 20655 | if (type_is_invalid(err_set_type)) | 20654 | if (type_is_invalid(err_set_type)) |
| 20656 | return ira->codegen->invalid_instruction; | 20655 | return ira->codegen->invalid_instruction; |
| ... | @@ -20742,7 +20741,7 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio | ... | @@ -20742,7 +20741,7 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio |
| 20742 | | 20741 | |
| 20743 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { | 20742 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { |
| 20744 | IrInstruction *value = ref_instruction->value->child; | 20743 | IrInstruction *value = ref_instruction->value->child; |
| 20745 | if (type_is_invalid(value->value.type)) | 20744 | if (type_is_invalid(value->value->type)) |
| 20746 | return ira->codegen->invalid_instruction; | 20745 | return ira->codegen->invalid_instruction; |
| 20747 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); | 20746 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); |
| 20748 | } | 20747 | } |
| ... | @@ -20768,13 +20767,13 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -20768,13 +20767,13 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc |
| 20768 | if (type_is_invalid(type_field->type_entry)) | 20767 | if (type_is_invalid(type_field->type_entry)) |
| 20769 | return ira->codegen->invalid_instruction; | 20768 | return ira->codegen->invalid_instruction; |
| 20770 | | 20769 | |
| 20771 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 20770 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20772 | if (instr_is_comptime(field_result_loc) && | 20771 | if (instr_is_comptime(field_result_loc) && |
| 20773 | field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 20772 | field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 20774 | { | 20773 | { |
| 20775 | // nothing | 20774 | // nothing |
| 20776 | } else { | 20775 | } else { |
| 20777 | result_loc->value.special = ConstValSpecialRuntime; | 20776 | result_loc->value->special = ConstValSpecialRuntime; |
| 20778 | } | 20777 | } |
| 20779 | } | 20778 | } |
| 20780 | | 20779 | |
| ... | @@ -20803,7 +20802,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20803,7 +20802,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20803 | } | 20802 | } |
| 20804 | IrInstructionContainerInitFieldsField *field = &fields[0]; | 20803 | IrInstructionContainerInitFieldsField *field = &fields[0]; |
| 20805 | IrInstruction *field_result_loc = field->result_loc->child; | 20804 | IrInstruction *field_result_loc = field->result_loc->child; |
| 20806 | if (type_is_invalid(field_result_loc->value.type)) | 20805 | if (type_is_invalid(field_result_loc->value->type)) |
| 20807 | return ira->codegen->invalid_instruction; | 20806 | return ira->codegen->invalid_instruction; |
| 20808 | | 20807 | |
| 20809 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, | 20808 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, |
| ... | @@ -20850,7 +20849,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20850,7 +20849,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20850 | IrInstructionContainerInitFieldsField *field = &fields[i]; | 20849 | IrInstructionContainerInitFieldsField *field = &fields[i]; |
| 20851 | | 20850 | |
| 20852 | IrInstruction *field_result_loc = field->result_loc->child; | 20851 | IrInstruction *field_result_loc = field->result_loc->child; |
| 20853 | if (type_is_invalid(field_result_loc->value.type)) | 20852 | if (type_is_invalid(field_result_loc->value->type)) |
| 20854 | return ira->codegen->invalid_instruction; | 20853 | return ira->codegen->invalid_instruction; |
| 20855 | | 20854 | |
| 20856 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); | 20855 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); |
| ... | @@ -20874,7 +20873,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20874,7 +20873,7 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20874 | field_assign_nodes[field_index] = field->source_node; | 20873 | field_assign_nodes[field_index] = field->source_node; |
| 20875 | | 20874 | |
| 20876 | if (instr_is_comptime(field_result_loc) && | 20875 | if (instr_is_comptime(field_result_loc) && |
| 20877 | field_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 20876 | field_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 20878 | { | 20877 | { |
| 20879 | const_ptrs.append(field_result_loc); | 20878 | const_ptrs.append(field_result_loc); |
| 20880 | } else { | 20879 | } else { |
| ... | @@ -20912,12 +20911,12 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20912,12 +20911,12 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20912 | return ira->codegen->invalid_instruction; | 20911 | return ira->codegen->invalid_instruction; |
| 20913 | | 20912 | |
| 20914 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); | 20913 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); |
| 20915 | copy_const_val(&runtime_inst->value, field->init_val, true); | 20914 | copy_const_val(runtime_inst->value, field->init_val, true); |
| 20916 | | 20915 | |
| 20917 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, | 20916 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, |
| 20918 | container_type, true); | 20917 | container_type, true); |
| 20919 | ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false); | 20918 | ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false); |
| 20920 | if (instr_is_comptime(field_ptr) && field_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 20919 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 20921 | const_ptrs.append(field_ptr); | 20920 | const_ptrs.append(field_ptr); |
| 20922 | } else { | 20921 | } else { |
| 20923 | first_non_const_instruction = result_loc; | 20922 | first_non_const_instruction = result_loc; |
| ... | @@ -20926,13 +20925,13 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -20926,13 +20925,13 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 20926 | if (any_missing) | 20925 | if (any_missing) |
| 20927 | return ira->codegen->invalid_instruction; | 20926 | return ira->codegen->invalid_instruction; |
| 20928 | | 20927 | |
| 20929 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 20928 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20930 | if (const_ptrs.length != actual_field_count) { | 20929 | if (const_ptrs.length != actual_field_count) { |
| 20931 | result_loc->value.special = ConstValSpecialRuntime; | 20930 | result_loc->value->special = ConstValSpecialRuntime; |
| 20932 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 20931 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 20933 | IrInstruction *field_result_loc = const_ptrs.at(i); | 20932 | IrInstruction *field_result_loc = const_ptrs.at(i); |
| 20934 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); | 20933 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); |
| 20935 | field_result_loc->value.special = ConstValSpecialRuntime; | 20934 | field_result_loc->value->special = ConstValSpecialRuntime; |
| 20936 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); | 20935 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); |
| 20937 | } | 20936 | } |
| 20938 | } | 20937 | } |
| ... | @@ -20954,11 +20953,11 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -20954,11 +20953,11 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 20954 | { | 20953 | { |
| 20955 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 20954 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 20956 | IrInstruction *result_loc = instruction->result_loc->child; | 20955 | IrInstruction *result_loc = instruction->result_loc->child; |
| 20957 | if (type_is_invalid(result_loc->value.type)) | 20956 | if (type_is_invalid(result_loc->value->type)) |
| 20958 | return result_loc; | 20957 | return result_loc; |
| 20959 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base); | 20958 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); |
| 20960 | | 20959 | |
| 20961 | ZigType *container_type = result_loc->value.type->data.pointer.child_type; | 20960 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 20962 | | 20961 | |
| 20963 | size_t elem_count = instruction->item_count; | 20962 | size_t elem_count = instruction->item_count; |
| 20964 | | 20963 | |
| ... | @@ -20980,7 +20979,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -20980,7 +20979,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 20980 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { | 20979 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { |
| 20981 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 20980 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 20982 | IrInstruction *result_loc = instruction->result_loc->child; | 20981 | IrInstruction *result_loc = instruction->result_loc->child; |
| 20983 | if (type_is_invalid(result_loc->value.type)) | 20982 | if (type_is_invalid(result_loc->value->type)) |
| 20984 | return result_loc; | 20983 | return result_loc; |
| 20985 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); | 20984 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); |
| 20986 | } | 20985 | } |
| ... | @@ -21041,13 +21040,13 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21041,13 +21040,13 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21041 | | 21040 | |
| 21042 | for (size_t i = 0; i < elem_count; i += 1) { | 21041 | for (size_t i = 0; i < elem_count; i += 1) { |
| 21043 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; | 21042 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; |
| 21044 | if (type_is_invalid(elem_result_loc->value.type)) | 21043 | if (type_is_invalid(elem_result_loc->value->type)) |
| 21045 | return ira->codegen->invalid_instruction; | 21044 | return ira->codegen->invalid_instruction; |
| 21046 | | 21045 | |
| 21047 | assert(elem_result_loc->value.type->id == ZigTypeIdPointer); | 21046 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); |
| 21048 | | 21047 | |
| 21049 | if (instr_is_comptime(elem_result_loc) && | 21048 | if (instr_is_comptime(elem_result_loc) && |
| 21050 | elem_result_loc->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 21049 | elem_result_loc->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 21051 | { | 21050 | { |
| 21052 | const_ptrs.append(elem_result_loc); | 21051 | const_ptrs.append(elem_result_loc); |
| 21053 | } else { | 21052 | } else { |
| ... | @@ -21055,14 +21054,14 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21055,14 +21054,14 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21055 | } | 21054 | } |
| 21056 | } | 21055 | } |
| 21057 | | 21056 | |
| 21058 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer) { | 21057 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21059 | if (const_ptrs.length != elem_count) { | 21058 | if (const_ptrs.length != elem_count) { |
| 21060 | result_loc->value.special = ConstValSpecialRuntime; | 21059 | result_loc->value->special = ConstValSpecialRuntime; |
| 21061 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 21060 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 21062 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 21061 | IrInstruction *elem_result_loc = const_ptrs.at(i); |
| 21063 | assert(elem_result_loc->value.special == ConstValSpecialStatic); | 21062 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 21064 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 21063 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); |
| 21065 | elem_result_loc->value.special = ConstValSpecialRuntime; | 21064 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 21066 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 21065 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); |
| 21067 | } | 21066 | } |
| 21068 | } | 21067 | } |
| ... | @@ -21078,7 +21077,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -21078,7 +21077,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 21078 | return ira->codegen->invalid_instruction; | 21077 | return ira->codegen->invalid_instruction; |
| 21079 | } | 21078 | } |
| 21080 | | 21079 | |
| 21081 | ZigType *result_elem_type = result_loc->value.type->data.pointer.child_type; | 21080 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; |
| 21082 | if (is_slice(result_elem_type)) { | 21081 | if (is_slice(result_elem_type)) { |
| 21083 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 21082 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 21084 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", | 21083 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", |
| ... | @@ -21095,11 +21094,11 @@ static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ir | ... | @@ -21095,11 +21094,11 @@ static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ir |
| 21095 | { | 21094 | { |
| 21096 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 21095 | ir_assert(instruction->result_loc != nullptr, &instruction->base); |
| 21097 | IrInstruction *result_loc = instruction->result_loc->child; | 21096 | IrInstruction *result_loc = instruction->result_loc->child; |
| 21098 | if (type_is_invalid(result_loc->value.type)) | 21097 | if (type_is_invalid(result_loc->value->type)) |
| 21099 | return result_loc; | 21098 | return result_loc; |
| 21100 | | 21099 | |
| 21101 | ir_assert(result_loc->value.type->id == ZigTypeIdPointer, &instruction->base); | 21100 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); |
| 21102 | ZigType *container_type = result_loc->value.type->data.pointer.child_type; | 21101 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 21103 | | 21102 | |
| 21104 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 21103 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 21105 | instruction->field_count, instruction->fields, result_loc); | 21104 | instruction->field_count, instruction->fields, result_loc); |
| ... | @@ -21123,15 +21122,15 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -21123,15 +21122,15 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 21123 | fprintf(stderr, "| "); | 21122 | fprintf(stderr, "| "); |
| 21124 | for (size_t i = 0; i < instruction->msg_count; i += 1) { | 21123 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 21125 | IrInstruction *msg = instruction->msg_list[i]->child; | 21124 | IrInstruction *msg = instruction->msg_list[i]->child; |
| 21126 | if (type_is_invalid(msg->value.type)) | 21125 | if (type_is_invalid(msg->value->type)) |
| 21127 | return ira->codegen->invalid_instruction; | 21126 | return ira->codegen->invalid_instruction; |
| 21128 | buf_resize(&buf, 0); | 21127 | buf_resize(&buf, 0); |
| 21129 | if (msg->value.special == ConstValSpecialLazy) { | 21128 | if (msg->value->special == ConstValSpecialLazy) { |
| 21130 | // Resolve any lazy value that's passed, we need its value | 21129 | // Resolve any lazy value that's passed, we need its value |
| 21131 | if (ir_resolve_lazy(ira->codegen, msg->source_node, &msg->value)) | 21130 | if (ir_resolve_lazy(ira->codegen, msg->source_node, msg->value)) |
| 21132 | return ira->codegen->invalid_instruction; | 21131 | return ira->codegen->invalid_instruction; |
| 21133 | } | 21132 | } |
| 21134 | render_const_value(ira->codegen, &buf, &msg->value); | 21133 | render_const_value(ira->codegen, &buf, msg->value); |
| 21135 | const char *comma_str = (i != 0) ? ", " : ""; | 21134 | const char *comma_str = (i != 0) ? ", " : ""; |
| 21136 | fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf)); | 21135 | fprintf(stderr, "%s%s", comma_str, buf_ptr(&buf)); |
| 21137 | } | 21136 | } |
| ... | @@ -21150,11 +21149,11 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -21150,11 +21149,11 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 21150 | | 21149 | |
| 21151 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { | 21150 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { |
| 21152 | IrInstruction *value = instruction->value->child; | 21151 | IrInstruction *value = instruction->value->child; |
| 21153 | if (type_is_invalid(value->value.type)) | 21152 | if (type_is_invalid(value->value->type)) |
| 21154 | return ira->codegen->invalid_instruction; | 21153 | return ira->codegen->invalid_instruction; |
| 21155 | | 21154 | |
| 21156 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | 21155 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); |
| 21157 | if (type_is_invalid(casted_value->value.type)) | 21156 | if (type_is_invalid(casted_value->value->type)) |
| 21158 | return ira->codegen->invalid_instruction; | 21157 | return ira->codegen->invalid_instruction; |
| 21159 | | 21158 | |
| 21160 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 21159 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| ... | @@ -21164,14 +21163,14 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -21164,14 +21163,14 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 21164 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 21163 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 21165 | if (val == nullptr) | 21164 | if (val == nullptr) |
| 21166 | return ira->codegen->invalid_instruction; | 21165 | return ira->codegen->invalid_instruction; |
| 21167 | ErrorTableEntry *err = casted_value->value.data.x_err_set; | 21166 | ErrorTableEntry *err = casted_value->value->data.x_err_set; |
| 21168 | if (!err->cached_error_name_val) { | 21167 | if (!err->cached_error_name_val) { |
| 21169 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 21168 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; |
| 21170 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 21169 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 21171 | } | 21170 | } |
| 21172 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 21171 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 21173 | copy_const_val(&result->value, err->cached_error_name_val, true); | 21172 | copy_const_val(result->value, err->cached_error_name_val, true); |
| 21174 | result->value.type = str_type; | 21173 | result->value->type = str_type; |
| 21175 | return result; | 21174 | return result; |
| 21176 | } | 21175 | } |
| 21177 | | 21176 | |
| ... | @@ -21179,25 +21178,25 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -21179,25 +21178,25 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 21179 | | 21178 | |
| 21180 | IrInstruction *result = ir_build_err_name(&ira->new_irb, | 21179 | IrInstruction *result = ir_build_err_name(&ira->new_irb, |
| 21181 | instruction->base.scope, instruction->base.source_node, value); | 21180 | instruction->base.scope, instruction->base.source_node, value); |
| 21182 | result->value.type = str_type; | 21181 | result->value->type = str_type; |
| 21183 | return result; | 21182 | return result; |
| 21184 | } | 21183 | } |
| 21185 | | 21184 | |
| 21186 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { | 21185 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { |
| 21187 | Error err; | 21186 | Error err; |
| 21188 | IrInstruction *target = instruction->target->child; | 21187 | IrInstruction *target = instruction->target->child; |
| 21189 | if (type_is_invalid(target->value.type)) | 21188 | if (type_is_invalid(target->value->type)) |
| 21190 | return ira->codegen->invalid_instruction; | 21189 | return ira->codegen->invalid_instruction; |
| 21191 | | 21190 | |
| 21192 | assert(target->value.type->id == ZigTypeIdEnum); | 21191 | assert(target->value->type->id == ZigTypeIdEnum); |
| 21193 | | 21192 | |
| 21194 | if (instr_is_comptime(target)) { | 21193 | if (instr_is_comptime(target)) { |
| 21195 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) | 21194 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 21196 | return ira->codegen->invalid_instruction; | 21195 | return ira->codegen->invalid_instruction; |
| 21197 | TypeEnumField *field = find_enum_field_by_tag(target->value.type, &target->value.data.x_bigint); | 21196 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); |
| 21198 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; | 21197 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; |
| 21199 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 21198 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 21200 | init_const_slice(ira->codegen, &result->value, array_val, 0, buf_len(field->name), true); | 21199 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); |
| 21201 | return result; | 21200 | return result; |
| 21202 | } | 21201 | } |
| 21203 | | 21202 | |
| ... | @@ -21207,7 +21206,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -21207,7 +21206,7 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 21207 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 21206 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 21208 | true, false, PtrLenUnknown, | 21207 | true, false, PtrLenUnknown, |
| 21209 | 0, 0, 0, false); | 21208 | 0, 0, 0, false); |
| 21210 | result->value.type = get_slice_type(ira->codegen, u8_ptr_type); | 21209 | result->value->type = get_slice_type(ira->codegen, u8_ptr_type); |
| 21211 | return result; | 21210 | return result; |
| 21212 | } | 21211 | } |
| 21213 | | 21212 | |
| ... | @@ -21226,7 +21225,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21226,7 +21225,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21226 | return ira->codegen->invalid_instruction; | 21225 | return ira->codegen->invalid_instruction; |
| 21227 | | 21226 | |
| 21228 | IrInstruction *field_ptr = instruction->field_ptr->child; | 21227 | IrInstruction *field_ptr = instruction->field_ptr->child; |
| 21229 | if (type_is_invalid(field_ptr->value.type)) | 21228 | if (type_is_invalid(field_ptr->value->type)) |
| 21230 | return ira->codegen->invalid_instruction; | 21229 | return ira->codegen->invalid_instruction; |
| 21231 | | 21230 | |
| 21232 | if (container_type->id != ZigTypeIdStruct) { | 21231 | if (container_type->id != ZigTypeIdStruct) { |
| ... | @@ -21246,9 +21245,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21246,9 +21245,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21246 | return ira->codegen->invalid_instruction; | 21245 | return ira->codegen->invalid_instruction; |
| 21247 | } | 21246 | } |
| 21248 | | 21247 | |
| 21249 | if (field_ptr->value.type->id != ZigTypeIdPointer) { | 21248 | if (field_ptr->value->type->id != ZigTypeIdPointer) { |
| 21250 | ir_add_error(ira, field_ptr, | 21249 | ir_add_error(ira, field_ptr, |
| 21251 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); | 21250 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); |
| 21252 | return ira->codegen->invalid_instruction; | 21251 | return ira->codegen->invalid_instruction; |
| 21253 | } | 21252 | } |
| 21254 | | 21253 | |
| ... | @@ -21257,17 +21256,17 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21257,17 +21256,17 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21257 | uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type); | 21256 | uint32_t parent_ptr_align = is_packed ? 1 : get_abi_alignment(ira->codegen, container_type); |
| 21258 | | 21257 | |
| 21259 | ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry, | 21258 | ZigType *field_ptr_type = get_pointer_to_type_extra(ira->codegen, field->type_entry, |
| 21260 | field_ptr->value.type->data.pointer.is_const, | 21259 | field_ptr->value->type->data.pointer.is_const, |
| 21261 | field_ptr->value.type->data.pointer.is_volatile, | 21260 | field_ptr->value->type->data.pointer.is_volatile, |
| 21262 | PtrLenSingle, | 21261 | PtrLenSingle, |
| 21263 | field_ptr_align, 0, 0, false); | 21262 | field_ptr_align, 0, 0, false); |
| 21264 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | 21263 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); |
| 21265 | if (type_is_invalid(casted_field_ptr->value.type)) | 21264 | if (type_is_invalid(casted_field_ptr->value->type)) |
| 21266 | return ira->codegen->invalid_instruction; | 21265 | return ira->codegen->invalid_instruction; |
| 21267 | | 21266 | |
| 21268 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, | 21267 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, |
| 21269 | casted_field_ptr->value.type->data.pointer.is_const, | 21268 | casted_field_ptr->value->type->data.pointer.is_const, |
| 21270 | casted_field_ptr->value.type->data.pointer.is_volatile, | 21269 | casted_field_ptr->value->type->data.pointer.is_volatile, |
| 21271 | PtrLenSingle, | 21270 | PtrLenSingle, |
| 21272 | parent_ptr_align, 0, 0, false); | 21271 | parent_ptr_align, 0, 0, false); |
| 21273 | | 21272 | |
| ... | @@ -21291,7 +21290,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21291,7 +21290,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21291 | } | 21290 | } |
| 21292 | | 21291 | |
| 21293 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 21292 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 21294 | ZigValue *out_val = &result->value; | 21293 | ZigValue *out_val = result->value; |
| 21295 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 21294 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 21296 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; | 21295 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; |
| 21297 | out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut; | 21296 | out_val->data.x_ptr.mut = field_ptr_val->data.x_ptr.mut; |
| ... | @@ -21300,7 +21299,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -21300,7 +21299,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21300 | | 21299 | |
| 21301 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, | 21300 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, |
| 21302 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); | 21301 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); |
| 21303 | result->value.type = result_type; | 21302 | result->value->type = result_type; |
| 21304 | return result; | 21303 | return result; |
| 21305 | } | 21304 | } |
| 21306 | | 21305 | |
| ... | @@ -21350,7 +21349,7 @@ static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, | ... | @@ -21350,7 +21349,7 @@ static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, |
| 21350 | IrInstructionByteOffsetOf *instruction) | 21349 | IrInstructionByteOffsetOf *instruction) |
| 21351 | { | 21350 | { |
| 21352 | IrInstruction *type_value = instruction->type_value->child; | 21351 | IrInstruction *type_value = instruction->type_value->child; |
| 21353 | if (type_is_invalid(type_value->value.type)) | 21352 | if (type_is_invalid(type_value->value->type)) |
| 21354 | return ira->codegen->invalid_instruction; | 21353 | return ira->codegen->invalid_instruction; |
| 21355 | | 21354 | |
| 21356 | IrInstruction *field_name_value = instruction->field_name->child; | 21355 | IrInstruction *field_name_value = instruction->field_name->child; |
| ... | @@ -21366,7 +21365,7 @@ static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, | ... | @@ -21366,7 +21365,7 @@ static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, |
| 21366 | IrInstructionBitOffsetOf *instruction) | 21365 | IrInstructionBitOffsetOf *instruction) |
| 21367 | { | 21366 | { |
| 21368 | IrInstruction *type_value = instruction->type_value->child; | 21367 | IrInstruction *type_value = instruction->type_value->child; |
| 21369 | if (type_is_invalid(type_value->value.type)) | 21368 | if (type_is_invalid(type_value->value->type)) |
| 21370 | return ira->codegen->invalid_instruction; | 21369 | return ira->codegen->invalid_instruction; |
| 21371 | IrInstruction *field_name_value = instruction->field_name->child; | 21370 | IrInstruction *field_name_value = instruction->field_name->child; |
| 21372 | size_t byte_offset = 0; | 21371 | size_t byte_offset = 0; |
| ... | @@ -22381,7 +22380,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -22381,7 +22380,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 22381 | return ira->codegen->invalid_instruction; | 22380 | return ira->codegen->invalid_instruction; |
| 22382 | | 22381 | |
| 22383 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22382 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22384 | ZigValue *out_val = &result->value; | 22383 | ZigValue *out_val = result->value; |
| 22385 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); | 22384 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 22386 | out_val->data.x_union.payload = payload; | 22385 | out_val->data.x_union.payload = payload; |
| 22387 | | 22386 | |
| ... | @@ -22407,10 +22406,10 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -22407,10 +22406,10 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst |
| 22407 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); | 22406 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); |
| 22408 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, | 22407 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 22409 | get_optional_type(ira->codegen, elem_type)); | 22408 | get_optional_type(ira->codegen, elem_type)); |
| 22410 | if (type_is_invalid(casted_field_inst->value.type)) | 22409 | if (type_is_invalid(casted_field_inst->value->type)) |
| 22411 | return ErrorSemanticAnalyzeFail; | 22410 | return ErrorSemanticAnalyzeFail; |
| 22412 | | 22411 | |
| 22413 | *result = casted_field_inst->value.data.x_optional; | 22412 | *result = casted_field_inst->value->data.x_optional; |
| 22414 | return ErrorNone; | 22413 | return ErrorNone; |
| 22415 | } | 22414 | } |
| 22416 | | 22415 | |
| ... | @@ -22549,11 +22548,11 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -22549,11 +22548,11 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 22549 | | 22548 | |
| 22550 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { | 22549 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { |
| 22551 | IrInstruction *type_info_ir = instruction->type_info->child; | 22550 | IrInstruction *type_info_ir = instruction->type_info->child; |
| 22552 | if (type_is_invalid(type_info_ir->value.type)) | 22551 | if (type_is_invalid(type_info_ir->value->type)) |
| 22553 | return ira->codegen->invalid_instruction; | 22552 | return ira->codegen->invalid_instruction; |
| 22554 | | 22553 | |
| 22555 | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); | 22554 | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); |
| 22556 | if (type_is_invalid(casted_ir->value.type)) | 22555 | if (type_is_invalid(casted_ir->value->type)) |
| 22557 | return ira->codegen->invalid_instruction; | 22556 | return ira->codegen->invalid_instruction; |
| 22558 | | 22557 | |
| 22559 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); | 22558 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); |
| ... | @@ -22579,7 +22578,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -22579,7 +22578,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 22579 | ZigType *result_type = var_value->data.x_type; | 22578 | ZigType *result_type = var_value->data.x_type; |
| 22580 | | 22579 | |
| 22581 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22580 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22582 | bigint_init_unsigned(&result->value.data.x_enum_tag, type_id_index(type_entry)); | 22581 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); |
| 22583 | return result; | 22582 | return result; |
| 22584 | } | 22583 | } |
| 22585 | | 22584 | |
| ... | @@ -22607,7 +22606,7 @@ static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstruc | ... | @@ -22607,7 +22606,7 @@ static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstruc |
| 22607 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); | 22606 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 22608 | } | 22607 | } |
| 22609 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 22608 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 22610 | copy_const_val(&result->value, type_entry->cached_const_name_val, true); | 22609 | copy_const_val(result->value, type_entry->cached_const_name_val, true); |
| 22611 | return result; | 22610 | return result; |
| 22612 | } | 22611 | } |
| 22613 | | 22612 | |
| ... | @@ -22796,7 +22795,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -22796,7 +22795,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 22796 | | 22795 | |
| 22797 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { | 22796 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { |
| 22798 | IrInstruction *name_value = instruction->name->child; | 22797 | IrInstruction *name_value = instruction->name->child; |
| 22799 | if (type_is_invalid(name_value->value.type)) | 22798 | if (type_is_invalid(name_value->value->type)) |
| 22800 | return ira->codegen->invalid_instruction; | 22799 | return ira->codegen->invalid_instruction; |
| 22801 | | 22800 | |
| 22802 | Buf *include_name = ir_resolve_str(ira, name_value); | 22801 | Buf *include_name = ir_resolve_str(ira, name_value); |
| ... | @@ -22814,7 +22813,7 @@ static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstruc | ... | @@ -22814,7 +22813,7 @@ static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstruc |
| 22814 | | 22813 | |
| 22815 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { | 22814 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { |
| 22816 | IrInstruction *name = instruction->name->child; | 22815 | IrInstruction *name = instruction->name->child; |
| 22817 | if (type_is_invalid(name->value.type)) | 22816 | if (type_is_invalid(name->value->type)) |
| 22818 | return ira->codegen->invalid_instruction; | 22817 | return ira->codegen->invalid_instruction; |
| 22819 | | 22818 | |
| 22820 | Buf *define_name = ir_resolve_str(ira, name); | 22819 | Buf *define_name = ir_resolve_str(ira, name); |
| ... | @@ -22822,12 +22821,12 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct | ... | @@ -22822,12 +22821,12 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct |
| 22822 | return ira->codegen->invalid_instruction; | 22821 | return ira->codegen->invalid_instruction; |
| 22823 | | 22822 | |
| 22824 | IrInstruction *value = instruction->value->child; | 22823 | IrInstruction *value = instruction->value->child; |
| 22825 | if (type_is_invalid(value->value.type)) | 22824 | if (type_is_invalid(value->value->type)) |
| 22826 | return ira->codegen->invalid_instruction; | 22825 | return ira->codegen->invalid_instruction; |
| 22827 | | 22826 | |
| 22828 | Buf *define_value = nullptr; | 22827 | Buf *define_value = nullptr; |
| 22829 | // The second parameter is either a string or void (equivalent to "") | 22828 | // The second parameter is either a string or void (equivalent to "") |
| 22830 | if (value->value.type->id != ZigTypeIdVoid) { | 22829 | if (value->value->type->id != ZigTypeIdVoid) { |
| 22831 | define_value = ir_resolve_str(ira, value); | 22830 | define_value = ir_resolve_str(ira, value); |
| 22832 | if (!define_value) | 22831 | if (!define_value) |
| 22833 | return ira->codegen->invalid_instruction; | 22832 | return ira->codegen->invalid_instruction; |
| ... | @@ -22845,7 +22844,7 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct | ... | @@ -22845,7 +22844,7 @@ static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruct |
| 22845 | | 22844 | |
| 22846 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { | 22845 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { |
| 22847 | IrInstruction *name = instruction->name->child; | 22846 | IrInstruction *name = instruction->name->child; |
| 22848 | if (type_is_invalid(name->value.type)) | 22847 | if (type_is_invalid(name->value->type)) |
| 22849 | return ira->codegen->invalid_instruction; | 22848 | return ira->codegen->invalid_instruction; |
| 22850 | | 22849 | |
| 22851 | Buf *undef_name = ir_resolve_str(ira, name); | 22850 | Buf *undef_name = ir_resolve_str(ira, name); |
| ... | @@ -22863,7 +22862,7 @@ static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructi | ... | @@ -22863,7 +22862,7 @@ static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructi |
| 22863 | | 22862 | |
| 22864 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { | 22863 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { |
| 22865 | IrInstruction *name = instruction->name->child; | 22864 | IrInstruction *name = instruction->name->child; |
| 22866 | if (type_is_invalid(name->value.type)) | 22865 | if (type_is_invalid(name->value->type)) |
| 22867 | return ira->codegen->invalid_instruction; | 22866 | return ira->codegen->invalid_instruction; |
| 22868 | | 22867 | |
| 22869 | Buf *rel_file_path = ir_resolve_str(ira, name); | 22868 | Buf *rel_file_path = ir_resolve_str(ira, name); |
| ... | @@ -22898,7 +22897,7 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru | ... | @@ -22898,7 +22897,7 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru |
| 22898 | ZigType *result_type = get_array_type(ira->codegen, | 22897 | ZigType *result_type = get_array_type(ira->codegen, |
| 22899 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); | 22898 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); |
| 22900 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 22899 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); |
| 22901 | init_const_str_lit(ira->codegen, &result->value, file_contents); | 22900 | init_const_str_lit(ira->codegen, result->value, file_contents); |
| 22902 | return result; | 22901 | return result; |
| 22903 | } | 22902 | } |
| 22904 | | 22903 | |
| ... | @@ -22908,25 +22907,25 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22908,25 +22907,25 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22908 | return ira->codegen->invalid_instruction; | 22907 | return ira->codegen->invalid_instruction; |
| 22909 | | 22908 | |
| 22910 | IrInstruction *ptr = instruction->ptr->child; | 22909 | IrInstruction *ptr = instruction->ptr->child; |
| 22911 | if (type_is_invalid(ptr->value.type)) | 22910 | if (type_is_invalid(ptr->value->type)) |
| 22912 | return ira->codegen->invalid_instruction; | 22911 | return ira->codegen->invalid_instruction; |
| 22913 | | 22912 | |
| 22914 | // TODO let this be volatile | 22913 | // TODO let this be volatile |
| 22915 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 22914 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 22916 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); | 22915 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); |
| 22917 | if (type_is_invalid(casted_ptr->value.type)) | 22916 | if (type_is_invalid(casted_ptr->value->type)) |
| 22918 | return ira->codegen->invalid_instruction; | 22917 | return ira->codegen->invalid_instruction; |
| 22919 | | 22918 | |
| 22920 | IrInstruction *cmp_value = instruction->cmp_value->child; | 22919 | IrInstruction *cmp_value = instruction->cmp_value->child; |
| 22921 | if (type_is_invalid(cmp_value->value.type)) | 22920 | if (type_is_invalid(cmp_value->value->type)) |
| 22922 | return ira->codegen->invalid_instruction; | 22921 | return ira->codegen->invalid_instruction; |
| 22923 | | 22922 | |
| 22924 | IrInstruction *new_value = instruction->new_value->child; | 22923 | IrInstruction *new_value = instruction->new_value->child; |
| 22925 | if (type_is_invalid(new_value->value.type)) | 22924 | if (type_is_invalid(new_value->value->type)) |
| 22926 | return ira->codegen->invalid_instruction; | 22925 | return ira->codegen->invalid_instruction; |
| 22927 | | 22926 | |
| 22928 | IrInstruction *success_order_value = instruction->success_order_value->child; | 22927 | IrInstruction *success_order_value = instruction->success_order_value->child; |
| 22929 | if (type_is_invalid(success_order_value->value.type)) | 22928 | if (type_is_invalid(success_order_value->value->type)) |
| 22930 | return ira->codegen->invalid_instruction; | 22929 | return ira->codegen->invalid_instruction; |
| 22931 | | 22930 | |
| 22932 | AtomicOrder success_order; | 22931 | AtomicOrder success_order; |
| ... | @@ -22934,7 +22933,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22934,7 +22933,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22934 | return ira->codegen->invalid_instruction; | 22933 | return ira->codegen->invalid_instruction; |
| 22935 | | 22934 | |
| 22936 | IrInstruction *failure_order_value = instruction->failure_order_value->child; | 22935 | IrInstruction *failure_order_value = instruction->failure_order_value->child; |
| 22937 | if (type_is_invalid(failure_order_value->value.type)) | 22936 | if (type_is_invalid(failure_order_value->value->type)) |
| 22938 | return ira->codegen->invalid_instruction; | 22937 | return ira->codegen->invalid_instruction; |
| 22939 | | 22938 | |
| 22940 | AtomicOrder failure_order; | 22939 | AtomicOrder failure_order; |
| ... | @@ -22942,11 +22941,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22942,11 +22941,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22942 | return ira->codegen->invalid_instruction; | 22941 | return ira->codegen->invalid_instruction; |
| 22943 | | 22942 | |
| 22944 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); | 22943 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); |
| 22945 | if (type_is_invalid(casted_cmp_value->value.type)) | 22944 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 22946 | return ira->codegen->invalid_instruction; | 22945 | return ira->codegen->invalid_instruction; |
| 22947 | | 22946 | |
| 22948 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); | 22947 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); |
| 22949 | if (type_is_invalid(casted_new_value->value.type)) | 22948 | if (type_is_invalid(casted_new_value->value->type)) |
| 22950 | return ira->codegen->invalid_instruction; | 22949 | return ira->codegen->invalid_instruction; |
| 22951 | | 22950 | |
| 22952 | if (success_order < AtomicOrderMonotonic) { | 22951 | if (success_order < AtomicOrderMonotonic) { |
| ... | @@ -22970,7 +22969,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22970,7 +22969,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22970 | return ira->codegen->invalid_instruction; | 22969 | return ira->codegen->invalid_instruction; |
| 22971 | } | 22970 | } |
| 22972 | | 22971 | |
| 22973 | if (instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar && | 22972 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 22974 | instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { | 22973 | instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { |
| 22975 | zig_panic("TODO compile-time execution of cmpxchg"); | 22974 | zig_panic("TODO compile-time execution of cmpxchg"); |
| 22976 | } | 22975 | } |
| ... | @@ -22980,7 +22979,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22980,7 +22979,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22980 | if (handle_is_ptr(result_type)) { | 22979 | if (handle_is_ptr(result_type)) { |
| 22981 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 22980 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 22982 | result_type, nullptr, true, false, true); | 22981 | result_type, nullptr, true, false, true); |
| 22983 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 22982 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 22984 | return result_loc; | 22983 | return result_loc; |
| 22985 | } | 22984 | } |
| 22986 | } else { | 22985 | } else { |
| ... | @@ -22994,7 +22993,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -22994,7 +22993,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22994 | | 22993 | |
| 22995 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { | 22994 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { |
| 22996 | IrInstruction *order_value = instruction->order_value->child; | 22995 | IrInstruction *order_value = instruction->order_value->child; |
| 22997 | if (type_is_invalid(order_value->value.type)) | 22996 | if (type_is_invalid(order_value->value->type)) |
| 22998 | return ira->codegen->invalid_instruction; | 22997 | return ira->codegen->invalid_instruction; |
| 22999 | | 22998 | |
| 23000 | AtomicOrder order; | 22999 | AtomicOrder order; |
| ... | @@ -23009,7 +23008,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction | ... | @@ -23009,7 +23008,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction |
| 23009 | | 23008 | |
| 23010 | IrInstruction *result = ir_build_fence(&ira->new_irb, | 23009 | IrInstruction *result = ir_build_fence(&ira->new_irb, |
| 23011 | instruction->base.scope, instruction->base.source_node, order_value, order); | 23010 | instruction->base.scope, instruction->base.source_node, order_value, order); |
| 23012 | result->value.type = ira->codegen->builtin_types.entry_void; | 23011 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 23013 | return result; | 23012 | return result; |
| 23014 | } | 23013 | } |
| 23015 | | 23014 | |
| ... | @@ -23027,7 +23026,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23027,7 +23026,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23027 | } | 23026 | } |
| 23028 | | 23027 | |
| 23029 | IrInstruction *target = instruction->target->child; | 23028 | IrInstruction *target = instruction->target->child; |
| 23030 | ZigType *src_type = target->value.type; | 23029 | ZigType *src_type = target->value->type; |
| 23031 | if (type_is_invalid(src_type)) | 23030 | if (type_is_invalid(src_type)) |
| 23032 | return ira->codegen->invalid_instruction; | 23031 | return ira->codegen->invalid_instruction; |
| 23033 | | 23032 | |
| ... | @@ -23048,14 +23047,14 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23048,14 +23047,14 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23048 | return ira->codegen->invalid_instruction; | 23047 | return ira->codegen->invalid_instruction; |
| 23049 | | 23048 | |
| 23050 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 23049 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); |
| 23051 | bigint_truncate(&result->value.data.x_bigint, &val->data.x_bigint, | 23050 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, |
| 23052 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); | 23051 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); |
| 23053 | return result; | 23052 | return result; |
| 23054 | } | 23053 | } |
| 23055 | | 23054 | |
| 23056 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { | 23055 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { |
| 23057 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 23056 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); |
| 23058 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 23057 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 23059 | return result; | 23058 | return result; |
| 23060 | } | 23059 | } |
| 23061 | | 23060 | |
| ... | @@ -23071,7 +23070,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -23071,7 +23070,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 23071 | | 23070 | |
| 23072 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, | 23071 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, |
| 23073 | instruction->base.source_node, dest_type_value, target); | 23072 | instruction->base.source_node, dest_type_value, target); |
| 23074 | new_instruction->value.type = dest_type; | 23073 | new_instruction->value->type = dest_type; |
| 23075 | return new_instruction; | 23074 | return new_instruction; |
| 23076 | } | 23075 | } |
| 23077 | | 23076 | |
| ... | @@ -23086,12 +23085,12 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -23086,12 +23085,12 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 23086 | } | 23085 | } |
| 23087 | | 23086 | |
| 23088 | IrInstruction *target = instruction->target->child; | 23087 | IrInstruction *target = instruction->target->child; |
| 23089 | if (type_is_invalid(target->value.type)) | 23088 | if (type_is_invalid(target->value->type)) |
| 23090 | return ira->codegen->invalid_instruction; | 23089 | return ira->codegen->invalid_instruction; |
| 23091 | | 23090 | |
| 23092 | if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) { | 23091 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 23093 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", | 23092 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", |
| 23094 | buf_ptr(&target->value.type->name))); | 23093 | buf_ptr(&target->value->type->name))); |
| 23095 | return ira->codegen->invalid_instruction; | 23094 | return ira->codegen->invalid_instruction; |
| 23096 | } | 23095 | } |
| 23097 | | 23096 | |
| ... | @@ -23120,15 +23119,15 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -23120,15 +23119,15 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 23120 | } | 23119 | } |
| 23121 | | 23120 | |
| 23122 | IrInstruction *target = instruction->target->child; | 23121 | IrInstruction *target = instruction->target->child; |
| 23123 | if (type_is_invalid(target->value.type)) | 23122 | if (type_is_invalid(target->value->type)) |
| 23124 | return ira->codegen->invalid_instruction; | 23123 | return ira->codegen->invalid_instruction; |
| 23125 | | 23124 | |
| 23126 | if (target->value.type->id == ZigTypeIdComptimeInt || | 23125 | if (target->value->type->id == ZigTypeIdComptimeInt || |
| 23127 | target->value.type->id == ZigTypeIdComptimeFloat) | 23126 | target->value->type->id == ZigTypeIdComptimeFloat) |
| 23128 | { | 23127 | { |
| 23129 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { | 23128 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { |
| 23130 | CastOp op; | 23129 | CastOp op; |
| 23131 | if (target->value.type->id == ZigTypeIdComptimeInt) { | 23130 | if (target->value->type->id == ZigTypeIdComptimeInt) { |
| 23132 | op = CastOpIntToFloat; | 23131 | op = CastOpIntToFloat; |
| 23133 | } else { | 23132 | } else { |
| 23134 | op = CastOpNumLitToConcrete; | 23133 | op = CastOpNumLitToConcrete; |
| ... | @@ -23139,9 +23138,9 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -23139,9 +23138,9 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 23139 | } | 23138 | } |
| 23140 | } | 23139 | } |
| 23141 | | 23140 | |
| 23142 | if (target->value.type->id != ZigTypeIdFloat) { | 23141 | if (target->value->type->id != ZigTypeIdFloat) { |
| 23143 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 23142 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 23144 | buf_ptr(&target->value.type->name))); | 23143 | buf_ptr(&target->value->type->name))); |
| 23145 | return ira->codegen->invalid_instruction; | 23144 | return ira->codegen->invalid_instruction; |
| 23146 | } | 23145 | } |
| 23147 | | 23146 | |
| ... | @@ -23160,12 +23159,12 @@ static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInst | ... | @@ -23160,12 +23159,12 @@ static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInst |
| 23160 | } | 23159 | } |
| 23161 | | 23160 | |
| 23162 | IrInstruction *target = instruction->target->child; | 23161 | IrInstruction *target = instruction->target->child; |
| 23163 | if (type_is_invalid(target->value.type)) | 23162 | if (type_is_invalid(target->value->type)) |
| 23164 | return ira->codegen->invalid_instruction; | 23163 | return ira->codegen->invalid_instruction; |
| 23165 | | 23164 | |
| 23166 | if (target->value.type->id != ZigTypeIdErrorSet) { | 23165 | if (target->value->type->id != ZigTypeIdErrorSet) { |
| 23167 | ir_add_error(ira, instruction->target, | 23166 | ir_add_error(ira, instruction->target, |
| 23168 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value.type->name))); | 23167 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); |
| 23169 | return ira->codegen->invalid_instruction; | 23168 | return ira->codegen->invalid_instruction; |
| 23170 | } | 23169 | } |
| 23171 | | 23170 | |
| ... | @@ -23180,20 +23179,20 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23180,20 +23179,20 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23180 | return ira->codegen->invalid_instruction; | 23179 | return ira->codegen->invalid_instruction; |
| 23181 | | 23180 | |
| 23182 | IrInstruction *target = instruction->target->child; | 23181 | IrInstruction *target = instruction->target->child; |
| 23183 | if (type_is_invalid(target->value.type)) | 23182 | if (type_is_invalid(target->value->type)) |
| 23184 | return ira->codegen->invalid_instruction; | 23183 | return ira->codegen->invalid_instruction; |
| 23185 | | 23184 | |
| 23186 | bool src_ptr_const; | 23185 | bool src_ptr_const; |
| 23187 | bool src_ptr_volatile; | 23186 | bool src_ptr_volatile; |
| 23188 | uint32_t src_ptr_align; | 23187 | uint32_t src_ptr_align; |
| 23189 | if (target->value.type->id == ZigTypeIdPointer) { | 23188 | if (target->value->type->id == ZigTypeIdPointer) { |
| 23190 | src_ptr_const = target->value.type->data.pointer.is_const; | 23189 | src_ptr_const = target->value->type->data.pointer.is_const; |
| 23191 | src_ptr_volatile = target->value.type->data.pointer.is_volatile; | 23190 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; |
| 23192 | | 23191 | |
| 23193 | if ((err = resolve_ptr_align(ira, target->value.type, &src_ptr_align))) | 23192 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) |
| 23194 | return ira->codegen->invalid_instruction; | 23193 | return ira->codegen->invalid_instruction; |
| 23195 | } else if (is_slice(target->value.type)) { | 23194 | } else if (is_slice(target->value->type)) { |
| 23196 | ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 23195 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 23197 | src_ptr_const = src_ptr_type->data.pointer.is_const; | 23196 | src_ptr_const = src_ptr_type->data.pointer.is_const; |
| 23198 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; | 23197 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; |
| 23199 | | 23198 | |
| ... | @@ -23203,10 +23202,10 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23203,10 +23202,10 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23203 | src_ptr_const = true; | 23202 | src_ptr_const = true; |
| 23204 | src_ptr_volatile = false; | 23203 | src_ptr_volatile = false; |
| 23205 | | 23204 | |
| 23206 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusAlignmentKnown))) | 23205 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) |
| 23207 | return ira->codegen->invalid_instruction; | 23206 | return ira->codegen->invalid_instruction; |
| 23208 | | 23207 | |
| 23209 | src_ptr_align = get_abi_alignment(ira->codegen, target->value.type); | 23208 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); |
| 23210 | } | 23209 | } |
| 23211 | | 23210 | |
| 23212 | if (src_ptr_align != 0) { | 23211 | if (src_ptr_align != 0) { |
| ... | @@ -23225,7 +23224,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23225,7 +23224,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23225 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); | 23224 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 23226 | | 23225 | |
| 23227 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); | 23226 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); |
| 23228 | if (type_is_invalid(casted_value->value.type)) | 23227 | if (type_is_invalid(casted_value->value->type)) |
| 23229 | return ira->codegen->invalid_instruction; | 23228 | return ira->codegen->invalid_instruction; |
| 23230 | | 23229 | |
| 23231 | bool have_known_len = false; | 23230 | bool have_known_len = false; |
| ... | @@ -23245,12 +23244,12 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -23245,12 +23244,12 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23245 | | 23244 | |
| 23246 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 23245 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 23247 | dest_slice_type, nullptr, true, false, true); | 23246 | dest_slice_type, nullptr, true, false, true); |
| 23248 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) { | 23247 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) { |
| 23249 | return result_loc; | 23248 | return result_loc; |
| 23250 | } | 23249 | } |
| 23251 | | 23250 | |
| 23252 | if (casted_value->value.data.rh_slice.id == RuntimeHintSliceIdLen) { | 23251 | if (casted_value->value->data.rh_slice.id == RuntimeHintSliceIdLen) { |
| 23253 | known_len = casted_value->value.data.rh_slice.len; | 23252 | known_len = casted_value->value->data.rh_slice.len; |
| 23254 | have_known_len = true; | 23253 | have_known_len = true; |
| 23255 | } | 23254 | } |
| 23256 | | 23255 | |
| ... | @@ -23277,16 +23276,16 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23277,16 +23276,16 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23277 | Error err; | 23276 | Error err; |
| 23278 | | 23277 | |
| 23279 | IrInstruction *target = instruction->target->child; | 23278 | IrInstruction *target = instruction->target->child; |
| 23280 | if (type_is_invalid(target->value.type)) | 23279 | if (type_is_invalid(target->value->type)) |
| 23281 | return ira->codegen->invalid_instruction; | 23280 | return ira->codegen->invalid_instruction; |
| 23282 | | 23281 | |
| 23283 | if (!is_slice(target->value.type)) { | 23282 | if (!is_slice(target->value->type)) { |
| 23284 | ir_add_error(ira, instruction->target, | 23283 | ir_add_error(ira, instruction->target, |
| 23285 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name))); | 23284 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); |
| 23286 | return ira->codegen->invalid_instruction; | 23285 | return ira->codegen->invalid_instruction; |
| 23287 | } | 23286 | } |
| 23288 | | 23287 | |
| 23289 | ZigType *src_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 23288 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 23290 | | 23289 | |
| 23291 | uint32_t alignment; | 23290 | uint32_t alignment; |
| 23292 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) | 23291 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) |
| ... | @@ -23303,14 +23302,14 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23303,14 +23302,14 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23303 | return ira->codegen->invalid_instruction; | 23302 | return ira->codegen->invalid_instruction; |
| 23304 | | 23303 | |
| 23305 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 23304 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); |
| 23306 | result->value.data.x_struct.fields = alloc_const_vals_ptrs(2); | 23305 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 23307 | | 23306 | |
| 23308 | ZigValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index]; | 23307 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; |
| 23309 | ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; | 23308 | ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; |
| 23310 | copy_const_val(ptr_val, target_ptr_val, false); | 23309 | copy_const_val(ptr_val, target_ptr_val, false); |
| 23311 | ptr_val->type = dest_ptr_type; | 23310 | ptr_val->type = dest_ptr_type; |
| 23312 | | 23311 | |
| 23313 | ZigValue *len_val = result->value.data.x_struct.fields[slice_len_index]; | 23312 | ZigValue *len_val = result->value->data.x_struct.fields[slice_len_index]; |
| 23314 | len_val->special = ConstValSpecialStatic; | 23313 | len_val->special = ConstValSpecialStatic; |
| 23315 | len_val->type = ira->codegen->builtin_types.entry_usize; | 23314 | len_val->type = ira->codegen->builtin_types.entry_usize; |
| 23316 | ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; | 23315 | ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; |
| ... | @@ -23324,7 +23323,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -23324,7 +23323,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 23324 | | 23323 | |
| 23325 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 23324 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 23326 | dest_slice_type, nullptr, true, false, true); | 23325 | dest_slice_type, nullptr, true, false, true); |
| 23327 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 23326 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 23328 | return result_loc; | 23327 | return result_loc; |
| 23329 | } | 23328 | } |
| 23330 | | 23329 | |
| ... | @@ -23351,12 +23350,12 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst | ... | @@ -23351,12 +23350,12 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst |
| 23351 | return ira->codegen->invalid_instruction; | 23350 | return ira->codegen->invalid_instruction; |
| 23352 | | 23351 | |
| 23353 | IrInstruction *target = instruction->target->child; | 23352 | IrInstruction *target = instruction->target->child; |
| 23354 | if (type_is_invalid(target->value.type)) | 23353 | if (type_is_invalid(target->value->type)) |
| 23355 | return ira->codegen->invalid_instruction; | 23354 | return ira->codegen->invalid_instruction; |
| 23356 | | 23355 | |
| 23357 | if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) { | 23356 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 23358 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", | 23357 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", |
| 23359 | buf_ptr(&target->value.type->name))); | 23358 | buf_ptr(&target->value->type->name))); |
| 23360 | return ira->codegen->invalid_instruction; | 23359 | return ira->codegen->invalid_instruction; |
| 23361 | } | 23360 | } |
| 23362 | | 23361 | |
| ... | @@ -23369,16 +23368,16 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst | ... | @@ -23369,16 +23368,16 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 23369 | return ira->codegen->invalid_instruction; | 23368 | return ira->codegen->invalid_instruction; |
| 23370 | | 23369 | |
| 23371 | IrInstruction *target = instruction->target->child; | 23370 | IrInstruction *target = instruction->target->child; |
| 23372 | if (type_is_invalid(target->value.type)) | 23371 | if (type_is_invalid(target->value->type)) |
| 23373 | return ira->codegen->invalid_instruction; | 23372 | return ira->codegen->invalid_instruction; |
| 23374 | | 23373 | |
| 23375 | if (target->value.type->id == ZigTypeIdComptimeInt) { | 23374 | if (target->value->type->id == ZigTypeIdComptimeInt) { |
| 23376 | return ir_implicit_cast(ira, target, dest_type); | 23375 | return ir_implicit_cast(ira, target, dest_type); |
| 23377 | } | 23376 | } |
| 23378 | | 23377 | |
| 23379 | if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) { | 23378 | if (target->value->type->id != ZigTypeIdFloat && target->value->type->id != ZigTypeIdComptimeFloat) { |
| 23380 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 23379 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 23381 | buf_ptr(&target->value.type->name))); | 23380 | buf_ptr(&target->value->type->name))); |
| 23382 | return ira->codegen->invalid_instruction; | 23381 | return ira->codegen->invalid_instruction; |
| 23383 | } | 23382 | } |
| 23384 | | 23383 | |
| ... | @@ -23387,15 +23386,15 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst | ... | @@ -23387,15 +23386,15 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 23387 | | 23386 | |
| 23388 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { | 23387 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { |
| 23389 | IrInstruction *target = instruction->target->child; | 23388 | IrInstruction *target = instruction->target->child; |
| 23390 | if (type_is_invalid(target->value.type)) | 23389 | if (type_is_invalid(target->value->type)) |
| 23391 | return ira->codegen->invalid_instruction; | 23390 | return ira->codegen->invalid_instruction; |
| 23392 | | 23391 | |
| 23393 | IrInstruction *casted_target; | 23392 | IrInstruction *casted_target; |
| 23394 | if (target->value.type->id == ZigTypeIdErrorSet) { | 23393 | if (target->value->type->id == ZigTypeIdErrorSet) { |
| 23395 | casted_target = target; | 23394 | casted_target = target; |
| 23396 | } else { | 23395 | } else { |
| 23397 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); | 23396 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| 23398 | if (type_is_invalid(casted_target->value.type)) | 23397 | if (type_is_invalid(casted_target->value->type)) |
| 23399 | return ira->codegen->invalid_instruction; | 23398 | return ira->codegen->invalid_instruction; |
| 23400 | } | 23399 | } |
| 23401 | | 23400 | |
| ... | @@ -23404,11 +23403,11 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru | ... | @@ -23404,11 +23403,11 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru |
| 23404 | | 23403 | |
| 23405 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { | 23404 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { |
| 23406 | IrInstruction *target = instruction->target->child; | 23405 | IrInstruction *target = instruction->target->child; |
| 23407 | if (type_is_invalid(target->value.type)) | 23406 | if (type_is_invalid(target->value->type)) |
| 23408 | return ira->codegen->invalid_instruction; | 23407 | return ira->codegen->invalid_instruction; |
| 23409 | | 23408 | |
| 23410 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | 23409 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); |
| 23411 | if (type_is_invalid(casted_target->value.type)) | 23410 | if (type_is_invalid(casted_target->value->type)) |
| 23412 | return ira->codegen->invalid_instruction; | 23411 | return ira->codegen->invalid_instruction; |
| 23413 | | 23412 | |
| 23414 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); | 23413 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); |
| ... | @@ -23416,12 +23415,12 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru | ... | @@ -23416,12 +23415,12 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru |
| 23416 | | 23415 | |
| 23417 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { | 23416 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { |
| 23418 | IrInstruction *target = instruction->target->child; | 23417 | IrInstruction *target = instruction->target->child; |
| 23419 | if (type_is_invalid(target->value.type)) | 23418 | if (type_is_invalid(target->value->type)) |
| 23420 | return ira->codegen->invalid_instruction; | 23419 | return ira->codegen->invalid_instruction; |
| 23421 | | 23420 | |
| 23422 | if (target->value.type->id != ZigTypeIdBool) { | 23421 | if (target->value->type->id != ZigTypeIdBool) { |
| 23423 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 23422 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", |
| 23424 | buf_ptr(&target->value.type->name))); | 23423 | buf_ptr(&target->value->type->name))); |
| 23425 | return ira->codegen->invalid_instruction; | 23424 | return ira->codegen->invalid_instruction; |
| 23426 | } | 23425 | } |
| 23427 | | 23426 | |
| ... | @@ -23472,48 +23471,48 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23472,48 +23471,48 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23472 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); | 23471 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); |
| 23473 | | 23472 | |
| 23474 | uint32_t len_mask; | 23473 | uint32_t len_mask; |
| 23475 | if (mask->value.type->id == ZigTypeIdVector) { | 23474 | if (mask->value->type->id == ZigTypeIdVector) { |
| 23476 | len_mask = mask->value.type->data.vector.len; | 23475 | len_mask = mask->value->type->data.vector.len; |
| 23477 | } else if (mask->value.type->id == ZigTypeIdArray) { | 23476 | } else if (mask->value->type->id == ZigTypeIdArray) { |
| 23478 | len_mask = mask->value.type->data.array.len; | 23477 | len_mask = mask->value->type->data.array.len; |
| 23479 | } else { | 23478 | } else { |
| 23480 | ir_add_error(ira, mask, | 23479 | ir_add_error(ira, mask, |
| 23481 | buf_sprintf("expected vector or array, found '%s'", | 23480 | buf_sprintf("expected vector or array, found '%s'", |
| 23482 | buf_ptr(&mask->value.type->name))); | 23481 | buf_ptr(&mask->value->type->name))); |
| 23483 | return ira->codegen->invalid_instruction; | 23482 | return ira->codegen->invalid_instruction; |
| 23484 | } | 23483 | } |
| 23485 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, | 23484 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, |
| 23486 | ira->codegen->builtin_types.entry_i32)); | 23485 | ira->codegen->builtin_types.entry_i32)); |
| 23487 | if (type_is_invalid(mask->value.type)) | 23486 | if (type_is_invalid(mask->value->type)) |
| 23488 | return ira->codegen->invalid_instruction; | 23487 | return ira->codegen->invalid_instruction; |
| 23489 | | 23488 | |
| 23490 | uint32_t len_a; | 23489 | uint32_t len_a; |
| 23491 | if (a->value.type->id == ZigTypeIdVector) { | 23490 | if (a->value->type->id == ZigTypeIdVector) { |
| 23492 | len_a = a->value.type->data.vector.len; | 23491 | len_a = a->value->type->data.vector.len; |
| 23493 | } else if (a->value.type->id == ZigTypeIdArray) { | 23492 | } else if (a->value->type->id == ZigTypeIdArray) { |
| 23494 | len_a = a->value.type->data.array.len; | 23493 | len_a = a->value->type->data.array.len; |
| 23495 | } else if (a->value.type->id == ZigTypeIdUndefined) { | 23494 | } else if (a->value->type->id == ZigTypeIdUndefined) { |
| 23496 | len_a = UINT32_MAX; | 23495 | len_a = UINT32_MAX; |
| 23497 | } else { | 23496 | } else { |
| 23498 | ir_add_error(ira, a, | 23497 | ir_add_error(ira, a, |
| 23499 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 23498 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 23500 | buf_ptr(&scalar_type->name), | 23499 | buf_ptr(&scalar_type->name), |
| 23501 | buf_ptr(&a->value.type->name))); | 23500 | buf_ptr(&a->value->type->name))); |
| 23502 | return ira->codegen->invalid_instruction; | 23501 | return ira->codegen->invalid_instruction; |
| 23503 | } | 23502 | } |
| 23504 | | 23503 | |
| 23505 | uint32_t len_b; | 23504 | uint32_t len_b; |
| 23506 | if (b->value.type->id == ZigTypeIdVector) { | 23505 | if (b->value->type->id == ZigTypeIdVector) { |
| 23507 | len_b = b->value.type->data.vector.len; | 23506 | len_b = b->value->type->data.vector.len; |
| 23508 | } else if (b->value.type->id == ZigTypeIdArray) { | 23507 | } else if (b->value->type->id == ZigTypeIdArray) { |
| 23509 | len_b = b->value.type->data.array.len; | 23508 | len_b = b->value->type->data.array.len; |
| 23510 | } else if (b->value.type->id == ZigTypeIdUndefined) { | 23509 | } else if (b->value->type->id == ZigTypeIdUndefined) { |
| 23511 | len_b = UINT32_MAX; | 23510 | len_b = UINT32_MAX; |
| 23512 | } else { | 23511 | } else { |
| 23513 | ir_add_error(ira, b, | 23512 | ir_add_error(ira, b, |
| 23514 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 23513 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 23515 | buf_ptr(&scalar_type->name), | 23514 | buf_ptr(&scalar_type->name), |
| 23516 | buf_ptr(&b->value.type->name))); | 23515 | buf_ptr(&b->value->type->name))); |
| 23517 | return ira->codegen->invalid_instruction; | 23516 | return ira->codegen->invalid_instruction; |
| 23518 | } | 23517 | } |
| 23519 | | 23518 | |
| ... | @@ -23526,7 +23525,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23526,7 +23525,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23526 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 23525 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23527 | } else { | 23526 | } else { |
| 23528 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 23527 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23529 | if (type_is_invalid(a->value.type)) | 23528 | if (type_is_invalid(a->value->type)) |
| 23530 | return ira->codegen->invalid_instruction; | 23529 | return ira->codegen->invalid_instruction; |
| 23531 | } | 23530 | } |
| 23532 | | 23531 | |
| ... | @@ -23535,7 +23534,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23535,7 +23534,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23535 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 23534 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23536 | } else { | 23535 | } else { |
| 23537 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 23536 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23538 | if (type_is_invalid(b->value.type)) | 23537 | if (type_is_invalid(b->value->type)) |
| 23539 | return ira->codegen->invalid_instruction; | 23538 | return ira->codegen->invalid_instruction; |
| 23540 | } | 23539 | } |
| 23541 | | 23540 | |
| ... | @@ -23559,12 +23558,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23559,12 +23558,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23559 | v = (uint32_t)~v_i32; | 23558 | v = (uint32_t)~v_i32; |
| 23560 | chosen_operand = b; | 23559 | chosen_operand = b; |
| 23561 | } | 23560 | } |
| 23562 | if (v >= chosen_operand->value.type->data.vector.len) { | 23561 | if (v >= chosen_operand->value->type->data.vector.len) { |
| 23563 | ErrorMsg *msg = ir_add_error(ira, mask, | 23562 | ErrorMsg *msg = ir_add_error(ira, mask, |
| 23564 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); | 23563 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); |
| 23565 | add_error_note(ira->codegen, msg, chosen_operand->source_node, | 23564 | add_error_note(ira->codegen, msg, chosen_operand->source_node, |
| 23566 | buf_sprintf("selected index '%u' out of bounds of %s", v, | 23565 | buf_sprintf("selected index '%u' out of bounds of %s", v, |
| 23567 | buf_ptr(&chosen_operand->value.type->name))); | 23566 | buf_ptr(&chosen_operand->value->type->name))); |
| 23568 | if (chosen_operand == a && v < len_a + len_b) { | 23567 | if (chosen_operand == a && v < len_a + len_b) { |
| 23569 | add_error_note(ira->codegen, msg, b->source_node, | 23568 | add_error_note(ira->codegen, msg, b->source_node, |
| 23570 | buf_create_from_str("selections from the second vector are specified with negative numbers")); | 23569 | buf_create_from_str("selections from the second vector are specified with negative numbers")); |
| ... | @@ -23587,10 +23586,10 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23587,10 +23586,10 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23587 | expand_undef_array(ira->codegen, b_val); | 23586 | expand_undef_array(ira->codegen, b_val); |
| 23588 | | 23587 | |
| 23589 | IrInstruction *result = ir_const(ira, source_instr, result_type); | 23588 | IrInstruction *result = ir_const(ira, source_instr, result_type); |
| 23590 | result->value.data.x_array.data.s_none.elements = create_const_vals(len_mask); | 23589 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); |
| 23591 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { | 23590 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 23592 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; | 23591 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| 23593 | ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; | 23592 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 23594 | if (mask_elem_val->special == ConstValSpecialUndef) { | 23593 | if (mask_elem_val->special == ConstValSpecialUndef) { |
| 23595 | result_elem_val->special = ConstValSpecialUndef; | 23594 | result_elem_val->special = ConstValSpecialUndef; |
| 23596 | continue; | 23595 | continue; |
| ... | @@ -23598,13 +23597,13 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23598,13 +23597,13 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23598 | int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint); | 23597 | int32_t v = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| 23599 | // We've already checked for and emitted compile errors for index out of bounds here. | 23598 | // We've already checked for and emitted compile errors for index out of bounds here. |
| 23600 | ZigValue *src_elem_val = (v >= 0) ? | 23599 | ZigValue *src_elem_val = (v >= 0) ? |
| 23601 | &a->value.data.x_array.data.s_none.elements[v] : | 23600 | &a->value->data.x_array.data.s_none.elements[v] : |
| 23602 | &b->value.data.x_array.data.s_none.elements[~v]; | 23601 | &b->value->data.x_array.data.s_none.elements[~v]; |
| 23603 | copy_const_val(result_elem_val, src_elem_val, false); | 23602 | copy_const_val(result_elem_val, src_elem_val, false); |
| 23604 | | 23603 | |
| 23605 | ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr); | 23604 | ir_assert(result_elem_val->special == ConstValSpecialStatic, source_instr); |
| 23606 | } | 23605 | } |
| 23607 | result->value.special = ConstValSpecialStatic; | 23606 | result->value->special = ConstValSpecialStatic; |
| 23608 | return result; | 23607 | return result; |
| 23609 | } | 23608 | } |
| 23610 | | 23609 | |
| ... | @@ -23620,12 +23619,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23620,12 +23619,12 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23620 | | 23619 | |
| 23621 | IrInstruction *expand_mask = ir_const(ira, mask, | 23620 | IrInstruction *expand_mask = ir_const(ira, mask, |
| 23622 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); | 23621 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); |
| 23623 | expand_mask->value.data.x_array.data.s_none.elements = create_const_vals(len_max); | 23622 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); |
| 23624 | uint32_t i = 0; | 23623 | uint32_t i = 0; |
| 23625 | for (; i < len_min; i += 1) | 23624 | for (; i < len_min; i += 1) |
| 23626 | bigint_init_unsigned(&expand_mask->value.data.x_array.data.s_none.elements[i].data.x_bigint, i); | 23625 | bigint_init_unsigned(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, i); |
| 23627 | for (; i < len_max; i += 1) | 23626 | for (; i < len_max; i += 1) |
| 23628 | bigint_init_signed(&expand_mask->value.data.x_array.data.s_none.elements[i].data.x_bigint, -1); | 23627 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); |
| 23629 | | 23628 | |
| 23630 | IrInstruction *undef = ir_const_undef(ira, source_instr, | 23629 | IrInstruction *undef = ir_const_undef(ira, source_instr, |
| 23631 | get_vector_type(ira->codegen, len_min, scalar_type)); | 23630 | get_vector_type(ira->codegen, len_min, scalar_type)); |
| ... | @@ -23640,7 +23639,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -23640,7 +23639,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23640 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, | 23639 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, |
| 23641 | source_instr->scope, source_instr->source_node, | 23640 | source_instr->scope, source_instr->source_node, |
| 23642 | nullptr, a, b, mask); | 23641 | nullptr, a, b, mask); |
| 23643 | result->value.type = result_type; | 23642 | result->value->type = result_type; |
| 23644 | return result; | 23643 | return result; |
| 23645 | } | 23644 | } |
| 23646 | | 23645 | |
| ... | @@ -23650,15 +23649,15 @@ static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrIn | ... | @@ -23650,15 +23649,15 @@ static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrIn |
| 23650 | return ira->codegen->invalid_instruction; | 23649 | return ira->codegen->invalid_instruction; |
| 23651 | | 23650 | |
| 23652 | IrInstruction *a = instruction->a->child; | 23651 | IrInstruction *a = instruction->a->child; |
| 23653 | if (type_is_invalid(a->value.type)) | 23652 | if (type_is_invalid(a->value->type)) |
| 23654 | return ira->codegen->invalid_instruction; | 23653 | return ira->codegen->invalid_instruction; |
| 23655 | | 23654 | |
| 23656 | IrInstruction *b = instruction->b->child; | 23655 | IrInstruction *b = instruction->b->child; |
| 23657 | if (type_is_invalid(b->value.type)) | 23656 | if (type_is_invalid(b->value->type)) |
| 23658 | return ira->codegen->invalid_instruction; | 23657 | return ira->codegen->invalid_instruction; |
| 23659 | | 23658 | |
| 23660 | IrInstruction *mask = instruction->mask->child; | 23659 | IrInstruction *mask = instruction->mask->child; |
| 23661 | if (type_is_invalid(mask->value.type)) | 23660 | if (type_is_invalid(mask->value->type)) |
| 23662 | return ira->codegen->invalid_instruction; | 23661 | return ira->codegen->invalid_instruction; |
| 23663 | | 23662 | |
| 23664 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); | 23663 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); |
| ... | @@ -23668,11 +23667,11 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23668,11 +23667,11 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23668 | Error err; | 23667 | Error err; |
| 23669 | | 23668 | |
| 23670 | IrInstruction *len = instruction->len->child; | 23669 | IrInstruction *len = instruction->len->child; |
| 23671 | if (type_is_invalid(len->value.type)) | 23670 | if (type_is_invalid(len->value->type)) |
| 23672 | return ira->codegen->invalid_instruction; | 23671 | return ira->codegen->invalid_instruction; |
| 23673 | | 23672 | |
| 23674 | IrInstruction *scalar = instruction->scalar->child; | 23673 | IrInstruction *scalar = instruction->scalar->child; |
| 23675 | if (type_is_invalid(scalar->value.type)) | 23674 | if (type_is_invalid(scalar->value->type)) |
| 23676 | return ira->codegen->invalid_instruction; | 23675 | return ira->codegen->invalid_instruction; |
| 23677 | | 23676 | |
| 23678 | uint64_t len_u64; | 23677 | uint64_t len_u64; |
| ... | @@ -23680,10 +23679,10 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23680,10 +23679,10 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23680 | return ira->codegen->invalid_instruction; | 23679 | return ira->codegen->invalid_instruction; |
| 23681 | uint32_t len_int = len_u64; | 23680 | uint32_t len_int = len_u64; |
| 23682 | | 23681 | |
| 23683 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value.type))) | 23682 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value->type))) |
| 23684 | return ira->codegen->invalid_instruction; | 23683 | return ira->codegen->invalid_instruction; |
| 23685 | | 23684 | |
| 23686 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value.type); | 23685 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); |
| 23687 | | 23686 | |
| 23688 | if (instr_is_comptime(scalar)) { | 23687 | if (instr_is_comptime(scalar)) { |
| 23689 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); | 23688 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); |
| ... | @@ -23693,9 +23692,9 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23693,9 +23692,9 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23693 | return ir_const_undef(ira, &instruction->base, return_type); | 23692 | return ir_const_undef(ira, &instruction->base, return_type); |
| 23694 | | 23693 | |
| 23695 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 23694 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 23696 | result->value.data.x_array.data.s_none.elements = create_const_vals(len_int); | 23695 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); |
| 23697 | for (uint32_t i = 0; i < len_int; i += 1) { | 23696 | for (uint32_t i = 0; i < len_int; i += 1) { |
| 23698 | copy_const_val(&result->value.data.x_array.data.s_none.elements[i], scalar_val, false); | 23697 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val, false); |
| 23699 | } | 23698 | } |
| 23700 | return result; | 23699 | return result; |
| 23701 | } | 23700 | } |
| ... | @@ -23705,13 +23704,13 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -23705,13 +23704,13 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 23705 | | 23704 | |
| 23706 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { | 23705 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { |
| 23707 | IrInstruction *value = instruction->value->child; | 23706 | IrInstruction *value = instruction->value->child; |
| 23708 | if (type_is_invalid(value->value.type)) | 23707 | if (type_is_invalid(value->value->type)) |
| 23709 | return ira->codegen->invalid_instruction; | 23708 | return ira->codegen->invalid_instruction; |
| 23710 | | 23709 | |
| 23711 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 23710 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 23712 | | 23711 | |
| 23713 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); | 23712 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 23714 | if (type_is_invalid(casted_value->value.type)) | 23713 | if (type_is_invalid(casted_value->value->type)) |
| 23715 | return ira->codegen->invalid_instruction; | 23714 | return ira->codegen->invalid_instruction; |
| 23716 | | 23715 | |
| 23717 | if (instr_is_comptime(casted_value)) { | 23716 | if (instr_is_comptime(casted_value)) { |
| ... | @@ -23724,7 +23723,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct | ... | @@ -23724,7 +23723,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct |
| 23724 | | 23723 | |
| 23725 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, | 23724 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, |
| 23726 | instruction->base.source_node, casted_value); | 23725 | instruction->base.source_node, casted_value); |
| 23727 | result->value.type = bool_type; | 23726 | result->value->type = bool_type; |
| 23728 | return result; | 23727 | return result; |
| 23729 | } | 23728 | } |
| 23730 | | 23729 | |
| ... | @@ -23732,18 +23731,18 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23732,18 +23731,18 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23732 | Error err; | 23731 | Error err; |
| 23733 | | 23732 | |
| 23734 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 23733 | IrInstruction *dest_ptr = instruction->dest_ptr->child; |
| 23735 | if (type_is_invalid(dest_ptr->value.type)) | 23734 | if (type_is_invalid(dest_ptr->value->type)) |
| 23736 | return ira->codegen->invalid_instruction; | 23735 | return ira->codegen->invalid_instruction; |
| 23737 | | 23736 | |
| 23738 | IrInstruction *byte_value = instruction->byte->child; | 23737 | IrInstruction *byte_value = instruction->byte->child; |
| 23739 | if (type_is_invalid(byte_value->value.type)) | 23738 | if (type_is_invalid(byte_value->value->type)) |
| 23740 | return ira->codegen->invalid_instruction; | 23739 | return ira->codegen->invalid_instruction; |
| 23741 | | 23740 | |
| 23742 | IrInstruction *count_value = instruction->count->child; | 23741 | IrInstruction *count_value = instruction->count->child; |
| 23743 | if (type_is_invalid(count_value->value.type)) | 23742 | if (type_is_invalid(count_value->value->type)) |
| 23744 | return ira->codegen->invalid_instruction; | 23743 | return ira->codegen->invalid_instruction; |
| 23745 | | 23744 | |
| 23746 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 23745 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 23747 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 23746 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 23748 | dest_uncasted_type->data.pointer.is_volatile; | 23747 | dest_uncasted_type->data.pointer.is_volatile; |
| 23749 | | 23748 | |
| ... | @@ -23760,15 +23759,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23760,15 +23759,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23760 | PtrLenUnknown, dest_align, 0, 0, false); | 23759 | PtrLenUnknown, dest_align, 0, 0, false); |
| 23761 | | 23760 | |
| 23762 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | 23761 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 23763 | if (type_is_invalid(casted_dest_ptr->value.type)) | 23762 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 23764 | return ira->codegen->invalid_instruction; | 23763 | return ira->codegen->invalid_instruction; |
| 23765 | | 23764 | |
| 23766 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); | 23765 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 23767 | if (type_is_invalid(casted_byte->value.type)) | 23766 | if (type_is_invalid(casted_byte->value->type)) |
| 23768 | return ira->codegen->invalid_instruction; | 23767 | return ira->codegen->invalid_instruction; |
| 23769 | | 23768 | |
| 23770 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 23769 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23771 | if (type_is_invalid(casted_count->value.type)) | 23770 | if (type_is_invalid(casted_count->value->type)) |
| 23772 | return ira->codegen->invalid_instruction; | 23771 | return ira->codegen->invalid_instruction; |
| 23773 | | 23772 | |
| 23774 | // TODO test this at comptime with u8 and non-u8 types | 23773 | // TODO test this at comptime with u8 and non-u8 types |
| ... | @@ -23788,8 +23787,8 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23788,8 +23787,8 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23788 | if (count_val == nullptr) | 23787 | if (count_val == nullptr) |
| 23789 | return ira->codegen->invalid_instruction; | 23788 | return ira->codegen->invalid_instruction; |
| 23790 | | 23789 | |
| 23791 | if (casted_dest_ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr && | 23790 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 23792 | casted_dest_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar) | 23791 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| 23793 | { | 23792 | { |
| 23794 | ZigValue *dest_elements; | 23793 | ZigValue *dest_elements; |
| 23795 | size_t start; | 23794 | size_t start; |
| ... | @@ -23845,7 +23844,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -23845,7 +23844,7 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23845 | | 23844 | |
| 23846 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 23845 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 23847 | casted_dest_ptr, casted_byte, casted_count); | 23846 | casted_dest_ptr, casted_byte, casted_count); |
| 23848 | result->value.type = ira->codegen->builtin_types.entry_void; | 23847 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 23849 | return result; | 23848 | return result; |
| 23850 | } | 23849 | } |
| 23851 | | 23850 | |
| ... | @@ -23853,20 +23852,20 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23853,20 +23852,20 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23853 | Error err; | 23852 | Error err; |
| 23854 | | 23853 | |
| 23855 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 23854 | IrInstruction *dest_ptr = instruction->dest_ptr->child; |
| 23856 | if (type_is_invalid(dest_ptr->value.type)) | 23855 | if (type_is_invalid(dest_ptr->value->type)) |
| 23857 | return ira->codegen->invalid_instruction; | 23856 | return ira->codegen->invalid_instruction; |
| 23858 | | 23857 | |
| 23859 | IrInstruction *src_ptr = instruction->src_ptr->child; | 23858 | IrInstruction *src_ptr = instruction->src_ptr->child; |
| 23860 | if (type_is_invalid(src_ptr->value.type)) | 23859 | if (type_is_invalid(src_ptr->value->type)) |
| 23861 | return ira->codegen->invalid_instruction; | 23860 | return ira->codegen->invalid_instruction; |
| 23862 | | 23861 | |
| 23863 | IrInstruction *count_value = instruction->count->child; | 23862 | IrInstruction *count_value = instruction->count->child; |
| 23864 | if (type_is_invalid(count_value->value.type)) | 23863 | if (type_is_invalid(count_value->value->type)) |
| 23865 | return ira->codegen->invalid_instruction; | 23864 | return ira->codegen->invalid_instruction; |
| 23866 | | 23865 | |
| 23867 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 23866 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 23868 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 23867 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 23869 | ZigType *src_uncasted_type = src_ptr->value.type; | 23868 | ZigType *src_uncasted_type = src_ptr->value->type; |
| 23870 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 23869 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 23871 | dest_uncasted_type->data.pointer.is_volatile; | 23870 | dest_uncasted_type->data.pointer.is_volatile; |
| 23872 | bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) && | 23871 | bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) && |
| ... | @@ -23895,15 +23894,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -23895,15 +23894,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23895 | PtrLenUnknown, src_align, 0, 0, false); | 23894 | PtrLenUnknown, src_align, 0, 0, false); |
| 23896 | | 23895 | |
| 23897 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | 23896 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 23898 | if (type_is_invalid(casted_dest_ptr->value.type)) | 23897 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 23899 | return ira->codegen->invalid_instruction; | 23898 | return ira->codegen->invalid_instruction; |
| 23900 | | 23899 | |
| 23901 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | 23900 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 23902 | if (type_is_invalid(casted_src_ptr->value.type)) | 23901 | if (type_is_invalid(casted_src_ptr->value->type)) |
| 23903 | return ira->codegen->invalid_instruction; | 23902 | return ira->codegen->invalid_instruction; |
| 23904 | | 23903 | |
| 23905 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 23904 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23906 | if (type_is_invalid(casted_count->value.type)) | 23905 | if (type_is_invalid(casted_count->value->type)) |
| 23907 | return ira->codegen->invalid_instruction; | 23906 | return ira->codegen->invalid_instruction; |
| 23908 | | 23907 | |
| 23909 | // TODO test this at comptime with u8 and non-u8 types | 23908 | // TODO test this at comptime with u8 and non-u8 types |
| ... | @@ -24024,35 +24023,35 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -24024,35 +24023,35 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 24024 | | 24023 | |
| 24025 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 24024 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 24026 | casted_dest_ptr, casted_src_ptr, casted_count); | 24025 | casted_dest_ptr, casted_src_ptr, casted_count); |
| 24027 | result->value.type = ira->codegen->builtin_types.entry_void; | 24026 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 24028 | return result; | 24027 | return result; |
| 24029 | } | 24028 | } |
| 24030 | | 24029 | |
| 24031 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { | 24030 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { |
| 24032 | IrInstruction *ptr_ptr = instruction->ptr->child; | 24031 | IrInstruction *ptr_ptr = instruction->ptr->child; |
| 24033 | if (type_is_invalid(ptr_ptr->value.type)) | 24032 | if (type_is_invalid(ptr_ptr->value->type)) |
| 24034 | return ira->codegen->invalid_instruction; | 24033 | return ira->codegen->invalid_instruction; |
| 24035 | | 24034 | |
| 24036 | ZigType *ptr_ptr_type = ptr_ptr->value.type; | 24035 | ZigType *ptr_ptr_type = ptr_ptr->value->type; |
| 24037 | assert(ptr_ptr_type->id == ZigTypeIdPointer); | 24036 | assert(ptr_ptr_type->id == ZigTypeIdPointer); |
| 24038 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; | 24037 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; |
| 24039 | | 24038 | |
| 24040 | IrInstruction *start = instruction->start->child; | 24039 | IrInstruction *start = instruction->start->child; |
| 24041 | if (type_is_invalid(start->value.type)) | 24040 | if (type_is_invalid(start->value->type)) |
| 24042 | return ira->codegen->invalid_instruction; | 24041 | return ira->codegen->invalid_instruction; |
| 24043 | | 24042 | |
| 24044 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 24043 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 24045 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); | 24044 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); |
| 24046 | if (type_is_invalid(casted_start->value.type)) | 24045 | if (type_is_invalid(casted_start->value->type)) |
| 24047 | return ira->codegen->invalid_instruction; | 24046 | return ira->codegen->invalid_instruction; |
| 24048 | | 24047 | |
| 24049 | IrInstruction *end; | 24048 | IrInstruction *end; |
| 24050 | if (instruction->end) { | 24049 | if (instruction->end) { |
| 24051 | end = instruction->end->child; | 24050 | end = instruction->end->child; |
| 24052 | if (type_is_invalid(end->value.type)) | 24051 | if (type_is_invalid(end->value->type)) |
| 24053 | return ira->codegen->invalid_instruction; | 24052 | return ira->codegen->invalid_instruction; |
| 24054 | end = ir_implicit_cast(ira, end, usize); | 24053 | end = ir_implicit_cast(ira, end, usize); |
| 24055 | if (type_is_invalid(end->value.type)) | 24054 | if (type_is_invalid(end->value->type)) |
| 24056 | return ira->codegen->invalid_instruction; | 24055 | return ira->codegen->invalid_instruction; |
| 24057 | } else { | 24056 | } else { |
| 24058 | end = nullptr; | 24057 | end = nullptr; |
| ... | @@ -24061,8 +24060,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24061,8 +24060,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24061 | ZigType *return_type; | 24060 | ZigType *return_type; |
| 24062 | | 24061 | |
| 24063 | if (array_type->id == ZigTypeIdArray) { | 24062 | if (array_type->id == ZigTypeIdArray) { |
| 24064 | bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic && | 24063 | bool is_comptime_const = ptr_ptr->value->special == ConstValSpecialStatic && |
| 24065 | ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst; | 24064 | ptr_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst; |
| 24066 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type, | 24065 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type, |
| 24067 | ptr_ptr_type->data.pointer.is_const || is_comptime_const, | 24066 | ptr_ptr_type->data.pointer.is_const || is_comptime_const, |
| 24068 | ptr_ptr_type->data.pointer.is_volatile, | 24067 | ptr_ptr_type->data.pointer.is_volatile, |
| ... | @@ -24103,8 +24102,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24103,8 +24102,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24103 | } | 24102 | } |
| 24104 | | 24103 | |
| 24105 | if (instr_is_comptime(ptr_ptr) && | 24104 | if (instr_is_comptime(ptr_ptr) && |
| 24106 | value_is_comptime(&casted_start->value) && | 24105 | value_is_comptime(casted_start->value) && |
| 24107 | (!end || value_is_comptime(&end->value))) | 24106 | (!end || value_is_comptime(end->value))) |
| 24108 | { | 24107 | { |
| 24109 | ZigValue *array_val; | 24108 | ZigValue *array_val; |
| 24110 | ZigValue *parent_ptr; | 24109 | ZigValue *parent_ptr; |
| ... | @@ -24117,7 +24116,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24117,7 +24116,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24117 | if (array_type->id == ZigTypeIdPointer) { | 24116 | if (array_type->id == ZigTypeIdPointer) { |
| 24118 | ZigType *child_array_type = array_type->data.pointer.child_type; | 24117 | ZigType *child_array_type = array_type->data.pointer.child_type; |
| 24119 | assert(child_array_type->id == ZigTypeIdArray); | 24118 | assert(child_array_type->id == ZigTypeIdArray); |
| 24120 | parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24119 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24121 | if (parent_ptr == nullptr) | 24120 | if (parent_ptr == nullptr) |
| 24122 | return ira->codegen->invalid_instruction; | 24121 | return ira->codegen->invalid_instruction; |
| 24123 | | 24122 | |
| ... | @@ -24136,7 +24135,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24136,7 +24135,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24136 | abs_offset = 0; | 24135 | abs_offset = 0; |
| 24137 | } | 24136 | } |
| 24138 | } else { | 24137 | } else { |
| 24139 | array_val = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24138 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24140 | if (array_val == nullptr) | 24139 | if (array_val == nullptr) |
| 24141 | return ira->codegen->invalid_instruction; | 24140 | return ira->codegen->invalid_instruction; |
| 24142 | rel_end = array_type->data.array.len; | 24141 | rel_end = array_type->data.array.len; |
| ... | @@ -24145,7 +24144,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24145,7 +24144,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24145 | } | 24144 | } |
| 24146 | } else if (array_type->id == ZigTypeIdPointer) { | 24145 | } else if (array_type->id == ZigTypeIdPointer) { |
| 24147 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); | 24146 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); |
| 24148 | parent_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24147 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24149 | if (parent_ptr == nullptr) | 24148 | if (parent_ptr == nullptr) |
| 24150 | return ira->codegen->invalid_instruction; | 24149 | return ira->codegen->invalid_instruction; |
| 24151 | | 24150 | |
| ... | @@ -24193,7 +24192,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24193,7 +24192,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24193 | zig_panic("TODO slice of null ptr"); | 24192 | zig_panic("TODO slice of null ptr"); |
| 24194 | } | 24193 | } |
| 24195 | } else if (is_slice(array_type)) { | 24194 | } else if (is_slice(array_type)) { |
| 24196 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); | 24195 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); |
| 24197 | if (slice_ptr == nullptr) | 24196 | if (slice_ptr == nullptr) |
| 24198 | return ira->codegen->invalid_instruction; | 24197 | return ira->codegen->invalid_instruction; |
| 24199 | | 24198 | |
| ... | @@ -24279,7 +24278,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24279,7 +24278,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24279 | } | 24278 | } |
| 24280 | | 24279 | |
| 24281 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 24280 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 24282 | ZigValue *out_val = &result->value; | 24281 | ZigValue *out_val = result->value; |
| 24283 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); | 24282 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 24284 | | 24283 | |
| 24285 | ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; | 24284 | ZigValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; |
| ... | @@ -24289,7 +24288,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24289,7 +24288,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24289 | bool is_const = slice_is_const(return_type); | 24288 | bool is_const = slice_is_const(return_type); |
| 24290 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); | 24289 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); |
| 24291 | if (array_type->id == ZigTypeIdArray) { | 24290 | if (array_type->id == ZigTypeIdArray) { |
| 24292 | ptr_val->data.x_ptr.mut = ptr_ptr->value.data.x_ptr.mut; | 24291 | ptr_val->data.x_ptr.mut = ptr_ptr->value->data.x_ptr.mut; |
| 24293 | } else if (is_slice(array_type)) { | 24292 | } else if (is_slice(array_type)) { |
| 24294 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; | 24293 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; |
| 24295 | } else if (array_type->id == ZigTypeIdPointer) { | 24294 | } else if (array_type->id == ZigTypeIdPointer) { |
| ... | @@ -24337,7 +24336,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24337,7 +24336,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24337 | | 24336 | |
| 24338 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 24337 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 24339 | return_type, nullptr, true, false, true); | 24338 | return_type, nullptr, true, false, true); |
| 24340 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { | 24339 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 24341 | return result_loc; | 24340 | return result_loc; |
| 24342 | } | 24341 | } |
| 24343 | return ir_build_slice_gen(ira, &instruction->base, return_type, | 24342 | return ir_build_slice_gen(ira, &instruction->base, return_type, |
| ... | @@ -24347,7 +24346,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -24347,7 +24346,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 24347 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { | 24346 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { |
| 24348 | Error err; | 24347 | Error err; |
| 24349 | IrInstruction *container = instruction->container->child; | 24348 | IrInstruction *container = instruction->container->child; |
| 24350 | if (type_is_invalid(container->value.type)) | 24349 | if (type_is_invalid(container->value->type)) |
| 24351 | return ira->codegen->invalid_instruction; | 24350 | return ira->codegen->invalid_instruction; |
| 24352 | ZigType *container_type = ir_resolve_type(ira, container); | 24351 | ZigType *container_type = ir_resolve_type(ira, container); |
| 24353 | | 24352 | |
| ... | @@ -24448,7 +24447,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24448,7 +24447,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24448 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 24447 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 24449 | | 24448 | |
| 24450 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24449 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24451 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24450 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24452 | return result; | 24451 | return result; |
| 24453 | } else if (container_type->id == ZigTypeIdEnum) { | 24452 | } else if (container_type->id == ZigTypeIdEnum) { |
| 24454 | if (member_index >= container_type->data.enumeration.src_field_count) { | 24453 | if (member_index >= container_type->data.enumeration.src_field_count) { |
| ... | @@ -24460,7 +24459,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24460,7 +24459,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24460 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; | 24459 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; |
| 24461 | | 24460 | |
| 24462 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24461 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24463 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24462 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24464 | return result; | 24463 | return result; |
| 24465 | } else if (container_type->id == ZigTypeIdUnion) { | 24464 | } else if (container_type->id == ZigTypeIdUnion) { |
| 24466 | if (member_index >= container_type->data.unionation.src_field_count) { | 24465 | if (member_index >= container_type->data.unionation.src_field_count) { |
| ... | @@ -24472,7 +24471,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr | ... | @@ -24472,7 +24471,7 @@ static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstr |
| 24472 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 24471 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 24473 | | 24472 | |
| 24474 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24473 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); |
| 24475 | init_const_str_lit(ira->codegen, &result->value, field->name); | 24474 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 24476 | return result; | 24475 | return result; |
| 24477 | } else { | 24476 | } else { |
| 24478 | ir_add_error(ira, container_type_value, | 24477 | ir_add_error(ira, container_type_value, |
| ... | @@ -24512,21 +24511,21 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc | ... | @@ -24512,21 +24511,21 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc |
| 24512 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { | 24511 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { |
| 24513 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, | 24512 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, |
| 24514 | instruction->base.scope, instruction->base.source_node); | 24513 | instruction->base.scope, instruction->base.source_node); |
| 24515 | result->value.type = ira->codegen->builtin_types.entry_void; | 24514 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 24516 | return result; | 24515 | return result; |
| 24517 | } | 24516 | } |
| 24518 | | 24517 | |
| 24519 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { | 24518 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { |
| 24520 | IrInstruction *result = ir_build_return_address(&ira->new_irb, | 24519 | IrInstruction *result = ir_build_return_address(&ira->new_irb, |
| 24521 | instruction->base.scope, instruction->base.source_node); | 24520 | instruction->base.scope, instruction->base.source_node); |
| 24522 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24521 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24523 | return result; | 24522 | return result; |
| 24524 | } | 24523 | } |
| 24525 | | 24524 | |
| 24526 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { | 24525 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { |
| 24527 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, | 24526 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, |
| 24528 | instruction->base.scope, instruction->base.source_node); | 24527 | instruction->base.scope, instruction->base.source_node); |
| 24529 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24528 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24530 | return result; | 24529 | return result; |
| 24531 | } | 24530 | } |
| 24532 | | 24531 | |
| ... | @@ -24542,7 +24541,7 @@ static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInst | ... | @@ -24542,7 +24541,7 @@ static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInst |
| 24542 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); | 24541 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); |
| 24543 | | 24542 | |
| 24544 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); | 24543 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); |
| 24545 | result->value.type = ptr_frame_type; | 24544 | result->value->type = ptr_frame_type; |
| 24546 | return result; | 24545 | return result; |
| 24547 | } | 24546 | } |
| 24548 | | 24547 | |
| ... | @@ -24563,12 +24562,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru | ... | @@ -24563,12 +24562,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru |
| 24563 | | 24562 | |
| 24564 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { | 24563 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { |
| 24565 | IrInstruction *fn = instruction->fn->child; | 24564 | IrInstruction *fn = instruction->fn->child; |
| 24566 | if (type_is_invalid(fn->value.type)) | 24565 | if (type_is_invalid(fn->value->type)) |
| 24567 | return ira->codegen->invalid_instruction; | 24566 | return ira->codegen->invalid_instruction; |
| 24568 | | 24567 | |
| 24569 | if (fn->value.type->id != ZigTypeIdFn) { | 24568 | if (fn->value->type->id != ZigTypeIdFn) { |
| 24570 | ir_add_error(ira, fn, | 24569 | ir_add_error(ira, fn, |
| 24571 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value.type->name))); | 24570 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); |
| 24572 | return ira->codegen->invalid_instruction; | 24571 | return ira->codegen->invalid_instruction; |
| 24573 | } | 24572 | } |
| 24574 | | 24573 | |
| ... | @@ -24576,7 +24575,7 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru | ... | @@ -24576,7 +24575,7 @@ static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstru |
| 24576 | | 24575 | |
| 24577 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, | 24576 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, |
| 24578 | instruction->base.source_node, fn); | 24577 | instruction->base.source_node, fn); |
| 24579 | result->value.type = ira->codegen->builtin_types.entry_usize; | 24578 | result->value->type = ira->codegen->builtin_types.entry_usize; |
| 24580 | return result; | 24579 | return result; |
| 24581 | } | 24580 | } |
| 24582 | | 24581 | |
| ... | @@ -24587,11 +24586,11 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -24587,11 +24586,11 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 24587 | // field: []align(@alignOf(Node)) Node, | 24586 | // field: []align(@alignOf(Node)) Node, |
| 24588 | // }; | 24587 | // }; |
| 24589 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 24588 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); |
| 24590 | result->value.special = ConstValSpecialLazy; | 24589 | result->value->special = ConstValSpecialLazy; |
| 24591 | | 24590 | |
| 24592 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); | 24591 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); |
| 24593 | lazy_align_of->ira = ira; | 24592 | lazy_align_of->ira = ira; |
| 24594 | result->value.data.x_lazy = &lazy_align_of->base; | 24593 | result->value->data.x_lazy = &lazy_align_of->base; |
| 24595 | lazy_align_of->base.id = LazyValueIdAlignOf; | 24594 | lazy_align_of->base.id = LazyValueIdAlignOf; |
| 24596 | | 24595 | |
| 24597 | lazy_align_of->target_type = instruction->type_value->child; | 24596 | lazy_align_of->target_type = instruction->type_value->child; |
| ... | @@ -24605,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24605,7 +24604,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24605 | Error err; | 24604 | Error err; |
| 24606 | | 24605 | |
| 24607 | IrInstruction *type_value = instruction->type_value->child; | 24606 | IrInstruction *type_value = instruction->type_value->child; |
| 24608 | if (type_is_invalid(type_value->value.type)) | 24607 | if (type_is_invalid(type_value->value->type)) |
| 24609 | return ira->codegen->invalid_instruction; | 24608 | return ira->codegen->invalid_instruction; |
| 24610 | | 24609 | |
| 24611 | ZigType *dest_type = ir_resolve_type(ira, type_value); | 24610 | ZigType *dest_type = ir_resolve_type(ira, type_value); |
| ... | @@ -24619,15 +24618,15 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24619,15 +24618,15 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24619 | } | 24618 | } |
| 24620 | | 24619 | |
| 24621 | IrInstruction *op1 = instruction->op1->child; | 24620 | IrInstruction *op1 = instruction->op1->child; |
| 24622 | if (type_is_invalid(op1->value.type)) | 24621 | if (type_is_invalid(op1->value->type)) |
| 24623 | return ira->codegen->invalid_instruction; | 24622 | return ira->codegen->invalid_instruction; |
| 24624 | | 24623 | |
| 24625 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 24624 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 24626 | if (type_is_invalid(casted_op1->value.type)) | 24625 | if (type_is_invalid(casted_op1->value->type)) |
| 24627 | return ira->codegen->invalid_instruction; | 24626 | return ira->codegen->invalid_instruction; |
| 24628 | | 24627 | |
| 24629 | IrInstruction *op2 = instruction->op2->child; | 24628 | IrInstruction *op2 = instruction->op2->child; |
| 24630 | if (type_is_invalid(op2->value.type)) | 24629 | if (type_is_invalid(op2->value->type)) |
| 24631 | return ira->codegen->invalid_instruction; | 24630 | return ira->codegen->invalid_instruction; |
| 24632 | | 24631 | |
| 24633 | IrInstruction *casted_op2; | 24632 | IrInstruction *casted_op2; |
| ... | @@ -24638,20 +24637,20 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24638,20 +24637,20 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24638 | } else { | 24637 | } else { |
| 24639 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 24638 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 24640 | } | 24639 | } |
| 24641 | if (type_is_invalid(casted_op2->value.type)) | 24640 | if (type_is_invalid(casted_op2->value->type)) |
| 24642 | return ira->codegen->invalid_instruction; | 24641 | return ira->codegen->invalid_instruction; |
| 24643 | | 24642 | |
| 24644 | IrInstruction *result_ptr = instruction->result_ptr->child; | 24643 | IrInstruction *result_ptr = instruction->result_ptr->child; |
| 24645 | if (type_is_invalid(result_ptr->value.type)) | 24644 | if (type_is_invalid(result_ptr->value->type)) |
| 24646 | return ira->codegen->invalid_instruction; | 24645 | return ira->codegen->invalid_instruction; |
| 24647 | | 24646 | |
| 24648 | ZigType *expected_ptr_type; | 24647 | ZigType *expected_ptr_type; |
| 24649 | if (result_ptr->value.type->id == ZigTypeIdPointer) { | 24648 | if (result_ptr->value->type->id == ZigTypeIdPointer) { |
| 24650 | uint32_t alignment; | 24649 | uint32_t alignment; |
| 24651 | if ((err = resolve_ptr_align(ira, result_ptr->value.type, &alignment))) | 24650 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) |
| 24652 | return ira->codegen->invalid_instruction; | 24651 | return ira->codegen->invalid_instruction; |
| 24653 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, | 24652 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, |
| 24654 | false, result_ptr->value.type->data.pointer.is_volatile, | 24653 | false, result_ptr->value->type->data.pointer.is_volatile, |
| 24655 | PtrLenSingle, | 24654 | PtrLenSingle, |
| 24656 | alignment, 0, 0, false); | 24655 | alignment, 0, 0, false); |
| 24657 | } else { | 24656 | } else { |
| ... | @@ -24659,7 +24658,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24659,7 +24658,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24659 | } | 24658 | } |
| 24660 | | 24659 | |
| 24661 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | 24660 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 24662 | if (type_is_invalid(casted_result_ptr->value.type)) | 24661 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 24663 | return ira->codegen->invalid_instruction; | 24662 | return ira->codegen->invalid_instruction; |
| 24664 | | 24663 | |
| 24665 | if (instr_is_comptime(casted_op1) && | 24664 | if (instr_is_comptime(casted_op1) && |
| ... | @@ -24716,7 +24715,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -24716,7 +24715,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24716 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, | 24715 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, |
| 24717 | instruction->base.scope, instruction->base.source_node, | 24716 | instruction->base.scope, instruction->base.source_node, |
| 24718 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); | 24717 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); |
| 24719 | result->value.type = ira->codegen->builtin_types.entry_bool; | 24718 | result->value->type = ira->codegen->builtin_types.entry_bool; |
| 24720 | return result; | 24719 | return result; |
| 24721 | } | 24720 | } |
| 24722 | | 24721 | |
| ... | @@ -24749,7 +24748,7 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z | ... | @@ -24749,7 +24748,7 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z |
| 24749 | | 24748 | |
| 24750 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { | 24749 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { |
| 24751 | IrInstruction *type_value = instruction->type_value->child; | 24750 | IrInstruction *type_value = instruction->type_value->child; |
| 24752 | if (type_is_invalid(type_value->value.type)) | 24751 | if (type_is_invalid(type_value->value->type)) |
| 24753 | return ira->codegen->invalid_instruction; | 24752 | return ira->codegen->invalid_instruction; |
| 24754 | | 24753 | |
| 24755 | ZigType *expr_type = ir_resolve_type(ira, type_value); | 24754 | ZigType *expr_type = ir_resolve_type(ira, type_value); |
| ... | @@ -24765,27 +24764,27 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24765,27 +24764,27 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24765 | } | 24764 | } |
| 24766 | | 24765 | |
| 24767 | IrInstruction *op1 = instruction->op1->child; | 24766 | IrInstruction *op1 = instruction->op1->child; |
| 24768 | if (type_is_invalid(op1->value.type)) | 24767 | if (type_is_invalid(op1->value->type)) |
| 24769 | return ira->codegen->invalid_instruction; | 24768 | return ira->codegen->invalid_instruction; |
| 24770 | | 24769 | |
| 24771 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | 24770 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); |
| 24772 | if (type_is_invalid(casted_op1->value.type)) | 24771 | if (type_is_invalid(casted_op1->value->type)) |
| 24773 | return ira->codegen->invalid_instruction; | 24772 | return ira->codegen->invalid_instruction; |
| 24774 | | 24773 | |
| 24775 | IrInstruction *op2 = instruction->op2->child; | 24774 | IrInstruction *op2 = instruction->op2->child; |
| 24776 | if (type_is_invalid(op2->value.type)) | 24775 | if (type_is_invalid(op2->value->type)) |
| 24777 | return ira->codegen->invalid_instruction; | 24776 | return ira->codegen->invalid_instruction; |
| 24778 | | 24777 | |
| 24779 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | 24778 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); |
| 24780 | if (type_is_invalid(casted_op2->value.type)) | 24779 | if (type_is_invalid(casted_op2->value->type)) |
| 24781 | return ira->codegen->invalid_instruction; | 24780 | return ira->codegen->invalid_instruction; |
| 24782 | | 24781 | |
| 24783 | IrInstruction *op3 = instruction->op3->child; | 24782 | IrInstruction *op3 = instruction->op3->child; |
| 24784 | if (type_is_invalid(op3->value.type)) | 24783 | if (type_is_invalid(op3->value->type)) |
| 24785 | return ira->codegen->invalid_instruction; | 24784 | return ira->codegen->invalid_instruction; |
| 24786 | | 24785 | |
| 24787 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | 24786 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); |
| 24788 | if (type_is_invalid(casted_op3->value.type)) | 24787 | if (type_is_invalid(casted_op3->value->type)) |
| 24789 | return ira->codegen->invalid_instruction; | 24788 | return ira->codegen->invalid_instruction; |
| 24790 | | 24789 | |
| 24791 | if (instr_is_comptime(casted_op1) && | 24790 | if (instr_is_comptime(casted_op1) && |
| ... | @@ -24802,7 +24801,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24802,7 +24801,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24802 | return ira->codegen->invalid_instruction; | 24801 | return ira->codegen->invalid_instruction; |
| 24803 | | 24802 | |
| 24804 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 24803 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 24805 | ZigValue *out_val = &result->value; | 24804 | ZigValue *out_val = result->value; |
| 24806 | | 24805 | |
| 24807 | if (expr_type->id == ZigTypeIdVector) { | 24806 | if (expr_type->id == ZigTypeIdVector) { |
| 24808 | expand_undef_array(ira->codegen, op1_const); | 24807 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -24835,13 +24834,13 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -24835,13 +24834,13 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24835 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, | 24834 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, |
| 24836 | instruction->base.scope, instruction->base.source_node, | 24835 | instruction->base.scope, instruction->base.source_node, |
| 24837 | type_value, casted_op1, casted_op2, casted_op3); | 24836 | type_value, casted_op1, casted_op2, casted_op3); |
| 24838 | result->value.type = expr_type; | 24837 | result->value->type = expr_type; |
| 24839 | return result; | 24838 | return result; |
| 24840 | } | 24839 | } |
| 24841 | | 24840 | |
| 24842 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { | 24841 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { |
| 24843 | IrInstruction *base_ptr = instruction->base_ptr->child; | 24842 | IrInstruction *base_ptr = instruction->base_ptr->child; |
| 24844 | if (type_is_invalid(base_ptr->value.type)) | 24843 | if (type_is_invalid(base_ptr->value->type)) |
| 24845 | return ira->codegen->invalid_instruction; | 24844 | return ira->codegen->invalid_instruction; |
| 24846 | | 24845 | |
| 24847 | IrInstruction *value; | 24846 | IrInstruction *value; |
| ... | @@ -24851,7 +24850,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct | ... | @@ -24851,7 +24850,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 24851 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); | 24850 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); |
| 24852 | } | 24851 | } |
| 24853 | | 24852 | |
| 24854 | ZigType *type_entry = value->value.type; | 24853 | ZigType *type_entry = value->value->type; |
| 24855 | if (type_is_invalid(type_entry)) | 24854 | if (type_is_invalid(type_entry)) |
| 24856 | return ira->codegen->invalid_instruction; | 24855 | return ira->codegen->invalid_instruction; |
| 24857 | if (type_entry->id == ZigTypeIdErrorUnion) { | 24856 | if (type_entry->id == ZigTypeIdErrorUnion) { |
| ... | @@ -24890,7 +24889,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct | ... | @@ -24890,7 +24889,7 @@ static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruct |
| 24890 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 24889 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, |
| 24891 | IrInstruction *base_ptr, bool initializing) | 24890 | IrInstruction *base_ptr, bool initializing) |
| 24892 | { | 24891 | { |
| 24893 | ZigType *ptr_type = base_ptr->value.type; | 24892 | ZigType *ptr_type = base_ptr->value->type; |
| 24894 | | 24893 | |
| 24895 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 24894 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 24896 | assert(ptr_type->id == ZigTypeIdPointer); | 24895 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -24946,12 +24945,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24946,12 +24945,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24946 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 24945 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 24947 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, | 24946 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, |
| 24948 | source_instr->source_node, base_ptr); | 24947 | source_instr->source_node, base_ptr); |
| 24949 | result->value.type = result_type; | 24948 | result->value->type = result_type; |
| 24950 | result->value.special = ConstValSpecialStatic; | 24949 | result->value->special = ConstValSpecialStatic; |
| 24951 | } else { | 24950 | } else { |
| 24952 | result = ir_const(ira, source_instr, result_type); | 24951 | result = ir_const(ira, source_instr, result_type); |
| 24953 | } | 24952 | } |
| 24954 | ZigValue *const_val = &result->value; | 24953 | ZigValue *const_val = result->value; |
| 24955 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; | 24954 | const_val->data.x_ptr.special = ConstPtrSpecialBaseErrorUnionCode; |
| 24956 | const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val; | 24955 | const_val->data.x_ptr.data.base_err_union_code.err_union_val = err_union_val; |
| 24957 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 24956 | const_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| ... | @@ -24961,7 +24960,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -24961,7 +24960,7 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 24961 | | 24960 | |
| 24962 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, | 24961 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, |
| 24963 | source_instr->scope, source_instr->source_node, base_ptr); | 24962 | source_instr->scope, source_instr->source_node, base_ptr); |
| 24964 | result->value.type = result_type; | 24963 | result->value->type = result_type; |
| 24965 | return result; | 24964 | return result; |
| 24966 | } | 24965 | } |
| 24967 | | 24966 | |
| ... | @@ -24969,7 +24968,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | ... | @@ -24969,7 +24968,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 24969 | IrInstructionUnwrapErrCode *instruction) | 24968 | IrInstructionUnwrapErrCode *instruction) |
| 24970 | { | 24969 | { |
| 24971 | IrInstruction *base_ptr = instruction->err_union_ptr->child; | 24970 | IrInstruction *base_ptr = instruction->err_union_ptr->child; |
| 24972 | if (type_is_invalid(base_ptr->value.type)) | 24971 | if (type_is_invalid(base_ptr->value->type)) |
| 24973 | return ira->codegen->invalid_instruction; | 24972 | return ira->codegen->invalid_instruction; |
| 24974 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); | 24973 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); |
| 24975 | } | 24974 | } |
| ... | @@ -24977,7 +24976,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | ... | @@ -24977,7 +24976,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 24977 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 24976 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, |
| 24978 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 24977 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) |
| 24979 | { | 24978 | { |
| 24980 | ZigType *ptr_type = base_ptr->value.type; | 24979 | ZigType *ptr_type = base_ptr->value->type; |
| 24981 | | 24980 | |
| 24982 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 24981 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 24983 | assert(ptr_type->id == ZigTypeIdPointer); | 24982 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -25036,14 +25035,14 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25036,14 +25035,14 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25036 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 25035 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 25037 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 25036 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, |
| 25038 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 25037 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 25039 | result->value.type = result_type; | 25038 | result->value->type = result_type; |
| 25040 | result->value.special = ConstValSpecialStatic; | 25039 | result->value->special = ConstValSpecialStatic; |
| 25041 | } else { | 25040 | } else { |
| 25042 | result = ir_const(ira, source_instr, result_type); | 25041 | result = ir_const(ira, source_instr, result_type); |
| 25043 | } | 25042 | } |
| 25044 | result->value.data.x_ptr.special = ConstPtrSpecialRef; | 25043 | result->value->data.x_ptr.special = ConstPtrSpecialRef; |
| 25045 | result->value.data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload; | 25044 | result->value->data.x_ptr.data.ref.pointee = err_union_val->data.x_err_union.payload; |
| 25046 | result->value.data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 25045 | result->value->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 25047 | return result; | 25046 | return result; |
| 25048 | } | 25047 | } |
| 25049 | } | 25048 | } |
| ... | @@ -25051,7 +25050,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -25051,7 +25050,7 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 25051 | | 25050 | |
| 25052 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 25051 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, |
| 25053 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 25052 | source_instr->source_node, base_ptr, safety_check_on, initializing); |
| 25054 | result->value.type = result_type; | 25053 | result->value->type = result_type; |
| 25055 | return result; | 25054 | return result; |
| 25056 | } | 25055 | } |
| 25057 | | 25056 | |
| ... | @@ -25060,7 +25059,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | ... | @@ -25060,7 +25059,7 @@ static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 25060 | { | 25059 | { |
| 25061 | assert(instruction->value->child); | 25060 | assert(instruction->value->child); |
| 25062 | IrInstruction *value = instruction->value->child; | 25061 | IrInstruction *value = instruction->value->child; |
| 25063 | if (type_is_invalid(value->value.type)) | 25062 | if (type_is_invalid(value->value->type)) |
| 25064 | return ira->codegen->invalid_instruction; | 25063 | return ira->codegen->invalid_instruction; |
| 25065 | | 25064 | |
| 25066 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); | 25065 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); |
| ... | @@ -25071,11 +25070,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25071,11 +25070,11 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25071 | assert(proto_node->type == NodeTypeFnProto); | 25070 | assert(proto_node->type == NodeTypeFnProto); |
| 25072 | | 25071 | |
| 25073 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 25072 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 25074 | result->value.special = ConstValSpecialLazy; | 25073 | result->value->special = ConstValSpecialLazy; |
| 25075 | | 25074 | |
| 25076 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); | 25075 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); |
| 25077 | lazy_fn_type->ira = ira; | 25076 | lazy_fn_type->ira = ira; |
| 25078 | result->value.data.x_lazy = &lazy_fn_type->base; | 25077 | result->value->data.x_lazy = &lazy_fn_type->base; |
| 25079 | lazy_fn_type->base.id = LazyValueIdFnType; | 25078 | lazy_fn_type->base.id = LazyValueIdFnType; |
| 25080 | | 25079 | |
| 25081 | if (proto_node->data.fn_proto.auto_err_set) { | 25080 | if (proto_node->data.fn_proto.auto_err_set) { |
| ... | @@ -25110,7 +25109,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25110,7 +25109,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25110 | } | 25109 | } |
| 25111 | | 25110 | |
| 25112 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; | 25111 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; |
| 25113 | if (type_is_invalid(param_type_value->value.type)) | 25112 | if (type_is_invalid(param_type_value->value->type)) |
| 25114 | return ira->codegen->invalid_instruction; | 25113 | return ira->codegen->invalid_instruction; |
| 25115 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) | 25114 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| 25116 | return ira->codegen->invalid_instruction; | 25115 | return ira->codegen->invalid_instruction; |
| ... | @@ -25132,7 +25131,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -25132,7 +25131,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 25132 | | 25131 | |
| 25133 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { | 25132 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { |
| 25134 | IrInstruction *value = instruction->value->child; | 25133 | IrInstruction *value = instruction->value->child; |
| 25135 | if (type_is_invalid(value->value.type)) | 25134 | if (type_is_invalid(value->value->type)) |
| 25136 | return ira->codegen->invalid_instruction; | 25135 | return ira->codegen->invalid_instruction; |
| 25137 | | 25136 | |
| 25138 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); | 25137 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); |
| ... | @@ -25142,7 +25141,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25142,7 +25141,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25142 | IrInstructionCheckSwitchProngs *instruction) | 25141 | IrInstructionCheckSwitchProngs *instruction) |
| 25143 | { | 25142 | { |
| 25144 | IrInstruction *target_value = instruction->target_value->child; | 25143 | IrInstruction *target_value = instruction->target_value->child; |
| 25145 | ZigType *switch_type = target_value->value.type; | 25144 | ZigType *switch_type = target_value->value->type; |
| 25146 | if (type_is_invalid(switch_type)) | 25145 | if (type_is_invalid(switch_type)) |
| 25147 | return ira->codegen->invalid_instruction; | 25146 | return ira->codegen->invalid_instruction; |
| 25148 | | 25147 | |
| ... | @@ -25154,25 +25153,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25154,25 +25153,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25154 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25153 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25155 | | 25154 | |
| 25156 | IrInstruction *start_value_uncasted = range->start->child; | 25155 | IrInstruction *start_value_uncasted = range->start->child; |
| 25157 | if (type_is_invalid(start_value_uncasted->value.type)) | 25156 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 25158 | return ira->codegen->invalid_instruction; | 25157 | return ira->codegen->invalid_instruction; |
| 25159 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 25158 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25160 | if (type_is_invalid(start_value->value.type)) | 25159 | if (type_is_invalid(start_value->value->type)) |
| 25161 | return ira->codegen->invalid_instruction; | 25160 | return ira->codegen->invalid_instruction; |
| 25162 | | 25161 | |
| 25163 | IrInstruction *end_value_uncasted = range->end->child; | 25162 | IrInstruction *end_value_uncasted = range->end->child; |
| 25164 | if (type_is_invalid(end_value_uncasted->value.type)) | 25163 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 25165 | return ira->codegen->invalid_instruction; | 25164 | return ira->codegen->invalid_instruction; |
| 25166 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 25165 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25167 | if (type_is_invalid(end_value->value.type)) | 25166 | if (type_is_invalid(end_value->value->type)) |
| 25168 | return ira->codegen->invalid_instruction; | 25167 | return ira->codegen->invalid_instruction; |
| 25169 | | 25168 | |
| 25170 | BigInt start_index; | 25169 | BigInt start_index; |
| 25171 | bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag); | 25170 | bigint_init_bigint(&start_index, &start_value->value->data.x_enum_tag); |
| 25172 | | 25171 | |
| 25173 | assert(end_value->value.type->id == ZigTypeIdEnum); | 25172 | assert(end_value->value->type->id == ZigTypeIdEnum); |
| 25174 | BigInt end_index; | 25173 | BigInt end_index; |
| 25175 | bigint_init_bigint(&end_index, &end_value->value.data.x_enum_tag); | 25174 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); |
| 25176 | | 25175 | |
| 25177 | BigInt field_index; | 25176 | BigInt field_index; |
| 25178 | bigint_init_bigint(&field_index, &start_index); | 25177 | bigint_init_bigint(&field_index, &start_index); |
| ... | @@ -25218,24 +25217,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25218,24 +25217,24 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25218 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25217 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25219 | | 25218 | |
| 25220 | IrInstruction *start_value_uncasted = range->start->child; | 25219 | IrInstruction *start_value_uncasted = range->start->child; |
| 25221 | if (type_is_invalid(start_value_uncasted->value.type)) | 25220 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 25222 | return ira->codegen->invalid_instruction; | 25221 | return ira->codegen->invalid_instruction; |
| 25223 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 25222 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25224 | if (type_is_invalid(start_value->value.type)) | 25223 | if (type_is_invalid(start_value->value->type)) |
| 25225 | return ira->codegen->invalid_instruction; | 25224 | return ira->codegen->invalid_instruction; |
| 25226 | | 25225 | |
| 25227 | IrInstruction *end_value_uncasted = range->end->child; | 25226 | IrInstruction *end_value_uncasted = range->end->child; |
| 25228 | if (type_is_invalid(end_value_uncasted->value.type)) | 25227 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 25229 | return ira->codegen->invalid_instruction; | 25228 | return ira->codegen->invalid_instruction; |
| 25230 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 25229 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25231 | if (type_is_invalid(end_value->value.type)) | 25230 | if (type_is_invalid(end_value->value->type)) |
| 25232 | return ira->codegen->invalid_instruction; | 25231 | return ira->codegen->invalid_instruction; |
| 25233 | | 25232 | |
| 25234 | ir_assert(start_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); | 25233 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); |
| 25235 | uint32_t start_index = start_value->value.data.x_err_set->value; | 25234 | uint32_t start_index = start_value->value->data.x_err_set->value; |
| 25236 | | 25235 | |
| 25237 | ir_assert(end_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); | 25236 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); |
| 25238 | uint32_t end_index = end_value->value.data.x_err_set->value; | 25237 | uint32_t end_index = end_value->value->data.x_err_set->value; |
| 25239 | | 25238 | |
| 25240 | if (start_index != end_index) { | 25239 | if (start_index != end_index) { |
| 25241 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); | 25240 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); |
| ... | @@ -25276,17 +25275,17 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25276,17 +25275,17 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25276 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 25275 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 25277 | | 25276 | |
| 25278 | IrInstruction *start_value = range->start->child; | 25277 | IrInstruction *start_value = range->start->child; |
| 25279 | if (type_is_invalid(start_value->value.type)) | 25278 | if (type_is_invalid(start_value->value->type)) |
| 25280 | return ira->codegen->invalid_instruction; | 25279 | return ira->codegen->invalid_instruction; |
| 25281 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | 25280 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); |
| 25282 | if (type_is_invalid(casted_start_value->value.type)) | 25281 | if (type_is_invalid(casted_start_value->value->type)) |
| 25283 | return ira->codegen->invalid_instruction; | 25282 | return ira->codegen->invalid_instruction; |
| 25284 | | 25283 | |
| 25285 | IrInstruction *end_value = range->end->child; | 25284 | IrInstruction *end_value = range->end->child; |
| 25286 | if (type_is_invalid(end_value->value.type)) | 25285 | if (type_is_invalid(end_value->value->type)) |
| 25287 | return ira->codegen->invalid_instruction; | 25286 | return ira->codegen->invalid_instruction; |
| 25288 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | 25287 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); |
| 25289 | if (type_is_invalid(casted_end_value->value.type)) | 25288 | if (type_is_invalid(casted_end_value->value->type)) |
| 25290 | return ira->codegen->invalid_instruction; | 25289 | return ira->codegen->invalid_instruction; |
| 25291 | | 25290 | |
| 25292 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); | 25291 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); |
| ... | @@ -25326,7 +25325,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -25326,7 +25325,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25326 | IrInstruction *value = range->start->child; | 25325 | IrInstruction *value = range->start->child; |
| 25327 | | 25326 | |
| 25328 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); | 25327 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); |
| 25329 | if (type_is_invalid(casted_value->value.type)) | 25328 | if (type_is_invalid(casted_value->value->type)) |
| 25330 | return ira->codegen->invalid_instruction; | 25329 | return ira->codegen->invalid_instruction; |
| 25331 | | 25330 | |
| 25332 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); | 25331 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | @@ -25362,7 +25361,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * | ... | @@ -25362,7 +25361,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * |
| 25362 | IrInstructionCheckStatementIsVoid *instruction) | 25361 | IrInstructionCheckStatementIsVoid *instruction) |
| 25363 | { | 25362 | { |
| 25364 | IrInstruction *statement_value = instruction->statement_value->child; | 25363 | IrInstruction *statement_value = instruction->statement_value->child; |
| 25365 | ZigType *statement_type = statement_value->value.type; | 25364 | ZigType *statement_type = statement_value->value->type; |
| 25366 | if (type_is_invalid(statement_type)) | 25365 | if (type_is_invalid(statement_type)) |
| 25367 | return ira->codegen->invalid_instruction; | 25366 | return ira->codegen->invalid_instruction; |
| 25368 | | 25367 | |
| ... | @@ -25375,7 +25374,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * | ... | @@ -25375,7 +25374,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * |
| 25375 | | 25374 | |
| 25376 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { | 25375 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { |
| 25377 | IrInstruction *msg = instruction->msg->child; | 25376 | IrInstruction *msg = instruction->msg->child; |
| 25378 | if (type_is_invalid(msg->value.type)) | 25377 | if (type_is_invalid(msg->value->type)) |
| 25379 | return ir_unreach_error(ira); | 25378 | return ir_unreach_error(ira); |
| 25380 | | 25379 | |
| 25381 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { | 25380 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { |
| ... | @@ -25387,7 +25386,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction | ... | @@ -25387,7 +25386,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction |
| 25387 | true, false, PtrLenUnknown, 0, 0, 0, false); | 25386 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 25388 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 25387 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 25389 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); | 25388 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); |
| 25390 | if (type_is_invalid(casted_msg->value.type)) | 25389 | if (type_is_invalid(casted_msg->value->type)) |
| 25391 | return ir_unreach_error(ira); | 25390 | return ir_unreach_error(ira); |
| 25392 | | 25391 | |
| 25393 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, | 25392 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, |
| ... | @@ -25398,7 +25397,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction | ... | @@ -25398,7 +25397,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction |
| 25398 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { | 25397 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { |
| 25399 | Error err; | 25398 | Error err; |
| 25400 | | 25399 | |
| 25401 | ZigType *target_type = target->value.type; | 25400 | ZigType *target_type = target->value->type; |
| 25402 | assert(!type_is_invalid(target_type)); | 25401 | assert(!type_is_invalid(target_type)); |
| 25403 | | 25402 | |
| 25404 | ZigType *result_type; | 25403 | ZigType *result_type; |
| ... | @@ -25457,8 +25456,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25457,8 +25456,8 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25457 | } | 25456 | } |
| 25458 | | 25457 | |
| 25459 | IrInstruction *result = ir_const(ira, target, result_type); | 25458 | IrInstruction *result = ir_const(ira, target, result_type); |
| 25460 | copy_const_val(&result->value, val, true); | 25459 | copy_const_val(result->value, val, true); |
| 25461 | result->value.type = result_type; | 25460 | result->value->type = result_type; |
| 25462 | return result; | 25461 | return result; |
| 25463 | } | 25462 | } |
| 25464 | | 25463 | |
| ... | @@ -25468,7 +25467,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -25468,7 +25467,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 25468 | } else { | 25467 | } else { |
| 25469 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); | 25468 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); |
| 25470 | } | 25469 | } |
| 25471 | result->value.type = result_type; | 25470 | result->value->type = result_type; |
| 25472 | return result; | 25471 | return result; |
| 25473 | } | 25472 | } |
| 25474 | | 25473 | |
| ... | @@ -25477,7 +25476,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25477,7 +25476,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25477 | { | 25476 | { |
| 25478 | Error err; | 25477 | Error err; |
| 25479 | | 25478 | |
| 25480 | ZigType *src_type = ptr->value.type; | 25479 | ZigType *src_type = ptr->value->type; |
| 25481 | assert(!type_is_invalid(src_type)); | 25480 | assert(!type_is_invalid(src_type)); |
| 25482 | | 25481 | |
| 25483 | if (src_type == dest_type) { | 25482 | if (src_type == dest_type) { |
| ... | @@ -25531,7 +25530,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25531,7 +25530,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25531 | } | 25530 | } |
| 25532 | | 25531 | |
| 25533 | IrInstruction *result; | 25532 | IrInstruction *result; |
| 25534 | if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) { | 25533 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 25535 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 25534 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 25536 | | 25535 | |
| 25537 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 25536 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| ... | @@ -25539,8 +25538,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25539,8 +25538,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25539 | } else { | 25538 | } else { |
| 25540 | result = ir_const(ira, source_instr, dest_type); | 25539 | result = ir_const(ira, source_instr, dest_type); |
| 25541 | } | 25540 | } |
| 25542 | copy_const_val(&result->value, val, true); | 25541 | copy_const_val(result->value, val, true); |
| 25543 | result->value.type = dest_type; | 25542 | result->value->type = dest_type; |
| 25544 | | 25543 | |
| 25545 | // Keep the bigger alignment, it can only help- | 25544 | // Keep the bigger alignment, it can only help- |
| 25546 | // unless the target is zero bits. | 25545 | // unless the target is zero bits. |
| ... | @@ -25584,7 +25583,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25584,7 +25583,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25584 | IrInstruction *result; | 25583 | IrInstruction *result; |
| 25585 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { | 25584 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { |
| 25586 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); | 25585 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); |
| 25587 | if (type_is_invalid(result->value.type)) | 25586 | if (type_is_invalid(result->value->type)) |
| 25588 | return ira->codegen->invalid_instruction; | 25587 | return ira->codegen->invalid_instruction; |
| 25589 | } else { | 25588 | } else { |
| 25590 | result = casted_ptr; | 25589 | result = casted_ptr; |
| ... | @@ -25599,7 +25598,7 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct | ... | @@ -25599,7 +25598,7 @@ static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruct |
| 25599 | return ira->codegen->invalid_instruction; | 25598 | return ira->codegen->invalid_instruction; |
| 25600 | | 25599 | |
| 25601 | IrInstruction *ptr = instruction->ptr->child; | 25600 | IrInstruction *ptr = instruction->ptr->child; |
| 25602 | ZigType *src_type = ptr->value.type; | 25601 | ZigType *src_type = ptr->value->type; |
| 25603 | if (type_is_invalid(src_type)) | 25602 | if (type_is_invalid(src_type)) |
| 25604 | return ira->codegen->invalid_instruction; | 25603 | return ira->codegen->invalid_instruction; |
| 25605 | | 25604 | |
| ... | @@ -25941,7 +25940,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25941,7 +25940,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25941 | { | 25940 | { |
| 25942 | Error err; | 25941 | Error err; |
| 25943 | | 25942 | |
| 25944 | ZigType *src_type = value->value.type; | 25943 | ZigType *src_type = value->value->type; |
| 25945 | ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr); | 25944 | ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr); |
| 25946 | ir_assert(type_can_bit_cast(src_type), source_instr); | 25945 | ir_assert(type_can_bit_cast(src_type), source_instr); |
| 25947 | ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr); | 25946 | ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr); |
| ... | @@ -25982,7 +25981,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -25982,7 +25981,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 25982 | IrInstruction *result = ir_const(ira, source_instr, dest_type); | 25981 | IrInstruction *result = ir_const(ira, source_instr, dest_type); |
| 25983 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); | 25982 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); |
| 25984 | buf_write_value_bytes(ira->codegen, buf, val); | 25983 | buf_write_value_bytes(ira->codegen, buf, val); |
| 25985 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, &result->value))) | 25984 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) |
| 25986 | return ira->codegen->invalid_instruction; | 25985 | return ira->codegen->invalid_instruction; |
| 25987 | return result; | 25986 | return result; |
| 25988 | } | 25987 | } |
| ... | @@ -25997,7 +25996,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -25997,7 +25996,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 25997 | ir_assert(type_has_bits(ptr_type), source_instr); | 25996 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 25998 | | 25997 | |
| 25999 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | 25998 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 26000 | if (type_is_invalid(casted_int->value.type)) | 25999 | if (type_is_invalid(casted_int->value->type)) |
| 26001 | return ira->codegen->invalid_instruction; | 26000 | return ira->codegen->invalid_instruction; |
| 26002 | | 26001 | |
| 26003 | if (instr_is_comptime(casted_int)) { | 26002 | if (instr_is_comptime(casted_int)) { |
| ... | @@ -26013,15 +26012,15 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -26013,15 +26012,15 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 26013 | } | 26012 | } |
| 26014 | | 26013 | |
| 26015 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); | 26014 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); |
| 26016 | result->value.data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 26015 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 26017 | result->value.data.x_ptr.mut = ConstPtrMutRuntimeVar; | 26016 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 26018 | result->value.data.x_ptr.data.hard_coded_addr.addr = addr; | 26017 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; |
| 26019 | return result; | 26018 | return result; |
| 26020 | } | 26019 | } |
| 26021 | | 26020 | |
| 26022 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, | 26021 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, |
| 26023 | source_instr->source_node, nullptr, casted_int); | 26022 | source_instr->source_node, nullptr, casted_int); |
| 26024 | result->value.type = ptr_type; | 26023 | result->value->type = ptr_type; |
| 26025 | return result; | 26024 | return result; |
| 26026 | } | 26025 | } |
| 26027 | | 26026 | |
| ... | @@ -26048,7 +26047,7 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru | ... | @@ -26048,7 +26047,7 @@ static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstru |
| 26048 | | 26047 | |
| 26049 | | 26048 | |
| 26050 | IrInstruction *target = instruction->target->child; | 26049 | IrInstruction *target = instruction->target->child; |
| 26051 | if (type_is_invalid(target->value.type)) | 26050 | if (type_is_invalid(target->value->type)) |
| 26052 | return ira->codegen->invalid_instruction; | 26051 | return ira->codegen->invalid_instruction; |
| 26053 | | 26052 | |
| 26054 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); | 26053 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); |
| ... | @@ -26058,7 +26057,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | ... | @@ -26058,7 +26057,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 26058 | IrInstructionDeclRef *instruction) | 26057 | IrInstructionDeclRef *instruction) |
| 26059 | { | 26058 | { |
| 26060 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); | 26059 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); |
| 26061 | if (type_is_invalid(ref_instruction->value.type)) { | 26060 | if (type_is_invalid(ref_instruction->value->type)) { |
| 26062 | return ira->codegen->invalid_instruction; | 26061 | return ira->codegen->invalid_instruction; |
| 26063 | } | 26062 | } |
| 26064 | | 26063 | |
| ... | @@ -26072,21 +26071,21 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | ... | @@ -26072,21 +26071,21 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 26072 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { | 26071 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { |
| 26073 | Error err; | 26072 | Error err; |
| 26074 | IrInstruction *target = instruction->target->child; | 26073 | IrInstruction *target = instruction->target->child; |
| 26075 | if (type_is_invalid(target->value.type)) | 26074 | if (type_is_invalid(target->value->type)) |
| 26076 | return ira->codegen->invalid_instruction; | 26075 | return ira->codegen->invalid_instruction; |
| 26077 | | 26076 | |
| 26078 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 26077 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 26079 | | 26078 | |
| 26080 | // We check size explicitly so we can use get_src_ptr_type here. | 26079 | // We check size explicitly so we can use get_src_ptr_type here. |
| 26081 | if (get_src_ptr_type(target->value.type) == nullptr) { | 26080 | if (get_src_ptr_type(target->value->type) == nullptr) { |
| 26082 | ir_add_error(ira, target, | 26081 | ir_add_error(ira, target, |
| 26083 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name))); | 26082 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); |
| 26084 | return ira->codegen->invalid_instruction; | 26083 | return ira->codegen->invalid_instruction; |
| 26085 | } | 26084 | } |
| 26086 | | 26085 | |
| 26087 | if ((err = type_resolve(ira->codegen, target->value.type, ResolveStatusZeroBitsKnown))) | 26086 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 26088 | return ira->codegen->invalid_instruction; | 26087 | return ira->codegen->invalid_instruction; |
| 26089 | if (!type_has_bits(target->value.type)) { | 26088 | if (!type_has_bits(target->value->type)) { |
| 26090 | ir_add_error(ira, target, | 26089 | ir_add_error(ira, target, |
| 26091 | buf_sprintf("pointer to size 0 type has no address")); | 26090 | buf_sprintf("pointer to size 0 type has no address")); |
| 26092 | return ira->codegen->invalid_instruction; | 26091 | return ira->codegen->invalid_instruction; |
| ... | @@ -26098,25 +26097,25 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -26098,25 +26097,25 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 26098 | return ira->codegen->invalid_instruction; | 26097 | return ira->codegen->invalid_instruction; |
| 26099 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 26098 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 26100 | IrInstruction *result = ir_const(ira, &instruction->base, usize); | 26099 | IrInstruction *result = ir_const(ira, &instruction->base, usize); |
| 26101 | bigint_init_unsigned(&result->value.data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); | 26100 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| 26102 | result->value.type = usize; | 26101 | result->value->type = usize; |
| 26103 | return result; | 26102 | return result; |
| 26104 | } | 26103 | } |
| 26105 | } | 26104 | } |
| 26106 | | 26105 | |
| 26107 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, | 26106 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, |
| 26108 | instruction->base.source_node, target); | 26107 | instruction->base.source_node, target); |
| 26109 | result->value.type = usize; | 26108 | result->value->type = usize; |
| 26110 | return result; | 26109 | return result; |
| 26111 | } | 26110 | } |
| 26112 | | 26111 | |
| 26113 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 26112 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { |
| 26114 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 26113 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); |
| 26115 | result->value.special = ConstValSpecialLazy; | 26114 | result->value->special = ConstValSpecialLazy; |
| 26116 | | 26115 | |
| 26117 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); | 26116 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); |
| 26118 | lazy_ptr_type->ira = ira; | 26117 | lazy_ptr_type->ira = ira; |
| 26119 | result->value.data.x_lazy = &lazy_ptr_type->base; | 26118 | result->value->data.x_lazy = &lazy_ptr_type->base; |
| 26120 | lazy_ptr_type->base.id = LazyValueIdPtrType; | 26119 | lazy_ptr_type->base.id = LazyValueIdPtrType; |
| 26121 | | 26120 | |
| 26122 | if (instruction->sentinel != nullptr) { | 26121 | if (instruction->sentinel != nullptr) { |
| ... | @@ -26147,15 +26146,15 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -26147,15 +26146,15 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 26147 | | 26146 | |
| 26148 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { | 26147 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { |
| 26149 | IrInstruction *target = instruction->target->child; | 26148 | IrInstruction *target = instruction->target->child; |
| 26150 | if (type_is_invalid(target->value.type)) | 26149 | if (type_is_invalid(target->value->type)) |
| 26151 | return ira->codegen->invalid_instruction; | 26150 | return ira->codegen->invalid_instruction; |
| 26152 | | 26151 | |
| 26153 | ZigType *elem_type = nullptr; | 26152 | ZigType *elem_type = nullptr; |
| 26154 | if (is_slice(target->value.type)) { | 26153 | if (is_slice(target->value->type)) { |
| 26155 | ZigType *slice_ptr_type = target->value.type->data.structure.fields[slice_ptr_index]->type_entry; | 26154 | ZigType *slice_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 26156 | elem_type = slice_ptr_type->data.pointer.child_type; | 26155 | elem_type = slice_ptr_type->data.pointer.child_type; |
| 26157 | } else if (target->value.type->id == ZigTypeIdPointer) { | 26156 | } else if (target->value->type->id == ZigTypeIdPointer) { |
| 26158 | elem_type = target->value.type->data.pointer.child_type; | 26157 | elem_type = target->value->type->data.pointer.child_type; |
| 26159 | } | 26158 | } |
| 26160 | | 26159 | |
| 26161 | uint32_t align_bytes; | 26160 | uint32_t align_bytes; |
| ... | @@ -26164,7 +26163,7 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru | ... | @@ -26164,7 +26163,7 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru |
| 26164 | return ira->codegen->invalid_instruction; | 26163 | return ira->codegen->invalid_instruction; |
| 26165 | | 26164 | |
| 26166 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); | 26165 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); |
| 26167 | if (type_is_invalid(result->value.type)) | 26166 | if (type_is_invalid(result->value->type)) |
| 26168 | return ira->codegen->invalid_instruction; | 26167 | return ira->codegen->invalid_instruction; |
| 26169 | | 26168 | |
| 26170 | return result; | 26169 | return result; |
| ... | @@ -26350,13 +26349,13 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26350,13 +26349,13 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26350 | return ira->codegen->invalid_instruction; | 26349 | return ira->codegen->invalid_instruction; |
| 26351 | | 26350 | |
| 26352 | IrInstruction *ptr_inst = instruction->ptr->child; | 26351 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26353 | if (type_is_invalid(ptr_inst->value.type)) | 26352 | if (type_is_invalid(ptr_inst->value->type)) |
| 26354 | return ira->codegen->invalid_instruction; | 26353 | return ira->codegen->invalid_instruction; |
| 26355 | | 26354 | |
| 26356 | // TODO let this be volatile | 26355 | // TODO let this be volatile |
| 26357 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 26356 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26358 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26357 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26359 | if (type_is_invalid(casted_ptr->value.type)) | 26358 | if (type_is_invalid(casted_ptr->value->type)) |
| 26360 | return ira->codegen->invalid_instruction; | 26359 | return ira->codegen->invalid_instruction; |
| 26361 | | 26360 | |
| 26362 | AtomicRmwOp op; | 26361 | AtomicRmwOp op; |
| ... | @@ -26375,11 +26374,11 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26375,11 +26374,11 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26375 | } | 26374 | } |
| 26376 | | 26375 | |
| 26377 | IrInstruction *operand = instruction->operand->child; | 26376 | IrInstruction *operand = instruction->operand->child; |
| 26378 | if (type_is_invalid(operand->value.type)) | 26377 | if (type_is_invalid(operand->value->type)) |
| 26379 | return ira->codegen->invalid_instruction; | 26378 | return ira->codegen->invalid_instruction; |
| 26380 | | 26379 | |
| 26381 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); | 26380 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); |
| 26382 | if (type_is_invalid(casted_operand->value.type)) | 26381 | if (type_is_invalid(casted_operand->value->type)) |
| 26383 | return ira->codegen->invalid_instruction; | 26382 | return ira->codegen->invalid_instruction; |
| 26384 | | 26383 | |
| 26385 | AtomicOrder ordering; | 26384 | AtomicOrder ordering; |
| ... | @@ -26395,7 +26394,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26395,7 +26394,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26395 | } | 26394 | } |
| 26396 | } | 26395 | } |
| 26397 | | 26396 | |
| 26398 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar) | 26397 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) |
| 26399 | { | 26398 | { |
| 26400 | zig_panic("TODO compile-time execution of atomicRmw"); | 26399 | zig_panic("TODO compile-time execution of atomicRmw"); |
| 26401 | } | 26400 | } |
| ... | @@ -26403,7 +26402,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru | ... | @@ -26403,7 +26402,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26403 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, | 26402 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, |
| 26404 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, | 26403 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, |
| 26405 | op, ordering); | 26404 | op, ordering); |
| 26406 | result->value.type = operand_type; | 26405 | result->value->type = operand_type; |
| 26407 | return result; | 26406 | return result; |
| 26408 | } | 26407 | } |
| 26409 | | 26408 | |
| ... | @@ -26413,12 +26412,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -26413,12 +26412,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 26413 | return ira->codegen->invalid_instruction; | 26412 | return ira->codegen->invalid_instruction; |
| 26414 | | 26413 | |
| 26415 | IrInstruction *ptr_inst = instruction->ptr->child; | 26414 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26416 | if (type_is_invalid(ptr_inst->value.type)) | 26415 | if (type_is_invalid(ptr_inst->value->type)) |
| 26417 | return ira->codegen->invalid_instruction; | 26416 | return ira->codegen->invalid_instruction; |
| 26418 | | 26417 | |
| 26419 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); | 26418 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 26420 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26419 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26421 | if (type_is_invalid(casted_ptr->value.type)) | 26420 | if (type_is_invalid(casted_ptr->value->type)) |
| 26422 | return ira->codegen->invalid_instruction; | 26421 | return ira->codegen->invalid_instruction; |
| 26423 | | 26422 | |
| 26424 | AtomicOrder ordering; | 26423 | AtomicOrder ordering; |
| ... | @@ -26438,13 +26437,13 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -26438,13 +26437,13 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 26438 | | 26437 | |
| 26439 | if (instr_is_comptime(casted_ptr)) { | 26438 | if (instr_is_comptime(casted_ptr)) { |
| 26440 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); | 26439 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); |
| 26441 | ir_assert(result->value.type != nullptr, &instruction->base); | 26440 | ir_assert(result->value->type != nullptr, &instruction->base); |
| 26442 | return result; | 26441 | return result; |
| 26443 | } | 26442 | } |
| 26444 | | 26443 | |
| 26445 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, | 26444 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, |
| 26446 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); | 26445 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); |
| 26447 | result->value.type = operand_type; | 26446 | result->value->type = operand_type; |
| 26448 | return result; | 26447 | return result; |
| 26449 | } | 26448 | } |
| 26450 | | 26449 | |
| ... | @@ -26454,20 +26453,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst | ... | @@ -26454,20 +26453,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26454 | return ira->codegen->invalid_instruction; | 26453 | return ira->codegen->invalid_instruction; |
| 26455 | | 26454 | |
| 26456 | IrInstruction *ptr_inst = instruction->ptr->child; | 26455 | IrInstruction *ptr_inst = instruction->ptr->child; |
| 26457 | if (type_is_invalid(ptr_inst->value.type)) | 26456 | if (type_is_invalid(ptr_inst->value->type)) |
| 26458 | return ira->codegen->invalid_instruction; | 26457 | return ira->codegen->invalid_instruction; |
| 26459 | | 26458 | |
| 26460 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 26459 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26461 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 26460 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26462 | if (type_is_invalid(casted_ptr->value.type)) | 26461 | if (type_is_invalid(casted_ptr->value->type)) |
| 26463 | return ira->codegen->invalid_instruction; | 26462 | return ira->codegen->invalid_instruction; |
| 26464 | | 26463 | |
| 26465 | IrInstruction *value = instruction->value->child; | 26464 | IrInstruction *value = instruction->value->child; |
| 26466 | if (type_is_invalid(value->value.type)) | 26465 | if (type_is_invalid(value->value->type)) |
| 26467 | return ira->codegen->invalid_instruction; | 26466 | return ira->codegen->invalid_instruction; |
| 26468 | | 26467 | |
| 26469 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); | 26468 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); |
| 26470 | if (type_is_invalid(casted_value->value.type)) | 26469 | if (type_is_invalid(casted_value->value->type)) |
| 26471 | return ira->codegen->invalid_instruction; | 26470 | return ira->codegen->invalid_instruction; |
| 26472 | | 26471 | |
| 26473 | | 26472 | |
| ... | @@ -26488,20 +26487,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst | ... | @@ -26488,20 +26487,20 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26488 | | 26487 | |
| 26489 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { | 26488 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |
| 26490 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); | 26489 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); |
| 26491 | result->value.type = ira->codegen->builtin_types.entry_void; | 26490 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26492 | return result; | 26491 | return result; |
| 26493 | } | 26492 | } |
| 26494 | | 26493 | |
| 26495 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, | 26494 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, |
| 26496 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); | 26495 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); |
| 26497 | result->value.type = ira->codegen->builtin_types.entry_void; | 26496 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26498 | return result; | 26497 | return result; |
| 26499 | } | 26498 | } |
| 26500 | | 26499 | |
| 26501 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { | 26500 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { |
| 26502 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, | 26501 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, |
| 26503 | instruction->base.source_node); | 26502 | instruction->base.source_node); |
| 26504 | result->value.type = ira->codegen->builtin_types.entry_void; | 26503 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 26505 | return result; | 26504 | return result; |
| 26506 | } | 26505 | } |
| 26507 | | 26506 | |
| ... | @@ -26687,7 +26686,7 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, | ... | @@ -26687,7 +26686,7 @@ static void ir_eval_float_op(IrAnalyze *ira, IrInstructionFloatOp *source_instr, |
| 26687 | | 26686 | |
| 26688 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { | 26687 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { |
| 26689 | IrInstruction *type = instruction->type->child; | 26688 | IrInstruction *type = instruction->type->child; |
| 26690 | if (type_is_invalid(type->value.type)) | 26689 | if (type_is_invalid(type->value->type)) |
| 26691 | return ira->codegen->invalid_instruction; | 26690 | return ira->codegen->invalid_instruction; |
| 26692 | | 26691 | |
| 26693 | ZigType *expr_type = ir_resolve_type(ira, type); | 26692 | ZigType *expr_type = ir_resolve_type(ira, type); |
| ... | @@ -26702,11 +26701,11 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26702,11 +26701,11 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26702 | } | 26701 | } |
| 26703 | | 26702 | |
| 26704 | IrInstruction *op1 = instruction->op1->child; | 26703 | IrInstruction *op1 = instruction->op1->child; |
| 26705 | if (type_is_invalid(op1->value.type)) | 26704 | if (type_is_invalid(op1->value->type)) |
| 26706 | return ira->codegen->invalid_instruction; | 26705 | return ira->codegen->invalid_instruction; |
| 26707 | | 26706 | |
| 26708 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type); | 26707 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type); |
| 26709 | if (type_is_invalid(casted_op1->value.type)) | 26708 | if (type_is_invalid(casted_op1->value->type)) |
| 26710 | return ira->codegen->invalid_instruction; | 26709 | return ira->codegen->invalid_instruction; |
| 26711 | | 26710 | |
| 26712 | if (instr_is_comptime(casted_op1)) { | 26711 | if (instr_is_comptime(casted_op1)) { |
| ... | @@ -26724,7 +26723,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26724,7 +26723,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26724 | return ira->codegen->invalid_instruction; | 26723 | return ira->codegen->invalid_instruction; |
| 26725 | | 26724 | |
| 26726 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 26725 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); |
| 26727 | ZigValue *out_val = &result->value; | 26726 | ZigValue *out_val = result->value; |
| 26728 | | 26727 | |
| 26729 | if (expr_type->id == ZigTypeIdVector) { | 26728 | if (expr_type->id == ZigTypeIdVector) { |
| 26730 | expand_undef_array(ira->codegen, op1_const); | 26729 | expand_undef_array(ira->codegen, op1_const); |
| ... | @@ -26752,7 +26751,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -26752,7 +26751,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26752 | | 26751 | |
| 26753 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, | 26752 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, |
| 26754 | instruction->base.source_node, nullptr, casted_op1, instruction->op); | 26753 | instruction->base.source_node, nullptr, casted_op1, instruction->op); |
| 26755 | result->value.type = expr_type; | 26754 | result->value->type = expr_type; |
| 26756 | return result; | 26755 | return result; |
| 26757 | } | 26756 | } |
| 26758 | | 26757 | |
| ... | @@ -26764,16 +26763,16 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26764,16 +26763,16 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26764 | return ira->codegen->invalid_instruction; | 26763 | return ira->codegen->invalid_instruction; |
| 26765 | | 26764 | |
| 26766 | IrInstruction *uncasted_op = instruction->op->child; | 26765 | IrInstruction *uncasted_op = instruction->op->child; |
| 26767 | if (type_is_invalid(uncasted_op->value.type)) | 26766 | if (type_is_invalid(uncasted_op->value->type)) |
| 26768 | return ira->codegen->invalid_instruction; | 26767 | return ira->codegen->invalid_instruction; |
| 26769 | | 26768 | |
| 26770 | uint32_t vector_len; // UINT32_MAX means not a vector | 26769 | uint32_t vector_len; // UINT32_MAX means not a vector |
| 26771 | if (uncasted_op->value.type->id == ZigTypeIdArray && | 26770 | if (uncasted_op->value->type->id == ZigTypeIdArray && |
| 26772 | is_valid_vector_elem_type(uncasted_op->value.type->data.array.child_type)) | 26771 | is_valid_vector_elem_type(uncasted_op->value->type->data.array.child_type)) |
| 26773 | { | 26772 | { |
| 26774 | vector_len = uncasted_op->value.type->data.array.len; | 26773 | vector_len = uncasted_op->value->type->data.array.len; |
| 26775 | } else if (uncasted_op->value.type->id == ZigTypeIdVector) { | 26774 | } else if (uncasted_op->value->type->id == ZigTypeIdVector) { |
| 26776 | vector_len = uncasted_op->value.type->data.vector.len; | 26775 | vector_len = uncasted_op->value->type->data.vector.len; |
| 26777 | } else { | 26776 | } else { |
| 26778 | vector_len = UINT32_MAX; | 26777 | vector_len = UINT32_MAX; |
| 26779 | } | 26778 | } |
| ... | @@ -26782,7 +26781,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26782,7 +26781,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26782 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; | 26781 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 26783 | | 26782 | |
| 26784 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); | 26783 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); |
| 26785 | if (type_is_invalid(op->value.type)) | 26784 | if (type_is_invalid(op->value->type)) |
| 26786 | return ira->codegen->invalid_instruction; | 26785 | return ira->codegen->invalid_instruction; |
| 26787 | | 26786 | |
| 26788 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) | 26787 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) |
| ... | @@ -26807,7 +26806,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26807,7 +26806,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26807 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); | 26806 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); |
| 26808 | if (is_vector) { | 26807 | if (is_vector) { |
| 26809 | expand_undef_array(ira->codegen, val); | 26808 | expand_undef_array(ira->codegen, val); |
| 26810 | result->value.data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); | 26809 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); |
| 26811 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { | 26810 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { |
| 26812 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; | 26811 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; |
| 26813 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, | 26812 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, |
| ... | @@ -26815,20 +26814,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26815,20 +26814,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26815 | { | 26814 | { |
| 26816 | return ira->codegen->invalid_instruction; | 26815 | return ira->codegen->invalid_instruction; |
| 26817 | } | 26816 | } |
| 26818 | ZigValue *result_elem_val = &result->value.data.x_array.data.s_none.elements[i]; | 26817 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 26819 | result_elem_val->type = int_type; | 26818 | result_elem_val->type = int_type; |
| 26820 | result_elem_val->special = op_elem_val->special; | 26819 | result_elem_val->special = op_elem_val->special; |
| 26821 | if (op_elem_val->special == ConstValSpecialUndef) | 26820 | if (op_elem_val->special == ConstValSpecialUndef) |
| 26822 | continue; | 26821 | continue; |
| 26823 | | 26822 | |
| 26824 | bigint_write_twos_complement(&op_elem_val->data.x_bigint, buf, int_type->data.integral.bit_count, true); | 26823 | bigint_write_twos_complement(&op_elem_val->data.x_bigint, buf, int_type->data.integral.bit_count, true); |
| 26825 | bigint_read_twos_complement(&result->value.data.x_array.data.s_none.elements[i].data.x_bigint, | 26824 | bigint_read_twos_complement(&result->value->data.x_array.data.s_none.elements[i].data.x_bigint, |
| 26826 | buf, int_type->data.integral.bit_count, false, | 26825 | buf, int_type->data.integral.bit_count, false, |
| 26827 | int_type->data.integral.is_signed); | 26826 | int_type->data.integral.is_signed); |
| 26828 | } | 26827 | } |
| 26829 | } else { | 26828 | } else { |
| 26830 | bigint_write_twos_complement(&val->data.x_bigint, buf, int_type->data.integral.bit_count, true); | 26829 | bigint_write_twos_complement(&val->data.x_bigint, buf, int_type->data.integral.bit_count, true); |
| 26831 | bigint_read_twos_complement(&result->value.data.x_bigint, buf, int_type->data.integral.bit_count, false, | 26830 | bigint_read_twos_complement(&result->value->data.x_bigint, buf, int_type->data.integral.bit_count, false, |
| 26832 | int_type->data.integral.is_signed); | 26831 | int_type->data.integral.is_signed); |
| 26833 | } | 26832 | } |
| 26834 | free(buf); | 26833 | free(buf); |
| ... | @@ -26837,7 +26836,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -26837,7 +26836,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26837 | | 26836 | |
| 26838 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, | 26837 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, |
| 26839 | instruction->base.source_node, nullptr, op); | 26838 | instruction->base.source_node, nullptr, op); |
| 26840 | result->value.type = op_type; | 26839 | result->value->type = op_type; |
| 26841 | return result; | 26840 | return result; |
| 26842 | } | 26841 | } |
| 26843 | | 26842 | |
| ... | @@ -26847,12 +26846,12 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26847,12 +26846,12 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26847 | return ira->codegen->invalid_instruction; | 26846 | return ira->codegen->invalid_instruction; |
| 26848 | | 26847 | |
| 26849 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 26848 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 26850 | if (type_is_invalid(op->value.type)) | 26849 | if (type_is_invalid(op->value->type)) |
| 26851 | return ira->codegen->invalid_instruction; | 26850 | return ira->codegen->invalid_instruction; |
| 26852 | | 26851 | |
| 26853 | if (int_type->data.integral.bit_count == 0) { | 26852 | if (int_type->data.integral.bit_count == 0) { |
| 26854 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 26853 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); |
| 26855 | bigint_init_unsigned(&result->value.data.x_bigint, 0); | 26854 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 26856 | return result; | 26855 | return result; |
| 26857 | } | 26856 | } |
| 26858 | | 26857 | |
| ... | @@ -26881,7 +26880,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26881,7 +26880,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26881 | } | 26880 | } |
| 26882 | } | 26881 | } |
| 26883 | | 26882 | |
| 26884 | bigint_read_twos_complement(&result->value.data.x_bigint, | 26883 | bigint_read_twos_complement(&result->value->data.x_bigint, |
| 26885 | result_buf, | 26884 | result_buf, |
| 26886 | int_type->data.integral.bit_count, | 26885 | int_type->data.integral.bit_count, |
| 26887 | ira->codegen->is_big_endian, | 26886 | ira->codegen->is_big_endian, |
| ... | @@ -26892,14 +26891,14 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -26892,14 +26891,14 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26892 | | 26891 | |
| 26893 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, | 26892 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, |
| 26894 | instruction->base.source_node, nullptr, op); | 26893 | instruction->base.source_node, nullptr, op); |
| 26895 | result->value.type = int_type; | 26894 | result->value->type = int_type; |
| 26896 | return result; | 26895 | return result; |
| 26897 | } | 26896 | } |
| 26898 | | 26897 | |
| 26899 | | 26898 | |
| 26900 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { | 26899 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { |
| 26901 | IrInstruction *target = instruction->target->child; | 26900 | IrInstruction *target = instruction->target->child; |
| 26902 | if (type_is_invalid(target->value.type)) | 26901 | if (type_is_invalid(target->value->type)) |
| 26903 | return ira->codegen->invalid_instruction; | 26902 | return ira->codegen->invalid_instruction; |
| 26904 | | 26903 | |
| 26905 | return ir_analyze_enum_to_int(ira, &instruction->base, target); | 26904 | return ir_analyze_enum_to_int(ira, &instruction->base, target); |
| ... | @@ -26924,11 +26923,11 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr | ... | @@ -26924,11 +26923,11 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr |
| 26924 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; | 26923 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; |
| 26925 | | 26924 | |
| 26926 | IrInstruction *target = instruction->target->child; | 26925 | IrInstruction *target = instruction->target->child; |
| 26927 | if (type_is_invalid(target->value.type)) | 26926 | if (type_is_invalid(target->value->type)) |
| 26928 | return ira->codegen->invalid_instruction; | 26927 | return ira->codegen->invalid_instruction; |
| 26929 | | 26928 | |
| 26930 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); | 26929 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); |
| 26931 | if (type_is_invalid(casted_target->value.type)) | 26930 | if (type_is_invalid(casted_target->value->type)) |
| 26932 | return ira->codegen->invalid_instruction; | 26931 | return ira->codegen->invalid_instruction; |
| 26933 | | 26932 | |
| 26934 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); | 26933 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); |
| ... | @@ -26995,33 +26994,33 @@ static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Ir | ... | @@ -26995,33 +26994,33 @@ static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, Ir |
| 26995 | | 26994 | |
| 26996 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { | 26995 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { |
| 26997 | IrInstruction *value = instruction->value->child; | 26996 | IrInstruction *value = instruction->value->child; |
| 26998 | if (type_is_invalid(value->value.type)) | 26997 | if (type_is_invalid(value->value->type)) |
| 26999 | return ira->codegen->invalid_instruction; | 26998 | return ira->codegen->invalid_instruction; |
| 27000 | | 26999 | |
| 27001 | bool was_written = instruction->result_loc->written; | 27000 | bool was_written = instruction->result_loc->written; |
| 27002 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 27001 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 27003 | value->value.type, value, false, false, true); | 27002 | value->value->type, value, false, false, true); |
| 27004 | if (result_loc != nullptr) { | 27003 | if (result_loc != nullptr) { |
| 27005 | if (type_is_invalid(result_loc->value.type)) | 27004 | if (type_is_invalid(result_loc->value->type)) |
| 27006 | return ira->codegen->invalid_instruction; | 27005 | return ira->codegen->invalid_instruction; |
| 27007 | if (result_loc->value.type->id == ZigTypeIdUnreachable) | 27006 | if (result_loc->value->type->id == ZigTypeIdUnreachable) |
| 27008 | return result_loc; | 27007 | return result_loc; |
| 27009 | | 27008 | |
| 27010 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { | 27009 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { |
| 27011 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, | 27010 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, |
| 27012 | instruction->result_loc->allow_write_through_const); | 27011 | instruction->result_loc->allow_write_through_const); |
| 27013 | if (type_is_invalid(store_ptr->value.type)) { | 27012 | if (type_is_invalid(store_ptr->value->type)) { |
| 27014 | return ira->codegen->invalid_instruction; | 27013 | return ira->codegen->invalid_instruction; |
| 27015 | } | 27014 | } |
| 27016 | } | 27015 | } |
| 27017 | | 27016 | |
| 27018 | if (result_loc->value.data.x_ptr.mut == ConstPtrMutInfer && | 27017 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer && |
| 27019 | instruction->result_loc->id != ResultLocIdPeer) | 27018 | instruction->result_loc->id != ResultLocIdPeer) |
| 27020 | { | 27019 | { |
| 27021 | if (instr_is_comptime(value)) { | 27020 | if (instr_is_comptime(value)) { |
| 27022 | result_loc->value.data.x_ptr.mut = ConstPtrMutComptimeConst; | 27021 | result_loc->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 27023 | } else { | 27022 | } else { |
| 27024 | result_loc->value.special = ConstValSpecialRuntime; | 27023 | result_loc->value->special = ConstValSpecialRuntime; |
| 27025 | } | 27024 | } |
| 27026 | } | 27025 | } |
| 27027 | } | 27026 | } |
| ... | @@ -27031,12 +27030,12 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct | ... | @@ -27031,12 +27030,12 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct |
| 27031 | | 27030 | |
| 27032 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { | 27031 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { |
| 27033 | IrInstruction *operand = instruction->operand->child; | 27032 | IrInstruction *operand = instruction->operand->child; |
| 27034 | if (type_is_invalid(operand->value.type)) | 27033 | if (type_is_invalid(operand->value->type)) |
| 27035 | return operand; | 27034 | return operand; |
| 27036 | | 27035 | |
| 27037 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 27036 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, |
| 27038 | &instruction->result_loc_cast->base, operand->value.type, operand, false, false, true); | 27037 | &instruction->result_loc_cast->base, operand->value->type, operand, false, false, true); |
| 27039 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 27038 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27040 | return result_loc; | 27039 | return result_loc; |
| 27041 | | 27040 | |
| 27042 | if (instruction->result_loc_cast->parent->gen_instruction != nullptr) { | 27041 | if (instruction->result_loc_cast->parent->gen_instruction != nullptr) { |
| ... | @@ -27051,12 +27050,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns | ... | @@ -27051,12 +27050,12 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns |
| 27051 | | 27050 | |
| 27052 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { | 27051 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { |
| 27053 | IrInstruction *operand = instruction->operand->child; | 27052 | IrInstruction *operand = instruction->operand->child; |
| 27054 | if (type_is_invalid(operand->value.type)) | 27053 | if (type_is_invalid(operand->value->type)) |
| 27055 | return operand; | 27054 | return operand; |
| 27056 | | 27055 | |
| 27057 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 27056 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, |
| 27058 | &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true); | 27057 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, false, true); |
| 27059 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 27058 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27060 | return result_loc; | 27059 | return result_loc; |
| 27061 | | 27060 | |
| 27062 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { | 27061 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { |
| ... | @@ -27084,11 +27083,11 @@ static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *i | ... | @@ -27084,11 +27083,11 @@ static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *i |
| 27084 | return ira->codegen->invalid_instruction; | 27083 | return ira->codegen->invalid_instruction; |
| 27085 | | 27084 | |
| 27086 | IrInstruction *field_result_loc = instruction->field_result_loc->child; | 27085 | IrInstruction *field_result_loc = instruction->field_result_loc->child; |
| 27087 | if (type_is_invalid(field_result_loc->value.type)) | 27086 | if (type_is_invalid(field_result_loc->value->type)) |
| 27088 | return ira->codegen->invalid_instruction; | 27087 | return ira->codegen->invalid_instruction; |
| 27089 | | 27088 | |
| 27090 | IrInstruction *result_loc = instruction->result_loc->child; | 27089 | IrInstruction *result_loc = instruction->result_loc->child; |
| 27091 | if (type_is_invalid(result_loc->value.type)) | 27090 | if (type_is_invalid(result_loc->value->type)) |
| 27092 | return ira->codegen->invalid_instruction; | 27091 | return ira->codegen->invalid_instruction; |
| 27093 | | 27092 | |
| 27094 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, | 27093 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, |
| ... | @@ -27105,7 +27104,7 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | ... | @@ -27105,7 +27104,7 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, |
| 27105 | IrInstructionSuspendFinish *instruction) | 27104 | IrInstructionSuspendFinish *instruction) |
| 27106 | { | 27105 | { |
| 27107 | IrInstruction *begin_base = instruction->begin->base.child; | 27106 | IrInstruction *begin_base = instruction->begin->base.child; |
| 27108 | if (type_is_invalid(begin_base->value.type)) | 27107 | if (type_is_invalid(begin_base->value->type)) |
| 27109 | return ira->codegen->invalid_instruction; | 27108 | return ira->codegen->invalid_instruction; |
| 27110 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); | 27109 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); |
| 27111 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); | 27110 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); |
| ... | @@ -27123,44 +27122,44 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | ... | @@ -27123,44 +27122,44 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, |
| 27123 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, | 27122 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, |
| 27124 | IrInstruction *frame_ptr, ZigFn **target_fn) | 27123 | IrInstruction *frame_ptr, ZigFn **target_fn) |
| 27125 | { | 27124 | { |
| 27126 | if (type_is_invalid(frame_ptr->value.type)) | 27125 | if (type_is_invalid(frame_ptr->value->type)) |
| 27127 | return ira->codegen->invalid_instruction; | 27126 | return ira->codegen->invalid_instruction; |
| 27128 | | 27127 | |
| 27129 | *target_fn = nullptr; | 27128 | *target_fn = nullptr; |
| 27130 | | 27129 | |
| 27131 | ZigType *result_type; | 27130 | ZigType *result_type; |
| 27132 | IrInstruction *frame; | 27131 | IrInstruction *frame; |
| 27133 | if (frame_ptr->value.type->id == ZigTypeIdPointer && | 27132 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 27134 | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && | 27133 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27135 | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27134 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27136 | { | 27135 | { |
| 27137 | ZigFn *func = frame_ptr->value.type->data.pointer.child_type->data.frame.fn; | 27136 | ZigFn *func = frame_ptr->value->type->data.pointer.child_type->data.frame.fn; |
| 27138 | result_type = func->type_entry->data.fn.fn_type_id.return_type; | 27137 | result_type = func->type_entry->data.fn.fn_type_id.return_type; |
| 27139 | *target_fn = func; | 27138 | *target_fn = func; |
| 27140 | frame = frame_ptr; | 27139 | frame = frame_ptr; |
| 27141 | } else { | 27140 | } else { |
| 27142 | frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr); | 27141 | frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr); |
| 27143 | if (frame->value.type->id == ZigTypeIdPointer && | 27142 | if (frame->value->type->id == ZigTypeIdPointer && |
| 27144 | frame->value.type->data.pointer.ptr_len == PtrLenSingle && | 27143 | frame->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27145 | frame->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27144 | frame->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27146 | { | 27145 | { |
| 27147 | ZigFn *func = frame->value.type->data.pointer.child_type->data.frame.fn; | 27146 | ZigFn *func = frame->value->type->data.pointer.child_type->data.frame.fn; |
| 27148 | result_type = func->type_entry->data.fn.fn_type_id.return_type; | 27147 | result_type = func->type_entry->data.fn.fn_type_id.return_type; |
| 27149 | *target_fn = func; | 27148 | *target_fn = func; |
| 27150 | } else if (frame->value.type->id != ZigTypeIdAnyFrame || | 27149 | } else if (frame->value->type->id != ZigTypeIdAnyFrame || |
| 27151 | frame->value.type->data.any_frame.result_type == nullptr) | 27150 | frame->value->type->data.any_frame.result_type == nullptr) |
| 27152 | { | 27151 | { |
| 27153 | ir_add_error(ira, source_instr, | 27152 | ir_add_error(ira, source_instr, |
| 27154 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value.type->name))); | 27153 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); |
| 27155 | return ira->codegen->invalid_instruction; | 27154 | return ira->codegen->invalid_instruction; |
| 27156 | } else { | 27155 | } else { |
| 27157 | result_type = frame->value.type->data.any_frame.result_type; | 27156 | result_type = frame->value->type->data.any_frame.result_type; |
| 27158 | } | 27157 | } |
| 27159 | } | 27158 | } |
| 27160 | | 27159 | |
| 27161 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); | 27160 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 27162 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 27161 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27163 | if (type_is_invalid(casted_frame->value.type)) | 27162 | if (type_is_invalid(casted_frame->value->type)) |
| 27164 | return ira->codegen->invalid_instruction; | 27163 | return ira->codegen->invalid_instruction; |
| 27165 | | 27164 | |
| 27166 | return casted_frame; | 27165 | return casted_frame; |
| ... | @@ -27168,14 +27167,14 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct | ... | @@ -27168,14 +27167,14 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct |
| 27168 | | 27167 | |
| 27169 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { | 27168 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { |
| 27170 | IrInstruction *operand = instruction->frame->child; | 27169 | IrInstruction *operand = instruction->frame->child; |
| 27171 | if (type_is_invalid(operand->value.type)) | 27170 | if (type_is_invalid(operand->value->type)) |
| 27172 | return ira->codegen->invalid_instruction; | 27171 | return ira->codegen->invalid_instruction; |
| 27173 | ZigFn *target_fn; | 27172 | ZigFn *target_fn; |
| 27174 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); | 27173 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); |
| 27175 | if (type_is_invalid(frame->value.type)) | 27174 | if (type_is_invalid(frame->value->type)) |
| 27176 | return ira->codegen->invalid_instruction; | 27175 | return ira->codegen->invalid_instruction; |
| 27177 | | 27176 | |
| 27178 | ZigType *result_type = frame->value.type->data.any_frame.result_type; | 27177 | ZigType *result_type = frame->value->type->data.any_frame.result_type; |
| 27179 | | 27178 | |
| 27180 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 27179 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 27181 | ir_assert(fn_entry != nullptr, &instruction->base); | 27180 | ir_assert(fn_entry != nullptr, &instruction->base); |
| ... | @@ -27195,7 +27194,7 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -27195,7 +27194,7 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 27195 | if (type_has_bits(result_type)) { | 27194 | if (type_has_bits(result_type)) { |
| 27196 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 27195 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, |
| 27197 | result_type, nullptr, true, true, true); | 27196 | result_type, nullptr, true, true, true); |
| 27198 | if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) | 27197 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) |
| 27199 | return result_loc; | 27198 | return result_loc; |
| 27200 | } else { | 27199 | } else { |
| 27201 | result_loc = nullptr; | 27200 | result_loc = nullptr; |
| ... | @@ -27209,13 +27208,13 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -27209,13 +27208,13 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 27209 | | 27208 | |
| 27210 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { | 27209 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { |
| 27211 | IrInstruction *frame_ptr = instruction->frame->child; | 27210 | IrInstruction *frame_ptr = instruction->frame->child; |
| 27212 | if (type_is_invalid(frame_ptr->value.type)) | 27211 | if (type_is_invalid(frame_ptr->value->type)) |
| 27213 | return ira->codegen->invalid_instruction; | 27212 | return ira->codegen->invalid_instruction; |
| 27214 | | 27213 | |
| 27215 | IrInstruction *frame; | 27214 | IrInstruction *frame; |
| 27216 | if (frame_ptr->value.type->id == ZigTypeIdPointer && | 27215 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 27217 | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && | 27216 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 27218 | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 27217 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 27219 | { | 27218 | { |
| 27220 | frame = frame_ptr; | 27219 | frame = frame_ptr; |
| 27221 | } else { | 27220 | } else { |
| ... | @@ -27224,7 +27223,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio | ... | @@ -27224,7 +27223,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio |
| 27224 | | 27223 | |
| 27225 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); | 27224 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 27226 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 27225 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27227 | if (type_is_invalid(casted_frame->value.type)) | 27226 | if (type_is_invalid(casted_frame->value->type)) |
| 27228 | return ira->codegen->invalid_instruction; | 27227 | return ira->codegen->invalid_instruction; |
| 27229 | | 27228 | |
| 27230 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); | 27229 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); |
| ... | @@ -27235,10 +27234,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr | ... | @@ -27235,10 +27234,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr |
| 27235 | return ir_const_void(ira, &instruction->base); | 27234 | return ir_const_void(ira, &instruction->base); |
| 27236 | | 27235 | |
| 27237 | IrInstruction *operand = instruction->operand->child; | 27236 | IrInstruction *operand = instruction->operand->child; |
| 27238 | if (type_is_invalid(operand->value.type)) | 27237 | if (type_is_invalid(operand->value->type)) |
| 27239 | return ira->codegen->invalid_instruction; | 27238 | return ira->codegen->invalid_instruction; |
| 27240 | | 27239 | |
| 27241 | if (!type_has_bits(operand->value.type)) | 27240 | if (!type_has_bits(operand->value->type)) |
| 27242 | return ir_const_void(ira, &instruction->base); | 27241 | return ir_const_void(ira, &instruction->base); |
| 27243 | | 27242 | |
| 27244 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); | 27243 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); |
| ... | @@ -27251,10 +27250,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr | ... | @@ -27251,10 +27250,10 @@ static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstr |
| 27251 | | 27250 | |
| 27252 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { | 27251 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { |
| 27253 | IrInstruction *operand = instruction->begin->operand->child; | 27252 | IrInstruction *operand = instruction->begin->operand->child; |
| 27254 | if (type_is_invalid(operand->value.type)) | 27253 | if (type_is_invalid(operand->value->type)) |
| 27255 | return ira->codegen->invalid_instruction; | 27254 | return ira->codegen->invalid_instruction; |
| 27256 | | 27255 | |
| 27257 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value.type)) | 27256 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value->type)) |
| 27258 | return operand; | 27257 | return operand; |
| 27259 | | 27258 | |
| 27260 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); | 27259 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); |
| ... | @@ -27262,7 +27261,7 @@ static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstruc | ... | @@ -27262,7 +27261,7 @@ static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstruc |
| 27262 | | 27261 | |
| 27263 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, | 27262 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, |
| 27264 | instruction->base.source_node, begin); | 27263 | instruction->base.source_node, begin); |
| 27265 | result->value.type = operand->value.type; | 27264 | result->value->type = operand->value->type; |
| 27266 | return result; | 27265 | return result; |
| 27267 | } | 27266 | } |
| 27268 | | 27267 | |
| ... | @@ -27628,10 +27627,10 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27628,10 +27627,10 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27628 | } | 27627 | } |
| 27629 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | 27628 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); |
| 27630 | if (new_instruction != nullptr) { | 27629 | if (new_instruction != nullptr) { |
| 27631 | ir_assert(new_instruction->value.type != nullptr || new_instruction->value.type != nullptr, old_instruction); | 27630 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction); |
| 27632 | old_instruction->child = new_instruction; | 27631 | old_instruction->child = new_instruction; |
| 27633 | | 27632 | |
| 27634 | if (type_is_invalid(new_instruction->value.type)) { | 27633 | if (type_is_invalid(new_instruction->value->type)) { |
| 27635 | if (new_exec->first_err_trace_msg != nullptr) { | 27634 | if (new_exec->first_err_trace_msg != nullptr) { |
| 27636 | ira->codegen->trace_err = new_exec->first_err_trace_msg; | 27635 | ira->codegen->trace_err = new_exec->first_err_trace_msg; |
| 27637 | } else { | 27636 | } else { |
| ... | @@ -27648,7 +27647,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -27648,7 +27647,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 27648 | } | 27647 | } |
| 27649 | | 27648 | |
| 27650 | // unreachable instructions do their own control flow. | 27649 | // unreachable instructions do their own control flow. |
| 27651 | if (new_instruction->value.type->id == ZigTypeIdUnreachable) | 27650 | if (new_instruction->value->type->id == ZigTypeIdUnreachable) |
| 27652 | continue; | 27651 | continue; |
| 27653 | } | 27652 | } |
| 27654 | | 27653 | |
| ... | @@ -27958,8 +27957,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -27958,8 +27957,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 27958 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); | 27957 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); |
| 27959 | IrAnalyze *ira = lazy_align_of->ira; | 27958 | IrAnalyze *ira = lazy_align_of->ira; |
| 27960 | | 27959 | |
| 27961 | if (lazy_align_of->target_type->value.special == ConstValSpecialStatic) { | 27960 | if (lazy_align_of->target_type->value->special == ConstValSpecialStatic) { |
| 27962 | switch (lazy_align_of->target_type->value.data.x_type->id) { | 27961 | switch (lazy_align_of->target_type->value->data.x_type->id) { |
| 27963 | case ZigTypeIdInvalid: | 27962 | case ZigTypeIdInvalid: |
| 27964 | zig_unreachable(); | 27963 | zig_unreachable(); |
| 27965 | case ZigTypeIdMetaType: | 27964 | case ZigTypeIdMetaType: |
| ... | @@ -27975,7 +27974,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -27975,7 +27974,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 27975 | case ZigTypeIdOpaque: | 27974 | case ZigTypeIdOpaque: |
| 27976 | ir_add_error(ira, lazy_align_of->target_type, | 27975 | ir_add_error(ira, lazy_align_of->target_type, |
| 27977 | buf_sprintf("no align available for type '%s'", | 27976 | buf_sprintf("no align available for type '%s'", |
| 27978 | buf_ptr(&lazy_align_of->target_type->value.data.x_type->name))); | 27977 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); |
| 27979 | return ErrorSemanticAnalyzeFail; | 27978 | return ErrorSemanticAnalyzeFail; |
| 27980 | case ZigTypeIdBool: | 27979 | case ZigTypeIdBool: |
| 27981 | case ZigTypeIdInt: | 27980 | case ZigTypeIdInt: |
| ... | @@ -27997,7 +27996,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -27997,7 +27996,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 27997 | } | 27996 | } |
| 27998 | | 27997 | |
| 27999 | uint32_t align_in_bytes; | 27998 | uint32_t align_in_bytes; |
| 28000 | if ((err = type_val_resolve_abi_align(ira->codegen, &lazy_align_of->target_type->value, | 27999 | if ((err = type_val_resolve_abi_align(ira->codegen, lazy_align_of->target_type->value, |
| 28001 | &align_in_bytes))) | 28000 | &align_in_bytes))) |
| 28002 | { | 28001 | { |
| 28003 | return err; | 28002 | return err; |
| ... | @@ -28012,8 +28011,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -28012,8 +28011,8 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 28012 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); | 28011 | LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); |
| 28013 | IrAnalyze *ira = lazy_size_of->ira; | 28012 | IrAnalyze *ira = lazy_size_of->ira; |
| 28014 | | 28013 | |
| 28015 | if (lazy_size_of->target_type->value.special == ConstValSpecialStatic) { | 28014 | if (lazy_size_of->target_type->value->special == ConstValSpecialStatic) { |
| 28016 | switch (lazy_size_of->target_type->value.data.x_type->id) { | 28015 | switch (lazy_size_of->target_type->value->data.x_type->id) { |
| 28017 | case ZigTypeIdInvalid: // handled above | 28016 | case ZigTypeIdInvalid: // handled above |
| 28018 | zig_unreachable(); | 28017 | zig_unreachable(); |
| 28019 | case ZigTypeIdUnreachable: | 28018 | case ZigTypeIdUnreachable: |
| ... | @@ -28024,7 +28023,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -28024,7 +28023,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 28024 | case ZigTypeIdOpaque: | 28023 | case ZigTypeIdOpaque: |
| 28025 | ir_add_error(ira, lazy_size_of->target_type, | 28024 | ir_add_error(ira, lazy_size_of->target_type, |
| 28026 | buf_sprintf("no size available for type '%s'", | 28025 | buf_sprintf("no size available for type '%s'", |
| 28027 | buf_ptr(&lazy_size_of->target_type->value.data.x_type->name))); | 28026 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); |
| 28028 | return ErrorSemanticAnalyzeFail; | 28027 | return ErrorSemanticAnalyzeFail; |
| 28029 | case ZigTypeIdMetaType: | 28028 | case ZigTypeIdMetaType: |
| 28030 | case ZigTypeIdEnumLiteral: | 28029 | case ZigTypeIdEnumLiteral: |
| ... | @@ -28052,7 +28051,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -28052,7 +28051,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 28052 | | 28051 | |
| 28053 | size_t abi_size; | 28052 | size_t abi_size; |
| 28054 | size_t size_in_bits; | 28053 | size_t size_in_bits; |
| 28055 | if ((err = type_val_resolve_abi_size(ira->codegen, source_node, &lazy_size_of->target_type->value, | 28054 | if ((err = type_val_resolve_abi_size(ira->codegen, source_node, lazy_size_of->target_type->value, |
| 28056 | &abi_size, &size_in_bits))) | 28055 | &abi_size, &size_in_bits))) |
| 28057 | { | 28056 | { |
| 28058 | return err; | 28057 | return err; |
| ... | @@ -28073,10 +28072,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -28073,10 +28072,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 28073 | | 28072 | |
| 28074 | ZigValue *sentinel_val; | 28073 | ZigValue *sentinel_val; |
| 28075 | if (lazy_slice_type->sentinel != nullptr) { | 28074 | if (lazy_slice_type->sentinel != nullptr) { |
| 28076 | if (type_is_invalid(lazy_slice_type->sentinel->value.type)) | 28075 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) |
| 28077 | return ErrorSemanticAnalyzeFail; | 28076 | return ErrorSemanticAnalyzeFail; |
| 28078 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | 28077 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); |
| 28079 | if (type_is_invalid(sentinel->value.type)) | 28078 | if (type_is_invalid(sentinel->value->type)) |
| 28080 | return ErrorSemanticAnalyzeFail; | 28079 | return ErrorSemanticAnalyzeFail; |
| 28081 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 28080 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 28082 | if (sentinel_val == nullptr) | 28081 | if (sentinel_val == nullptr) |
| ... | @@ -28151,10 +28150,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -28151,10 +28150,10 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 28151 | | 28150 | |
| 28152 | ZigValue *sentinel_val; | 28151 | ZigValue *sentinel_val; |
| 28153 | if (lazy_ptr_type->sentinel != nullptr) { | 28152 | if (lazy_ptr_type->sentinel != nullptr) { |
| 28154 | if (type_is_invalid(lazy_ptr_type->sentinel->value.type)) | 28153 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) |
| 28155 | return ErrorSemanticAnalyzeFail; | 28154 | return ErrorSemanticAnalyzeFail; |
| 28156 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | 28155 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); |
| 28157 | if (type_is_invalid(sentinel->value.type)) | 28156 | if (type_is_invalid(sentinel->value->type)) |
| 28158 | return ErrorSemanticAnalyzeFail; | 28157 | return ErrorSemanticAnalyzeFail; |
| 28159 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 28158 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 28160 | if (sentinel_val == nullptr) | 28159 | if (sentinel_val == nullptr) |