Stream: cranelift

Topic: > Cranelift documentation and guides


view this post on Zulip clacla (Aug 06 2024 at 12:40):

Hello, I am writing a programming language. I am trying translating my AST to Cranelift IR and then compile it to WASM.

I am having a hard time making progress. I was able to write a basic function with numeric variable. But now I am having a really hard time to translate more of my language AST to Cranelift IR.

Specifically I am having a hard time doing simple things like:

Apart from the API documentation, cranelift-jit-demo and kaleidoscope-cranelift I have not found any guide, examples or extensive documentation. I am not a compiler expert so I need more help probably.

Do you have any documentation, guides or well documented examples that you can share? 

Thank you very much

PS: I originally posted this message in the SIG Documentation channel, but since I got no reply I reposted it here.

JIT compiler and runtime for a toy language, using Cranelift - bytecodealliance/cranelift-jit-demo
Tutorial to learn to use the cranelift compiler backend - CraneStation/kaleidoscope-cranelift

view this post on Zulip Chris Fallin (Aug 06 2024 at 14:58):

clacla said:

Hello, I am writing a programming language. I am trying translating my AST to Cranelift IR and then compile it to WASM.

[ ... ]

hard time doing simple things like:
[ ... ]

Unfortunately Cranelift does not support Wasm as a target; only the four native ISAs x86-64, aarch64, riscv64, and s390x. If your goal is to generate Wasm I'd recommend looking into libraries like walrus or waffle, or perhaps Binaryen's producer API.

view this post on Zulip clacla (Aug 06 2024 at 16:12):

Thank you a lot Chris. I re-read the Cranelift documentation and now I get it. I was using it for something wrong. My bad.

Thank you also for suggesting walrus and Binaryen. I will experiment with these frameworks, they seem to be made for what I need


Last updated: Oct 23 2024 at 20:03 UTC