Home | History | Annotate | Download | only in arm-neon-tests
      1 /*
      2 
      3 Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics
      4 Written by Christophe Lyon
      5 
      6 Permission is hereby granted, free of charge, to any person obtaining a copy
      7 of this software and associated documentation files (the "Software"), to deal
      8 in the Software without restriction, including without limitation the rights
      9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     10 copies of the Software, and to permit persons to whom the Software is
     11 furnished to do so, subject to the following conditions:
     12 
     13 The above copyright notice and this permission notice shall be included in
     14 all copies or substantial portions of the Software.
     15 
     16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     22 THE SOFTWARE.
     23 
     24 */
     25 
     26 #if defined(__arm__) || defined(__aarch64__)
     27 #include <arm_neon.h>
     28 #else
     29 #include "stm-arm-neon.h"
     30 #endif
     31 
     32 #include "stm-arm-neon-ref.h"
     33 
     34 #define TEST_MSG "VDUP/VDUPQ"
     35 void exec_vdup (void)
     36 {
     37   int i;
     38 
     39   /* Basic test: vec=vdup(x), then store the result.  */
     40 #define TEST_VDUP(Q, T1, T2, W, N)					\
     41   VECT_VAR(vector, T1, W, N) =						\
     42     vdup##Q##_n_##T2##W(VECT_VAR(buffer_dup, T1, W, N)[i]);		\
     43   vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector, T1, W, N))
     44 
     45   /* Basic test: vec=vmov(x), then store the result.  */
     46 #define TEST_VMOV(Q, T1, T2, W, N)					\
     47   VECT_VAR(vector, T1, W, N) =						\
     48     vmov##Q##_n_##T2##W(VECT_VAR(buffer_dup, T1, W, N)[i]);		\
     49   vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector, T1, W, N))
     50 
     51   /* With ARM RVCT, we need to declare variables before any executable
     52      statement */
     53   DECL_VARIABLE_ALL_VARIANTS(vector);
     54 
     55   for (i=0; i< 3; i++) {
     56     clean_results ();
     57 
     58     TEST_VDUP(, int, s, 8, 8);
     59     TEST_VDUP(, int, s, 16, 4);
     60     TEST_VDUP(, int, s, 32, 2);
     61     TEST_VDUP(, int, s, 64, 1);
     62     TEST_VDUP(, uint, u, 8, 8);
     63     TEST_VDUP(, uint, u, 16, 4);
     64     TEST_VDUP(, uint, u, 32, 2);
     65     TEST_VDUP(, uint, u, 64, 1);
     66     TEST_VDUP(, poly, p, 8, 8);
     67     TEST_VDUP(, poly, p, 16, 4);
     68     TEST_VDUP(, float, f, 32, 2);
     69 
     70     TEST_VDUP(q, int, s, 8, 16);
     71     TEST_VDUP(q, int, s, 16, 8);
     72     TEST_VDUP(q, int, s, 32, 4);
     73     TEST_VDUP(q, int, s, 64, 2);
     74     TEST_VDUP(q, uint, u, 8, 16);
     75     TEST_VDUP(q, uint, u, 16, 8);
     76     TEST_VDUP(q, uint, u, 32, 4);
     77     TEST_VDUP(q, uint, u, 64, 2);
     78     TEST_VDUP(q, poly, p, 8, 16);
     79     TEST_VDUP(q, poly, p, 16, 8);
     80     TEST_VDUP(q, float, f, 32, 4);
     81 
     82     dump_results_hex (TEST_MSG);
     83   }
     84 
     85 #undef TEST_MSG
     86 #define TEST_MSG "VMOV/VMOVQ"
     87   for (i=0; i< 3; i++) {
     88     clean_results ();
     89 
     90     TEST_VMOV(, int, s, 8, 8);
     91     TEST_VMOV(, int, s, 16, 4);
     92     TEST_VMOV(, int, s, 32, 2);
     93     TEST_VMOV(, int, s, 64, 1);
     94     TEST_VMOV(, uint, u, 8, 8);
     95     TEST_VMOV(, uint, u, 16, 4);
     96     TEST_VMOV(, uint, u, 32, 2);
     97     TEST_VMOV(, uint, u, 64, 1);
     98     TEST_VMOV(, poly, p, 8, 8);
     99     TEST_VMOV(, poly, p, 16, 4);
    100     TEST_VMOV(, float, f, 32, 2);
    101 
    102     TEST_VMOV(q, int, s, 8, 16);
    103     TEST_VMOV(q, int, s, 16, 8);
    104     TEST_VMOV(q, int, s, 32, 4);
    105     TEST_VMOV(q, int, s, 64, 2);
    106     TEST_VMOV(q, uint, u, 8, 16);
    107     TEST_VMOV(q, uint, u, 16, 8);
    108     TEST_VMOV(q, uint, u, 32, 4);
    109     TEST_VMOV(q, uint, u, 64, 2);
    110     TEST_VMOV(q, poly, p, 8, 16);
    111     TEST_VMOV(q, poly, p, 16, 8);
    112     TEST_VMOV(q, float, f, 32, 4);
    113 
    114     dump_results_hex (TEST_MSG);
    115   }
    116 }
    117