| ... | @@ -1878,6 +1878,9 @@ pub const Cpu = struct { | ... | @@ -1878,6 +1878,9 @@ pub const Cpu = struct { |
| 1878 | }; | 1878 | }; |
| 1879 | } | 1879 | } |
| 1880 | | 1880 | |
| | 1881 | /// Returns the most bare-bones CPU model that is valid for `arch`. Note that this function |
| | 1882 | /// can return CPU models that are understood by LLVM, but *not* understood by Clang. If |
| | 1883 | /// Clang compatibility is important, consider using `baseline` instead. |
| 1881 | pub fn generic(arch: Arch) *const Model { | 1884 | pub fn generic(arch: Arch) *const Model { |
| 1882 | const S = struct { | 1885 | const S = struct { |
| 1883 | const generic_model = Model{ | 1886 | const generic_model = Model{ |
| ... | @@ -1887,10 +1890,11 @@ pub const Cpu = struct { | ... | @@ -1887,10 +1890,11 @@ pub const Cpu = struct { |
| 1887 | }; | 1890 | }; |
| 1888 | }; | 1891 | }; |
| 1889 | return switch (arch) { | 1892 | return switch (arch) { |
| | 1893 | .amdgcn => &amdgpu.cpu.gfx600, |
| 1890 | .arc => &arc.cpu.generic, | 1894 | .arc => &arc.cpu.generic, |
| 1891 | .arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic, | 1895 | .arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic, |
| 1892 | .aarch64, .aarch64_be => &aarch64.cpu.generic, | 1896 | .aarch64, .aarch64_be => &aarch64.cpu.generic, |
| 1893 | .avr => &avr.cpu.avr2, | 1897 | .avr => &avr.cpu.avr1, |
| 1894 | .bpfel, .bpfeb => &bpf.cpu.generic, | 1898 | .bpfel, .bpfeb => &bpf.cpu.generic, |
| 1895 | .csky => &csky.cpu.generic, | 1899 | .csky => &csky.cpu.generic, |
| 1896 | .hexagon => &hexagon.cpu.generic, | 1900 | .hexagon => &hexagon.cpu.generic, |
| ... | @@ -1901,13 +1905,10 @@ pub const Cpu = struct { | ... | @@ -1901,13 +1905,10 @@ pub const Cpu = struct { |
| 1901 | .mips, .mipsel => &mips.cpu.mips32, | 1905 | .mips, .mipsel => &mips.cpu.mips32, |
| 1902 | .mips64, .mips64el => &mips.cpu.mips64, | 1906 | .mips64, .mips64el => &mips.cpu.mips64, |
| 1903 | .msp430 => &msp430.cpu.generic, | 1907 | .msp430 => &msp430.cpu.generic, |
| 1904 | .powerpc => &powerpc.cpu.ppc, | 1908 | .powerpc, .powerpcle => &powerpc.cpu.ppc, |
| 1905 | .powerpcle => &powerpc.cpu.ppc, | 1909 | .powerpc64, .powerpc64le => &powerpc.cpu.ppc64, |
| 1906 | .powerpc64 => &powerpc.cpu.ppc64, | | |
| 1907 | .powerpc64le => &powerpc.cpu.ppc64le, | | |
| 1908 | .propeller1 => &propeller.cpu.generic, | 1910 | .propeller1 => &propeller.cpu.generic, |
| 1909 | .propeller2 => &propeller.cpu.generic, | 1911 | .propeller2 => &propeller.cpu.generic, |
| 1910 | .amdgcn => &amdgpu.cpu.generic, | | |
| 1911 | .riscv32 => &riscv.cpu.generic_rv32, | 1912 | .riscv32 => &riscv.cpu.generic_rv32, |
| 1912 | .riscv64 => &riscv.cpu.generic_rv64, | 1913 | .riscv64 => &riscv.cpu.generic_rv64, |
| 1913 | .spirv, .spirv32, .spirv64 => &spirv.cpu.generic, | 1914 | .spirv, .spirv32, .spirv64 => &spirv.cpu.generic, |
| ... | @@ -1928,8 +1929,17 @@ pub const Cpu = struct { | ... | @@ -1928,8 +1929,17 @@ pub const Cpu = struct { |
| 1928 | }; | 1929 | }; |
| 1929 | } | 1930 | } |
| 1930 | | 1931 | |
| | 1932 | /// Returns a conservative CPU model for `arch` that is expected to be compatible with the |
| | 1933 | /// vast majority of hardware available. This function is guaranteed to return CPU models |
| | 1934 | /// that are understood by both LLVM and Clang, unlike `generic`. |
| | 1935 | /// |
| | 1936 | /// For certain `os` values, this function will additionally bump the baseline higher than |
| | 1937 | /// the baseline would be for `arch` in isolation; for example, for `aarch64-macos`, the |
| | 1938 | /// baseline is considered to be `apple_m1`. To avoid this behavior entirely, pass |
| | 1939 | /// `Os.Tag.freestanding`. |
| 1931 | pub fn baseline(arch: Arch, os: Os) *const Model { | 1940 | pub fn baseline(arch: Arch, os: Os) *const Model { |
| 1932 | return switch (arch) { | 1941 | return switch (arch) { |
| | 1942 | .amdgcn => &amdgpu.cpu.gfx906, |
| 1933 | .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline, | 1943 | .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline, |
| 1934 | .aarch64 => switch (os.tag) { | 1944 | .aarch64 => switch (os.tag) { |
| 1935 | .bridgeos, .driverkit, .macos => &aarch64.cpu.apple_m1, | 1945 | .bridgeos, .driverkit, .macos => &aarch64.cpu.apple_m1, |
| ... | @@ -1938,14 +1948,31 @@ pub const Cpu = struct { | ... | @@ -1938,14 +1948,31 @@ pub const Cpu = struct { |
| 1938 | .watchos => &aarch64.cpu.apple_s4, | 1948 | .watchos => &aarch64.cpu.apple_s4, |
| 1939 | else => generic(arch), | 1949 | else => generic(arch), |
| 1940 | }, | 1950 | }, |
| | 1951 | .avr => &avr.cpu.avr2, |
| | 1952 | .bpfel, .bpfeb => &bpf.cpu.v1, |
| | 1953 | .csky => &csky.cpu.ck810, // gcc/clang do not have a generic csky model. |
| 1941 | .hexagon => &hexagon.cpu.hexagonv60, // gcc/clang do not have a generic hexagon model. | 1954 | .hexagon => &hexagon.cpu.hexagonv60, // gcc/clang do not have a generic hexagon model. |
| | 1955 | .lanai => &lanai.cpu.v11, // clang does not have a generic lanai model. |
| | 1956 | .loongarch64 => &loongarch.cpu.loongarch64, |
| | 1957 | .m68k => &m68k.cpu.M68000, |
| | 1958 | .mips, .mipsel => &mips.cpu.mips32r2, |
| | 1959 | .mips64, .mips64el => &mips.cpu.mips64r2, |
| | 1960 | .msp430 => &msp430.cpu.msp430, |
| | 1961 | .nvptx, .nvptx64 => &nvptx.cpu.sm_52, |
| | 1962 | .powerpc64le => &powerpc.cpu.ppc64le, |
| 1942 | .riscv32 => &riscv.cpu.baseline_rv32, | 1963 | .riscv32 => &riscv.cpu.baseline_rv32, |
| 1943 | .riscv64 => &riscv.cpu.baseline_rv64, | 1964 | .riscv64 => &riscv.cpu.baseline_rv64, |
| 1944 | .x86 => &x86.cpu.pentium4, | | |
| 1945 | .nvptx, .nvptx64 => &nvptx.cpu.sm_20, | | |
| 1946 | .s390x => &s390x.cpu.arch8, // gcc/clang do not have a generic s390x model. | 1965 | .s390x => &s390x.cpu.arch8, // gcc/clang do not have a generic s390x model. |
| 1947 | .sparc => &sparc.cpu.v9, // glibc does not work with 'plain' v8. | 1966 | .sparc => &sparc.cpu.v9, // glibc does not work with 'plain' v8. |
| 1948 | .loongarch64 => &loongarch.cpu.loongarch64, | 1967 | .x86 => &x86.cpu.pentium4, |
| | 1968 | .x86_64 => switch (os.tag) { |
| | 1969 | .driverkit => &x86.cpu.nehalem, |
| | 1970 | .ios, .macos, .tvos, .visionos, .watchos => &x86.cpu.core2, |
| | 1971 | .ps4 => &x86.cpu.btver2, |
| | 1972 | .ps5 => &x86.cpu.znver2, |
| | 1973 | else => generic(arch), |
| | 1974 | }, |
| | 1975 | .xcore => &xcore.cpu.xs1b_generic, |
| 1949 | | 1976 | |
| 1950 | else => generic(arch), | 1977 | else => generic(arch), |
| 1951 | }; | 1978 | }; |