ZERO_REGION_SIZE
Warner Losh
imp at bsdimp.com
Thu Nov 15 22:25:06 UTC 2012
On Nov 15, 2012, at 3:11 PM, Patrick Kelsey wrote:
> On Thu, Nov 15, 2012 at 5:02 PM, Juli Mallett <jmallett at freebsd.org> wrote:
>> On Thu, Nov 15, 2012 at 1:07 PM, Warner Losh <imp at bsdimp.com> wrote:
>>
>>>
>>> On Nov 15, 2012, at 1:13 PM, Alan Cox wrote:
>>>> P.S. I would encourage someone with hardware to look into implementing a
>>>> non-iterative ffs*() using (d)clz. The MIPS pmap would benefit from
>>>> this. Basically, most pmap_enter() calls are doing an ffs*().
>>>
>>> ffs finds the first bit set. clz counts the number of leading zeros and
>>> thus finds the last bit set. Would a non-iterative fls* be helpful?
>>>
>>
>> Right. And no widespread ctz/ffs MIPS instructions as far as I know. We
>> could use pop/dpop on processors that support them to do non-iterative
>> ffs*, with a few additional instructions, though.
>
> I was thinking something like this might work:
>
> value to ffs is in r1, MSB is the index of the MSB (so, 31 or 63):
>
> if (0 == r1) return(your_choice);
> r2 = r1 - 1;
> r2 = r1 ^ r2;
> return (MSB - clz(r2));
Turns out NetBSD has one that does exactly this...
Warner
More information about the freebsd-mips
mailing list