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

supportsAddressSpace

Public Function
std.Target.supportsAddressSpace
pub fn supportsAddressSpace(
    target: Target,
    address_space: std.builtin.AddressSpace,
    context: ?AddressSpaceContext,
) bool

Returns whether this target supports address_space. If context is null, this function simply answers the general question of whether the target has any concept of address_space; if non-null, the function additionally checks whether address_space is valid in that context.

Params

File

Target.zig:2370
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
pub fn supportsAddressSpace(
    target: Target,
    address_space: std.builtin.AddressSpace,
    context: ?AddressSpaceContext,
) bool {
    const arch = target.cpu.arch;

    const is_nvptx = arch.isNvptx();
    const is_spirv = arch.isSpirV();
    const is_gpu = is_nvptx or is_spirv or arch == .amdgcn;

    return switch (address_space) {
        .generic => true,
        .fs, .gs, .ss => (arch == .x86_64 or arch == .x86 or arch == .x86_16) and (context == null or context == .pointer),
        // Technically x86 can use segmentation...
        .far => (arch == .x86_16),

        .flash, .flash1, .flash2, .flash3, .flash4, .flash5 => arch == .avr, // TODO this should also check how many flash banks the cpu has
        .cog, .hub => arch == .propeller,
        .lut => arch == .propeller and std.Target.propeller.featureSetHas(target.cpu.features, .p2),

        .global, .local, .shared => is_gpu,
        .constant => (is_gpu and (context == null or context == .constant)) or
            (is_spirv and (context == null or context == .constant or context == .pointer)),
        .param => is_nvptx,
        .input, .output, .uniform, .push_constant, .storage_buffer => is_spirv,
        .physical_storage_buffer => arch == .spirv64,
        .externref, .funcref => target.cpu.has(.wasm, .reference_types),
    };
}