Hacker News new | past | comments | ask | show | jobs | submit login
My First LLVM Compiler (2015) (wilfred.me.uk)
87 points by lrsjng 10 days ago | hide | past | web | favorite | 7 comments





I recently wrote a brainfuck compiler using Rust [0], but I targeted x86-64 asm directly. I implemented some very basic optimization (as you show at the bottom of your post), but I'd imagine llvm is able to take things much further. I'd be curious to see a performance comparison.

[0]: https://github.com/JoshMcguigan/nerve


State of the art compilers are ridiculously clever sometimes, so I imagine quite a lot.

I wonder how good they are at extracting information from code generated from BF however.


So why did he use gcc to link the program at the end?

I imagine it is because gcc -o is a convenient way to call the linker such that it correctly links the binary and libc. Doing this manually with ld would require several (non-portable) command line arguments that would be distracting from the main point of the post.

GCC is a front-end: in this case, it should just call ld.

Because he wrote a compiler but not a linker?

gcc is probably used to call the platforms linker



Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: