aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-08-20 02:53:29 +0200
committerRobin Voetter <robin@voetter.nl>2021-09-20 02:29:03 +0200
commitcd9f6001af407a6961281cbe9c658cfe94b81ecb (patch)
tree348a4612ec8bcc0b89368955932615cecc6f4634 /src/Module.zig
parent60231086508d26689d53b8bc545e8fe98cad966d (diff)
downloadzig-cd9f6001af407a6961281cbe9c658cfe94b81ecb.tar.gz
zig-cd9f6001af407a6961281cbe9c658cfe94b81ecb.zip
Address Spaces: decl_ref, *?T => *T, and *(E!T) -> *T
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 957987b895..83b9a600d0 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -353,7 +353,7 @@ pub const Decl = struct {
/// to require re-analysis.
outdated,
},
- /// Whether `typed_value`, `align_val`, `linksection_val` and `has_addrspace` are populated.
+ /// Whether `typed_value`, `align_val`, `linksection_val` and `addrspace` are populated.
has_tv: bool,
/// If `true` it means the `Decl` is the resource owner of the type/value associated
/// with it. That means when `Decl` is destroyed, the cleanup code should additionally
@@ -4401,6 +4401,34 @@ pub fn ptrType(
});
}
+/// Create a pointer type with an explicit address space. This function might return results
+/// of either simplePtrType or ptrType, depending on the address space.
+/// TODO(Snektron) unify ptrType functions.
+pub fn simplePtrTypeWithAddressSpace(
+ arena: *Allocator,
+ elem_ty: Type,
+ mutable: bool,
+ size: std.builtin.TypeInfo.Pointer.Size,
+ address_space: std.builtin.AddressSpace,
+) Allocator.Error!Type {
+ switch (address_space) {
+ .generic => return simplePtrType(arena, elem_ty, mutable, size),
+ else => return ptrType(
+ arena,
+ elem_ty,
+ null,
+ 0,
+ address_space,
+ 0,
+ 0,
+ mutable,
+ false,
+ false,
+ size,
+ ),
+ }
+}
+
pub fn optionalType(arena: *Allocator, child_type: Type) Allocator.Error!Type {
switch (child_type.tag()) {
.single_const_pointer => return Type.Tag.optional_single_const_pointer.create(