| ... | ... | @@ -1576,34 +1576,6 @@ pub const Cpu = struct { |
| 1576 | 1576 | }; |
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | | /// Returns whether this architecture supports `address_space`. If `context` is `null`, this |
| 1580 | | /// function simply answers the general question of whether the architecture has any concept |
| 1581 | | /// of `address_space`; if non-`null`, the function additionally checks whether |
| 1582 | | /// `address_space` is valid in that context. |
| 1583 | | pub fn supportsAddressSpace( |
| 1584 | | arch: Arch, |
| 1585 | | address_space: std.builtin.AddressSpace, |
| 1586 | | context: ?std.builtin.AddressSpace.Context, |
| 1587 | | ) bool { |
| 1588 | | const is_nvptx = arch.isNvptx(); |
| 1589 | | const is_spirv = arch.isSpirV(); |
| 1590 | | const is_gpu = is_nvptx or is_spirv or arch == .amdgcn; |
| 1591 | | return switch (address_space) { |
| 1592 | | .generic => true, |
| 1593 | | .fs, .gs, .ss => (arch == .x86_64 or arch == .x86) and (context == null or context == .pointer), |
| 1594 | | .global, .local, .shared => is_gpu, |
| 1595 | | .constant => is_gpu and (context == null or context == .constant), |
| 1596 | | .param => is_nvptx, |
| 1597 | | .input, .output, .uniform, .push_constant, .storage_buffer => is_spirv, |
| 1598 | | // TODO this should also check how many flash banks the cpu has |
| 1599 | | .flash, .flash1, .flash2, .flash3, .flash4, .flash5 => arch == .avr, |
| 1600 | | |
| 1601 | | // Propeller address spaces: |
| 1602 | | .cog, .hub => arch == .propeller, |
| 1603 | | .lut => arch == .propeller, // TODO: This should check for the `p2` CPU feature. |
| 1604 | | }; |
| 1605 | | } |
| 1606 | | |
| 1607 | 1579 | /// Returns a name that matches the lib/std/target/* source file name. |
| 1608 | 1580 | pub fn genericName(arch: Arch) [:0]const u8 { |
| 1609 | 1581 | return switch (arch) { |
| ... | ... | @@ -1999,6 +1971,35 @@ pub const Cpu = struct { |
| 1999 | 1971 | pub fn baseline(arch: Arch, os: Os) Cpu { |
| 2000 | 1972 | return Model.baseline(arch, os).toCpu(arch); |
| 2001 | 1973 | } |
| 1974 | |
| 1975 | /// Returns whether this architecture supports `address_space`. If `context` is `null`, this |
| 1976 | /// function simply answers the general question of whether the architecture has any concept |
| 1977 | /// of `address_space`; if non-`null`, the function additionally checks whether |
| 1978 | /// `address_space` is valid in that context. |
| 1979 | pub fn supportsAddressSpace( |
| 1980 | cpu: Cpu, |
| 1981 | address_space: std.builtin.AddressSpace, |
| 1982 | context: ?std.builtin.AddressSpace.Context, |
| 1983 | ) bool { |
| 1984 | const arch = cpu.arch; |
| 1985 | |
| 1986 | const is_nvptx = arch.isNvptx(); |
| 1987 | const is_spirv = arch.isSpirV(); |
| 1988 | const is_gpu = is_nvptx or is_spirv or arch == .amdgcn; |
| 1989 | |
| 1990 | return switch (address_space) { |
| 1991 | .generic => true, |
| 1992 | .fs, .gs, .ss => (arch == .x86_64 or arch == .x86) and (context == null or context == .pointer), |
| 1993 | .flash, .flash1, .flash2, .flash3, .flash4, .flash5 => arch == .avr, // TODO this should also check how many flash banks the cpu has |
| 1994 | .cog, .hub => arch == .propeller, |
| 1995 | .lut => arch == .propeller and std.Target.propeller.featureSetHas(cpu.features, .p2), |
| 1996 | |
| 1997 | .global, .local, .shared => is_gpu, |
| 1998 | .constant => is_gpu and (context == null or context == .constant), |
| 1999 | .param => is_nvptx, |
| 2000 | .input, .output, .uniform, .push_constant, .storage_buffer => is_spirv, |
| 2001 | }; |
| 2002 | } |
| 2002 | 2003 | }; |
| 2003 | 2004 | |
| 2004 | 2005 | pub fn zigTriple(target: Target, allocator: Allocator) Allocator.Error![]u8 { |