diff --git a/README.md b/README.md index 3bb612a..5fc4e43 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,85 @@ -http://vxcc.vxcc.dev/ +# VXCC +optimizing, small, simple, compiler backend. -# building -use the `./build.sh` +VXCC uses SSA IR with block arguments instead of the commonly used phi-nodes. -## deps +## compilation stages +- frontend generates non-SSA IR +- backend converts it to SSA +- backend applies optimizations +- backend converts it to "LL IR" (non-SSA + labels) and performs some more optimizations +- simple code generation + +## goals +- easily modifyable and readable code +- not much special knowladge required +- easy to implement code generation for any architecture +- make it easy for people to learn about compiler backends +- good-ish optimizations +- beat QBE + +## **non**-goals +- reach complexity of GCC or even LLVM +- beat GCC or LLVM + +## frontends +- [C3](https://c3-lang.org/) compiler [fork](https://github.com/alex-s168/c3c) + +## current status +| goal | | progress | +| --------------------------------------- | - | -------- | +| x86 codegen | ![#33cc33](https://placehold.co/15x15/33cc33/33cc33.png) | done but will be re-made | +| codegen of basic code involving loops | ![#33cc33](https://placehold.co/15x15/33cc33/33cc33.png) | done | +| basic optimizations | ![#33cc33](https://placehold.co/15x15/33cc33/33cc33.png) | done | +| struct support | ![#ff9900](https://placehold.co/15x15/ff9900/ff9900.png) | soon | +| proper register allocator & ISEL rework | ![#ff9900](https://placehold.co/15x15/ff9900/ff9900.png) | soon | +| floating point numbers | ![#cc0000](https://placehold.co/15x15/cc0000/cc0000.png) | planned | + +## building +use the `./build.sh build` + +## compile dependencies `clang`: different C compiler can be used by doing `CC=someothercc ./build.sh [build|test]` (`test` can be executed after `build` to run all tests) `python3`: it is recommended to create a venv in the repository root using `python -m venv venv` -## include into projects -Link with `build/lib.a` and `build/x86.a` +## including into projects +Link with all files returned by `./build.sh libfiles` (at time of writing, `build/lib.a` and `allib/build/all.a`) + +## using VXCC in a compiler +this is meant to be extremely easy to do (for the frontend developer) + +currently there is no documentation, but you can look at the [C3C fork](https://github.com/alex-s168/c3c) in the `src/compiler/vxcc_*` files. + +If you have any questions, you can ask me on Discord (`alex_s168`) or send me an [E-Mail](mailto:alexandernutz68@gmail.com) + +## contributing +all contributions are welcome! Don't hesitate to ask me if you have any questions. + +## current optimizations + + +## code-gen example +input: +```c +fn void strcpy(char* dest, char* src) @export +{ + for (usz i = 0; src[i] != '\0'; i ++) + dest[i] = src[i]; +} +``` +output: +```asm +strcpy: + xor r11d, r11d + .l0: + mov r9b, byte [rsi + 1 * r11] + test r9b, r9b + je .l1 + mov byte [rdi + 1 * r11], r9b + lea r8, [r11 + 1] + mov r11, r8 + jmp .l0 + .l1: + ret +```