[libre-riscv-dev] power pc

Luke Kenneth Casson Leighton lkcl at lkcl.net
Thu Oct 31 19:23:53 GMT 2019


On Thu, Oct 31, 2019 at 7:19 PM Jacob Lifshay <programmerjake at gmail.com> wrote:
>
> On Thu, Oct 31, 2019, 11:36 Luke Kenneth Casson Leighton <lkcl at lkcl.net>
> wrote:
>
> > On Thu, Oct 31, 2019 at 7:58 AM Jacob Lifshay <programmerjake at gmail.com>
> > wrote:
> > >
> > > On Thu, Oct 31, 2019, 00:39 Luke Kenneth Casson Leighton <lkcl at lkcl.net>
> > > wrote:
> > >
> > > > Hiya Jacob
> > > >
> > > > Realised that the tricky bit will be the context switch: CSRs,
> > registers.
> > > > Can you put some thought into how to do that?
> > > >
> > >
> > > sure. my initial plans are that the power and riscv integer and fp
> > > registers are the same (I think they both have 32 64-bit registers for
> > each
> > > of int/fp).
> >
> > yehyeh. we could hypothetically map them to the higher-numbered
> > registers (32-63, 64-95, 96-127) which will keep them out of the way
> > of the POWER ones.
> >
>
> well, I had intentionally wanted to map risc-v x1 to x31 to power's integer
> register 1 to 31 and risc-v f0 to f31 to power's fp reg 0 to 31. that
> allows using standard power instructions to save and restore state to also
> save and restore the risc-v registers rather than needing the risc-v
> extensions to depend on SV extending the register numbers. that also
> simplifies the code needed to handle syscalls and (if they're are
> implemented) inter-architecture function calls.

true.  the potential issue is: if POWER overwrites registers in a
different fashion.  RV has a single "scratch register" {x}SCRATCH
which swaps into (one) register so that you have at least one register
to do context-switching "stuff".

if however POWER does things differently - has a different register
from x2 as the convention for SP, etc. etc. there may not *be* a way
to "preserve" the RV regs without the addition of some extra CSRs or
even some new instructions.

moving the regs into the upper sections would avoid any need for messing about.

that's what needs to be properly researched: it *may* be the case
that, yes, there already happens to be a PowerISA "clean" and
non-destructive way to save the entire regfile onto the stack, which
makes the upper-mapping unnecessary.

l.



More information about the libre-riscv-dev mailing list