LLVM-MOS – Clang LLVM fork targeting the 6502

llvm-mos.org

138 points by jdmoreira a day ago


HarHarVeryFunny - a day ago

According to this page, LLVM-MOS seems to be pretty soundly beaten in performance of generated code by Oscar64.

https://thred.github.io/c-bench-64/

I think the ideal compiler for 6502, and maybe any of the memory-poor 8-bit systems would be one that supported both native code generation where speed is needed as well as virtual machine code for compactness. Ideally would also support inline assembler.

The LLVM-MOS approach of reserving some of zero page as registers is a good start, but given how valuable zero page is, it would also be useful to be able to designate static/global variables as zero page or not.

mtklein - a day ago

This was a nice surprise when learning to code for NES, that I could write pretty much normal C and have it work on the 6502. A lot of tutorials warn you, "prepare for weird code" and this pretty much moots that.

gregsadetsky - a day ago

I don't know this world well (I know what llvm is) but - does anyone know why this was made as a fork vs. contributing to llvm? I suppose it's harder to contribute code to the real llvm..?

Thanks

avadodin - 12 hours ago

A lot of people try to write backends for LLVM to support obscure architectures but these guys are the only ones I know that have ever been successful to any degree.

Portable assembly has a nice ring to it but reality is a harsh mistress and she only speaks C++.

Even the hobby underdog qbe seems ill-suited to 6502 repurposing.

bbbbbr - 21 hours ago

There is a similar project for the Game Boy (sm83 cpu) with a fork of LLVM.

https://github.com/DaveDuck321/gb-llvm

https://github.com/DaveDuck321/libgbxx

It seems to be first reasonably successful attempt (can actually be used) among a handful of previous abandoned llvm Game Boy attempts.

self_awareness - a day ago

Rust fork that works on this LLVM fork, for 6502, genering code that can be executed on a Commodore-64: https://github.com/mrk-its/rust-mos

iberator - a day ago

Slightly off-topic. If you want to learn low level assembly programming in the XXI century, 6502 is still an EXCELLENT choice!

Simple architecture and really really joyful to use even for casual programmers born a decade, or two later :)

cmrdporcupine - a day ago

It's been amazing to see the progress on this project over the last 5 years. As someone who poked around looking at the feasibility of this myself, and gave up thinking it'd never be practical, I'm super happy to see how far they've gotten.

Maybe someday the 65816 target will get out there, a challenge in itself.

michalpleban - a day ago

How does it compare to cc65 with regard to code size and speed?