Home | History | Annotate | Download | only in jni
      1 #include <stdio.h>
      2 #include <arm_neon.h>
      3 
      4 int fail_count = 0;
      5 
      6 void dump_and_check(unsigned long long v, unsigned long long expected)
      7 {
      8    printf("%016llx\n", v);
      9    fail_count += (v != expected);
     10 }
     11 
     12 static const uint8x8_t v00FF8 = { 0,0,0,0, 0xff,0xff,0xff,0xff }; // wrong
     13 static const uint8x8_t vFF008 = { 0xff,0xff,0xff,0xff, 0,0,0,0 };
     14 
     15 void test1()
     16 {
     17     uint8x8_t v = v00FF8;
     18     dump_and_check(*(unsigned long long *)&v, 0xffffffff00000000ULL);
     19 }
     20 
     21 void test2()
     22 {
     23     static const uint64_t local_Mask2 = { 0xffffffff00000000ULL };
     24     uint8x8_t v00FF8 = vcreate_u8(local_Mask2); //{ 0,0,0,0,0xff,0xff,0xff,0xff };
     25     dump_and_check(*(unsigned long long *)&v00FF8, 0xffffffff00000000ULL);
     26 }
     27 
     28 void test3()
     29 {
     30     static const uint32_t vFF_ = { 0xFFFFFFFF };
     31     static const uint32_t v00_ = { 0x00000000 };
     32     static uint32x2_t v00FF_;
     33     v00FF_ = vset_lane_u32( vFF_, v00FF_, 1);
     34     v00FF_ = vset_lane_u32( v00_, v00FF_, 0);
     35     uint8x8_t v00FF8 = (uint8x8_t)v00FF_;
     36     dump_and_check(*(unsigned long long *)&v00FF8, 0xffffffff00000000ULL);
     37 }
     38 
     39 void test4()
     40 {
     41     uint8x8_t mask_high = vcreate_u8(0xFFFFFFFF00000000ULL);
     42     uint8x8_t mask_low = vcreate_u8(0x00000000FFFFFFFFULL);
     43     uint8x8_t va = vdup_n_u8 ('a');
     44     uint8x8_t vb = vdup_n_u8 ('b');
     45     uint8x8_t in = vorr_u8(vand_u8 (va, mask_low), vand_u8 (vb, mask_high));
     46     dump_and_check(*(unsigned long long *)&in, 0x6262626261616161ULL);
     47 }
     48 
     49 
     50 int main()
     51 {
     52     test1();
     53     test2();
     54     test3();
     55     test4();
     56     printf("fail_count = %d\n", fail_count);
     57     return (fail_count == 0)? 0 : 1;
     58 }
     59