On Wed Aug 19, 2026 at 8:09 PM JST, Gary Guo wrote: > Relative registers can be better served by projection to subregion instead > of ad-hoc handling in register macro. Projection composes better (e.g. it > natively allows relative registers of relative registers without needing > additional support). > > Remove relative register support, and update the documentation to > demonstrate how projection and subregions can be used to achieve this > instead. > > Signed-off-by: Gary Guo <[email protected]>
Reviewed-by: Alexandre Courbot <[email protected]> And good riddance! <...> > @@ -763,115 +511,83 @@ pub const fn element_alias_offset<Base: ?Sized, Alias: > RegisterArray<Base = Base > /// # } > /// ``` > /// > -/// ## Relative arrays of registers > +/// ## Relative registers > /// > -/// Combining the two features described in the sections above, arrays of > registers accessible from > -/// a base can also be defined: > +/// There are cases where a register region is subdivided into small > subregions, and you may wish to > +/// have your register definition be relative to these subregions. This may > be needed, for example, > +/// if these subregions are instantiated several times, or you just want it > for encapsulation > +/// purpose. > /// > -/// ```ignore > -/// register! { > -/// ... > -/// pub RELATIVE_REGISTER_ARRAY(u8)[10, stride = 4] @ Base + 0x100 { > -/// ... > -/// } > -/// } > +/// For instance, imagine the following I/O space: > +/// > +/// ```text > +/// +-----------------------------+ > +/// | ... | > +/// | | > +/// 0x100--->+------------CPU0-------------+ > +/// | | > +/// 0x110--->+-----------------------------+ > +/// | CPU_CTL | > +/// +-----------------------------+ > +/// | ... | > +/// | | > +/// | | > +/// 0x200--->+------------CPU1-------------+ > +/// | | > +/// 0x210--->+-----------------------------+ > +/// | CPU_CTL | > +/// +-----------------------------+ > +/// | ... | > +/// +-----------------------------+ > /// ``` > /// > -/// Like relative registers, they implement the [`WithBase`] trait. However > the return value of > -/// [`WithBase::of`] cannot be used directly as a location and must be > further specified using the > -/// [`at`](RelativeRegisterLoc::at) method. > +/// `CPU0` and `CPU1` both have a `CPU_CTL` register that starts at offset > `0x10` of their I/O > +/// space segment. Since both instances of `CPU_CTL` share the same layout, > we don't want to define > +/// them twice and would prefer a way to select which one to use from a > single definition. > +/// > +/// This can be done define a new type for the subregion, and then define > registers that use the new nit: "done by defining ... and then defining registers"
