[llvm-dev] Having trouble getting started on writing a WDC 65816 backend

Bruce Hoult via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 15 13:16:46 PDT 2019


On Sat, Jul 13, 2019 at 11:19 AM via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> July 10, 2019 1:29 PM, "Tim Northover" <t.p.northover at gmail.com> wrote:
>
> > As I recall the big one is that LLVM isn't well adapted to instruction
> > sets without fungible registers.
>
> What does this mean exactly? How does the WDC 65816 not have fungible registers, while other processors do?

That comes directly from the dictionary definition of fungible. You
can not substitute one register for another.

Take, for example, RISC-V. You have 32 registers that, in the base
fixed-length 32 bits long instruction set, are absolutely
interchangeable with each other. No instructions use implicit source
or destination registers, any register can be used for anything. There
is no fixed stack pointer register -- any register can equally well be
used as a stack pointer. There is no fixed function return link
register -- any register can equally well be used as a link register.
The only exception is that reads from register 0 always return 0 and
writes to it are discarded. In general, if the compiler needs a
register or some purpose it does not matter what the purpose is, the
compiler can just grab the next available register and use it, without
regard for what other registers are in use or what they are being used
for.

Compare to 6502. There is a stack pointer that can't be directly
accessed, but only used in push and pop and transferred to or from
another register. There is a condition code register that can only be
accessed implicitly or by pushing or popping it to the stack.
Arithmetic such as add/siub/and/or/xor can only be done with the A
register. Increment and decrement can only be done with the X and Y
registers, not the A register. The (zp,reg) addressing mode can only
be used with the X register. The (zp),reg addressing mode can only use
the Y register.

Yes, the 65C02 and 65816 relaxed some of these things a little, but
not all that much.


More information about the llvm-dev mailing list