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

Re: (m) Re: [f-cpu] More Instruction Set Trouble



Yann Guidon wrote:
>i have the feeling (beware !) that we can attempt to do an exception.
>i presume that this instruction will be used more often than i thought,
>depending on the compiler quality etc...
>
>we can maybe try to make an "extended" form with (r1+1) as a destination.
>opcode : 8 bits
>I/D flag : 1 bit
>sign : 1
>imm16 : 16
>src/dest+1 : 6 bits
>  total : 32 bits.
>
>it's tight but it's worth.
>
>WHYGEE

        I think this may end up being messy. Consider that two places
where this instruction will be heavily used:

1) loading data at an immediate offset from a stack/frame pointer
2) loading data at an immediate offset from a global storage pointer

        In both cases, these pointers are fixed registers, therefor the
destination of said load instruction would also end up being fixed. So
then you'd have to carefully lay out your ABI so that fixed registers
are atleast a distance of 2 away from eachother. Moreover, since it is
a fixed register if you wanted to load another address in parallel with
it (you're not going to use the data quite immediately or else you fuck
with the pipeline/scheduling/prefetch), you'd have to move the calculated
address out of that fixed register to make room for another.

        What I suggest is, as controversial as this may be or not, just
to overwrite the source register (r1) with the calculated address. This
can be quite handy in a number of situations such as iterating over an
array (where you're constantly incrementing a pointer to load/store
elements), and also gives the processor good hints about what you're
doing with an array as a side-effect. This does mean you have to move
the base register to a scratch register before you can use the
instruction, but consider that you can also reuse previously calculated
addresses to minimize this cost signifigantly: i.e. if we need
to calculate SP + 16 for some snippet of code, and later need
to calculate SP + 48, so long as the result of the SP + 16 calculation
is still live, we can just calculate the result + 32 with the
special form of the loadaddr instruction all the same.

        Lee Salzman
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/