authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-01 04:54:58-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-01 20:39:06-04:00
log4d594090b13629cb940bc400750b044473d26b11
tree2dea81eba8fed0c067b409daf94f196cb862483a
parent09763435a85a6108cc4624b51ac1b016746078b6

cbe: incorrectly implement volatile memset

This will have to be replaced with manual volatile stores.

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

src/codegen/c.zig+11
...@@ -4926,12 +4926,23 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa...@@ -4926,12 +4926,23 @@ fn airAtomicStore(f: *Function, inst: Air.Inst.Index, order: [*:0]const u8) !CVa
4926fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {4926fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
4927 const pl_op = f.air.instructions.items(.data)[inst].pl_op;4927 const pl_op = f.air.instructions.items(.data)[inst].pl_op;
4928 const extra = f.air.extraData(Air.Bin, pl_op.payload).data;4928 const extra = f.air.extraData(Air.Bin, pl_op.payload).data;
4929 const dest_ty = f.air.typeOf(pl_op.operand);
4929 const dest_ptr = try f.resolveInst(pl_op.operand);4930 const dest_ptr = try f.resolveInst(pl_op.operand);
4930 const value = try f.resolveInst(extra.lhs);4931 const value = try f.resolveInst(extra.lhs);
4931 const len = try f.resolveInst(extra.rhs);4932 const len = try f.resolveInst(extra.rhs);
4932 const writer = f.object.writer();4933 const writer = f.object.writer();
49334934
4934 try writer.writeAll("memset(");4935 try writer.writeAll("memset(");
4936 if (dest_ty.isVolatilePtr()) {
4937 // This is wrong, but good enough for now.
4938 var remove_volatile_pl = dest_ty.ptrInfo();
4939 remove_volatile_pl.data.@"volatile" = false;
4940 const remove_volatile_ty = Type.initPayload(&remove_volatile_pl.base);
4941
4942 try writer.writeByte('(');
4943 try f.renderTypecast(writer, remove_volatile_ty);
4944 try writer.writeByte(')');
4945 }
4935 try f.writeCValue(writer, dest_ptr, .FunctionArgument);4946 try f.writeCValue(writer, dest_ptr, .FunctionArgument);
4936 try writer.writeAll(", ");4947 try writer.writeAll(", ");
4937 try f.writeCValue(writer, value, .FunctionArgument);4948 try f.writeCValue(writer, value, .FunctionArgument);