• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
2 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
3 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -x c++ %s -verify
4 // expected-no-diagnostics
5 
6 #if defined(__wasm__) && defined(__wasm_simd128__)
7 
8 #include <wasm_simd128.h>
9 
10 // Test that macros are correct as well
main()11 int main() {
12   v128_t v;
13   v = wasm_i8x16_const(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
14   v = wasm_i16x8_const(0, 1, 2, 3, 4, 5, 6, 7);
15   v = wasm_i32x4_const(0, 1, 2, 3);
16   v = wasm_i64x2_const(0, 1);
17   v = wasm_f32x4_const(0.0, 1.0, 2.0, 3.0);
18   v = wasm_f64x2_const(0.0, 1.0);
19 
20   int8_t i8 = wasm_i8x16_extract_lane(v, 0);
21   uint8_t u8 = wasm_u8x16_extract_lane(v, 15);
22   v = wasm_i8x16_replace_lane(v, 0, 42);
23 
24   int16_t i16 = wasm_i16x8_extract_lane(v, 0);
25   uint16_t u16 = wasm_u16x8_extract_lane(v, 7);
26   v = wasm_i16x8_replace_lane(v, 0, 42);
27 
28   int32_t i32 = wasm_i32x4_extract_lane(v, 0);
29   v = wasm_i32x4_replace_lane(v, 0, 42);
30 
31   int64_t i64 = wasm_i64x2_extract_lane(v, 0);
32   v = wasm_i64x2_replace_lane(v, 0, 42);
33 
34   float f32 = wasm_f32x4_extract_lane(v, 0);
35   v = wasm_f32x4_replace_lane(v, 0, 42.0);
36 
37   double f64 = wasm_f64x2_extract_lane(v, 0);
38   v = wasm_f64x2_replace_lane(v, 0, 42.0);
39 
40   wasm_v8x16_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
41   wasm_v16x8_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7);
42   wasm_v32x4_shuffle(v, v, 0, 1, 2, 3);
43   wasm_v64x2_shuffle(v, v, 0, 1);
44 
45   return 0;
46 }
47 
48 #endif
49