| ... | ... | @@ -979,10 +979,38 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) C |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 982 | | _ = inst; |
| 983 | 982 | const tracy = trace(@src()); |
| 984 | 983 | defer tracy.end(); |
| 985 | | return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); |
| 984 | |
| 985 | const src: LazySrcLoc = sema.src; |
| 986 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 987 | const pointee_ty = try sema.resolveType(block, src, bin_inst.lhs); |
| 988 | const ptr = sema.resolveInst(bin_inst.rhs); |
| 989 | |
| 990 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 991 | const ptr_ty = try Type.ptr(sema.arena, .{ |
| 992 | .pointee_type = pointee_ty, |
| 993 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 994 | }); |
| 995 | try sema.requireRuntimeBlock(block, src); |
| 996 | const bitcasted_ptr = try block.addTyOp(.bitcast, ptr_ty, ptr); |
| 997 | |
| 998 | if (Air.refToIndex(ptr)) |ptr_inst| { |
| 999 | if (sema.air_instructions.items(.tag)[ptr_inst] == .constant) { |
| 1000 | const air_datas = sema.air_instructions.items(.data); |
| 1001 | const ptr_val = sema.air_values.items[air_datas[ptr_inst].ty_pl.payload]; |
| 1002 | if (ptr_val.castTag(.inferred_alloc)) |inferred_alloc| { |
| 1003 | // Add the stored instruction to the set we will use to resolve peer types |
| 1004 | // for the inferred allocation. |
| 1005 | // This instruction will not make it to codegen; it is only to participate |
| 1006 | // in the `stored_inst_list` of the `inferred_alloc`. |
| 1007 | const operand = try block.addTyOp(.bitcast, pointee_ty, .void_value); |
| 1008 | try inferred_alloc.data.stored_inst_list.append(sema.arena, operand); |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | return bitcasted_ptr; |
| 986 | 1014 | } |
| 987 | 1015 | |
| 988 | 1016 | pub fn analyzeStructDecl( |
| ... | ... | @@ -1427,13 +1455,10 @@ fn zirRetPtr( |
| 1427 | 1455 | return sema.analyzeComptimeAlloc(block, sema.fn_ret_ty); |
| 1428 | 1456 | } |
| 1429 | 1457 | |
| 1430 | | const ptr_type = try Module.simplePtrType( |
| 1431 | | sema.arena, |
| 1432 | | sema.fn_ret_ty, |
| 1433 | | true, |
| 1434 | | .One, |
| 1435 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1436 | | ); |
| 1458 | const ptr_type = try Type.ptr(sema.arena, .{ |
| 1459 | .pointee_type = sema.fn_ret_ty, |
| 1460 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1461 | }); |
| 1437 | 1462 | return block.addTy(.alloc, ptr_type); |
| 1438 | 1463 | } |
| 1439 | 1464 | |
| ... | ... | @@ -1581,13 +1606,10 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError |
| 1581 | 1606 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1582 | 1607 | const var_decl_src = inst_data.src(); |
| 1583 | 1608 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); |
| 1584 | | const ptr_type = try Module.simplePtrType( |
| 1585 | | sema.arena, |
| 1586 | | var_type, |
| 1587 | | true, |
| 1588 | | .One, |
| 1589 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1590 | | ); |
| 1609 | const ptr_type = try Type.ptr(sema.arena, .{ |
| 1610 | .pointee_type = var_type, |
| 1611 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1612 | }); |
| 1591 | 1613 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1592 | 1614 | return block.addTy(.alloc, ptr_type); |
| 1593 | 1615 | } |
| ... | ... | @@ -1604,13 +1626,10 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileEr |
| 1604 | 1626 | return sema.analyzeComptimeAlloc(block, var_type); |
| 1605 | 1627 | } |
| 1606 | 1628 | try sema.validateVarType(block, ty_src, var_type); |
| 1607 | | const ptr_type = try Module.simplePtrType( |
| 1608 | | sema.arena, |
| 1609 | | var_type, |
| 1610 | | true, |
| 1611 | | .One, |
| 1612 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1613 | | ); |
| 1629 | const ptr_type = try Type.ptr(sema.arena, .{ |
| 1630 | .pointee_type = var_type, |
| 1631 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1632 | }); |
| 1614 | 1633 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1615 | 1634 | return block.addTy(.alloc, ptr_type); |
| 1616 | 1635 | } |
| ... | ... | @@ -1670,13 +1689,10 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1670 | 1689 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); |
| 1671 | 1690 | |
| 1672 | 1691 | const final_elem_ty = try decl.ty.copy(sema.arena); |
| 1673 | | const final_ptr_ty = try Module.simplePtrType( |
| 1674 | | sema.arena, |
| 1675 | | final_elem_ty, |
| 1676 | | true, |
| 1677 | | .One, |
| 1678 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1679 | | ); |
| 1692 | const final_ptr_ty = try Type.ptr(sema.arena, .{ |
| 1693 | .pointee_type = final_elem_ty, |
| 1694 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1695 | }); |
| 1680 | 1696 | const final_ptr_ty_inst = try sema.addType(final_ptr_ty); |
| 1681 | 1697 | sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst; |
| 1682 | 1698 | |
| ... | ... | @@ -1698,13 +1714,10 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1698 | 1714 | try sema.validateVarType(block, ty_src, final_elem_ty); |
| 1699 | 1715 | } |
| 1700 | 1716 | // Change it to a normal alloc. |
| 1701 | | const final_ptr_ty = try Module.simplePtrType( |
| 1702 | | sema.arena, |
| 1703 | | final_elem_ty, |
| 1704 | | true, |
| 1705 | | .One, |
| 1706 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1707 | | ); |
| 1717 | const final_ptr_ty = try Type.ptr(sema.arena, .{ |
| 1718 | .pointee_type = final_elem_ty, |
| 1719 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1720 | }); |
| 1708 | 1721 | sema.air_instructions.set(ptr_inst, .{ |
| 1709 | 1722 | .tag = .alloc, |
| 1710 | 1723 | .data = .{ .ty = final_ptr_ty }, |
| ... | ... | @@ -1858,14 +1871,11 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Co |
| 1858 | 1871 | } |
| 1859 | 1872 | const ptr = sema.resolveInst(bin_inst.lhs); |
| 1860 | 1873 | const value = sema.resolveInst(bin_inst.rhs); |
| 1861 | | const ptr_ty = try Module.simplePtrType( |
| 1862 | | sema.arena, |
| 1863 | | sema.typeOf(value), |
| 1864 | | true, |
| 1865 | | .One, |
| 1874 | const ptr_ty = try Type.ptr(sema.arena, .{ |
| 1875 | .pointee_type = sema.typeOf(value), |
| 1866 | 1876 | // TODO figure out which address space is appropriate here |
| 1867 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1868 | | ); |
| 1877 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1878 | }); |
| 1869 | 1879 | // TODO detect when this store should be done at compile-time. For example, |
| 1870 | 1880 | // if expressions should force it when the condition is compile-time known. |
| 1871 | 1881 | const src: LazySrcLoc = .unneeded; |
| ... | ... | @@ -1912,14 +1922,10 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 1912 | 1922 | // for the inferred allocation. |
| 1913 | 1923 | try inferred_alloc.data.stored_inst_list.append(sema.arena, operand); |
| 1914 | 1924 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 1915 | | const ptr_ty = try Module.simplePtrType( |
| 1916 | | sema.arena, |
| 1917 | | operand_ty, |
| 1918 | | true, |
| 1919 | | .One, |
| 1920 | | // TODO figure out which address space is appropriate here |
| 1921 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1922 | | ); |
| 1925 | const ptr_ty = try Type.ptr(sema.arena, .{ |
| 1926 | .pointee_type = operand_ty, |
| 1927 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .local), |
| 1928 | }); |
| 1923 | 1929 | const bitcasted_ptr = try block.addTyOp(.bitcast, ptr_ty, ptr); |
| 1924 | 1930 | return sema.storePtr(block, src, bitcasted_ptr, operand); |
| 1925 | 1931 | } |
| ... | ... | @@ -3845,13 +3851,11 @@ fn zirOptionalPayloadPtr( |
| 3845 | 3851 | } |
| 3846 | 3852 | |
| 3847 | 3853 | const child_type = try opt_type.optionalChildAlloc(sema.arena); |
| 3848 | | const child_pointer = try Module.simplePtrType( |
| 3849 | | sema.arena, |
| 3850 | | child_type, |
| 3851 | | !optional_ptr_ty.isConstPtr(), |
| 3852 | | .One, |
| 3853 | | optional_ptr_ty.ptrAddressSpace(), |
| 3854 | | ); |
| 3854 | const child_pointer = try Type.ptr(sema.arena, .{ |
| 3855 | .pointee_type = child_type, |
| 3856 | .mutable = !optional_ptr_ty.isConstPtr(), |
| 3857 | .@"addrspace" = optional_ptr_ty.ptrAddressSpace(), |
| 3858 | }); |
| 3855 | 3859 | |
| 3856 | 3860 | if (try sema.resolveDefinedValue(block, src, optional_ptr)) |pointer_val| { |
| 3857 | 3861 | if (try pointer_val.pointerDeref(sema.arena)) |val| { |
| ... | ... | @@ -3966,13 +3970,11 @@ fn zirErrUnionPayloadPtr( |
| 3966 | 3970 | return sema.mod.fail(&block.base, src, "expected error union type, found {}", .{operand_ty.elemType()}); |
| 3967 | 3971 | |
| 3968 | 3972 | const payload_ty = operand_ty.elemType().errorUnionPayload(); |
| 3969 | | const operand_pointer_ty = try Module.simplePtrType( |
| 3970 | | sema.arena, |
| 3971 | | payload_ty, |
| 3972 | | !operand_ty.isConstPtr(), |
| 3973 | | .One, |
| 3974 | | operand_ty.ptrAddressSpace(), |
| 3975 | | ); |
| 3973 | const operand_pointer_ty = try Type.ptr(sema.arena, .{ |
| 3974 | .pointee_type = payload_ty, |
| 3975 | .mutable = !operand_ty.isConstPtr(), |
| 3976 | .@"addrspace" = operand_ty.ptrAddressSpace(), |
| 3977 | }); |
| 3976 | 3978 | |
| 3977 | 3979 | if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| { |
| 3978 | 3980 | if (try pointer_val.pointerDeref(sema.arena)) |val| { |
| ... | ... | @@ -7306,19 +7308,14 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Comp |
| 7306 | 7308 | |
| 7307 | 7309 | const inst_data = sema.code.instructions.items(.data)[inst].ptr_type_simple; |
| 7308 | 7310 | const elem_type = try sema.resolveType(block, .unneeded, inst_data.elem_type); |
| 7309 | | const ty = try Module.ptrType( |
| 7310 | | sema.arena, |
| 7311 | | elem_type, |
| 7312 | | null, |
| 7313 | | 0, |
| 7314 | | .generic, |
| 7315 | | 0, |
| 7316 | | 0, |
| 7317 | | inst_data.is_mutable, |
| 7318 | | inst_data.is_allowzero, |
| 7319 | | inst_data.is_volatile, |
| 7320 | | inst_data.size, |
| 7321 | | ); |
| 7311 | const ty = try Type.ptr(sema.arena, .{ |
| 7312 | .pointee_type = elem_type, |
| 7313 | .@"addrspace" = .generic, |
| 7314 | .mutable = inst_data.is_mutable, |
| 7315 | .@"allowzero" = inst_data.is_allowzero, |
| 7316 | .@"volatile" = inst_data.is_volatile, |
| 7317 | .size = inst_data.size, |
| 7318 | }); |
| 7322 | 7319 | return sema.addType(ty); |
| 7323 | 7320 | } |
| 7324 | 7321 | |
| ... | ... | @@ -7367,19 +7364,18 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErr |
| 7367 | 7364 | |
| 7368 | 7365 | const elem_type = try sema.resolveType(block, .unneeded, extra.data.elem_type); |
| 7369 | 7366 | |
| 7370 | | const ty = try Module.ptrType( |
| 7371 | | sema.arena, |
| 7372 | | elem_type, |
| 7373 | | sentinel, |
| 7374 | | abi_align, |
| 7375 | | address_space, |
| 7376 | | bit_start, |
| 7377 | | bit_end, |
| 7378 | | inst_data.flags.is_mutable, |
| 7379 | | inst_data.flags.is_allowzero, |
| 7380 | | inst_data.flags.is_volatile, |
| 7381 | | inst_data.size, |
| 7382 | | ); |
| 7367 | const ty = try Type.ptr(sema.arena, .{ |
| 7368 | .pointee_type = elem_type, |
| 7369 | .sentinel = sentinel, |
| 7370 | .@"align" = abi_align, |
| 7371 | .@"addrspace" = address_space, |
| 7372 | .bit_offset = bit_start, |
| 7373 | .host_size = bit_end, |
| 7374 | .mutable = inst_data.flags.is_mutable, |
| 7375 | .@"allowzero" = inst_data.flags.is_allowzero, |
| 7376 | .@"volatile" = inst_data.flags.is_volatile, |
| 7377 | .size = inst_data.size, |
| 7378 | }); |
| 7383 | 7379 | return sema.addType(ty); |
| 7384 | 7380 | } |
| 7385 | 7381 | |
| ... | ... | @@ -8456,19 +8452,15 @@ fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileErro |
| 8456 | 8452 | }); |
| 8457 | 8453 | } |
| 8458 | 8454 | const src_ptr_info = uncasted_src_ptr_ty.ptrInfo().data; |
| 8459 | | const wanted_src_ptr_ty = try Module.ptrType( |
| 8460 | | sema.arena, |
| 8461 | | dest_ptr_ty.elemType2(), |
| 8462 | | null, |
| 8463 | | src_ptr_info.@"align", |
| 8464 | | src_ptr_info.@"addrspace", |
| 8465 | | 0, |
| 8466 | | 0, |
| 8467 | | false, |
| 8468 | | src_ptr_info.@"allowzero", |
| 8469 | | src_ptr_info.@"volatile", |
| 8470 | | .Many, |
| 8471 | | ); |
| 8455 | const wanted_src_ptr_ty = try Type.ptr(sema.arena, .{ |
| 8456 | .pointee_type = dest_ptr_ty.elemType2(), |
| 8457 | .@"align" = src_ptr_info.@"align", |
| 8458 | .@"addrspace" = src_ptr_info.@"addrspace", |
| 8459 | .mutable = false, |
| 8460 | .@"allowzero" = src_ptr_info.@"allowzero", |
| 8461 | .@"volatile" = src_ptr_info.@"volatile", |
| 8462 | .size = .Many, |
| 8463 | }); |
| 8472 | 8464 | const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src); |
| 8473 | 8465 | const len = try sema.coerce(block, Type.initTag(.usize), sema.resolveInst(extra.byte_count), len_src); |
| 8474 | 8466 | |
| ... | ... | @@ -8922,13 +8914,10 @@ fn panicWithMsg( |
| 8922 | 8914 | const panic_fn = try sema.getBuiltin(block, src, "panic"); |
| 8923 | 8915 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); |
| 8924 | 8916 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); |
| 8925 | | const ptr_stack_trace_ty = try Module.simplePtrType( |
| 8926 | | arena, |
| 8927 | | stack_trace_ty, |
| 8928 | | true, |
| 8929 | | .One, |
| 8930 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), // TODO might need a place that is more dynamic |
| 8931 | | ); |
| 8917 | const ptr_stack_trace_ty = try Type.ptr(arena, .{ |
| 8918 | .pointee_type = stack_trace_ty, |
| 8919 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), // TODO might need a place that is more dynamic |
| 8920 | }); |
| 8932 | 8921 | const null_stack_trace = try sema.addConstant( |
| 8933 | 8922 | try Module.optionalType(arena, ptr_stack_trace_ty), |
| 8934 | 8923 | Value.initTag(.null_value), |
| ... | ... | @@ -9407,13 +9396,11 @@ fn structFieldPtr( |
| 9407 | 9396 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 9408 | 9397 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); |
| 9409 | 9398 | const field = struct_obj.fields.values()[field_index]; |
| 9410 | | const ptr_field_ty = try Module.simplePtrType( |
| 9411 | | arena, |
| 9412 | | field.ty, |
| 9413 | | struct_ptr_ty.ptrIsMutable(), |
| 9414 | | .One, |
| 9415 | | struct_ptr_ty.ptrAddressSpace(), |
| 9416 | | ); |
| 9399 | const ptr_field_ty = try Type.ptr(arena, .{ |
| 9400 | .pointee_type = field.ty, |
| 9401 | .mutable = struct_ptr_ty.ptrIsMutable(), |
| 9402 | .@"addrspace" = struct_ptr_ty.ptrAddressSpace(), |
| 9403 | }); |
| 9417 | 9404 | |
| 9418 | 9405 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { |
| 9419 | 9406 | return sema.addConstant( |
| ... | ... | @@ -9512,13 +9499,11 @@ fn unionFieldPtr( |
| 9512 | 9499 | return sema.failWithBadUnionFieldAccess(block, union_obj, field_name_src, field_name); |
| 9513 | 9500 | |
| 9514 | 9501 | const field = union_obj.fields.values()[field_index]; |
| 9515 | | const ptr_field_ty = try Module.simplePtrType( |
| 9516 | | arena, |
| 9517 | | field.ty, |
| 9518 | | union_ptr_ty.ptrIsMutable(), |
| 9519 | | .One, |
| 9520 | | union_ptr_ty.ptrAddressSpace(), |
| 9521 | | ); |
| 9502 | const ptr_field_ty = try Type.ptr(arena, .{ |
| 9503 | .pointee_type = field.ty, |
| 9504 | .mutable = union_ptr_ty.ptrIsMutable(), |
| 9505 | .@"addrspace" = union_ptr_ty.ptrAddressSpace(), |
| 9506 | }); |
| 9522 | 9507 | |
| 9523 | 9508 | if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| { |
| 9524 | 9509 | // TODO detect inactive union field and emit compile error |
| ... | ... | @@ -9694,13 +9679,11 @@ fn elemPtrArray( |
| 9694 | 9679 | ) CompileError!Air.Inst.Ref { |
| 9695 | 9680 | const array_ptr_ty = sema.typeOf(array_ptr); |
| 9696 | 9681 | const pointee_type = array_ptr_ty.elemType().elemType(); |
| 9697 | | const result_ty = try Module.simplePtrType( |
| 9698 | | sema.arena, |
| 9699 | | pointee_type, |
| 9700 | | array_ptr_ty.ptrIsMutable(), |
| 9701 | | .One, |
| 9702 | | array_ptr_ty.ptrAddressSpace(), |
| 9703 | | ); |
| 9682 | const result_ty = try Type.ptr(sema.arena, .{ |
| 9683 | .pointee_type = pointee_type, |
| 9684 | .mutable = array_ptr_ty.ptrIsMutable(), |
| 9685 | .@"addrspace" = array_ptr_ty.ptrAddressSpace(), |
| 9686 | }); |
| 9704 | 9687 | |
| 9705 | 9688 | if (try sema.resolveDefinedValue(block, src, array_ptr)) |array_ptr_val| { |
| 9706 | 9689 | if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| { |
| ... | ... | @@ -10243,11 +10226,19 @@ fn analyzeDeclRef(sema: *Sema, decl: *Decl) CompileError!Air.Inst.Ref { |
| 10243 | 10226 | const decl_tv = try decl.typedValue(); |
| 10244 | 10227 | if (decl_tv.val.castTag(.variable)) |payload| { |
| 10245 | 10228 | const variable = payload.data; |
| 10246 | | const ty = try Module.simplePtrType(sema.arena, decl_tv.ty, variable.is_mutable, .One, decl.@"addrspace"); |
| 10229 | const ty = try Type.ptr(sema.arena, .{ |
| 10230 | .pointee_type = decl_tv.ty, |
| 10231 | .mutable = variable.is_mutable, |
| 10232 | .@"addrspace" = decl.@"addrspace", |
| 10233 | }); |
| 10247 | 10234 | return sema.addConstant(ty, try Value.Tag.decl_ref.create(sema.arena, decl)); |
| 10248 | 10235 | } |
| 10249 | 10236 | return sema.addConstant( |
| 10250 | | try Module.simplePtrType(sema.arena, decl_tv.ty, false, .One, decl.@"addrspace"), |
| 10237 | try Type.ptr(sema.arena, .{ |
| 10238 | .pointee_type = decl_tv.ty, |
| 10239 | .mutable = false, |
| 10240 | .@"addrspace" = decl.@"addrspace", |
| 10241 | }), |
| 10251 | 10242 | try Value.Tag.decl_ref.create(sema.arena, decl), |
| 10252 | 10243 | ); |
| 10253 | 10244 | } |
| ... | ... | @@ -10271,8 +10262,15 @@ fn analyzeRef( |
| 10271 | 10262 | |
| 10272 | 10263 | try sema.requireRuntimeBlock(block, src); |
| 10273 | 10264 | const address_space = target_util.defaultAddressSpace(sema.mod.getTarget(), .local); |
| 10274 | | const ptr_type = try Module.simplePtrType(sema.arena, operand_ty, false, .One, address_space); |
| 10275 | | const mut_ptr_type = try Module.simplePtrType(sema.arena, operand_ty, true, .One, address_space); |
| 10265 | const ptr_type = try Type.ptr(sema.arena, .{ |
| 10266 | .pointee_type = operand_ty, |
| 10267 | .mutable = false, |
| 10268 | .@"addrspace" = address_space, |
| 10269 | }); |
| 10270 | const mut_ptr_type = try Type.ptr(sema.arena, .{ |
| 10271 | .pointee_type = operand_ty, |
| 10272 | .@"addrspace" = address_space, |
| 10273 | }); |
| 10276 | 10274 | const alloc = try block.addTy(.alloc, mut_ptr_type); |
| 10277 | 10275 | try sema.storePtr(block, src, alloc, operand); |
| 10278 | 10276 | |
| ... | ... | @@ -10428,19 +10426,16 @@ fn analyzeSlice( |
| 10428 | 10426 | } |
| 10429 | 10427 | } |
| 10430 | 10428 | } |
| 10431 | | const return_type = try Module.ptrType( |
| 10432 | | sema.arena, |
| 10433 | | return_elem_type, |
| 10434 | | if (end_opt == .none) slice_sentinel else null, |
| 10435 | | 0, // TODO alignment |
| 10436 | | if (ptr_child.zigTypeTag() == .Pointer) ptr_child.ptrAddressSpace() else .generic, |
| 10437 | | 0, |
| 10438 | | 0, |
| 10439 | | !ptr_child.isConstPtr(), |
| 10440 | | ptr_child.isAllowzeroPtr(), |
| 10441 | | ptr_child.isVolatilePtr(), |
| 10442 | | return_ptr_size, |
| 10443 | | ); |
| 10429 | const return_type = try Type.ptr(sema.arena, .{ |
| 10430 | .pointee_type = return_elem_type, |
| 10431 | .sentinel = if (end_opt == .none) slice_sentinel else null, |
| 10432 | .@"align" = 0, // TODO alignment |
| 10433 | .@"addrspace" = if (ptr_child.zigTypeTag() == .Pointer) ptr_child.ptrAddressSpace() else .generic, |
| 10434 | .mutable = !ptr_child.isConstPtr(), |
| 10435 | .@"allowzero" = ptr_child.isAllowzeroPtr(), |
| 10436 | .@"volatile" = ptr_child.isVolatilePtr(), |
| 10437 | .size = return_ptr_size, |
| 10438 | }); |
| 10444 | 10439 | _ = return_type; |
| 10445 | 10440 | |
| 10446 | 10441 | return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{}); |
| ... | ... | @@ -11626,13 +11621,10 @@ fn analyzeComptimeAlloc( |
| 11626 | 11621 | block: *Scope.Block, |
| 11627 | 11622 | var_type: Type, |
| 11628 | 11623 | ) CompileError!Air.Inst.Ref { |
| 11629 | | const ptr_type = try Module.simplePtrType( |
| 11630 | | sema.arena, |
| 11631 | | var_type, |
| 11632 | | true, |
| 11633 | | .One, |
| 11634 | | target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), |
| 11635 | | ); |
| 11624 | const ptr_type = try Type.ptr(sema.arena, .{ |
| 11625 | .pointee_type = var_type, |
| 11626 | .@"addrspace" = target_util.defaultAddressSpace(sema.mod.getTarget(), .global_constant), |
| 11627 | }); |
| 11636 | 11628 | |
| 11637 | 11629 | var anon_decl = try block.startAnonDecl(); |
| 11638 | 11630 | defer anon_decl.deinit(); |