sheredom / yair

🦜 yair - a high-level compiler IR entirely written in Rust
https://sheredom.github.io/yair
Creative Commons Zero v1.0 Universal
35 stars 1 forks source link

Library That Could Be Useful for Designing the Optimizer #14

Open zicklag opened 3 years ago

zicklag commented 3 years ago

Hey there! I just found this and thought it was interesting because I've been thinking about what it would look like to build essentially an LLVM replacement in Rust, not that I have the time or any compiler experience to do so. :)

Still, I found this library called egg that could be used for creating the optimizer using equality saturation. After walking through the tutorial I was so amazed by how well it seemed like it could work that I wanted to write a compiler just so I could test out the possibilities for optimization using egg.

Anyway, this is probably way pre-mature being that it doesn't look like you have code generation yet ( Edit: Oh, wait maybe you do have LLVM codegen ). Take it or leave it, but I thought the idea might be useful. ;)

sheredom commented 3 years ago

Always happy for people to give me some fun reading material - I'll take a look thanks!

sheredom commented 3 years ago

Oh and yeah I do have LLVM code-generation - the debug info doesn't work yet, I need to actually reimplement the mess that is target ABI function signature, and I really need to build some binaries, do a load library, and make sure some stuff works.

I really want to use cranelift for the target code - but since I know LLVM pretty well I thought I'd start with what I know (and what seems to be the logical first integration these days).

zicklag commented 3 years ago

Yeah, I would love to have codegen written in Rust for a project, but the security aspect of cranelift is what makes me hesitant to use it over LLVM for anything security sensitive:

image

LLVM still seems like the most solid option out there for now, but cranelift is exciting to look out for.


Disclaimer: I know nothing about writing compilers, I just look around and entertain the idea of writing cool stuff in different fields. :wink: