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.
pub fn supportsAddressSpace(
target: Target,
address_space: std.builtin.AddressSpace,
context: ?AddressSpaceContext,
) bool
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),
};
}