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

Method atomic_rmw

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:2203–2310  ·  view source on GitHub ↗
(
        &mut self,
        op: AtomicRmwBinOp,
        dst: Self::Value,
        src: Self::Value,
        order: AtomicOrdering,
    )

Source from the content-addressed store, hash-verified

2201 }
2202
2203 fn atomic_rmw(
2204 &mut self,
2205 op: AtomicRmwBinOp,
2206 dst: Self::Value,
2207 src: Self::Value,
2208 order: AtomicOrdering,
2209 ) -> Self::Value {
2210 let dst_pointee_ty = match self.lookup_type(dst.ty) {
2211 SpirvType::Pointer { pointee } => pointee,
2212 ty => self.fatal(&format!(
2213 "atomic_rmw called on variable that wasn't a pointer: {ty:?}"
2214 )),
2215 };
2216 assert_ty_eq!(self, dst_pointee_ty, src.ty);
2217 self.validate_atomic(dst_pointee_ty, dst.def(self));
2218 // TODO: Default to device scope
2219 let memory = self
2220 .constant_u32(self.span(), Scope::Device as u32)
2221 .def(self);
2222 let semantics = self.ordering_to_semantics_def(order).def(self);
2223 let mut emit = self.emit();
2224 use AtomicRmwBinOp::*;
2225 match op {
2226 AtomicXchg => emit.atomic_exchange(
2227 src.ty,
2228 None,
2229 dst.def(self),
2230 memory,
2231 semantics,
2232 src.def(self),
2233 ),
2234 AtomicAdd => emit.atomic_i_add(
2235 src.ty,
2236 None,
2237 dst.def(self),
2238 memory,
2239 semantics,
2240 src.def(self),
2241 ),
2242 AtomicSub => emit.atomic_i_sub(
2243 src.ty,
2244 None,
2245 dst.def(self),
2246 memory,
2247 semantics,
2248 src.def(self),
2249 ),
2250 AtomicAnd => emit.atomic_and(
2251 src.ty,
2252 None,
2253 dst.def(self),
2254 memory,
2255 semantics,
2256 src.def(self),
2257 ),
2258 AtomicNand => self.fatal("atomic nand is not supported"),
2259 AtomicOr => emit.atomic_or(
2260 src.ty,

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