gccrs: Implement rust-intrinsics atomic min/max builtins
GCC Rust frontend adds support for atomic min/max intrinsics.
This commit introduces support for atomic minimum and maximum operations within the GCC Rust frontend. Since the GCC backend lacks direct equivalents, these operations are implemented using compare-exchange loops, similar to other projects like rustc_codegen_gcc. This enables Rust programs to correctly utilize these atomic primitives for thread-safe manipulation of shared data.
In Details
gccrs now supports Rust's atomic min/max intrinsics by implementing them via compare-exchange loops in the backend handlers. New entries were added to rust-intrinsic-values.h, and handler functions inner::atomic_minmax and atomic_minmax were implemented in rust-intrinsic-handlers.cc. These are then registered in generic_intrinsics and intrinsic_rules for compilation and type-checking.
- compare-exchange loop
- A common pattern for implementing atomic operations when direct hardware support is unavailable. It repeatedly attempts to read a value, compute a new value based on it, and then atomically compare the current value with the read value, only succeeding if they match. If they don't match (meaning another thread modified the value), the loop retries.