rust/compiler/rustc_codegen_ssa/src
Jacob Pratt 6912c676cd
Rollup merge of #150607 - dispatch-ptr-intrinsic, r=workingjubilee
Add amdgpu_dispatch_ptr intrinsic

There is an ongoing discussion in rust-lang/rust#150452 about using address spaces from the Rust language in some way.
As that discussion will likely not conclude soon, this PR adds one rustc_intrinsic with an addrspacecast to unblock getting basic information like launch and workgroup size and make it possible to implement something like `core::gpu`.

Add a rustc intrinsic `amdgpu_dispatch_ptr` to access the kernel dispatch packet on amdgpu.
The HSA kernel dispatch packet contains important information like the launch size and workgroup size.

The Rust intrinsic lowers to the `llvm.amdgcn.dispatch.ptr` LLVM intrinsic, which returns a `ptr addrspace(4)`, plus an addrspacecast to `addrspace(0)`, so it can be returned as a Rust reference.
The returned pointer/reference is valid for the whole program lifetime, and is therefore `'static`.
The return type of the intrinsic (`&'static ()`) does not mention the struct so that rustc does not need to know the exact struct type. An alternative would be to define the struct as lang item or add a generic argument to the function.
Is this ok or is there a better way (also, should it return a pointer instead of a reference)?

Short version:
```rust
#[cfg(target_arch = "amdgpu")]
pub fn amdgpu_dispatch_ptr() -> *const ();
```

Tracking issue: rust-lang/rust#135024
2026-01-15 19:35:46 -05:00
..
back Remove Deref/DerefMut impl for Providers. 2026-01-14 15:55:59 +11:00
debuginfo Merge associated_const_equality feature gate into MGCA 2026-01-05 12:31:42 +08:00
mir Rollup merge of #150607 - dispatch-ptr-intrinsic, r=workingjubilee 2026-01-15 19:35:46 -05:00
traits Move llvm intrinsic call to backend 2025-12-27 17:46:25 +00:00
assert_module_sources.rs Print CGU reuse statistics when -Zprint-mono-items is enabled 2025-08-04 15:43:50 +02:00
base.rs Fix alloc_error_handler signature mismatch 2026-01-07 17:17:05 +08:00
codegen_attrs.rs rename extern item to foreign item 2026-01-12 08:07:23 +01:00
common.rs rustc_target: introduce Os 2025-11-11 18:55:40 -05:00
errors.rs Reduce visibility of some errors 2026-01-09 14:45:25 +00:00
lib.rs Remove Deref/DerefMut impl for Providers. 2026-01-14 15:55:59 +11:00
meth.rs Remove DynKind 2025-09-17 04:46:46 +02:00
mono_item.rs Port the #[linkage] attribute to the new attribute system 2025-08-13 21:01:37 +02:00
size_of_val.rs remove explicit deref of AbiAlign for most methods 2025-09-28 15:02:14 -07:00
target_features.rs Use rust rather than LLVM target features in the target spec 2025-11-25 14:39:42 +00:00