1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
(module
(import "env" "pair" (func $pair (result i32 i64)))
(global $g1 (mut (i32 i64)) (tuple.make (i32.const 0) (i64.const 0)))
(global $g2 (i32 i64) (tuple.make (i32.const 0) (i64.const 0)))
;; Test basic lowering of tuple.make, tuple.extract, and tuple variables
(func $triple (result i32 i64 f32)
(tuple.make
(i32.const 42)
(i64.const 7)
(f32.const 13)
)
)
(func $get-first (result i32)
(tuple.extract 0
(call $triple)
)
)
(func $get-second (result i64)
(tuple.extract 1
(call $triple)
)
)
(func $get-third (result f32)
(tuple.extract 2
(call $triple)
)
)
(func $reverse (result f32 i64 i32)
(local $x (i32 i64 f32))
(local.set $x
(call $triple)
)
(tuple.make
(tuple.extract 2
(local.get $x)
)
(tuple.extract 1
(local.get $x)
)
(tuple.extract 0
(local.get $x)
)
)
)
(func $unreachable (result i64)
(tuple.extract 1
(tuple.make
(i32.const 42)
(i64.const 7)
(unreachable)
)
)
)
;; Test multivalue globals
(func $global (result i32 i64)
(global.set $g1
(tuple.make
(i32.const 42)
(i64.const 7)
)
)
(global.get $g2)
)
;; Test lowering of multivalue drops
(func $drop-call
(drop
(call $pair)
)
)
(func $drop-tuple-make
(drop
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
(func $drop-block
(drop
(block (result i32 i64)
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
)
;; Test multivalue control structures
(func $mv-return (result i32 i64)
(return
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
(func $mv-return-in-block (result i32 i64)
(block (result i32 i64)
(return
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
)
(func $mv-block-break (result i32 i64)
(block $l (result i32 i64)
(br $l
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
)
(func $mv-block-br-if (result i32 i64)
(block $l (result i32 i64)
(br_if $l
(tuple.make
(i32.const 42)
(i64.const 42)
)
(i32.const 1)
)
)
)
(func $mv-if (result i32 i64 externref)
(if (result i32 i64 externref)
(i32.const 1)
(tuple.make
(i32.const 42)
(i64.const 42)
(ref.null extern)
)
(tuple.make
(i32.const 42)
(i64.const 42)
(ref.null extern)
)
)
)
(func $mv-loop (result i32 i64)
(loop (result i32 i64)
(tuple.make
(i32.const 42)
(i64.const 42)
)
)
)
(func $mv-switch (result i32 i64)
(block $a (result i32 i64)
(block $b (result i32 i64)
(br_table $a $b
(tuple.make
(i32.const 42)
(i64.const 42)
)
(i32.const 0)
)
)
)
)
)
|