| author | |
| committer | |
| log | ca16f1e8a703491bcaac0d13379d2556e8ca837d |
| tree | fefadd0912e8e3deedbf0a7261219fbd7ee5149f |
| parent | dbd44658ff2d392451ea4f3a38ca4bd26da34314 |
* move `ptrBitWidth` from Arch to Target since it needs to know about the abi
* double isn't always 8 bits
* AVR uses 1-byte alignment for everything in GCC28 files changed, 180 insertions(+), 168 deletions(-)
lib/std/c/freebsd.zig+1-1| ... | @@ -322,7 +322,7 @@ pub const RTLD = struct { | ... | @@ -322,7 +322,7 @@ pub const RTLD = struct { |
| 322 | 322 | ||
| 323 | pub const dl_phdr_info = extern struct { | 323 | pub const dl_phdr_info = extern struct { |
| 324 | /// Module relocation base. | 324 | /// Module relocation base. |
| 325 | dlpi_addr: if (builtin.cpu.arch.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, | 325 | dlpi_addr: if (builtin.target.ptrBitWidth() == 32) std.elf.Elf32_Addr else std.elf.Elf64_Addr, |
| 326 | /// Module name. | 326 | /// Module name. |
| 327 | dlpi_name: ?[*:0]const u8, | 327 | dlpi_name: ?[*:0]const u8, |
| 328 | /// Pointer to module's phdr. | 328 | /// Pointer to module's phdr. |
lib/std/os/linux.zig+12-2| ... | @@ -5847,8 +5847,18 @@ pub const AUDIT = struct { | ... | @@ -5847,8 +5847,18 @@ pub const AUDIT = struct { |
| 5847 | fn toAudit(arch: std.Target.Cpu.Arch) u32 { | 5847 | fn toAudit(arch: std.Target.Cpu.Arch) u32 { |
| 5848 | var res: u32 = @enumToInt(arch.toElfMachine()); | 5848 | var res: u32 = @enumToInt(arch.toElfMachine()); |
| 5849 | if (arch.endian() == .Little) res |= LE; | 5849 | if (arch.endian() == .Little) res |= LE; |
| 5850 | if (arch.ptrBitWidth() == 64) res |= @"64BIT"; | 5850 | switch (arch) { |
| 5851 | 5851 | .aarch64, | |
| 5852 | .mips64, | ||
| 5853 | .mips64el, | ||
| 5854 | .powerpc64, | ||
| 5855 | .powerpc64le, | ||
| 5856 | .riscv64, | ||
| 5857 | .sparc64, | ||
| 5858 | .x86_64, | ||
| 5859 | => res |= @"64BIT", | ||
| 5860 | else => {}, | ||
| 5861 | } | ||
| 5852 | return res; | 5862 | return res; |
| 5853 | } | 5863 | } |
| 5854 | }; | 5864 | }; |
lib/std/target.zig+83-81| ... | @@ -1189,77 +1189,6 @@ pub const Target = struct { | ... | @@ -1189,77 +1189,6 @@ pub const Target = struct { |
| 1189 | }; | 1189 | }; |
| 1190 | } | 1190 | } |
| 1191 | 1191 | ||
| 1192 | pub fn ptrBitWidth(arch: Arch) u16 { | ||
| 1193 | switch (arch) { | ||
| 1194 | .avr, | ||
| 1195 | .msp430, | ||
| 1196 | .spu_2, | ||
| 1197 | => return 16, | ||
| 1198 | |||
| 1199 | .arc, | ||
| 1200 | .arm, | ||
| 1201 | .armeb, | ||
| 1202 | .csky, | ||
| 1203 | .hexagon, | ||
| 1204 | .m68k, | ||
| 1205 | .le32, | ||
| 1206 | .mips, | ||
| 1207 | .mipsel, | ||
| 1208 | .powerpc, | ||
| 1209 | .powerpcle, | ||
| 1210 | .r600, | ||
| 1211 | .riscv32, | ||
| 1212 | .sparc, | ||
| 1213 | .sparcel, | ||
| 1214 | .tce, | ||
| 1215 | .tcele, | ||
| 1216 | .thumb, | ||
| 1217 | .thumbeb, | ||
| 1218 | .x86, | ||
| 1219 | .xcore, | ||
| 1220 | .nvptx, | ||
| 1221 | .amdil, | ||
| 1222 | .hsail, | ||
| 1223 | .spir, | ||
| 1224 | .kalimba, | ||
| 1225 | .shave, | ||
| 1226 | .lanai, | ||
| 1227 | .wasm32, | ||
| 1228 | .renderscript32, | ||
| 1229 | .aarch64_32, | ||
| 1230 | .spirv32, | ||
| 1231 | .loongarch32, | ||
| 1232 | .dxil, | ||
| 1233 | .xtensa, | ||
| 1234 | => return 32, | ||
| 1235 | |||
| 1236 | .aarch64, | ||
| 1237 | .aarch64_be, | ||
| 1238 | .mips64, | ||
| 1239 | .mips64el, | ||
| 1240 | .powerpc64, | ||
| 1241 | .powerpc64le, | ||
| 1242 | .riscv64, | ||
| 1243 | .x86_64, | ||
| 1244 | .nvptx64, | ||
| 1245 | .le64, | ||
| 1246 | .amdil64, | ||
| 1247 | .hsail64, | ||
| 1248 | .spir64, | ||
| 1249 | .wasm64, | ||
| 1250 | .renderscript64, | ||
| 1251 | .amdgcn, | ||
| 1252 | .bpfel, | ||
| 1253 | .bpfeb, | ||
| 1254 | .sparc64, | ||
| 1255 | .s390x, | ||
| 1256 | .ve, | ||
| 1257 | .spirv64, | ||
| 1258 | .loongarch64, | ||
| 1259 | => return 64, | ||
| 1260 | } | ||
| 1261 | } | ||
| 1262 | |||
| 1263 | /// Returns a name that matches the lib/std/target/* source file name. | 1192 | /// Returns a name that matches the lib/std/target/* source file name. |
| 1264 | pub fn genericName(arch: Arch) []const u8 { | 1193 | pub fn genericName(arch: Arch) []const u8 { |
| 1265 | return switch (arch) { | 1194 | return switch (arch) { |
| ... | @@ -1621,7 +1550,7 @@ pub const Target = struct { | ... | @@ -1621,7 +1550,7 @@ pub const Target = struct { |
| 1621 | const copy = S.copy; | 1550 | const copy = S.copy; |
| 1622 | 1551 | ||
| 1623 | if (self.abi == .android) { | 1552 | if (self.abi == .android) { |
| 1624 | const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else ""; | 1553 | const suffix = if (self.ptrBitWidth() == 64) "64" else ""; |
| 1625 | return print(&result, "/system/bin/linker{s}", .{suffix}); | 1554 | return print(&result, "/system/bin/linker{s}", .{suffix}); |
| 1626 | } | 1555 | } |
| 1627 | 1556 | ||
| ... | @@ -1904,6 +1833,83 @@ pub const Target = struct { | ... | @@ -1904,6 +1833,83 @@ pub const Target = struct { |
| 1904 | }; | 1833 | }; |
| 1905 | } | 1834 | } |
| 1906 | 1835 | ||
| 1836 | pub fn ptrBitWidth(target: std.Target) u16 { | ||
| 1837 | switch (target.abi) { | ||
| 1838 | .gnux32, .muslx32, .gnuabin32, .gnuilp32 => return 32, | ||
| 1839 | .gnuabi64 => return 64, | ||
| 1840 | else => {}, | ||
| 1841 | } | ||
| 1842 | switch (target.cpu.arch) { | ||
| 1843 | .avr, | ||
| 1844 | .msp430, | ||
| 1845 | .spu_2, | ||
| 1846 | => return 16, | ||
| 1847 | |||
| 1848 | .arc, | ||
| 1849 | .arm, | ||
| 1850 | .armeb, | ||
| 1851 | .csky, | ||
| 1852 | .hexagon, | ||
| 1853 | .m68k, | ||
| 1854 | .le32, | ||
| 1855 | .mips, | ||
| 1856 | .mipsel, | ||
| 1857 | .powerpc, | ||
| 1858 | .powerpcle, | ||
| 1859 | .r600, | ||
| 1860 | .riscv32, | ||
| 1861 | .sparcel, | ||
| 1862 | .tce, | ||
| 1863 | .tcele, | ||
| 1864 | .thumb, | ||
| 1865 | .thumbeb, | ||
| 1866 | .x86, | ||
| 1867 | .xcore, | ||
| 1868 | .nvptx, | ||
| 1869 | .amdil, | ||
| 1870 | .hsail, | ||
| 1871 | .spir, | ||
| 1872 | .kalimba, | ||
| 1873 | .shave, | ||
| 1874 | .lanai, | ||
| 1875 | .wasm32, | ||
| 1876 | .renderscript32, | ||
| 1877 | .aarch64_32, | ||
| 1878 | .spirv32, | ||
| 1879 | .loongarch32, | ||
| 1880 | .dxil, | ||
| 1881 | .xtensa, | ||
| 1882 | => return 32, | ||
| 1883 | |||
| 1884 | .aarch64, | ||
| 1885 | .aarch64_be, | ||
| 1886 | .mips64, | ||
| 1887 | .mips64el, | ||
| 1888 | .powerpc64, | ||
| 1889 | .powerpc64le, | ||
| 1890 | .riscv64, | ||
| 1891 | .x86_64, | ||
| 1892 | .nvptx64, | ||
| 1893 | .le64, | ||
| 1894 | .amdil64, | ||
| 1895 | .hsail64, | ||
| 1896 | .spir64, | ||
| 1897 | .wasm64, | ||
| 1898 | .renderscript64, | ||
| 1899 | .amdgcn, | ||
| 1900 | .bpfel, | ||
| 1901 | .bpfeb, | ||
| 1902 | .sparc64, | ||
| 1903 | .s390x, | ||
| 1904 | .ve, | ||
| 1905 | .spirv64, | ||
| 1906 | .loongarch64, | ||
| 1907 | => return 64, | ||
| 1908 | |||
| 1909 | .sparc => return if (std.Target.sparc.featureSetHas(target.cpu.features, .v9)) 64 else 32, | ||
| 1910 | } | ||
| 1911 | } | ||
| 1912 | |||
| 1907 | pub const CType = enum { | 1913 | pub const CType = enum { |
| 1908 | char, | 1914 | char, |
| 1909 | short, | 1915 | short, |
| ... | @@ -1930,11 +1936,10 @@ pub const Target = struct { | ... | @@ -1930,11 +1936,10 @@ pub const Target = struct { |
| 1930 | .ulong, | 1936 | .ulong, |
| 1931 | .longlong, | 1937 | .longlong, |
| 1932 | .ulonglong, | 1938 | .ulonglong, |
| 1939 | .float, | ||
| 1940 | .double, | ||
| 1933 | => @divExact(c_type_bit_size(t, c_type), 8), | 1941 | => @divExact(c_type_bit_size(t, c_type), 8), |
| 1934 | 1942 | ||
| 1935 | .float => 4, | ||
| 1936 | .double => 8, | ||
| 1937 | |||
| 1938 | .longdouble => switch (c_type_bit_size(t, c_type)) { | 1943 | .longdouble => switch (c_type_bit_size(t, c_type)) { |
| 1939 | 16 => 2, | 1944 | 16 => 2, |
| 1940 | 32 => 4, | 1945 | 32 => 4, |
| ... | @@ -1990,7 +1995,7 @@ pub const Target = struct { | ... | @@ -1990,7 +1995,7 @@ pub const Target = struct { |
| 1990 | .char => return 8, | 1995 | .char => return 8, |
| 1991 | .short, .ushort => return 16, | 1996 | .short, .ushort => return 16, |
| 1992 | .int, .uint, .float => return 32, | 1997 | .int, .uint, .float => return 32, |
| 1993 | .long, .ulong => return target.cpu.arch.ptrBitWidth(), | 1998 | .long, .ulong => return target.ptrBitWidth(), |
| 1994 | .longlong, .ulonglong, .double => return 64, | 1999 | .longlong, .ulonglong, .double => return 64, |
| 1995 | .longdouble => switch (target.cpu.arch) { | 2000 | .longdouble => switch (target.cpu.arch) { |
| 1996 | .x86 => switch (target.abi) { | 2001 | .x86 => switch (target.abi) { |
| ... | @@ -2084,7 +2089,7 @@ pub const Target = struct { | ... | @@ -2084,7 +2089,7 @@ pub const Target = struct { |
| 2084 | .char => return 8, | 2089 | .char => return 8, |
| 2085 | .short, .ushort => return 16, | 2090 | .short, .ushort => return 16, |
| 2086 | .int, .uint, .float => return 32, | 2091 | .int, .uint, .float => return 32, |
| 2087 | .long, .ulong => return target.cpu.arch.ptrBitWidth(), | 2092 | .long, .ulong => return target.ptrBitWidth(), |
| 2088 | .longlong, .ulonglong, .double => return 64, | 2093 | .longlong, .ulonglong, .double => return 64, |
| 2089 | .longdouble => switch (target.cpu.arch) { | 2094 | .longdouble => switch (target.cpu.arch) { |
| 2090 | .x86 => switch (target.abi) { | 2095 | .x86 => switch (target.abi) { |
| ... | @@ -2256,10 +2261,7 @@ pub const Target = struct { | ... | @@ -2256,10 +2261,7 @@ pub const Target = struct { |
| 2256 | pub fn c_type_alignment(target: Target, c_type: CType) u16 { | 2261 | pub fn c_type_alignment(target: Target, c_type: CType) u16 { |
| 2257 | // Overrides for unusual alignments | 2262 | // Overrides for unusual alignments |
| 2258 | switch (target.cpu.arch) { | 2263 | switch (target.cpu.arch) { |
| 2259 | .avr => switch (c_type) { | 2264 | .avr => return 1, |
| 2260 | .short, .ushort => return 2, | ||
| 2261 | else => return 1, | ||
| 2262 | }, | ||
| 2263 | .x86 => switch (target.os.tag) { | 2265 | .x86 => switch (target.os.tag) { |
| 2264 | .windows, .uefi => switch (c_type) { | 2266 | .windows, .uefi => switch (c_type) { |
| 2265 | .longlong, .ulonglong, .double => return 8, | 2267 | .longlong, .ulonglong, .double => return 8, |
lib/std/zig/system/NativePaths.zig+1-1| ... | @@ -117,7 +117,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths | ... | @@ -117,7 +117,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths |
| 117 | const triple = try native_target.linuxTriple(allocator); | 117 | const triple = try native_target.linuxTriple(allocator); |
| 118 | defer allocator.free(triple); | 118 | defer allocator.free(triple); |
| 119 | 119 | ||
| 120 | const qual = native_target.cpu.arch.ptrBitWidth(); | 120 | const qual = native_target.ptrBitWidth(); |
| 121 | 121 | ||
| 122 | // TODO: $ ld --verbose | grep SEARCH_DIR | 122 | // TODO: $ ld --verbose | grep SEARCH_DIR |
| 123 | // the output contains some paths that end with lib64, maybe include them too? | 123 | // the output contains some paths that end with lib64, maybe include them too? |
lib/std/zig/system/NativeTargetInfo.zig+2-2| ... | @@ -1095,7 +1095,7 @@ pub fn getExternalExecutor( | ... | @@ -1095,7 +1095,7 @@ pub fn getExternalExecutor( |
| 1095 | if (candidate.target.cpu.arch != builtin.cpu.arch) { | 1095 | if (candidate.target.cpu.arch != builtin.cpu.arch) { |
| 1096 | return bad_result; | 1096 | return bad_result; |
| 1097 | } | 1097 | } |
| 1098 | switch (candidate.target.cpu.arch.ptrBitWidth()) { | 1098 | switch (candidate.target.ptrBitWidth()) { |
| 1099 | 32 => return Executor{ .wine = "wine" }, | 1099 | 32 => return Executor{ .wine = "wine" }, |
| 1100 | 64 => return Executor{ .wine = "wine64" }, | 1100 | 64 => return Executor{ .wine = "wine64" }, |
| 1101 | else => return bad_result, | 1101 | else => return bad_result, |
| ... | @@ -1105,7 +1105,7 @@ pub fn getExternalExecutor( | ... | @@ -1105,7 +1105,7 @@ pub fn getExternalExecutor( |
| 1105 | }, | 1105 | }, |
| 1106 | .wasi => { | 1106 | .wasi => { |
| 1107 | if (options.allow_wasmtime) { | 1107 | if (options.allow_wasmtime) { |
| 1108 | switch (candidate.target.cpu.arch.ptrBitWidth()) { | 1108 | switch (candidate.target.ptrBitWidth()) { |
| 1109 | 32 => return Executor{ .wasmtime = "wasmtime" }, | 1109 | 32 => return Executor{ .wasmtime = "wasmtime" }, |
| 1110 | else => return bad_result, | 1110 | else => return bad_result, |
| 1111 | } | 1111 | } |
src/Sema.zig+1-1| ... | @@ -34002,7 +34002,7 @@ fn intFitsInType( | ... | @@ -34002,7 +34002,7 @@ fn intFitsInType( |
| 34002 | => switch (ty.zigTypeTag()) { | 34002 | => switch (ty.zigTypeTag()) { |
| 34003 | .Int => { | 34003 | .Int => { |
| 34004 | const info = ty.intInfo(target); | 34004 | const info = ty.intInfo(target); |
| 34005 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 34005 | const ptr_bits = target.ptrBitWidth(); |
| 34006 | return switch (info.signedness) { | 34006 | return switch (info.signedness) { |
| 34007 | .signed => info.bits > ptr_bits, | 34007 | .signed => info.bits > ptr_bits, |
| 34008 | .unsigned => info.bits >= ptr_bits, | 34008 | .unsigned => info.bits >= ptr_bits, |
src/arch/aarch64/CodeGen.zig+6-6| ... | @@ -501,7 +501,7 @@ fn gen(self: *Self) !void { | ... | @@ -501,7 +501,7 @@ fn gen(self: *Self) !void { |
| 501 | // (or w0 when pointer size is 32 bits). As this register | 501 | // (or w0 when pointer size is 32 bits). As this register |
| 502 | // might get overwritten along the way, save the address | 502 | // might get overwritten along the way, save the address |
| 503 | // to the stack. | 503 | // to the stack. |
| 504 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 504 | const ptr_bits = self.target.ptrBitWidth(); |
| 505 | const ptr_bytes = @divExact(ptr_bits, 8); | 505 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 506 | const ret_ptr_reg = self.registerAlias(.x0, Type.usize); | 506 | const ret_ptr_reg = self.registerAlias(.x0, Type.usize); |
| 507 | 507 | ||
| ... | @@ -1512,7 +1512,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1512,7 +1512,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 1512 | const len = try self.resolveInst(bin_op.rhs); | 1512 | const len = try self.resolveInst(bin_op.rhs); |
| 1513 | const len_ty = self.air.typeOf(bin_op.rhs); | 1513 | const len_ty = self.air.typeOf(bin_op.rhs); |
| 1514 | 1514 | ||
| 1515 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 1515 | const ptr_bits = self.target.ptrBitWidth(); |
| 1516 | const ptr_bytes = @divExact(ptr_bits, 8); | 1516 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 1517 | 1517 | ||
| 1518 | const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst); | 1518 | const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst); |
| ... | @@ -3362,7 +3362,7 @@ fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3362,7 +3362,7 @@ fn airSlicePtr(self: *Self, inst: Air.Inst.Index) !void { |
| 3362 | fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { | 3362 | fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { |
| 3363 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 3363 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 3364 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 3364 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 3365 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 3365 | const ptr_bits = self.target.ptrBitWidth(); |
| 3366 | const ptr_bytes = @divExact(ptr_bits, 8); | 3366 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 3367 | const mcv = try self.resolveInst(ty_op.operand); | 3367 | const mcv = try self.resolveInst(ty_op.operand); |
| 3368 | switch (mcv) { | 3368 | switch (mcv) { |
| ... | @@ -3386,7 +3386,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3386,7 +3386,7 @@ fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { |
| 3386 | fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { | 3386 | fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 3387 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 3387 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 3388 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 3388 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 3389 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 3389 | const ptr_bits = self.target.ptrBitWidth(); |
| 3390 | const ptr_bytes = @divExact(ptr_bits, 8); | 3390 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 3391 | const mcv = try self.resolveInst(ty_op.operand); | 3391 | const mcv = try self.resolveInst(ty_op.operand); |
| 3392 | switch (mcv) { | 3392 | switch (mcv) { |
| ... | @@ -4321,7 +4321,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier | ... | @@ -4321,7 +4321,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 4321 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { | 4321 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { |
| 4322 | const decl_block_index = try p9.seeDecl(func.owner_decl); | 4322 | const decl_block_index = try p9.seeDecl(func.owner_decl); |
| 4323 | const decl_block = p9.getDeclBlock(decl_block_index); | 4323 | const decl_block = p9.getDeclBlock(decl_block_index); |
| 4324 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 4324 | const ptr_bits = self.target.ptrBitWidth(); |
| 4325 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 4325 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 4326 | const got_addr = p9.bases.data; | 4326 | const got_addr = p9.bases.data; |
| 4327 | const got_index = decl_block.got_index.?; | 4327 | const got_index = decl_block.got_index.?; |
| ... | @@ -5929,7 +5929,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -5929,7 +5929,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 5929 | const array_ty = ptr_ty.childType(); | 5929 | const array_ty = ptr_ty.childType(); |
| 5930 | const array_len = @intCast(u32, array_ty.arrayLen()); | 5930 | const array_len = @intCast(u32, array_ty.arrayLen()); |
| 5931 | 5931 | ||
| 5932 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 5932 | const ptr_bits = self.target.ptrBitWidth(); |
| 5933 | const ptr_bytes = @divExact(ptr_bits, 8); | 5933 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 5934 | 5934 | ||
| 5935 | const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst); | 5935 | const stack_offset = try self.allocMem(ptr_bytes * 2, ptr_bytes * 2, inst); |
src/arch/arm/CodeGen.zig+1-1| ... | @@ -1035,7 +1035,7 @@ fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst | ... | @@ -1035,7 +1035,7 @@ fn allocRegOrMem(self: *Self, elem_ty: Type, reg_ok: bool, maybe_inst: ?Air.Inst |
| 1035 | 1035 | ||
| 1036 | if (reg_ok) { | 1036 | if (reg_ok) { |
| 1037 | // Make sure the type can fit in a register before we try to allocate one. | 1037 | // Make sure the type can fit in a register before we try to allocate one. |
| 1038 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 1038 | const ptr_bits = self.target.ptrBitWidth(); |
| 1039 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 1039 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 1040 | if (abi_size <= ptr_bytes) { | 1040 | if (abi_size <= ptr_bytes) { |
| 1041 | if (self.register_manager.tryAllocReg(maybe_inst, gp)) |reg| { | 1041 | if (self.register_manager.tryAllocReg(maybe_inst, gp)) |reg| { |
src/arch/riscv64/CodeGen.zig+1-1| ... | @@ -826,7 +826,7 @@ fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue { | ... | @@ -826,7 +826,7 @@ fn allocRegOrMem(self: *Self, inst: Air.Inst.Index, reg_ok: bool) !MCValue { |
| 826 | 826 | ||
| 827 | if (reg_ok) { | 827 | if (reg_ok) { |
| 828 | // Make sure the type can fit in a register before we try to allocate one. | 828 | // Make sure the type can fit in a register before we try to allocate one. |
| 829 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 829 | const ptr_bits = self.target.ptrBitWidth(); |
| 830 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 830 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 831 | if (abi_size <= ptr_bytes) { | 831 | if (abi_size <= ptr_bytes) { |
| 832 | if (self.register_manager.tryAllocReg(inst, gp)) |reg| { | 832 | if (self.register_manager.tryAllocReg(inst, gp)) |reg| { |
src/arch/riscv64/abi.zig+1-1| ... | @@ -9,7 +9,7 @@ pub const Class = enum { memory, byval, integer, double_integer }; | ... | @@ -9,7 +9,7 @@ pub const Class = enum { memory, byval, integer, double_integer }; |
| 9 | pub fn classifyType(ty: Type, target: std.Target) Class { | 9 | pub fn classifyType(ty: Type, target: std.Target) Class { |
| 10 | std.debug.assert(ty.hasRuntimeBitsIgnoreComptime()); | 10 | std.debug.assert(ty.hasRuntimeBitsIgnoreComptime()); |
| 11 | 11 | ||
| 12 | const max_byval_size = target.cpu.arch.ptrBitWidth() * 2; | 12 | const max_byval_size = target.ptrBitWidth() * 2; |
| 13 | switch (ty.zigTypeTag()) { | 13 | switch (ty.zigTypeTag()) { |
| 14 | .Struct => { | 14 | .Struct => { |
| 15 | const bit_size = ty.bitSize(target); | 15 | const bit_size = ty.bitSize(target); |
src/arch/sparc64/CodeGen.zig+4-4| ... | @@ -876,7 +876,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -876,7 +876,7 @@ fn airArrayToSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 876 | const array_ty = ptr_ty.childType(); | 876 | const array_ty = ptr_ty.childType(); |
| 877 | const array_len = @intCast(u32, array_ty.arrayLen()); | 877 | const array_len = @intCast(u32, array_ty.arrayLen()); |
| 878 | 878 | ||
| 879 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 879 | const ptr_bits = self.target.ptrBitWidth(); |
| 880 | const ptr_bytes = @divExact(ptr_bits, 8); | 880 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 881 | 881 | ||
| 882 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); | 882 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); |
| ... | @@ -2241,7 +2241,7 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2241,7 +2241,7 @@ fn airPtrElemPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 2241 | fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { | 2241 | fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 2242 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 2242 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2243 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 2243 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2244 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 2244 | const ptr_bits = self.target.ptrBitWidth(); |
| 2245 | const ptr_bytes = @divExact(ptr_bits, 8); | 2245 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 2246 | const mcv = try self.resolveInst(ty_op.operand); | 2246 | const mcv = try self.resolveInst(ty_op.operand); |
| 2247 | switch (mcv) { | 2247 | switch (mcv) { |
| ... | @@ -2427,7 +2427,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2427,7 +2427,7 @@ fn airSlice(self: *Self, inst: Air.Inst.Index) !void { |
| 2427 | const len = try self.resolveInst(bin_op.rhs); | 2427 | const len = try self.resolveInst(bin_op.rhs); |
| 2428 | const len_ty = self.air.typeOf(bin_op.rhs); | 2428 | const len_ty = self.air.typeOf(bin_op.rhs); |
| 2429 | 2429 | ||
| 2430 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 2430 | const ptr_bits = self.target.ptrBitWidth(); |
| 2431 | const ptr_bytes = @divExact(ptr_bits, 8); | 2431 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 2432 | 2432 | ||
| 2433 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); | 2433 | const stack_offset = try self.allocMem(inst, ptr_bytes * 2, ptr_bytes * 2); |
| ... | @@ -2485,7 +2485,7 @@ fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2485,7 +2485,7 @@ fn airSliceElemVal(self: *Self, inst: Air.Inst.Index) !void { |
| 2485 | fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { | 2485 | fn airSliceLen(self: *Self, inst: Air.Inst.Index) !void { |
| 2486 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 2486 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2487 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { | 2487 | const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: { |
| 2488 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 2488 | const ptr_bits = self.target.ptrBitWidth(); |
| 2489 | const ptr_bytes = @divExact(ptr_bits, 8); | 2489 | const ptr_bytes = @divExact(ptr_bits, 8); |
| 2490 | const mcv = try self.resolveInst(ty_op.operand); | 2490 | const mcv = try self.resolveInst(ty_op.operand); |
| 2491 | switch (mcv) { | 2491 | switch (mcv) { |
src/arch/wasm/CodeGen.zig+1-1| ... | @@ -1684,7 +1684,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void { | ... | @@ -1684,7 +1684,7 @@ fn memcpy(func: *CodeGen, dst: WValue, src: WValue, len: WValue) !void { |
| 1684 | } | 1684 | } |
| 1685 | 1685 | ||
| 1686 | fn ptrSize(func: *const CodeGen) u16 { | 1686 | fn ptrSize(func: *const CodeGen) u16 { |
| 1687 | return @divExact(func.target.cpu.arch.ptrBitWidth(), 8); | 1687 | return @divExact(func.target.ptrBitWidth(), 8); |
| 1688 | } | 1688 | } |
| 1689 | 1689 | ||
| 1690 | fn arch(func: *const CodeGen) std.Target.Cpu.Arch { | 1690 | fn arch(func: *const CodeGen) std.Target.Cpu.Arch { |
src/arch/x86_64/CodeGen.zig+2-2| ... | @@ -4000,7 +4000,7 @@ fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -4000,7 +4000,7 @@ fn airPtrSliceLenPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 4000 | registerAlias(dst_reg, dst_abi_size), | 4000 | registerAlias(dst_reg, dst_abi_size), |
| 4001 | Memory.sib(.qword, .{ | 4001 | Memory.sib(.qword, .{ |
| 4002 | .base = .{ .reg = src_reg }, | 4002 | .base = .{ .reg = src_reg }, |
| 4003 | .disp = @divExact(self.target.cpu.arch.ptrBitWidth(), 8), | 4003 | .disp = @divExact(self.target.ptrBitWidth(), 8), |
| 4004 | }), | 4004 | }), |
| 4005 | ); | 4005 | ); |
| 4006 | 4006 | ||
| ... | @@ -8131,7 +8131,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier | ... | @@ -8131,7 +8131,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier |
| 8131 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { | 8131 | } else if (self.bin_file.cast(link.File.Plan9)) |p9| { |
| 8132 | const decl_block_index = try p9.seeDecl(owner_decl); | 8132 | const decl_block_index = try p9.seeDecl(owner_decl); |
| 8133 | const decl_block = p9.getDeclBlock(decl_block_index); | 8133 | const decl_block = p9.getDeclBlock(decl_block_index); |
| 8134 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); | 8134 | const ptr_bits = self.target.ptrBitWidth(); |
| 8135 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 8135 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 8136 | const got_addr = p9.bases.data; | 8136 | const got_addr = p9.bases.data; |
| 8137 | const got_index = decl_block.got_index.?; | 8137 | const got_index = decl_block.got_index.?; |
src/codegen.zig+6-6| ... | @@ -314,7 +314,7 @@ pub fn generateSymbol( | ... | @@ -314,7 +314,7 @@ pub fn generateSymbol( |
| 314 | }, | 314 | }, |
| 315 | .Pointer => switch (typed_value.val.tag()) { | 315 | .Pointer => switch (typed_value.val.tag()) { |
| 316 | .null_value => { | 316 | .null_value => { |
| 317 | switch (target.cpu.arch.ptrBitWidth()) { | 317 | switch (target.ptrBitWidth()) { |
| 318 | 32 => { | 318 | 32 => { |
| 319 | mem.writeInt(u32, try code.addManyAsArray(4), 0, endian); | 319 | mem.writeInt(u32, try code.addManyAsArray(4), 0, endian); |
| 320 | if (typed_value.ty.isSlice()) try code.appendNTimes(0xaa, 4); | 320 | if (typed_value.ty.isSlice()) try code.appendNTimes(0xaa, 4); |
| ... | @@ -328,7 +328,7 @@ pub fn generateSymbol( | ... | @@ -328,7 +328,7 @@ pub fn generateSymbol( |
| 328 | return Result.ok; | 328 | return Result.ok; |
| 329 | }, | 329 | }, |
| 330 | .zero, .one, .int_u64, .int_big_positive => { | 330 | .zero, .one, .int_u64, .int_big_positive => { |
| 331 | switch (target.cpu.arch.ptrBitWidth()) { | 331 | switch (target.ptrBitWidth()) { |
| 332 | 32 => { | 332 | 32 => { |
| 333 | const x = typed_value.val.toUnsignedInt(target); | 333 | const x = typed_value.val.toUnsignedInt(target); |
| 334 | mem.writeInt(u32, try code.addManyAsArray(4), @intCast(u32, x), endian); | 334 | mem.writeInt(u32, try code.addManyAsArray(4), @intCast(u32, x), endian); |
| ... | @@ -970,7 +970,7 @@ fn lowerDeclRef( | ... | @@ -970,7 +970,7 @@ fn lowerDeclRef( |
| 970 | return Result.ok; | 970 | return Result.ok; |
| 971 | } | 971 | } |
| 972 | 972 | ||
| 973 | const ptr_width = target.cpu.arch.ptrBitWidth(); | 973 | const ptr_width = target.ptrBitWidth(); |
| 974 | const decl = module.declPtr(decl_index); | 974 | const decl = module.declPtr(decl_index); |
| 975 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; | 975 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; |
| 976 | if (!is_fn_body and !decl.ty.hasRuntimeBits()) { | 976 | if (!is_fn_body and !decl.ty.hasRuntimeBits()) { |
| ... | @@ -1059,7 +1059,7 @@ fn genDeclRef( | ... | @@ -1059,7 +1059,7 @@ fn genDeclRef( |
| 1059 | log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(module), tv.val.fmtValue(tv.ty, module) }); | 1059 | log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(module), tv.val.fmtValue(tv.ty, module) }); |
| 1060 | 1060 | ||
| 1061 | const target = bin_file.options.target; | 1061 | const target = bin_file.options.target; |
| 1062 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 1062 | const ptr_bits = target.ptrBitWidth(); |
| 1063 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 1063 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 1064 | 1064 | ||
| 1065 | const decl = module.declPtr(decl_index); | 1065 | const decl = module.declPtr(decl_index); |
| ... | @@ -1137,7 +1137,7 @@ fn genUnnamedConst( | ... | @@ -1137,7 +1137,7 @@ fn genUnnamedConst( |
| 1137 | } else if (bin_file.cast(link.File.Coff)) |_| { | 1137 | } else if (bin_file.cast(link.File.Coff)) |_| { |
| 1138 | return GenResult.mcv(.{ .load_direct = local_sym_index }); | 1138 | return GenResult.mcv(.{ .load_direct = local_sym_index }); |
| 1139 | } else if (bin_file.cast(link.File.Plan9)) |p9| { | 1139 | } else if (bin_file.cast(link.File.Plan9)) |p9| { |
| 1140 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 1140 | const ptr_bits = target.ptrBitWidth(); |
| 1141 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 1141 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 1142 | const got_index = local_sym_index; // the plan9 backend returns the got_index | 1142 | const got_index = local_sym_index; // the plan9 backend returns the got_index |
| 1143 | const got_addr = p9.bases.data + got_index * ptr_bytes; | 1143 | const got_addr = p9.bases.data + got_index * ptr_bytes; |
| ... | @@ -1168,7 +1168,7 @@ pub fn genTypedValue( | ... | @@ -1168,7 +1168,7 @@ pub fn genTypedValue( |
| 1168 | return GenResult.mcv(.undef); | 1168 | return GenResult.mcv(.undef); |
| 1169 | 1169 | ||
| 1170 | const target = bin_file.options.target; | 1170 | const target = bin_file.options.target; |
| 1171 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 1171 | const ptr_bits = target.ptrBitWidth(); |
| 1172 | 1172 | ||
| 1173 | if (!typed_value.ty.isSlice()) { | 1173 | if (!typed_value.ty.isSlice()) { |
| 1174 | if (typed_value.val.castTag(.variable)) |payload| { | 1174 | if (typed_value.val.castTag(.variable)) |payload| { |
src/codegen/c/type.zig+1-1| ... | @@ -879,7 +879,7 @@ pub const CType = extern union { | ... | @@ -879,7 +879,7 @@ pub const CType = extern union { |
| 879 | .pointer_const, | 879 | .pointer_const, |
| 880 | .pointer_volatile, | 880 | .pointer_volatile, |
| 881 | .pointer_const_volatile, | 881 | .pointer_const_volatile, |
| 882 | => @divExact(target.cpu.arch.ptrBitWidth(), 8), | 882 | => @divExact(target.ptrBitWidth(), 8), |
| 883 | .uint16_t, .int16_t, .zig_f16 => 2, | 883 | .uint16_t, .int16_t, .zig_f16 => 2, |
| 884 | .uint32_t, .int32_t, .zig_f32 => 4, | 884 | .uint32_t, .int32_t, .zig_f32 => 4, |
| 885 | .uint64_t, .int64_t, .zig_f64 => 8, | 885 | .uint64_t, .int64_t, .zig_f64 => 8, |
src/codegen/llvm.zig+12-12| ... | @@ -591,7 +591,7 @@ pub const Object = struct { | ... | @@ -591,7 +591,7 @@ pub const Object = struct { |
| 591 | const target = mod.getTarget(); | 591 | const target = mod.getTarget(); |
| 592 | 592 | ||
| 593 | const llvm_ptr_ty = self.context.pointerType(0); // TODO: Address space | 593 | const llvm_ptr_ty = self.context.pointerType(0); // TODO: Address space |
| 594 | const llvm_usize_ty = self.context.intType(target.cpu.arch.ptrBitWidth()); | 594 | const llvm_usize_ty = self.context.intType(target.ptrBitWidth()); |
| 595 | const type_fields = [_]*llvm.Type{ | 595 | const type_fields = [_]*llvm.Type{ |
| 596 | llvm_ptr_ty, | 596 | llvm_ptr_ty, |
| 597 | llvm_usize_ty, | 597 | llvm_usize_ty, |
| ... | @@ -1114,7 +1114,7 @@ pub const Object = struct { | ... | @@ -1114,7 +1114,7 @@ pub const Object = struct { |
| 1114 | llvm_arg_i += 1; | 1114 | llvm_arg_i += 1; |
| 1115 | const field_ptr = builder.buildStructGEP(llvm_ty, arg_ptr, field_i, ""); | 1115 | const field_ptr = builder.buildStructGEP(llvm_ty, arg_ptr, field_i, ""); |
| 1116 | const store_inst = builder.buildStore(param, field_ptr); | 1116 | const store_inst = builder.buildStore(param, field_ptr); |
| 1117 | store_inst.setAlignment(target.cpu.arch.ptrBitWidth() / 8); | 1117 | store_inst.setAlignment(target.ptrBitWidth() / 8); |
| 1118 | } | 1118 | } |
| 1119 | 1119 | ||
| 1120 | const is_by_ref = isByRef(param_ty); | 1120 | const is_by_ref = isByRef(param_ty); |
| ... | @@ -1718,7 +1718,7 @@ pub const Object = struct { | ... | @@ -1718,7 +1718,7 @@ pub const Object = struct { |
| 1718 | defer gpa.free(name); | 1718 | defer gpa.free(name); |
| 1719 | const ptr_di_ty = dib.createPointerType( | 1719 | const ptr_di_ty = dib.createPointerType( |
| 1720 | elem_di_ty, | 1720 | elem_di_ty, |
| 1721 | target.cpu.arch.ptrBitWidth(), | 1721 | target.ptrBitWidth(), |
| 1722 | ty.ptrAlignment(target) * 8, | 1722 | ty.ptrAlignment(target) * 8, |
| 1723 | name, | 1723 | name, |
| 1724 | ); | 1724 | ); |
| ... | @@ -4071,7 +4071,7 @@ pub const DeclGen = struct { | ... | @@ -4071,7 +4071,7 @@ pub const DeclGen = struct { |
| 4071 | .Struct => { | 4071 | .Struct => { |
| 4072 | if (parent_ty.containerLayout() == .Packed) { | 4072 | if (parent_ty.containerLayout() == .Packed) { |
| 4073 | if (!byte_aligned) return parent_llvm_ptr; | 4073 | if (!byte_aligned) return parent_llvm_ptr; |
| 4074 | const llvm_usize = dg.context.intType(target.cpu.arch.ptrBitWidth()); | 4074 | const llvm_usize = dg.context.intType(target.ptrBitWidth()); |
| 4075 | const base_addr = parent_llvm_ptr.constPtrToInt(llvm_usize); | 4075 | const base_addr = parent_llvm_ptr.constPtrToInt(llvm_usize); |
| 4076 | // count bits of fields before this one | 4076 | // count bits of fields before this one |
| 4077 | const prev_bits = b: { | 4077 | const prev_bits = b: { |
| ... | @@ -4261,7 +4261,7 @@ pub const DeclGen = struct { | ... | @@ -4261,7 +4261,7 @@ pub const DeclGen = struct { |
| 4261 | // instruction is followed by a `wrap_optional`, it will return this value | 4261 | // instruction is followed by a `wrap_optional`, it will return this value |
| 4262 | // verbatim, and the result should test as non-null. | 4262 | // verbatim, and the result should test as non-null. |
| 4263 | const target = dg.module.getTarget(); | 4263 | const target = dg.module.getTarget(); |
| 4264 | const int = switch (target.cpu.arch.ptrBitWidth()) { | 4264 | const int = switch (target.ptrBitWidth()) { |
| 4265 | 16 => llvm_usize.constInt(0xaaaa, .False), | 4265 | 16 => llvm_usize.constInt(0xaaaa, .False), |
| 4266 | 32 => llvm_usize.constInt(0xaaaaaaaa, .False), | 4266 | 32 => llvm_usize.constInt(0xaaaaaaaa, .False), |
| 4267 | 64 => llvm_usize.constInt(0xaaaaaaaa_aaaaaaaa, .False), | 4267 | 64 => llvm_usize.constInt(0xaaaaaaaa_aaaaaaaa, .False), |
| ... | @@ -4910,7 +4910,7 @@ pub const FuncGen = struct { | ... | @@ -4910,7 +4910,7 @@ pub const FuncGen = struct { |
| 4910 | const i = @intCast(c_uint, i_usize); | 4910 | const i = @intCast(c_uint, i_usize); |
| 4911 | const field_ptr = self.builder.buildStructGEP(llvm_ty, arg_ptr, i, ""); | 4911 | const field_ptr = self.builder.buildStructGEP(llvm_ty, arg_ptr, i, ""); |
| 4912 | const load_inst = self.builder.buildLoad(field_ty, field_ptr, ""); | 4912 | const load_inst = self.builder.buildLoad(field_ty, field_ptr, ""); |
| 4913 | load_inst.setAlignment(target.cpu.arch.ptrBitWidth() / 8); | 4913 | load_inst.setAlignment(target.ptrBitWidth() / 8); |
| 4914 | llvm_args.appendAssumeCapacity(load_inst); | 4914 | llvm_args.appendAssumeCapacity(load_inst); |
| 4915 | } | 4915 | } |
| 4916 | }, | 4916 | }, |
| ... | @@ -5579,7 +5579,7 @@ pub const FuncGen = struct { | ... | @@ -5579,7 +5579,7 @@ pub const FuncGen = struct { |
| 5579 | const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload); | 5579 | const switch_br = self.air.extraData(Air.SwitchBr, pl_op.payload); |
| 5580 | const else_block = self.context.appendBasicBlock(self.llvm_func, "Else"); | 5580 | const else_block = self.context.appendBasicBlock(self.llvm_func, "Else"); |
| 5581 | const target = self.dg.module.getTarget(); | 5581 | const target = self.dg.module.getTarget(); |
| 5582 | const llvm_usize = self.context.intType(target.cpu.arch.ptrBitWidth()); | 5582 | const llvm_usize = self.context.intType(target.ptrBitWidth()); |
| 5583 | const cond_int = if (cond.typeOf().getTypeKind() == .Pointer) | 5583 | const cond_int = if (cond.typeOf().getTypeKind() == .Pointer) |
| 5584 | self.builder.buildPtrToInt(cond, llvm_usize, "") | 5584 | self.builder.buildPtrToInt(cond, llvm_usize, "") |
| 5585 | else | 5585 | else |
| ... | @@ -5787,7 +5787,7 @@ pub const FuncGen = struct { | ... | @@ -5787,7 +5787,7 @@ pub const FuncGen = struct { |
| 5787 | 5787 | ||
| 5788 | fn sliceOrArrayLenInBytes(fg: *FuncGen, ptr: *llvm.Value, ty: Type) *llvm.Value { | 5788 | fn sliceOrArrayLenInBytes(fg: *FuncGen, ptr: *llvm.Value, ty: Type) *llvm.Value { |
| 5789 | const target = fg.dg.module.getTarget(); | 5789 | const target = fg.dg.module.getTarget(); |
| 5790 | const llvm_usize_ty = fg.context.intType(target.cpu.arch.ptrBitWidth()); | 5790 | const llvm_usize_ty = fg.context.intType(target.ptrBitWidth()); |
| 5791 | switch (ty.ptrSize()) { | 5791 | switch (ty.ptrSize()) { |
| 5792 | .Slice => { | 5792 | .Slice => { |
| 5793 | const len = fg.builder.buildExtractValue(ptr, 1, ""); | 5793 | const len = fg.builder.buildExtractValue(ptr, 1, ""); |
| ... | @@ -6085,7 +6085,7 @@ pub const FuncGen = struct { | ... | @@ -6085,7 +6085,7 @@ pub const FuncGen = struct { |
| 6085 | if (field_offset == 0) { | 6085 | if (field_offset == 0) { |
| 6086 | return field_ptr; | 6086 | return field_ptr; |
| 6087 | } | 6087 | } |
| 6088 | const llvm_usize_ty = self.context.intType(target.cpu.arch.ptrBitWidth()); | 6088 | const llvm_usize_ty = self.context.intType(target.ptrBitWidth()); |
| 6089 | 6089 | ||
| 6090 | const field_ptr_int = self.builder.buildPtrToInt(field_ptr, llvm_usize_ty, ""); | 6090 | const field_ptr_int = self.builder.buildPtrToInt(field_ptr, llvm_usize_ty, ""); |
| 6091 | const base_ptr_int = self.builder.buildNUWSub(field_ptr_int, llvm_usize_ty.constInt(field_offset, .False), ""); | 6091 | const base_ptr_int = self.builder.buildNUWSub(field_ptr_int, llvm_usize_ty.constInt(field_offset, .False), ""); |
| ... | @@ -8534,7 +8534,7 @@ pub const FuncGen = struct { | ... | @@ -8534,7 +8534,7 @@ pub const FuncGen = struct { |
| 8534 | const body_block = self.context.appendBasicBlock(self.llvm_func, "InlineMemsetBody"); | 8534 | const body_block = self.context.appendBasicBlock(self.llvm_func, "InlineMemsetBody"); |
| 8535 | const end_block = self.context.appendBasicBlock(self.llvm_func, "InlineMemsetEnd"); | 8535 | const end_block = self.context.appendBasicBlock(self.llvm_func, "InlineMemsetEnd"); |
| 8536 | 8536 | ||
| 8537 | const llvm_usize_ty = self.context.intType(target.cpu.arch.ptrBitWidth()); | 8537 | const llvm_usize_ty = self.context.intType(target.ptrBitWidth()); |
| 8538 | const len = switch (ptr_ty.ptrSize()) { | 8538 | const len = switch (ptr_ty.ptrSize()) { |
| 8539 | .Slice => self.builder.buildExtractValue(dest_slice, 1, ""), | 8539 | .Slice => self.builder.buildExtractValue(dest_slice, 1, ""), |
| 8540 | .One => llvm_usize_ty.constInt(ptr_ty.childType().arrayLen(), .False), | 8540 | .One => llvm_usize_ty.constInt(ptr_ty.childType().arrayLen(), .False), |
| ... | @@ -10013,7 +10013,7 @@ pub const FuncGen = struct { | ... | @@ -10013,7 +10013,7 @@ pub const FuncGen = struct { |
| 10013 | fn valgrindMarkUndef(fg: *FuncGen, ptr: *llvm.Value, len: *llvm.Value) void { | 10013 | fn valgrindMarkUndef(fg: *FuncGen, ptr: *llvm.Value, len: *llvm.Value) void { |
| 10014 | const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545; | 10014 | const VG_USERREQ__MAKE_MEM_UNDEFINED = 1296236545; |
| 10015 | const target = fg.dg.module.getTarget(); | 10015 | const target = fg.dg.module.getTarget(); |
| 10016 | const usize_llvm_ty = fg.context.intType(target.cpu.arch.ptrBitWidth()); | 10016 | const usize_llvm_ty = fg.context.intType(target.ptrBitWidth()); |
| 10017 | const zero = usize_llvm_ty.constInt(0, .False); | 10017 | const zero = usize_llvm_ty.constInt(0, .False); |
| 10018 | const req = usize_llvm_ty.constInt(VG_USERREQ__MAKE_MEM_UNDEFINED, .False); | 10018 | const req = usize_llvm_ty.constInt(VG_USERREQ__MAKE_MEM_UNDEFINED, .False); |
| 10019 | const ptr_as_usize = fg.builder.buildPtrToInt(ptr, usize_llvm_ty, ""); | 10019 | const ptr_as_usize = fg.builder.buildPtrToInt(ptr, usize_llvm_ty, ""); |
| ... | @@ -10033,7 +10033,7 @@ pub const FuncGen = struct { | ... | @@ -10033,7 +10033,7 @@ pub const FuncGen = struct { |
| 10033 | const target = fg.dg.module.getTarget(); | 10033 | const target = fg.dg.module.getTarget(); |
| 10034 | if (!target_util.hasValgrindSupport(target)) return default_value; | 10034 | if (!target_util.hasValgrindSupport(target)) return default_value; |
| 10035 | 10035 | ||
| 10036 | const usize_llvm_ty = fg.context.intType(target.cpu.arch.ptrBitWidth()); | 10036 | const usize_llvm_ty = fg.context.intType(target.ptrBitWidth()); |
| 10037 | const usize_alignment = @intCast(c_uint, Type.usize.abiSize(target)); | 10037 | const usize_alignment = @intCast(c_uint, Type.usize.abiSize(target)); |
| 10038 | 10038 | ||
| 10039 | const array_llvm_ty = usize_llvm_ty.arrayType(6); | 10039 | const array_llvm_ty = usize_llvm_ty.arrayType(6); |
src/codegen/spirv.zig+2-2| ... | @@ -556,7 +556,7 @@ pub const DeclGen = struct { | ... | @@ -556,7 +556,7 @@ pub const DeclGen = struct { |
| 556 | // TODO: Double check pointer sizes here. | 556 | // TODO: Double check pointer sizes here. |
| 557 | // shared pointers might be u32... | 557 | // shared pointers might be u32... |
| 558 | const target = self.dg.getTarget(); | 558 | const target = self.dg.getTarget(); |
| 559 | const width = @divExact(target.cpu.arch.ptrBitWidth(), 8); | 559 | const width = @divExact(target.ptrBitWidth(), 8); |
| 560 | if (self.size % width != 0) { | 560 | if (self.size % width != 0) { |
| 561 | return self.dg.todo("misaligned pointer constants", .{}); | 561 | return self.dg.todo("misaligned pointer constants", .{}); |
| 562 | } | 562 | } |
| ... | @@ -1160,7 +1160,7 @@ pub const DeclGen = struct { | ... | @@ -1160,7 +1160,7 @@ pub const DeclGen = struct { |
| 1160 | 1160 | ||
| 1161 | /// Create an integer type that represents 'usize'. | 1161 | /// Create an integer type that represents 'usize'. |
| 1162 | fn sizeType(self: *DeclGen) !SpvType.Ref { | 1162 | fn sizeType(self: *DeclGen) !SpvType.Ref { |
| 1163 | return try self.intType(.unsigned, self.getTarget().cpu.arch.ptrBitWidth()); | 1163 | return try self.intType(.unsigned, self.getTarget().ptrBitWidth()); |
| 1164 | } | 1164 | } |
| 1165 | 1165 | ||
| 1166 | /// Generate a union type, optionally with a known field. If the tag alignment is greater | 1166 | /// Generate a union type, optionally with a known field. If the tag alignment is greater |
src/glibc.zig+9-9| ... | @@ -378,7 +378,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![ | ... | @@ -378,7 +378,7 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![ |
| 378 | const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le; | 378 | const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le; |
| 379 | const is_aarch64 = arch == .aarch64 or arch == .aarch64_be; | 379 | const is_aarch64 = arch == .aarch64 or arch == .aarch64_be; |
| 380 | const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64; | 380 | const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64; |
| 381 | const is_64 = arch.ptrBitWidth() == 64; | 381 | const is_64 = comp.getTarget().ptrBitWidth() == 64; |
| 382 | 382 | ||
| 383 | const s = path.sep_str; | 383 | const s = path.sep_str; |
| 384 | 384 | ||
| ... | @@ -435,7 +435,6 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![ | ... | @@ -435,7 +435,6 @@ fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![ |
| 435 | 435 | ||
| 436 | fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { | 436 | fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { |
| 437 | const target = comp.getTarget(); | 437 | const target = comp.getTarget(); |
| 438 | const arch = target.cpu.arch; | ||
| 439 | const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl"; | 438 | const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl"; |
| 440 | 439 | ||
| 441 | const s = path.sep_str; | 440 | const s = path.sep_str; |
| ... | @@ -444,11 +443,11 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ | ... | @@ -444,11 +443,11 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ |
| 444 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include")); | 443 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include")); |
| 445 | 444 | ||
| 446 | if (target.os.tag == .linux) { | 445 | if (target.os.tag == .linux) { |
| 447 | try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux")); | 446 | try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux")); |
| 448 | } | 447 | } |
| 449 | 448 | ||
| 450 | if (opt_nptl) |nptl| { | 449 | if (opt_nptl) |nptl| { |
| 451 | try add_include_dirs_arch(arena, args, arch, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps")); | 450 | try add_include_dirs_arch(arena, args, target, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps")); |
| 452 | } | 451 | } |
| 453 | 452 | ||
| 454 | if (target.os.tag == .linux) { | 453 | if (target.os.tag == .linux) { |
| ... | @@ -474,12 +473,12 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ | ... | @@ -474,12 +473,12 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ |
| 474 | try args.append("-I"); | 473 | try args.append("-I"); |
| 475 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv")); | 474 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv")); |
| 476 | 475 | ||
| 477 | try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix")); | 476 | try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix")); |
| 478 | 477 | ||
| 479 | try args.append("-I"); | 478 | try args.append("-I"); |
| 480 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix")); | 479 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix")); |
| 481 | 480 | ||
| 482 | try add_include_dirs_arch(arena, args, arch, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps")); | 481 | try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps")); |
| 483 | 482 | ||
| 484 | try args.append("-I"); | 483 | try args.append("-I"); |
| 485 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic")); | 484 | try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic")); |
| ... | @@ -489,7 +488,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ | ... | @@ -489,7 +488,7 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ |
| 489 | 488 | ||
| 490 | try args.append("-I"); | 489 | try args.append("-I"); |
| 491 | try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{ | 490 | try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{ |
| 492 | comp.zig_lib_directory.path.?, @tagName(arch), @tagName(target.os.tag), @tagName(target.abi), | 491 | comp.zig_lib_directory.path.?, @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi), |
| 493 | })); | 492 | })); |
| 494 | 493 | ||
| 495 | try args.append("-I"); | 494 | try args.append("-I"); |
| ... | @@ -508,15 +507,16 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ | ... | @@ -508,15 +507,16 @@ fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([ |
| 508 | fn add_include_dirs_arch( | 507 | fn add_include_dirs_arch( |
| 509 | arena: Allocator, | 508 | arena: Allocator, |
| 510 | args: *std.ArrayList([]const u8), | 509 | args: *std.ArrayList([]const u8), |
| 511 | arch: std.Target.Cpu.Arch, | 510 | target: std.Target, |
| 512 | opt_nptl: ?[]const u8, | 511 | opt_nptl: ?[]const u8, |
| 513 | dir: []const u8, | 512 | dir: []const u8, |
| 514 | ) error{OutOfMemory}!void { | 513 | ) error{OutOfMemory}!void { |
| 514 | const arch = target.cpu.arch; | ||
| 515 | const is_x86 = arch == .x86 or arch == .x86_64; | 515 | const is_x86 = arch == .x86 or arch == .x86_64; |
| 516 | const is_aarch64 = arch == .aarch64 or arch == .aarch64_be; | 516 | const is_aarch64 = arch == .aarch64 or arch == .aarch64_be; |
| 517 | const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le; | 517 | const is_ppc = arch == .powerpc or arch == .powerpc64 or arch == .powerpc64le; |
| 518 | const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64; | 518 | const is_sparc = arch == .sparc or arch == .sparcel or arch == .sparc64; |
| 519 | const is_64 = arch.ptrBitWidth() == 64; | 519 | const is_64 = target.ptrBitWidth() == 64; |
| 520 | 520 | ||
| 521 | const s = path.sep_str; | 521 | const s = path.sep_str; |
| 522 | 522 |
src/link/Coff.zig+1-1| ... | @@ -245,7 +245,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option | ... | @@ -245,7 +245,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { | 247 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { |
| 248 | const ptr_width: PtrWidth = switch (options.target.cpu.arch.ptrBitWidth()) { | 248 | const ptr_width: PtrWidth = switch (options.target.ptrBitWidth()) { |
| 249 | 0...32 => .p32, | 249 | 0...32 => .p32, |
| 250 | 33...64 => .p64, | 250 | 33...64 => .p64, |
| 251 | else => return error.UnsupportedCOFFArchitecture, | 251 | else => return error.UnsupportedCOFFArchitecture, |
src/link/Coff/lld.zig+1-1| ... | @@ -199,7 +199,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod | ... | @@ -199,7 +199,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 199 | } else if (target.cpu.arch == .x86_64) { | 199 | } else if (target.cpu.arch == .x86_64) { |
| 200 | try argv.append("-MACHINE:X64"); | 200 | try argv.append("-MACHINE:X64"); |
| 201 | } else if (target.cpu.arch.isARM()) { | 201 | } else if (target.cpu.arch.isARM()) { |
| 202 | if (target.cpu.arch.ptrBitWidth() == 32) { | 202 | if (target.ptrBitWidth() == 32) { |
| 203 | try argv.append("-MACHINE:ARM"); | 203 | try argv.append("-MACHINE:ARM"); |
| 204 | } else { | 204 | } else { |
| 205 | try argv.append("-MACHINE:ARM64"); | 205 | try argv.append("-MACHINE:ARM64"); |
src/link/Dwarf.zig+3-3| ... | @@ -260,7 +260,7 @@ pub const DeclState = struct { | ... | @@ -260,7 +260,7 @@ pub const DeclState = struct { |
| 260 | .Pointer => { | 260 | .Pointer => { |
| 261 | if (ty.isSlice()) { | 261 | if (ty.isSlice()) { |
| 262 | // Slices are structs: struct { .ptr = *, .len = N } | 262 | // Slices are structs: struct { .ptr = *, .len = N } |
| 263 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 263 | const ptr_bits = target.ptrBitWidth(); |
| 264 | const ptr_bytes = @intCast(u8, @divExact(ptr_bits, 8)); | 264 | const ptr_bytes = @intCast(u8, @divExact(ptr_bits, 8)); |
| 265 | // DW.AT.structure_type | 265 | // DW.AT.structure_type |
| 266 | try dbg_info_buffer.ensureUnusedCapacity(2); | 266 | try dbg_info_buffer.ensureUnusedCapacity(2); |
| ... | @@ -751,7 +751,7 @@ pub const DeclState = struct { | ... | @@ -751,7 +751,7 @@ pub const DeclState = struct { |
| 751 | .memory, | 751 | .memory, |
| 752 | .linker_load, | 752 | .linker_load, |
| 753 | => { | 753 | => { |
| 754 | const ptr_width = @intCast(u8, @divExact(target.cpu.arch.ptrBitWidth(), 8)); | 754 | const ptr_width = @intCast(u8, @divExact(target.ptrBitWidth(), 8)); |
| 755 | try dbg_info.ensureUnusedCapacity(2 + ptr_width); | 755 | try dbg_info.ensureUnusedCapacity(2 + ptr_width); |
| 756 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc | 756 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc |
| 757 | 1 + ptr_width + @boolToInt(is_ptr), | 757 | 1 + ptr_width + @boolToInt(is_ptr), |
| ... | @@ -928,7 +928,7 @@ const min_nop_size = 2; | ... | @@ -928,7 +928,7 @@ const min_nop_size = 2; |
| 928 | const ideal_factor = 3; | 928 | const ideal_factor = 3; |
| 929 | 929 | ||
| 930 | pub fn init(allocator: Allocator, bin_file: *File, target: std.Target) Dwarf { | 930 | pub fn init(allocator: Allocator, bin_file: *File, target: std.Target) Dwarf { |
| 931 | const ptr_width: PtrWidth = switch (target.cpu.arch.ptrBitWidth()) { | 931 | const ptr_width: PtrWidth = switch (target.ptrBitWidth()) { |
| 932 | 0...32 => .p32, | 932 | 0...32 => .p32, |
| 933 | 33...64 => .p64, | 933 | 33...64 => .p64, |
| 934 | else => unreachable, | 934 | else => unreachable, |
src/link/Elf.zig+6-6| ... | @@ -273,7 +273,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option | ... | @@ -273,7 +273,7 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { | 275 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 276 | const ptr_width: PtrWidth = switch (options.target.cpu.arch.ptrBitWidth()) { | 276 | const ptr_width: PtrWidth = switch (options.target.ptrBitWidth()) { |
| 277 | 0...32 => .p32, | 277 | 0...32 => .p32, |
| 278 | 33...64 => .p64, | 278 | 33...64 => .p64, |
| 279 | else => return error.UnsupportedELFArchitecture, | 279 | else => return error.UnsupportedELFArchitecture, |
| ... | @@ -474,7 +474,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -474,7 +474,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 474 | if (self.phdr_table_load_index == null) { | 474 | if (self.phdr_table_load_index == null) { |
| 475 | self.phdr_table_load_index = @intCast(u16, self.program_headers.items.len); | 475 | self.phdr_table_load_index = @intCast(u16, self.program_headers.items.len); |
| 476 | // TODO Same as for GOT | 476 | // TODO Same as for GOT |
| 477 | const phdr_addr: u64 = if (self.base.options.target.cpu.arch.ptrBitWidth() >= 32) 0x1000000 else 0x1000; | 477 | const phdr_addr: u64 = if (self.base.options.target.ptrBitWidth() >= 32) 0x1000000 else 0x1000; |
| 478 | const p_align = self.page_size; | 478 | const p_align = self.page_size; |
| 479 | try self.program_headers.append(gpa, .{ | 479 | try self.program_headers.append(gpa, .{ |
| 480 | .p_type = elf.PT_LOAD, | 480 | .p_type = elf.PT_LOAD, |
| ... | @@ -521,7 +521,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -521,7 +521,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 521 | // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at. | 521 | // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at. |
| 522 | // we'll need to re-use that function anyway, in case the GOT grows and overlaps something | 522 | // we'll need to re-use that function anyway, in case the GOT grows and overlaps something |
| 523 | // else in virtual memory. | 523 | // else in virtual memory. |
| 524 | const got_addr: u32 = if (self.base.options.target.cpu.arch.ptrBitWidth() >= 32) 0x4000000 else 0x8000; | 524 | const got_addr: u32 = if (self.base.options.target.ptrBitWidth() >= 32) 0x4000000 else 0x8000; |
| 525 | try self.program_headers.append(gpa, .{ | 525 | try self.program_headers.append(gpa, .{ |
| 526 | .p_type = elf.PT_LOAD, | 526 | .p_type = elf.PT_LOAD, |
| 527 | .p_offset = off, | 527 | .p_offset = off, |
| ... | @@ -544,7 +544,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -544,7 +544,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 544 | const off = self.findFreeSpace(file_size, p_align); | 544 | const off = self.findFreeSpace(file_size, p_align); |
| 545 | log.debug("found PT_LOAD RO free space 0x{x} to 0x{x}", .{ off, off + file_size }); | 545 | log.debug("found PT_LOAD RO free space 0x{x} to 0x{x}", .{ off, off + file_size }); |
| 546 | // TODO Same as for GOT | 546 | // TODO Same as for GOT |
| 547 | const rodata_addr: u32 = if (self.base.options.target.cpu.arch.ptrBitWidth() >= 32) 0xc000000 else 0xa000; | 547 | const rodata_addr: u32 = if (self.base.options.target.ptrBitWidth() >= 32) 0xc000000 else 0xa000; |
| 548 | try self.program_headers.append(gpa, .{ | 548 | try self.program_headers.append(gpa, .{ |
| 549 | .p_type = elf.PT_LOAD, | 549 | .p_type = elf.PT_LOAD, |
| 550 | .p_offset = off, | 550 | .p_offset = off, |
| ... | @@ -567,7 +567,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -567,7 +567,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 567 | const off = self.findFreeSpace(file_size, p_align); | 567 | const off = self.findFreeSpace(file_size, p_align); |
| 568 | log.debug("found PT_LOAD RW free space 0x{x} to 0x{x}", .{ off, off + file_size }); | 568 | log.debug("found PT_LOAD RW free space 0x{x} to 0x{x}", .{ off, off + file_size }); |
| 569 | // TODO Same as for GOT | 569 | // TODO Same as for GOT |
| 570 | const rwdata_addr: u32 = if (self.base.options.target.cpu.arch.ptrBitWidth() >= 32) 0x10000000 else 0xc000; | 570 | const rwdata_addr: u32 = if (self.base.options.target.ptrBitWidth() >= 32) 0x10000000 else 0xc000; |
| 571 | try self.program_headers.append(gpa, .{ | 571 | try self.program_headers.append(gpa, .{ |
| 572 | .p_type = elf.PT_LOAD, | 572 | .p_type = elf.PT_LOAD, |
| 573 | .p_offset = off, | 573 | .p_offset = off, |
| ... | @@ -3180,7 +3180,7 @@ fn ptrWidthBytes(self: Elf) u8 { | ... | @@ -3180,7 +3180,7 @@ fn ptrWidthBytes(self: Elf) u8 { |
| 3180 | /// Does not necessarily match `ptrWidthBytes` for example can be 2 bytes | 3180 | /// Does not necessarily match `ptrWidthBytes` for example can be 2 bytes |
| 3181 | /// in a 32-bit ELF file. | 3181 | /// in a 32-bit ELF file. |
| 3182 | fn archPtrWidthBytes(self: Elf) u8 { | 3182 | fn archPtrWidthBytes(self: Elf) u8 { |
| 3183 | return @intCast(u8, self.base.options.target.cpu.arch.ptrBitWidth() / 8); | 3183 | return @intCast(u8, self.base.options.target.ptrBitWidth() / 8); |
| 3184 | } | 3184 | } |
| 3185 | 3185 | ||
| 3186 | fn progHeaderTo32(phdr: elf.Elf64_Phdr) elf.Elf32_Phdr { | 3186 | fn progHeaderTo32(phdr: elf.Elf64_Phdr) elf.Elf32_Phdr { |
src/link/Elf/Atom.zig+1-1| ... | @@ -59,7 +59,7 @@ pub fn getOffsetTableAddress(self: Atom, elf_file: *Elf) u64 { | ... | @@ -59,7 +59,7 @@ pub fn getOffsetTableAddress(self: Atom, elf_file: *Elf) u64 { |
| 59 | const sym_index = self.getSymbolIndex().?; | 59 | const sym_index = self.getSymbolIndex().?; |
| 60 | const got_entry_index = elf_file.got_table.lookup.get(sym_index).?; | 60 | const got_entry_index = elf_file.got_table.lookup.get(sym_index).?; |
| 61 | const target = elf_file.base.options.target; | 61 | const target = elf_file.base.options.target; |
| 62 | const ptr_bits = target.cpu.arch.ptrBitWidth(); | 62 | const ptr_bits = target.ptrBitWidth(); |
| 63 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); | 63 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| 64 | const got = elf_file.program_headers.items[elf_file.phdr_got_index.?]; | 64 | const got = elf_file.program_headers.items[elf_file.phdr_got_index.?]; |
| 65 | return got.p_vaddr + got_entry_index * ptr_bytes; | 65 | return got.p_vaddr + got_entry_index * ptr_bytes; |
src/link/Plan9.zig+1-1| ... | @@ -183,7 +183,7 @@ pub fn defaultBaseAddrs(arch: std.Target.Cpu.Arch) Bases { | ... | @@ -183,7 +183,7 @@ pub fn defaultBaseAddrs(arch: std.Target.Cpu.Arch) Bases { |
| 183 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 { | 183 | pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 { |
| 184 | if (options.use_llvm) | 184 | if (options.use_llvm) |
| 185 | return error.LLVMBackendDoesNotSupportPlan9; | 185 | return error.LLVMBackendDoesNotSupportPlan9; |
| 186 | const sixtyfour_bit: bool = switch (options.target.cpu.arch.ptrBitWidth()) { | 186 | const sixtyfour_bit: bool = switch (options.target.ptrBitWidth()) { |
| 187 | 0...32 => false, | 187 | 0...32 => false, |
| 188 | 33...64 => true, | 188 | 33...64 => true, |
| 189 | else => return error.UnsupportedP9Architecture, | 189 | else => return error.UnsupportedP9Architecture, |
src/mingw.zig+1-1| ... | @@ -265,7 +265,7 @@ fn add_cc_args( | ... | @@ -265,7 +265,7 @@ fn add_cc_args( |
| 265 | }); | 265 | }); |
| 266 | 266 | ||
| 267 | const target = comp.getTarget(); | 267 | const target = comp.getTarget(); |
| 268 | if (target.cpu.arch.isARM() and target.cpu.arch.ptrBitWidth() == 32) { | 268 | if (target.cpu.arch.isARM() and target.ptrBitWidth() == 32) { |
| 269 | try args.append("-mfpu=vfp"); | 269 | try args.append("-mfpu=vfp"); |
| 270 | } | 270 | } |
| 271 | 271 |
src/musl.zig+1-1| ... | @@ -194,7 +194,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr | ... | @@ -194,7 +194,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr |
| 194 | const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{ | 194 | const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{ |
| 195 | @tagName(target.cpu.arch), | 195 | @tagName(target.cpu.arch), |
| 196 | }); | 196 | }); |
| 197 | const clang_argv: []const []const u8 = if (target.cpu.arch.ptrBitWidth() == 64) | 197 | const clang_argv: []const []const u8 = if (target.ptrBitWidth() == 64) |
| 198 | &[_][]const u8{ "-DPTR64", arch_define } | 198 | &[_][]const u8{ "-DPTR64", arch_define } |
| 199 | else | 199 | else |
| 200 | &[_][]const u8{arch_define}; | 200 | &[_][]const u8{arch_define}; |
src/type.zig+18-18| ... | @@ -2936,7 +2936,7 @@ pub const Type = extern union { | ... | @@ -2936,7 +2936,7 @@ pub const Type = extern union { |
| 2936 | .manyptr_const_u8_sentinel_0, | 2936 | .manyptr_const_u8_sentinel_0, |
| 2937 | .@"anyframe", | 2937 | .@"anyframe", |
| 2938 | .anyframe_T, | 2938 | .anyframe_T, |
| 2939 | => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }, | 2939 | => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 2940 | 2940 | ||
| 2941 | .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) }, | 2941 | .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) }, |
| 2942 | .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) }, | 2942 | .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) }, |
| ... | @@ -3007,7 +3007,7 @@ pub const Type = extern union { | ... | @@ -3007,7 +3007,7 @@ pub const Type = extern union { |
| 3007 | const child_type = ty.optionalChild(&buf); | 3007 | const child_type = ty.optionalChild(&buf); |
| 3008 | 3008 | ||
| 3009 | switch (child_type.zigTypeTag()) { | 3009 | switch (child_type.zigTypeTag()) { |
| 3010 | .Pointer => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }, | 3010 | .Pointer => return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 3011 | .ErrorSet => return abiAlignmentAdvanced(Type.anyerror, target, strat), | 3011 | .ErrorSet => return abiAlignmentAdvanced(Type.anyerror, target, strat), |
| 3012 | .NoReturn => return AbiAlignmentAdvanced{ .scalar = 0 }, | 3012 | .NoReturn => return AbiAlignmentAdvanced{ .scalar = 0 }, |
| 3013 | else => {}, | 3013 | else => {}, |
| ... | @@ -3069,7 +3069,7 @@ pub const Type = extern union { | ... | @@ -3069,7 +3069,7 @@ pub const Type = extern union { |
| 3069 | // We'll guess "pointer-aligned", if the struct has an | 3069 | // We'll guess "pointer-aligned", if the struct has an |
| 3070 | // underaligned pointer field then some allocations | 3070 | // underaligned pointer field then some allocations |
| 3071 | // might require explicit alignment. | 3071 | // might require explicit alignment. |
| 3072 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; | 3072 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }; |
| 3073 | } | 3073 | } |
| 3074 | _ = try sema.resolveTypeFields(ty); | 3074 | _ = try sema.resolveTypeFields(ty); |
| 3075 | } | 3075 | } |
| ... | @@ -3195,7 +3195,7 @@ pub const Type = extern union { | ... | @@ -3195,7 +3195,7 @@ pub const Type = extern union { |
| 3195 | // We'll guess "pointer-aligned", if the union has an | 3195 | // We'll guess "pointer-aligned", if the union has an |
| 3196 | // underaligned pointer field then some allocations | 3196 | // underaligned pointer field then some allocations |
| 3197 | // might require explicit alignment. | 3197 | // might require explicit alignment. |
| 3198 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }; | 3198 | return AbiAlignmentAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }; |
| 3199 | } | 3199 | } |
| 3200 | _ = try sema.resolveTypeFields(ty); | 3200 | _ = try sema.resolveTypeFields(ty); |
| 3201 | } | 3201 | } |
| ... | @@ -3419,17 +3419,17 @@ pub const Type = extern union { | ... | @@ -3419,17 +3419,17 @@ pub const Type = extern union { |
| 3419 | .manyptr_u8, | 3419 | .manyptr_u8, |
| 3420 | .manyptr_const_u8, | 3420 | .manyptr_const_u8, |
| 3421 | .manyptr_const_u8_sentinel_0, | 3421 | .manyptr_const_u8_sentinel_0, |
| 3422 | => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }, | 3422 | => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 3423 | 3423 | ||
| 3424 | .const_slice, | 3424 | .const_slice, |
| 3425 | .mut_slice, | 3425 | .mut_slice, |
| 3426 | .const_slice_u8, | 3426 | .const_slice_u8, |
| 3427 | .const_slice_u8_sentinel_0, | 3427 | .const_slice_u8_sentinel_0, |
| 3428 | => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2 }, | 3428 | => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, |
| 3429 | 3429 | ||
| 3430 | .pointer => switch (ty.castTag(.pointer).?.data.size) { | 3430 | .pointer => switch (ty.castTag(.pointer).?.data.size) { |
| 3431 | .Slice => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2 }, | 3431 | .Slice => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) * 2 }, |
| 3432 | else => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) }, | 3432 | else => return AbiSizeAdvanced{ .scalar = @divExact(target.ptrBitWidth(), 8) }, |
| 3433 | }, | 3433 | }, |
| 3434 | 3434 | ||
| 3435 | .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) }, | 3435 | .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) }, |
| ... | @@ -3702,20 +3702,20 @@ pub const Type = extern union { | ... | @@ -3702,20 +3702,20 @@ pub const Type = extern union { |
| 3702 | .usize, | 3702 | .usize, |
| 3703 | .@"anyframe", | 3703 | .@"anyframe", |
| 3704 | .anyframe_T, | 3704 | .anyframe_T, |
| 3705 | => return target.cpu.arch.ptrBitWidth(), | 3705 | => return target.ptrBitWidth(), |
| 3706 | 3706 | ||
| 3707 | .const_slice, | 3707 | .const_slice, |
| 3708 | .mut_slice, | 3708 | .mut_slice, |
| 3709 | => return target.cpu.arch.ptrBitWidth() * 2, | 3709 | => return target.ptrBitWidth() * 2, |
| 3710 | 3710 | ||
| 3711 | .const_slice_u8, | 3711 | .const_slice_u8, |
| 3712 | .const_slice_u8_sentinel_0, | 3712 | .const_slice_u8_sentinel_0, |
| 3713 | => return target.cpu.arch.ptrBitWidth() * 2, | 3713 | => return target.ptrBitWidth() * 2, |
| 3714 | 3714 | ||
| 3715 | .optional_single_const_pointer, | 3715 | .optional_single_const_pointer, |
| 3716 | .optional_single_mut_pointer, | 3716 | .optional_single_mut_pointer, |
| 3717 | => { | 3717 | => { |
| 3718 | return target.cpu.arch.ptrBitWidth(); | 3718 | return target.ptrBitWidth(); |
| 3719 | }, | 3719 | }, |
| 3720 | 3720 | ||
| 3721 | .single_const_pointer, | 3721 | .single_const_pointer, |
| ... | @@ -3725,18 +3725,18 @@ pub const Type = extern union { | ... | @@ -3725,18 +3725,18 @@ pub const Type = extern union { |
| 3725 | .c_const_pointer, | 3725 | .c_const_pointer, |
| 3726 | .c_mut_pointer, | 3726 | .c_mut_pointer, |
| 3727 | => { | 3727 | => { |
| 3728 | return target.cpu.arch.ptrBitWidth(); | 3728 | return target.ptrBitWidth(); |
| 3729 | }, | 3729 | }, |
| 3730 | 3730 | ||
| 3731 | .pointer => switch (ty.castTag(.pointer).?.data.size) { | 3731 | .pointer => switch (ty.castTag(.pointer).?.data.size) { |
| 3732 | .Slice => return target.cpu.arch.ptrBitWidth() * 2, | 3732 | .Slice => return target.ptrBitWidth() * 2, |
| 3733 | else => return target.cpu.arch.ptrBitWidth(), | 3733 | else => return target.ptrBitWidth(), |
| 3734 | }, | 3734 | }, |
| 3735 | 3735 | ||
| 3736 | .manyptr_u8, | 3736 | .manyptr_u8, |
| 3737 | .manyptr_const_u8, | 3737 | .manyptr_const_u8, |
| 3738 | .manyptr_const_u8_sentinel_0, | 3738 | .manyptr_const_u8_sentinel_0, |
| 3739 | => return target.cpu.arch.ptrBitWidth(), | 3739 | => return target.ptrBitWidth(), |
| 3740 | 3740 | ||
| 3741 | .c_char => return target.c_type_bit_size(.char), | 3741 | .c_char => return target.c_type_bit_size(.char), |
| 3742 | .c_short => return target.c_type_bit_size(.short), | 3742 | .c_short => return target.c_type_bit_size(.short), |
| ... | @@ -4624,8 +4624,8 @@ pub const Type = extern union { | ... | @@ -4624,8 +4624,8 @@ pub const Type = extern union { |
| 4624 | .i64 => return .{ .signedness = .signed, .bits = 64 }, | 4624 | .i64 => return .{ .signedness = .signed, .bits = 64 }, |
| 4625 | .u128 => return .{ .signedness = .unsigned, .bits = 128 }, | 4625 | .u128 => return .{ .signedness = .unsigned, .bits = 128 }, |
| 4626 | .i128 => return .{ .signedness = .signed, .bits = 128 }, | 4626 | .i128 => return .{ .signedness = .signed, .bits = 128 }, |
| 4627 | .usize => return .{ .signedness = .unsigned, .bits = target.cpu.arch.ptrBitWidth() }, | 4627 | .usize => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, |
| 4628 | .isize => return .{ .signedness = .signed, .bits = target.cpu.arch.ptrBitWidth() }, | 4628 | .isize => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, |
| 4629 | .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) }, | 4629 | .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) }, |
| 4630 | .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, | 4630 | .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) }, |
| 4631 | .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, | 4631 | .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) }, |
src/value.zig+1-1| ... | @@ -1922,7 +1922,7 @@ pub const Value = extern union { | ... | @@ -1922,7 +1922,7 @@ pub const Value = extern union { |
| 1922 | .variable, | 1922 | .variable, |
| 1923 | .eu_payload_ptr, | 1923 | .eu_payload_ptr, |
| 1924 | .opt_payload_ptr, | 1924 | .opt_payload_ptr, |
| 1925 | => return target.cpu.arch.ptrBitWidth(), | 1925 | => return target.ptrBitWidth(), |
| 1926 | 1926 | ||
| 1927 | else => { | 1927 | else => { |
| 1928 | var buffer: BigIntSpace = undefined; | 1928 | var buffer: BigIntSpace = undefined; |