wa-lang.org/wazero@v1.0.2/internal/integration_test/spectest/v2/testdata/simd_load.wast (about)

     1  ;; v128.load operater with normal argument (e.g. (i8x16, i16x8 i32x4))
     2  
     3  (module
     4    (memory 1)
     5    (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
     6    (func (export "v128.load") (result v128)
     7      (v128.load (i32.const 0))
     8    )
     9  )
    10  
    11  (assert_return (invoke "v128.load") (v128.const i8x16 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f))
    12  (assert_return (invoke "v128.load") (v128.const i16x8 0x0100 0x0302 0x0504 0x0706 0x0908 0x0b0a 0x0d0c 0x0f0e))
    13  (assert_return (invoke "v128.load") (v128.const i32x4 0x03020100 0x07060504 0x0b0a0908 0x0f0e0d0c))
    14  
    15  
    16  ;; v128.load operater as the argument of other SIMD instructions
    17  
    18  (module (memory 1)
    19    (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
    20    (func (export "as-i8x16_extract_lane_s-value/0") (result i32)
    21      (i8x16.extract_lane_s 0 (v128.load (i32.const 0)))
    22    )
    23  )
    24  (assert_return (invoke "as-i8x16_extract_lane_s-value/0") (i32.const 0x00))
    25  
    26  (module (memory 1)
    27    (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
    28    (func (export "as-i8x16.eq-operand") (result v128)
    29      (i8x16.eq (v128.load offset=0 (i32.const 0)) (v128.load offset=16 (i32.const 0)))
    30    )
    31  )
    32  (assert_return (invoke "as-i8x16.eq-operand") (v128.const i32x4 0xffffffff 0x00000000 0x00000000 0x00000000))
    33  
    34  (module (memory 1)
    35    (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
    36    (func (export "as-v128.not-operand") (result v128)
    37      (v128.not (v128.load (i32.const 0)))
    38    )
    39    (func (export "as-i8x16.all_true-operand") (result i32)
    40      (i8x16.all_true (v128.load (i32.const 0)))
    41    )
    42  )
    43  (assert_return (invoke "as-v128.not-operand") (v128.const i32x4 0xfcfdfeff 0xf8f9fafb 0xf4f5f6f7 0xf0f1f2f3))
    44  (assert_return (invoke "as-i8x16.all_true-operand") (i32.const 0))
    45  
    46  (module (memory 1)
    47    (data (offset (i32.const 0))  "\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA")
    48    (data (offset (i32.const 16)) "\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB\BB")
    49    (data (offset (i32.const 32)) "\F0\F0\F0\F0\FF\FF\FF\FF\00\00\00\00\FF\00\FF\00")
    50    (func (export "as-v128.bitselect-operand") (result v128)
    51      (v128.bitselect (v128.load (i32.const 0)) (v128.load (i32.const 16)) (v128.load (i32.const 32)))
    52    )
    53  )
    54  (assert_return (invoke "as-v128.bitselect-operand") (v128.const i32x4 0xabababab 0xaaaaaaaa 0xbbbbbbbb 0xbbaabbaa))
    55  
    56  (module (memory 1)
    57    (data (offset (i32.const 0)) "\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA")
    58    (func (export "as-i8x16.shl-operand") (result v128)
    59      (i8x16.shl (v128.load (i32.const 0)) (i32.const 1))
    60    )
    61  )
    62  (assert_return (invoke "as-i8x16.shl-operand") (v128.const i32x4 0x54545454 0x54545454 0x54545454 0x54545454)) ;; 1010 1000 << 1010 1010
    63  
    64  (module (memory 1)
    65    (data (offset (i32.const 0))  "\02\00\00\00\02\00\00\00\02\00\00\00\02\00\00\00")
    66    (data (offset (i32.const 16)) "\03\00\00\00\03\00\00\00\03\00\00\00\03\00\00\00")
    67    (func (export "as-add/sub-operand") (result v128)
    68      ;; 2 2 2 2 + 3 3 3 3 = 5 5 5 5
    69      ;; 5 5 5 5 - 3 3 3 3 = 2 2 2 2
    70      (i8x16.sub
    71        (i8x16.add (v128.load (i32.const 0)) (v128.load (i32.const 16)))
    72        (v128.load (i32.const 16))
    73      )
    74    )
    75  )
    76  (assert_return (invoke "as-add/sub-operand") (v128.const i32x4 2 2 2 2))
    77  
    78  (module (memory 1)
    79    (data (offset (i32.const 0))  "\00\00\00\43\00\00\80\3f\66\66\e6\3f\00\00\80\bf")  ;; 128 1.0 1.8 -1
    80    (data (offset (i32.const 16)) "\00\00\00\40\00\00\00\40\00\00\00\40\00\00\00\40")  ;; 2.0 2.0 2.0 2.0
    81    (func (export "as-f32x4.mul-operand") (result v128)
    82      (f32x4.mul (v128.load (i32.const 0)) (v128.load (i32.const 16)))
    83    )
    84  )
    85  (assert_return (invoke "as-f32x4.mul-operand") (v128.const f32x4 256 2 3.6 -2))
    86  
    87  (module (memory 1)
    88    (data (offset (i32.const 0)) "\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff")  ;; 1111 ...
    89    (func (export "as-f32x4.abs-operand") (result v128)
    90      (f32x4.abs (v128.load (i32.const 0)))
    91    )
    92  )
    93  (assert_return (invoke "as-f32x4.abs-operand") (v128.const i32x4 0x7fffffff 0x7fffffff 0x7fffffff 0x7fffffff)) ;; 1111 -> 0111
    94  
    95  (module (memory 1)
    96    (data (offset (i32.const 0)) "\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA\AA")
    97    (data (offset (i32.const 16)) "\02\00\00\00\02\00\00\00\02\00\00\00\02\00\00\00")
    98    (func (export "as-f32x4.min-operand") (result v128)
    99      (f32x4.min (v128.load (i32.const 0)) (v128.load offset=16 (i32.const 1)))
   100    )
   101  )
   102  (assert_return (invoke "as-f32x4.min-operand") (v128.const i32x4 0xaaaaaaaa 0xaaaaaaaa 0xaaaaaaaa 0xaaaaaaaa)) ;; signed 1010 < 0010
   103  
   104  (module (memory 1)
   105    (data (offset (i32.const 0))  "\00\00\00\43\00\00\80\3f\66\66\e6\3f\00\00\80\bf")  ;; 128 1.0 1.8 -1
   106    (func (export "as-i32x4.trunc_sat_f32x4_s-operand") (result v128)
   107      (i32x4.trunc_sat_f32x4_s (v128.load (i32.const 0)))
   108    )
   109  )
   110  (assert_return (invoke "as-i32x4.trunc_sat_f32x4_s-operand") (v128.const i32x4 128 1 1 -1)) ;; 128 1.0 1.8 -1 -> 128 1 1 -1
   111  
   112  (module (memory 1)
   113    (data (offset (i32.const 0)) "\02\00\00\00\02\00\00\00\02\00\00\00\02\00\00\00")
   114    (func (export "as-f32x4.convert_i32x4_u-operand") (result v128)
   115      (f32x4.convert_i32x4_u (v128.load (i32.const 0)))
   116    )
   117  )
   118  (assert_return (invoke "as-f32x4.convert_i32x4_u-operand") (v128.const f32x4 2 2 2 2))
   119  
   120  (module (memory 1)
   121    (data (offset (i32.const 0)) "\64\65\66\67\68\69\6a\6b\6c\6d\6e\6f\70\71\72\73")  ;; 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
   122    (data (offset (i32.const 16)) "\0f\0e\0d\0c\0b\0a\09\08\07\06\05\04\03\02\01\00")  ;;  15  14  13  12  11  10  09  08  07  06  05  04  03  02  01  00
   123    (func (export "as-i8x16.swizzle-operand") (result v128)
   124      (i8x16.swizzle (v128.load (i32.const 0)) (v128.load offset=15 (i32.const 1)))
   125    )
   126  )
   127  (assert_return(invoke "as-i8x16.swizzle-operand") (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100))
   128  
   129  (module (memory 1)
   130    (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03")
   131    (func (export "as-br-value") (result v128)
   132      (block (result v128) (br 0 (v128.load (i32.const 0))))
   133    )
   134  )
   135  (assert_return (invoke "as-br-value") (v128.const i32x4 0x03020100 0x07060504 0x0b0a0908 0x0f0e0d0c))
   136  
   137  
   138  ;; Unknown operator(e.g. v128.load8, v128.load16, v128.load32)
   139  
   140  (assert_malformed
   141    (module quote
   142      "(memory 1)"
   143      "(func (local v128) (drop (v128.load8 (i32.const 0))))"
   144    )
   145    "unknown operator"
   146  )
   147  (assert_malformed
   148    (module quote
   149      "(memory 1)"
   150      "(func (local v128) (drop (v128.load16 (i32.const 0))))"
   151    )
   152    "unknown operator"
   153  )
   154  (assert_malformed
   155    (module quote
   156      "(memory 1)"
   157      "(func (local v128) (drop (v128.load32 (i32.const 0))))"
   158    )
   159    "unknown operator"
   160  )
   161  
   162  
   163  ;; Type mismatched (e.g. v128.load(f32.const 0), type address empty)
   164  
   165  (assert_invalid
   166    (module (memory 1) (func (local v128) (drop (v128.load (f32.const 0)))))
   167    "type mismatch"
   168  )
   169  (assert_invalid
   170    (module (memory 1) (func (local v128) (block (br_if 0 (v128.load (i32.const 0))))))
   171    "type mismatch"
   172  )
   173  (assert_invalid
   174    (module (memory 1) (func (local v128) (v128.load (i32.const 0))))
   175    "type mismatch"
   176  )
   177  
   178  
   179  ;; Type address empty
   180  
   181  (assert_invalid
   182    (module (memory 1) (func (drop (v128.load (local.get 2)))))
   183    "unknown local 2"
   184  )
   185  (assert_invalid
   186    (module (memory 1) (func (drop (v128.load))))
   187    "type mismatch"
   188  )