ELVM
ELVM is a compiler infrastructure (similar to LLVM) for esoteric (and some non-esoteric) languages. It can be used to compile C to many esoteric and other languages. An online demonstration can be found here.
ELVM is similar to LLVM but dedicated to esoteric languages. This project consists of two components - frontend and backend. Currently, the only frontend we have is a modified version of 8cc. The modified 8cc translates C code to an internal representation format called ELVM IR (EIR). Unlike LLVM bitcode, EIR is designed to be extremely simple, so there's more chance we can write a translator from EIR to an esoteric language.
Some backends include:
- Brainfuck
- Befunge
- Unlambda
- Whitespace
- Turing Machine
- Python
- Javascript
- C
- ... And many others!
Contributions, such as adding features (e.g. bit operations), adding backends, and others, would be welcome!
Internals
- Harvard architecture, not Neumann (allowing self-modifying code is hard)
- 6 registers: A, B, C, D, SP, and BP
- Ops: mov, add, sub, load, store, setcc, jcc, putc, getc, and exit
- Psuedo ops: .text, .data, .long, and .string
- mul/div/mod are implemented by _builtin*
- No bit operations
- No floating point arithmetic
- sizeof(char) == sizeof(int) == sizeof(void*) == 1
- The word-size is backend dependent, but most backend uses 24bit words
- A single programming counter may contain multiple operations