Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

baseline

Public Function
std.Target.lanai.CpuModel.baseline
pub fn baseline(arch: Arch, os: Os) *const Model

Returns a conservative CPU model for arch that is expected to be compatible with the vast majority of hardware available. This function is guaranteed to return CPU models that are understood by both LLVM and Clang, unlike generic.

For certain os values, this function will additionally bump the baseline higher than the baseline would be for arch in isolation; for example, for aarch64-macos, the baseline is considered to be apple_m1. To avoid this behavior entirely, pass Os.Tag.freestanding.

Params

File

Target.zig:2083
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
        pub fn baseline(arch: Arch, os: Os) *const Model {
            return switch (arch) {
                .alpha => &alpha.cpu.ev6,
                .amdgcn => &amdgcn.cpu.gfx906,
                .arm => switch (os.tag) {
                    .@"3ds" => &arm.cpu.mpcore,
                    .vita => &arm.cpu.cortex_a9,
                    .gba => &arm.cpu.arm7tdmi,
                    else => &arm.cpu.baseline,
                },
                .thumb => switch (os.tag) {
                    .vita => &arm.cpu.cortex_a9,
                    .gba => &arm.cpu.arm7tdmi,
                    else => &arm.cpu.baseline,
                },
                .armeb, .thumbeb => &arm.cpu.baseline,
                .aarch64 => switch (os.tag) {
                    .haiku => &aarch64.cpu.cortex_a55,
                    .driverkit, .maccatalyst, .macos => &aarch64.cpu.apple_m1,
                    .ios, .tvos => &aarch64.cpu.apple_a7,
                    .visionos => &aarch64.cpu.apple_m2,
                    .watchos => &aarch64.cpu.apple_s4,
                    .@"switch" => &aarch64.cpu.cortex_a57,
                    else => generic(arch),
                },
                .avr => &avr.cpu.avr2,
                .bpfel, .bpfeb => &bpf.cpu.v3,
                .csky => &csky.cpu.ck810, // gcc/clang do not have a generic csky model.
                .hexagon => &hexagon.cpu.hexagonv68, // gcc/clang do not have a generic hexagon model.
                .hppa => &hppa.cpu.pa_7300lc,
                .kvx => &kvx.cpu.coolidge_v2,
                .lanai => &lanai.cpu.v11, // clang does not have a generic lanai model.
                .loongarch32 => &loongarch.cpu.la32v1_0,
                .loongarch64 => &loongarch.cpu.la64v1_0,
                .m68k => &m68k.cpu.M68030,
                .mips => &mips.cpu.mips32r2,
                .mipsel => switch (os.tag) {
                    .psx => &mips.cpu.r3000a,
                    .psp => &mips.cpu.allegrex,
                    else => &mips.cpu.mips32r2,
                },
                .mips64 => switch (os.tag) {
                    .openbsd => &mips.cpu.octeon,
                    else => &mips.cpu.mips64r2,
                },
                .mips64el => &mips.cpu.mips64r2,
                .msp430 => &msp430.cpu.msp430,
                .nvptx, .nvptx64 => &nvptx.cpu.sm_52,
                .powerpc => switch (os.tag) {
                    .openbsd, .wiiu => &powerpc.cpu.@"750",
                    else => generic(arch),
                },
                .powerpc64 => switch (os.tag) {
                    .linux, .freebsd => &powerpc.cpu.pwr8,
                    .openbsd => &powerpc.cpu.pwr9,
                    else => generic(arch),
                },
                .powerpc64le => &powerpc.cpu.ppc64le,
                .riscv32, .riscv32be => &riscv.cpu.baseline_rv32,
                .riscv64, .riscv64be => &riscv.cpu.baseline_rv64,
                .s390x => &s390x.cpu.arch11,
                .sparc => switch (os.tag) {
                    .linux => &sparc.cpu.v9, // glibc does not work with 'plain' v8.
                    else => generic(arch),
                },
                .sparc64 => &sparc.cpu.ultrasparc,
                .x86 => &x86.cpu.pentium4,
                .x86_64 => switch (os.tag) {
                    .driverkit, .maccatalyst => &x86.cpu.nehalem,
                    .macos => &x86.cpu.core2,
                    .ps4 => &x86.cpu.btver2,
                    .ps5 => &x86.cpu.znver2,
                    else => generic(arch),
                },
                .xcore => &xcore.cpu.xs1b_generic,
                .xtensa => &xtensa.cpu.esp32,
                .wasm32, .wasm64 => &wasm.cpu.lime1,

                else => generic(arch),
            };
        }