Implement no-op intrinsics for prefetch hints in GCC Rust
GCC's Rust compiler now handles `prefetch_instruction` intrinsics as no-ops, aligning with LLVM and allowing them to be safely ignored.
The GCC Rust compiler introduces no-operation implementations for __builtin_prefetch_read_instruction and __builtin_prefetch_write_instruction. These intrinsics, unlike LLVM’s llvm.prefetch, currently lack support for specifying cache levels. Since prefetches are performance hints and can be safely ignored, treating these specific instruction prefetches as no-ops provides compatibility without full implementation.
In Details
This commit modifies intrinsic handling in rust-compile-intrinsic.cc and rust-intrinsic-handlers.cc/.h. The prefetch intrinsic handler is reworked, and new handlers for prefetch_{read, write}_instruction are added as no-ops. This aligns with the fact that instruction prefetches are not standard or heavily optimized, and __builtin_prefetch() in GCC's C++ frontend doesn't expose cache-level arguments like LLVM's intrinsic. New enum values PREFETCH_READ_INSTRUCTION and PREFETCH_WRITE_INSTRUCTION are added to rust-intrinsic-values.h.
- intrinsics
- Special functions or operations that a compiler can recognize and translate into specific machine instructions or optimized code sequences.
- prefetch
- A hardware instruction that hints to the processor to load data into the cache, anticipating future use to improve performance.
- no-op
- No Operation. An instruction or operation that does nothing and is often used as a placeholder or to satisfy a required interface.
- builtin
- A function or macro provided directly by the compiler, often with special optimization or access to low-level features.