Contributing

From llvm-mos

llvm-mos is a project with considerable scope, and considerably less resources. We can always use more help!

SDK[edit | edit source]

The https://github.com/llvm-mos/llvm-mos-sdk contains the general C and C++ libraries and linker scripts that provide support for each platform. If you have knowledge of a 6502 system and are willing to monkey around with a GCC-alike compiler, then you could help by adding support for a new platform, extending the C library coverage for that platform's OS or hardware, or by adding new configurations of platforms (i.e., tape, boot disk, baremetal, SD card boot, etc.)

The Porting guide describes how to bring up a new target from scratch using the base compiler and common target, while the Extending SDK guide describes how to incorporate such changes into the SDK's CMake scripts. Reading these also provides a good baseline for understanding the layout of the SDK. Afterwards, just jump in and start picking apart how your (or the most similar to your) target works, and feel free to ask questions in the Discord.

Compiler[edit | edit source]

Contributing to the compiler is considerably less straightforward. (But it's still greatly appreciated!) LLVM is one of the world's premier industrial-duty compiler frameworks; it's tremendously powerful, but with great power (usually) comes great complexity, and LLVM is no exception. Learning how it works can be easier or harder, depending on what exactly it is you're trying to do, as you may have to only learn a tiny portion of its codebase, or you may need to make sweeping changes throughout.

A great resource for this is https://godbolt.org; this allows you to analyze any snippet of C or C++ in the llvm-mos compiler. Adding a "LLVM Opt Pipeline" view to the compiler in Godbolt shows the program as each pass gradually transform it from almost-C all the way to 6502 assembly. This is a great way to learn the breakdown of which responsibilities lie with which LLVM passes, and where one should go looking to make changes. After that, it's mostly a matter of reading code, reading comments, and playing with toy examples until you've built a sufficient mental model of how stuff works to make changes.

There are a few resources available to help kickstart the mental-model building process. First, there's an excellent video overview of how LLVM backends work; this is probably the best bang-for-your buck in learning LLVM's backend architecture. Second, there's a video overview and readable reference documentation for how the Global Instruction Selector (GlobalISel) works; this is the process of lowering abstract instructions like "multiply" into moderately 6502-ey pseudo-instructions, and it's accordingly where most of the llvm-mos backend actually operates. There's also a variety of llvm-mos-specific passes; these implement logic that doesn't fit anywhere else in LLVM's existing framework.

Lastly, don't struggle alone (like I did); ask questions on our Discord instead! There's quite a bit of LLVM expertise floating around there at this point, and we might be able to save a lot of time on your end with just a little of ours.