Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFC: Translate to Cranelift #41

Open
Araq opened this issue Aug 30, 2024 · 3 comments
Open

NIFC: Translate to Cranelift #41

Araq opened this issue Aug 30, 2024 · 3 comments

Comments

@Araq
Copy link
Member

Araq commented Aug 30, 2024

NIFC cannot only be translated to C. It can also be translated to Cranelift giving us native code without undefined behavior nonsense. Cranelift also offers a JIT for our compile-time needs.

If the dependency to Cranelift turns out to be a problem in the longer run, port its implementation to Nim, its IR is incredibly well designed ("SSA without the obscure Phi nodes") and simple yet powerful.

@ASVIEST
Copy link

ASVIEST commented Aug 30, 2024

I believe that directly converting NIFC to cranelift would be a mistake, you need to create an intermediate nif layer (NIF-BB) that expresses the control flow through the basic blocks before doing so. Then writing the backend would be much easier and not as error prone.

@Araq
Copy link
Member Author

Araq commented Aug 30, 2024

My plan is to generate a NIF based syntax instead of cranelift's adhoc syntax. We can call that NIF-BB, yes.

@Araq
Copy link
Member Author

Araq commented Aug 31, 2024

Cranelift's tooling simply isn't ready for any of this. There is not even an assembler-like tool and the one I've written produces terrible error messages. There is no documention to speak of beyond "read the Rust code".

@Araq Araq added wontfix This will not be worked on Postponed and removed wontfix This will not be worked on labels Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants