bytecodealliance / bytecodealliance/wasmtime
Define a textual representation of a cranelift module
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
#### Feature
Define a textual representation of a cranelift module that is like the current clir ir text form, but with added support for defining data objects, importing extern functions and data objects, defining linkage and giving everything a name that isn't limited to 16 characters ascii characters.
#### Benefit
This allows writing and reading a whole cranelift module as text file, making it easier to find problems with what you defined, making changes while debugging quicker and making cranelift easier to use from non-rust users. (https://bytecodealliance.zulipchat.com/#narrow/stream/217117-cranelift/topic/using.20cranelift.20as.20a.20backend.20for.20a.20non-rust.20compiler/near/212909451).
#### Implementation
Part of the serialization could be handled by `ModuleDeclarations` and the rest needs to be handled by a custom `Module` implementor. The deserialization needs to take an `&mut impl Module` as argument.
The textual representation could be like the following:
```
; declare: "puts" = import func0(i64) -> i32
; declare: "print_hello" = export func1()
; declare: "hello_str" = local data0() ro
; === the part above could be handled by `ModuleDeclarations` ===
; data: "hello_str" = "Hello World!\0"
function u0:1() system_v {
sig0 = (i64) -> i32 system_v
fn0 = u0:0 sig0
gv0 = symbol u1:0
block0:
v0 = global_value gv0
call fn0(v0)
}
```
#### Alternatives
Contributor guide
Assessment
This issue has not been assessed yet.