| author | |
| committer | |
| log | 95e83afa98c5af89c6e5f40d559eb54c6c31a54e |
| tree | f1616f0a6a546a0ff7434b56b6efd1d0a3213c0f |
| parent | 5a142dfa5651ec21792de211a6e9341c31ab4dbb |
This is a property which solely belongs to pointers to functions,
not to the functions themselves. This cannot be properly represented by
stage 2 at the moment, as type with zigTypeTag() == .Fn is overloaded for
for function pointers and function prototypes.10 files changed, 179 insertions(+), 208 deletions(-)
lib/std/builtin.zig-1| ... | @@ -365,7 +365,6 @@ pub const TypeInfo = union(enum) { | ... | @@ -365,7 +365,6 @@ pub const TypeInfo = union(enum) { |
| 365 | pub const Fn = struct { | 365 | pub const Fn = struct { |
| 366 | calling_convention: CallingConvention, | 366 | calling_convention: CallingConvention, |
| 367 | alignment: comptime_int, | 367 | alignment: comptime_int, |
| 368 | address_space: AddressSpace, | ||
| 369 | is_generic: bool, | 368 | is_generic: bool, |
| 370 | is_var_args: bool, | 369 | is_var_args: bool, |
| 371 | return_type: ?type, | 370 | return_type: ?type, |
src/AstGen.zig+4-14| ... | @@ -1117,9 +1117,9 @@ fn fnProtoExpr( | ... | @@ -1117,9 +1117,9 @@ fn fnProtoExpr( |
| 1117 | break :inst try expr(gz, scope, align_rl, fn_proto.ast.align_expr); | 1117 | break :inst try expr(gz, scope, align_rl, fn_proto.ast.align_expr); |
| 1118 | }; | 1118 | }; |
| 1119 | 1119 | ||
| 1120 | const addrspace_inst: Zir.Inst.Ref = if (fn_proto.ast.addrspace_expr == 0) .none else inst: { | 1120 | if (fn_proto.ast.addrspace_expr != 0) { |
| 1121 | break :inst try expr(gz, scope, .{ .ty = .address_space_type }, fn_proto.ast.addrspace_expr); | 1121 | return astgen.failNode(fn_proto.ast.addrspace_expr, "addrspace not allowed on function prototypes", .{}); |
| 1122 | }; | 1122 | } |
| 1123 | 1123 | ||
| 1124 | if (fn_proto.ast.section_expr != 0) { | 1124 | if (fn_proto.ast.section_expr != 0) { |
| 1125 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); | 1125 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); |
| ... | @@ -1153,7 +1153,6 @@ fn fnProtoExpr( | ... | @@ -1153,7 +1153,6 @@ fn fnProtoExpr( |
| 1153 | .body = &[0]Zir.Inst.Index{}, | 1153 | .body = &[0]Zir.Inst.Index{}, |
| 1154 | .cc = cc, | 1154 | .cc = cc, |
| 1155 | .align_inst = align_inst, | 1155 | .align_inst = align_inst, |
| 1156 | .addrspace_inst = addrspace_inst, | ||
| 1157 | .lib_name = 0, | 1156 | .lib_name = 0, |
| 1158 | .is_var_args = is_var_args, | 1157 | .is_var_args = is_var_args, |
| 1159 | .is_inferred_error = false, | 1158 | .is_inferred_error = false, |
| ... | @@ -3089,7 +3088,6 @@ fn fnDecl( | ... | @@ -3089,7 +3088,6 @@ fn fnDecl( |
| 3089 | .body = &[0]Zir.Inst.Index{}, | 3088 | .body = &[0]Zir.Inst.Index{}, |
| 3090 | .cc = cc, | 3089 | .cc = cc, |
| 3091 | .align_inst = .none, // passed in the per-decl data | 3090 | .align_inst = .none, // passed in the per-decl data |
| 3092 | .addrspace_inst = .none, // passed in the per-decl data | ||
| 3093 | .lib_name = lib_name, | 3091 | .lib_name = lib_name, |
| 3094 | .is_var_args = is_var_args, | 3092 | .is_var_args = is_var_args, |
| 3095 | .is_inferred_error = false, | 3093 | .is_inferred_error = false, |
| ... | @@ -3129,7 +3127,6 @@ fn fnDecl( | ... | @@ -3129,7 +3127,6 @@ fn fnDecl( |
| 3129 | .body = fn_gz.instructions.items, | 3127 | .body = fn_gz.instructions.items, |
| 3130 | .cc = cc, | 3128 | .cc = cc, |
| 3131 | .align_inst = .none, // passed in the per-decl data | 3129 | .align_inst = .none, // passed in the per-decl data |
| 3132 | .addrspace_inst = .none, // passed in the per-decl data | ||
| 3133 | .lib_name = lib_name, | 3130 | .lib_name = lib_name, |
| 3134 | .is_var_args = is_var_args, | 3131 | .is_var_args = is_var_args, |
| 3135 | .is_inferred_error = is_inferred_error, | 3132 | .is_inferred_error = is_inferred_error, |
| ... | @@ -3481,7 +3478,6 @@ fn testDecl( | ... | @@ -3481,7 +3478,6 @@ fn testDecl( |
| 3481 | .body = fn_block.instructions.items, | 3478 | .body = fn_block.instructions.items, |
| 3482 | .cc = .none, | 3479 | .cc = .none, |
| 3483 | .align_inst = .none, | 3480 | .align_inst = .none, |
| 3484 | .addrspace_inst = .none, | ||
| 3485 | .lib_name = 0, | 3481 | .lib_name = 0, |
| 3486 | .is_var_args = false, | 3482 | .is_var_args = false, |
| 3487 | .is_inferred_error = true, | 3483 | .is_inferred_error = true, |
| ... | @@ -9217,7 +9213,6 @@ const GenZir = struct { | ... | @@ -9217,7 +9213,6 @@ const GenZir = struct { |
| 9217 | ret_br: Zir.Inst.Index, | 9213 | ret_br: Zir.Inst.Index, |
| 9218 | cc: Zir.Inst.Ref, | 9214 | cc: Zir.Inst.Ref, |
| 9219 | align_inst: Zir.Inst.Ref, | 9215 | align_inst: Zir.Inst.Ref, |
| 9220 | addrspace_inst: Zir.Inst.Ref, | ||
| 9221 | lib_name: u32, | 9216 | lib_name: u32, |
| 9222 | is_var_args: bool, | 9217 | is_var_args: bool, |
| 9223 | is_inferred_error: bool, | 9218 | is_inferred_error: bool, |
| ... | @@ -9261,7 +9256,7 @@ const GenZir = struct { | ... | @@ -9261,7 +9256,7 @@ const GenZir = struct { |
| 9261 | 9256 | ||
| 9262 | if (args.cc != .none or args.lib_name != 0 or | 9257 | if (args.cc != .none or args.lib_name != 0 or |
| 9263 | args.is_var_args or args.is_test or args.align_inst != .none or | 9258 | args.is_var_args or args.is_test or args.align_inst != .none or |
| 9264 | args.addrspace_inst != .none or args.is_extern) | 9259 | args.is_extern) |
| 9265 | { | 9260 | { |
| 9266 | try astgen.extra.ensureUnusedCapacity( | 9261 | try astgen.extra.ensureUnusedCapacity( |
| 9267 | gpa, | 9262 | gpa, |
| ... | @@ -9269,7 +9264,6 @@ const GenZir = struct { | ... | @@ -9269,7 +9264,6 @@ const GenZir = struct { |
| 9269 | args.ret_ty.len + args.body.len + src_locs.len + | 9264 | args.ret_ty.len + args.body.len + src_locs.len + |
| 9270 | @boolToInt(args.lib_name != 0) + | 9265 | @boolToInt(args.lib_name != 0) + |
| 9271 | @boolToInt(args.align_inst != .none) + | 9266 | @boolToInt(args.align_inst != .none) + |
| 9272 | @boolToInt(args.addrspace_inst != .none) + | ||
| 9273 | @boolToInt(args.cc != .none), | 9267 | @boolToInt(args.cc != .none), |
| 9274 | ); | 9268 | ); |
| 9275 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{ | 9269 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{ |
| ... | @@ -9287,9 +9281,6 @@ const GenZir = struct { | ... | @@ -9287,9 +9281,6 @@ const GenZir = struct { |
| 9287 | if (args.align_inst != .none) { | 9281 | if (args.align_inst != .none) { |
| 9288 | astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); | 9282 | astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); |
| 9289 | } | 9283 | } |
| 9290 | if (args.addrspace_inst != .none) { | ||
| 9291 | astgen.extra.appendAssumeCapacity(@enumToInt(args.addrspace_inst)); | ||
| 9292 | } | ||
| 9293 | astgen.extra.appendSliceAssumeCapacity(args.ret_ty); | 9284 | astgen.extra.appendSliceAssumeCapacity(args.ret_ty); |
| 9294 | astgen.extra.appendSliceAssumeCapacity(args.body); | 9285 | astgen.extra.appendSliceAssumeCapacity(args.body); |
| 9295 | astgen.extra.appendSliceAssumeCapacity(src_locs); | 9286 | astgen.extra.appendSliceAssumeCapacity(src_locs); |
| ... | @@ -9308,7 +9299,6 @@ const GenZir = struct { | ... | @@ -9308,7 +9299,6 @@ const GenZir = struct { |
| 9308 | .has_lib_name = args.lib_name != 0, | 9299 | .has_lib_name = args.lib_name != 0, |
| 9309 | .has_cc = args.cc != .none, | 9300 | .has_cc = args.cc != .none, |
| 9310 | .has_align = args.align_inst != .none, | 9301 | .has_align = args.align_inst != .none, |
| 9311 | .has_addrspace = args.addrspace_inst != .none, | ||
| 9312 | .is_test = args.is_test, | 9302 | .is_test = args.is_test, |
| 9313 | .is_extern = args.is_extern, | 9303 | .is_extern = args.is_extern, |
| 9314 | }), | 9304 | }), |
src/Module.zig+55-59| ... | @@ -3220,7 +3220,12 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { | ... | @@ -3220,7 +3220,12 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { |
| 3220 | }; | 3220 | }; |
| 3221 | 3221 | ||
| 3222 | break :blk switch (decl.zirAddrspaceRef()) { | 3222 | break :blk switch (decl.zirAddrspaceRef()) { |
| 3223 | .none => .generic, | 3223 | .none => switch (addrspace_ctx) { |
| 3224 | .function => target_util.defaultAddressSpace(sema.mod.getTarget(), .function), | ||
| 3225 | .variable => target_util.defaultAddressSpace(sema.mod.getTarget(), .global_mutable), | ||
| 3226 | .constant => target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), | ||
| 3227 | else => unreachable, | ||
| 3228 | }, | ||
| 3224 | else => |addrspace_ref| try sema.analyzeAddrspace(&block_scope, src, addrspace_ref, addrspace_ctx), | 3229 | else => |addrspace_ref| try sema.analyzeAddrspace(&block_scope, src, addrspace_ref, addrspace_ctx), |
| 3225 | }; | 3230 | }; |
| 3226 | }; | 3231 | }; |
| ... | @@ -4359,26 +4364,21 @@ pub fn simplePtrType( | ... | @@ -4359,26 +4364,21 @@ pub fn simplePtrType( |
| 4359 | elem_ty: Type, | 4364 | elem_ty: Type, |
| 4360 | mutable: bool, | 4365 | mutable: bool, |
| 4361 | size: std.builtin.TypeInfo.Pointer.Size, | 4366 | size: std.builtin.TypeInfo.Pointer.Size, |
| 4367 | @"addrspace": std.builtin.AddressSpace, | ||
| 4362 | ) Allocator.Error!Type { | 4368 | ) Allocator.Error!Type { |
| 4363 | if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { | 4369 | return ptrType( |
| 4364 | return Type.initTag(.const_slice_u8); | 4370 | arena, |
| 4365 | } | 4371 | elem_ty, |
| 4366 | // TODO stage1 type inference bug | 4372 | null, |
| 4367 | const T = Type.Tag; | 4373 | 0, |
| 4368 | 4374 | @"addrspace", | |
| 4369 | const type_payload = try arena.create(Type.Payload.ElemType); | 4375 | 0, |
| 4370 | type_payload.* = .{ | 4376 | 0, |
| 4371 | .base = .{ | 4377 | mutable, |
| 4372 | .tag = switch (size) { | 4378 | false, |
| 4373 | .One => if (mutable) T.single_mut_pointer else T.single_const_pointer, | 4379 | false, |
| 4374 | .Many => if (mutable) T.many_mut_pointer else T.many_const_pointer, | 4380 | size, |
| 4375 | .C => if (mutable) T.c_mut_pointer else T.c_const_pointer, | 4381 | ); |
| 4376 | .Slice => if (mutable) T.mut_slice else T.const_slice, | ||
| 4377 | }, | ||
| 4378 | }, | ||
| 4379 | .data = elem_ty, | ||
| 4380 | }; | ||
| 4381 | return Type.initPayload(&type_payload.base); | ||
| 4382 | } | 4382 | } |
| 4383 | 4383 | ||
| 4384 | pub fn ptrType( | 4384 | pub fn ptrType( |
| ... | @@ -4396,47 +4396,43 @@ pub fn ptrType( | ... | @@ -4396,47 +4396,43 @@ pub fn ptrType( |
| 4396 | ) Allocator.Error!Type { | 4396 | ) Allocator.Error!Type { |
| 4397 | assert(host_size == 0 or bit_offset < host_size * 8); | 4397 | assert(host_size == 0 or bit_offset < host_size * 8); |
| 4398 | 4398 | ||
| 4399 | // TODO check if type can be represented by simplePtrType | 4399 | if (sentinel != null or @"align" != 0 or @"addrspace" != .generic or |
| 4400 | return Type.Tag.pointer.create(arena, .{ | 4400 | bit_offset != 0 or host_size != 0 or @"allowzero" or @"volatile") |
| 4401 | .pointee_type = elem_ty, | 4401 | { |
| 4402 | .sentinel = sentinel, | 4402 | return Type.Tag.pointer.create(arena, .{ |
| 4403 | .@"align" = @"align", | 4403 | .pointee_type = elem_ty, |
| 4404 | .@"addrspace" = @"addrspace", | 4404 | .sentinel = sentinel, |
| 4405 | .bit_offset = bit_offset, | 4405 | .@"align" = @"align", |
| 4406 | .host_size = host_size, | 4406 | .@"addrspace" = @"addrspace", |
| 4407 | .@"allowzero" = @"allowzero", | 4407 | .bit_offset = bit_offset, |
| 4408 | .mutable = mutable, | 4408 | .host_size = host_size, |
| 4409 | .@"volatile" = @"volatile", | 4409 | .@"allowzero" = @"allowzero", |
| 4410 | .size = size, | 4410 | .mutable = mutable, |
| 4411 | }); | 4411 | .@"volatile" = @"volatile", |
| 4412 | } | 4412 | .size = size, |
| 4413 | }); | ||
| 4414 | } | ||
| 4413 | 4415 | ||
| 4414 | /// Create a pointer type with an explicit address space. This function might return results | 4416 | if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { |
| 4415 | /// of either simplePtrType or ptrType, depending on the address space. | 4417 | return Type.initTag(.const_slice_u8); |
| 4416 | /// TODO(Snektron) unify ptrType functions. | ||
| 4417 | pub fn simplePtrTypeWithAddressSpace( | ||
| 4418 | arena: *Allocator, | ||
| 4419 | elem_ty: Type, | ||
| 4420 | mutable: bool, | ||
| 4421 | size: std.builtin.TypeInfo.Pointer.Size, | ||
| 4422 | address_space: std.builtin.AddressSpace, | ||
| 4423 | ) Allocator.Error!Type { | ||
| 4424 | switch (address_space) { | ||
| 4425 | .generic => return simplePtrType(arena, elem_ty, mutable, size), | ||
| 4426 | else => return ptrType( | ||
| 4427 | arena, | ||
| 4428 | elem_ty, | ||
| 4429 | null, | ||
| 4430 | 0, | ||
| 4431 | address_space, | ||
| 4432 | 0, | ||
| 4433 | 0, | ||
| 4434 | mutable, | ||
| 4435 | false, | ||
| 4436 | false, | ||
| 4437 | size, | ||
| 4438 | ), | ||
| 4439 | } | 4418 | } |
| 4419 | |||
| 4420 | // TODO stage1 type inference bug | ||
| 4421 | const T = Type.Tag; | ||
| 4422 | |||
| 4423 | const type_payload = try arena.create(Type.Payload.ElemType); | ||
| 4424 | type_payload.* = .{ | ||
| 4425 | .base = .{ | ||
| 4426 | .tag = switch (size) { | ||
| 4427 | .One => if (mutable) T.single_mut_pointer else T.single_const_pointer, | ||
| 4428 | .Many => if (mutable) T.many_mut_pointer else T.many_const_pointer, | ||
| 4429 | .C => if (mutable) T.c_mut_pointer else T.c_const_pointer, | ||
| 4430 | .Slice => if (mutable) T.mut_slice else T.const_slice, | ||
| 4431 | }, | ||
| 4432 | }, | ||
| 4433 | .data = elem_ty, | ||
| 4434 | }; | ||
| 4435 | return Type.initPayload(&type_payload.base); | ||
| 4440 | } | 4436 | } |
| 4441 | 4437 | ||
| 4442 | pub fn optionalType(arena: *Allocator, child_type: Type) Allocator.Error!Type { | 4438 | pub fn optionalType(arena: *Allocator, child_type: Type) Allocator.Error!Type { |
src/Sema.zig+81-40| ... | @@ -1373,7 +1373,13 @@ fn zirRetPtr( | ... | @@ -1373,7 +1373,13 @@ fn zirRetPtr( |
| 1373 | return sema.analyzeComptimeAlloc(block, sema.fn_ret_ty); | 1373 | return sema.analyzeComptimeAlloc(block, sema.fn_ret_ty); |
| 1374 | } | 1374 | } |
| 1375 | 1375 | ||
| 1376 | const ptr_type = try Module.simplePtrType(sema.arena, sema.fn_ret_ty, true, .One); | 1376 | const ptr_type = try Module.simplePtrType( |
| 1377 | sema.arena, | ||
| 1378 | sema.fn_ret_ty, | ||
| 1379 | true, | ||
| 1380 | .One, | ||
| 1381 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1382 | ); | ||
| 1377 | return block.addTy(.alloc, ptr_type); | 1383 | return block.addTy(.alloc, ptr_type); |
| 1378 | } | 1384 | } |
| 1379 | 1385 | ||
| ... | @@ -1521,7 +1527,13 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError | ... | @@ -1521,7 +1527,13 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError |
| 1521 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 1527 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1522 | const var_decl_src = inst_data.src(); | 1528 | const var_decl_src = inst_data.src(); |
| 1523 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); | 1529 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); |
| 1524 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); | 1530 | const ptr_type = try Module.simplePtrType( |
| 1531 | sema.arena, | ||
| 1532 | var_type, | ||
| 1533 | true, | ||
| 1534 | .One, | ||
| 1535 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1536 | ); | ||
| 1525 | try sema.requireRuntimeBlock(block, var_decl_src); | 1537 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1526 | return block.addTy(.alloc, ptr_type); | 1538 | return block.addTy(.alloc, ptr_type); |
| 1527 | } | 1539 | } |
| ... | @@ -1538,7 +1550,13 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -1538,7 +1550,13 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 1538 | return sema.analyzeComptimeAlloc(block, var_type); | 1550 | return sema.analyzeComptimeAlloc(block, var_type); |
| 1539 | } | 1551 | } |
| 1540 | try sema.validateVarType(block, ty_src, var_type); | 1552 | try sema.validateVarType(block, ty_src, var_type); |
| 1541 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); | 1553 | const ptr_type = try Module.simplePtrType( |
| 1554 | sema.arena, | ||
| 1555 | var_type, | ||
| 1556 | true, | ||
| 1557 | .One, | ||
| 1558 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1559 | ); | ||
| 1542 | try sema.requireRuntimeBlock(block, var_decl_src); | 1560 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1543 | return block.addTy(.alloc, ptr_type); | 1561 | return block.addTy(.alloc, ptr_type); |
| 1544 | } | 1562 | } |
| ... | @@ -1598,7 +1616,13 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1598,7 +1616,13 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1598 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); | 1616 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); |
| 1599 | 1617 | ||
| 1600 | const final_elem_ty = try decl.ty.copy(sema.arena); | 1618 | const final_elem_ty = try decl.ty.copy(sema.arena); |
| 1601 | const final_ptr_ty = try Module.simplePtrType(sema.arena, final_elem_ty, true, .One); | 1619 | const final_ptr_ty = try Module.simplePtrType( |
| 1620 | sema.arena, | ||
| 1621 | final_elem_ty, | ||
| 1622 | true, | ||
| 1623 | .One, | ||
| 1624 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1625 | ); | ||
| 1602 | const final_ptr_ty_inst = try sema.addType(final_ptr_ty); | 1626 | const final_ptr_ty_inst = try sema.addType(final_ptr_ty); |
| 1603 | sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst; | 1627 | sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst; |
| 1604 | 1628 | ||
| ... | @@ -1620,7 +1644,13 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1620,7 +1644,13 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1620 | try sema.validateVarType(block, ty_src, final_elem_ty); | 1644 | try sema.validateVarType(block, ty_src, final_elem_ty); |
| 1621 | } | 1645 | } |
| 1622 | // Change it to a normal alloc. | 1646 | // Change it to a normal alloc. |
| 1623 | const final_ptr_ty = try Module.simplePtrType(sema.arena, final_elem_ty, true, .One); | 1647 | const final_ptr_ty = try Module.simplePtrType( |
| 1648 | sema.arena, | ||
| 1649 | final_elem_ty, | ||
| 1650 | true, | ||
| 1651 | .One, | ||
| 1652 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1653 | ); | ||
| 1624 | sema.air_instructions.set(ptr_inst, .{ | 1654 | sema.air_instructions.set(ptr_inst, .{ |
| 1625 | .tag = .alloc, | 1655 | .tag = .alloc, |
| 1626 | .data = .{ .ty = final_ptr_ty }, | 1656 | .data = .{ .ty = final_ptr_ty }, |
| ... | @@ -1774,7 +1804,14 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co | ... | @@ -1774,7 +1804,14 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 1774 | } | 1804 | } |
| 1775 | const ptr = sema.resolveInst(bin_inst.lhs); | 1805 | const ptr = sema.resolveInst(bin_inst.lhs); |
| 1776 | const value = sema.resolveInst(bin_inst.rhs); | 1806 | const value = sema.resolveInst(bin_inst.rhs); |
| 1777 | const ptr_ty = try Module.simplePtrType(sema.arena, sema.typeOf(value), true, .One); | 1807 | const ptr_ty = try Module.simplePtrType( |
| 1808 | sema.arena, | ||
| 1809 | sema.typeOf(value), | ||
| 1810 | true, | ||
| 1811 | .One, | ||
| 1812 | // TODO figure out which address space is appropriate here | ||
| 1813 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1814 | ); | ||
| 1778 | // TODO detect when this store should be done at compile-time. For example, | 1815 | // TODO detect when this store should be done at compile-time. For example, |
| 1779 | // if expressions should force it when the condition is compile-time known. | 1816 | // if expressions should force it when the condition is compile-time known. |
| 1780 | const src: LazySrcLoc = .unneeded; | 1817 | const src: LazySrcLoc = .unneeded; |
| ... | @@ -1821,7 +1858,14 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) | ... | @@ -1821,7 +1858,14 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 1821 | // for the inferred allocation. | 1858 | // for the inferred allocation. |
| 1822 | try inferred_alloc.data.stored_inst_list.append(sema.arena, operand); | 1859 | try inferred_alloc.data.stored_inst_list.append(sema.arena, operand); |
| 1823 | // Create a runtime bitcast instruction with exactly the type the pointer wants. | 1860 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 1824 | const ptr_ty = try Module.simplePtrType(sema.arena, operand_ty, true, .One); | 1861 | const ptr_ty = try Module.simplePtrType( |
| 1862 | sema.arena, | ||
| 1863 | operand_ty, | ||
| 1864 | true, | ||
| 1865 | .One, | ||
| 1866 | // TODO figure out which address space is appropriate here | ||
| 1867 | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), | ||
| 1868 | ); | ||
| 1825 | const bitcasted_ptr = try block.addTyOp(.bitcast, ptr_ty, ptr); | 1869 | const bitcasted_ptr = try block.addTyOp(.bitcast, ptr_ty, ptr); |
| 1826 | return sema.storePtr(block, src, bitcasted_ptr, operand); | 1870 | return sema.storePtr(block, src, bitcasted_ptr, operand); |
| 1827 | } | 1871 | } |
| ... | @@ -3658,7 +3702,7 @@ fn zirOptionalPayloadPtr( | ... | @@ -3658,7 +3702,7 @@ fn zirOptionalPayloadPtr( |
| 3658 | } | 3702 | } |
| 3659 | 3703 | ||
| 3660 | const child_type = try opt_type.optionalChildAlloc(sema.arena); | 3704 | const child_type = try opt_type.optionalChildAlloc(sema.arena); |
| 3661 | const child_pointer = try Module.simplePtrTypeWithAddressSpace( | 3705 | const child_pointer = try Module.simplePtrType( |
| 3662 | sema.arena, | 3706 | sema.arena, |
| 3663 | child_type, | 3707 | child_type, |
| 3664 | !optional_ptr_ty.isConstPtr(), | 3708 | !optional_ptr_ty.isConstPtr(), |
| ... | @@ -3779,7 +3823,7 @@ fn zirErrUnionPayloadPtr( | ... | @@ -3779,7 +3823,7 @@ fn zirErrUnionPayloadPtr( |
| 3779 | return sema.mod.fail(&block.base, src, "expected error union type, found {}", .{operand_ty.elemType()}); | 3823 | return sema.mod.fail(&block.base, src, "expected error union type, found {}", .{operand_ty.elemType()}); |
| 3780 | 3824 | ||
| 3781 | const payload_ty = operand_ty.elemType().errorUnionPayload(); | 3825 | const payload_ty = operand_ty.elemType().errorUnionPayload(); |
| 3782 | const operand_pointer_ty = try Module.simplePtrTypeWithAddressSpace( | 3826 | const operand_pointer_ty = try Module.simplePtrType( |
| 3783 | sema.arena, | 3827 | sema.arena, |
| 3784 | payload_ty, | 3828 | payload_ty, |
| 3785 | !operand_ty.isConstPtr(), | 3829 | !operand_ty.isConstPtr(), |
| ... | @@ -3907,7 +3951,6 @@ fn zirFunc( | ... | @@ -3907,7 +3951,6 @@ fn zirFunc( |
| 3907 | ret_ty_body, | 3951 | ret_ty_body, |
| 3908 | cc, | 3952 | cc, |
| 3909 | Value.initTag(.null_value), | 3953 | Value.initTag(.null_value), |
| 3910 | .generic, | ||
| 3911 | false, | 3954 | false, |
| 3912 | inferred_error_set, | 3955 | inferred_error_set, |
| 3913 | false, | 3956 | false, |
| ... | @@ -3924,7 +3967,6 @@ fn funcCommon( | ... | @@ -3924,7 +3967,6 @@ fn funcCommon( |
| 3924 | ret_ty_body: []const Zir.Inst.Index, | 3967 | ret_ty_body: []const Zir.Inst.Index, |
| 3925 | cc: std.builtin.CallingConvention, | 3968 | cc: std.builtin.CallingConvention, |
| 3926 | align_val: Value, | 3969 | align_val: Value, |
| 3927 | address_space: std.builtin.AddressSpace, | ||
| 3928 | var_args: bool, | 3970 | var_args: bool, |
| 3929 | inferred_error_set: bool, | 3971 | inferred_error_set: bool, |
| 3930 | is_extern: bool, | 3972 | is_extern: bool, |
| ... | @@ -3982,7 +4024,7 @@ fn funcCommon( | ... | @@ -3982,7 +4024,7 @@ fn funcCommon( |
| 3982 | // Hot path for some common function types. | 4024 | // Hot path for some common function types. |
| 3983 | // TODO can we eliminate some of these Type tag values? seems unnecessarily complicated. | 4025 | // TODO can we eliminate some of these Type tag values? seems unnecessarily complicated. |
| 3984 | if (!is_generic and block.params.items.len == 0 and !var_args and | 4026 | if (!is_generic and block.params.items.len == 0 and !var_args and |
| 3985 | align_val.tag() == .null_value and !inferred_error_set and address_space == .generic) | 4027 | align_val.tag() == .null_value and !inferred_error_set) |
| 3986 | { | 4028 | { |
| 3987 | if (bare_return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) { | 4029 | if (bare_return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) { |
| 3988 | break :fn_ty Type.initTag(.fn_noreturn_no_args); | 4030 | break :fn_ty Type.initTag(.fn_noreturn_no_args); |
| ... | @@ -4034,7 +4076,6 @@ fn funcCommon( | ... | @@ -4034,7 +4076,6 @@ fn funcCommon( |
| 4034 | .comptime_params = comptime_params.ptr, | 4076 | .comptime_params = comptime_params.ptr, |
| 4035 | .return_type = return_type, | 4077 | .return_type = return_type, |
| 4036 | .cc = cc, | 4078 | .cc = cc, |
| 4037 | .@"addrspace" = address_space, | ||
| 4038 | .is_var_args = var_args, | 4079 | .is_var_args = var_args, |
| 4039 | .is_generic = is_generic, | 4080 | .is_generic = is_generic, |
| 4040 | }); | 4081 | }); |
| ... | @@ -6413,7 +6454,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -6413,7 +6454,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 6413 | 6454 | ||
| 6414 | switch (ty.zigTypeTag()) { | 6455 | switch (ty.zigTypeTag()) { |
| 6415 | .Fn => { | 6456 | .Fn => { |
| 6416 | const field_values = try sema.arena.alloc(Value, 7); | 6457 | const field_values = try sema.arena.alloc(Value, 6); |
| 6417 | // calling_convention: CallingConvention, | 6458 | // calling_convention: CallingConvention, |
| 6418 | field_values[0] = try Value.Tag.enum_field_index.create( | 6459 | field_values[0] = try Value.Tag.enum_field_index.create( |
| 6419 | sema.arena, | 6460 | sema.arena, |
| ... | @@ -6421,19 +6462,14 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -6421,19 +6462,14 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 6421 | ); | 6462 | ); |
| 6422 | // alignment: comptime_int, | 6463 | // alignment: comptime_int, |
| 6423 | field_values[1] = try Value.Tag.int_u64.create(sema.arena, ty.abiAlignment(target)); | 6464 | field_values[1] = try Value.Tag.int_u64.create(sema.arena, ty.abiAlignment(target)); |
| 6424 | // address_space: AddressSpace, | ||
| 6425 | field_values[2] = try Value.Tag.enum_field_index.create( | ||
| 6426 | sema.arena, | ||
| 6427 | @enumToInt(ty.fnAddressSpace()), | ||
| 6428 | ); | ||
| 6429 | // is_generic: bool, | 6465 | // is_generic: bool, |
| 6430 | field_values[3] = Value.initTag(.bool_false); // TODO | 6466 | field_values[2] = Value.initTag(.bool_false); // TODO |
| 6431 | // is_var_args: bool, | 6467 | // is_var_args: bool, |
| 6432 | field_values[4] = Value.initTag(.bool_false); // TODO | 6468 | field_values[3] = Value.initTag(.bool_false); // TODO |
| 6433 | // return_type: ?type, | 6469 | // return_type: ?type, |
| 6434 | field_values[5] = try Value.Tag.ty.create(sema.arena, ty.fnReturnType()); | 6470 | field_values[4] = try Value.Tag.ty.create(sema.arena, ty.fnReturnType()); |
| 6435 | // args: []const FnArg, | 6471 | // args: []const FnArg, |
| 6436 | field_values[6] = Value.initTag(.null_value); // TODO | 6472 | field_values[5] = Value.initTag(.null_value); // TODO |
| 6437 | 6473 | ||
| 6438 | return sema.addConstant( | 6474 | return sema.addConstant( |
| 6439 | type_info_ty, | 6475 | type_info_ty, |
| ... | @@ -8063,7 +8099,6 @@ fn zirFuncExtended( | ... | @@ -8063,7 +8099,6 @@ fn zirFuncExtended( |
| 8063 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; | 8099 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 8064 | const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = extra.data.src_node }; | 8100 | const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = extra.data.src_node }; |
| 8065 | const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align | 8101 | const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align |
| 8066 | const addrspace_src: LazySrcLoc = src; // TODO(Snektron) add a LazySrcLoc that points at addrspace | ||
| 8067 | const small = @bitCast(Zir.Inst.ExtendedFunc.Small, extended.small); | 8102 | const small = @bitCast(Zir.Inst.ExtendedFunc.Small, extended.small); |
| 8068 | 8103 | ||
| 8069 | var extra_index: usize = extra.end; | 8104 | var extra_index: usize = extra.end; |
| ... | @@ -8088,12 +8123,6 @@ fn zirFuncExtended( | ... | @@ -8088,12 +8123,6 @@ fn zirFuncExtended( |
| 8088 | break :blk align_tv.val; | 8123 | break :blk align_tv.val; |
| 8089 | } else Value.initTag(.null_value); | 8124 | } else Value.initTag(.null_value); |
| 8090 | 8125 | ||
| 8091 | const address_space: std.builtin.AddressSpace = if (small.has_addrspace) blk: { | ||
| 8092 | const addrspace_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | ||
| 8093 | extra_index += 1; | ||
| 8094 | break :blk try sema.analyzeAddrspace(block, addrspace_src, addrspace_ref, .function); | ||
| 8095 | } else .generic; | ||
| 8096 | |||
| 8097 | const ret_ty_body = sema.code.extra[extra_index..][0..extra.data.ret_body_len]; | 8126 | const ret_ty_body = sema.code.extra[extra_index..][0..extra.data.ret_body_len]; |
| 8098 | extra_index += ret_ty_body.len; | 8127 | extra_index += ret_ty_body.len; |
| 8099 | 8128 | ||
| ... | @@ -8116,7 +8145,6 @@ fn zirFuncExtended( | ... | @@ -8116,7 +8145,6 @@ fn zirFuncExtended( |
| 8116 | ret_ty_body, | 8145 | ret_ty_body, |
| 8117 | cc, | 8146 | cc, |
| 8118 | align_val, | 8147 | align_val, |
| 8119 | address_space, | ||
| 8120 | is_var_args, | 8148 | is_var_args, |
| 8121 | is_inferred_error, | 8149 | is_inferred_error, |
| 8122 | is_extern, | 8150 | is_extern, |
| ... | @@ -8309,7 +8337,13 @@ fn panicWithMsg( | ... | @@ -8309,7 +8337,13 @@ fn panicWithMsg( |
| 8309 | const panic_fn = try sema.getBuiltin(block, src, "panic"); | 8337 | const panic_fn = try sema.getBuiltin(block, src, "panic"); |
| 8310 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); | 8338 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); |
| 8311 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); | 8339 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); |
| 8312 | const ptr_stack_trace_ty = try Module.simplePtrType(arena, stack_trace_ty, true, .One); | 8340 | const ptr_stack_trace_ty = try Module.simplePtrType( |
| 8341 | arena, | ||
| 8342 | stack_trace_ty, | ||
| 8343 | true, | ||
| 8344 | .One, | ||
| 8345 | target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), // TODO might need a place that is more dynamic | ||
| 8346 | ); | ||
| 8313 | const null_stack_trace = try sema.addConstant( | 8347 | const null_stack_trace = try sema.addConstant( |
| 8314 | try Module.optionalType(arena, ptr_stack_trace_ty), | 8348 | try Module.optionalType(arena, ptr_stack_trace_ty), |
| 8315 | Value.initTag(.null_value), | 8349 | Value.initTag(.null_value), |
| ... | @@ -8788,7 +8822,7 @@ fn structFieldPtr( | ... | @@ -8788,7 +8822,7 @@ fn structFieldPtr( |
| 8788 | const field_index = struct_obj.fields.getIndex(field_name) orelse | 8822 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 8789 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); | 8823 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); |
| 8790 | const field = struct_obj.fields.values()[field_index]; | 8824 | const field = struct_obj.fields.values()[field_index]; |
| 8791 | const ptr_field_ty = try Module.simplePtrTypeWithAddressSpace( | 8825 | const ptr_field_ty = try Module.simplePtrType( |
| 8792 | arena, | 8826 | arena, |
| 8793 | field.ty, | 8827 | field.ty, |
| 8794 | struct_ptr_ty.ptrIsMutable(), | 8828 | struct_ptr_ty.ptrIsMutable(), |
| ... | @@ -8893,7 +8927,7 @@ fn unionFieldPtr( | ... | @@ -8893,7 +8927,7 @@ fn unionFieldPtr( |
| 8893 | return sema.failWithBadUnionFieldAccess(block, union_obj, field_name_src, field_name); | 8927 | return sema.failWithBadUnionFieldAccess(block, union_obj, field_name_src, field_name); |
| 8894 | 8928 | ||
| 8895 | const field = union_obj.fields.values()[field_index]; | 8929 | const field = union_obj.fields.values()[field_index]; |
| 8896 | const ptr_field_ty = try Module.simplePtrTypeWithAddressSpace( | 8930 | const ptr_field_ty = try Module.simplePtrType( |
| 8897 | arena, | 8931 | arena, |
| 8898 | field.ty, | 8932 | field.ty, |
| 8899 | union_ptr_ty.ptrIsMutable(), | 8933 | union_ptr_ty.ptrIsMutable(), |
| ... | @@ -9075,7 +9109,7 @@ fn elemPtrArray( | ... | @@ -9075,7 +9109,7 @@ fn elemPtrArray( |
| 9075 | ) CompileError!Air.Inst.Ref { | 9109 | ) CompileError!Air.Inst.Ref { |
| 9076 | const array_ptr_ty = sema.typeOf(array_ptr); | 9110 | const array_ptr_ty = sema.typeOf(array_ptr); |
| 9077 | const pointee_type = array_ptr_ty.elemType().elemType(); | 9111 | const pointee_type = array_ptr_ty.elemType().elemType(); |
| 9078 | const result_ty = try Module.simplePtrTypeWithAddressSpace( | 9112 | const result_ty = try Module.simplePtrType( |
| 9079 | sema.arena, | 9113 | sema.arena, |
| 9080 | pointee_type, | 9114 | pointee_type, |
| 9081 | array_ptr_ty.ptrIsMutable(), | 9115 | array_ptr_ty.ptrIsMutable(), |
| ... | @@ -9581,11 +9615,11 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref { | ... | @@ -9581,11 +9615,11 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref { |
| 9581 | const decl_tv = try decl.typedValue(); | 9615 | const decl_tv = try decl.typedValue(); |
| 9582 | if (decl_tv.val.castTag(.variable)) |payload| { | 9616 | if (decl_tv.val.castTag(.variable)) |payload| { |
| 9583 | const variable = payload.data; | 9617 | const variable = payload.data; |
| 9584 | const ty = try Module.simplePtrTypeWithAddressSpace(sema.arena, decl_tv.ty, variable.is_mutable, .One, decl.@"addrspace"); | 9618 | const ty = try Module.simplePtrType(sema.arena, decl_tv.ty, variable.is_mutable, .One, decl.@"addrspace"); |
| 9585 | return sema.addConstant(ty, try Value.Tag.decl_ref.create(sema.arena, decl)); | 9619 | return sema.addConstant(ty, try Value.Tag.decl_ref.create(sema.arena, decl)); |
| 9586 | } | 9620 | } |
| 9587 | return sema.addConstant( | 9621 | return sema.addConstant( |
| 9588 | try Module.simplePtrTypeWithAddressSpace(sema.arena, decl_tv.ty, false, .One, decl.@"addrspace"), | 9622 | try Module.simplePtrType(sema.arena, decl_tv.ty, false, .One, decl.@"addrspace"), |
| 9589 | try Value.Tag.decl_ref.create(sema.arena, decl), | 9623 | try Value.Tag.decl_ref.create(sema.arena, decl), |
| 9590 | ); | 9624 | ); |
| 9591 | } | 9625 | } |
| ... | @@ -9608,8 +9642,9 @@ fn analyzeRef( | ... | @@ -9608,8 +9642,9 @@ fn analyzeRef( |
| 9608 | } | 9642 | } |
| 9609 | 9643 | ||
| 9610 | try sema.requireRuntimeBlock(block, src); | 9644 | try sema.requireRuntimeBlock(block, src); |
| 9611 | const ptr_type = try Module.simplePtrType(sema.arena, operand_ty, false, .One); | 9645 | const address_space = target_util.defaultAddressSpace(sema.mod.getTarget(), .local); |
| 9612 | const mut_ptr_type = try Module.simplePtrType(sema.arena, operand_ty, true, .One); | 9646 | const ptr_type = try Module.simplePtrType(sema.arena, operand_ty, false, .One, address_space); |
| 9647 | const mut_ptr_type = try Module.simplePtrType(sema.arena, operand_ty, true, .One, address_space); | ||
| 9613 | const alloc = try block.addTy(.alloc, mut_ptr_type); | 9648 | const alloc = try block.addTy(.alloc, mut_ptr_type); |
| 9614 | try sema.storePtr(block, src, alloc, operand); | 9649 | try sema.storePtr(block, src, alloc, operand); |
| 9615 | 9650 | ||
| ... | @@ -10955,7 +10990,13 @@ fn analyzeComptimeAlloc( | ... | @@ -10955,7 +10990,13 @@ fn analyzeComptimeAlloc( |
| 10955 | block: *Scope.Block, | 10990 | block: *Scope.Block, |
| 10956 | var_type: Type, | 10991 | var_type: Type, |
| 10957 | ) CompileError!Air.Inst.Ref { | 10992 | ) CompileError!Air.Inst.Ref { |
| 10958 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); | 10993 | const ptr_type = try Module.simplePtrType( |
| 10994 | sema.arena, | ||
| 10995 | var_type, | ||
| 10996 | true, | ||
| 10997 | .One, | ||
| 10998 | target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), | ||
| 10999 | ); | ||
| 10959 | 11000 | ||
| 10960 | var anon_decl = try block.startAnonDecl(); | 11001 | var anon_decl = try block.startAnonDecl(); |
| 10961 | defer anon_decl.deinit(); | 11002 | defer anon_decl.deinit(); |
src/Zir.zig+1-14| ... | @@ -2309,7 +2309,6 @@ pub const Inst = struct { | ... | @@ -2309,7 +2309,6 @@ pub const Inst = struct { |
| 2309 | /// 0. lib_name: u32, // null terminated string index, if has_lib_name is set | 2309 | /// 0. lib_name: u32, // null terminated string index, if has_lib_name is set |
| 2310 | /// 1. cc: Ref, // if has_cc is set | 2310 | /// 1. cc: Ref, // if has_cc is set |
| 2311 | /// 2. align: Ref, // if has_align is set | 2311 | /// 2. align: Ref, // if has_align is set |
| 2312 | /// 3. addrspace: Ref, // if has_addrspace is set | ||
| 2313 | /// 3. return_type: Index // for each ret_body_len | 2312 | /// 3. return_type: Index // for each ret_body_len |
| 2314 | /// 4. body: Index // for each body_len | 2313 | /// 4. body: Index // for each body_len |
| 2315 | /// 5. src_locs: Func.SrcLocs // if body_len != 0 | 2314 | /// 5. src_locs: Func.SrcLocs // if body_len != 0 |
| ... | @@ -2327,10 +2326,9 @@ pub const Inst = struct { | ... | @@ -2327,10 +2326,9 @@ pub const Inst = struct { |
| 2327 | has_lib_name: bool, | 2326 | has_lib_name: bool, |
| 2328 | has_cc: bool, | 2327 | has_cc: bool, |
| 2329 | has_align: bool, | 2328 | has_align: bool, |
| 2330 | has_addrspace: bool, | ||
| 2331 | is_test: bool, | 2329 | is_test: bool, |
| 2332 | is_extern: bool, | 2330 | is_extern: bool, |
| 2333 | _: u8 = undefined, | 2331 | _: u9 = undefined, |
| 2334 | }; | 2332 | }; |
| 2335 | }; | 2333 | }; |
| 2336 | 2334 | ||
| ... | @@ -4483,7 +4481,6 @@ const Writer = struct { | ... | @@ -4483,7 +4481,6 @@ const Writer = struct { |
| 4483 | false, | 4481 | false, |
| 4484 | .none, | 4482 | .none, |
| 4485 | .none, | 4483 | .none, |
| 4486 | .none, | ||
| 4487 | body, | 4484 | body, |
| 4488 | src, | 4485 | src, |
| 4489 | src_locs, | 4486 | src_locs, |
| ... | @@ -4512,11 +4509,6 @@ const Writer = struct { | ... | @@ -4512,11 +4509,6 @@ const Writer = struct { |
| 4512 | extra_index += 1; | 4509 | extra_index += 1; |
| 4513 | break :blk align_inst; | 4510 | break :blk align_inst; |
| 4514 | }; | 4511 | }; |
| 4515 | const addrspace_inst: Inst.Ref = if (!small.has_addrspace) .none else blk: { | ||
| 4516 | const addrspace_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); | ||
| 4517 | extra_index += 1; | ||
| 4518 | break :blk addrspace_inst; | ||
| 4519 | }; | ||
| 4520 | 4512 | ||
| 4521 | const ret_ty_body = self.code.extra[extra_index..][0..extra.data.ret_body_len]; | 4513 | const ret_ty_body = self.code.extra[extra_index..][0..extra.data.ret_body_len]; |
| 4522 | extra_index += ret_ty_body.len; | 4514 | extra_index += ret_ty_body.len; |
| ... | @@ -4536,7 +4528,6 @@ const Writer = struct { | ... | @@ -4536,7 +4528,6 @@ const Writer = struct { |
| 4536 | small.is_extern, | 4528 | small.is_extern, |
| 4537 | cc, | 4529 | cc, |
| 4538 | align_inst, | 4530 | align_inst, |
| 4539 | addrspace_inst, | ||
| 4540 | body, | 4531 | body, |
| 4541 | src, | 4532 | src, |
| 4542 | src_locs, | 4533 | src_locs, |
| ... | @@ -4619,7 +4610,6 @@ const Writer = struct { | ... | @@ -4619,7 +4610,6 @@ const Writer = struct { |
| 4619 | is_extern: bool, | 4610 | is_extern: bool, |
| 4620 | cc: Inst.Ref, | 4611 | cc: Inst.Ref, |
| 4621 | align_inst: Inst.Ref, | 4612 | align_inst: Inst.Ref, |
| 4622 | addrspace_inst: Inst.Ref, | ||
| 4623 | body: []const Inst.Index, | 4613 | body: []const Inst.Index, |
| 4624 | src: LazySrcLoc, | 4614 | src: LazySrcLoc, |
| 4625 | src_locs: Zir.Inst.Func.SrcLocs, | 4615 | src_locs: Zir.Inst.Func.SrcLocs, |
| ... | @@ -4637,7 +4627,6 @@ const Writer = struct { | ... | @@ -4637,7 +4627,6 @@ const Writer = struct { |
| 4637 | 4627 | ||
| 4638 | try self.writeOptionalInstRef(stream, ", cc=", cc); | 4628 | try self.writeOptionalInstRef(stream, ", cc=", cc); |
| 4639 | try self.writeOptionalInstRef(stream, ", align=", align_inst); | 4629 | try self.writeOptionalInstRef(stream, ", align=", align_inst); |
| 4640 | try self.writeOptionalInstRef(stream, ", addrspace=", addrspace_inst); | ||
| 4641 | try self.writeFlag(stream, ", vargs", var_args); | 4630 | try self.writeFlag(stream, ", vargs", var_args); |
| 4642 | try self.writeFlag(stream, ", extern", is_extern); | 4631 | try self.writeFlag(stream, ", extern", is_extern); |
| 4643 | try self.writeFlag(stream, ", inferror", inferred_error_set); | 4632 | try self.writeFlag(stream, ", inferror", inferred_error_set); |
| ... | @@ -4915,7 +4904,6 @@ fn findDeclsInner( | ... | @@ -4915,7 +4904,6 @@ fn findDeclsInner( |
| 4915 | extra_index += @boolToInt(small.has_lib_name); | 4904 | extra_index += @boolToInt(small.has_lib_name); |
| 4916 | extra_index += @boolToInt(small.has_cc); | 4905 | extra_index += @boolToInt(small.has_cc); |
| 4917 | extra_index += @boolToInt(small.has_align); | 4906 | extra_index += @boolToInt(small.has_align); |
| 4918 | extra_index += @boolToInt(small.has_addrspace); | ||
| 4919 | const body = zir.extra[extra_index..][0..extra.data.body_len]; | 4907 | const body = zir.extra[extra_index..][0..extra.data.body_len]; |
| 4920 | return zir.findDeclsBody(list, body); | 4908 | return zir.findDeclsBody(list, body); |
| 4921 | }, | 4909 | }, |
| ... | @@ -5119,7 +5107,6 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { | ... | @@ -5119,7 +5107,6 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { |
| 5119 | extra_index += @boolToInt(small.has_lib_name); | 5107 | extra_index += @boolToInt(small.has_lib_name); |
| 5120 | extra_index += @boolToInt(small.has_cc); | 5108 | extra_index += @boolToInt(small.has_cc); |
| 5121 | extra_index += @boolToInt(small.has_align); | 5109 | extra_index += @boolToInt(small.has_align); |
| 5122 | extra_index += @boolToInt(small.has_addrspace); | ||
| 5123 | const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len]; | 5110 | const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len]; |
| 5124 | extra_index += ret_ty_body.len; | 5111 | extra_index += ret_ty_body.len; |
| 5125 | const body = zir.extra[extra_index..][0..extra.data.body_len]; | 5112 | const body = zir.extra[extra_index..][0..extra.data.body_len]; |
src/codegen/llvm.zig+2-1| ... | @@ -700,7 +700,8 @@ pub const DeclGen = struct { | ... | @@ -700,7 +700,8 @@ pub const DeclGen = struct { |
| 700 | @intCast(c_uint, llvm_params.len), | 700 | @intCast(c_uint, llvm_params.len), |
| 701 | llvm.Bool.fromBool(is_var_args), | 701 | llvm.Bool.fromBool(is_var_args), |
| 702 | ); | 702 | ); |
| 703 | const llvm_addrspace = self.llvmAddressSpace(t.fnAddressSpace()); | 703 | // TODO make .Fn not both a pointer type and a prototype |
| 704 | const llvm_addrspace = self.llvmAddressSpace(.generic); | ||
| 704 | return llvm_fn_ty.pointerType(llvm_addrspace); | 705 | return llvm_fn_ty.pointerType(llvm_addrspace); |
| 705 | }, | 706 | }, |
| 706 | .ComptimeInt => unreachable, | 707 | .ComptimeInt => unreachable, |
src/stage1/ir.cpp+18-36| ... | @@ -18483,35 +18483,30 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour | ... | @@ -18483,35 +18483,30 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 18483 | fields[1]->special = ConstValSpecialStatic; | 18483 | fields[1]->special = ConstValSpecialStatic; |
| 18484 | fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; | 18484 | fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 18485 | bigint_init_unsigned(&fields[1]->data.x_bigint, get_ptr_align(ira->codegen, type_entry)); | 18485 | bigint_init_unsigned(&fields[1]->data.x_bigint, get_ptr_align(ira->codegen, type_entry)); |
| 18486 | // address_space: AddressSpace | ||
| 18487 | ensure_field_index(result->type, "address_space", 2); | ||
| 18488 | fields[2]->special = ConstValSpecialStatic; | ||
| 18489 | fields[2]->type = get_builtin_type(ira->codegen, "AddressSpace"); | ||
| 18490 | bigint_init_unsigned(&fields[2]->data.x_enum_tag, AddressSpaceGeneric); | ||
| 18491 | // is_generic: bool | 18486 | // is_generic: bool |
| 18492 | ensure_field_index(result->type, "is_generic", 3); | 18487 | ensure_field_index(result->type, "is_generic", 2); |
| 18493 | bool is_generic = type_entry->data.fn.is_generic; | 18488 | bool is_generic = type_entry->data.fn.is_generic; |
| 18494 | fields[3]->special = ConstValSpecialStatic; | 18489 | fields[2]->special = ConstValSpecialStatic; |
| 18495 | fields[3]->type = ira->codegen->builtin_types.entry_bool; | 18490 | fields[2]->type = ira->codegen->builtin_types.entry_bool; |
| 18496 | fields[3]->data.x_bool = is_generic; | 18491 | fields[2]->data.x_bool = is_generic; |
| 18497 | // is_varargs: bool | 18492 | // is_varargs: bool |
| 18498 | ensure_field_index(result->type, "is_var_args", 4); | 18493 | ensure_field_index(result->type, "is_var_args", 3); |
| 18499 | bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args; | 18494 | bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args; |
| 18500 | fields[4]->special = ConstValSpecialStatic; | 18495 | fields[3]->special = ConstValSpecialStatic; |
| 18501 | fields[4]->type = ira->codegen->builtin_types.entry_bool; | 18496 | fields[3]->type = ira->codegen->builtin_types.entry_bool; |
| 18502 | fields[4]->data.x_bool = is_varargs; | 18497 | fields[3]->data.x_bool = is_varargs; |
| 18503 | // return_type: ?type | 18498 | // return_type: ?type |
| 18504 | ensure_field_index(result->type, "return_type", 5); | 18499 | ensure_field_index(result->type, "return_type", 4); |
| 18505 | fields[5]->special = ConstValSpecialStatic; | 18500 | fields[4]->special = ConstValSpecialStatic; |
| 18506 | fields[5]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); | 18501 | fields[4]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 18507 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) | 18502 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 18508 | fields[5]->data.x_optional = nullptr; | 18503 | fields[4]->data.x_optional = nullptr; |
| 18509 | else { | 18504 | else { |
| 18510 | ZigValue *return_type = ira->codegen->pass1_arena->create<ZigValue>(); | 18505 | ZigValue *return_type = ira->codegen->pass1_arena->create<ZigValue>(); |
| 18511 | return_type->special = ConstValSpecialStatic; | 18506 | return_type->special = ConstValSpecialStatic; |
| 18512 | return_type->type = ira->codegen->builtin_types.entry_type; | 18507 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 18513 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; | 18508 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| 18514 | fields[5]->data.x_optional = return_type; | 18509 | fields[4]->data.x_optional = return_type; |
| 18515 | } | 18510 | } |
| 18516 | // args: []TypeInfo.FnArg | 18511 | // args: []TypeInfo.FnArg |
| 18517 | ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr); | 18512 | ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr); |
| ... | @@ -18526,7 +18521,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour | ... | @@ -18526,7 +18521,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour |
| 18526 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; | 18521 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; |
| 18527 | fn_arg_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); | 18522 | fn_arg_array->data.x_array.data.s_none.elements = ira->codegen->pass1_arena->allocate<ZigValue>(fn_arg_count); |
| 18528 | 18523 | ||
| 18529 | init_const_slice(ira->codegen, fields[6], fn_arg_array, 0, fn_arg_count, false, nullptr); | 18524 | init_const_slice(ira->codegen, fields[5], fn_arg_array, 0, fn_arg_count, false, nullptr); |
| 18530 | 18525 | ||
| 18531 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 18526 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { |
| 18532 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; | 18527 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; |
| ... | @@ -19330,22 +19325,9 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ | ... | @@ -19330,22 +19325,9 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 19330 | if (alignment == nullptr) | 19325 | if (alignment == nullptr) |
| 19331 | return ira->codegen->invalid_inst_gen->value->type; | 19326 | return ira->codegen->invalid_inst_gen->value->type; |
| 19332 | 19327 | ||
| 19333 | ZigValue *as_value = get_const_field(ira, source_node, payload, "address_space", 2); | ||
| 19334 | if (as_value == nullptr) | ||
| 19335 | return ira->codegen->invalid_inst_gen->value->type; | ||
| 19336 | assert(as_value->special == ConstValSpecialStatic); | ||
| 19337 | assert(as_value->type == get_builtin_type(ira->codegen, "AddressSpace")); | ||
| 19338 | AddressSpace as = (AddressSpace)bigint_as_u32(&as_value->data.x_enum_tag); | ||
| 19339 | if (as != AddressSpaceGeneric) { | ||
| 19340 | ir_add_error_node(ira, source_node, buf_sprintf( | ||
| 19341 | "address space '%s' not available in stage 1 compiler, must be .generic", | ||
| 19342 | address_space_name(as))); | ||
| 19343 | return ira->codegen->invalid_inst_gen->value->type; | ||
| 19344 | } | ||
| 19345 | |||
| 19346 | Error err; | 19328 | Error err; |
| 19347 | bool is_generic; | 19329 | bool is_generic; |
| 19348 | if ((err = get_const_field_bool(ira, source_node, payload, "is_generic", 3, &is_generic))) | 19330 | if ((err = get_const_field_bool(ira, source_node, payload, "is_generic", 2, &is_generic))) |
| 19349 | return ira->codegen->invalid_inst_gen->value->type; | 19331 | return ira->codegen->invalid_inst_gen->value->type; |
| 19350 | if (is_generic) { | 19332 | if (is_generic) { |
| 19351 | ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.is_generic must be false for @Type")); | 19333 | ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.is_generic must be false for @Type")); |
| ... | @@ -19353,20 +19335,20 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ | ... | @@ -19353,20 +19335,20 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_ |
| 19353 | } | 19335 | } |
| 19354 | 19336 | ||
| 19355 | bool is_var_args; | 19337 | bool is_var_args; |
| 19356 | if ((err = get_const_field_bool(ira, source_node, payload, "is_var_args", 4, &is_var_args))) | 19338 | if ((err = get_const_field_bool(ira, source_node, payload, "is_var_args", 3, &is_var_args))) |
| 19357 | return ira->codegen->invalid_inst_gen->value->type; | 19339 | return ira->codegen->invalid_inst_gen->value->type; |
| 19358 | if (is_var_args && cc != CallingConventionC) { | 19340 | if (is_var_args && cc != CallingConventionC) { |
| 19359 | ir_add_error_node(ira, source_node, buf_sprintf("varargs functions must have C calling convention")); | 19341 | ir_add_error_node(ira, source_node, buf_sprintf("varargs functions must have C calling convention")); |
| 19360 | return ira->codegen->invalid_inst_gen->value->type; | 19342 | return ira->codegen->invalid_inst_gen->value->type; |
| 19361 | } | 19343 | } |
| 19362 | 19344 | ||
| 19363 | ZigType *return_type = get_const_field_meta_type_optional(ira, source_node, payload, "return_type", 5); | 19345 | ZigType *return_type = get_const_field_meta_type_optional(ira, source_node, payload, "return_type", 4); |
| 19364 | if (return_type == nullptr) { | 19346 | if (return_type == nullptr) { |
| 19365 | ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.return_type must be non-null for @Type")); | 19347 | ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.return_type must be non-null for @Type")); |
| 19366 | return ira->codegen->invalid_inst_gen->value->type; | 19348 | return ira->codegen->invalid_inst_gen->value->type; |
| 19367 | } | 19349 | } |
| 19368 | 19350 | ||
| 19369 | ZigValue *args_value = get_const_field(ira, source_node, payload, "args", 6); | 19351 | ZigValue *args_value = get_const_field(ira, source_node, payload, "args", 5); |
| 19370 | if (args_value == nullptr) | 19352 | if (args_value == nullptr) |
| 19371 | return ira->codegen->invalid_inst_gen->value->type; | 19353 | return ira->codegen->invalid_inst_gen->value->type; |
| 19372 | assert(args_value->special == ConstValSpecialStatic); | 19354 | assert(args_value->special == ConstValSpecialStatic); |
src/target.zig+18| ... | @@ -544,3 +544,21 @@ pub fn largestAtomicBits(target: std.Target) u32 { | ... | @@ -544,3 +544,21 @@ pub fn largestAtomicBits(target: std.Target) u32 { |
| 544 | .x86_64 => 128, | 544 | .x86_64 => 128, |
| 545 | }; | 545 | }; |
| 546 | } | 546 | } |
| 547 | |||
| 548 | pub fn defaultAddressSpace( | ||
| 549 | target: std.Target, | ||
| 550 | context: enum { | ||
| 551 | /// Query the default address space for global constant values. | ||
| 552 | global_constant, | ||
| 553 | /// Query the default address space for global mutable values. | ||
| 554 | global_mutable, | ||
| 555 | /// Query the default address space for function-local values. | ||
| 556 | local, | ||
| 557 | /// Query the default address space for functions themselves. | ||
| 558 | function, | ||
| 559 | }, | ||
| 560 | ) std.builtin.AddressSpace { | ||
| 561 | _ = target; | ||
| 562 | _ = context; | ||
| 563 | return .generic; | ||
| 564 | } |
src/type.zig-23| ... | @@ -530,8 +530,6 @@ pub const Type = extern union { | ... | @@ -530,8 +530,6 @@ pub const Type = extern union { |
| 530 | return false; | 530 | return false; |
| 531 | if (a.fnCallingConvention() != b.fnCallingConvention()) | 531 | if (a.fnCallingConvention() != b.fnCallingConvention()) |
| 532 | return false; | 532 | return false; |
| 533 | if (a.fnAddressSpace() != b.fnAddressSpace()) | ||
| 534 | return false; | ||
| 535 | const a_param_len = a.fnParamLen(); | 533 | const a_param_len = a.fnParamLen(); |
| 536 | const b_param_len = b.fnParamLen(); | 534 | const b_param_len = b.fnParamLen(); |
| 537 | if (a_param_len != b_param_len) | 535 | if (a_param_len != b_param_len) |
| ... | @@ -838,7 +836,6 @@ pub const Type = extern union { | ... | @@ -838,7 +836,6 @@ pub const Type = extern union { |
| 838 | .return_type = try payload.return_type.copy(allocator), | 836 | .return_type = try payload.return_type.copy(allocator), |
| 839 | .param_types = param_types, | 837 | .param_types = param_types, |
| 840 | .cc = payload.cc, | 838 | .cc = payload.cc, |
| 841 | .@"addrspace" = payload.@"addrspace", | ||
| 842 | .is_var_args = payload.is_var_args, | 839 | .is_var_args = payload.is_var_args, |
| 843 | .is_generic = payload.is_generic, | 840 | .is_generic = payload.is_generic, |
| 844 | .comptime_params = comptime_params.ptr, | 841 | .comptime_params = comptime_params.ptr, |
| ... | @@ -1001,9 +998,6 @@ pub const Type = extern union { | ... | @@ -1001,9 +998,6 @@ pub const Type = extern union { |
| 1001 | try writer.writeAll(") callconv(."); | 998 | try writer.writeAll(") callconv(."); |
| 1002 | try writer.writeAll(@tagName(payload.cc)); | 999 | try writer.writeAll(@tagName(payload.cc)); |
| 1003 | try writer.writeAll(") "); | 1000 | try writer.writeAll(") "); |
| 1004 | if (payload.@"addrspace" != .generic) { | ||
| 1005 | try writer.print("addrspace(.{s}) ", .{@tagName(payload.@"addrspace")}); | ||
| 1006 | } | ||
| 1007 | ty = payload.return_type; | 1001 | ty = payload.return_type; |
| 1008 | continue; | 1002 | continue; |
| 1009 | }, | 1003 | }, |
| ... | @@ -2730,18 +2724,6 @@ pub const Type = extern union { | ... | @@ -2730,18 +2724,6 @@ pub const Type = extern union { |
| 2730 | }; | 2724 | }; |
| 2731 | } | 2725 | } |
| 2732 | 2726 | ||
| 2733 | pub fn fnAddressSpace(self: Type) std.builtin.AddressSpace { | ||
| 2734 | return switch (self.tag()) { | ||
| 2735 | .fn_noreturn_no_args => .generic, | ||
| 2736 | .fn_void_no_args => .generic, | ||
| 2737 | .fn_naked_noreturn_no_args => .generic, | ||
| 2738 | .fn_ccc_void_no_args => .generic, | ||
| 2739 | .function => self.castTag(.function).?.data.@"addrspace", | ||
| 2740 | |||
| 2741 | else => unreachable, | ||
| 2742 | }; | ||
| 2743 | } | ||
| 2744 | |||
| 2745 | pub fn fnInfo(ty: Type) Payload.Function.Data { | 2727 | pub fn fnInfo(ty: Type) Payload.Function.Data { |
| 2746 | return switch (ty.tag()) { | 2728 | return switch (ty.tag()) { |
| 2747 | .fn_noreturn_no_args => .{ | 2729 | .fn_noreturn_no_args => .{ |
| ... | @@ -2749,7 +2731,6 @@ pub const Type = extern union { | ... | @@ -2749,7 +2731,6 @@ pub const Type = extern union { |
| 2749 | .comptime_params = undefined, | 2731 | .comptime_params = undefined, |
| 2750 | .return_type = initTag(.noreturn), | 2732 | .return_type = initTag(.noreturn), |
| 2751 | .cc = .Unspecified, | 2733 | .cc = .Unspecified, |
| 2752 | .@"addrspace" = .generic, | ||
| 2753 | .is_var_args = false, | 2734 | .is_var_args = false, |
| 2754 | .is_generic = false, | 2735 | .is_generic = false, |
| 2755 | }, | 2736 | }, |
| ... | @@ -2758,7 +2739,6 @@ pub const Type = extern union { | ... | @@ -2758,7 +2739,6 @@ pub const Type = extern union { |
| 2758 | .comptime_params = undefined, | 2739 | .comptime_params = undefined, |
| 2759 | .return_type = initTag(.void), | 2740 | .return_type = initTag(.void), |
| 2760 | .cc = .Unspecified, | 2741 | .cc = .Unspecified, |
| 2761 | .@"addrspace" = .generic, | ||
| 2762 | .is_var_args = false, | 2742 | .is_var_args = false, |
| 2763 | .is_generic = false, | 2743 | .is_generic = false, |
| 2764 | }, | 2744 | }, |
| ... | @@ -2767,7 +2747,6 @@ pub const Type = extern union { | ... | @@ -2767,7 +2747,6 @@ pub const Type = extern union { |
| 2767 | .comptime_params = undefined, | 2747 | .comptime_params = undefined, |
| 2768 | .return_type = initTag(.noreturn), | 2748 | .return_type = initTag(.noreturn), |
| 2769 | .cc = .Naked, | 2749 | .cc = .Naked, |
| 2770 | .@"addrspace" = .generic, | ||
| 2771 | .is_var_args = false, | 2750 | .is_var_args = false, |
| 2772 | .is_generic = false, | 2751 | .is_generic = false, |
| 2773 | }, | 2752 | }, |
| ... | @@ -2776,7 +2755,6 @@ pub const Type = extern union { | ... | @@ -2776,7 +2755,6 @@ pub const Type = extern union { |
| 2776 | .comptime_params = undefined, | 2755 | .comptime_params = undefined, |
| 2777 | .return_type = initTag(.void), | 2756 | .return_type = initTag(.void), |
| 2778 | .cc = .C, | 2757 | .cc = .C, |
| 2779 | .@"addrspace" = .generic, | ||
| 2780 | .is_var_args = false, | 2758 | .is_var_args = false, |
| 2781 | .is_generic = false, | 2759 | .is_generic = false, |
| 2782 | }, | 2760 | }, |
| ... | @@ -3648,7 +3626,6 @@ pub const Type = extern union { | ... | @@ -3648,7 +3626,6 @@ pub const Type = extern union { |
| 3648 | comptime_params: [*]bool, | 3626 | comptime_params: [*]bool, |
| 3649 | return_type: Type, | 3627 | return_type: Type, |
| 3650 | cc: std.builtin.CallingConvention, | 3628 | cc: std.builtin.CallingConvention, |
| 3651 | @"addrspace": std.builtin.AddressSpace, | ||
| 3652 | is_var_args: bool, | 3629 | is_var_args: bool, |
| 3653 | is_generic: bool, | 3630 | is_generic: bool, |
| 3654 | 3631 |
test/compile_errors.zig-20| ... | @@ -410,7 +410,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -410,7 +410,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 410 | \\ .Fn = .{ | 410 | \\ .Fn = .{ |
| 411 | \\ .calling_convention = .Unspecified, | 411 | \\ .calling_convention = .Unspecified, |
| 412 | \\ .alignment = 0, | 412 | \\ .alignment = 0, |
| 413 | \\ .address_space = .generic, | ||
| 414 | \\ .is_generic = true, | 413 | \\ .is_generic = true, |
| 415 | \\ .is_var_args = false, | 414 | \\ .is_var_args = false, |
| 416 | \\ .return_type = u0, | 415 | \\ .return_type = u0, |
| ... | @@ -427,7 +426,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -427,7 +426,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 427 | \\ .Fn = .{ | 426 | \\ .Fn = .{ |
| 428 | \\ .calling_convention = .Unspecified, | 427 | \\ .calling_convention = .Unspecified, |
| 429 | \\ .alignment = 0, | 428 | \\ .alignment = 0, |
| 430 | \\ .address_space = .generic, | ||
| 431 | \\ .is_generic = false, | 429 | \\ .is_generic = false, |
| 432 | \\ .is_var_args = true, | 430 | \\ .is_var_args = true, |
| 433 | \\ .return_type = u0, | 431 | \\ .return_type = u0, |
| ... | @@ -444,7 +442,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -444,7 +442,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 444 | \\ .Fn = .{ | 442 | \\ .Fn = .{ |
| 445 | \\ .calling_convention = .Unspecified, | 443 | \\ .calling_convention = .Unspecified, |
| 446 | \\ .alignment = 0, | 444 | \\ .alignment = 0, |
| 447 | \\ .address_space = .generic, | ||
| 448 | \\ .is_generic = false, | 445 | \\ .is_generic = false, |
| 449 | \\ .is_var_args = false, | 446 | \\ .is_var_args = false, |
| 450 | \\ .return_type = null, | 447 | \\ .return_type = null, |
| ... | @@ -456,23 +453,6 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -456,23 +453,6 @@ pub fn addCases(ctx: *TestContext) !void { |
| 456 | "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type", | 453 | "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type", |
| 457 | }); | 454 | }); |
| 458 | 455 | ||
| 459 | ctx.objErrStage1("@Type(.Fn) with invalid address space ", | ||
| 460 | \\const Foo = @Type(.{ | ||
| 461 | \\ .Fn = .{ | ||
| 462 | \\ .calling_convention = .Unspecified, | ||
| 463 | \\ .alignment = 0, | ||
| 464 | \\ .address_space = .fs, | ||
| 465 | \\ .is_generic = false, | ||
| 466 | \\ .is_var_args = false, | ||
| 467 | \\ .return_type = u0, | ||
| 468 | \\ .args = &[_]@import("std").builtin.TypeInfo.FnArg{}, | ||
| 469 | \\ }, | ||
| 470 | \\}); | ||
| 471 | \\comptime { _ = Foo; } | ||
| 472 | , &[_][]const u8{ | ||
| 473 | "tmp.zig:1:20: error: address space 'fs' not available in stage 1 compiler, must be .generic", | ||
| 474 | }); | ||
| 475 | |||
| 476 | ctx.objErrStage1("@Type for union with opaque field", | 456 | ctx.objErrStage1("@Type for union with opaque field", |
| 477 | \\const TypeInfo = @import("std").builtin.TypeInfo; | 457 | \\const TypeInfo = @import("std").builtin.TypeInfo; |
| 478 | \\const Untagged = @Type(.{ | 458 | \\const Untagged = @Type(.{ |