aboutsummaryrefslogtreecommitdiff
path: root/src/arch/sparc64/CodeGen.zig
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2022-06-16 01:32:02 +0700
committerKoakuma <koachan@protonmail.com>2022-06-24 21:19:33 +0700
commit36bfe4b7efedd1b030c335151b2d6a61bbeab1eb (patch)
tree026c5e3204905780be6984bd5e372c17d8493b9f /src/arch/sparc64/CodeGen.zig
parent18d61d691c0c28405a521422a590e6ea84d13c61 (diff)
downloadzig-36bfe4b7efedd1b030c335151b2d6a61bbeab1eb.tar.gz
zig-36bfe4b7efedd1b030c335151b2d6a61bbeab1eb.zip
stage2: sparc64: Implement airFence + SPARCv9 membar
Diffstat (limited to 'src/arch/sparc64/CodeGen.zig')
-rw-r--r--src/arch/sparc64/CodeGen.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
index 6f6137e030..b071f8ac59 100644
--- a/src/arch/sparc64/CodeGen.zig
+++ b/src/arch/sparc64/CodeGen.zig
@@ -578,7 +578,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
.breakpoint => try self.airBreakpoint(),
.ret_addr => @panic("TODO try self.airRetAddr(inst)"),
.frame_addr => @panic("TODO try self.airFrameAddress(inst)"),
- .fence => @panic("TODO try self.airFence()"),
+ .fence => try self.airFence(inst),
.cond_br => try self.airCondBr(inst),
.dbg_stmt => try self.airDbgStmt(inst),
.fptrunc => @panic("TODO try self.airFptrunc(inst)"),
@@ -1442,6 +1442,29 @@ fn airDiv(self: *Self, inst: Air.Inst.Index) !void {
return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
}
+fn airFence(self: *Self, inst: Air.Inst.Index) !void {
+ // TODO weaken this as needed, currently this implements the strongest membar form
+ const fence = self.air.instructions.items(.data)[inst].fence;
+ _ = fence;
+
+ // membar #StoreStore | #LoadStore | #StoreLoad | #LoadLoad
+ _ = try self.addInst(.{
+ .tag = .membar,
+ .data = .{
+ .membar_mask = .{
+ .mmask = .{
+ .store_store = true,
+ .store_load = true,
+ .load_store = true,
+ .load_load = true,
+ },
+ },
+ },
+ });
+
+ return self.finishAir(inst, .dead, .{ .none, .none, .none });
+}
+
fn airIsErr(self: *Self, inst: Air.Inst.Index) !void {
const un_op = self.air.instructions.items(.data)[inst].un_op;
const result: MCValue = if (self.liveness.isUnused(inst)) .dead else result: {