How would you represent this operand stack in cranelift? (Has anybody wrote some JVM-Bytecode -> Cranelift Code)?
https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.bipush
If you are trying to emulate a stack machine you can try looking at how wasmtime translates wasm to cranelift, which also emulates a stack machine.
I think they just keep track of the stack of values at translation time. See here the code for add
@Afonso Bordado Thank you.
Next question: How can I divide two values? FuncInstBuilder does not have idiv
same for and/or
We have two instructions for division sdiv which divides two values as if they are signed integers and udiv which does the same but as if they are unsiged.
For bools we prefix instructions with a b, so you'll find those instructions as band and bor
Last updated: Dec 06 2025 at 06:05 UTC