| ... | @@ -1944,35 +1944,6 @@ pub const Cpu = struct { | ... | @@ -1944,35 +1944,6 @@ pub const Cpu = struct { |
| 1944 | return Model.baseline(arch, os).toCpu(arch); | 1944 | return Model.baseline(arch, os).toCpu(arch); |
| 1945 | } | 1945 | } |
| 1946 | | 1946 | |
| 1947 | /// Returns whether this architecture supports `address_space`. If `context` is `null`, this | | |
| 1948 | /// function simply answers the general question of whether the architecture has any concept | | |
| 1949 | /// of `address_space`; if non-`null`, the function additionally checks whether | | |
| 1950 | /// `address_space` is valid in that context. | | |
| 1951 | pub fn supportsAddressSpace( | | |
| 1952 | cpu: Cpu, | | |
| 1953 | address_space: std.builtin.AddressSpace, | | |
| 1954 | context: ?std.builtin.AddressSpace.Context, | | |
| 1955 | ) bool { | | |
| 1956 | const arch = cpu.arch; | | |
| 1957 | | | |
| 1958 | const is_nvptx = arch.isNvptx(); | | |
| 1959 | const is_spirv = arch.isSpirV(); | | |
| 1960 | const is_gpu = is_nvptx or is_spirv or arch == .amdgcn; | | |
| 1961 | | | |
| 1962 | return switch (address_space) { | | |
| 1963 | .generic => true, | | |
| 1964 | .fs, .gs, .ss => (arch == .x86_64 or arch == .x86) and (context == null or context == .pointer), | | |
| 1965 | .flash, .flash1, .flash2, .flash3, .flash4, .flash5 => arch == .avr, // TODO this should also check how many flash banks the cpu has | | |
| 1966 | .cog, .hub => arch == .propeller, | | |
| 1967 | .lut => arch == .propeller and cpu.has(.propeller, .p2), | | |
| 1968 | | | |
| 1969 | .global, .local, .shared => is_gpu, | | |
| 1970 | .constant => is_gpu and (context == null or context == .constant), | | |
| 1971 | .param => is_nvptx, | | |
| 1972 | .input, .output, .uniform, .push_constant, .storage_buffer, .physical_storage_buffer => is_spirv, | | |
| 1973 | }; | | |
| 1974 | } | | |
| 1975 | | | |
| 1976 | /// Returns true if `feature` is enabled. | 1947 | /// Returns true if `feature` is enabled. |
| 1977 | pub fn has(cpu: Cpu, comptime family: Arch.Family, feature: @field(Target, @tagName(family)).Feature) bool { | 1948 | pub fn has(cpu: Cpu, comptime family: Arch.Family, feature: @field(Target, @tagName(family)).Feature) bool { |
| 1978 | if (family != cpu.arch.family()) return false; | 1949 | if (family != cpu.arch.family()) return false; |
| ... | @@ -2132,6 +2103,35 @@ pub fn requiresLibC(target: *const Target) bool { | ... | @@ -2132,6 +2103,35 @@ pub fn requiresLibC(target: *const Target) bool { |
| 2132 | }; | 2103 | }; |
| 2133 | } | 2104 | } |
| 2134 | | 2105 | |
| | 2106 | /// Returns whether this target supports `address_space`. If `context` is `null`, this |
| | 2107 | /// function simply answers the general question of whether the target has any concept |
| | 2108 | /// of `address_space`; if non-`null`, the function additionally checks whether |
| | 2109 | /// `address_space` is valid in that context. |
| | 2110 | pub fn supportsAddressSpace( |
| | 2111 | target: Target, |
| | 2112 | address_space: std.builtin.AddressSpace, |
| | 2113 | context: ?std.builtin.AddressSpace.Context, |
| | 2114 | ) bool { |
| | 2115 | const arch = target.cpu.arch; |
| | 2116 | |
| | 2117 | const is_nvptx = arch.isNvptx(); |
| | 2118 | const is_spirv = arch.isSpirV(); |
| | 2119 | const is_gpu = is_nvptx or is_spirv or arch == .amdgcn; |
| | 2120 | |
| | 2121 | return switch (address_space) { |
| | 2122 | .generic => true, |
| | 2123 | .fs, .gs, .ss => (arch == .x86_64 or arch == .x86) and (context == null or context == .pointer), |
| | 2124 | .flash, .flash1, .flash2, .flash3, .flash4, .flash5 => arch == .avr, // TODO this should also check how many flash banks the cpu has |
| | 2125 | .cog, .hub => arch == .propeller, |
| | 2126 | .lut => arch == .propeller and std.Target.propeller.featureSetHas(target.cpu.features, .p2), |
| | 2127 | |
| | 2128 | .global, .local, .shared => is_gpu, |
| | 2129 | .constant => is_gpu and (context == null or context == .constant), |
| | 2130 | .param => is_nvptx, |
| | 2131 | .input, .output, .uniform, .push_constant, .storage_buffer, .physical_storage_buffer => is_spirv, |
| | 2132 | }; |
| | 2133 | } |
| | 2134 | |
| 2135 | pub const DynamicLinker = struct { | 2135 | pub const DynamicLinker = struct { |
| 2136 | /// Contains the memory used to store the dynamic linker path. This field | 2136 | /// Contains the memory used to store the dynamic linker path. This field |
| 2137 | /// should not be used directly. See `get` and `set`. This field exists so | 2137 | /// should not be used directly. See `get` and `set`. This field exists so |