Stream: cranelift

Topic: Silly questions


view this post on Zulip Firestar99 (Jan 14 2026 at 16:25):

I'm investigating cranelift since the beginning of this week and have a few questions. Instead of creating a bunch of threads, I thought I'd cummulate them here :D

view this post on Zulip Firestar99 (Jan 14 2026 at 16:28):

What's the difference between a StackSlot and a DynamicStackSlot? Is DynamicStackSlot only used to put DynamicTypes on the stack, for what are those used? I remember something about ARM having a dynamically sized SIMD width, could it be for that?

view this post on Zulip Chris Fallin (Jan 14 2026 at 16:29):

yes, exactly, and only for its new SVE instruction set, which isn't really fully supported in our compiler

view this post on Zulip Firestar99 (Jan 15 2026 at 12:19):

I've been reading into isle for a few days now, and I see this pattern in tutorial.isle:

(decl lower (HighLevelInst) LowLevelInst)
(rule lower ...)
(decl inst_result (HighLevelInst) Value)
(extern extractor inst_result inst_result)

I see these decl as rust function calls, in macro-rules form (decl $name:ident $($param:ty),+ $result:ty). So isle would generate to this in rust, ignoring self:

fn constructor_lower(_: HighLevelInst) -> LowLevelInst { ... }
fn inst_result(_: HighLevelInst) -> Option<Value> { ... }

(I think constructors only return Option<_> if the decl has partial?)

Now in the prelude.lower I'm coming across this:

(decl value_type (Type) Value)
(extern extractor infallible value_type value_type)

which I would think should be:

fn value_type(val: Type) -> Value { ... }

but it is actually:

fn value_type(val: Value) -> Type { ... }

Why are params and return type suddenly swapped?
(Logically, it ofc only sense to turn an SSA value into a result type, not the other way around)

These "swapped params / results" go all the way up to has_type, where I originally encountered it:

(decl result_type (Type) Inst)
(extractor (result_type ty)
           (first_result (value_type ty)))
(decl has_type (Type Inst) Inst)
(extractor (has_type ty inst)
           (and (result_type ty)
                inst))
A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime
A lightweight WebAssembly runtime that is fast, secure, and standards-compliant - bytecodealliance/wasmtime

view this post on Zulip Firestar99 (Jan 15 2026 at 13:08):

I assume the answer is that extern extractors "swap" return type and args within Rust compared to their constructor counterparts, since they "work in reverse" to constructors? Which would allow isle extractors, constructors and types (implicitly declaring both) to be declared with the exact same arg order, but extractors ofc "working in reverse".

view this post on Zulip Chris Fallin (Jan 15 2026 at 13:46):

Yep, exactly


Last updated: Jan 29 2026 at 13:25 UTC