github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/integration_test/spectest/v2/testdata/simd_align.wast (about) 1 ;; Valid alignment 2 3 (module (memory 1) (func (drop (v128.load align=1 (i32.const 0))))) 4 (module (memory 1) (func (drop (v128.load align=2 (i32.const 0))))) 5 (module (memory 1) (func (drop (v128.load align=4 (i32.const 0))))) 6 (module (memory 1) (func (drop (v128.load align=8 (i32.const 0))))) 7 (module (memory 1) (func (drop (v128.load align=16 (i32.const 0))))) 8 9 (module (memory 1) (func (v128.store align=1 (i32.const 0) (v128.const i32x4 0 1 2 3)))) 10 (module (memory 1) (func (v128.store align=2 (i32.const 0) (v128.const i32x4 0 1 2 3)))) 11 (module (memory 1) (func (v128.store align=4 (i32.const 0) (v128.const i32x4 0 1 2 3)))) 12 (module (memory 1) (func (v128.store align=8 (i32.const 0) (v128.const i32x4 0 1 2 3)))) 13 (module (memory 1) (func (v128.store align=16 (i32.const 0) (v128.const i32x4 0 1 2 3)))) 14 15 (module (memory 1) (func (drop (v128.load8x8_s align=1 (i32.const 0))))) 16 (module (memory 1) (func (drop (v128.load8x8_s align=2 (i32.const 0))))) 17 (module (memory 1) (func (drop (v128.load8x8_s align=4 (i32.const 0))))) 18 (module (memory 1) (func (drop (v128.load8x8_s align=8 (i32.const 0))))) 19 (module (memory 1) (func (drop (v128.load8x8_u align=1 (i32.const 0))))) 20 (module (memory 1) (func (drop (v128.load8x8_u align=2 (i32.const 0))))) 21 (module (memory 1) (func (drop (v128.load8x8_u align=4 (i32.const 0))))) 22 (module (memory 1) (func (drop (v128.load8x8_u align=8 (i32.const 0))))) 23 (module (memory 1) (func (drop (v128.load16x4_s align=1 (i32.const 0))))) 24 (module (memory 1) (func (drop (v128.load16x4_s align=2 (i32.const 0))))) 25 (module (memory 1) (func (drop (v128.load16x4_s align=4 (i32.const 0))))) 26 (module (memory 1) (func (drop (v128.load16x4_s align=8 (i32.const 0))))) 27 (module (memory 1) (func (drop (v128.load16x4_u align=1 (i32.const 0))))) 28 (module (memory 1) (func (drop (v128.load16x4_u align=2 (i32.const 0))))) 29 (module (memory 1) (func (drop (v128.load16x4_u align=4 (i32.const 0))))) 30 (module (memory 1) (func (drop (v128.load16x4_u align=8 (i32.const 0))))) 31 (module (memory 1) (func (drop (v128.load32x2_s align=1 (i32.const 0))))) 32 (module (memory 1) (func (drop (v128.load32x2_s align=2 (i32.const 0))))) 33 (module (memory 1) (func (drop (v128.load32x2_s align=4 (i32.const 0))))) 34 (module (memory 1) (func (drop (v128.load32x2_s align=8 (i32.const 0))))) 35 (module (memory 1) (func (drop (v128.load32x2_u align=1 (i32.const 0))))) 36 (module (memory 1) (func (drop (v128.load32x2_u align=2 (i32.const 0))))) 37 (module (memory 1) (func (drop (v128.load32x2_u align=4 (i32.const 0))))) 38 (module (memory 1) (func (drop (v128.load32x2_u align=8 (i32.const 0))))) 39 40 (module (memory 1) (func (drop (v128.load8_splat align=1 (i32.const 0))))) 41 (module (memory 1) (func (drop (v128.load16_splat align=1 (i32.const 0))))) 42 (module (memory 1) (func (drop (v128.load16_splat align=2 (i32.const 0))))) 43 (module (memory 1) (func (drop (v128.load32_splat align=1 (i32.const 0))))) 44 (module (memory 1) (func (drop (v128.load32_splat align=2 (i32.const 0))))) 45 (module (memory 1) (func (drop (v128.load32_splat align=4 (i32.const 0))))) 46 (module (memory 1) (func (drop (v128.load64_splat align=1 (i32.const 0))))) 47 (module (memory 1) (func (drop (v128.load64_splat align=2 (i32.const 0))))) 48 (module (memory 1) (func (drop (v128.load64_splat align=4 (i32.const 0))))) 49 (module (memory 1) (func (drop (v128.load64_splat align=8 (i32.const 0))))) 50 51 ;; Invalid alignment 52 53 (assert_invalid 54 (module (memory 1) (func (drop (v128.load align=32 (i32.const 0))))) 55 "alignment must not be larger than natural" 56 ) 57 (assert_invalid 58 (module (memory 0) (func(v128.store align=32 (i32.const 0) (v128.const i32x4 0 0 0 0)))) 59 "alignment must not be larger than natural" 60 ) 61 (assert_invalid 62 (module (memory 1) (func (result v128) (v128.load8x8_s align=16 (i32.const 0)))) 63 "alignment must not be larger than natural" 64 ) 65 (assert_invalid 66 (module (memory 1) (func (result v128) (v128.load8x8_u align=16 (i32.const 0)))) 67 "alignment must not be larger than natural" 68 ) 69 (assert_invalid 70 (module (memory 1) (func (result v128) (v128.load16x4_s align=16 (i32.const 0)))) 71 "alignment must not be larger than natural" 72 ) 73 (assert_invalid 74 (module (memory 1) (func (result v128) (v128.load16x4_u align=16 (i32.const 0)))) 75 "alignment must not be larger than natural" 76 ) 77 (assert_invalid 78 (module (memory 1) (func (result v128) (v128.load32x2_s align=16 (i32.const 0)))) 79 "alignment must not be larger than natural" 80 ) 81 (assert_invalid 82 (module (memory 1) (func (result v128) (v128.load32x2_u align=16 (i32.const 0)))) 83 "alignment must not be larger than natural" 84 ) 85 (assert_invalid 86 (module (memory 1) (func (result v128) (v128.load8_splat align=2 (i32.const 0)))) 87 "alignment must not be larger than natural" 88 ) 89 (assert_invalid 90 (module (memory 1) (func (result v128) (v128.load16_splat align=4 (i32.const 0)))) 91 "alignment must not be larger than natural" 92 ) 93 (assert_invalid 94 (module (memory 1) (func (result v128) (v128.load32_splat align=8 (i32.const 0)))) 95 "alignment must not be larger than natural" 96 ) 97 (assert_invalid 98 (module (memory 1) (func (result v128) (v128.load64_splat align=16 (i32.const 0)))) 99 "alignment must not be larger than natural" 100 ) 101 102 ;; Malformed alignment 103 104 (assert_malformed 105 (module quote 106 "(memory 1) (func (drop (v128.load align=-1 (i32.const 0))))" 107 ) 108 "unknown operator" 109 ) 110 (assert_malformed 111 (module quote 112 "(memory 1) (func (drop (v128.load align=0 (i32.const 0))))" 113 ) 114 "alignment must be a power of two" 115 ) 116 (assert_malformed 117 (module quote 118 "(memory 1) (func (drop (v128.load align=7 (i32.const 0))))" 119 ) 120 "alignment must be a power of two" 121 ) 122 (assert_malformed 123 (module quote 124 "(memory 1) (func (v128.store align=-1 (i32.const 0) (v128.const i32x4 0 0 0 0)))" 125 ) 126 "unknown operator" 127 ) 128 (assert_malformed 129 (module quote 130 "(memory 0) (func (v128.store align=0 (i32.const 0) (v128.const i32x4 0 0 0 0)))" 131 ) 132 "alignment must be a power of two" 133 ) 134 (assert_malformed 135 (module quote 136 "(memory 0) (func (v128.store align=7 (i32.const 0) (v128.const i32x4 0 0 0 0)))" 137 ) 138 "alignment must be a power of two" 139 ) 140 (assert_malformed 141 (module quote 142 "(memory 1) (func (result v128) (v128.load8x8_s align=-1 (i32.const 0)))" 143 ) 144 "unknown operator" 145 ) 146 (assert_malformed 147 (module quote 148 "(memory 1) (func (result v128) (v128.load8x8_s align=0 (i32.const 0)))" 149 ) 150 "alignment must be a power of two" 151 ) 152 (assert_malformed 153 (module quote 154 "(memory 1) (func (result v128) (v128.load8x8_s align=7 (i32.const 0)))" 155 ) 156 "alignment must be a power of two" 157 ) 158 (assert_malformed 159 (module quote 160 "(memory 1) (func (result v128) (v128.load8x8_u align=-1 (i32.const 0)))" 161 ) 162 "unknown operator" 163 ) 164 (assert_malformed 165 (module quote 166 "(memory 1) (func (result v128) (v128.load8x8_u align=0 (i32.const 0)))" 167 ) 168 "alignment must be a power of two" 169 ) 170 (assert_malformed 171 (module quote 172 "(memory 1) (func (result v128) (v128.load8x8_u align=7 (i32.const 0)))" 173 ) 174 "alignment must be a power of two" 175 ) 176 (assert_malformed 177 (module quote 178 "(memory 1) (func (result v128) (v128.load16x4_s align=-1 (i32.const 0)))" 179 ) 180 "unknown operator" 181 ) 182 (assert_malformed 183 (module quote 184 "(memory 1) (func (result v128) (v128.load16x4_s align=0 (i32.const 0)))" 185 ) 186 "alignment must be a power of two" 187 ) 188 (assert_malformed 189 (module quote 190 "(memory 1) (func (result v128) (v128.load16x4_s align=7 (i32.const 0)))" 191 ) 192 "alignment must be a power of two" 193 ) 194 (assert_malformed 195 (module quote 196 "(memory 1) (func (result v128) (v128.load16x4_u align=-1 (i32.const 0)))" 197 ) 198 "unknown operator" 199 ) 200 (assert_malformed 201 (module quote 202 "(memory 1) (func (result v128) (v128.load16x4_u align=0 (i32.const 0)))" 203 ) 204 "alignment must be a power of two" 205 ) 206 (assert_malformed 207 (module quote 208 "(memory 1) (func (result v128) (v128.load16x4_u align=7 (i32.const 0)))" 209 ) 210 "alignment must be a power of two" 211 ) 212 (assert_malformed 213 (module quote 214 "(memory 1) (func (result v128) (v128.load32x2_s align=-1 (i32.const 0)))" 215 ) 216 "unknown operator" 217 ) 218 (assert_malformed 219 (module quote 220 "(memory 1) (func (result v128) (v128.load32x2_s align=0 (i32.const 0)))" 221 ) 222 "alignment must be a power of two" 223 ) 224 (assert_malformed 225 (module quote 226 "(memory 1) (func (result v128) (v128.load32x2_s align=7 (i32.const 0)))" 227 ) 228 "alignment must be a power of two" 229 ) 230 (assert_malformed 231 (module quote 232 "(memory 1) (func (result v128) (v128.load32x2_u align=-1 (i32.const 0)))" 233 ) 234 "unknown operator" 235 ) 236 (assert_malformed 237 (module quote 238 "(memory 1) (func (result v128) (v128.load32x2_u align=0 (i32.const 0)))" 239 ) 240 "alignment must be a power of two" 241 ) 242 (assert_malformed 243 (module quote 244 "(memory 1) (func (result v128) (v128.load32x2_u align=7 (i32.const 0)))" 245 ) 246 "alignment must be a power of two" 247 ) 248 (assert_malformed 249 (module quote 250 "(memory 1) (func (result v128) (v128.load8_splat align=-1 (i32.const 0)))" 251 ) 252 "unknown operator" 253 ) 254 (assert_malformed 255 (module quote 256 "(memory 1) (func (result v128) (v128.load8_splat align=0 (i32.const 0)))" 257 ) 258 "alignment must be a power of two" 259 ) 260 (assert_malformed 261 (module quote 262 "(memory 1) (func (result v128) (v128.load16_splat align=-1 (i32.const 0)))" 263 ) 264 "unknown operator" 265 ) 266 (assert_malformed 267 (module quote 268 "(memory 1) (func (result v128) (v128.load16_splat align=0 (i32.const 0)))" 269 ) 270 "alignment must be a power of two" 271 ) 272 (assert_malformed 273 (module quote 274 "(memory 1) (func (result v128) (v128.load32_splat align=-1 (i32.const 0)))" 275 ) 276 "unknown operator" 277 ) 278 (assert_malformed 279 (module quote 280 "(memory 1) (func (result v128) (v128.load32_splat align=0 (i32.const 0)))" 281 ) 282 "alignment must be a power of two" 283 ) 284 (assert_malformed 285 (module quote 286 "(memory 1) (func (result v128) (v128.load32_splat align=3 (i32.const 0)))" 287 ) 288 "alignment must be a power of two" 289 ) 290 (assert_malformed 291 (module quote 292 "(memory 1) (func (result v128) (v128.load64_splat align=-1 (i32.const 0)))" 293 ) 294 "unknown operator" 295 ) 296 (assert_malformed 297 (module quote 298 "(memory 1) (func (result v128) (v128.load64_splat align=0 (i32.const 0)))" 299 ) 300 "alignment must be a power of two" 301 ) 302 (assert_malformed 303 (module quote 304 "(memory 1) (func (result v128) (v128.load64_splat align=7 (i32.const 0)))" 305 ) 306 "alignment must be a power of two" 307 ) 308 309 ;; Test that misaligned SIMD loads/stores don't trap 310 311 (module 312 (memory 1 1) 313 (func (export "v128.load align=16") (param $address i32) (result v128) 314 (v128.load align=16 (local.get $address)) 315 ) 316 (func (export "v128.store align=16") (param $address i32) (param $value v128) 317 (v128.store align=16 (local.get $address) (local.get $value)) 318 ) 319 ) 320 321 (assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i32x4 0 0 0 0)) 322 (assert_return (invoke "v128.load align=16" (i32.const 1)) (v128.const i32x4 0 0 0 0)) 323 (assert_return (invoke "v128.store align=16" (i32.const 1) (v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))) 324 (assert_return (invoke "v128.load align=16" (i32.const 0)) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) 325 326 ;; Test aligned and unaligned read/write 327 328 (module 329 (memory 1) 330 (func (export "v128_unaligned_read_and_write") (result v128) 331 (local v128) 332 (v128.store (i32.const 0) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) 333 (v128.load (i32.const 0)) 334 ) 335 (func (export "v128_aligned_read_and_write") (result v128) 336 (local v128) 337 (v128.store align=2 (i32.const 0) (v128.const i16x8 0 1 2 3 4 5 6 7)) 338 (v128.load align=2 (i32.const 0)) 339 ) 340 (func (export "v128_aligned_read_and_unaligned_write") (result v128) 341 (local v128) 342 (v128.store (i32.const 0) (v128.const i32x4 0 1 2 3)) 343 (v128.load align=2 (i32.const 0)) 344 ) 345 (func (export "v128_unaligned_read_and_aligned_write") (result v128) 346 (local v128) 347 (v128.store align=2 (i32.const 0) (v128.const i32x4 0 1 2 3)) 348 (v128.load (i32.const 0)) 349 ) 350 ) 351 352 (assert_return (invoke "v128_unaligned_read_and_write") (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) 353 (assert_return (invoke "v128_aligned_read_and_write") (v128.const i16x8 0 1 2 3 4 5 6 7)) 354 (assert_return (invoke "v128_aligned_read_and_unaligned_write") (v128.const i32x4 0 1 2 3)) 355 (assert_return (invoke "v128_unaligned_read_and_aligned_write") (v128.const i32x4 0 1 2 3))