pub fn cmpxchg(
self: *WipFunction,
kind: Instruction.CmpXchg.Kind,
access_kind: MemoryAccessKind,
ptr: Value,
cmp: Value,
new: Value,
sync_scope: SyncScope,
success_ordering: AtomicOrdering,
failure_ordering: AtomicOrdering,
alignment: Alignment,
name: []const u8,
) Allocator.Error!Value self: *WipFunctionkind: Instruction.CmpXchg.Kindaccess_kind: MemoryAccessKindptr: Valuecmp: Valuenew: Valuesync_scope: SyncScopesuccess_ordering: AtomicOrderingfailure_ordering: AtomicOrderingalignment: Alignmentname: []const u86916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956 pub fn cmpxchg(
self: *WipFunction,
kind: Instruction.CmpXchg.Kind,
access_kind: MemoryAccessKind,
ptr: Value,
cmp: Value,
new: Value,
sync_scope: SyncScope,
success_ordering: AtomicOrdering,
failure_ordering: AtomicOrdering,
alignment: Alignment,
name: []const u8,
) Allocator.Error!Value {
assert(ptr.typeOfWip(self).isPointer(self.builder));
const ty = cmp.typeOfWip(self);
assert(ty == new.typeOfWip(self));
assert(success_ordering != .none);
assert(failure_ordering != .none);
_ = try self.builder.structType(.normal, &.{ ty, .i1 });
try self.ensureUnusedExtraCapacity(1, Instruction.CmpXchg, 0);
const instruction = try self.addInst(name, .{
.tag = switch (kind) {
.strong => .cmpxchg,
.weak => .@"cmpxchg weak",
},
.data = self.addExtraAssumeCapacity(Instruction.CmpXchg{
.info = .{
.access_kind = access_kind,
.sync_scope = sync_scope,
.success_ordering = success_ordering,
.failure_ordering = failure_ordering,
.alignment = alignment,
},
.ptr = ptr,
.cmp = cmp,
.new = new,
}),
});
return instruction.toValue();
}