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

[f-cpu] `cshift' redesign



Hi *,

while playing with the new `permute' feature, I also noticed that
there is room for a more complex `cshift' instruction; therefore,
its definition will change as follows:

    cshiftl[.size] [r3,]r2,r1       // changed instruction
    cshiftr[.size] [r3,]r2,r1       // changed instruction

        shifts r2 left (right) by a single chunk (as indicated by the
        size flags) and puts the result in r1. The new chunk that is
        `shifted in' at the top (bottom) is taken from the least
        significant (= lowest) chunk of r3; if r3 is not specified,
        the bits come from r0 (that is, they are zero).

The old syntax will continue to work: the former `cshiftl r2, r1' will
translate to `cshiftl.64 r0, r2, r1' which is exactly the same; similarly,
`cshiftr r2, r1' translates to `cshiftr.64 r0, r2, r1'.

Advantages of the new instruction are that you can save the `or' step
when you combine values from two registers, and that it also works on
smaller chunks. There are also funny special cases that might be useful:

    cshiftl.sz r1, r2, r1

        replaces all but the lowest chunk of r1 with left-shifted chunks
        from r2

    cshiftl.sz r2, r2, r1

        duplicates the lowest chunk of r2 and shifts the rest

    cshiftr.sz r2, r2, r1

        rotates r2 right by a single chunk

    cshiftr.sz r2, r1, r1
    cshiftr.sz r3, r2, r2
    cshiftr.sz r4, r3, r3
    cshiftr.sz r5, r4, r4
    ...

        shift register (e.g. for digital signal processing). Note that
        there are no dependencies (= no stalls!) between the shift
        instructions.

Here's the instruction encoding, for the manual:

    31-24   OP_CSHIFT
    23-22   size (as usual)
    21-20   unused (0)
    19      0=left, 1=right
    18      unused (0)
    17-12   r3
    11- 6   r2
     5- 0   r1

This instruction is optional for a 64-bit processor but mandatory for
`wider' F-CPU versions. It is already implemented, though, as well as
the new vector permute functions.

-- 
 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/