-
Notifications
You must be signed in to change notification settings - Fork 702
Description
IIRC the set of valid instructions in constant expressions was designed to be extended over time. Currently we only allow global.get and t.const (e.g. i32.const).
For llvm's dynamic linking (and PIC in general) ABI it would be very useful to at least be able to do i32.add and i64.add. In the (currently experimental) PIC ABI we model function and data addresses as wasm globals storing absolute table and memory offsets. Because we can't to addition in the constant expressions we are forced to mark these globals as mutable (even though logically they are immutable after initialization) and generate startup/relocation code to set them to their correct values. This is done by adding offsets to __memory_base and __table_base which are imported globals.
For this use case we only need integer addition but I would probably make sense to consider wider set of instructions. e.g. all arithmetic operations.
(sorry if this is a duplicate issue, I tried searching for constant expressions but couldn't find anything).