authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-18 17:57:28+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-18 18:10:59+01:00
logde49a9a17352a36a0888b03905f207b0584fc269
treeebda829424b7df833084bc0f8275815d42a6eeec
parenta239d8d4e2c0e5a7f3eb4b9973f869afdb3bbe05
signaturelock-open Commit is signed but in an unrecognized format.

Zir: add instructions to fetch std.builtin types

This replaces the constant `Zir.Inst.Ref` tags (and the analagous tags in `Air.Inst.Ref`, `InternPool.Index`) referring to types in `std.builtin` with a ZIR instruction `extended(builtin_type(...))` which instructs Sema to fetch such a type, effectively as if it were a shorthand for the ZIR for `@import("std").builtin.xyz`. Previously, this was achieved through constant tags in `Ref`. The analagous `InternPool` indices began as `simple_type` values, and were later rewritten to the correct type information. This system was kind of brittle, and more importantly, isn't compatible with incremental compilation of std, since incremental compilation relies on the ability to recreate types at different indices when they change. Replacing the old system with this instruction slightly increases the size of ZIR, but it simplifies logic and allows incremental compilation to work correctly on the standard library. This shouldn't have a significant impact on ZIR size or compiler performance, but I will take measurements in the PR to confirm this.

11 files changed, 152 insertions(+), 492 deletions(-)

