aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-05 16:32:38 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:42:28 -0700
commit9ec0017f460854300004ab263bf585c2d376d1fb (patch)
treedf586141cc238241a5ce4d9898a119c217baf78c /src/codegen
parent70a4b76acaef8d4062f4d5317af398929ea6c9c4 (diff)
downloadzig-9ec0017f460854300004ab263bf585c2d376d1fb.tar.gz
zig-9ec0017f460854300004ab263bf585c2d376d1fb.zip
stage2: migrate many pointer types to the InternPool
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig12
-rw-r--r--src/codegen/llvm.zig10
-rw-r--r--src/codegen/spirv.zig13
3 files changed, 19 insertions, 16 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index cd3974bc91..b0fb9fa480 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -6117,7 +6117,7 @@ fn airCmpxchg(f: *Function, inst: Air.Inst.Index, flavor: [*:0]const u8) !CValue
try writer.print("zig_cmpxchg_{s}((zig_atomic(", .{flavor});
try f.renderType(writer, ty);
try writer.writeByte(')');
- if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
+ if (ptr_ty.isVolatilePtr(mod)) try writer.writeAll(" volatile");
try writer.writeAll(" *)");
try f.writeCValue(writer, ptr, .Other);
try writer.writeAll(", ");
@@ -6159,7 +6159,7 @@ fn airCmpxchg(f: *Function, inst: Air.Inst.Index, flavor: [*:0]const u8) !CValue
try writer.print("zig_cmpxchg_{s}((zig_atomic(", .{flavor});
try f.renderType(writer, ty);
try writer.writeByte(')');
- if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
+ if (ptr_ty.isVolatilePtr(mod)) try writer.writeAll(" volatile");
try writer.writeAll(" *)");
try f.writeCValue(writer, ptr, .Other);
try writer.writeAll(", ");
@@ -6221,7 +6221,7 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
if (use_atomic) try writer.writeAll("zig_atomic(");
try f.renderType(writer, ty);
if (use_atomic) try writer.writeByte(')');
- if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
+ if (ptr_ty.isVolatilePtr(mod)) try writer.writeAll(" volatile");
try writer.writeAll(" *)");
try f.writeCValue(writer, ptr, .Other);
try writer.writeAll(", ");
@@ -6265,7 +6265,7 @@ fn airAtomicLoad(f: *Function, inst: Air.Inst.Index) !CValue {
try writer.writeAll(", (zig_atomic(");
try f.renderType(writer, ty);
try writer.writeByte(')');
- if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
+ if (ptr_ty.isVolatilePtr(mod)) try writer.writeAll(" volatile");
try writer.writeAll(" *)");
try f.writeCValue(writer, ptr, .Other);
try writer.writeAll(", ");
@@ -6299,7 +6299,7 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa
try writer.writeAll("zig_atomic_store((zig_atomic(");
try f.renderType(writer, ty);
try writer.writeByte(')');
- if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
+ if (ptr_ty.isVolatilePtr(mod)) try writer.writeAll(" volatile");
try writer.writeAll(" *)");
try f.writeCValue(writer, ptr, .Other);
try writer.writeAll(", ");
@@ -6365,7 +6365,7 @@ fn airMemset(f: *Function, inst: Air.Inst.Index, safety: bool) !CValue {
return .none;
}
- if (elem_abi_size > 1 or dest_ty.isVolatilePtr()) {
+ if (elem_abi_size > 1 or dest_ty.isVolatilePtr(mod)) {
// For the assignment in this loop, the array pointer needs to get
// casted to a regular pointer, otherwise an error like this occurs:
// error: array type 'uint32_t[20]' (aka 'unsigned int[20]') is not assignable
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 558534a651..7fa9b74334 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -7046,7 +7046,7 @@ pub const FuncGen = struct {
const elem_llvm_ty = try self.dg.lowerType(vector_ptr_ty.childType(mod));
const load_inst = self.builder.buildLoad(elem_llvm_ty, vector_ptr, "");
load_inst.setAlignment(vector_ptr_ty.ptrAlignment(mod));
- load_inst.setVolatile(llvm.Bool.fromBool(vector_ptr_ty.isVolatilePtr()));
+ load_inst.setVolatile(llvm.Bool.fromBool(vector_ptr_ty.isVolatilePtr(mod)));
break :blk load_inst;
};
const modified_vector = self.builder.buildInsertElement(loaded_vector, operand, index, "");
@@ -8221,7 +8221,7 @@ pub const FuncGen = struct {
const usize_llvm_ty = try self.dg.lowerType(Type.usize);
const len = usize_llvm_ty.constInt(operand_size, .False);
const dest_ptr_align = ptr_ty.ptrAlignment(mod);
- _ = self.builder.buildMemSet(dest_ptr, fill_byte, len, dest_ptr_align, ptr_ty.isVolatilePtr());
+ _ = self.builder.buildMemSet(dest_ptr, fill_byte, len, dest_ptr_align, ptr_ty.isVolatilePtr(mod));
if (safety and mod.comp.bin_file.options.valgrind) {
self.valgrindMarkUndef(dest_ptr, len);
}
@@ -8497,7 +8497,7 @@ pub const FuncGen = struct {
const dest_ptr_align = ptr_ty.ptrAlignment(mod);
const u8_llvm_ty = self.context.intType(8);
const dest_ptr = self.sliceOrArrayPtr(dest_slice, ptr_ty);
- const is_volatile = ptr_ty.isVolatilePtr();
+ const is_volatile = ptr_ty.isVolatilePtr(mod);
if (self.air.value(bin_op.rhs, mod)) |elem_val| {
if (elem_val.isUndefDeep()) {
@@ -8621,7 +8621,7 @@ pub const FuncGen = struct {
const len = self.sliceOrArrayLenInBytes(dest_slice, dest_ptr_ty);
const dest_ptr = self.sliceOrArrayPtr(dest_slice, dest_ptr_ty);
const mod = self.dg.module;
- const is_volatile = src_ptr_ty.isVolatilePtr() or dest_ptr_ty.isVolatilePtr();
+ const is_volatile = src_ptr_ty.isVolatilePtr(mod) or dest_ptr_ty.isVolatilePtr(mod);
_ = self.builder.buildMemCpy(
dest_ptr,
dest_ptr_ty.ptrAlignment(mod),
@@ -9894,7 +9894,7 @@ pub const FuncGen = struct {
if (!info.pointee_type.hasRuntimeBitsIgnoreComptime(mod)) return null;
const ptr_alignment = info.alignment(mod);
- const ptr_volatile = llvm.Bool.fromBool(ptr_ty.isVolatilePtr());
+ const ptr_volatile = llvm.Bool.fromBool(ptr_ty.isVolatilePtr(mod));
assert(info.vector_index != .runtime);
if (info.vector_index != .none) {
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 5fa81d19ff..27a79c1c45 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -1689,7 +1689,7 @@ pub const DeclGen = struct {
const indirect_value_ty_ref = try self.resolveType(value_ty, .indirect);
const result_id = self.spv.allocId();
const access = spec.MemoryAccess.Extended{
- .Volatile = ptr_ty.isVolatilePtr(),
+ .Volatile = ptr_ty.isVolatilePtr(mod),
};
try self.func.body.emit(self.spv.gpa, .OpLoad, .{
.id_result_type = self.typeId(indirect_value_ty_ref),
@@ -1705,7 +1705,7 @@ pub const DeclGen = struct {
const value_ty = ptr_ty.childType(mod);
const indirect_value_id = try self.convertToIndirect(value_ty, value_id);
const access = spec.MemoryAccess.Extended{
- .Volatile = ptr_ty.isVolatilePtr(),
+ .Volatile = ptr_ty.isVolatilePtr(mod),
};
try self.func.body.emit(self.spv.gpa, .OpStore, .{
.pointer = ptr_id,
@@ -2464,9 +2464,10 @@ pub const DeclGen = struct {
}
fn airSliceElemPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
+ const mod = self.module;
const bin_op = self.air.instructions.items(.data)[inst].bin_op;
const slice_ty = self.typeOf(bin_op.lhs);
- if (!slice_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
+ if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null;
const slice_id = try self.resolve(bin_op.lhs);
const index_id = try self.resolve(bin_op.rhs);
@@ -2479,9 +2480,10 @@ pub const DeclGen = struct {
}
fn airSliceElemVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
+ const mod = self.module;
const bin_op = self.air.instructions.items(.data)[inst].bin_op;
const slice_ty = self.typeOf(bin_op.lhs);
- if (!slice_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
+ if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null;
const slice_id = try self.resolve(bin_op.lhs);
const index_id = try self.resolve(bin_op.rhs);
@@ -2781,10 +2783,11 @@ pub const DeclGen = struct {
}
fn airLoad(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
+ const mod = self.module;
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
const ptr_ty = self.typeOf(ty_op.operand);
const operand = try self.resolve(ty_op.operand);
- if (!ptr_ty.isVolatilePtr() and self.liveness.isUnused(inst)) return null;
+ if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null;
return try self.load(ptr_ty, operand);
}