MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / atomic_cmpxchg

Method atomic_cmpxchg

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:2165–2201  ·  view source on GitHub ↗
(
        &mut self,
        dst: Self::Value,
        cmp: Self::Value,
        src: Self::Value,
        order: AtomicOrdering,
        failure_order: AtomicOrdering,
        _weak: bool,
    )

Source from the content-addressed store, hash-verified

2163 }
2164
2165 fn atomic_cmpxchg(
2166 &mut self,
2167 dst: Self::Value,
2168 cmp: Self::Value,
2169 src: Self::Value,
2170 order: AtomicOrdering,
2171 failure_order: AtomicOrdering,
2172 _weak: bool,
2173 ) -> Self::Value {
2174 let dst_pointee_ty = match self.lookup_type(dst.ty) {
2175 SpirvType::Pointer { pointee } => pointee,
2176 ty => self.fatal(&format!(
2177 "atomic_cmpxchg called on variable that wasn't a pointer: {ty:?}"
2178 )),
2179 };
2180 assert_ty_eq!(self, dst_pointee_ty, cmp.ty);
2181 assert_ty_eq!(self, dst_pointee_ty, src.ty);
2182 self.validate_atomic(dst_pointee_ty, dst.def(self));
2183 // TODO: Default to device scope
2184 let memory = self.constant_u32(self.span(), Scope::Device as u32);
2185 let semantics_equal = self.ordering_to_semantics_def(order);
2186 let semantics_unequal = self.ordering_to_semantics_def(failure_order);
2187 // Note: OpAtomicCompareExchangeWeak is deprecated, and has the same semantics
2188 self.emit()
2189 .atomic_compare_exchange(
2190 src.ty,
2191 None,
2192 dst.def(self),
2193 memory.def(self),
2194 semantics_equal.def(self),
2195 semantics_unequal.def(self),
2196 src.def(self),
2197 cmp.def(self),
2198 )
2199 .unwrap()
2200 .with_type(src.ty)
2201 }
2202
2203 fn atomic_rmw(
2204 &mut self,

Callers

nothing calls this directly

Calls 9

lookup_typeMethod · 0.80
fatalMethod · 0.80
validate_atomicMethod · 0.80
constant_u32Method · 0.80
spanMethod · 0.80
with_typeMethod · 0.80
defMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected