Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm -> Miden IR translation #22

Merged
merged 78 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
31c1c88
feat: draft Wasm -> Miden IR translator, handling control flow ops an…
greenhat Aug 19, 2023
f3fc66f
chore: better var names, cleanup comments
greenhat Aug 24, 2023
c8292f9
fix: check for duplicates in Module::declare_function
greenhat Aug 24, 2023
f26fdef
chore: update expected module name in tests
greenhat Aug 24, 2023
07da762
feat: add Rust -> Wasm -> Miden IR test pipeline with a simple functi…
greenhat Aug 24, 2023
6522e10
chore: add Rust->Wasm->IR Fibonacci example
greenhat Aug 25, 2023
422a519
chore: make a temp dir for Rust->Wasm compilation tests artifacts
greenhat Aug 26, 2023
29fd885
chore: install wasm32-unknown-unknown target for test task in Makefil…
greenhat Aug 26, 2023
c039efb
chore: cleanup rust compilation test;
greenhat Aug 27, 2023
945ede0
feat: handle BrTable and CallIndirect usupported Wasm instructions
greenhat Aug 27, 2023
ae9e14a
feat: Wasm memory store/load ops translation
greenhat Aug 28, 2023
b299fa5
feat: Wasm memory.grow and memory.size translation
greenhat Aug 28, 2023
8c8be39
fix: pass SourceSpan in translate_operator
greenhat Aug 28, 2023
9a8a56e
refactor: move all unsupported Wasm ops to catch-all case
greenhat Aug 28, 2023
aae268e
feat: run wasmparser's validator when parsing function bodies
greenhat Aug 30, 2023
a361985
test: add per-instruction test for every implemented Wasm instruction
greenhat Aug 30, 2023
76eccc6
feat: add i32.popcnt, i64.extend_i32_s, extend_i32_u Wasm ops transla…
greenhat Sep 1, 2023
474c45f
test: silence diagnostic output in tests
greenhat Sep 1, 2023
9c8434d
chore: re-word unsupported Wasm feature error message;
greenhat Sep 1, 2023
7eead13
test: add test for unsupported Wasm spec v1 instructions
greenhat Sep 1, 2023
d2a4c82
feat: Wasm i32.and, i32.or, i64.and, i64.or translation
greenhat Sep 1, 2023
f69540a
chore: import `Type::*` and remove repetitive `Type::`;
greenhat Sep 1, 2023
4a5eaa5
feat: i32 and i64 variants of `shl` and `xor` Wasm ops translation
greenhat Sep 3, 2023
396c695
chore: remove todo! for Wasm `select` and `unreachable`
greenhat Sep 3, 2023
cdd6981
feat: Wasm `shr_u`, `rotl`, `rotr` i32 and i64 instructions translation
greenhat Sep 3, 2023
edea9bf
feat: Wasm `f64.add, sub` and integer `sub` translation
greenhat Sep 3, 2023
31f927d
feat: Wasm integer `mul`, `div_u`, `rem_u` and f64 `mul`, `div`, `min…
greenhat Sep 3, 2023
f41d9fb
feat: Wasm integer `lt_u`, `le_u`, `ge_u` and `gt_u` operators transl…
greenhat Sep 3, 2023
d0000f4
feat: Wasm `eqz`, `eq`, `ne`, `lt`, `gt`, `le`, `ge` integer and f64 …
greenhat Sep 4, 2023
1071825
chore: add BrTable(commented) to unsupported instructions test
greenhat Sep 4, 2023
6c912cf
fix: fix build and tests after rebasing on top of bitwalker/wip branch
greenhat Sep 6, 2023
a0677c5
test: fix the test for unsupported ops
greenhat Sep 6, 2023
e7f8b6a
fix: handle InvalidFunctionError in ModuleEnviromnment::build
greenhat Sep 6, 2023
9a43036
chore: fix build after rebase
greenhat Sep 7, 2023
68e63b2
fix: make `add`, `mul` and `sub` to use wrapping Miden operations
greenhat Sep 7, 2023
23e2d98
feat: Wasm `select` op translation
greenhat Sep 8, 2023
0a325a0
feat: Wasm `unreachable` op translation
greenhat Sep 8, 2023
78c46a1
feat: Wasm br_table translation
greenhat Sep 8, 2023
fc9f59c
feat: cast arguments for unsigned Wasm ops, implement signed Wasm ops…
greenhat Sep 10, 2023
7562894
feat: Wasm `i32.wrap_i64` translation
greenhat Sep 10, 2023
be05156
feat: Wasm globals (`global.get`,`set`) translation
greenhat Sep 24, 2023
af2922b
refactor: remove `FuncEnvironment` and use `ModuleInfo` directly
greenhat Sep 13, 2023
a6fbc2e
chore: skip `@producers` Wasm section when printing wasm in Rust comp…
greenhat Sep 14, 2023
b7c5619
chore: remove caching for Rust -> Wasm compilation artifacts in tests
greenhat Sep 16, 2023
19263a4
feat: Wasm data section parsing
greenhat Sep 17, 2023
5a288a7
refactor: avoid unnecessary allocation by making `DataSegment::data` …
greenhat Sep 17, 2023
8b81560
fix: set `state.reachable = false` for `Operator::Unreachable`
greenhat Sep 18, 2023
2cb627c
fix: skip Wasm element section instead of failing
greenhat Sep 18, 2023
a427fae
chore: print types on type mismatch error when defining a variable;
greenhat Sep 18, 2023
ccd6c6b
fix: cast u32/u64 back to Wasm ops expected i32/i64 after `shr_u`, `d…
greenhat Sep 18, 2023
d0d33cf
fix: Cast i1 back to i32/i64 expected by Wasm ops after comparison ops
greenhat Sep 18, 2023
e293776
chore: `check_ir_files` variant with expected wat and mir files;
greenhat Sep 19, 2023
80b618b
fix: cast i64 comparison ops result to i32 to preserve Wasm op semantics
greenhat Sep 19, 2023
6af205f
fix: handle missing `Instruction::Switch` in jump destination changes
greenhat Sep 19, 2023
329cae9
refactor: move module_translator tests to code_translator test,
greenhat Sep 19, 2023
ba294e0
refactor: move `module_env` to the root of the crate, remove `environ…
greenhat Sep 19, 2023
559ec2e
refactor: make `translation_utils::block_with_params` a `FunctionBuil…
greenhat Sep 19, 2023
429165b
chore: remove float point ops translation;
greenhat Sep 19, 2023
d3d1117
test: Rust code using dlmalloc in no_std
greenhat Sep 22, 2023
207535a
test: Rust code using dlmalloc in no_std
greenhat Sep 22, 2023
e2eb1d3
test: Rust code with `div`, `rem`, `shr` signed and unsigned ops
greenhat Sep 22, 2023
bd4b566
feat: declare data segments in module, remove ptr type casting for `g…
greenhat Sep 24, 2023
acb1ee6
test: use `panic_immediate_abort` std feature to avoid core::fmt (use…
greenhat Sep 24, 2023
d861eb0
test: install rust-src component on CI
greenhat Sep 25, 2023
312c316
feat: translate Wasm `memory.grow` op
greenhat Sep 25, 2023
1148d97
chore: fix build after rebase
greenhat Oct 14, 2023
a7eae31
fix: cast pointer in memory access ops and br_table selector to U32
greenhat Oct 14, 2023
55fd26b
chore: ignore dlmalloc test because hash part in mangled function nam…
greenhat Oct 14, 2023
4110cc2
fix: set reduced load/store mem ops ptr type to unsigned,
greenhat Oct 16, 2023
0dea190
refactor: use `ModuleFunctionBuilder` instead of `FunctionBuilder` in…
greenhat Oct 17, 2023
5d84fa3
feat: add `Function::builder` method
greenhat Oct 17, 2023
51595d4
test: update expected IR for dlmalloc test
greenhat Oct 17, 2023
dfc86df
refactor: remove `ValueData::Alias`
greenhat Oct 17, 2023
da74790
chore: code cleanup
greenhat Oct 17, 2023
f0eb478
fix: fix build after rebase
greenhat Oct 19, 2023
c275566
refactor: use `*_imm` op variant where possible
greenhat Oct 19, 2023
21ed2b3
refactor: more readable `mem_total_pages` implementation
greenhat Oct 19, 2023
699e26e
chore: add a debug assert to not allow declaring a block predecessor …
greenhat Oct 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 193 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ members = [
"hir-transform",
"hir-type",
"tools/*",
"frontend-wasm",
"tests/rust-wasm-tests"
]

[workspace.package]
Expand Down Expand Up @@ -40,7 +42,11 @@ parking_lot = "0.12"
parking_lot_core = "0.9"
pretty_assertions = "1.0"
rustc-hash = "1.1"
smallvec = { version = "1.9", features = ["union", "const_generics", "const_new"] }
smallvec = { version = "1.9", features = [
"union",
"const_generics",
"const_new",
] }
smallstr = { version = "0.3", features = ["union"] }
thiserror = "1.0"
miden-assembly = "0.7"
Expand All @@ -53,6 +59,7 @@ miden-hir-symbol = { path = "hir-symbol" }
miden-hir-transform = { path = "hir-transform" }
miden-hir-type = { path = "hir-type" }
miden-parsing = "0.1"
miden-frontend-wasm = { path = "frontend-wasm" }

[profile.release]
opt-level = 2
Expand Down
13 changes: 13 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,24 @@ category = "Test"
description = "Runs all tests"
dependencies = ["test-rust", "test-filecheck"]

[tasks.install-wasm-target]
category = "Test"
description = "Install wasm32-unknown-unknown target"
command = "rustup"
args = ["target", "add", "wasm32-unknown-unknown", "--toolchain", "${CARGO_MAKE_TOOLCHAIN}"]

[tasks.install-rust-src]
category = "Test"
description = "Install rust-src component"
command = "rustup"
args = ["component", "add", "rust-src", "--toolchain", "${CARGO_MAKE_TOOLCHAIN}"]

[tasks.test-rust]
category = "Test"
description = "Runs tests written in Rust"
command = "rustup"
args = ["run", "${CARGO_MAKE_TOOLCHAIN}", "cargo", "test", "@@remove-empty(CARGO_MAKE_CARGO_VERBOSE_FLAGS)", "@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )", "${@}"]
dependencies = ["install-wasm-target", "install-rust-src"]

[tasks.test-filecheck]
category = "Test"
Expand Down
Loading
Loading