Function cmpxchg [src]

Prototype

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

Parameters

self: *WipFunctionkind: Instruction.CmpXchg.Kindaccess_kind: MemoryAccessKindptr: Valuecmp: Valuenew: Valuesync_scope: SyncScopesuccess_ordering: AtomicOrderingfailure_ordering: AtomicOrderingalignment: Alignmentname: []const u8

Source

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(); }