| ... | ... | @@ -59,14 +59,14 @@ pub const Target = struct { |
| 59 | 59 | plan9, |
| 60 | 60 | other, |
| 61 | 61 | |
| 62 | | pub fn isDarwin(tag: Tag) bool { |
| 62 | pub inline fn isDarwin(tag: Tag) bool { |
| 63 | 63 | return switch (tag) { |
| 64 | 64 | .ios, .macos, .watchos, .tvos => true, |
| 65 | 65 | else => false, |
| 66 | 66 | }; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | | pub fn isBSD(tag: Tag) bool { |
| 69 | pub inline fn isBSD(tag: Tag) bool { |
| 70 | 70 | return tag.isDarwin() or switch (tag) { |
| 71 | 71 | .kfreebsd, .freebsd, .openbsd, .netbsd, .dragonfly => true, |
| 72 | 72 | else => false, |
| ... | ... | @@ -135,7 +135,7 @@ pub const Target = struct { |
| 135 | 135 | }; |
| 136 | 136 | |
| 137 | 137 | /// Returns whether the first version `self` is newer (greater) than or equal to the second version `ver`. |
| 138 | | pub fn isAtLeast(self: WindowsVersion, ver: WindowsVersion) bool { |
| 138 | pub inline fn isAtLeast(self: WindowsVersion, ver: WindowsVersion) bool { |
| 139 | 139 | return @intFromEnum(self) >= @intFromEnum(ver); |
| 140 | 140 | } |
| 141 | 141 | |
| ... | ... | @@ -143,13 +143,13 @@ pub const Target = struct { |
| 143 | 143 | min: WindowsVersion, |
| 144 | 144 | max: WindowsVersion, |
| 145 | 145 | |
| 146 | | pub fn includesVersion(self: Range, ver: WindowsVersion) bool { |
| 146 | pub inline fn includesVersion(self: Range, ver: WindowsVersion) bool { |
| 147 | 147 | return @intFromEnum(ver) >= @intFromEnum(self.min) and @intFromEnum(ver) <= @intFromEnum(self.max); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /// Checks if system is guaranteed to be at least `version` or older than `version`. |
| 151 | 151 | /// Returns `null` if a runtime check is required. |
| 152 | | pub fn isAtLeast(self: Range, ver: WindowsVersion) ?bool { |
| 152 | pub inline fn isAtLeast(self: Range, ver: WindowsVersion) ?bool { |
| 153 | 153 | if (@intFromEnum(self.min) >= @intFromEnum(ver)) return true; |
| 154 | 154 | if (@intFromEnum(self.max) < @intFromEnum(ver)) return false; |
| 155 | 155 | return null; |
| ... | ... | @@ -187,13 +187,13 @@ pub const Target = struct { |
| 187 | 187 | range: Version.Range, |
| 188 | 188 | glibc: Version, |
| 189 | 189 | |
| 190 | | pub fn includesVersion(self: LinuxVersionRange, ver: Version) bool { |
| 190 | pub inline fn includesVersion(self: LinuxVersionRange, ver: Version) bool { |
| 191 | 191 | return self.range.includesVersion(ver); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /// Checks if system is guaranteed to be at least `version` or older than `version`. |
| 195 | 195 | /// Returns `null` if a runtime check is required. |
| 196 | | pub fn isAtLeast(self: LinuxVersionRange, ver: Version) ?bool { |
| 196 | pub inline fn isAtLeast(self: LinuxVersionRange, ver: Version) ?bool { |
| 197 | 197 | return self.range.isAtLeast(ver); |
| 198 | 198 | } |
| 199 | 199 | }; |
| ... | ... | @@ -360,7 +360,7 @@ pub const Target = struct { |
| 360 | 360 | |
| 361 | 361 | /// Provides a tagged union. `Target` does not store the tag because it is |
| 362 | 362 | /// redundant with the OS tag; this function abstracts that part away. |
| 363 | | pub fn getVersionRange(self: Os) TaggedVersionRange { |
| 363 | pub inline fn getVersionRange(self: Os) TaggedVersionRange { |
| 364 | 364 | switch (self.tag) { |
| 365 | 365 | .linux => return TaggedVersionRange{ .linux = self.version_range.linux }, |
| 366 | 366 | .windows => return TaggedVersionRange{ .windows = self.version_range.windows }, |
| ... | ... | @@ -382,7 +382,7 @@ pub const Target = struct { |
| 382 | 382 | |
| 383 | 383 | /// Checks if system is guaranteed to be at least `version` or older than `version`. |
| 384 | 384 | /// Returns `null` if a runtime check is required. |
| 385 | | pub fn isAtLeast(self: Os, comptime tag: Tag, version: anytype) ?bool { |
| 385 | pub inline fn isAtLeast(self: Os, comptime tag: Tag, version: anytype) ?bool { |
| 386 | 386 | if (self.tag != tag) return false; |
| 387 | 387 | |
| 388 | 388 | return switch (tag) { |
| ... | ... | @@ -395,7 +395,7 @@ pub const Target = struct { |
| 395 | 395 | /// On Darwin, we always link libSystem which contains libc. |
| 396 | 396 | /// Similarly on FreeBSD and NetBSD we always link system libc |
| 397 | 397 | /// since this is the stable syscall interface. |
| 398 | | pub fn requiresLibC(os: Os) bool { |
| 398 | pub inline fn requiresLibC(os: Os) bool { |
| 399 | 399 | return switch (os.tag) { |
| 400 | 400 | .freebsd, |
| 401 | 401 | .netbsd, |
| ... | ... | @@ -569,21 +569,21 @@ pub const Target = struct { |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | | pub fn isGnu(abi: Abi) bool { |
| 572 | pub inline fn isGnu(abi: Abi) bool { |
| 573 | 573 | return switch (abi) { |
| 574 | 574 | .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => true, |
| 575 | 575 | else => false, |
| 576 | 576 | }; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | | pub fn isMusl(abi: Abi) bool { |
| 579 | pub inline fn isMusl(abi: Abi) bool { |
| 580 | 580 | return switch (abi) { |
| 581 | 581 | .musl, .musleabi, .musleabihf => true, |
| 582 | 582 | else => false, |
| 583 | 583 | }; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | | pub fn floatAbi(abi: Abi) FloatAbi { |
| 586 | pub inline fn floatAbi(abi: Abi) FloatAbi { |
| 587 | 587 | return switch (abi) { |
| 588 | 588 | .gnueabihf, |
| 589 | 589 | .eabihf, |
| ... | ... | @@ -871,95 +871,95 @@ pub const Target = struct { |
| 871 | 871 | // map one-to-one with the ZigLLVM_ArchType enum. |
| 872 | 872 | spu_2, |
| 873 | 873 | |
| 874 | | pub fn isX86(arch: Arch) bool { |
| 874 | pub inline fn isX86(arch: Arch) bool { |
| 875 | 875 | return switch (arch) { |
| 876 | 876 | .x86, .x86_64 => true, |
| 877 | 877 | else => false, |
| 878 | 878 | }; |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | | pub fn isARM(arch: Arch) bool { |
| 881 | pub inline fn isARM(arch: Arch) bool { |
| 882 | 882 | return switch (arch) { |
| 883 | 883 | .arm, .armeb => true, |
| 884 | 884 | else => false, |
| 885 | 885 | }; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | | pub fn isAARCH64(arch: Arch) bool { |
| 888 | pub inline fn isAARCH64(arch: Arch) bool { |
| 889 | 889 | return switch (arch) { |
| 890 | 890 | .aarch64, .aarch64_be, .aarch64_32 => true, |
| 891 | 891 | else => false, |
| 892 | 892 | }; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | | pub fn isThumb(arch: Arch) bool { |
| 895 | pub inline fn isThumb(arch: Arch) bool { |
| 896 | 896 | return switch (arch) { |
| 897 | 897 | .thumb, .thumbeb => true, |
| 898 | 898 | else => false, |
| 899 | 899 | }; |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | | pub fn isArmOrThumb(arch: Arch) bool { |
| 902 | pub inline fn isArmOrThumb(arch: Arch) bool { |
| 903 | 903 | return arch.isARM() or arch.isThumb(); |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | | pub fn isWasm(arch: Arch) bool { |
| 906 | pub inline fn isWasm(arch: Arch) bool { |
| 907 | 907 | return switch (arch) { |
| 908 | 908 | .wasm32, .wasm64 => true, |
| 909 | 909 | else => false, |
| 910 | 910 | }; |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | | pub fn isRISCV(arch: Arch) bool { |
| 913 | pub inline fn isRISCV(arch: Arch) bool { |
| 914 | 914 | return switch (arch) { |
| 915 | 915 | .riscv32, .riscv64 => true, |
| 916 | 916 | else => false, |
| 917 | 917 | }; |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | | pub fn isMIPS(arch: Arch) bool { |
| 920 | pub inline fn isMIPS(arch: Arch) bool { |
| 921 | 921 | return switch (arch) { |
| 922 | 922 | .mips, .mipsel, .mips64, .mips64el => true, |
| 923 | 923 | else => false, |
| 924 | 924 | }; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | | pub fn isPPC(arch: Arch) bool { |
| 927 | pub inline fn isPPC(arch: Arch) bool { |
| 928 | 928 | return switch (arch) { |
| 929 | 929 | .powerpc, .powerpcle => true, |
| 930 | 930 | else => false, |
| 931 | 931 | }; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | | pub fn isPPC64(arch: Arch) bool { |
| 934 | pub inline fn isPPC64(arch: Arch) bool { |
| 935 | 935 | return switch (arch) { |
| 936 | 936 | .powerpc64, .powerpc64le => true, |
| 937 | 937 | else => false, |
| 938 | 938 | }; |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | | pub fn isSPARC(arch: Arch) bool { |
| 941 | pub inline fn isSPARC(arch: Arch) bool { |
| 942 | 942 | return switch (arch) { |
| 943 | 943 | .sparc, .sparcel, .sparc64 => true, |
| 944 | 944 | else => false, |
| 945 | 945 | }; |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | | pub fn isSpirV(arch: Arch) bool { |
| 948 | pub inline fn isSpirV(arch: Arch) bool { |
| 949 | 949 | return switch (arch) { |
| 950 | 950 | .spirv32, .spirv64 => true, |
| 951 | 951 | else => false, |
| 952 | 952 | }; |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | | pub fn isBpf(arch: Arch) bool { |
| 955 | pub inline fn isBpf(arch: Arch) bool { |
| 956 | 956 | return switch (arch) { |
| 957 | 957 | .bpfel, .bpfeb => true, |
| 958 | 958 | else => false, |
| 959 | 959 | }; |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | | pub fn isNvptx(arch: Arch) bool { |
| 962 | pub inline fn isNvptx(arch: Arch) bool { |
| 963 | 963 | return switch (arch) { |
| 964 | 964 | .nvptx, .nvptx64 => true, |
| 965 | 965 | else => false, |
| ... | ... | @@ -975,7 +975,7 @@ pub const Target = struct { |
| 975 | 975 | return error.UnknownCpuModel; |
| 976 | 976 | } |
| 977 | 977 | |
| 978 | | pub fn toElfMachine(arch: Arch) std.elf.EM { |
| 978 | pub inline fn toElfMachine(arch: Arch) std.elf.EM { |
| 979 | 979 | return switch (arch) { |
| 980 | 980 | .avr => .AVR, |
| 981 | 981 | .msp430 => .MSP430, |
| ... | ... | @@ -1040,7 +1040,7 @@ pub const Target = struct { |
| 1040 | 1040 | }; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | | pub fn toCoffMachine(arch: Arch) std.coff.MachineType { |
| 1043 | pub inline fn toCoffMachine(arch: Arch) std.coff.MachineType { |
| 1044 | 1044 | return switch (arch) { |
| 1045 | 1045 | .avr => .Unknown, |
| 1046 | 1046 | .msp430 => .Unknown, |
| ... | ... | @@ -1105,7 +1105,7 @@ pub const Target = struct { |
| 1105 | 1105 | }; |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | | pub fn endian(arch: Arch) std.builtin.Endian { |
| 1108 | pub inline fn endian(arch: Arch) std.builtin.Endian { |
| 1109 | 1109 | return switch (arch) { |
| 1110 | 1110 | .avr, |
| 1111 | 1111 | .arm, |
| ... | ... | @@ -1176,7 +1176,7 @@ pub const Target = struct { |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /// Returns whether this architecture supports the address space |
| 1179 | | pub fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool { |
| 1179 | pub inline fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool { |
| 1180 | 1180 | const is_nvptx = arch == .nvptx or arch == .nvptx64; |
| 1181 | 1181 | const is_spirv = arch == .spirv32 or arch == .spirv64; |
| 1182 | 1182 | const is_gpu = is_nvptx or is_spirv or arch == .amdgcn; |
| ... | ... | @@ -1418,51 +1418,51 @@ pub const Target = struct { |
| 1418 | 1418 | return libPrefix_os_abi(self.os.tag, self.abi); |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | | pub fn isMinGW(self: Target) bool { |
| 1421 | pub inline fn isMinGW(self: Target) bool { |
| 1422 | 1422 | return self.os.tag == .windows and self.isGnu(); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | | pub fn isGnu(self: Target) bool { |
| 1425 | pub inline fn isGnu(self: Target) bool { |
| 1426 | 1426 | return self.abi.isGnu(); |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | | pub fn isMusl(self: Target) bool { |
| 1429 | pub inline fn isMusl(self: Target) bool { |
| 1430 | 1430 | return self.abi.isMusl(); |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | | pub fn isAndroid(self: Target) bool { |
| 1433 | pub inline fn isAndroid(self: Target) bool { |
| 1434 | 1434 | return self.abi == .android; |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | | pub fn isWasm(self: Target) bool { |
| 1437 | pub inline fn isWasm(self: Target) bool { |
| 1438 | 1438 | return self.cpu.arch.isWasm(); |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | | pub fn isDarwin(self: Target) bool { |
| 1441 | pub inline fn isDarwin(self: Target) bool { |
| 1442 | 1442 | return self.os.tag.isDarwin(); |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | | pub fn isBSD(self: Target) bool { |
| 1445 | pub inline fn isBSD(self: Target) bool { |
| 1446 | 1446 | return self.os.tag.isBSD(); |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | | pub fn isBpfFreestanding(self: Target) bool { |
| 1449 | pub inline fn isBpfFreestanding(self: Target) bool { |
| 1450 | 1450 | return self.cpu.arch.isBpf() and self.os.tag == .freestanding; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | | pub fn isGnuLibC_os_tag_abi(os_tag: Os.Tag, abi: Abi) bool { |
| 1453 | pub inline fn isGnuLibC_os_tag_abi(os_tag: Os.Tag, abi: Abi) bool { |
| 1454 | 1454 | return os_tag == .linux and abi.isGnu(); |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | | pub fn isGnuLibC(self: Target) bool { |
| 1457 | pub inline fn isGnuLibC(self: Target) bool { |
| 1458 | 1458 | return isGnuLibC_os_tag_abi(self.os.tag, self.abi); |
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | | pub fn supportsNewStackCall(self: Target) bool { |
| 1461 | pub inline fn supportsNewStackCall(self: Target) bool { |
| 1462 | 1462 | return !self.cpu.arch.isWasm(); |
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | | pub fn isSpirV(self: Target) bool { |
| 1465 | pub inline fn isSpirV(self: Target) bool { |
| 1466 | 1466 | return self.cpu.arch.isSpirV(); |
| 1467 | 1467 | } |
| 1468 | 1468 | |
| ... | ... | @@ -1472,11 +1472,11 @@ pub const Target = struct { |
| 1472 | 1472 | soft_fp, |
| 1473 | 1473 | }; |
| 1474 | 1474 | |
| 1475 | | pub fn getFloatAbi(self: Target) FloatAbi { |
| 1475 | pub inline fn getFloatAbi(self: Target) FloatAbi { |
| 1476 | 1476 | return self.abi.floatAbi(); |
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | | pub fn hasDynamicLinker(self: Target) bool { |
| 1479 | pub inline fn hasDynamicLinker(self: Target) bool { |
| 1480 | 1480 | if (self.cpu.arch.isWasm()) { |
| 1481 | 1481 | return false; |
| 1482 | 1482 | } |
| ... | ... | @@ -1832,7 +1832,7 @@ pub const Target = struct { |
| 1832 | 1832 | }; |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | | pub fn ptrBitWidth(target: Target) u16 { |
| 1835 | pub inline fn ptrBitWidth(target: Target) u16 { |
| 1836 | 1836 | switch (target.abi) { |
| 1837 | 1837 | .gnux32, .muslx32, .gnuabin32, .gnuilp32 => return 32, |
| 1838 | 1838 | .gnuabi64 => return 64, |
| ... | ... | @@ -1909,7 +1909,7 @@ pub const Target = struct { |
| 1909 | 1909 | } |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | | pub fn stackAlignment(target: Target) u16 { |
| 1912 | pub inline fn stackAlignment(target: Target) u16 { |
| 1913 | 1913 | return switch (target.cpu.arch) { |
| 1914 | 1914 | .m68k => 2, |
| 1915 | 1915 | .amdgcn => 4, |
| ... | ... | @@ -1954,7 +1954,7 @@ pub const Target = struct { |
| 1954 | 1954 | /// Default signedness of `char` for the native C compiler for this target |
| 1955 | 1955 | /// Note that char signedness is implementation-defined and many compilers provide |
| 1956 | 1956 | /// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char |
| 1957 | | pub fn charSignedness(target: Target) std.builtin.Signedness { |
| 1957 | pub inline fn charSignedness(target: Target) std.builtin.Signedness { |
| 1958 | 1958 | switch (target.cpu.arch) { |
| 1959 | 1959 | .aarch64, |
| 1960 | 1960 | .aarch64_32, |
| ... | ... | @@ -1993,7 +1993,7 @@ pub const Target = struct { |
| 1993 | 1993 | longdouble, |
| 1994 | 1994 | }; |
| 1995 | 1995 | |
| 1996 | | pub fn c_type_byte_size(t: Target, c_type: CType) u16 { |
| 1996 | pub inline fn c_type_byte_size(t: Target, c_type: CType) u16 { |
| 1997 | 1997 | return switch (c_type) { |
| 1998 | 1998 | .char, |
| 1999 | 1999 | .short, |
| ... | ... | @@ -2019,7 +2019,7 @@ pub const Target = struct { |
| 2019 | 2019 | }; |
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | | pub fn c_type_bit_size(target: Target, c_type: CType) u16 { |
| 2022 | pub inline fn c_type_bit_size(target: Target, c_type: CType) u16 { |
| 2023 | 2023 | switch (target.os.tag) { |
| 2024 | 2024 | .freestanding, .other => switch (target.cpu.arch) { |
| 2025 | 2025 | .msp430 => switch (c_type) { |
| ... | ... | @@ -2333,7 +2333,7 @@ pub const Target = struct { |
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | 2335 | |
| 2336 | | pub fn c_type_alignment(target: Target, c_type: CType) u16 { |
| 2336 | pub inline fn c_type_alignment(target: Target, c_type: CType) u16 { |
| 2337 | 2337 | // Overrides for unusual alignments |
| 2338 | 2338 | switch (target.cpu.arch) { |
| 2339 | 2339 | .avr => return 1, |
| ... | ... | @@ -2440,7 +2440,7 @@ pub const Target = struct { |
| 2440 | 2440 | ); |
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | | pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 { |
| 2443 | pub inline fn c_type_preferred_alignment(target: Target, c_type: CType) u16 { |
| 2444 | 2444 | // Overrides for unusual alignments |
| 2445 | 2445 | switch (target.cpu.arch) { |
| 2446 | 2446 | .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) { |