Skip to content

Commit

Permalink
refactor: remove miden:core-import/types custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Oct 13, 2024
1 parent 402179b commit fe28b1c
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 180 deletions.
20 changes: 10 additions & 10 deletions tests/integration/expected/rust_sdk/basic_wallet.hir
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
;; Modules
(module #basic_wallet
;; Data Segments
(data (mut) (offset 1048576) 0x010000000100000001000000010000000100000001000000010000000100000002000000)
(data (mut) (offset 1048576) 0x0100000001000000010000000100000001000000010000000100000002000000)

;; Constants
(const (id 0) 0x00100000)
Expand Down Expand Up @@ -37,7 +37,7 @@

(func (export #__rust_alloc) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (const.i32 1048620))
(let (v3 i32) (const.i32 1048616))
(let (v4 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v3 v1 v0))
(br (block 1 v4)))

Expand All @@ -56,7 +56,7 @@
(func (export #__rust_realloc)
(param i32) (param i32) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32) (param v2 i32) (param v3 i32)
(let (v5 i32) (const.i32 1048620))
(let (v5 i32) (const.i32 1048616))
(let (v6 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v5 v2 v3))
(let (v7 i1) (eq v6 0))
(let (v8 i32) (zext v7))
Expand Down Expand Up @@ -86,7 +86,7 @@

(func (export #__rust_alloc_zeroed) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (const.i32 1048620))
(let (v3 i32) (const.i32 1048616))
(let (v4 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v3 v1 v0))
(let (v5 i1) (eq v4 0))
(let (v6 i32) (zext v5))
Expand Down Expand Up @@ -476,14 +476,14 @@
(let (v166 (ptr i64)) (inttoptr v164))
(let (v167 i64) (load v166))
(let (v168 u32) (bitcast v162))
(let (v169 u32) (add.checked v168 1048612))
(let (v169 u32) (add.checked v168 1048608))
(let (v170 u32) (mod.unchecked v169 4))
(assertz 250 v170)
(let (v171 (ptr i64)) (inttoptr v169))
(store v171 v167)
(let (v172 (ptr i32)) (global.symbol #__stack_pointer))
(store v172 v4)
(let (v173 i32) (const.i32 1048612))
(let (v173 i32) (const.i32 1048608))
(ret v173))
)

Expand Down Expand Up @@ -535,7 +535,7 @@
(block 6
(let (v9 i32) (const.i32 0))
(let (v10 u32) (bitcast v9))
(let (v11 u32) (add.checked v10 1048624))
(let (v11 u32) (add.checked v10 1048620))
(let (v12 (ptr u8)) (inttoptr v11))
(let (v13 u8) (load v12))
(let (v14 i32) (zext v13))
Expand All @@ -550,7 +550,7 @@
(block 0
(let (v0 i32) (const.i32 0))
(let (v1 u32) (bitcast v0))
(let (v2 u32) (add.checked v1 1048625))
(let (v2 u32) (add.checked v1 1048621))
(let (v3 (ptr u8)) (inttoptr v2))
(let (v4 u8) (load v3))
(let (v5 i32) (zext v4))
Expand All @@ -570,7 +570,7 @@
(let (v9 u32) (bitcast v8))
(let (v10 u8) (trunc v9))
(let (v11 u32) (bitcast v7))
(let (v12 u32) (add.checked v11 1048625))
(let (v12 u32) (add.checked v11 1048621))
(let (v13 (ptr u8)) (inttoptr v12))
(store v13 v10)
(br (block 2)))
Expand Down Expand Up @@ -1162,7 +1162,7 @@
(block 5
(let (v8 i32) (const.i32 0))
(let (v9 u32) (bitcast v8))
(let (v10 u32) (add.checked v9 1048624))
(let (v10 u32) (add.checked v9 1048620))
(let (v11 (ptr u8)) (inttoptr v10))
(let (v12 u8) (load v11))
(let (v13 i32) (zext v12))
Expand Down
165 changes: 69 additions & 96 deletions tests/integration/expected/rust_sdk/basic_wallet.wat
Original file line number Diff line number Diff line change
Expand Up @@ -19,67 +19,40 @@
(import "miden:base/core-types@1.0.0" (instance (;0;) (type 0)))
(type (;1;)
(instance
(type (;0;) s32)
(export (;1;) "ptr" (type (eq 0)))
(type (;2;) float32)
(export (;3;) "felt" (type (eq 2)))
(type (;0;) (func (result s32)))
(export (;0;) "heap-base" (func (type 0)))
)
)
(import "miden:core-import/types@1.0.0" (instance (;1;) (type 1)))
(alias export 1 "ptr" (type (;2;)))
(type (;3;)
(instance
(alias outer 1 2 (type (;0;)))
(export (;1;) "ptr" (type (eq 0)))
(type (;2;) (func (result 1)))
(export (;0;) "heap-base" (func (type 2)))
)
)
(import "miden:core-import/intrinsics-mem@1.0.0" (instance (;2;) (type 3)))
(alias export 1 "felt" (type (;4;)))
(type (;5;)
(import "miden:core-import/intrinsics-mem@1.0.0" (instance (;1;) (type 1)))
(type (;2;)
(instance
(alias outer 1 4 (type (;0;)))
(export (;1;) "felt" (type (eq 0)))
(type (;2;) (func (param "a" 1) (param "b" 1) (result 1)))
(export (;0;) "add" (func (type 2)))
(type (;0;) (func (param "a" float32) (param "b" float32) (result float32)))
(export (;0;) "add" (func (type 0)))
)
)
(import "miden:core-import/intrinsics-felt@1.0.0" (instance (;3;) (type 5)))
(alias export 1 "ptr" (type (;6;)))
(type (;7;)
(import "miden:core-import/intrinsics-felt@1.0.0" (instance (;2;) (type 2)))
(type (;3;)
(instance
(alias outer 1 6 (type (;0;)))
(export (;1;) "ptr" (type (eq 0)))
(type (;2;) (func (param "a0" s32) (param "a1" s32) (param "a2" s32) (param "a3" s32) (param "a4" s32) (param "a5" s32) (param "a6" s32) (param "a7" s32) (param "result-ptr" 1)))
(export (;0;) "hash-one-to-one" (func (type 2)))
(type (;0;) (func (param "a0" s32) (param "a1" s32) (param "a2" s32) (param "a3" s32) (param "a4" s32) (param "a5" s32) (param "a6" s32) (param "a7" s32) (param "result-ptr" s32)))
(export (;0;) "hash-one-to-one" (func (type 0)))
)
)
(import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" (instance (;4;) (type 7)))
(alias export 1 "felt" (type (;8;)))
(alias export 1 "ptr" (type (;9;)))
(type (;10;)
(import "miden:core-import/stdlib-crypto-hashes-blake3@1.0.0" (instance (;3;) (type 3)))
(type (;4;)
(instance
(alias outer 1 8 (type (;0;)))
(export (;1;) "felt" (type (eq 0)))
(alias outer 1 9 (type (;2;)))
(export (;3;) "ptr" (type (eq 2)))
(type (;4;) (func (param "asset0" 1) (param "asset1" 1) (param "asset2" 1) (param "asset3" 1) (param "result-ptr" 3)))
(export (;0;) "add-asset" (func (type 4)))
(export (;1;) "remove-asset" (func (type 4)))
(type (;0;) (func (param "asset0" float32) (param "asset1" float32) (param "asset2" float32) (param "asset3" float32) (param "result-ptr" s32)))
(export (;0;) "add-asset" (func (type 0)))
(export (;1;) "remove-asset" (func (type 0)))
)
)
(import "miden:core-import/account@1.0.0" (instance (;5;) (type 10)))
(alias export 1 "felt" (type (;11;)))
(type (;12;)
(import "miden:core-import/account@1.0.0" (instance (;4;) (type 4)))
(type (;5;)
(instance
(alias outer 1 11 (type (;0;)))
(export (;1;) "felt" (type (eq 0)))
(type (;2;) (func (param "asset0" 1) (param "asset1" 1) (param "asset2" 1) (param "asset3" 1) (param "tag" 1) (param "note-type" 1) (param "recipient0" 1) (param "recipient1" 1) (param "recipient2" 1) (param "recipient3" 1) (result 1)))
(export (;0;) "create-note" (func (type 2)))
(type (;0;) (func (param "asset0" float32) (param "asset1" float32) (param "asset2" float32) (param "asset3" float32) (param "tag" float32) (param "note-type" float32) (param "recipient0" float32) (param "recipient1" float32) (param "recipient2" float32) (param "recipient3" float32) (result float32)))
(export (;0;) "create-note" (func (type 0)))
)
)
(import "miden:core-import/tx@1.0.0" (instance (;6;) (type 12)))
(import "miden:core-import/tx@1.0.0" (instance (;5;) (type 5)))
(core module (;0;)
(type (;0;) (func (param f32 f32) (result f32)))
(type (;1;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32)))
Expand All @@ -106,15 +79,15 @@
(func $__wasm_call_ctors (;6;) (type 5))
(func $basic_wallet::bindings::__link_custom_section_describing_imports (;7;) (type 5))
(func $__rust_alloc (;8;) (type 6) (param i32 i32) (result i32)
i32.const 1048620
i32.const 1048616
local.get 1
local.get 0
call $<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc
)
(func $__rust_dealloc (;9;) (type 7) (param i32 i32 i32))
(func $__rust_realloc (;10;) (type 8) (param i32 i32 i32 i32) (result i32)
block ;; label = @1
i32.const 1048620
i32.const 1048616
local.get 2
local.get 3
call $<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc
Expand All @@ -135,7 +108,7 @@
)
(func $__rust_alloc_zeroed (;11;) (type 6) (param i32 i32) (result i32)
block ;; label = @1
i32.const 1048620
i32.const 1048616
local.get 1
local.get 0
call $<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc
Expand Down Expand Up @@ -368,10 +341,10 @@
i32.const 0
local.get 2
i64.load offset=8
i64.store offset=1048612 align=4
i64.store offset=1048608 align=4
local.get 3
global.set $__stack_pointer
i32.const 1048612
i32.const 1048608
return
end
unreachable
Expand Down Expand Up @@ -400,7 +373,7 @@
i32.eqz
br_if 2 (;@1;)
i32.const 0
i32.load8_u offset=1048624
i32.load8_u offset=1048620
drop
local.get 3
local.get 2
Expand All @@ -424,12 +397,12 @@
(func $wit_bindgen_rt::run_ctors_once (;19;) (type 5)
block ;; label = @1
i32.const 0
i32.load8_u offset=1048625
i32.load8_u offset=1048621
br_if 0 (;@1;)
call $__wasm_call_ctors
i32.const 0
i32.const 1
i32.store8 offset=1048625
i32.store8 offset=1048621
end
)
(func $<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc (;20;) (type 12) (param i32 i32 i32) (result i32)
Expand Down Expand Up @@ -731,7 +704,7 @@
local.get 3
br_if 0 (;@2;)
i32.const 0
i32.load8_u offset=1048624
i32.load8_u offset=1048620
drop
local.get 2
local.get 1
Expand Down Expand Up @@ -836,32 +809,32 @@
(export "cabi_realloc_wit_bindgen_0_28_0" (func $cabi_realloc_wit_bindgen_0_28_0))
(export "cabi_realloc" (func $cabi_realloc))
(elem (;0;) (i32.const 1) func $basic_wallet::bindings::__link_custom_section_describing_imports $cabi_realloc)
(data $.rodata (;0;) (i32.const 1048576) "\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00")
(data $.rodata (;0;) (i32.const 1048576) "\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\01\00\00\00\02\00\00\00")
)
(alias export 3 "add" (func (;0;)))
(alias export 2 "add" (func (;0;)))
(core func (;0;) (canon lower (func 0)))
(core instance (;0;)
(export "add" (func 0))
)
(alias export 4 "hash-one-to-one" (func (;1;)))
(alias export 3 "hash-one-to-one" (func (;1;)))
(core func (;1;) (canon lower (func 1)))
(core instance (;1;)
(export "hash-one-to-one" (func 1))
)
(alias export 2 "heap-base" (func (;2;)))
(alias export 1 "heap-base" (func (;2;)))
(core func (;2;) (canon lower (func 2)))
(core instance (;2;)
(export "heap-base" (func 2))
)
(alias export 5 "add-asset" (func (;3;)))
(alias export 4 "add-asset" (func (;3;)))
(core func (;3;) (canon lower (func 3)))
(alias export 5 "remove-asset" (func (;4;)))
(alias export 4 "remove-asset" (func (;4;)))
(core func (;4;) (canon lower (func 4)))
(core instance (;3;)
(export "add-asset" (func 3))
(export "remove-asset" (func 4))
)
(alias export 6 "create-note" (func (;5;)))
(alias export 5 "create-note" (func (;5;)))
(core func (;5;) (canon lower (func 5)))
(core instance (;4;)
(export "create-note" (func 5))
Expand All @@ -876,31 +849,31 @@
)
(alias core export 5 "memory" (core memory (;0;)))
(alias core export 5 "cabi_realloc" (core func (;6;)))
(alias export 0 "core-asset" (type (;13;)))
(type (;14;) (func (param "core-asset" 13)))
(alias export 0 "core-asset" (type (;6;)))
(type (;7;) (func (param "core-asset" 6)))
(alias core export 5 "miden:basic-wallet/basic-wallet@1.0.0#receive-asset" (core func (;7;)))
(func (;6;) (type 14) (canon lift (core func 7)))
(alias export 0 "tag" (type (;15;)))
(alias export 0 "note-type" (type (;16;)))
(alias export 0 "recipient" (type (;17;)))
(type (;18;) (func (param "core-asset" 13) (param "tag" 15) (param "note-type" 16) (param "recipient" 17)))
(func (;6;) (type 7) (canon lift (core func 7)))
(alias export 0 "tag" (type (;8;)))
(alias export 0 "note-type" (type (;9;)))
(alias export 0 "recipient" (type (;10;)))
(type (;11;) (func (param "core-asset" 6) (param "tag" 8) (param "note-type" 9) (param "recipient" 10)))
(alias core export 5 "miden:basic-wallet/basic-wallet@1.0.0#send-asset" (core func (;8;)))
(func (;7;) (type 18) (canon lift (core func 8)))
(alias export 0 "felt" (type (;19;)))
(type (;20;) (func (param "a" 19) (param "b" 19) (result 19)))
(func (;7;) (type 11) (canon lift (core func 8)))
(alias export 0 "felt" (type (;12;)))
(type (;13;) (func (param "a" 12) (param "b" 12) (result 12)))
(alias core export 5 "miden:basic-wallet/basic-wallet@1.0.0#test-felt-intrinsics" (core func (;9;)))
(func (;8;) (type 20) (canon lift (core func 9)))
(type (;21;) (list u8))
(type (;22;) (func (param "input" 21) (result 21)))
(func (;8;) (type 13) (canon lift (core func 9)))
(type (;14;) (list u8))
(type (;15;) (func (param "input" 14) (result 14)))
(alias core export 5 "miden:basic-wallet/basic-wallet@1.0.0#test-stdlib" (core func (;10;)))
(alias core export 5 "cabi_post_miden:basic-wallet/basic-wallet@1.0.0#test-stdlib" (core func (;11;)))
(func (;9;) (type 22) (canon lift (core func 10) (memory 0) (realloc 6) (post-return 11)))
(alias export 0 "felt" (type (;23;)))
(alias export 0 "word" (type (;24;)))
(alias export 0 "core-asset" (type (;25;)))
(alias export 0 "tag" (type (;26;)))
(alias export 0 "recipient" (type (;27;)))
(alias export 0 "note-type" (type (;28;)))
(func (;9;) (type 15) (canon lift (core func 10) (memory 0) (realloc 6) (post-return 11)))
(alias export 0 "felt" (type (;16;)))
(alias export 0 "word" (type (;17;)))
(alias export 0 "core-asset" (type (;18;)))
(alias export 0 "tag" (type (;19;)))
(alias export 0 "recipient" (type (;20;)))
(alias export 0 "note-type" (type (;21;)))
(component (;0;)
(type (;0;) (record (field "inner" float32)))
(import "import-type-felt" (type (;1;) (eq 0)))
Expand Down Expand Up @@ -944,23 +917,23 @@
(type (;32;) (func (param "input" 31) (result 31)))
(export (;7;) "test-stdlib" (func 3) (func (type 32)))
)
(instance (;7;) (instantiate 0
(instance (;6;) (instantiate 0
(with "import-func-receive-asset" (func 6))
(with "import-func-send-asset" (func 7))
(with "import-func-test-felt-intrinsics" (func 8))
(with "import-func-test-stdlib" (func 9))
(with "import-type-felt" (type 23))
(with "import-type-word" (type 24))
(with "import-type-core-asset" (type 25))
(with "import-type-tag" (type 26))
(with "import-type-recipient" (type 27))
(with "import-type-note-type" (type 28))
(with "import-type-core-asset0" (type 13))
(with "import-type-tag0" (type 15))
(with "import-type-note-type0" (type 16))
(with "import-type-recipient0" (type 17))
(with "import-type-felt0" (type 19))
(with "import-type-felt" (type 16))
(with "import-type-word" (type 17))
(with "import-type-core-asset" (type 18))
(with "import-type-tag" (type 19))
(with "import-type-recipient" (type 20))
(with "import-type-note-type" (type 21))
(with "import-type-core-asset0" (type 6))
(with "import-type-tag0" (type 8))
(with "import-type-note-type0" (type 9))
(with "import-type-recipient0" (type 10))
(with "import-type-felt0" (type 12))
)
)
(export (;8;) "miden:basic-wallet/basic-wallet@1.0.0" (instance 7))
(export (;7;) "miden:basic-wallet/basic-wallet@1.0.0" (instance 6))
)
Loading

0 comments on commit fe28b1c

Please sign in to comment.