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 /* Template file for unary operator validation */
27
28 #if defined(__arm__) || defined(__aarch64__)
29 #include <arm_neon.h>
30 #else
31 #include "stm-arm-neon.h"
32 #endif
33
34 #include "stm-arm-neon-ref.h"
35
36 #define INSN_NAME vcreate
37 #define TEST_MSG "VCREATE"
38
39 #define FNNAME1(NAME) void exec_ ## NAME (void)
40 #define FNNAME(NAME) FNNAME1(NAME)
41
FNNAME(INSN_NAME)42 FNNAME (INSN_NAME)
43 {
44 /* Basic test: y=vcreate(x), then store the result. */
45 #define TEST_VCREATE(T1, T2, W, N) \
46 VECT_VAR(vector_res, T1, W, N) = vcreate_##T2##W(VECT_VAR(val, T1, W, N)); \
47 vst1_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
48
49 /* With ARM RVCT, we need to declare variables before any executable
50 statement */
51
52 #define DECL_VAL(VAR, T1, W, N) \
53 uint64_t VECT_VAR(VAR, T1, W, N)
54
55 DECL_VAL(val, int, 8, 8);
56 DECL_VAL(val, int, 16, 4);
57 DECL_VAL(val, int, 32, 2);
58 DECL_VAL(val, int, 64, 1);
59 DECL_VAL(val, float, 32, 2);
60 DECL_VAL(val, uint, 8, 8);
61 DECL_VAL(val, uint, 16, 4);
62 DECL_VAL(val, uint, 32, 2);
63 DECL_VAL(val, uint, 64, 1);
64 DECL_VAL(val, poly, 8, 8);
65 DECL_VAL(val, poly, 16, 4);
66 #if defined(__ARM_FP16_FORMAT_IEEE) && ( ((__ARM_FP & 0x2) != 0) || ((__ARM_NEON_FP16_INTRINSICS & 1) != 0) )
67 DECL_VAL(val, float, 16, 4);
68 #endif
69
70 DECL_VARIABLE(vector_res, int, 8, 8);
71 DECL_VARIABLE(vector_res, int, 16, 4);
72 DECL_VARIABLE(vector_res, int, 32, 2);
73 DECL_VARIABLE(vector_res, int, 64, 1);
74 DECL_VARIABLE(vector_res, float, 32, 2);
75 #if defined(__ARM_FP16_FORMAT_IEEE) && ( ((__ARM_FP & 0x2) != 0) || ((__ARM_NEON_FP16_INTRINSICS & 1) != 0) )
76 DECL_VARIABLE(vector_res, float, 16, 4);
77 #endif
78 DECL_VARIABLE(vector_res, uint, 8, 8);
79 DECL_VARIABLE(vector_res, uint, 16, 4);
80 DECL_VARIABLE(vector_res, uint, 32, 2);
81 DECL_VARIABLE(vector_res, uint, 64, 1);
82 DECL_VARIABLE(vector_res, poly, 8, 8);
83 DECL_VARIABLE(vector_res, poly, 16, 4);
84
85 clean_results ();
86
87 /* Initialize input values arbitrarily */
88 VECT_VAR(val, int, 8, 8) = 0x123456789abcdef0LL;
89 VECT_VAR(val, int, 16, 4) = 0x123456789abcdef0LL;
90 VECT_VAR(val, int, 32, 2) = 0x123456789abcdef0LL;
91 VECT_VAR(val, int, 64, 1) = 0x123456789abcdef0LL;
92 VECT_VAR(val, float, 32, 2) = 0x123456789abcdef0LL;
93 #if defined(__ARM_FP16_FORMAT_IEEE) && ( ((__ARM_FP & 0x2) != 0) || ((__ARM_NEON_FP16_INTRINSICS & 1) != 0) )
94 VECT_VAR(val, float, 16, 4) = 0x123456789abcdef0LL;
95 #endif
96 VECT_VAR(val, uint, 8, 8) = 0x123456789abcdef0ULL;
97 VECT_VAR(val, uint, 16, 4) = 0x123456789abcdef0ULL;
98 VECT_VAR(val, uint, 32, 2) = 0x123456789abcdef0ULL;
99 VECT_VAR(val, uint, 64, 1) = 0x123456789abcdef0ULL;
100 VECT_VAR(val, poly, 8, 8) = 0x123456789abcdef0ULL;
101 VECT_VAR(val, poly, 16, 4) = 0x123456789abcdef0ULL;
102
103 TEST_VCREATE(int, s, 8, 8);
104 TEST_VCREATE(int, s, 16, 4);
105 TEST_VCREATE(int, s, 32, 2);
106 TEST_VCREATE(float, f, 32, 2);
107 #if defined(__ARM_FP16_FORMAT_IEEE) && ( ((__ARM_FP & 0x2) != 0) || ((__ARM_NEON_FP16_INTRINSICS & 1) != 0) )
108 TEST_VCREATE(float, f, 16, 4);
109 #endif
110 TEST_VCREATE(int, s, 64, 1);
111 TEST_VCREATE(uint, u, 8, 8);
112 TEST_VCREATE(uint, u, 16, 4);
113 TEST_VCREATE(uint, u, 32, 2);
114 TEST_VCREATE(uint, u, 64, 1);
115 TEST_VCREATE(poly, p, 8, 8);
116 TEST_VCREATE(poly, p, 16, 4);
117
118 dump_results_hex (TEST_MSG);
119 }
120