Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-21 Thread Danilo Krummrich
On Fri, Feb 21, 2025 at 08:35:54PM +0900, Alexandre Courbot wrote: > On Thu Feb 20, 2025 at 9:14 AM JST, John Hubbard wrote: > > On 2/19/25 3:13 PM, Daniel Almeida wrote: > >>> On 19 Feb 2025, at 17:23, Dave Airlie wrote: > >>> On Thu, 20 Feb 2025 at 06:22, John Hubbard wrote: > On 2/19/25 4

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-21 Thread Alexandre Courbot
On Thu Feb 20, 2025 at 9:14 AM JST, John Hubbard wrote: > On 2/19/25 3:13 PM, Daniel Almeida wrote: >>> On 19 Feb 2025, at 17:23, Dave Airlie wrote: >>> On Thu, 20 Feb 2025 at 06:22, John Hubbard wrote: On 2/19/25 4:51 AM, Alexandre Courbot wrote: > Yes, that looks like the optimal way t

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-20 Thread Dirk Behme
On 18/02/2025 14:07, Alexandre Courbot wrote: > On Tue Feb 18, 2025 at 7:07 PM JST, Dirk Behme wrote: >> On 17/02/2025 15:04, Alexandre Courbot wrote: >>> It is common to build a u64 from its high and low parts obtained from >>> two 32-bit registers. Conversely, it is also common to split a u64 int

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread John Hubbard
On 2/19/25 3:13 PM, Daniel Almeida wrote: On 19 Feb 2025, at 17:23, Dave Airlie wrote: On Thu, 20 Feb 2025 at 06:22, John Hubbard wrote: On 2/19/25 4:51 AM, Alexandre Courbot wrote: Yes, that looks like the optimal way to do this actually. It also doesn't introduce any overhead as the destruc

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread Daniel Almeida
> On 19 Feb 2025, at 17:23, Dave Airlie wrote: > > On Thu, 20 Feb 2025 at 06:22, John Hubbard wrote: >> >> On 2/19/25 4:51 AM, Alexandre Courbot wrote: >>> Yes, that looks like the optimal way to do this actually. It also >>> doesn't introduce any overhead as the destructuring was doing both

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread Sergio González Collado
> Actually. How about adding methods to this trait that return either > component? > > let some_u32 = some_u64.high_half(); > let another_u32 = some_u64.low_half(); > > These should be used most of the times, and using destructuring/tuple > would only be useful for a few select cases. > Indeed

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread Dave Airlie
On Thu, 20 Feb 2025 at 06:22, John Hubbard wrote: > > On 2/19/25 4:51 AM, Alexandre Courbot wrote: > > Yes, that looks like the optimal way to do this actually. It also > > doesn't introduce any overhead as the destructuring was doing both > > high_half() and low_half() in sequence, so in some cas

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread John Hubbard
On 2/19/25 4:51 AM, Alexandre Courbot wrote: Yes, that looks like the optimal way to do this actually. It also doesn't introduce any overhead as the destructuring was doing both high_half() and low_half() in sequence, so in some cases it might even be more efficient. I'd just like to find a bett

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread Alexandre Courbot
On Wed Feb 19, 2025 at 12:24 PM JST, John Hubbard wrote: > On 2/18/25 5:21 PM, Alexandre Courbot wrote: >> On Wed Feb 19, 2025 at 5:51 AM JST, Timur Tabi wrote: >>> On Tue, 2025-02-18 at 22:16 +0900, Alexandre Courbot wrote: > ... >> More likely this would be something like: >> >>let SplitU64

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-19 Thread Dirk Behme
On 17/02/2025 15:04, Alexandre Courbot wrote: > It is common to build a u64 from its high and low parts obtained from > two 32-bit registers. Conversely, it is also common to split a u64 into > two u32s to write them into registers. Add an extension trait for u64 > that implement these methods in a

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-18 Thread John Hubbard
On 2/18/25 5:21 PM, Alexandre Courbot wrote: On Wed Feb 19, 2025 at 5:51 AM JST, Timur Tabi wrote: On Tue, 2025-02-18 at 22:16 +0900, Alexandre Courbot wrote: ... More likely this would be something like: let SplitU64 { high: some_u32, .. } = some_u64; Which is still a bit verbose, but a

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-18 Thread Alexandre Courbot
On Wed Feb 19, 2025 at 5:51 AM JST, Timur Tabi wrote: > On Tue, 2025-02-18 at 22:16 +0900, Alexandre Courbot wrote: >> > A proper struct with `high` and `low` might be more verbose, but >> > it rules out this issue. >> >> Mmm indeed, so we would have client code looking like: >> >>   let SplitU64

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-18 Thread Timur Tabi
On Tue, 2025-02-18 at 22:16 +0900, Alexandre Courbot wrote: > > A proper struct with `high` and `low` might be more verbose, but > > it rules out this issue. > > Mmm indeed, so we would have client code looking like: > >   let SplitU64 { high, low } = some_u64.into_u32(); > > instead of > >  

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-18 Thread Alexandre Courbot
Hi Daniel! On Tue Feb 18, 2025 at 6:10 AM JST, Daniel Almeida wrote: > Hi Alex, > >> On 17 Feb 2025, at 11:04, Alexandre Courbot wrote: >> >> It is common to build a u64 from its high and low parts obtained from >> two 32-bit registers. Conversely, it is also common to split a u64 into >> two u

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-18 Thread Alexandre Courbot
On Tue Feb 18, 2025 at 7:07 PM JST, Dirk Behme wrote: > On 17/02/2025 15:04, Alexandre Courbot wrote: >> It is common to build a u64 from its high and low parts obtained from >> two 32-bit registers. Conversely, it is also common to split a u64 into >> two u32s to write them into registers. Add an

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-17 Thread Sergio González Collado
On Mon, 17 Feb 2025 at 15:07, Alexandre Courbot wrote: > > It is common to build a u64 from its high and low parts obtained from > two 32-bit registers. Conversely, it is also common to split a u64 into > two u32s to write them into registers. Add an extension trait for u64 > that implement these

Re: [PATCH RFC 1/3] rust: add useful ops for u64

2025-02-17 Thread Daniel Almeida
Hi Alex, > On 17 Feb 2025, at 11:04, Alexandre Courbot wrote: > > It is common to build a u64 from its high and low parts obtained from > two 32-bit registers. Conversely, it is also common to split a u64 into > two u32s to write them into registers. Add an extension trait for u64 > that implem