[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] Zen and the art of F-CPU assembler coding



On Tue, Dec 10, 2002 at 11:45:25AM +0100, devik wrote:

> What is .o(...) :-) ? You version with cmple is much better,
> no doubt ! I like it :-)

.o(...) means that I was just thinking "...".

> > On the other hand, the examples show that we can live without combine.
> > If we drop it (or maybe move it to a second pipeline stage and make it
> > support *all* chunk sizes), there will be enough room in the ROP2 unit to
> > add `n -> 2**n' decoders in front of it for 1-cycle btst/bchg/bset/bclr
> > instructions that are more useful than combine, IMHO.
> 
> It would be very nice (how complex is such decoder?). Could be possible
> to support bnclr then (when we have nand) ?

Yes. The decoder will just change the way the second operand is
interpreted, everything else remains unchanged.

> I used bseti $C,r0,r for loading some constants in my gcc backend and
> it helped the code. bnclr $C,r0,r could be used to load big masks
> with one cleared bit. Both of these constants are heavily used in
> C codes to create and modify flag bitmasks and rotating masks for
> bit selection.

In fact, the compiler's optimization phase should get rid of those C
idioms and use bitop directly when a single-bit mask is needed. For

	mask = 1 << count;
	if (item & mask) ...

it should use something like

	btst count, item, tmp
	jmp[n]z tmp, target

and not deal with constant shifting at all.  Similarly, if you want to
clear a single bit, just use

	bclr $index, reg, reg

In other cases, bnclr & friends might be quite helpful, though.
E.g. LONG_MAX (0x7fffffffffffffff) could be loaded with a single

	bnseti $63, r0, reg

NB: We got to carefully choose the mnemonics. Maybe we should use `band',
`bor', `bxor' and so on for clarity. The old `legacy' instructions (bset,
bclr, bchg and btst) should still be supported, however.

-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/