aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2022-08-27 12:55:28 +0200
committerRobin Voetter <robin@voetter.nl>2022-10-12 20:36:14 +0200
commit9f14681473140cd79e6d38cb2bb46a90c1be1259 (patch)
tree29a1774bb986ef24679911bfb7de662a34d66ec1 /lib/std
parent5d429b03e3d43e937e2b517d594275034a873959 (diff)
downloadzig-9f14681473140cd79e6d38cb2bb46a90c1be1259.tar.gz
zig-9f14681473140cd79e6d38cb2bb46a90c1be1259.zip
stage2: check address space cast validity
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/target.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/std/target.zig b/lib/std/target.zig
index b6a8a8b9c0..139df629c5 100644
--- a/lib/std/target.zig
+++ b/lib/std/target.zig
@@ -1157,6 +1157,17 @@ pub const Target = struct {
};
}
+ /// Returns whether this architecture supporst the address space
+ pub fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool {
+ const is_nvptx = arch == .nvptx or arch == .nvptx64;
+ return switch (address_space) {
+ .generic => true,
+ .fs, .gs, .ss => arch == .x86_64 or arch == .i386,
+ .global, .constant, .local, .shared => arch == .amdgcn or is_nvptx,
+ .param => is_nvptx,
+ };
+ }
+
pub fn ptrBitWidth(arch: Arch) u16 {
switch (arch) {
.avr,