gccrs: Implement rust-intrinsics atomic compare-exchange built-ins
GCC Rust frontend now supports atomic compare-and-exchange operations.
This commit adds support for Rust’s atomic compare-exchange (compare-and-swap) built-in functions to the GCC Rust compiler. These operations are fundamental for lock-free data structures and concurrent programming, allowing atomic conditional updates of memory locations. The implementation involves defining new intrinsic handlers and integrating them into the compiler’s intrinsic processing pipeline.
In Details
gccrs now handles Rust's atomic compare-exchange intrinsics. New entries for 'atomic_compare_exchange' and its variants were added to rust-intrinsic-values.h. Corresponding handler functions, inner::atomic_compare_exchange and atomic_compare_exchange, were implemented in rust-intrinsic-handlers.cc and registered in generic_intrinsics and intrinsic_rules for compilation and type checking.
- atomic compare-exchange
- An atomic operation that compares the value of a memory location with an expected value. If they match, it replaces the memory location's value with a new value. This operation is performed indivisibly, ensuring thread safety without requiring locks.