aboutsummaryrefslogtreecommitdiff
path: root/src/arch/sparc64/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-04-24 17:58:23 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-04-25 11:23:41 -0700
commit5378fdffdcc60a5273021bc9cfc5be917e87c992 (patch)
treeab4ceb8185b8a8fa3977b7fa76e1a49450f0aabb /src/arch/sparc64/CodeGen.zig
parentd604553ee0c32caa0632a01e263a34e31a95b2b3 (diff)
downloadzig-5378fdffdcc60a5273021bc9cfc5be917e87c992.tar.gz
zig-5378fdffdcc60a5273021bc9cfc5be917e87c992.zip
stage2: introduce store_safe AIR instruction
store: The value to store may be undefined, in which case the destination memory region has undefined bytes after this instruction is evaluated. In such case ignoring this instruction is legal lowering. store_safe: Same as `store`, except if the value to store is undefined, the memory region should be filled with 0xaa bytes, and any other safety metadata such as Valgrind integrations should be notified of this memory region being undefined.
Diffstat (limited to 'src/arch/sparc64/CodeGen.zig')
-rw-r--r--src/arch/sparc64/CodeGen.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
index 53e07b2103..cc5c9e9832 100644
--- a/src/arch/sparc64/CodeGen.zig
+++ b/src/arch/sparc64/CodeGen.zig
@@ -593,7 +593,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
.ptrtoint => try self.airPtrToInt(inst),
.ret => try self.airRet(inst),
.ret_load => try self.airRetLoad(inst),
- .store => try self.airStore(inst),
+ .store => try self.airStore(inst, false),
+ .store_safe => try self.airStore(inst, true),
.struct_field_ptr=> @panic("TODO try self.airStructFieldPtr(inst)"),
.struct_field_val=> try self.airStructFieldVal(inst),
.array_to_slice => try self.airArrayToSlice(inst),
@@ -2407,7 +2408,12 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
}
-fn airStore(self: *Self, inst: Air.Inst.Index) !void {
+fn airStore(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
+ if (safety) {
+ // TODO if the value is undef, write 0xaa bytes to dest
+ } else {
+ // TODO if the value is undef, don't lower this instruction
+ }
const bin_op = self.air.instructions.items(.data)[inst].bin_op;
const ptr = try self.resolveInst(bin_op.lhs);
const value = try self.resolveInst(bin_op.rhs);