anti…@fricas.org (Waldek Hebisch) posted:
> Anton Ertl <ant…@mips.complang.tuwien.ac.at> wrote:
> > Stefan Monnier <monn…@iro.umontreal.ca> writes:
--------------
> >>That's beside the point. With a load/store architecture you don't need > >>to choose between using the ADD-with-addressing mode or using explicit > >>loads and stores. Makes life simpler for the compiler.
> > > > No. With an architecture like the VAX, RISC is actually harder: > > > > VAX: If operand src1 is in memory, accessed with d(SP), use the ADD > > instruction with d(SP) as second operand. Likewise for src2 and dst. > > > > RISC: If operand src2 is in memory, allocate a register for it (but > > why is it in memory? Probably because there are no registers > > available, so first spill some other value); then load the operand > > from d(SP) into the register; possibly do the same for the other > > source operand (but don't spill the register for src2). If the > > destination is in memory, allocate a register for storing it in the > > meantime (again with the potential for spilling). Finally do the add. > > Store the result if necessary. And now refill all the spilled values. > > > > It's all doable, but simpler? No.
> > Partially playing devil's advocate: if you reserve registers for > arguments and for handlinig addressing modes, then all one has > to do is generating code for loads. But some loads seem to be > neccessary even for VAX, so you need function which generates > loads in the compiler anyway. > For RISC, you generate much more > loads than for VAX, but decision when to generate a load is > quite simple.
The data does not substantiate that statement. CISC machines operated with an inbound memory reference about 50% of instructions. RISC machines trimmed this down to 20%. A variable is used (typically) 1.2 times after it gets loaded. A CISC will simply use the D$ and produce 2 address modes, whereas RISC will LD the location and use it 1.2 times.
> I estimate that for typical instructions one > needs to reserve between 3 and 8 registers, that is 2 for > arguments, one for result and additional registers to handle > addressing modes.
Registers 00..08 are for arguments {R0 is return address} Registers 09..15 are temporary {unused arguments are also temp} Registers 16..31 are preserved. R30 is FP, R31 is SP
> IIUC Risc-V and ARM need at least one > register to generate large constants which may be needed for > addressing.
That is a typical RISC problem--but not for my ISA
> Now, with 4 registers reserved on 32 bit ARM > there remain 11 general purpose registers (plus PC), that is > significantly less than 15 general purpose registers on VAX.
Don't forget the free access to memory via address modes.
> But Risc-V and 64 bit ARM even after reserving a few still > have more usable general purpose registers than VAX.
But less than me !!
> Of course, that assumes out of order RISC. For superscalar > in-order RISC one needs to schedule instructions and that > significantly complicates register allocation. >
> > For the more common CISC style with load-and-op and read-modify-write, > > things are harder than on the VAX, but RISC still is not simpler.
> > In simple (almost naive) compiler main issue is how much you > care about possibly redundant temporary registers. Due to
Does redundant mean the same value is in more than one register ??
> software conventions, it seems that one actually does not > need to care much. That is, there is limited supply of > registers usable for local variables. More precisely, > to avoid excessive spill code around calls variables that > need to persists after function call need to be allocated > in call-preserved registers, and those are relatively small > fraction of all registers.'
Where "small fraction" = a full 50% of them.
> And in a simple compiler it > is reasonable to assume that all variables that are allocated > to registers should survive after function call (otherwise > compiler need to do some real work like livenes ananlysis, > rage splitting etc.). So there are plenty of registers that > are usable only for temporaries. >