C compiler

From llvm-mos
Jump to navigation Jump to search

A backend has been added to Clang to support the MOS instruction set. This backend may be targeted by adding the flag --target=mos to clang.

The Clang is broadly compatible with the freestanding portion of the C99 standard, with one big caveat:

  • No float and no double. We'll eventually ship a working IEEE 754 soft float library with the compiler for completeness' sake, but we expect low demand for this, and it'll distract from the rest of the project.

Some of the GCC and Clang language extensions work, some don't. Similarly some of the C++ language features work, some don't. We haven't exhaustively catalogued this; there's a lot, and some are extremely obscure and nearly useless.

Still, some compiler extensions are de-facto standard, so we'll call out a few caveats for those.

Known Compiler Extension Caveats:

  • The GCC/Clang alignment directives work only for global and static variables, not automatic (local) variables. Aligning the stack pointer is tricky, since it requires use of a frame pointer; but the rigors of 6502 indexing cause our frame pointer to be useless for this purpose. To get this to work, we may need *two* frame pointers. Expected call for this feature is low, so if you need it, let us know, and we'll reprioritize.