authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-21 00:15:19-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-21 16:36:31-04:00
loga519c9daced7dc182a57d8a49992463eabf3c825
tree596e8154fac01211c21ee66382898049de2b15e3
parente364627e3ea0de3037ced086406516d956c3bcd7

cbe: fix atomic float min/max

These need `zig_atomic`, unlike int min/max.

1 files changed, 9 insertions(+), 11 deletions(-)

src/codegen/c.zig+9-11
...@@ -6070,17 +6070,15 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -6070,17 +6070,15 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
6070 try writer.writeByte('(');6070 try writer.writeByte('(');
6071 try f.writeCValue(writer, local, .Other);6071 try f.writeCValue(writer, local, .Other);
6072 try writer.writeAll(", (");6072 try writer.writeAll(", (");
6073 switch (extra.op()) {6073 const use_atomic = switch (extra.op()) {
6074 else => {6074 else => true,
6075 try writer.writeAll("zig_atomic(");6075 // These are missing from stdatomic.h, so no atomic types for now.
6076 try f.renderType(writer, ty);6076 .Nand => false,
6077 try writer.writeByte(')');6077 .Min, .Max => is_float,
6078 },6078 };
6079 .Nand, .Min, .Max => {6079 if (use_atomic) try writer.writeAll("zig_atomic(");
6080 // These are missing from stdatomic.h, so no atomic types for now.6080 try f.renderType(writer, ty);
6081 try f.renderType(writer, ty);6081 if (use_atomic) try writer.writeByte(')');
6082 },
6083 }
6084 if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");6082 if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
6085 try writer.writeAll(" *)");6083 try writer.writeAll(" *)");
6086 try f.writeCValue(writer, ptr, .Other);6084 try f.writeCValue(writer, ptr, .Other);