| author | |
| committer | |
| log | 54e48f7b7dec96c8cdd1a0a0491554b118767817 |
| tree | 0fade2355498d008e8cbe9e7e1d7ac6afdffc8c8 |
| parent | c6677be53bd41e7e9a208fb0c1c9135605c761cb |
| parent | de49a9a17352a36a0888b03905f207b0584fc269 |
| signature |
incremental: more progress13 files changed, 251 insertions(+), 524 deletions(-)
lib/std/zig/AstGen.zig+57-46| ... | ... | @@ -366,7 +366,6 @@ const ResultInfo = struct { |
| 366 | 366 | }; |
| 367 | 367 | |
| 368 | 368 | const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } }; |
| 369 | const coerced_addrspace_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .address_space_type } }; | |
| 370 | 369 | const coerced_linksection_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .slice_const_u8_type } }; |
| 371 | 370 | const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } }; |
| 372 | 371 | const coerced_bool_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .bool_type } }; |
| ... | ... | @@ -1387,7 +1386,7 @@ fn fnProtoExpr( |
| 1387 | 1386 | try expr( |
| 1388 | 1387 | &block_scope, |
| 1389 | 1388 | scope, |
| 1390 | .{ .rl = .{ .coerced_ty = .calling_convention_type } }, | |
| 1389 | .{ .rl = .{ .coerced_ty = try block_scope.addBuiltinValue(fn_proto.ast.callconv_expr, .calling_convention) } }, | |
| 1391 | 1390 | fn_proto.ast.callconv_expr, |
| 1392 | 1391 | ) |
| 1393 | 1392 | else |
| ... | ... | @@ -3804,7 +3803,8 @@ fn ptrType( |
| 3804 | 3803 | gz.astgen.source_line = source_line; |
| 3805 | 3804 | gz.astgen.source_column = source_column; |
| 3806 | 3805 | |
| 3807 | addrspace_ref = try expr(gz, scope, coerced_addrspace_ri, ptr_info.ast.addrspace_node); | |
| 3806 | const addrspace_ty = try gz.addBuiltinValue(ptr_info.ast.addrspace_node, .address_space); | |
| 3807 | addrspace_ref = try expr(gz, scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, ptr_info.ast.addrspace_node); | |
| 3808 | 3808 | trailing_count += 1; |
| 3809 | 3809 | } |
| 3810 | 3810 | if (ptr_info.ast.align_node != 0) { |
| ... | ... | @@ -4202,7 +4202,8 @@ fn fnDecl( |
| 4202 | 4202 | var addrspace_gz = decl_gz.makeSubBlock(params_scope); |
| 4203 | 4203 | defer addrspace_gz.unstack(); |
| 4204 | 4204 | const addrspace_ref: Zir.Inst.Ref = if (fn_proto.ast.addrspace_expr == 0) .none else inst: { |
| 4205 | const inst = try expr(&decl_gz, params_scope, coerced_addrspace_ri, fn_proto.ast.addrspace_expr); | |
| 4205 | const addrspace_ty = try decl_gz.addBuiltinValue(fn_proto.ast.addrspace_expr, .address_space); | |
| 4206 | const inst = try expr(&decl_gz, params_scope, .{ .rl = .{ .coerced_ty = addrspace_ty } }, fn_proto.ast.addrspace_expr); | |
| 4206 | 4207 | if (addrspace_gz.instructionsSlice().len == 0) { |
| 4207 | 4208 | // In this case we will send a len=0 body which can be encoded more efficiently. |
| 4208 | 4209 | break :inst inst; |
| ... | ... | @@ -4235,9 +4236,9 @@ fn fnDecl( |
| 4235 | 4236 | ); |
| 4236 | 4237 | } |
| 4237 | 4238 | const inst = try expr( |
| 4238 | &decl_gz, | |
| 4239 | &cc_gz, | |
| 4239 | 4240 | params_scope, |
| 4240 | .{ .rl = .{ .coerced_ty = .calling_convention_type } }, | |
| 4241 | .{ .rl = .{ .coerced_ty = try cc_gz.addBuiltinValue(fn_proto.ast.callconv_expr, .calling_convention) } }, | |
| 4241 | 4242 | fn_proto.ast.callconv_expr, |
| 4242 | 4243 | ); |
| 4243 | 4244 | if (cc_gz.instructionsSlice().len == 0) { |
| ... | ... | @@ -4247,10 +4248,13 @@ fn fnDecl( |
| 4247 | 4248 | _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst); |
| 4248 | 4249 | break :blk inst; |
| 4249 | 4250 | } else if (is_extern) { |
| 4250 | // note: https://github.com/ziglang/zig/issues/5269 | |
| 4251 | break :blk .calling_convention_c; | |
| 4251 | const inst = try cc_gz.addBuiltinValue(decl_node, .calling_convention_c); | |
| 4252 | _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst); | |
| 4253 | break :blk inst; | |
| 4252 | 4254 | } else if (has_inline_keyword) { |
| 4253 | break :blk .calling_convention_inline; | |
| 4255 | const inst = try cc_gz.addBuiltinValue(decl_node, .calling_convention_inline); | |
| 4256 | _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst); | |
| 4257 | break :blk inst; | |
| 4254 | 4258 | } else { |
| 4255 | 4259 | break :blk .none; |
| 4256 | 4260 | } |
| ... | ... | @@ -4525,7 +4529,8 @@ fn globalVarDecl( |
| 4525 | 4529 | |
| 4526 | 4530 | var addrspace_gz = linksection_gz.makeSubBlock(scope); |
| 4527 | 4531 | if (var_decl.ast.addrspace_node != 0) { |
| 4528 | const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, coerced_addrspace_ri, var_decl.ast.addrspace_node); | |
| 4532 | const addrspace_ty = try addrspace_gz.addBuiltinValue(var_decl.ast.addrspace_node, .address_space); | |
| 4533 | const addrspace_inst = try fullBodyExpr(&addrspace_gz, &addrspace_gz.base, .{ .rl = .{ .coerced_ty = addrspace_ty } }, var_decl.ast.addrspace_node); | |
| 4529 | 4534 | _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node); |
| 4530 | 4535 | } |
| 4531 | 4536 | |
| ... | ... | @@ -9169,6 +9174,7 @@ fn builtinCall( |
| 9169 | 9174 | // zig fmt: on |
| 9170 | 9175 | |
| 9171 | 9176 | .@"export" => { |
| 9177 | const export_options_ty = try gz.addBuiltinValue(node, .export_options); | |
| 9172 | 9178 | const node_tags = tree.nodes.items(.tag); |
| 9173 | 9179 | const node_datas = tree.nodes.items(.data); |
| 9174 | 9180 | // This function causes a Decl to be exported. The first parameter is not an expression, |
| ... | ... | @@ -9192,7 +9198,7 @@ fn builtinCall( |
| 9192 | 9198 | local_val.used = ident_token; |
| 9193 | 9199 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ |
| 9194 | 9200 | .operand = local_val.inst, |
| 9195 | .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .export_options_type } }, params[1]), | |
| 9201 | .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]), | |
| 9196 | 9202 | }); |
| 9197 | 9203 | return rvalue(gz, ri, .void_value, node); |
| 9198 | 9204 | } |
| ... | ... | @@ -9207,7 +9213,7 @@ fn builtinCall( |
| 9207 | 9213 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, node); |
| 9208 | 9214 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ |
| 9209 | 9215 | .operand = loaded, |
| 9210 | .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .export_options_type } }, params[1]), | |
| 9216 | .options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]), | |
| 9211 | 9217 | }); |
| 9212 | 9218 | return rvalue(gz, ri, .void_value, node); |
| 9213 | 9219 | } |
| ... | ... | @@ -9245,7 +9251,7 @@ fn builtinCall( |
| 9245 | 9251 | }, |
| 9246 | 9252 | else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}), |
| 9247 | 9253 | } |
| 9248 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .export_options_type } }, params[1]); | |
| 9254 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = export_options_ty } }, params[1]); | |
| 9249 | 9255 | _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{ |
| 9250 | 9256 | .namespace = namespace, |
| 9251 | 9257 | .decl_name = decl_name, |
| ... | ... | @@ -9255,7 +9261,8 @@ fn builtinCall( |
| 9255 | 9261 | }, |
| 9256 | 9262 | .@"extern" => { |
| 9257 | 9263 | const type_inst = try typeExpr(gz, scope, params[0]); |
| 9258 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .extern_options_type } }, params[1]); | |
| 9264 | const extern_options_ty = try gz.addBuiltinValue(node, .extern_options); | |
| 9265 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = extern_options_ty } }, params[1]); | |
| 9259 | 9266 | const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{ |
| 9260 | 9267 | .node = gz.nodeIndexToRelative(node), |
| 9261 | 9268 | .lhs = type_inst, |
| ... | ... | @@ -9264,7 +9271,8 @@ fn builtinCall( |
| 9264 | 9271 | return rvalue(gz, ri, result, node); |
| 9265 | 9272 | }, |
| 9266 | 9273 | .fence => { |
| 9267 | const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[0]); | |
| 9274 | const atomic_order_ty = try gz.addBuiltinValue(node, .atomic_order); | |
| 9275 | const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_ty } }, params[0]); | |
| 9268 | 9276 | _ = try gz.addExtendedPayload(.fence, Zir.Inst.UnNode{ |
| 9269 | 9277 | .node = gz.nodeIndexToRelative(node), |
| 9270 | 9278 | .operand = order, |
| ... | ... | @@ -9272,7 +9280,8 @@ fn builtinCall( |
| 9272 | 9280 | return rvalue(gz, ri, .void_value, node); |
| 9273 | 9281 | }, |
| 9274 | 9282 | .set_float_mode => { |
| 9275 | const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .float_mode_type } }, params[0]); | |
| 9283 | const float_mode_ty = try gz.addBuiltinValue(node, .float_mode); | |
| 9284 | const order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = float_mode_ty } }, params[0]); | |
| 9276 | 9285 | _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{ |
| 9277 | 9286 | .node = gz.nodeIndexToRelative(node), |
| 9278 | 9287 | .operand = order, |
| ... | ... | @@ -9365,7 +9374,8 @@ fn builtinCall( |
| 9365 | 9374 | }, |
| 9366 | 9375 | |
| 9367 | 9376 | .Type => { |
| 9368 | const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .type_info_type } }, params[0]); | |
| 9377 | const type_info_ty = try gz.addBuiltinValue(node, .type_info); | |
| 9378 | const operand = try expr(gz, scope, .{ .rl = .{ .coerced_ty = type_info_ty } }, params[0]); | |
| 9369 | 9379 | |
| 9370 | 9380 | const gpa = gz.astgen.gpa; |
| 9371 | 9381 | |
| ... | ... | @@ -9502,7 +9512,8 @@ fn builtinCall( |
| 9502 | 9512 | return rvalue(gz, ri, result, node); |
| 9503 | 9513 | }, |
| 9504 | 9514 | .reduce => { |
| 9505 | const op = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .reduce_op_type } }, params[0]); | |
| 9515 | const reduce_op_ty = try gz.addBuiltinValue(node, .reduce_op); | |
| 9516 | const op = try expr(gz, scope, .{ .rl = .{ .coerced_ty = reduce_op_ty } }, params[0]); | |
| 9506 | 9517 | const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]); |
| 9507 | 9518 | const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{ |
| 9508 | 9519 | .lhs = op, |
| ... | ... | @@ -9517,34 +9528,38 @@ fn builtinCall( |
| 9517 | 9528 | .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow), |
| 9518 | 9529 | |
| 9519 | 9530 | .atomic_load => { |
| 9531 | const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order); | |
| 9520 | 9532 | const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{ |
| 9521 | 9533 | // zig fmt: off |
| 9522 | .elem_type = try typeExpr(gz, scope, params[0]), | |
| 9523 | .ptr = try expr (gz, scope, .{ .rl = .none }, params[1]), | |
| 9524 | .ordering = try expr (gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[2]), | |
| 9534 | .elem_type = try typeExpr(gz, scope, params[0]), | |
| 9535 | .ptr = try expr (gz, scope, .{ .rl = .none }, params[1]), | |
| 9536 | .ordering = try expr (gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[2]), | |
| 9525 | 9537 | // zig fmt: on |
| 9526 | 9538 | }); |
| 9527 | 9539 | return rvalue(gz, ri, result, node); |
| 9528 | 9540 | }, |
| 9529 | 9541 | .atomic_rmw => { |
| 9542 | const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order); | |
| 9543 | const atomic_rmw_op_type = try gz.addBuiltinValue(node, .atomic_rmw_op); | |
| 9530 | 9544 | const int_type = try typeExpr(gz, scope, params[0]); |
| 9531 | 9545 | const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{ |
| 9532 | 9546 | // zig fmt: off |
| 9533 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9534 | .operation = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_rmw_op_type } }, params[2]), | |
| 9535 | .operand = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[3]), | |
| 9536 | .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[4]), | |
| 9547 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9548 | .operation = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_rmw_op_type } }, params[2]), | |
| 9549 | .operand = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[3]), | |
| 9550 | .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[4]), | |
| 9537 | 9551 | // zig fmt: on |
| 9538 | 9552 | }); |
| 9539 | 9553 | return rvalue(gz, ri, result, node); |
| 9540 | 9554 | }, |
| 9541 | 9555 | .atomic_store => { |
| 9556 | const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order); | |
| 9542 | 9557 | const int_type = try typeExpr(gz, scope, params[0]); |
| 9543 | 9558 | _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{ |
| 9544 | 9559 | // zig fmt: off |
| 9545 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9546 | .operand = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]), | |
| 9547 | .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[3]), | |
| 9560 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9561 | .operand = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]), | |
| 9562 | .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[3]), | |
| 9548 | 9563 | // zig fmt: on |
| 9549 | 9564 | }); |
| 9550 | 9565 | return rvalue(gz, ri, .void_value, node); |
| ... | ... | @@ -9562,7 +9577,8 @@ fn builtinCall( |
| 9562 | 9577 | return rvalue(gz, ri, result, node); |
| 9563 | 9578 | }, |
| 9564 | 9579 | .call => { |
| 9565 | const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .call_modifier_type } }, params[0]); | |
| 9580 | const call_modifier_ty = try gz.addBuiltinValue(node, .call_modifier); | |
| 9581 | const modifier = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = call_modifier_ty } }, params[0]); | |
| 9566 | 9582 | const callee = try expr(gz, scope, .{ .rl = .none }, params[1]); |
| 9567 | 9583 | const args = try expr(gz, scope, .{ .rl = .none }, params[2]); |
| 9568 | 9584 | const result = try gz.addPlNode(.builtin_call, node, Zir.Inst.BuiltinCall{ |
| ... | ... | @@ -9641,8 +9657,9 @@ fn builtinCall( |
| 9641 | 9657 | return rvalue(gz, ri, result, node); |
| 9642 | 9658 | }, |
| 9643 | 9659 | .prefetch => { |
| 9660 | const prefetch_options_ty = try gz.addBuiltinValue(node, .prefetch_options); | |
| 9644 | 9661 | const ptr = try expr(gz, scope, .{ .rl = .none }, params[0]); |
| 9645 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .prefetch_options_type } }, params[1]); | |
| 9662 | const options = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = prefetch_options_ty } }, params[1]); | |
| 9646 | 9663 | _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{ |
| 9647 | 9664 | .node = gz.nodeIndexToRelative(node), |
| 9648 | 9665 | .lhs = ptr, |
| ... | ... | @@ -9812,14 +9829,15 @@ fn cmpxchg( |
| 9812 | 9829 | small: u16, |
| 9813 | 9830 | ) InnerError!Zir.Inst.Ref { |
| 9814 | 9831 | const int_type = try typeExpr(gz, scope, params[0]); |
| 9832 | const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order); | |
| 9815 | 9833 | const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{ |
| 9816 | 9834 | // zig fmt: off |
| 9817 | 9835 | .node = gz.nodeIndexToRelative(node), |
| 9818 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9819 | .expected_value = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]), | |
| 9820 | .new_value = try expr(gz, scope, .{ .rl = .{ .coerced_ty = int_type } }, params[3]), | |
| 9821 | .success_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[4]), | |
| 9822 | .failure_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[5]), | |
| 9836 | .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]), | |
| 9837 | .expected_value = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]), | |
| 9838 | .new_value = try expr(gz, scope, .{ .rl = .{ .coerced_ty = int_type } }, params[3]), | |
| 9839 | .success_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[4]), | |
| 9840 | .failure_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[5]), | |
| 9823 | 9841 | // zig fmt: on |
| 9824 | 9842 | }); |
| 9825 | 9843 | return rvalue(gz, ri, result, node); |
| ... | ... | @@ -11106,17 +11124,6 @@ fn rvalueInner( |
| 11106 | 11124 | as_ty | @intFromEnum(Zir.Inst.Ref.null_type), |
| 11107 | 11125 | as_ty | @intFromEnum(Zir.Inst.Ref.undefined_type), |
| 11108 | 11126 | as_ty | @intFromEnum(Zir.Inst.Ref.enum_literal_type), |
| 11109 | as_ty | @intFromEnum(Zir.Inst.Ref.atomic_order_type), | |
| 11110 | as_ty | @intFromEnum(Zir.Inst.Ref.atomic_rmw_op_type), | |
| 11111 | as_ty | @intFromEnum(Zir.Inst.Ref.calling_convention_type), | |
| 11112 | as_ty | @intFromEnum(Zir.Inst.Ref.address_space_type), | |
| 11113 | as_ty | @intFromEnum(Zir.Inst.Ref.float_mode_type), | |
| 11114 | as_ty | @intFromEnum(Zir.Inst.Ref.reduce_op_type), | |
| 11115 | as_ty | @intFromEnum(Zir.Inst.Ref.call_modifier_type), | |
| 11116 | as_ty | @intFromEnum(Zir.Inst.Ref.prefetch_options_type), | |
| 11117 | as_ty | @intFromEnum(Zir.Inst.Ref.export_options_type), | |
| 11118 | as_ty | @intFromEnum(Zir.Inst.Ref.extern_options_type), | |
| 11119 | as_ty | @intFromEnum(Zir.Inst.Ref.type_info_type), | |
| 11120 | 11127 | as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_u8_type), |
| 11121 | 11128 | as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_type), |
| 11122 | 11129 | as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type), |
| ... | ... | @@ -12572,6 +12579,10 @@ const GenZir = struct { |
| 12572 | 12579 | return new_index; |
| 12573 | 12580 | } |
| 12574 | 12581 | |
| 12582 | fn addBuiltinValue(gz: *GenZir, src_node: Ast.Node.Index, val: Zir.Inst.BuiltinValue) !Zir.Inst.Ref { | |
| 12583 | return addExtendedNodeSmall(gz, .builtin_value, src_node, @intFromEnum(val)); | |
| 12584 | } | |
| 12585 | ||
| 12575 | 12586 | fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref { |
| 12576 | 12587 | return addExtendedPayloadSmall(gz, opcode, undefined, extra); |
| 12577 | 12588 | } |
lib/std/zig/Zir.zig+24-14| ... | ... | @@ -2055,6 +2055,10 @@ pub const Inst = struct { |
| 2055 | 2055 | /// Guaranteed to not have the `ptr_cast` flag. |
| 2056 | 2056 | /// Uses the `pl_node` union field with payload `FieldParentPtr`. |
| 2057 | 2057 | field_parent_ptr, |
| 2058 | /// Get a type or value from `std.builtin`. | |
| 2059 | /// `operand` is `src_node: i32`. | |
| 2060 | /// `small` is an `Inst.BuiltinValue`. | |
| 2061 | builtin_value, | |
| 2058 | 2062 | |
| 2059 | 2063 | pub const InstData = struct { |
| 2060 | 2064 | opcode: Extended, |
| ... | ... | @@ -2071,7 +2075,7 @@ pub const Inst = struct { |
| 2071 | 2075 | ref_start_index = static_len, |
| 2072 | 2076 | _, |
| 2073 | 2077 | |
| 2074 | pub const static_len = 84; | |
| 2078 | pub const static_len = 71; | |
| 2075 | 2079 | |
| 2076 | 2080 | pub fn toRef(i: Index) Inst.Ref { |
| 2077 | 2081 | return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i)); |
| ... | ... | @@ -2148,17 +2152,6 @@ pub const Inst = struct { |
| 2148 | 2152 | null_type, |
| 2149 | 2153 | undefined_type, |
| 2150 | 2154 | enum_literal_type, |
| 2151 | atomic_order_type, | |
| 2152 | atomic_rmw_op_type, | |
| 2153 | calling_convention_type, | |
| 2154 | address_space_type, | |
| 2155 | float_mode_type, | |
| 2156 | reduce_op_type, | |
| 2157 | call_modifier_type, | |
| 2158 | prefetch_options_type, | |
| 2159 | export_options_type, | |
| 2160 | extern_options_type, | |
| 2161 | type_info_type, | |
| 2162 | 2155 | manyptr_u8_type, |
| 2163 | 2156 | manyptr_const_u8_type, |
| 2164 | 2157 | manyptr_const_u8_sentinel_0_type, |
| ... | ... | @@ -2179,8 +2172,6 @@ pub const Inst = struct { |
| 2179 | 2172 | one_u8, |
| 2180 | 2173 | four_u8, |
| 2181 | 2174 | negative_one, |
| 2182 | calling_convention_c, | |
| 2183 | calling_convention_inline, | |
| 2184 | 2175 | void_value, |
| 2185 | 2176 | unreachable_value, |
| 2186 | 2177 | null_value, |
| ... | ... | @@ -3146,6 +3137,24 @@ pub const Inst = struct { |
| 3146 | 3137 | } |
| 3147 | 3138 | }; |
| 3148 | 3139 | |
| 3140 | pub const BuiltinValue = enum(u16) { | |
| 3141 | // Types | |
| 3142 | atomic_order, | |
| 3143 | atomic_rmw_op, | |
| 3144 | calling_convention, | |
| 3145 | address_space, | |
| 3146 | float_mode, | |
| 3147 | reduce_op, | |
| 3148 | call_modifier, | |
| 3149 | prefetch_options, | |
| 3150 | export_options, | |
| 3151 | extern_options, | |
| 3152 | type_info, | |
| 3153 | // Values | |
| 3154 | calling_convention_c, | |
| 3155 | calling_convention_inline, | |
| 3156 | }; | |
| 3157 | ||
| 3149 | 3158 | /// Trailing: |
| 3150 | 3159 | /// 0. tag_type: Ref, // if has_tag_type |
| 3151 | 3160 | /// 1. captures_len: u32, // if has_captures_len |
| ... | ... | @@ -3977,6 +3986,7 @@ fn findDeclsInner( |
| 3977 | 3986 | .restore_err_ret_index, |
| 3978 | 3987 | .closure_get, |
| 3979 | 3988 | .field_parent_ptr, |
| 3989 | .builtin_value, | |
| 3980 | 3990 | => return, |
| 3981 | 3991 | |
| 3982 | 3992 | // `@TypeOf` has a body. |
src/Air.zig-13| ... | ... | @@ -938,17 +938,6 @@ pub const Inst = struct { |
| 938 | 938 | null_type = @intFromEnum(InternPool.Index.null_type), |
| 939 | 939 | undefined_type = @intFromEnum(InternPool.Index.undefined_type), |
| 940 | 940 | enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type), |
| 941 | atomic_order_type = @intFromEnum(InternPool.Index.atomic_order_type), | |
| 942 | atomic_rmw_op_type = @intFromEnum(InternPool.Index.atomic_rmw_op_type), | |
| 943 | calling_convention_type = @intFromEnum(InternPool.Index.calling_convention_type), | |
| 944 | address_space_type = @intFromEnum(InternPool.Index.address_space_type), | |
| 945 | float_mode_type = @intFromEnum(InternPool.Index.float_mode_type), | |
| 946 | reduce_op_type = @intFromEnum(InternPool.Index.reduce_op_type), | |
| 947 | call_modifier_type = @intFromEnum(InternPool.Index.call_modifier_type), | |
| 948 | prefetch_options_type = @intFromEnum(InternPool.Index.prefetch_options_type), | |
| 949 | export_options_type = @intFromEnum(InternPool.Index.export_options_type), | |
| 950 | extern_options_type = @intFromEnum(InternPool.Index.extern_options_type), | |
| 951 | type_info_type = @intFromEnum(InternPool.Index.type_info_type), | |
| 952 | 941 | manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type), |
| 953 | 942 | manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type), |
| 954 | 943 | manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type), |
| ... | ... | @@ -969,8 +958,6 @@ pub const Inst = struct { |
| 969 | 958 | one_u8 = @intFromEnum(InternPool.Index.one_u8), |
| 970 | 959 | four_u8 = @intFromEnum(InternPool.Index.four_u8), |
| 971 | 960 | negative_one = @intFromEnum(InternPool.Index.negative_one), |
| 972 | calling_convention_c = @intFromEnum(InternPool.Index.calling_convention_c), | |
| 973 | calling_convention_inline = @intFromEnum(InternPool.Index.calling_convention_inline), | |
| 974 | 961 | void_value = @intFromEnum(InternPool.Index.void_value), |
| 975 | 962 | unreachable_value = @intFromEnum(InternPool.Index.unreachable_value), |
| 976 | 963 | null_value = @intFromEnum(InternPool.Index.null_value), |
src/InternPool.zig+11-143| ... | ... | @@ -2160,6 +2160,14 @@ pub const Key = union(enum) { |
| 2160 | 2160 | pub fn resolvedErrorSetUnordered(func: Func, ip: *const InternPool) Index { |
| 2161 | 2161 | return @atomicLoad(Index, func.resolvedErrorSetPtr(@constCast(ip)), .unordered); |
| 2162 | 2162 | } |
| 2163 | ||
| 2164 | pub fn setResolvedErrorSet(func: Func, ip: *InternPool, ies: Index) void { | |
| 2165 | const extra_mutex = &ip.getLocal(func.tid).mutate.extra.mutex; | |
| 2166 | extra_mutex.lock(); | |
| 2167 | defer extra_mutex.unlock(); | |
| 2168 | ||
| 2169 | @atomicStore(Index, func.resolvedErrorSetPtr(ip), ies, .release); | |
| 2170 | } | |
| 2163 | 2171 | }; |
| 2164 | 2172 | |
| 2165 | 2173 | pub const Int = struct { |
| ... | ... | @@ -4403,17 +4411,6 @@ pub const Index = enum(u32) { |
| 4403 | 4411 | null_type, |
| 4404 | 4412 | undefined_type, |
| 4405 | 4413 | enum_literal_type, |
| 4406 | atomic_order_type, | |
| 4407 | atomic_rmw_op_type, | |
| 4408 | calling_convention_type, | |
| 4409 | address_space_type, | |
| 4410 | float_mode_type, | |
| 4411 | reduce_op_type, | |
| 4412 | call_modifier_type, | |
| 4413 | prefetch_options_type, | |
| 4414 | export_options_type, | |
| 4415 | extern_options_type, | |
| 4416 | type_info_type, | |
| 4417 | 4414 | manyptr_u8_type, |
| 4418 | 4415 | manyptr_const_u8_type, |
| 4419 | 4416 | manyptr_const_u8_sentinel_0_type, |
| ... | ... | @@ -4446,10 +4443,6 @@ pub const Index = enum(u32) { |
| 4446 | 4443 | four_u8, |
| 4447 | 4444 | /// `-1` (comptime_int) |
| 4448 | 4445 | negative_one, |
| 4449 | /// `std.builtin.CallingConvention.C` | |
| 4450 | calling_convention_c, | |
| 4451 | /// `std.builtin.CallingConvention.Inline` | |
| 4452 | calling_convention_inline, | |
| 4453 | 4446 | /// `{}` |
| 4454 | 4447 | void_value, |
| 4455 | 4448 | /// `unreachable` (noreturn type) |
| ... | ... | @@ -4829,17 +4822,6 @@ pub const static_keys = [_]Key{ |
| 4829 | 4822 | .{ .simple_type = .null }, |
| 4830 | 4823 | .{ .simple_type = .undefined }, |
| 4831 | 4824 | .{ .simple_type = .enum_literal }, |
| 4832 | .{ .simple_type = .atomic_order }, | |
| 4833 | .{ .simple_type = .atomic_rmw_op }, | |
| 4834 | .{ .simple_type = .calling_convention }, | |
| 4835 | .{ .simple_type = .address_space }, | |
| 4836 | .{ .simple_type = .float_mode }, | |
| 4837 | .{ .simple_type = .reduce_op }, | |
| 4838 | .{ .simple_type = .call_modifier }, | |
| 4839 | .{ .simple_type = .prefetch_options }, | |
| 4840 | .{ .simple_type = .export_options }, | |
| 4841 | .{ .simple_type = .extern_options }, | |
| 4842 | .{ .simple_type = .type_info }, | |
| 4843 | 4825 | |
| 4844 | 4826 | // [*]u8 |
| 4845 | 4827 | .{ .ptr_type = .{ |
| ... | ... | @@ -4868,7 +4850,7 @@ pub const static_keys = [_]Key{ |
| 4868 | 4850 | }, |
| 4869 | 4851 | } }, |
| 4870 | 4852 | |
| 4871 | // comptime_int | |
| 4853 | // *const comptime_int | |
| 4872 | 4854 | .{ .ptr_type = .{ |
| 4873 | 4855 | .child = .comptime_int_type, |
| 4874 | 4856 | .flags = .{ |
| ... | ... | @@ -4959,16 +4941,6 @@ pub const static_keys = [_]Key{ |
| 4959 | 4941 | .ty = .comptime_int_type, |
| 4960 | 4942 | .storage = .{ .i64 = -1 }, |
| 4961 | 4943 | } }, |
| 4962 | // calling_convention_c | |
| 4963 | .{ .enum_tag = .{ | |
| 4964 | .ty = .calling_convention_type, | |
| 4965 | .int = .one_u8, | |
| 4966 | } }, | |
| 4967 | // calling_convention_inline | |
| 4968 | .{ .enum_tag = .{ | |
| 4969 | .ty = .calling_convention_type, | |
| 4970 | .int = .four_u8, | |
| 4971 | } }, | |
| 4972 | 4944 | |
| 4973 | 4945 | .{ .simple_value = .void }, |
| 4974 | 4946 | .{ .simple_value = .@"unreachable" }, |
| ... | ... | @@ -5682,18 +5654,6 @@ pub const SimpleType = enum(u32) { |
| 5682 | 5654 | undefined = @intFromEnum(Index.undefined_type), |
| 5683 | 5655 | enum_literal = @intFromEnum(Index.enum_literal_type), |
| 5684 | 5656 | |
| 5685 | atomic_order = @intFromEnum(Index.atomic_order_type), | |
| 5686 | atomic_rmw_op = @intFromEnum(Index.atomic_rmw_op_type), | |
| 5687 | calling_convention = @intFromEnum(Index.calling_convention_type), | |
| 5688 | address_space = @intFromEnum(Index.address_space_type), | |
| 5689 | float_mode = @intFromEnum(Index.float_mode_type), | |
| 5690 | reduce_op = @intFromEnum(Index.reduce_op_type), | |
| 5691 | call_modifier = @intFromEnum(Index.call_modifier_type), | |
| 5692 | prefetch_options = @intFromEnum(Index.prefetch_options_type), | |
| 5693 | export_options = @intFromEnum(Index.export_options_type), | |
| 5694 | extern_options = @intFromEnum(Index.extern_options_type), | |
| 5695 | type_info = @intFromEnum(Index.type_info_type), | |
| 5696 | ||
| 5697 | 5657 | adhoc_inferred_error_set = @intFromEnum(Index.adhoc_inferred_error_set_type), |
| 5698 | 5658 | generic_poison = @intFromEnum(Index.generic_poison_type), |
| 5699 | 5659 | }; |
| ... | ... | @@ -6273,18 +6233,6 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void { |
| 6273 | 6233 | // Sanity check. |
| 6274 | 6234 | assert(ip.indexToKey(.bool_true).simple_value == .true); |
| 6275 | 6235 | assert(ip.indexToKey(.bool_false).simple_value == .false); |
| 6276 | ||
| 6277 | const cc_inline = ip.indexToKey(.calling_convention_inline).enum_tag.int; | |
| 6278 | const cc_c = ip.indexToKey(.calling_convention_c).enum_tag.int; | |
| 6279 | ||
| 6280 | assert(ip.indexToKey(cc_inline).int.storage.u64 == | |
| 6281 | @intFromEnum(std.builtin.CallingConvention.Inline)); | |
| 6282 | ||
| 6283 | assert(ip.indexToKey(cc_c).int.storage.u64 == | |
| 6284 | @intFromEnum(std.builtin.CallingConvention.C)); | |
| 6285 | ||
| 6286 | assert(ip.indexToKey(ip.typeOf(cc_inline)).int_type.bits == | |
| 6287 | @typeInfo(@typeInfo(std.builtin.CallingConvention).Enum.tag_type).Int.bits); | |
| 6288 | 6236 | } |
| 6289 | 6237 | } |
| 6290 | 6238 | |
| ... | ... | @@ -7100,7 +7048,7 @@ fn getOrPutKeyEnsuringAdditionalCapacity( |
| 7100 | 7048 | const index = entry.acquire(); |
| 7101 | 7049 | if (index == .none) break; |
| 7102 | 7050 | if (entry.hash != hash) continue; |
| 7103 | if (ip.isRemoved(index)) continue; | |
| 7051 | if (index.unwrap(ip).getTag(ip) == .removed) continue; | |
| 7104 | 7052 | if (ip.indexToKey(index).eql(key, ip)) return .{ .existing = index }; |
| 7105 | 7053 | } |
| 7106 | 7054 | shard.mutate.map.mutex.lock(); |
| ... | ... | @@ -9735,14 +9683,6 @@ fn addMap(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, cap: usize) Al |
| 9735 | 9683 | /// Invalidates all references to this index. |
| 9736 | 9684 | pub fn remove(ip: *InternPool, tid: Zcu.PerThread.Id, index: Index) void { |
| 9737 | 9685 | const unwrapped_index = index.unwrap(ip); |
| 9738 | if (@intFromEnum(index) < static_keys.len) { | |
| 9739 | // The item being removed replaced a special index via `InternPool.resolveBuiltinType`. | |
| 9740 | // Restore the original item at this index. | |
| 9741 | assert(static_keys[@intFromEnum(index)] == .simple_type); | |
| 9742 | const items = ip.getLocalShared(unwrapped_index.tid).items.acquire().view(); | |
| 9743 | @atomicStore(Tag, &items.items(.tag)[unwrapped_index.index], .simple_type, .unordered); | |
| 9744 | return; | |
| 9745 | } | |
| 9746 | 9686 | |
| 9747 | 9687 | if (unwrapped_index.tid == tid) { |
| 9748 | 9688 | const items_len = &ip.getLocal(unwrapped_index.tid).mutate.items.len; |
| ... | ... | @@ -10382,17 +10322,7 @@ pub fn isIntegerType(ip: *const InternPool, ty: Index) bool { |
| 10382 | 10322 | |
| 10383 | 10323 | /// does not include .enum_literal_type |
| 10384 | 10324 | pub fn isEnumType(ip: *const InternPool, ty: Index) bool { |
| 10385 | return switch (ty) { | |
| 10386 | .atomic_order_type, | |
| 10387 | .atomic_rmw_op_type, | |
| 10388 | .calling_convention_type, | |
| 10389 | .address_space_type, | |
| 10390 | .float_mode_type, | |
| 10391 | .reduce_op_type, | |
| 10392 | .call_modifier_type, | |
| 10393 | => true, | |
| 10394 | else => ip.indexToKey(ty) == .enum_type, | |
| 10395 | }; | |
| 10325 | return ip.indexToKey(ty) == .enum_type; | |
| 10396 | 10326 | } |
| 10397 | 10327 | |
| 10398 | 10328 | pub fn isUnion(ip: *const InternPool, ty: Index) bool { |
| ... | ... | @@ -11393,17 +11323,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { |
| 11393 | 11323 | .null_type, |
| 11394 | 11324 | .undefined_type, |
| 11395 | 11325 | .enum_literal_type, |
| 11396 | .atomic_order_type, | |
| 11397 | .atomic_rmw_op_type, | |
| 11398 | .calling_convention_type, | |
| 11399 | .address_space_type, | |
| 11400 | .float_mode_type, | |
| 11401 | .reduce_op_type, | |
| 11402 | .call_modifier_type, | |
| 11403 | .prefetch_options_type, | |
| 11404 | .export_options_type, | |
| 11405 | .extern_options_type, | |
| 11406 | .type_info_type, | |
| 11407 | 11326 | .manyptr_u8_type, |
| 11408 | 11327 | .manyptr_const_u8_type, |
| 11409 | 11328 | .manyptr_const_u8_sentinel_0_type, |
| ... | ... | @@ -11421,7 +11340,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { |
| 11421 | 11340 | .zero, .one, .negative_one => .comptime_int_type, |
| 11422 | 11341 | .zero_usize, .one_usize => .usize_type, |
| 11423 | 11342 | .zero_u8, .one_u8, .four_u8 => .u8_type, |
| 11424 | .calling_convention_c, .calling_convention_inline => .calling_convention_type, | |
| 11425 | 11343 | .void_value => .void_type, |
| 11426 | 11344 | .unreachable_value => .noreturn_type, |
| 11427 | 11345 | .null_value => .null_type, |
| ... | ... | @@ -11717,22 +11635,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11717 | 11635 | .undefined_type => .Undefined, |
| 11718 | 11636 | .enum_literal_type => .EnumLiteral, |
| 11719 | 11637 | |
| 11720 | .atomic_order_type, | |
| 11721 | .atomic_rmw_op_type, | |
| 11722 | .calling_convention_type, | |
| 11723 | .address_space_type, | |
| 11724 | .float_mode_type, | |
| 11725 | .reduce_op_type, | |
| 11726 | .call_modifier_type, | |
| 11727 | => .Enum, | |
| 11728 | ||
| 11729 | .prefetch_options_type, | |
| 11730 | .export_options_type, | |
| 11731 | .extern_options_type, | |
| 11732 | => .Struct, | |
| 11733 | ||
| 11734 | .type_info_type => .Union, | |
| 11735 | ||
| 11736 | 11638 | .manyptr_u8_type, |
| 11737 | 11639 | .manyptr_const_u8_type, |
| 11738 | 11640 | .manyptr_const_u8_sentinel_0_type, |
| ... | ... | @@ -11757,8 +11659,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois |
| 11757 | 11659 | .one_u8 => unreachable, |
| 11758 | 11660 | .four_u8 => unreachable, |
| 11759 | 11661 | .negative_one => unreachable, |
| 11760 | .calling_convention_c => unreachable, | |
| 11761 | .calling_convention_inline => unreachable, | |
| 11762 | 11662 | .void_value => unreachable, |
| 11763 | 11663 | .unreachable_value => unreachable, |
| 11764 | 11664 | .null_value => unreachable, |
| ... | ... | @@ -12077,34 +11977,6 @@ pub fn unwrapCoercedFunc(ip: *const InternPool, index: Index) Index { |
| 12077 | 11977 | }; |
| 12078 | 11978 | } |
| 12079 | 11979 | |
| 12080 | /// Having resolved a builtin type to a real struct/union/enum (which is now at `resolverd_index`), | |
| 12081 | /// make `want_index` refer to this type instead. This invalidates `resolved_index`, so must be | |
| 12082 | /// called only when it is guaranteed that no reference to `resolved_index` exists. | |
| 12083 | pub fn resolveBuiltinType( | |
| 12084 | ip: *InternPool, | |
| 12085 | tid: Zcu.PerThread.Id, | |
| 12086 | want_index: Index, | |
| 12087 | resolved_index: Index, | |
| 12088 | ) void { | |
| 12089 | assert(@intFromEnum(want_index) >= @intFromEnum(Index.first_type)); | |
| 12090 | assert(@intFromEnum(want_index) <= @intFromEnum(Index.last_type)); | |
| 12091 | ||
| 12092 | // Make sure the type isn't already resolved! | |
| 12093 | assert(ip.indexToKey(want_index) == .simple_type); | |
| 12094 | ||
| 12095 | // Make sure it's the same kind of type | |
| 12096 | assert((ip.zigTypeTagOrPoison(want_index) catch unreachable) == | |
| 12097 | (ip.zigTypeTagOrPoison(resolved_index) catch unreachable)); | |
| 12098 | ||
| 12099 | // Copy the data | |
| 12100 | const item = resolved_index.unwrap(ip).getItem(ip); | |
| 12101 | const unwrapped_index = want_index.unwrap(ip); | |
| 12102 | var items = ip.getLocalShared(unwrapped_index.tid).items.acquire().view().slice(); | |
| 12103 | items.items(.data)[unwrapped_index.index] = item.data; | |
| 12104 | @atomicStore(Tag, &items.items(.tag)[unwrapped_index.index], item.tag, .release); | |
| 12105 | ip.remove(tid, resolved_index); | |
| 12106 | } | |
| 12107 | ||
| 12108 | 11980 | pub fn anonStructFieldTypes(ip: *const InternPool, i: Index) []const Index { |
| 12109 | 11981 | return ip.indexToKey(i).anon_struct_type.types; |
| 12110 | 11982 | } |
| ... | ... | @@ -12303,7 +12175,3 @@ pub fn getErrorValue( |
| 12303 | 12175 | pub fn getErrorValueIfExists(ip: *const InternPool, name: NullTerminatedString) ?Zcu.ErrorInt { |
| 12304 | 12176 | return @intFromEnum(ip.global_error_set.getErrorValueIfExists(name) orelse return null); |
| 12305 | 12177 | } |
| 12306 | ||
| 12307 | pub fn isRemoved(ip: *const InternPool, ty: Index) bool { | |
| 12308 | return ty.unwrap(ip).getTag(ip) == .removed; | |
| 12309 | } |
src/Sema.zig+55-41| ... | ... | @@ -76,10 +76,6 @@ no_partial_func_ty: bool = false, |
| 76 | 76 | /// here so the values can be dropped without any cleanup. |
| 77 | 77 | unresolved_inferred_allocs: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, InferredAlloc) = .{}, |
| 78 | 78 | |
| 79 | /// While analyzing a type which has a special InternPool index, this is set to the index at which | |
| 80 | /// the struct/enum/union type created should be placed. Otherwise, it is `.none`. | |
| 81 | builtin_type_target_index: InternPool.Index = .none, | |
| 82 | ||
| 83 | 79 | /// Links every pointer derived from a base `alloc` back to that `alloc`. Used |
| 84 | 80 | /// to detect comptime-known `const`s. |
| 85 | 81 | /// TODO: ZIR liveness analysis would allow us to remove elements from this map. |
| ... | ... | @@ -1327,6 +1323,7 @@ fn analyzeBodyInner( |
| 1327 | 1323 | }, |
| 1328 | 1324 | .value_placeholder => unreachable, // never appears in a body |
| 1329 | 1325 | .field_parent_ptr => try sema.zirFieldParentPtr(block, extended), |
| 1326 | .builtin_value => try sema.zirBuiltinValue(extended), | |
| 1330 | 1327 | }; |
| 1331 | 1328 | }, |
| 1332 | 1329 | |
| ... | ... | @@ -2712,17 +2709,6 @@ fn getCaptures(sema: *Sema, block: *Block, type_src: LazySrcLoc, extra_index: us |
| 2712 | 2709 | return captures; |
| 2713 | 2710 | } |
| 2714 | 2711 | |
| 2715 | /// Given an `InternPool.WipNamespaceType` or `InternPool.WipEnumType`, apply | |
| 2716 | /// `sema.builtin_type_target_index` to it if necessary. | |
| 2717 | fn wrapWipTy(sema: *Sema, wip_ty: anytype) @TypeOf(wip_ty) { | |
| 2718 | const pt = sema.pt; | |
| 2719 | if (sema.builtin_type_target_index == .none) return wip_ty; | |
| 2720 | var new = wip_ty; | |
| 2721 | new.index = sema.builtin_type_target_index; | |
| 2722 | pt.zcu.intern_pool.resolveBuiltinType(pt.tid, new.index, wip_ty.index); | |
| 2723 | return new; | |
| 2724 | } | |
| 2725 | ||
| 2726 | 2712 | fn zirStructDecl( |
| 2727 | 2713 | sema: *Sema, |
| 2728 | 2714 | block: *Block, |
| ... | ... | @@ -2788,7 +2774,7 @@ fn zirStructDecl( |
| 2788 | 2774 | .captures = captures, |
| 2789 | 2775 | } }, |
| 2790 | 2776 | }; |
| 2791 | const wip_ty = sema.wrapWipTy(switch (try ip.getStructType(gpa, pt.tid, struct_init, false)) { | |
| 2777 | const wip_ty = switch (try ip.getStructType(gpa, pt.tid, struct_init, false)) { | |
| 2792 | 2778 | .existing => |ty| { |
| 2793 | 2779 | const new_ty = try pt.ensureTypeUpToDate(ty, false); |
| 2794 | 2780 | |
| ... | ... | @@ -2801,7 +2787,7 @@ fn zirStructDecl( |
| 2801 | 2787 | return Air.internedToRef(new_ty); |
| 2802 | 2788 | }, |
| 2803 | 2789 | .wip => |wip| wip, |
| 2804 | }); | |
| 2790 | }; | |
| 2805 | 2791 | errdefer wip_ty.cancel(ip, pt.tid); |
| 2806 | 2792 | |
| 2807 | 2793 | wip_ty.setName(ip, try sema.createTypeName( |
| ... | ... | @@ -3017,7 +3003,7 @@ fn zirEnumDecl( |
| 3017 | 3003 | .captures = captures, |
| 3018 | 3004 | } }, |
| 3019 | 3005 | }; |
| 3020 | const wip_ty = sema.wrapWipTy(switch (try ip.getEnumType(gpa, pt.tid, enum_init, false)) { | |
| 3006 | const wip_ty = switch (try ip.getEnumType(gpa, pt.tid, enum_init, false)) { | |
| 3021 | 3007 | .existing => |ty| { |
| 3022 | 3008 | const new_ty = try pt.ensureTypeUpToDate(ty, false); |
| 3023 | 3009 | |
| ... | ... | @@ -3030,7 +3016,7 @@ fn zirEnumDecl( |
| 3030 | 3016 | return Air.internedToRef(new_ty); |
| 3031 | 3017 | }, |
| 3032 | 3018 | .wip => |wip| wip, |
| 3033 | }); | |
| 3019 | }; | |
| 3034 | 3020 | |
| 3035 | 3021 | // Once this is `true`, we will not delete the decl or type even upon failure, since we |
| 3036 | 3022 | // have finished constructing the type and are in the process of analyzing it. |
| ... | ... | @@ -3161,7 +3147,7 @@ fn zirUnionDecl( |
| 3161 | 3147 | .captures = captures, |
| 3162 | 3148 | } }, |
| 3163 | 3149 | }; |
| 3164 | const wip_ty = sema.wrapWipTy(switch (try ip.getUnionType(gpa, pt.tid, union_init, false)) { | |
| 3150 | const wip_ty = switch (try ip.getUnionType(gpa, pt.tid, union_init, false)) { | |
| 3165 | 3151 | .existing => |ty| { |
| 3166 | 3152 | const new_ty = try pt.ensureTypeUpToDate(ty, false); |
| 3167 | 3153 | |
| ... | ... | @@ -3174,7 +3160,7 @@ fn zirUnionDecl( |
| 3174 | 3160 | return Air.internedToRef(new_ty); |
| 3175 | 3161 | }, |
| 3176 | 3162 | .wip => |wip| wip, |
| 3177 | }); | |
| 3163 | }; | |
| 3178 | 3164 | errdefer wip_ty.cancel(ip, pt.tid); |
| 3179 | 3165 | |
| 3180 | 3166 | wip_ty.setName(ip, try sema.createTypeName( |
| ... | ... | @@ -3259,7 +3245,6 @@ fn zirOpaqueDecl( |
| 3259 | 3245 | .captures = captures, |
| 3260 | 3246 | } }, |
| 3261 | 3247 | }; |
| 3262 | // No `wrapWipTy` needed as no std.builtin types are opaque. | |
| 3263 | 3248 | const wip_ty = switch (try ip.getOpaqueType(gpa, pt.tid, opaque_init)) { |
| 3264 | 3249 | .existing => |ty| { |
| 3265 | 3250 | // Make sure we update the namespace if the declaration is re-analyzed, to pick |
| ... | ... | @@ -26179,7 +26164,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26179 | 26164 | const body = sema.code.bodySlice(extra_index, body_len); |
| 26180 | 26165 | extra_index += body.len; |
| 26181 | 26166 | |
| 26182 | const addrspace_ty = Type.fromInterned(.address_space_type); | |
| 26167 | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); | |
| 26183 | 26168 | const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, .{ |
| 26184 | 26169 | .needed_comptime_reason = "addrspace must be comptime-known", |
| 26185 | 26170 | }); |
| ... | ... | @@ -26190,7 +26175,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26190 | 26175 | } else if (extra.data.bits.has_addrspace_ref) blk: { |
| 26191 | 26176 | const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 26192 | 26177 | extra_index += 1; |
| 26193 | const addrspace_ty = Type.fromInterned(.address_space_type); | |
| 26178 | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); | |
| 26194 | 26179 | const uncoerced_addrspace = sema.resolveInst(addrspace_ref) catch |err| switch (err) { |
| 26195 | 26180 | error.GenericPoison => break :blk null, |
| 26196 | 26181 | else => |e| return e, |
| ... | ... | @@ -26255,7 +26240,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 26255 | 26240 | } else if (extra.data.bits.has_cc_ref) blk: { |
| 26256 | 26241 | const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]); |
| 26257 | 26242 | extra_index += 1; |
| 26258 | const cc_ty = Type.fromInterned(.calling_convention_type); | |
| 26243 | const cc_ty = try pt.getBuiltinType("CallingConvention"); | |
| 26259 | 26244 | const uncoerced_cc = sema.resolveInst(cc_ref) catch |err| switch (err) { |
| 26260 | 26245 | error.GenericPoison => break :blk null, |
| 26261 | 26246 | else => |e| return e, |
| ... | ... | @@ -26713,6 +26698,46 @@ fn zirInComptime( |
| 26713 | 26698 | return if (block.is_comptime) .bool_true else .bool_false; |
| 26714 | 26699 | } |
| 26715 | 26700 | |
| 26701 | fn zirBuiltinValue(sema: *Sema, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | |
| 26702 | const pt = sema.pt; | |
| 26703 | const value: Zir.Inst.BuiltinValue = @enumFromInt(extended.small); | |
| 26704 | const type_name = switch (value) { | |
| 26705 | .atomic_order => "AtomicOrder", | |
| 26706 | .atomic_rmw_op => "AtomicRmwOp", | |
| 26707 | .calling_convention => "CallingConvention", | |
| 26708 | .address_space => "AddressSpace", | |
| 26709 | .float_mode => "FloatMode", | |
| 26710 | .reduce_op => "ReduceOp", | |
| 26711 | .call_modifier => "CallModifier", | |
| 26712 | .prefetch_options => "PrefetchOptions", | |
| 26713 | .export_options => "ExportOptions", | |
| 26714 | .extern_options => "ExternOptions", | |
| 26715 | .type_info => "Type", | |
| 26716 | ||
| 26717 | // Values are handled here. | |
| 26718 | .calling_convention_c => { | |
| 26719 | const callconv_ty = try pt.getBuiltinType("CallingConvention"); | |
| 26720 | comptime assert(@intFromEnum(std.builtin.CallingConvention.C) == 1); | |
| 26721 | const val = try pt.intern(.{ .enum_tag = .{ | |
| 26722 | .ty = callconv_ty.toIntern(), | |
| 26723 | .int = .one_u8, | |
| 26724 | } }); | |
| 26725 | return Air.internedToRef(val); | |
| 26726 | }, | |
| 26727 | .calling_convention_inline => { | |
| 26728 | const callconv_ty = try pt.getBuiltinType("CallingConvention"); | |
| 26729 | comptime assert(@intFromEnum(std.builtin.CallingConvention.Inline) == 4); | |
| 26730 | const val = try pt.intern(.{ .enum_tag = .{ | |
| 26731 | .ty = callconv_ty.toIntern(), | |
| 26732 | .int = .four_u8, | |
| 26733 | } }); | |
| 26734 | return Air.internedToRef(val); | |
| 26735 | }, | |
| 26736 | }; | |
| 26737 | const ty = try pt.getBuiltinType(type_name); | |
| 26738 | return Air.internedToRef(ty.toIntern()); | |
| 26739 | } | |
| 26740 | ||
| 26716 | 26741 | fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void { |
| 26717 | 26742 | if (block.is_comptime) { |
| 26718 | 26743 | const msg = msg: { |
| ... | ... | @@ -32527,6 +32552,7 @@ fn analyzeIsNonErrComptimeOnly( |
| 32527 | 32552 | // If the error set is empty, we must return a comptime true or false. |
| 32528 | 32553 | // However we want to avoid unnecessarily resolving an inferred error set |
| 32529 | 32554 | // in case it is already non-empty. |
| 32555 | try mod.maybeUnresolveIes(func_index); | |
| 32530 | 32556 | switch (ip.funcIesResolvedUnordered(func_index)) { |
| 32531 | 32557 | .anyerror_type => break :blk, |
| 32532 | 32558 | .none => {}, |
| ... | ... | @@ -33596,6 +33622,7 @@ fn wrapErrorUnionSet( |
| 33596 | 33622 | .inferred_error_set_type => |func_index| ok: { |
| 33597 | 33623 | // We carefully do this in an order that avoids unnecessarily |
| 33598 | 33624 | // resolving the destination error set type. |
| 33625 | try mod.maybeUnresolveIes(func_index); | |
| 33599 | 33626 | switch (ip.funcIesResolvedUnordered(func_index)) { |
| 33600 | 33627 | .anyerror_type => break :ok, |
| 33601 | 33628 | .none => if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, dest_err_set_ty, inst_ty, inst_src, inst_src)) { |
| ... | ... | @@ -35853,8 +35880,7 @@ fn resolveInferredErrorSet( |
| 35853 | 35880 | |
| 35854 | 35881 | try sema.declareDependency(.{ .interned = func_index }); // resolved IES |
| 35855 | 35882 | |
| 35856 | // TODO: during an incremental update this might not be `.none`, but the | |
| 35857 | // function might be out-of-date! | |
| 35883 | try zcu.maybeUnresolveIes(func_index); | |
| 35858 | 35884 | const resolved_ty = func.resolvedErrorSetUnordered(ip); |
| 35859 | 35885 | if (resolved_ty != .none) return resolved_ty; |
| 35860 | 35886 | |
| ... | ... | @@ -36898,17 +36924,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36898 | 36924 | .comptime_int_type, |
| 36899 | 36925 | .comptime_float_type, |
| 36900 | 36926 | .enum_literal_type, |
| 36901 | .atomic_order_type, | |
| 36902 | .atomic_rmw_op_type, | |
| 36903 | .calling_convention_type, | |
| 36904 | .address_space_type, | |
| 36905 | .float_mode_type, | |
| 36906 | .reduce_op_type, | |
| 36907 | .call_modifier_type, | |
| 36908 | .prefetch_options_type, | |
| 36909 | .export_options_type, | |
| 36910 | .extern_options_type, | |
| 36911 | .type_info_type, | |
| 36912 | 36927 | .manyptr_u8_type, |
| 36913 | 36928 | .manyptr_const_u8_type, |
| 36914 | 36929 | .manyptr_const_u8_sentinel_0_type, |
| ... | ... | @@ -36935,8 +36950,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value { |
| 36935 | 36950 | .one_u8, |
| 36936 | 36951 | .four_u8, |
| 36937 | 36952 | .negative_one, |
| 36938 | .calling_convention_c, | |
| 36939 | .calling_convention_inline, | |
| 36940 | 36953 | .void_value, |
| 36941 | 36954 | .unreachable_value, |
| 36942 | 36955 | .null_value, |
| ... | ... | @@ -37290,7 +37303,8 @@ pub fn analyzeAsAddressSpace( |
| 37290 | 37303 | ) !std.builtin.AddressSpace { |
| 37291 | 37304 | const pt = sema.pt; |
| 37292 | 37305 | const mod = pt.zcu; |
| 37293 | const coerced = try sema.coerce(block, Type.fromInterned(.address_space_type), air_ref, src); | |
| 37306 | const addrspace_ty = try pt.getBuiltinType("AddressSpace"); | |
| 37307 | const coerced = try sema.coerce(block, addrspace_ty, air_ref, src); | |
| 37294 | 37308 | const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{ |
| 37295 | 37309 | .needed_comptime_reason = "address space must be comptime-known", |
| 37296 | 37310 | }); |
src/Type.zig+1-129| ... | ... | @@ -316,17 +316,6 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error |
| 316 | 316 | => try writer.print("@TypeOf({s})", .{@tagName(s)}), |
| 317 | 317 | |
| 318 | 318 | .enum_literal => try writer.print("@TypeOf(.{s})", .{@tagName(s)}), |
| 319 | .atomic_order => try writer.writeAll("std.builtin.AtomicOrder"), | |
| 320 | .atomic_rmw_op => try writer.writeAll("std.builtin.AtomicRmwOp"), | |
| 321 | .calling_convention => try writer.writeAll("std.builtin.CallingConvention"), | |
| 322 | .address_space => try writer.writeAll("std.builtin.AddressSpace"), | |
| 323 | .float_mode => try writer.writeAll("std.builtin.FloatMode"), | |
| 324 | .reduce_op => try writer.writeAll("std.builtin.ReduceOp"), | |
| 325 | .call_modifier => try writer.writeAll("std.builtin.CallModifier"), | |
| 326 | .prefetch_options => try writer.writeAll("std.builtin.PrefetchOptions"), | |
| 327 | .export_options => try writer.writeAll("std.builtin.ExportOptions"), | |
| 328 | .extern_options => try writer.writeAll("std.builtin.ExternOptions"), | |
| 329 | .type_info => try writer.writeAll("std.builtin.Type"), | |
| 330 | 319 | |
| 331 | 320 | .generic_poison => unreachable, |
| 332 | 321 | }, |
| ... | ... | @@ -544,16 +533,6 @@ pub fn hasRuntimeBitsAdvanced( |
| 544 | 533 | .anyerror, |
| 545 | 534 | .adhoc_inferred_error_set, |
| 546 | 535 | .anyopaque, |
| 547 | .atomic_order, | |
| 548 | .atomic_rmw_op, | |
| 549 | .calling_convention, | |
| 550 | .address_space, | |
| 551 | .float_mode, | |
| 552 | .reduce_op, | |
| 553 | .call_modifier, | |
| 554 | .prefetch_options, | |
| 555 | .export_options, | |
| 556 | .extern_options, | |
| 557 | 536 | => true, |
| 558 | 537 | |
| 559 | 538 | // These are false because they are comptime-only types. |
| ... | ... | @@ -565,7 +544,6 @@ pub fn hasRuntimeBitsAdvanced( |
| 565 | 544 | .null, |
| 566 | 545 | .undefined, |
| 567 | 546 | .enum_literal, |
| 568 | .type_info, | |
| 569 | 547 | => false, |
| 570 | 548 | |
| 571 | 549 | .generic_poison => unreachable, |
| ... | ... | @@ -711,16 +689,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool { |
| 711 | 689 | .anyerror, |
| 712 | 690 | .adhoc_inferred_error_set, |
| 713 | 691 | .anyopaque, |
| 714 | .atomic_order, | |
| 715 | .atomic_rmw_op, | |
| 716 | .calling_convention, | |
| 717 | .address_space, | |
| 718 | .float_mode, | |
| 719 | .reduce_op, | |
| 720 | .call_modifier, | |
| 721 | .prefetch_options, | |
| 722 | .export_options, | |
| 723 | .extern_options, | |
| 724 | 692 | .type, |
| 725 | 693 | .comptime_int, |
| 726 | 694 | .comptime_float, |
| ... | ... | @@ -728,7 +696,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool { |
| 728 | 696 | .null, |
| 729 | 697 | .undefined, |
| 730 | 698 | .enum_literal, |
| 731 | .type_info, | |
| 732 | 699 | .generic_poison, |
| 733 | 700 | => false, |
| 734 | 701 | }, |
| ... | ... | @@ -972,14 +939,6 @@ pub fn abiAlignmentAdvanced( |
| 972 | 939 | |
| 973 | 940 | .simple_type => |t| switch (t) { |
| 974 | 941 | .bool, |
| 975 | .atomic_order, | |
| 976 | .atomic_rmw_op, | |
| 977 | .calling_convention, | |
| 978 | .address_space, | |
| 979 | .float_mode, | |
| 980 | .reduce_op, | |
| 981 | .call_modifier, | |
| 982 | .prefetch_options, | |
| 983 | 942 | .anyopaque, |
| 984 | 943 | => return .{ .scalar = .@"1" }, |
| 985 | 944 | |
| ... | ... | @@ -987,11 +946,6 @@ pub fn abiAlignmentAdvanced( |
| 987 | 946 | .isize, |
| 988 | 947 | => return .{ .scalar = intAbiAlignment(target.ptrBitWidth(), target, use_llvm) }, |
| 989 | 948 | |
| 990 | .export_options, | |
| 991 | .extern_options, | |
| 992 | .type_info, | |
| 993 | => return .{ .scalar = ptrAbiAlignment(target) }, | |
| 994 | ||
| 995 | 949 | .c_char => return .{ .scalar = cTypeAlign(target, .char) }, |
| 996 | 950 | .c_short => return .{ .scalar = cTypeAlign(target, .short) }, |
| 997 | 951 | .c_ushort => return .{ .scalar = cTypeAlign(target, .ushort) }, |
| ... | ... | @@ -1352,15 +1306,7 @@ pub fn abiSizeAdvanced( |
| 1352 | 1306 | }, |
| 1353 | 1307 | .func_type => unreachable, // represents machine code; not a pointer |
| 1354 | 1308 | .simple_type => |t| switch (t) { |
| 1355 | .bool, | |
| 1356 | .atomic_order, | |
| 1357 | .atomic_rmw_op, | |
| 1358 | .calling_convention, | |
| 1359 | .address_space, | |
| 1360 | .float_mode, | |
| 1361 | .reduce_op, | |
| 1362 | .call_modifier, | |
| 1363 | => return .{ .scalar = 1 }, | |
| 1309 | .bool => return .{ .scalar = 1 }, | |
| 1364 | 1310 | |
| 1365 | 1311 | .f16 => return .{ .scalar = 2 }, |
| 1366 | 1312 | .f32 => return .{ .scalar = 4 }, |
| ... | ... | @@ -1402,11 +1348,6 @@ pub fn abiSizeAdvanced( |
| 1402 | 1348 | return .{ .scalar = intAbiSize(bits, target, use_llvm) }; |
| 1403 | 1349 | }, |
| 1404 | 1350 | |
| 1405 | .prefetch_options => unreachable, // missing call to resolveTypeFields | |
| 1406 | .export_options => unreachable, // missing call to resolveTypeFields | |
| 1407 | .extern_options => unreachable, // missing call to resolveTypeFields | |
| 1408 | ||
| 1409 | .type_info => unreachable, | |
| 1410 | 1351 | .noreturn => unreachable, |
| 1411 | 1352 | .generic_poison => unreachable, |
| 1412 | 1353 | }, |
| ... | ... | @@ -1751,18 +1692,6 @@ pub fn bitSizeAdvanced( |
| 1751 | 1692 | .undefined => unreachable, |
| 1752 | 1693 | .enum_literal => unreachable, |
| 1753 | 1694 | .generic_poison => unreachable, |
| 1754 | ||
| 1755 | .atomic_order => unreachable, | |
| 1756 | .atomic_rmw_op => unreachable, | |
| 1757 | .calling_convention => unreachable, | |
| 1758 | .address_space => unreachable, | |
| 1759 | .float_mode => unreachable, | |
| 1760 | .reduce_op => unreachable, | |
| 1761 | .call_modifier => unreachable, | |
| 1762 | .prefetch_options => unreachable, | |
| 1763 | .export_options => unreachable, | |
| 1764 | .extern_options => unreachable, | |
| 1765 | .type_info => unreachable, | |
| 1766 | 1695 | }, |
| 1767 | 1696 | .struct_type => { |
| 1768 | 1697 | const struct_type = ip.loadStructType(ty.toIntern()); |
| ... | ... | @@ -2565,17 +2494,6 @@ pub fn onePossibleValue(starting_type: Type, pt: Zcu.PerThread) !?Value { |
| 2565 | 2494 | .comptime_int, |
| 2566 | 2495 | .comptime_float, |
| 2567 | 2496 | .enum_literal, |
| 2568 | .atomic_order, | |
| 2569 | .atomic_rmw_op, | |
| 2570 | .calling_convention, | |
| 2571 | .address_space, | |
| 2572 | .float_mode, | |
| 2573 | .reduce_op, | |
| 2574 | .call_modifier, | |
| 2575 | .prefetch_options, | |
| 2576 | .export_options, | |
| 2577 | .extern_options, | |
| 2578 | .type_info, | |
| 2579 | 2497 | .adhoc_inferred_error_set, |
| 2580 | 2498 | => return null, |
| 2581 | 2499 | |
| ... | ... | @@ -2782,16 +2700,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve |
| 2782 | 2700 | .adhoc_inferred_error_set, |
| 2783 | 2701 | .noreturn, |
| 2784 | 2702 | .generic_poison, |
| 2785 | .atomic_order, | |
| 2786 | .atomic_rmw_op, | |
| 2787 | .calling_convention, | |
| 2788 | .address_space, | |
| 2789 | .float_mode, | |
| 2790 | .reduce_op, | |
| 2791 | .call_modifier, | |
| 2792 | .prefetch_options, | |
| 2793 | .export_options, | |
| 2794 | .extern_options, | |
| 2795 | 2703 | => false, |
| 2796 | 2704 | |
| 2797 | 2705 | .type, |
| ... | ... | @@ -2800,7 +2708,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve |
| 2800 | 2708 | .null, |
| 2801 | 2709 | .undefined, |
| 2802 | 2710 | .enum_literal, |
| 2803 | .type_info, | |
| 2804 | 2711 | => true, |
| 2805 | 2712 | }, |
| 2806 | 2713 | .struct_type => { |
| ... | ... | @@ -3534,10 +3441,6 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx: |
| 3534 | 3441 | pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3535 | 3442 | const zcu = pt.zcu; |
| 3536 | 3443 | const ip = &zcu.intern_pool; |
| 3537 | switch (ip.indexToKey(ty.toIntern())) { | |
| 3538 | .simple_type => |simple_type| return resolveSimpleType(simple_type, pt), | |
| 3539 | else => {}, | |
| 3540 | } | |
| 3541 | 3444 | switch (ty.zigTypeTag(zcu)) { |
| 3542 | 3445 | .Struct => switch (ip.indexToKey(ty.toIntern())) { |
| 3543 | 3446 | .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| { |
| ... | ... | @@ -3651,8 +3554,6 @@ pub fn resolveFields(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3651 | 3554 | .one_u8 => unreachable, |
| 3652 | 3555 | .four_u8 => unreachable, |
| 3653 | 3556 | .negative_one => unreachable, |
| 3654 | .calling_convention_c => unreachable, | |
| 3655 | .calling_convention_inline => unreachable, | |
| 3656 | 3557 | .void_value => unreachable, |
| 3657 | 3558 | .unreachable_value => unreachable, |
| 3658 | 3559 | .null_value => unreachable, |
| ... | ... | @@ -3669,8 +3570,6 @@ pub fn resolveFields(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3669 | 3570 | |
| 3670 | 3571 | .type_union => return ty.resolveUnionInner(pt, .fields), |
| 3671 | 3572 | |
| 3672 | .simple_type => return resolveSimpleType(ip.indexToKey(ty_ip).simple_type, pt), | |
| 3673 | ||
| 3674 | 3573 | else => {}, |
| 3675 | 3574 | }, |
| 3676 | 3575 | } |
| ... | ... | @@ -3680,11 +3579,6 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void { |
| 3680 | 3579 | const zcu = pt.zcu; |
| 3681 | 3580 | const ip = &zcu.intern_pool; |
| 3682 | 3581 | |
| 3683 | switch (ip.indexToKey(ty.toIntern())) { | |
| 3684 | .simple_type => |simple_type| return resolveSimpleType(simple_type, pt), | |
| 3685 | else => {}, | |
| 3686 | } | |
| 3687 | ||
| 3688 | 3582 | switch (ty.zigTypeTag(zcu)) { |
| 3689 | 3583 | .Type, |
| 3690 | 3584 | .Void, |
| ... | ... | @@ -3850,28 +3744,6 @@ fn resolveUnionInner( |
| 3850 | 3744 | }; |
| 3851 | 3745 | } |
| 3852 | 3746 | |
| 3853 | /// Fully resolves a simple type. This is usually a nop, but for builtin types with | |
| 3854 | /// special InternPool indices (such as std.builtin.Type) it will analyze and fully | |
| 3855 | /// resolve the type. | |
| 3856 | fn resolveSimpleType(simple_type: InternPool.SimpleType, pt: Zcu.PerThread) Allocator.Error!void { | |
| 3857 | const builtin_type_name: []const u8 = switch (simple_type) { | |
| 3858 | .atomic_order => "AtomicOrder", | |
| 3859 | .atomic_rmw_op => "AtomicRmwOp", | |
| 3860 | .calling_convention => "CallingConvention", | |
| 3861 | .address_space => "AddressSpace", | |
| 3862 | .float_mode => "FloatMode", | |
| 3863 | .reduce_op => "ReduceOp", | |
| 3864 | .call_modifier => "CallModifer", | |
| 3865 | .prefetch_options => "PrefetchOptions", | |
| 3866 | .export_options => "ExportOptions", | |
| 3867 | .extern_options => "ExternOptions", | |
| 3868 | .type_info => "Type", | |
| 3869 | else => return, | |
| 3870 | }; | |
| 3871 | // This will fully resolve the type. | |
| 3872 | _ = try pt.getBuiltinType(builtin_type_name); | |
| 3873 | } | |
| 3874 | ||
| 3875 | 3747 | /// Returns the type of a pointer to an element. |
| 3876 | 3748 | /// Asserts that the type is a pointer, and that the element type is indexable. |
| 3877 | 3749 | /// If the element index is comptime-known, it must be passed in `offset`. |
src/Zcu.zig+26| ... | ... | @@ -3468,3 +3468,29 @@ fn formatDependee(data: struct { dependee: InternPool.Dependee, zcu: *Zcu }, com |
| 3468 | 3468 | }, |
| 3469 | 3469 | } |
| 3470 | 3470 | } |
| 3471 | ||
| 3472 | /// Given the `InternPool.Index` of a function, set its resolved IES to `.none` if it | |
| 3473 | /// may be outdated. `Sema` should do this before ever loading a resolved IES. | |
| 3474 | pub fn maybeUnresolveIes(zcu: *Zcu, func_index: InternPool.Index) !void { | |
| 3475 | const unit = AnalUnit.wrap(.{ .func = func_index }); | |
| 3476 | if (zcu.outdated.contains(unit) or zcu.potentially_outdated.contains(unit)) { | |
| 3477 | // We're consulting the resolved IES now, but the function is outdated, so its | |
| 3478 | // IES may have changed. We have to assume the IES is outdated and set the resolved | |
| 3479 | // set back to `.none`. | |
| 3480 | // | |
| 3481 | // This will cause `PerThread.analyzeFnBody` to mark the IES as outdated when it's | |
| 3482 | // eventually hit. | |
| 3483 | // | |
| 3484 | // Since the IES needs to be resolved, the function body will now definitely need | |
| 3485 | // re-analysis (even if the IES turns out to be the same!), so mark it as | |
| 3486 | // definitely-outdated if it's only PO. | |
| 3487 | if (zcu.potentially_outdated.fetchSwapRemove(unit)) |kv| { | |
| 3488 | const gpa = zcu.gpa; | |
| 3489 | try zcu.outdated.putNoClobber(gpa, unit, kv.value); | |
| 3490 | if (kv.value == 0) { | |
| 3491 | try zcu.outdated_ready.put(gpa, unit, {}); | |
| 3492 | } | |
| 3493 | } | |
| 3494 | zcu.intern_pool.funcSetIesResolved(func_index, .none); | |
| 3495 | } | |
| 3496 | } |
src/Zcu/PerThread.zig+29-100| ... | ... | @@ -734,31 +734,25 @@ fn ensureFuncBodyAnalyzedInner( |
| 734 | 734 | const func = zcu.funcInfo(func_index); |
| 735 | 735 | const anal_unit = AnalUnit.wrap(.{ .func = func_index }); |
| 736 | 736 | |
| 737 | // Here's an interesting question: is this function actually valid? | |
| 738 | // Maybe the signature changed, so we'll end up creating a whole different `func` | |
| 739 | // in the InternPool, and this one is a waste of time to analyze. Worse, we'd be | |
| 740 | // analyzing new ZIR with old data, and get bogus errors. They would be unused, | |
| 741 | // but they would still hang around internally! So, let's detect this case. | |
| 742 | // For function decls, we must ensure the declaration's `Cau` is up-to-date, and | |
| 743 | // check if `func_index` was removed by that update. | |
| 744 | // For function instances, we do that process on the generic owner. | |
| 745 | ||
| 746 | try pt.ensureCauAnalyzed(cau: { | |
| 747 | const func_nav = if (func.generic_owner == .none) | |
| 748 | func.owner_nav | |
| 749 | else | |
| 750 | zcu.funcInfo(func.generic_owner).owner_nav; | |
| 751 | ||
| 752 | break :cau ip.getNav(func_nav).analysis_owner.unwrap().?; | |
| 753 | }); | |
| 754 | ||
| 755 | if (ip.isRemoved(func_index) or (func.generic_owner != .none and ip.isRemoved(func.generic_owner))) { | |
| 756 | if (func_outdated) { | |
| 757 | try zcu.markDependeeOutdated(.marked_po, .{ .interned = func_index }); // IES | |
| 737 | // Make sure that this function is still owned by the same `Nav`. Otherwise, analyzing | |
| 738 | // it would be a waste of time in the best case, and could cause codegen to give bogus | |
| 739 | // results in the worst case. | |
| 740 | ||
| 741 | if (func.generic_owner == .none) { | |
| 742 | try pt.ensureCauAnalyzed(ip.getNav(func.owner_nav).analysis_owner.unwrap().?); | |
| 743 | if (ip.getNav(func.owner_nav).status.resolved.val != func_index) { | |
| 744 | // This function is no longer referenced! There's no point in re-analyzing it. | |
| 745 | // Just mark a transitive failure and move on. | |
| 746 | return error.AnalysisFail; | |
| 747 | } | |
| 748 | } else { | |
| 749 | const go_nav = zcu.funcInfo(func.generic_owner).owner_nav; | |
| 750 | try pt.ensureCauAnalyzed(ip.getNav(go_nav).analysis_owner.unwrap().?); | |
| 751 | if (ip.getNav(go_nav).status.resolved.val != func.generic_owner) { | |
| 752 | // The generic owner is no longer referenced, so this function is also unreferenced. | |
| 753 | // There's no point in re-analyzing it. Just mark a transitive failure and move on. | |
| 754 | return error.AnalysisFail; | |
| 758 | 755 | } |
| 759 | ip.removeDependenciesForDepender(gpa, AnalUnit.wrap(.{ .func = func_index })); | |
| 760 | ip.remove(pt.tid, func_index); | |
| 761 | @panic("TODO: remove orphaned function from binary"); | |
| 762 | 756 | } |
| 763 | 757 | |
| 764 | 758 | // We'll want to remember what the IES used to be before the update for |
| ... | ... | @@ -1108,12 +1102,9 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult { |
| 1108 | 1102 | // We are about to re-analyze this `Cau`; drop its depenndencies. |
| 1109 | 1103 | zcu.intern_pool.removeDependenciesForDepender(gpa, anal_unit); |
| 1110 | 1104 | |
| 1111 | const builtin_type_target_index: InternPool.Index = switch (cau.owner.unwrap()) { | |
| 1112 | .none => ip_index: { | |
| 1113 | // `comptime` decl -- we will re-analyze its body. | |
| 1114 | // This declaration has no value so is definitely not a std.builtin type. | |
| 1115 | break :ip_index .none; | |
| 1116 | }, | |
| 1105 | switch (cau.owner.unwrap()) { | |
| 1106 | .none => {}, // `comptime` decl -- we will re-analyze its body. | |
| 1107 | .nav => {}, // Other decl -- we will re-analyze its value. | |
| 1117 | 1108 | .type => |ty| { |
| 1118 | 1109 | // This is an incremental update, and this type is being re-analyzed because it is outdated. |
| 1119 | 1110 | // Create a new type in its place, and mark the old one as outdated so that use sites will |
| ... | ... | @@ -1125,53 +1116,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult { |
| 1125 | 1116 | .invalidate_decl_ref = true, |
| 1126 | 1117 | }; |
| 1127 | 1118 | }, |
| 1128 | .nav => |nav| ip_index: { | |
| 1129 | // Other decl -- we will re-analyze its value. | |
| 1130 | // This might be a type in `builtin.zig` -- check. | |
| 1131 | if (file.mod != zcu.std_mod) break :ip_index .none; | |
| 1132 | // We're in the std module. | |
| 1133 | const nav_name = ip.getNav(nav).name; | |
| 1134 | const std_file_imported = try pt.importPkg(zcu.std_mod); | |
| 1135 | const std_type = Type.fromInterned(zcu.fileRootType(std_file_imported.file_index)); | |
| 1136 | const std_namespace = zcu.namespacePtr(std_type.getNamespace(zcu).unwrap().?); | |
| 1137 | const builtin_str = try ip.getOrPutString(gpa, pt.tid, "builtin", .no_embedded_nulls); | |
| 1138 | const builtin_nav = ip.getNav(std_namespace.pub_decls.getKeyAdapted(builtin_str, Zcu.Namespace.NameAdapter{ .zcu = zcu }) orelse break :ip_index .none); | |
| 1139 | const builtin_namespace = switch (builtin_nav.status) { | |
| 1140 | .unresolved => break :ip_index .none, | |
| 1141 | .resolved => |r| Type.fromInterned(r.val).getNamespace(zcu).unwrap().?, | |
| 1142 | }; | |
| 1143 | if (cau.namespace != builtin_namespace) break :ip_index .none; | |
| 1144 | // We're in builtin.zig. This could be a builtin we need to add to a specific InternPool index. | |
| 1145 | for ([_][]const u8{ | |
| 1146 | "AtomicOrder", | |
| 1147 | "AtomicRmwOp", | |
| 1148 | "CallingConvention", | |
| 1149 | "AddressSpace", | |
| 1150 | "FloatMode", | |
| 1151 | "ReduceOp", | |
| 1152 | "CallModifier", | |
| 1153 | "PrefetchOptions", | |
| 1154 | "ExportOptions", | |
| 1155 | "ExternOptions", | |
| 1156 | "Type", | |
| 1157 | }, [_]InternPool.Index{ | |
| 1158 | .atomic_order_type, | |
| 1159 | .atomic_rmw_op_type, | |
| 1160 | .calling_convention_type, | |
| 1161 | .address_space_type, | |
| 1162 | .float_mode_type, | |
| 1163 | .reduce_op_type, | |
| 1164 | .call_modifier_type, | |
| 1165 | .prefetch_options_type, | |
| 1166 | .export_options_type, | |
| 1167 | .extern_options_type, | |
| 1168 | .type_info_type, | |
| 1169 | }) |type_name, type_ip| { | |
| 1170 | if (nav_name.eqlSlice(type_name, ip)) break :ip_index type_ip; | |
| 1171 | } | |
| 1172 | break :ip_index .none; | |
| 1173 | }, | |
| 1174 | }; | |
| 1119 | } | |
| 1175 | 1120 | |
| 1176 | 1121 | const is_usingnamespace = switch (cau.owner.unwrap()) { |
| 1177 | 1122 | .nav => |nav| ip.getNav(nav).is_usingnamespace, |
| ... | ... | @@ -1200,7 +1145,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult { |
| 1200 | 1145 | .fn_ret_ty = Type.void, |
| 1201 | 1146 | .fn_ret_ty_ies = null, |
| 1202 | 1147 | .comptime_err_ret_trace = &comptime_err_ret_trace, |
| 1203 | .builtin_type_target_index = builtin_type_target_index, | |
| 1204 | 1148 | }; |
| 1205 | 1149 | defer sema.deinit(); |
| 1206 | 1150 | |
| ... | ... | @@ -1255,9 +1199,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult { |
| 1255 | 1199 | .type => unreachable, // Handled at top of function. |
| 1256 | 1200 | }; |
| 1257 | 1201 | |
| 1258 | // We'll do more work with the Sema. Clear the target type index just in case we analyze any type. | |
| 1259 | sema.builtin_type_target_index = .none; | |
| 1260 | ||
| 1261 | 1202 | const align_src = block.src(.{ .node_offset_var_decl_align = 0 }); |
| 1262 | 1203 | const section_src = block.src(.{ .node_offset_var_decl_section = 0 }); |
| 1263 | 1204 | const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = 0 }); |
| ... | ... | @@ -2072,6 +2013,9 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError! |
| 2072 | 2013 | errdefer _ = zcu.analysis_in_progress.swapRemove(anal_unit); |
| 2073 | 2014 | |
| 2074 | 2015 | func.setAnalysisState(ip, .analyzed); |
| 2016 | if (func.analysisUnordered(ip).inferred_error_set) { | |
| 2017 | func.setResolvedErrorSet(ip, .none); | |
| 2018 | } | |
| 2075 | 2019 | |
| 2076 | 2020 | // This is the `Cau` corresponding to the `declaration` instruction which the function or its generic owner originates from. |
| 2077 | 2021 | const decl_cau = ip.getCau(cau: { |
| ... | ... | @@ -2278,7 +2222,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError! |
| 2278 | 2222 | else => |e| return e, |
| 2279 | 2223 | }; |
| 2280 | 2224 | assert(ies.resolved != .none); |
| 2281 | ip.funcSetIesResolved(func_index, ies.resolved); | |
| 2225 | func.setResolvedErrorSet(ip, ies.resolved); | |
| 2282 | 2226 | } |
| 2283 | 2227 | |
| 2284 | 2228 | assert(zcu.analysis_in_progress.swapRemove(anal_unit)); |
| ... | ... | @@ -3352,7 +3296,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat |
| 3352 | 3296 | break :o o; |
| 3353 | 3297 | }; |
| 3354 | 3298 | if (!outdated) return ty; |
| 3355 | return pt.recreateStructType(ty, key, struct_obj); | |
| 3299 | return pt.recreateStructType(key, struct_obj); | |
| 3356 | 3300 | }, |
| 3357 | 3301 | .union_type => |key| { |
| 3358 | 3302 | const union_obj = ip.loadUnionType(ty); |
| ... | ... | @@ -3367,7 +3311,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat |
| 3367 | 3311 | break :o o; |
| 3368 | 3312 | }; |
| 3369 | 3313 | if (!outdated) return ty; |
| 3370 | return pt.recreateUnionType(ty, key, union_obj); | |
| 3314 | return pt.recreateUnionType(key, union_obj); | |
| 3371 | 3315 | }, |
| 3372 | 3316 | .enum_type => |key| { |
| 3373 | 3317 | const enum_obj = ip.loadEnumType(ty); |
| ... | ... | @@ -3382,7 +3326,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat |
| 3382 | 3326 | break :o o; |
| 3383 | 3327 | }; |
| 3384 | 3328 | if (!outdated) return ty; |
| 3385 | return pt.recreateEnumType(ty, key, enum_obj); | |
| 3329 | return pt.recreateEnumType(key, enum_obj); | |
| 3386 | 3330 | }, |
| 3387 | 3331 | .opaque_type => { |
| 3388 | 3332 | assert(!already_updating); |
| ... | ... | @@ -3394,7 +3338,6 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat |
| 3394 | 3338 | |
| 3395 | 3339 | fn recreateStructType( |
| 3396 | 3340 | pt: Zcu.PerThread, |
| 3397 | ty: InternPool.Index, | |
| 3398 | 3341 | full_key: InternPool.Key.NamespaceType, |
| 3399 | 3342 | struct_obj: InternPool.LoadedStructType, |
| 3400 | 3343 | ) Zcu.SemaError!InternPool.Index { |
| ... | ... | @@ -3409,10 +3352,6 @@ fn recreateStructType( |
| 3409 | 3352 | .declared => |d| d, |
| 3410 | 3353 | }; |
| 3411 | 3354 | |
| 3412 | if (@intFromEnum(ty) <= InternPool.static_len) { | |
| 3413 | @panic("TODO: recreate resolved builtin type"); | |
| 3414 | } | |
| 3415 | ||
| 3416 | 3355 | const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 3417 | 3356 | const file = zcu.fileByIndex(inst_info.file); |
| 3418 | 3357 | if (file.status != .success_zir) return error.AnalysisFail; |
| ... | ... | @@ -3485,7 +3424,6 @@ fn recreateStructType( |
| 3485 | 3424 | |
| 3486 | 3425 | fn recreateUnionType( |
| 3487 | 3426 | pt: Zcu.PerThread, |
| 3488 | ty: InternPool.Index, | |
| 3489 | 3427 | full_key: InternPool.Key.NamespaceType, |
| 3490 | 3428 | union_obj: InternPool.LoadedUnionType, |
| 3491 | 3429 | ) Zcu.SemaError!InternPool.Index { |
| ... | ... | @@ -3500,10 +3438,6 @@ fn recreateUnionType( |
| 3500 | 3438 | .declared => |d| d, |
| 3501 | 3439 | }; |
| 3502 | 3440 | |
| 3503 | if (@intFromEnum(ty) <= InternPool.static_len) { | |
| 3504 | @panic("TODO: recreate resolved builtin type"); | |
| 3505 | } | |
| 3506 | ||
| 3507 | 3441 | const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 3508 | 3442 | const file = zcu.fileByIndex(inst_info.file); |
| 3509 | 3443 | if (file.status != .success_zir) return error.AnalysisFail; |
| ... | ... | @@ -3584,7 +3518,6 @@ fn recreateUnionType( |
| 3584 | 3518 | |
| 3585 | 3519 | fn recreateEnumType( |
| 3586 | 3520 | pt: Zcu.PerThread, |
| 3587 | ty: InternPool.Index, | |
| 3588 | 3521 | full_key: InternPool.Key.NamespaceType, |
| 3589 | 3522 | enum_obj: InternPool.LoadedEnumType, |
| 3590 | 3523 | ) Zcu.SemaError!InternPool.Index { |
| ... | ... | @@ -3599,10 +3532,6 @@ fn recreateEnumType( |
| 3599 | 3532 | .declared => |d| d, |
| 3600 | 3533 | }; |
| 3601 | 3534 | |
| 3602 | if (@intFromEnum(ty) <= InternPool.static_len) { | |
| 3603 | @panic("TODO: recreate resolved builtin type"); | |
| 3604 | } | |
| 3605 | ||
| 3606 | 3535 | const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 3607 | 3536 | const file = zcu.fileByIndex(inst_info.file); |
| 3608 | 3537 | if (file.status != .success_zir) return error.AnalysisFail; |
src/codegen/c/Type.zig+1-23| ... | ... | @@ -1389,21 +1389,6 @@ pub const Pool = struct { |
| 1389 | 1389 | .anyframe_type, |
| 1390 | 1390 | .generic_poison_type, |
| 1391 | 1391 | => unreachable, |
| 1392 | .atomic_order_type, | |
| 1393 | .atomic_rmw_op_type, | |
| 1394 | .calling_convention_type, | |
| 1395 | .address_space_type, | |
| 1396 | .float_mode_type, | |
| 1397 | .reduce_op_type, | |
| 1398 | .call_modifier_type, | |
| 1399 | => |ip_index| return pool.fromType( | |
| 1400 | allocator, | |
| 1401 | scratch, | |
| 1402 | Type.fromInterned(ip.loadEnumType(ip_index).tag_ty), | |
| 1403 | pt, | |
| 1404 | mod, | |
| 1405 | kind, | |
| 1406 | ), | |
| 1407 | 1392 | .anyerror_type, |
| 1408 | 1393 | .anyerror_void_error_union_type, |
| 1409 | 1394 | .adhoc_inferred_error_set_type, |
| ... | ... | @@ -1459,8 +1444,6 @@ pub const Pool = struct { |
| 1459 | 1444 | .one_u8, |
| 1460 | 1445 | .four_u8, |
| 1461 | 1446 | .negative_one, |
| 1462 | .calling_convention_c, | |
| 1463 | .calling_convention_inline, | |
| 1464 | 1447 | .void_value, |
| 1465 | 1448 | .unreachable_value, |
| 1466 | 1449 | .null_value, |
| ... | ... | @@ -1471,12 +1454,7 @@ pub const Pool = struct { |
| 1471 | 1454 | .none, |
| 1472 | 1455 | => unreachable, |
| 1473 | 1456 | |
| 1474 | //.prefetch_options_type, | |
| 1475 | //.export_options_type, | |
| 1476 | //.extern_options_type, | |
| 1477 | //.type_info_type, | |
| 1478 | //_, | |
| 1479 | else => |ip_index| switch (ip.indexToKey(ip_index)) { | |
| 1457 | _ => |ip_index| switch (ip.indexToKey(ip_index)) { | |
| 1480 | 1458 | .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind), |
| 1481 | 1459 | .ptr_type => |ptr_info| switch (ptr_info.flags.size) { |
| 1482 | 1460 | .One, .Many, .C => { |
src/codegen/llvm.zig-2| ... | ... | @@ -3195,8 +3195,6 @@ pub const Object = struct { |
| 3195 | 3195 | .one_u8, |
| 3196 | 3196 | .four_u8, |
| 3197 | 3197 | .negative_one, |
| 3198 | .calling_convention_c, | |
| 3199 | .calling_convention_inline, | |
| 3200 | 3198 | .void_value, |
| 3201 | 3199 | .unreachable_value, |
| 3202 | 3200 | .null_value, |
src/link/Dwarf.zig+1-13| ... | ... | @@ -2565,19 +2565,7 @@ fn updateType( |
| 2565 | 2565 | try wip_nav.strp(if (type_index == .generic_poison_type) "anytype" else name); |
| 2566 | 2566 | }, |
| 2567 | 2567 | .anyerror => return, // delay until flush |
| 2568 | .atomic_order, | |
| 2569 | .atomic_rmw_op, | |
| 2570 | .calling_convention, | |
| 2571 | .address_space, | |
| 2572 | .float_mode, | |
| 2573 | .reduce_op, | |
| 2574 | .call_modifier, | |
| 2575 | .prefetch_options, | |
| 2576 | .export_options, | |
| 2577 | .extern_options, | |
| 2578 | .type_info, | |
| 2579 | .adhoc_inferred_error_set, | |
| 2580 | => unreachable, | |
| 2568 | .adhoc_inferred_error_set => unreachable, | |
| 2581 | 2569 | }, |
| 2582 | 2570 | .struct_type, |
| 2583 | 2571 | .union_type, |
src/print_zir.zig+7| ... | ... | @@ -615,6 +615,7 @@ const Writer = struct { |
| 615 | 615 | .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended), |
| 616 | 616 | .closure_get => try self.writeClosureGet(stream, extended), |
| 617 | 617 | .field_parent_ptr => try self.writeFieldParentPtr(stream, extended), |
| 618 | .builtin_value => try self.writeBuiltinValue(stream, extended), | |
| 618 | 619 | } |
| 619 | 620 | } |
| 620 | 621 | |
| ... | ... | @@ -2782,6 +2783,12 @@ const Writer = struct { |
| 2782 | 2783 | try self.writeSrcNode(stream, @bitCast(extended.operand)); |
| 2783 | 2784 | } |
| 2784 | 2785 | |
| 2786 | fn writeBuiltinValue(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | |
| 2787 | const val: Zir.Inst.BuiltinValue = @enumFromInt(extended.small); | |
| 2788 | try stream.print("{s})) ", .{@tagName(val)}); | |
| 2789 | try self.writeSrcNode(stream, @bitCast(extended.operand)); | |
| 2790 | } | |
| 2791 | ||
| 2785 | 2792 | fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void { |
| 2786 | 2793 | if (ref == .none) { |
| 2787 | 2794 | return stream.writeAll(".none"); |
test/incremental/type_becomes_comptime_only created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | #target=x86_64-linux | |
| 2 | #update=initial version | |
| 3 | #file=main.zig | |
| 4 | const SomeType = u32; | |
| 5 | const S = struct { | |
| 6 | x: SomeType, | |
| 7 | fn foo(_: S) void {} | |
| 8 | }; | |
| 9 | pub fn main() void { | |
| 10 | const s: S = .{ .x = 456 }; | |
| 11 | s.foo(); | |
| 12 | } | |
| 13 | #expect_stdout="" | |
| 14 | ||
| 15 | #update=make S comptime-only | |
| 16 | #file=main.zig | |
| 17 | const SomeType = comptime_int; | |
| 18 | const S = struct { | |
| 19 | x: SomeType, | |
| 20 | fn foo(_: S) void {} | |
| 21 | }; | |
| 22 | pub fn main() void { | |
| 23 | const s: S = .{ .x = 456 }; | |
| 24 | s.foo(); | |
| 25 | } | |
| 26 | #expect_stdout="" | |
| 27 | ||
| 28 | #update=make S runtime again | |
| 29 | #file=main.zig | |
| 30 | const SomeType = u16; | |
| 31 | const S = struct { | |
| 32 | x: SomeType, | |
| 33 | fn foo(_: S) void {} | |
| 34 | }; | |
| 35 | pub fn main() void { | |
| 36 | const s: S = .{ .x = 456 }; | |
| 37 | s.foo(); | |
| 38 | } | |
| 39 | #expect_stdout="" |