I have been mulling over the idea of adding backends for the various 8bit and 16bit microprocessors directly to llvm.
I have been mulling over the idea of adding backends for the various 8bit and 16bit microprocessors directly to llvm.
It's honestly probably the best way of going about it. The target-independent backend in LLVM really isn't designed for these kinds of architectures. When you have pointers that don't fit in registers, an extremely register-starved architecture (6502), crippled "index registers", no stack-relative addressing, a tiny stack, odd concepts like zero-page, etc. then most of LLVM's codegen infrastructure isn't applicable.
I'm sure it's technically possible to slot some kind of 8-bit codegen into the framework, but the fact that it's been tried many times and hasn't succeeded indicates to me that it's just not worth it. It seems a lot easier to just write a custom code generator that lowers LLVM IR to the target with its own mechanisms, and using the SDCC backend is likely as reasonable a choice as any other.
packet __xdata * __data rx_packet;
a pointer to (16-bit addresses) external data space stored in (8-bit addressed) local data space. Any useful compiler for an 8051 is going to need these SDCC extensions