What builder do you guys use?

i am currently making a compiler. i already finished making parsing using the pest crate and i made some custom IR code. but i now need to make a builder. i know already how to create a custom builder, but making the custom IR took long enough, so i wanted to see if there's any cool crates to make my life easier for this. please suggest any crate you guys know, I'd love to see what options would i have.

thanks!

Builder in what sense?

a builder for the compiler. meaning, something that takes in IR tokens as input, and for every IR token, it returns a String of the equivalent in another language. so for example, this c code:

int main() {return 0;}

could be turned into this IR:

<function> () -> int {<std::return>(int::0)} 

and then be compiled into assembly

section .text:
    global _start

_start:
    mov ebx 0
    mov eax 1
    syscall ; int 0x80, but simpler

or at least, this is the goal

So you want a compiler backend? Something like Cranelift?

1 Like

yeah, that's exactly what i want. i just wanted to see the different options the community suggests

If you want to target WebAssembly, the wasm-encoder crate is one of the most popular, and it's maintained by The Bytecode Alliance so you know it'll be the most up to date.

1 Like

I'd second the recommendation for cranelift as a good backend to target and contribute to.

2 Likes

If you want to work with LLVM specifically, take a look at inkwell.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.