aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-04-21 15:58:40 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-04-21 16:36:31 -0400
commitd56c6c77913a6d560b7d3ebd6283cbf71d5a0222 (patch)
tree11af28d08220a48515a75f073bd18127f6cebd7a /src
parent5afaaf865f93965f2a13069d4890c1491664652f (diff)
downloadzig-d56c6c77913a6d560b7d3ebd6283cbf71d5a0222.tar.gz
zig-d56c6c77913a6d560b7d3ebd6283cbf71d5a0222.zip
cbe: implement 128-bit atomics support
* Disable 128-bit atomics for x86_64 generic (currently also baseline) because they require heavy abi agreement to correctly lower. ** This is a breaking change ** * Enable 128-bit atomics for aarch64 in Sema since it just works.
Diffstat (limited to 'src')
-rw-r--r--src/codegen/c.zig8
-rw-r--r--src/target.zig10
2 files changed, 10 insertions, 8 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index 832a97526e..8697411793 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -6062,19 +6062,19 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
.data = @intCast(u16, ty.abiSize(target) * 8),
};
const is_float = ty.isRuntimeFloat();
+ const is_128 = repr_pl.data == 128;
const repr_ty = if (is_float) Type.initPayload(&repr_pl.base) else ty;
const operand_mat = try Materialize.start(f, inst, writer, ty, operand);
try writer.print("zig_atomicrmw_{s}", .{toAtomicRmwSuffix(extra.op())});
- if (is_float) try writer.writeAll("_float");
+ if (is_float) try writer.writeAll("_float") else if (is_128) try writer.writeAll("_int128");
try writer.writeByte('(');
try f.writeCValue(writer, local, .Other);
try writer.writeAll(", (");
const use_atomic = switch (extra.op()) {
else => true,
- // These are missing from stdatomic.h, so no atomic types for now.
- .Nand => false,
- .Min, .Max => is_float,
+ // These are missing from stdatomic.h, so no atomic types unless a fallback is used.
+ .Nand, .Min, .Max => is_float or is_128,
};
if (use_atomic) try writer.writeAll("zig_atomic(");
try f.renderType(writer, ty);
diff --git a/src/target.zig b/src/target.zig
index 76186db269..5e66c8f417 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -575,9 +575,6 @@ pub fn atomicPtrAlignment(
.xtensa,
=> 32,
- .aarch64,
- .aarch64_be,
- .aarch64_32,
.amdgcn,
.bpfel,
.bpfeb,
@@ -600,7 +597,12 @@ pub fn atomicPtrAlignment(
.loongarch64,
=> 64,
- .x86_64 => 128,
+ .aarch64,
+ .aarch64_be,
+ .aarch64_32,
+ => 128,
+
+ .x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,
};
var buffer: Type.Payload.Bits = undefined;