Hey, I'm implementing FuncEnvironment::make_global, and struggling to figure out how to correctly use cranelift_wasm::GlobalVariable::Const (https://docs.rs/cranelift-wasm/0.69.0/cranelift_wasm/enum.GlobalVariable.html). My assumption was that I could create a Value using a constant, but seems I would need to insert an instruction (iconst, etc), and use the return Value? make_global also has no access to the builder (just the ir::Function), can you advise how I should go about inserting such an instruction?
You can create a FuncCursor
with the mutable function ref, and then insert any series of instruction that creates a Value, and set this to the GlobalVariable::Const value.
Last updated: Dec 23 2024 at 13:07 UTC