lib/std/zig/AstGen.zig+57-46
...@@ -366,7 +366,6 @@ const ResultInfo = struct {...@@ -366,7 +366,6 @@ const ResultInfo = struct {
366};366};
367367
368const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };368const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };
369const coerced_addrspace_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .address_space_type } };
370const coerced_linksection_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .slice_const_u8_type } };369const coerced_linksection_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .slice_const_u8_type } };
371const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };370const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };
372const coerced_bool_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .bool_type } };371const coerced_bool_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .bool_type } };
...@@ -1387,7 +1386,7 @@ fn fnProtoExpr(...@@ -1387,7 +1386,7 @@ fn fnProtoExpr(
1387 try expr(1386 try expr(
1388 &block_scope,1387 &block_scope,
1389 scope,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 fn_proto.ast.callconv_expr,1390 fn_proto.ast.callconv_expr,
1392 )1391 )
1393 else1392 else
...@@ -3804,7 +3803,8 @@ fn ptrType(...@@ -3804,7 +3803,8 @@ fn ptrType(
3804 gz.astgen.source_line = source_line;3803 gz.astgen.source_line = source_line;
3805 gz.astgen.source_column = source_column;3804 gz.astgen.source_column = source_column;
38063805
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 trailing_count += 1;3808 trailing_count += 1;
3809 }3809 }
3810 if (ptr_info.ast.align_node != 0) {3810 if (ptr_info.ast.align_node != 0) {
...@@ -4202,7 +4202,8 @@ fn fnDecl(...@@ -4202,7 +4202,8 @@ fn fnDecl(
4202 var addrspace_gz = decl_gz.makeSubBlock(params_scope);4202 var addrspace_gz = decl_gz.makeSubBlock(params_scope);
4203 defer addrspace_gz.unstack();4203 defer addrspace_gz.unstack();
4204 const addrspace_ref: Zir.Inst.Ref = if (fn_proto.ast.addrspace_expr == 0) .none else inst: {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 if (addrspace_gz.instructionsSlice().len == 0) {4207 if (addrspace_gz.instructionsSlice().len == 0) {
4207 // In this case we will send a len=0 body which can be encoded more efficiently.4208 // In this case we will send a len=0 body which can be encoded more efficiently.
4208 break :inst inst;4209 break :inst inst;
...@@ -4235,9 +4236,9 @@ fn fnDecl(...@@ -4235,9 +4236,9 @@ fn fnDecl(
4235 );4236 );
4236 }4237 }
4237 const inst = try expr(4238 const inst = try expr(
4238 &decl_gz,4239 &cc_gz,
4239 params_scope,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 fn_proto.ast.callconv_expr,4242 fn_proto.ast.callconv_expr,
4242 );4243 );
4243 if (cc_gz.instructionsSlice().len == 0) {4244 if (cc_gz.instructionsSlice().len == 0) {
...@@ -4247,10 +4248,13 @@ fn fnDecl(...@@ -4247,10 +4248,13 @@ fn fnDecl(
4247 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);4248 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
4248 break :blk inst;4249 break :blk inst;
4249 } else if (is_extern) {4250 } else if (is_extern) {
4250 // note: https://github.com/ziglang/zig/issues/52694251 const inst = try cc_gz.addBuiltinValue(decl_node, .calling_convention_c);
4251 break :blk .calling_convention_c;4252 _ = try cc_gz.addBreak(.break_inline, @enumFromInt(0), inst);
4253 break :blk inst;
4252 } else if (has_inline_keyword) {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 } else {4258 } else {
4255 break :blk .none;4259 break :blk .none;
4256 }4260 }
...@@ -4525,7 +4529,8 @@ fn globalVarDecl(...@@ -4525,7 +4529,8 @@ fn globalVarDecl(
45254529
4526 var addrspace_gz = linksection_gz.makeSubBlock(scope);4530 var addrspace_gz = linksection_gz.makeSubBlock(scope);
4527 if (var_decl.ast.addrspace_node != 0) {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 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);4534 _ = try addrspace_gz.addBreakWithSrcNode(.break_inline, decl_inst, addrspace_inst, node);
4530 }4535 }
45314536
...@@ -9169,6 +9174,7 @@ fn builtinCall(...@@ -9169,6 +9174,7 @@ fn builtinCall(
9169 // zig fmt: on9174 // zig fmt: on
91709175
9171 .@"export" => {9176 .@"export" => {
9177 const export_options_ty = try gz.addBuiltinValue(node, .export_options);
9172 const node_tags = tree.nodes.items(.tag);9178 const node_tags = tree.nodes.items(.tag);
9173 const node_datas = tree.nodes.items(.data);9179 const node_datas = tree.nodes.items(.data);
9174 // This function causes a Decl to be exported. The first parameter is not an expression,9180 // This function causes a Decl to be exported. The first parameter is not an expression,
...@@ -9192,7 +9198,7 @@ fn builtinCall(...@@ -9192,7 +9198,7 @@ fn builtinCall(
9192 local_val.used = ident_token;9198 local_val.used = ident_token;
9193 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{9199 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9194 .operand = local_val.inst,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 return rvalue(gz, ri, .void_value, node);9203 return rvalue(gz, ri, .void_value, node);
9198 }9204 }
...@@ -9207,7 +9213,7 @@ fn builtinCall(...@@ -9207,7 +9213,7 @@ fn builtinCall(
9207 const loaded = try gz.addUnNode(.load, local_ptr.ptr, node);9213 const loaded = try gz.addUnNode(.load, local_ptr.ptr, node);
9208 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{9214 _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{
9209 .operand = loaded,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 return rvalue(gz, ri, .void_value, node);9218 return rvalue(gz, ri, .void_value, node);
9213 }9219 }
...@@ -9245,7 +9251,7 @@ fn builtinCall(...@@ -9245,7 +9251,7 @@ fn builtinCall(
9245 },9251 },
9246 else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}),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 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{9255 _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
9250 .namespace = namespace,9256 .namespace = namespace,
9251 .decl_name = decl_name,9257 .decl_name = decl_name,
...@@ -9255,7 +9261,8 @@ fn builtinCall(...@@ -9255,7 +9261,8 @@ fn builtinCall(
9255 },9261 },
9256 .@"extern" => {9262 .@"extern" => {
9257 const type_inst = try typeExpr(gz, scope, params[0]);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 const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{9266 const result = try gz.addExtendedPayload(.builtin_extern, Zir.Inst.BinNode{
9260 .node = gz.nodeIndexToRelative(node),9267 .node = gz.nodeIndexToRelative(node),
9261 .lhs = type_inst,9268 .lhs = type_inst,
...@@ -9264,7 +9271,8 @@ fn builtinCall(...@@ -9264,7 +9271,8 @@ fn builtinCall(
9264 return rvalue(gz, ri, result, node);9271 return rvalue(gz, ri, result, node);
9265 },9272 },
9266 .fence => {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 _ = try gz.addExtendedPayload(.fence, Zir.Inst.UnNode{9276 _ = try gz.addExtendedPayload(.fence, Zir.Inst.UnNode{
9269 .node = gz.nodeIndexToRelative(node),9277 .node = gz.nodeIndexToRelative(node),
9270 .operand = order,9278 .operand = order,
...@@ -9272,7 +9280,8 @@ fn builtinCall(...@@ -9272,7 +9280,8 @@ fn builtinCall(
9272 return rvalue(gz, ri, .void_value, node);9280 return rvalue(gz, ri, .void_value, node);
9273 },9281 },
9274 .set_float_mode => {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 _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{9285 _ = try gz.addExtendedPayload(.set_float_mode, Zir.Inst.UnNode{
9277 .node = gz.nodeIndexToRelative(node),9286 .node = gz.nodeIndexToRelative(node),
9278 .operand = order,9287 .operand = order,
...@@ -9365,7 +9374,8 @@ fn builtinCall(...@@ -9365,7 +9374,8 @@ fn builtinCall(
9365 },9374 },
93669375
9367 .Type => {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]);
93699379
9370 const gpa = gz.astgen.gpa;9380 const gpa = gz.astgen.gpa;
93719381
...@@ -9502,7 +9512,8 @@ fn builtinCall(...@@ -9502,7 +9512,8 @@ fn builtinCall(
9502 return rvalue(gz, ri, result, node);9512 return rvalue(gz, ri, result, node);
9503 },9513 },
9504 .reduce => {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 const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]);9517 const scalar = try expr(gz, scope, .{ .rl = .none }, params[1]);
9507 const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{9518 const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{
9508 .lhs = op,9519 .lhs = op,
...@@ -9517,34 +9528,38 @@ fn builtinCall(...@@ -9517,34 +9528,38 @@ fn builtinCall(
9517 .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow),9528 .shl_with_overflow => return overflowArithmetic(gz, scope, ri, node, params, .shl_with_overflow),
95189529
9519 .atomic_load => {9530 .atomic_load => {
9531 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9520 const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{9532 const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.AtomicLoad{
9521 // zig fmt: off9533 // zig fmt: off
9522 .elem_type = try typeExpr(gz, scope, params[0]),9534 .elem_type = try typeExpr(gz, scope, params[0]),
9523 .ptr = try expr (gz, scope, .{ .rl = .none }, params[1]),9535 .ptr = try expr (gz, scope, .{ .rl = .none }, params[1]),
9524 .ordering = try expr (gz, scope, .{ .rl = .{ .coerced_ty = .atomic_order_type } }, params[2]),9536 .ordering = try expr (gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[2]),
9525 // zig fmt: on9537 // zig fmt: on
9526 });9538 });
9527 return rvalue(gz, ri, result, node);9539 return rvalue(gz, ri, result, node);
9528 },9540 },
9529 .atomic_rmw => {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 const int_type = try typeExpr(gz, scope, params[0]);9544 const int_type = try typeExpr(gz, scope, params[0]);
9531 const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{9545 const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{
9532 // zig fmt: off9546 // zig fmt: off
9533 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),9547 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),
9534 .operation = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .atomic_rmw_op_type } }, params[2]),9548 .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]),9549 .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]),9550 .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[4]),
9537 // zig fmt: on9551 // zig fmt: on
9538 });9552 });
9539 return rvalue(gz, ri, result, node);9553 return rvalue(gz, ri, result, node);
9540 },9554 },
9541 .atomic_store => {9555 .atomic_store => {
9556 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9542 const int_type = try typeExpr(gz, scope, params[0]);9557 const int_type = try typeExpr(gz, scope, params[0]);
9543 _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{9558 _ = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{
9544 // zig fmt: off9559 // zig fmt: off
9545 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),9560 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),
9546 .operand = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]),9561 .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]),9562 .ordering = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[3]),
9548 // zig fmt: on9563 // zig fmt: on
9549 });9564 });
9550 return rvalue(gz, ri, .void_value, node);9565 return rvalue(gz, ri, .void_value, node);
...@@ -9562,7 +9577,8 @@ fn builtinCall(...@@ -9562,7 +9577,8 @@ fn builtinCall(
9562 return rvalue(gz, ri, result, node);9577 return rvalue(gz, ri, result, node);
9563 },9578 },
9564 .call => {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 const callee = try expr(gz, scope, .{ .rl = .none }, params[1]);9582 const callee = try expr(gz, scope, .{ .rl = .none }, params[1]);
9567 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);9583 const args = try expr(gz, scope, .{ .rl = .none }, params[2]);
9568 const result = try gz.addPlNode(.builtin_call, node, Zir.Inst.BuiltinCall{9584 const result = try gz.addPlNode(.builtin_call, node, Zir.Inst.BuiltinCall{
...@@ -9641,8 +9657,9 @@ fn builtinCall(...@@ -9641,8 +9657,9 @@ fn builtinCall(
9641 return rvalue(gz, ri, result, node);9657 return rvalue(gz, ri, result, node);
9642 },9658 },
9643 .prefetch => {9659 .prefetch => {
9660 const prefetch_options_ty = try gz.addBuiltinValue(node, .prefetch_options);
9644 const ptr = try expr(gz, scope, .{ .rl = .none }, params[0]);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 _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{9663 _ = try gz.addExtendedPayload(.prefetch, Zir.Inst.BinNode{
9647 .node = gz.nodeIndexToRelative(node),9664 .node = gz.nodeIndexToRelative(node),
9648 .lhs = ptr,9665 .lhs = ptr,
...@@ -9812,14 +9829,15 @@ fn cmpxchg(...@@ -9812,14 +9829,15 @@ fn cmpxchg(
9812 small: u16,9829 small: u16,
9813) InnerError!Zir.Inst.Ref {9830) InnerError!Zir.Inst.Ref {
9814 const int_type = try typeExpr(gz, scope, params[0]);9831 const int_type = try typeExpr(gz, scope, params[0]);
9832 const atomic_order_type = try gz.addBuiltinValue(node, .atomic_order);
9815 const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{9833 const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{
9816 // zig fmt: off9834 // zig fmt: off
9817 .node = gz.nodeIndexToRelative(node),9835 .node = gz.nodeIndexToRelative(node),
9818 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),9836 .ptr = try expr(gz, scope, .{ .rl = .none }, params[1]),
9819 .expected_value = try expr(gz, scope, .{ .rl = .{ .ty = int_type } }, params[2]),9837 .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]),9838 .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]),9839 .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]),9840 .failure_order = try expr(gz, scope, .{ .rl = .{ .coerced_ty = atomic_order_type } }, params[5]),
9823 // zig fmt: on9841 // zig fmt: on
9824 });9842 });
9825 return rvalue(gz, ri, result, node);9843 return rvalue(gz, ri, result, node);
...@@ -11106,17 +11124,6 @@ fn rvalueInner(...@@ -11106,17 +11124,6 @@ fn rvalueInner(
11106 as_ty | @intFromEnum(Zir.Inst.Ref.null_type),11124 as_ty | @intFromEnum(Zir.Inst.Ref.null_type),
11107 as_ty | @intFromEnum(Zir.Inst.Ref.undefined_type),11125 as_ty | @intFromEnum(Zir.Inst.Ref.undefined_type),
11108 as_ty | @intFromEnum(Zir.Inst.Ref.enum_literal_type),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 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_u8_type),11127 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_u8_type),
11121 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_type),11128 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_type),
11122 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type),11129 as_ty | @intFromEnum(Zir.Inst.Ref.manyptr_const_u8_sentinel_0_type),
...@@ -12572,6 +12579,10 @@ const GenZir = struct {...@@ -12572,6 +12579,10 @@ const GenZir = struct {
12572 return new_index;12579 return new_index;
12573 }12580 }
1257412581
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 fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref {12586 fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref {
12576 return addExtendedPayloadSmall(gz, opcode, undefined, extra);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,6 +2055,10 @@ pub const Inst = struct {
2055 /// Guaranteed to not have the `ptr_cast` flag.2055 /// Guaranteed to not have the `ptr_cast` flag.
2056 /// Uses the `pl_node` union field with payload `FieldParentPtr`.2056 /// Uses the `pl_node` union field with payload `FieldParentPtr`.
2057 field_parent_ptr,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,
20582062
2059 pub const InstData = struct {2063 pub const InstData = struct {
2060 opcode: Extended,2064 opcode: Extended,
...@@ -2071,7 +2075,7 @@ pub const Inst = struct {...@@ -2071,7 +2075,7 @@ pub const Inst = struct {
2071 ref_start_index = static_len,2075 ref_start_index = static_len,
2072 _,2076 _,
20732077
2074 pub const static_len = 84;2078 pub const static_len = 71;
20752079
2076 pub fn toRef(i: Index) Inst.Ref {2080 pub fn toRef(i: Index) Inst.Ref {
2077 return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));2081 return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
...@@ -2148,17 +2152,6 @@ pub const Inst = struct {...@@ -2148,17 +2152,6 @@ pub const Inst = struct {
2148 null_type,2152 null_type,
2149 undefined_type,2153 undefined_type,
2150 enum_literal_type,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 manyptr_u8_type,2155 manyptr_u8_type,
2163 manyptr_const_u8_type,2156 manyptr_const_u8_type,
2164 manyptr_const_u8_sentinel_0_type,2157 manyptr_const_u8_sentinel_0_type,
...@@ -2179,8 +2172,6 @@ pub const Inst = struct {...@@ -2179,8 +2172,6 @@ pub const Inst = struct {
2179 one_u8,2172 one_u8,
2180 four_u8,2173 four_u8,
2181 negative_one,2174 negative_one,
2182 calling_convention_c,
2183 calling_convention_inline,
2184 void_value,2175 void_value,
2185 unreachable_value,2176 unreachable_value,
2186 null_value,2177 null_value,
...@@ -3146,6 +3137,24 @@ pub const Inst = struct {...@@ -3146,6 +3137,24 @@ pub const Inst = struct {
3146 }3137 }
3147 };3138 };
31483139
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 /// Trailing:3158 /// Trailing:
3150 /// 0. tag_type: Ref, // if has_tag_type3159 /// 0. tag_type: Ref, // if has_tag_type
3151 /// 1. captures_len: u32, // if has_captures_len3160 /// 1. captures_len: u32, // if has_captures_len
...@@ -3977,6 +3986,7 @@ fn findDeclsInner(...@@ -3977,6 +3986,7 @@ fn findDeclsInner(
3977 .restore_err_ret_index,3986 .restore_err_ret_index,
3978 .closure_get,3987 .closure_get,
3979 .field_parent_ptr,3988 .field_parent_ptr,
3989 .builtin_value,
3980 => return,3990 => return,
39813991
3982 // `@TypeOf` has a body.3992 // `@TypeOf` has a body.
src/Air.zig-13
...@@ -938,17 +938,6 @@ pub const Inst = struct {...@@ -938,17 +938,6 @@ pub const Inst = struct {
938 null_type = @intFromEnum(InternPool.Index.null_type),938 null_type = @intFromEnum(InternPool.Index.null_type),
939 undefined_type = @intFromEnum(InternPool.Index.undefined_type),939 undefined_type = @intFromEnum(InternPool.Index.undefined_type),
940 enum_literal_type = @intFromEnum(InternPool.Index.enum_literal_type),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 manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type),941 manyptr_u8_type = @intFromEnum(InternPool.Index.manyptr_u8_type),
953 manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type),942 manyptr_const_u8_type = @intFromEnum(InternPool.Index.manyptr_const_u8_type),
954 manyptr_const_u8_sentinel_0_type = @intFromEnum(InternPool.Index.manyptr_const_u8_sentinel_0_type),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,8 +958,6 @@ pub const Inst = struct {
969 one_u8 = @intFromEnum(InternPool.Index.one_u8),958 one_u8 = @intFromEnum(InternPool.Index.one_u8),
970 four_u8 = @intFromEnum(InternPool.Index.four_u8),959 four_u8 = @intFromEnum(InternPool.Index.four_u8),
971 negative_one = @intFromEnum(InternPool.Index.negative_one),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 void_value = @intFromEnum(InternPool.Index.void_value),961 void_value = @intFromEnum(InternPool.Index.void_value),
975 unreachable_value = @intFromEnum(InternPool.Index.unreachable_value),962 unreachable_value = @intFromEnum(InternPool.Index.unreachable_value),
976 null_value = @intFromEnum(InternPool.Index.null_value),963 null_value = @intFromEnum(InternPool.Index.null_value),
src/InternPool.zig+2-138
...@@ -4411,17 +4411,6 @@ pub const Index = enum(u32) {...@@ -4411,17 +4411,6 @@ pub const Index = enum(u32) {
4411 null_type,4411 null_type,
4412 undefined_type,4412 undefined_type,
4413 enum_literal_type,4413 enum_literal_type,
4414 atomic_order_type,
4415 atomic_rmw_op_type,
4416 calling_convention_type,
4417 address_space_type,
4418 float_mode_type,
4419 reduce_op_type,
4420 call_modifier_type,
4421 prefetch_options_type,
4422 export_options_type,
4423 extern_options_type,
4424 type_info_type,
4425 manyptr_u8_type,4414 manyptr_u8_type,
4426 manyptr_const_u8_type,4415 manyptr_const_u8_type,
4427 manyptr_const_u8_sentinel_0_type,4416 manyptr_const_u8_sentinel_0_type,
...@@ -4454,10 +4443,6 @@ pub const Index = enum(u32) {...@@ -4454,10 +4443,6 @@ pub const Index = enum(u32) {
4454 four_u8,4443 four_u8,
4455 /// `-1` (comptime_int)4444 /// `-1` (comptime_int)
4456 negative_one,4445 negative_one,
4457 /// `std.builtin.CallingConvention.C`
4458 calling_convention_c,
4459 /// `std.builtin.CallingConvention.Inline`
4460 calling_convention_inline,
4461 /// `{}`4446 /// `{}`
4462 void_value,4447 void_value,
4463 /// `unreachable` (noreturn type)4448 /// `unreachable` (noreturn type)
...@@ -4837,17 +4822,6 @@ pub const static_keys = [_]Key{...@@ -4837,17 +4822,6 @@ pub const static_keys = [_]Key{
4837 .{ .simple_type = .null },4822 .{ .simple_type = .null },
4838 .{ .simple_type = .undefined },4823 .{ .simple_type = .undefined },
4839 .{ .simple_type = .enum_literal },4824 .{ .simple_type = .enum_literal },
4840 .{ .simple_type = .atomic_order },
4841 .{ .simple_type = .atomic_rmw_op },
4842 .{ .simple_type = .calling_convention },
4843 .{ .simple_type = .address_space },
4844 .{ .simple_type = .float_mode },
4845 .{ .simple_type = .reduce_op },
4846 .{ .simple_type = .call_modifier },
4847 .{ .simple_type = .prefetch_options },
4848 .{ .simple_type = .export_options },
4849 .{ .simple_type = .extern_options },
4850 .{ .simple_type = .type_info },
48514825
4852 // [*]u84826 // [*]u8
4853 .{ .ptr_type = .{4827 .{ .ptr_type = .{
...@@ -4876,7 +4850,7 @@ pub const static_keys = [_]Key{...@@ -4876,7 +4850,7 @@ pub const static_keys = [_]Key{
4876 },4850 },
4877 } },4851 } },
48784852
4879 // comptime_int4853 // *const comptime_int
4880 .{ .ptr_type = .{4854 .{ .ptr_type = .{
4881 .child = .comptime_int_type,4855 .child = .comptime_int_type,
4882 .flags = .{4856 .flags = .{
...@@ -4967,16 +4941,6 @@ pub const static_keys = [_]Key{...@@ -4967,16 +4941,6 @@ pub const static_keys = [_]Key{
4967 .ty = .comptime_int_type,4941 .ty = .comptime_int_type,
4968 .storage = .{ .i64 = -1 },4942 .storage = .{ .i64 = -1 },
4969 } },4943 } },
4970 // calling_convention_c
4971 .{ .enum_tag = .{
4972 .ty = .calling_convention_type,
4973 .int = .one_u8,
4974 } },
4975 // calling_convention_inline
4976 .{ .enum_tag = .{
4977 .ty = .calling_convention_type,
4978 .int = .four_u8,
4979 } },
49804944
4981 .{ .simple_value = .void },4945 .{ .simple_value = .void },
4982 .{ .simple_value = .@"unreachable" },4946 .{ .simple_value = .@"unreachable" },
...@@ -5690,18 +5654,6 @@ pub const SimpleType = enum(u32) {...@@ -5690,18 +5654,6 @@ pub const SimpleType = enum(u32) {
5690 undefined = @intFromEnum(Index.undefined_type),5654 undefined = @intFromEnum(Index.undefined_type),
5691 enum_literal = @intFromEnum(Index.enum_literal_type),5655 enum_literal = @intFromEnum(Index.enum_literal_type),
56925656
5693 atomic_order = @intFromEnum(Index.atomic_order_type),
5694 atomic_rmw_op = @intFromEnum(Index.atomic_rmw_op_type),
5695 calling_convention = @intFromEnum(Index.calling_convention_type),
5696 address_space = @intFromEnum(Index.address_space_type),
5697 float_mode = @intFromEnum(Index.float_mode_type),
5698 reduce_op = @intFromEnum(Index.reduce_op_type),
5699 call_modifier = @intFromEnum(Index.call_modifier_type),
5700 prefetch_options = @intFromEnum(Index.prefetch_options_type),
5701 export_options = @intFromEnum(Index.export_options_type),
5702 extern_options = @intFromEnum(Index.extern_options_type),
5703 type_info = @intFromEnum(Index.type_info_type),
5704
5705 adhoc_inferred_error_set = @intFromEnum(Index.adhoc_inferred_error_set_type),5657 adhoc_inferred_error_set = @intFromEnum(Index.adhoc_inferred_error_set_type),
5706 generic_poison = @intFromEnum(Index.generic_poison_type),5658 generic_poison = @intFromEnum(Index.generic_poison_type),
5707};5659};
...@@ -6281,18 +6233,6 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void {...@@ -6281,18 +6233,6 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void {
6281 // Sanity check.6233 // Sanity check.
6282 assert(ip.indexToKey(.bool_true).simple_value == .true);6234 assert(ip.indexToKey(.bool_true).simple_value == .true);
6283 assert(ip.indexToKey(.bool_false).simple_value == .false);6235 assert(ip.indexToKey(.bool_false).simple_value == .false);
6284
6285 const cc_inline = ip.indexToKey(.calling_convention_inline).enum_tag.int;
6286 const cc_c = ip.indexToKey(.calling_convention_c).enum_tag.int;
6287
6288 assert(ip.indexToKey(cc_inline).int.storage.u64 ==
6289 @intFromEnum(std.builtin.CallingConvention.Inline));
6290
6291 assert(ip.indexToKey(cc_c).int.storage.u64 ==
6292 @intFromEnum(std.builtin.CallingConvention.C));
6293
6294 assert(ip.indexToKey(ip.typeOf(cc_inline)).int_type.bits ==
6295 @typeInfo(@typeInfo(std.builtin.CallingConvention).Enum.tag_type).Int.bits);
6296 }6236 }
6297}6237}
62986238
...@@ -9743,14 +9683,6 @@ fn addMap(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, cap: usize) Al...@@ -9743,14 +9683,6 @@ fn addMap(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, cap: usize) Al
9743/// Invalidates all references to this index.9683/// Invalidates all references to this index.
9744pub fn remove(ip: *InternPool, tid: Zcu.PerThread.Id, index: Index) void {9684pub fn remove(ip: *InternPool, tid: Zcu.PerThread.Id, index: Index) void {
9745 const unwrapped_index = index.unwrap(ip);9685 const unwrapped_index = index.unwrap(ip);
9746 if (@intFromEnum(index) < static_keys.len) {
9747 // The item being removed replaced a special index via `InternPool.resolveBuiltinType`.
9748 // Restore the original item at this index.
9749 assert(static_keys[@intFromEnum(index)] == .simple_type);
9750 const items = ip.getLocalShared(unwrapped_index.tid).items.acquire().view();
9751 @atomicStore(Tag, &items.items(.tag)[unwrapped_index.index], .simple_type, .unordered);
9752 return;
9753 }
97549686
9755 if (unwrapped_index.tid == tid) {9687 if (unwrapped_index.tid == tid) {
9756 const items_len = &ip.getLocal(unwrapped_index.tid).mutate.items.len;9688 const items_len = &ip.getLocal(unwrapped_index.tid).mutate.items.len;
...@@ -10390,17 +10322,7 @@ pub fn isIntegerType(ip: *const InternPool, ty: Index) bool {...@@ -10390,17 +10322,7 @@ pub fn isIntegerType(ip: *const InternPool, ty: Index) bool {
1039010322
10391/// does not include .enum_literal_type10323/// does not include .enum_literal_type
10392pub fn isEnumType(ip: *const InternPool, ty: Index) bool {10324pub fn isEnumType(ip: *const InternPool, ty: Index) bool {
10393 return switch (ty) {10325 return ip.indexToKey(ty) == .enum_type;
10394 .atomic_order_type,
10395 .atomic_rmw_op_type,
10396 .calling_convention_type,
10397 .address_space_type,
10398 .float_mode_type,
10399 .reduce_op_type,
10400 .call_modifier_type,
10401 => true,
10402 else => ip.indexToKey(ty) == .enum_type,
10403 };
10404}10326}
1040510327
10406pub fn isUnion(ip: *const InternPool, ty: Index) bool {10328pub fn isUnion(ip: *const InternPool, ty: Index) bool {
...@@ -11401,17 +11323,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {...@@ -11401,17 +11323,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
11401 .null_type,11323 .null_type,
11402 .undefined_type,11324 .undefined_type,
11403 .enum_literal_type,11325 .enum_literal_type,
11404 .atomic_order_type,
11405 .atomic_rmw_op_type,
11406 .calling_convention_type,
11407 .address_space_type,
11408 .float_mode_type,
11409 .reduce_op_type,
11410 .call_modifier_type,
11411 .prefetch_options_type,
11412 .export_options_type,
11413 .extern_options_type,
11414 .type_info_type,
11415 .manyptr_u8_type,11326 .manyptr_u8_type,
11416 .manyptr_const_u8_type,11327 .manyptr_const_u8_type,
11417 .manyptr_const_u8_sentinel_0_type,11328 .manyptr_const_u8_sentinel_0_type,
...@@ -11429,7 +11340,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {...@@ -11429,7 +11340,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
11429 .zero, .one, .negative_one => .comptime_int_type,11340 .zero, .one, .negative_one => .comptime_int_type,
11430 .zero_usize, .one_usize => .usize_type,11341 .zero_usize, .one_usize => .usize_type,
11431 .zero_u8, .one_u8, .four_u8 => .u8_type,11342 .zero_u8, .one_u8, .four_u8 => .u8_type,
11432 .calling_convention_c, .calling_convention_inline => .calling_convention_type,
11433 .void_value => .void_type,11343 .void_value => .void_type,
11434 .unreachable_value => .noreturn_type,11344 .unreachable_value => .noreturn_type,
11435 .null_value => .null_type,11345 .null_value => .null_type,
...@@ -11725,22 +11635,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11725,22 +11635,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
11725 .undefined_type => .Undefined,11635 .undefined_type => .Undefined,
11726 .enum_literal_type => .EnumLiteral,11636 .enum_literal_type => .EnumLiteral,
1172711637
11728 .atomic_order_type,
11729 .atomic_rmw_op_type,
11730 .calling_convention_type,
11731 .address_space_type,
11732 .float_mode_type,
11733 .reduce_op_type,
11734 .call_modifier_type,
11735 => .Enum,
11736
11737 .prefetch_options_type,
11738 .export_options_type,
11739 .extern_options_type,
11740 => .Struct,
11741
11742 .type_info_type => .Union,
11743
11744 .manyptr_u8_type,11638 .manyptr_u8_type,
11745 .manyptr_const_u8_type,11639 .manyptr_const_u8_type,
11746 .manyptr_const_u8_sentinel_0_type,11640 .manyptr_const_u8_sentinel_0_type,
...@@ -11765,8 +11659,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11765,8 +11659,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
11765 .one_u8 => unreachable,11659 .one_u8 => unreachable,
11766 .four_u8 => unreachable,11660 .four_u8 => unreachable,
11767 .negative_one => unreachable,11661 .negative_one => unreachable,
11768 .calling_convention_c => unreachable,
11769 .calling_convention_inline => unreachable,
11770 .void_value => unreachable,11662 .void_value => unreachable,
11771 .unreachable_value => unreachable,11663 .unreachable_value => unreachable,
11772 .null_value => unreachable,11664 .null_value => unreachable,
...@@ -12085,34 +11977,6 @@ pub fn unwrapCoercedFunc(ip: *const InternPool, index: Index) Index {...@@ -12085,34 +11977,6 @@ pub fn unwrapCoercedFunc(ip: *const InternPool, index: Index) Index {
12085 };11977 };
12086}11978}
1208711979
12088/// Having resolved a builtin type to a real struct/union/enum (which is now at `resolverd_index`),
12089/// make `want_index` refer to this type instead. This invalidates `resolved_index`, so must be
12090/// called only when it is guaranteed that no reference to `resolved_index` exists.
12091pub fn resolveBuiltinType(
12092 ip: *InternPool,
12093 tid: Zcu.PerThread.Id,
12094 want_index: Index,
12095 resolved_index: Index,
12096) void {
12097 assert(@intFromEnum(want_index) >= @intFromEnum(Index.first_type));
12098 assert(@intFromEnum(want_index) <= @intFromEnum(Index.last_type));
12099
12100 // Make sure the type isn't already resolved!
12101 assert(ip.indexToKey(want_index) == .simple_type);
12102
12103 // Make sure it's the same kind of type
12104 assert((ip.zigTypeTagOrPoison(want_index) catch unreachable) ==
12105 (ip.zigTypeTagOrPoison(resolved_index) catch unreachable));
12106
12107 // Copy the data
12108 const item = resolved_index.unwrap(ip).getItem(ip);
12109 const unwrapped_index = want_index.unwrap(ip);
12110 var items = ip.getLocalShared(unwrapped_index.tid).items.acquire().view().slice();
12111 items.items(.data)[unwrapped_index.index] = item.data;
12112 @atomicStore(Tag, &items.items(.tag)[unwrapped_index.index], item.tag, .release);
12113 ip.remove(tid, resolved_index);
12114}
12115
12116pub fn anonStructFieldTypes(ip: *const InternPool, i: Index) []const Index {11980pub fn anonStructFieldTypes(ip: *const InternPool, i: Index) []const Index {
12117 return ip.indexToKey(i).anon_struct_type.types;11981 return ip.indexToKey(i).anon_struct_type.types;
12118}11982}
src/Sema.zig+52-39
...@@ -76,10 +76,6 @@ no_partial_func_ty: bool = false,...@@ -76,10 +76,6 @@ no_partial_func_ty: bool = false,
76/// here so the values can be dropped without any cleanup.76/// here so the values can be dropped without any cleanup.
77unresolved_inferred_allocs: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, InferredAlloc) = .{},77unresolved_inferred_allocs: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, InferredAlloc) = .{},
7878
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`.
81builtin_type_target_index: InternPool.Index = .none,
82
83/// Links every pointer derived from a base `alloc` back to that `alloc`. Used79/// Links every pointer derived from a base `alloc` back to that `alloc`. Used
84/// to detect comptime-known `const`s.80/// to detect comptime-known `const`s.
85/// TODO: ZIR liveness analysis would allow us to remove elements from this map.81/// TODO: ZIR liveness analysis would allow us to remove elements from this map.
...@@ -1327,6 +1323,7 @@ fn analyzeBodyInner(...@@ -1327,6 +1323,7 @@ fn analyzeBodyInner(
1327 },1323 },
1328 .value_placeholder => unreachable, // never appears in a body1324 .value_placeholder => unreachable, // never appears in a body
1329 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),1325 .field_parent_ptr => try sema.zirFieldParentPtr(block, extended),
1326 .builtin_value => try sema.zirBuiltinValue(extended),
1330 };1327 };
1331 },1328 },
13321329
...@@ -2712,17 +2709,6 @@ fn getCaptures(sema: *Sema, block: *Block, type_src: LazySrcLoc, extra_index: us...@@ -2712,17 +2709,6 @@ fn getCaptures(sema: *Sema, block: *Block, type_src: LazySrcLoc, extra_index: us
2712 return captures;2709 return captures;
2713}2710}
27142711
2715/// Given an `InternPool.WipNamespaceType` or `InternPool.WipEnumType`, apply
2716/// `sema.builtin_type_target_index` to it if necessary.
2717fn 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
2726fn zirStructDecl(2712fn zirStructDecl(
2727 sema: *Sema,2713 sema: *Sema,
2728 block: *Block,2714 block: *Block,
...@@ -2788,7 +2774,7 @@ fn zirStructDecl(...@@ -2788,7 +2774,7 @@ fn zirStructDecl(
2788 .captures = captures,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 .existing => |ty| {2778 .existing => |ty| {
2793 const new_ty = try pt.ensureTypeUpToDate(ty, false);2779 const new_ty = try pt.ensureTypeUpToDate(ty, false);
27942780
...@@ -2801,7 +2787,7 @@ fn zirStructDecl(...@@ -2801,7 +2787,7 @@ fn zirStructDecl(
2801 return Air.internedToRef(new_ty);2787 return Air.internedToRef(new_ty);
2802 },2788 },
2803 .wip => |wip| wip,2789 .wip => |wip| wip,
2804 });2790 };
2805 errdefer wip_ty.cancel(ip, pt.tid);2791 errdefer wip_ty.cancel(ip, pt.tid);
28062792
2807 wip_ty.setName(ip, try sema.createTypeName(2793 wip_ty.setName(ip, try sema.createTypeName(
...@@ -3017,7 +3003,7 @@ fn zirEnumDecl(...@@ -3017,7 +3003,7 @@ fn zirEnumDecl(
3017 .captures = captures,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 .existing => |ty| {3007 .existing => |ty| {
3022 const new_ty = try pt.ensureTypeUpToDate(ty, false);3008 const new_ty = try pt.ensureTypeUpToDate(ty, false);
30233009
...@@ -3030,7 +3016,7 @@ fn zirEnumDecl(...@@ -3030,7 +3016,7 @@ fn zirEnumDecl(
3030 return Air.internedToRef(new_ty);3016 return Air.internedToRef(new_ty);
3031 },3017 },
3032 .wip => |wip| wip,3018 .wip => |wip| wip,
3033 });3019 };
30343020
3035 // Once this is `true`, we will not delete the decl or type even upon failure, since we3021 // Once this is `true`, we will not delete the decl or type even upon failure, since we
3036 // have finished constructing the type and are in the process of analyzing it.3022 // have finished constructing the type and are in the process of analyzing it.
...@@ -3161,7 +3147,7 @@ fn zirUnionDecl(...@@ -3161,7 +3147,7 @@ fn zirUnionDecl(
3161 .captures = captures,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 .existing => |ty| {3151 .existing => |ty| {
3166 const new_ty = try pt.ensureTypeUpToDate(ty, false);3152 const new_ty = try pt.ensureTypeUpToDate(ty, false);
31673153
...@@ -3174,7 +3160,7 @@ fn zirUnionDecl(...@@ -3174,7 +3160,7 @@ fn zirUnionDecl(
3174 return Air.internedToRef(new_ty);3160 return Air.internedToRef(new_ty);
3175 },3161 },
3176 .wip => |wip| wip,3162 .wip => |wip| wip,
3177 });3163 };
3178 errdefer wip_ty.cancel(ip, pt.tid);3164 errdefer wip_ty.cancel(ip, pt.tid);
31793165
3180 wip_ty.setName(ip, try sema.createTypeName(3166 wip_ty.setName(ip, try sema.createTypeName(
...@@ -3259,7 +3245,6 @@ fn zirOpaqueDecl(...@@ -3259,7 +3245,6 @@ fn zirOpaqueDecl(
3259 .captures = captures,3245 .captures = captures,
3260 } },3246 } },
3261 };3247 };
3262 // No `wrapWipTy` needed as no std.builtin types are opaque.
3263 const wip_ty = switch (try ip.getOpaqueType(gpa, pt.tid, opaque_init)) {3248 const wip_ty = switch (try ip.getOpaqueType(gpa, pt.tid, opaque_init)) {
3264 .existing => |ty| {3249 .existing => |ty| {
3265 // Make sure we update the namespace if the declaration is re-analyzed, to pick3250 // 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,7 +26164,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
26179 const body = sema.code.bodySlice(extra_index, body_len);26164 const body = sema.code.bodySlice(extra_index, body_len);
26180 extra_index += body.len;26165 extra_index += body.len;
2618126166
26182 const addrspace_ty = Type.fromInterned(.address_space_type);26167 const addrspace_ty = try pt.getBuiltinType("AddressSpace");
26183 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, .{26168 const val = try sema.resolveGenericBody(block, addrspace_src, body, inst, addrspace_ty, .{
26184 .needed_comptime_reason = "addrspace must be comptime-known",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,7 +26175,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
26190 } else if (extra.data.bits.has_addrspace_ref) blk: {26175 } else if (extra.data.bits.has_addrspace_ref) blk: {
26191 const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);26176 const addrspace_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
26192 extra_index += 1;26177 extra_index += 1;
26193 const addrspace_ty = Type.fromInterned(.address_space_type);26178 const addrspace_ty = try pt.getBuiltinType("AddressSpace");
26194 const uncoerced_addrspace = sema.resolveInst(addrspace_ref) catch |err| switch (err) {26179 const uncoerced_addrspace = sema.resolveInst(addrspace_ref) catch |err| switch (err) {
26195 error.GenericPoison => break :blk null,26180 error.GenericPoison => break :blk null,
26196 else => |e| return e,26181 else => |e| return e,
...@@ -26255,7 +26240,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -26255,7 +26240,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
26255 } else if (extra.data.bits.has_cc_ref) blk: {26240 } else if (extra.data.bits.has_cc_ref) blk: {
26256 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);26241 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
26257 extra_index += 1;26242 extra_index += 1;
26258 const cc_ty = Type.fromInterned(.calling_convention_type);26243 const cc_ty = try pt.getBuiltinType("CallingConvention");
26259 const uncoerced_cc = sema.resolveInst(cc_ref) catch |err| switch (err) {26244 const uncoerced_cc = sema.resolveInst(cc_ref) catch |err| switch (err) {
26260 error.GenericPoison => break :blk null,26245 error.GenericPoison => break :blk null,
26261 else => |e| return e,26246 else => |e| return e,
...@@ -26713,6 +26698,46 @@ fn zirInComptime(...@@ -26713,6 +26698,46 @@ fn zirInComptime(
26713 return if (block.is_comptime) .bool_true else .bool_false;26698 return if (block.is_comptime) .bool_true else .bool_false;
26714}26699}
2671526700
26701fn 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
26716fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void {26741fn requireRuntimeBlock(sema: *Sema, block: *Block, src: LazySrcLoc, runtime_src: ?LazySrcLoc) !void {
26717 if (block.is_comptime) {26742 if (block.is_comptime) {
26718 const msg = msg: {26743 const msg = msg: {
...@@ -36899,17 +36924,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -36899,17 +36924,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
36899 .comptime_int_type,36924 .comptime_int_type,
36900 .comptime_float_type,36925 .comptime_float_type,
36901 .enum_literal_type,36926 .enum_literal_type,
36902 .atomic_order_type,
36903 .atomic_rmw_op_type,
36904 .calling_convention_type,
36905 .address_space_type,
36906 .float_mode_type,
36907 .reduce_op_type,
36908 .call_modifier_type,
36909 .prefetch_options_type,
36910 .export_options_type,
36911 .extern_options_type,
36912 .type_info_type,
36913 .manyptr_u8_type,36927 .manyptr_u8_type,
36914 .manyptr_const_u8_type,36928 .manyptr_const_u8_type,
36915 .manyptr_const_u8_sentinel_0_type,36929 .manyptr_const_u8_sentinel_0_type,
...@@ -36936,8 +36950,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -36936,8 +36950,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
36936 .one_u8,36950 .one_u8,
36937 .four_u8,36951 .four_u8,
36938 .negative_one,36952 .negative_one,
36939 .calling_convention_c,
36940 .calling_convention_inline,
36941 .void_value,36953 .void_value,
36942 .unreachable_value,36954 .unreachable_value,
36943 .null_value,36955 .null_value,
...@@ -37291,7 +37303,8 @@ pub fn analyzeAsAddressSpace(...@@ -37291,7 +37303,8 @@ pub fn analyzeAsAddressSpace(
37291) !std.builtin.AddressSpace {37303) !std.builtin.AddressSpace {
37292 const pt = sema.pt;37304 const pt = sema.pt;
37293 const mod = pt.zcu;37305 const mod = pt.zcu;
37294 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);
37295 const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{37308 const addrspace_val = try sema.resolveConstDefinedValue(block, src, coerced, .{
37296 .needed_comptime_reason = "address space must be comptime-known",37309 .needed_comptime_reason = "address space must be comptime-known",
37297 });37310 });
src/Type.zig+1-129
...@@ -316,17 +316,6 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error...@@ -316,17 +316,6 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
316 => try writer.print("@TypeOf({s})", .{@tagName(s)}),316 => try writer.print("@TypeOf({s})", .{@tagName(s)}),
317317
318 .enum_literal => try writer.print("@TypeOf(.{s})", .{@tagName(s)}),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"),
330319
331 .generic_poison => unreachable,320 .generic_poison => unreachable,
332 },321 },
...@@ -544,16 +533,6 @@ pub fn hasRuntimeBitsAdvanced(...@@ -544,16 +533,6 @@ pub fn hasRuntimeBitsAdvanced(
544 .anyerror,533 .anyerror,
545 .adhoc_inferred_error_set,534 .adhoc_inferred_error_set,
546 .anyopaque,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 => true,536 => true,
558537
559 // These are false because they are comptime-only types.538 // These are false because they are comptime-only types.
...@@ -565,7 +544,6 @@ pub fn hasRuntimeBitsAdvanced(...@@ -565,7 +544,6 @@ pub fn hasRuntimeBitsAdvanced(
565 .null,544 .null,
566 .undefined,545 .undefined,
567 .enum_literal,546 .enum_literal,
568 .type_info,
569 => false,547 => false,
570548
571 .generic_poison => unreachable,549 .generic_poison => unreachable,
...@@ -711,16 +689,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool {...@@ -711,16 +689,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool {
711 .anyerror,689 .anyerror,
712 .adhoc_inferred_error_set,690 .adhoc_inferred_error_set,
713 .anyopaque,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 .type,692 .type,
725 .comptime_int,693 .comptime_int,
726 .comptime_float,694 .comptime_float,
...@@ -728,7 +696,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool {...@@ -728,7 +696,6 @@ pub fn hasWellDefinedLayout(ty: Type, mod: *Module) bool {
728 .null,696 .null,
729 .undefined,697 .undefined,
730 .enum_literal,698 .enum_literal,
731 .type_info,
732 .generic_poison,699 .generic_poison,
733 => false,700 => false,
734 },701 },
...@@ -972,14 +939,6 @@ pub fn abiAlignmentAdvanced(...@@ -972,14 +939,6 @@ pub fn abiAlignmentAdvanced(
972939
973 .simple_type => |t| switch (t) {940 .simple_type => |t| switch (t) {
974 .bool,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 .anyopaque,942 .anyopaque,
984 => return .{ .scalar = .@"1" },943 => return .{ .scalar = .@"1" },
985944
...@@ -987,11 +946,6 @@ pub fn abiAlignmentAdvanced(...@@ -987,11 +946,6 @@ pub fn abiAlignmentAdvanced(
987 .isize,946 .isize,
988 => return .{ .scalar = intAbiAlignment(target.ptrBitWidth(), target, use_llvm) },947 => return .{ .scalar = intAbiAlignment(target.ptrBitWidth(), target, use_llvm) },
989948
990 .export_options,
991 .extern_options,
992 .type_info,
993 => return .{ .scalar = ptrAbiAlignment(target) },
994
995 .c_char => return .{ .scalar = cTypeAlign(target, .char) },949 .c_char => return .{ .scalar = cTypeAlign(target, .char) },
996 .c_short => return .{ .scalar = cTypeAlign(target, .short) },950 .c_short => return .{ .scalar = cTypeAlign(target, .short) },
997 .c_ushort => return .{ .scalar = cTypeAlign(target, .ushort) },951 .c_ushort => return .{ .scalar = cTypeAlign(target, .ushort) },
...@@ -1352,15 +1306,7 @@ pub fn abiSizeAdvanced(...@@ -1352,15 +1306,7 @@ pub fn abiSizeAdvanced(
1352 },1306 },
1353 .func_type => unreachable, // represents machine code; not a pointer1307 .func_type => unreachable, // represents machine code; not a pointer
1354 .simple_type => |t| switch (t) {1308 .simple_type => |t| switch (t) {
1355 .bool,1309 .bool => return .{ .scalar = 1 },
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 },
13641310
1365 .f16 => return .{ .scalar = 2 },1311 .f16 => return .{ .scalar = 2 },
1366 .f32 => return .{ .scalar = 4 },1312 .f32 => return .{ .scalar = 4 },
...@@ -1402,11 +1348,6 @@ pub fn abiSizeAdvanced(...@@ -1402,11 +1348,6 @@ pub fn abiSizeAdvanced(
1402 return .{ .scalar = intAbiSize(bits, target, use_llvm) };1348 return .{ .scalar = intAbiSize(bits, target, use_llvm) };
1403 },1349 },
14041350
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 .noreturn => unreachable,1351 .noreturn => unreachable,
1411 .generic_poison => unreachable,1352 .generic_poison => unreachable,
1412 },1353 },
...@@ -1751,18 +1692,6 @@ pub fn bitSizeAdvanced(...@@ -1751,18 +1692,6 @@ pub fn bitSizeAdvanced(
1751 .undefined => unreachable,1692 .undefined => unreachable,
1752 .enum_literal => unreachable,1693 .enum_literal => unreachable,
1753 .generic_poison => unreachable,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 .struct_type => {1696 .struct_type => {
1768 const struct_type = ip.loadStructType(ty.toIntern());1697 const struct_type = ip.loadStructType(ty.toIntern());
...@@ -2565,17 +2494,6 @@ pub fn onePossibleValue(starting_type: Type, pt: Zcu.PerThread) !?Value {...@@ -2565,17 +2494,6 @@ pub fn onePossibleValue(starting_type: Type, pt: Zcu.PerThread) !?Value {
2565 .comptime_int,2494 .comptime_int,
2566 .comptime_float,2495 .comptime_float,
2567 .enum_literal,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 .adhoc_inferred_error_set,2497 .adhoc_inferred_error_set,
2580 => return null,2498 => return null,
25812499
...@@ -2782,16 +2700,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve...@@ -2782,16 +2700,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
2782 .adhoc_inferred_error_set,2700 .adhoc_inferred_error_set,
2783 .noreturn,2701 .noreturn,
2784 .generic_poison,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 => false,2703 => false,
27962704
2797 .type,2705 .type,
...@@ -2800,7 +2708,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve...@@ -2800,7 +2708,6 @@ pub fn comptimeOnlyAdvanced(ty: Type, pt: Zcu.PerThread, comptime strat: Resolve
2800 .null,2708 .null,
2801 .undefined,2709 .undefined,
2802 .enum_literal,2710 .enum_literal,
2803 .type_info,
2804 => true,2711 => true,
2805 },2712 },
2806 .struct_type => {2713 .struct_type => {
...@@ -3534,10 +3441,6 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx:...@@ -3534,10 +3441,6 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx:
3534pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {3441pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {
3535 const zcu = pt.zcu;3442 const zcu = pt.zcu;
3536 const ip = &zcu.intern_pool;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 switch (ty.zigTypeTag(zcu)) {3444 switch (ty.zigTypeTag(zcu)) {
3542 .Struct => switch (ip.indexToKey(ty.toIntern())) {3445 .Struct => switch (ip.indexToKey(ty.toIntern())) {
3543 .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| {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,8 +3554,6 @@ pub fn resolveFields(ty: Type, pt: Zcu.PerThread) SemaError!void {
3651 .one_u8 => unreachable,3554 .one_u8 => unreachable,
3652 .four_u8 => unreachable,3555 .four_u8 => unreachable,
3653 .negative_one => unreachable,3556 .negative_one => unreachable,
3654 .calling_convention_c => unreachable,
3655 .calling_convention_inline => unreachable,
3656 .void_value => unreachable,3557 .void_value => unreachable,
3657 .unreachable_value => unreachable,3558 .unreachable_value => unreachable,
3658 .null_value => unreachable,3559 .null_value => unreachable,
...@@ -3669,8 +3570,6 @@ pub fn resolveFields(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3669,8 +3570,6 @@ pub fn resolveFields(ty: Type, pt: Zcu.PerThread) SemaError!void {
36693570
3670 .type_union => return ty.resolveUnionInner(pt, .fields),3571 .type_union => return ty.resolveUnionInner(pt, .fields),
36713572
3672 .simple_type => return resolveSimpleType(ip.indexToKey(ty_ip).simple_type, pt),
3673
3674 else => {},3573 else => {},
3675 },3574 },
3676 }3575 }
...@@ -3680,11 +3579,6 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3680,11 +3579,6 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {
3680 const zcu = pt.zcu;3579 const zcu = pt.zcu;
3681 const ip = &zcu.intern_pool;3580 const ip = &zcu.intern_pool;
36823581
3683 switch (ip.indexToKey(ty.toIntern())) {
3684 .simple_type => |simple_type| return resolveSimpleType(simple_type, pt),
3685 else => {},
3686 }
3687
3688 switch (ty.zigTypeTag(zcu)) {3582 switch (ty.zigTypeTag(zcu)) {
3689 .Type,3583 .Type,
3690 .Void,3584 .Void,
...@@ -3850,28 +3744,6 @@ fn resolveUnionInner(...@@ -3850,28 +3744,6 @@ fn resolveUnionInner(
3850 };3744 };
3851}3745}
38523746
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.
3856fn 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/// Returns the type of a pointer to an element.3747/// Returns the type of a pointer to an element.
3876/// Asserts that the type is a pointer, and that the element type is indexable.3748/// Asserts that the type is a pointer, and that the element type is indexable.
3877/// If the element index is comptime-known, it must be passed in `offset`.3749/// If the element index is comptime-known, it must be passed in `offset`.
src/Zcu/PerThread.zig+7-75
...@@ -1102,12 +1102,9 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1102,12 +1102,9 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1102 // We are about to re-analyze this `Cau`; drop its depenndencies.1102 // We are about to re-analyze this `Cau`; drop its depenndencies.
1103 zcu.intern_pool.removeDependenciesForDepender(gpa, anal_unit);1103 zcu.intern_pool.removeDependenciesForDepender(gpa, anal_unit);
11041104
1105 const builtin_type_target_index: InternPool.Index = switch (cau.owner.unwrap()) {1105 switch (cau.owner.unwrap()) {
1106 .none => ip_index: {1106 .none => {}, // `comptime` decl -- we will re-analyze its body.
1107 // `comptime` decl -- we will re-analyze its body.1107 .nav => {}, // Other decl -- we will re-analyze its value.
1108 // This declaration has no value so is definitely not a std.builtin type.
1109 break :ip_index .none;
1110 },
1111 .type => |ty| {1108 .type => |ty| {
1112 // This is an incremental update, and this type is being re-analyzed because it is outdated.1109 // This is an incremental update, and this type is being re-analyzed because it is outdated.
1113 // Create a new type in its place, and mark the old one as outdated so that use sites will1110 // Create a new type in its place, and mark the old one as outdated so that use sites will
...@@ -1119,53 +1116,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1119,53 +1116,7 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1119 .invalidate_decl_ref = true,1116 .invalidate_decl_ref = true,
1120 };1117 };
1121 },1118 },
1122 .nav => |nav| ip_index: {1119 }
1123 // Other decl -- we will re-analyze its value.
1124 // This might be a type in `builtin.zig` -- check.
1125 if (file.mod != zcu.std_mod) break :ip_index .none;
1126 // We're in the std module.
1127 const nav_name = ip.getNav(nav).name;
1128 const std_file_imported = try pt.importPkg(zcu.std_mod);
1129 const std_type = Type.fromInterned(zcu.fileRootType(std_file_imported.file_index));
1130 const std_namespace = zcu.namespacePtr(std_type.getNamespace(zcu).unwrap().?);
1131 const builtin_str = try ip.getOrPutString(gpa, pt.tid, "builtin", .no_embedded_nulls);
1132 const builtin_nav = ip.getNav(std_namespace.pub_decls.getKeyAdapted(builtin_str, Zcu.Namespace.NameAdapter{ .zcu = zcu }) orelse break :ip_index .none);
1133 const builtin_namespace = switch (builtin_nav.status) {
1134 .unresolved => break :ip_index .none,
1135 .resolved => |r| Type.fromInterned(r.val).getNamespace(zcu).unwrap().?,
1136 };
1137 if (cau.namespace != builtin_namespace) break :ip_index .none;
1138 // We're in builtin.zig. This could be a builtin we need to add to a specific InternPool index.
1139 for ([_][]const u8{
1140 "AtomicOrder",
1141 "AtomicRmwOp",
1142 "CallingConvention",
1143 "AddressSpace",
1144 "FloatMode",
1145 "ReduceOp",
1146 "CallModifier",
1147 "PrefetchOptions",
1148 "ExportOptions",
1149 "ExternOptions",
1150 "Type",
1151 }, [_]InternPool.Index{
1152 .atomic_order_type,
1153 .atomic_rmw_op_type,
1154 .calling_convention_type,
1155 .address_space_type,
1156 .float_mode_type,
1157 .reduce_op_type,
1158 .call_modifier_type,
1159 .prefetch_options_type,
1160 .export_options_type,
1161 .extern_options_type,
1162 .type_info_type,
1163 }) |type_name, type_ip| {
1164 if (nav_name.eqlSlice(type_name, ip)) break :ip_index type_ip;
1165 }
1166 break :ip_index .none;
1167 },
1168 };
11691120
1170 const is_usingnamespace = switch (cau.owner.unwrap()) {1121 const is_usingnamespace = switch (cau.owner.unwrap()) {
1171 .nav => |nav| ip.getNav(nav).is_usingnamespace,1122 .nav => |nav| ip.getNav(nav).is_usingnamespace,
...@@ -1194,7 +1145,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1194,7 +1145,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1194 .fn_ret_ty = Type.void,1145 .fn_ret_ty = Type.void,
1195 .fn_ret_ty_ies = null,1146 .fn_ret_ty_ies = null,
1196 .comptime_err_ret_trace = &comptime_err_ret_trace,1147 .comptime_err_ret_trace = &comptime_err_ret_trace,
1197 .builtin_type_target_index = builtin_type_target_index,
1198 };1148 };
1199 defer sema.deinit();1149 defer sema.deinit();
12001150
...@@ -1249,9 +1199,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {...@@ -1249,9 +1199,6 @@ fn semaCau(pt: Zcu.PerThread, cau_index: InternPool.Cau.Index) !SemaCauResult {
1249 .type => unreachable, // Handled at top of function.1199 .type => unreachable, // Handled at top of function.
1250 };1200 };
12511201
1252 // We'll do more work with the Sema. Clear the target type index just in case we analyze any type.
1253 sema.builtin_type_target_index = .none;
1254
1255 const align_src = block.src(.{ .node_offset_var_decl_align = 0 });1202 const align_src = block.src(.{ .node_offset_var_decl_align = 0 });
1256 const section_src = block.src(.{ .node_offset_var_decl_section = 0 });1203 const section_src = block.src(.{ .node_offset_var_decl_section = 0 });
1257 const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = 0 });1204 const addrspace_src = block.src(.{ .node_offset_var_decl_addrspace = 0 });
...@@ -3349,7 +3296,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat...@@ -3349,7 +3296,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat
3349 break :o o;3296 break :o o;
3350 };3297 };
3351 if (!outdated) return ty;3298 if (!outdated) return ty;
3352 return pt.recreateStructType(ty, key, struct_obj);3299 return pt.recreateStructType(key, struct_obj);
3353 },3300 },
3354 .union_type => |key| {3301 .union_type => |key| {
3355 const union_obj = ip.loadUnionType(ty);3302 const union_obj = ip.loadUnionType(ty);
...@@ -3364,7 +3311,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat...@@ -3364,7 +3311,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat
3364 break :o o;3311 break :o o;
3365 };3312 };
3366 if (!outdated) return ty;3313 if (!outdated) return ty;
3367 return pt.recreateUnionType(ty, key, union_obj);3314 return pt.recreateUnionType(key, union_obj);
3368 },3315 },
3369 .enum_type => |key| {3316 .enum_type => |key| {
3370 const enum_obj = ip.loadEnumType(ty);3317 const enum_obj = ip.loadEnumType(ty);
...@@ -3379,7 +3326,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat...@@ -3379,7 +3326,7 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat
3379 break :o o;3326 break :o o;
3380 };3327 };
3381 if (!outdated) return ty;3328 if (!outdated) return ty;
3382 return pt.recreateEnumType(ty, key, enum_obj);3329 return pt.recreateEnumType(key, enum_obj);
3383 },3330 },
3384 .opaque_type => {3331 .opaque_type => {
3385 assert(!already_updating);3332 assert(!already_updating);
...@@ -3391,7 +3338,6 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat...@@ -3391,7 +3338,6 @@ pub fn ensureTypeUpToDate(pt: Zcu.PerThread, ty: InternPool.Index, already_updat
33913338
3392fn recreateStructType(3339fn recreateStructType(
3393 pt: Zcu.PerThread,3340 pt: Zcu.PerThread,
3394 ty: InternPool.Index,
3395 full_key: InternPool.Key.NamespaceType,3341 full_key: InternPool.Key.NamespaceType,
3396 struct_obj: InternPool.LoadedStructType,3342 struct_obj: InternPool.LoadedStructType,
3397) Zcu.SemaError!InternPool.Index {3343) Zcu.SemaError!InternPool.Index {
...@@ -3406,10 +3352,6 @@ fn recreateStructType(...@@ -3406,10 +3352,6 @@ fn recreateStructType(
3406 .declared => |d| d,3352 .declared => |d| d,
3407 };3353 };
34083354
3409 if (@intFromEnum(ty) <= InternPool.static_len) {
3410 @panic("TODO: recreate resolved builtin type");
3411 }
3412
3413 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;3355 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;
3414 const file = zcu.fileByIndex(inst_info.file);3356 const file = zcu.fileByIndex(inst_info.file);
3415 if (file.status != .success_zir) return error.AnalysisFail;3357 if (file.status != .success_zir) return error.AnalysisFail;
...@@ -3482,7 +3424,6 @@ fn recreateStructType(...@@ -3482,7 +3424,6 @@ fn recreateStructType(
34823424
3483fn recreateUnionType(3425fn recreateUnionType(
3484 pt: Zcu.PerThread,3426 pt: Zcu.PerThread,
3485 ty: InternPool.Index,
3486 full_key: InternPool.Key.NamespaceType,3427 full_key: InternPool.Key.NamespaceType,
3487 union_obj: InternPool.LoadedUnionType,3428 union_obj: InternPool.LoadedUnionType,
3488) Zcu.SemaError!InternPool.Index {3429) Zcu.SemaError!InternPool.Index {
...@@ -3497,10 +3438,6 @@ fn recreateUnionType(...@@ -3497,10 +3438,6 @@ fn recreateUnionType(
3497 .declared => |d| d,3438 .declared => |d| d,
3498 };3439 };
34993440
3500 if (@intFromEnum(ty) <= InternPool.static_len) {
3501 @panic("TODO: recreate resolved builtin type");
3502 }
3503
3504 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;3441 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;
3505 const file = zcu.fileByIndex(inst_info.file);3442 const file = zcu.fileByIndex(inst_info.file);
3506 if (file.status != .success_zir) return error.AnalysisFail;3443 if (file.status != .success_zir) return error.AnalysisFail;
...@@ -3581,7 +3518,6 @@ fn recreateUnionType(...@@ -3581,7 +3518,6 @@ fn recreateUnionType(
35813518
3582fn recreateEnumType(3519fn recreateEnumType(
3583 pt: Zcu.PerThread,3520 pt: Zcu.PerThread,
3584 ty: InternPool.Index,
3585 full_key: InternPool.Key.NamespaceType,3521 full_key: InternPool.Key.NamespaceType,
3586 enum_obj: InternPool.LoadedEnumType,3522 enum_obj: InternPool.LoadedEnumType,
3587) Zcu.SemaError!InternPool.Index {3523) Zcu.SemaError!InternPool.Index {
...@@ -3596,10 +3532,6 @@ fn recreateEnumType(...@@ -3596,10 +3532,6 @@ fn recreateEnumType(
3596 .declared => |d| d,3532 .declared => |d| d,
3597 };3533 };
35983534
3599 if (@intFromEnum(ty) <= InternPool.static_len) {
3600 @panic("TODO: recreate resolved builtin type");
3601 }
3602
3603 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;3535 const inst_info = key.zir_index.resolveFull(ip) orelse return error.AnalysisFail;
3604 const file = zcu.fileByIndex(inst_info.file);3536 const file = zcu.fileByIndex(inst_info.file);
3605 if (file.status != .success_zir) return error.AnalysisFail;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,21 +1389,6 @@ pub const Pool = struct {
1389 .anyframe_type,1389 .anyframe_type,
1390 .generic_poison_type,1390 .generic_poison_type,
1391 => unreachable,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 .anyerror_type,1392 .anyerror_type,
1408 .anyerror_void_error_union_type,1393 .anyerror_void_error_union_type,
1409 .adhoc_inferred_error_set_type,1394 .adhoc_inferred_error_set_type,
...@@ -1459,8 +1444,6 @@ pub const Pool = struct {...@@ -1459,8 +1444,6 @@ pub const Pool = struct {
1459 .one_u8,1444 .one_u8,
1460 .four_u8,1445 .four_u8,
1461 .negative_one,1446 .negative_one,
1462 .calling_convention_c,
1463 .calling_convention_inline,
1464 .void_value,1447 .void_value,
1465 .unreachable_value,1448 .unreachable_value,
1466 .null_value,1449 .null_value,
...@@ -1471,12 +1454,7 @@ pub const Pool = struct {...@@ -1471,12 +1454,7 @@ pub const Pool = struct {
1471 .none,1454 .none,
1472 => unreachable,1455 => unreachable,
14731456
1474 //.prefetch_options_type,1457 _ => |ip_index| switch (ip.indexToKey(ip_index)) {
1475 //.export_options_type,
1476 //.extern_options_type,
1477 //.type_info_type,
1478 //_,
1479 else => |ip_index| switch (ip.indexToKey(ip_index)) {
1480 .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),1458 .int_type => |int_info| return pool.fromIntInfo(allocator, int_info, mod, kind),
1481 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {1459 .ptr_type => |ptr_info| switch (ptr_info.flags.size) {
1482 .One, .Many, .C => {1460 .One, .Many, .C => {
src/codegen/llvm.zig-2
...@@ -3194,8 +3194,6 @@ pub const Object = struct {...@@ -3194,8 +3194,6 @@ pub const Object = struct {
3194 .one_u8,3194 .one_u8,
3195 .four_u8,3195 .four_u8,
3196 .negative_one,3196 .negative_one,
3197 .calling_convention_c,
3198 .calling_convention_inline,
3199 .void_value,3197 .void_value,
3200 .unreachable_value,3198 .unreachable_value,
3201 .null_value,3199 .null_value,
src/link/Dwarf.zig+1-13
...@@ -2565,19 +2565,7 @@ fn updateType(...@@ -2565,19 +2565,7 @@ fn updateType(
2565 try wip_nav.strp(if (type_index == .generic_poison_type) "anytype" else name);2565 try wip_nav.strp(if (type_index == .generic_poison_type) "anytype" else name);
2566 },2566 },
2567 .anyerror => return, // delay until flush2567 .anyerror => return, // delay until flush
2568 .atomic_order,2568 .adhoc_inferred_error_set => unreachable,
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,
2581 },2569 },
2582 .struct_type,2570 .struct_type,
2583 .union_type,2571 .union_type,
src/print_zir.zig+7
...@@ -615,6 +615,7 @@ const Writer = struct {...@@ -615,6 +615,7 @@ const Writer = struct {
615 .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended),615 .restore_err_ret_index => try self.writeRestoreErrRetIndex(stream, extended),
616 .closure_get => try self.writeClosureGet(stream, extended),616 .closure_get => try self.writeClosureGet(stream, extended),
617 .field_parent_ptr => try self.writeFieldParentPtr(stream, extended),617 .field_parent_ptr => try self.writeFieldParentPtr(stream, extended),
618 .builtin_value => try self.writeBuiltinValue(stream, extended),
618 }619 }
619 }620 }
620621
...@@ -2782,6 +2783,12 @@ const Writer = struct {...@@ -2782,6 +2783,12 @@ const Writer = struct {
2782 try self.writeSrcNode(stream, @bitCast(extended.operand));2783 try self.writeSrcNode(stream, @bitCast(extended.operand));
2783 }2784 }
27842785
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 fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void {2792 fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void {
2786 if (ref == .none) {2793 if (ref == .none) {
2787 return stream.writeAll(".none");2794 return stream.writeAll(".none");