Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / mips / user / ase / msa / shift / test_msa_sra_h.c
blobf00003d51cbb1b026b010e40ddbb0153fa240c70
1 /*
2 * Test program for MSA instruction SRA.H
4 * Copyright (C) 2019 Wave Computing, Inc.
5 * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 #include <sys/time.h>
23 #include <stdint.h>
25 #include "../../../../include/wrappers_msa.h"
26 #include "../../../../include/test_inputs_128.h"
27 #include "../../../../include/test_utils_128.h"
29 #define TEST_COUNT_TOTAL ( \
30 (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
31 (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
34 int32_t main(void)
36 char *isa_ase_name = "MSA";
37 char *group_name = "Shift";
38 char *instruction_name = "SRA.H";
39 int32_t ret;
40 uint32_t i, j;
41 struct timeval start, end;
42 double elapsed_time;
44 uint64_t b128_result[TEST_COUNT_TOTAL][2];
45 uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
46 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */
47 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
48 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
49 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
50 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
51 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
53 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
54 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */
55 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
56 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
57 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
58 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
59 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
60 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
61 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
62 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */
63 { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
64 { 0xffeaffeaffeaffeaULL, 0xffeaffeaffeaffeaULL, },
65 { 0xfd55fd55fd55fd55ULL, 0xfd55fd55fd55fd55ULL, },
66 { 0xfffafffafffafffaULL, 0xfffafffafffafffaULL, },
67 { 0xf555f555f555f555ULL, 0xf555f555f555f555ULL, },
68 { 0xfffef555ffaafffeULL, 0xf555ffaafffef555ULL, },
69 { 0xd555fffaff55d555ULL, 0xfffaff55d555fffaULL, },
70 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */
71 { 0x5555555555555555ULL, 0x5555555555555555ULL, },
72 { 0x0015001500150015ULL, 0x0015001500150015ULL, },
73 { 0x02aa02aa02aa02aaULL, 0x02aa02aa02aa02aaULL, },
74 { 0x0005000500050005ULL, 0x0005000500050005ULL, },
75 { 0x0aaa0aaa0aaa0aaaULL, 0x0aaa0aaa0aaa0aaaULL, },
76 { 0x00010aaa00550001ULL, 0x0aaa005500010aaaULL, },
77 { 0x2aaa000500aa2aaaULL, 0x000500aa2aaa0005ULL, },
78 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */
79 { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
80 { 0xfff3fff3fff3fff3ULL, 0xfff3fff3fff3fff3ULL, },
81 { 0xfe66fe66fe66fe66ULL, 0xfe66fe66fe66fe66ULL, },
82 { 0xfffcfffcfffcfffcULL, 0xfffcfffcfffcfffcULL, },
83 { 0xf999f999f999f999ULL, 0xf999f999f999f999ULL, },
84 { 0xfffff999ffccffffULL, 0xf999ffccfffff999ULL, },
85 { 0xe666fffcff99e666ULL, 0xfffcff99e666fffcULL, },
86 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */
87 { 0x3333333333333333ULL, 0x3333333333333333ULL, },
88 { 0x000c000c000c000cULL, 0x000c000c000c000cULL, },
89 { 0x0199019901990199ULL, 0x0199019901990199ULL, },
90 { 0x0003000300030003ULL, 0x0003000300030003ULL, },
91 { 0x0666066606660666ULL, 0x0666066606660666ULL, },
92 { 0x0000066600330000ULL, 0x0666003300000666ULL, },
93 { 0x1999000300661999ULL, 0x0003006619990003ULL, },
94 { 0xffff0000ffffffffULL, 0x0000ffffffff0000ULL, }, /* 48 */
95 { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
96 { 0xfff8000effe3fff8ULL, 0x000effe3fff8000eULL, },
97 { 0xff1c01c7fc71ff1cULL, 0x01c7fc71ff1c01c7ULL, },
98 { 0xfffe0003fff8fffeULL, 0x0003fff8fffe0003ULL, },
99 { 0xfc71071cf1c7fc71ULL, 0x071cf1c7fc71071cULL, },
100 { 0xffff071cff8effffULL, 0x071cff8effff071cULL, },
101 { 0xf1c70003ff1cf1c7ULL, 0x0003ff1cf1c70003ULL, },
102 { 0x0000ffff00000000ULL, 0xffff00000000ffffULL, }, /* 56 */
103 { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
104 { 0x0007fff1001c0007ULL, 0xfff1001c0007fff1ULL, },
105 { 0x00e3fe38038e00e3ULL, 0xfe38038e00e3fe38ULL, },
106 { 0x0001fffc00070001ULL, 0xfffc00070001fffcULL, },
107 { 0x038ef8e30e38038eULL, 0xf8e30e38038ef8e3ULL, },
108 { 0x0000f8e300710000ULL, 0xf8e300710000f8e3ULL, },
109 { 0x0e38fffc00e30e38ULL, 0xfffc00e30e38fffcULL, },
110 { 0xffe2fffe0a185540ULL, 0x00960000fffffffbULL, }, /* 64 */
111 { 0xfffefcd9050c0055ULL, 0x00960002fffffffbULL, },
112 { 0xffe2fff900005540ULL, 0x004b0000fffffb00ULL, },
113 { 0xffffffff14310001ULL, 0x25b3000bff9eb00cULL, },
114 { 0xfffe00001364c708ULL, 0x0025fffe00020005ULL, },
115 { 0xffff000c09b2ffc7ULL, 0x0025ffee00000005ULL, },
116 { 0xfffe00000000c708ULL, 0x0012ffff0002052fULL, },
117 { 0xffff000026c9ffffULL, 0x097bffbb054f52fcULL, },
118 { 0xffebfffaee738b80ULL, 0x004ffffffff50002ULL, }, /* 72 */
119 { 0xfffef5d5f739ff8bULL, 0x004ffff1ffff0002ULL, },
120 { 0xffebffebffff8b80ULL, 0x0027fffffff50251ULL, },
121 { 0xfffffffddce7fffeULL, 0x13ecffc6eaca2514ULL, },
122 { 0x001c0001178ce24eULL, 0xff1bfffefff5fffeULL, },
123 { 0x000102c90bc6ffe2ULL, 0xff1bffe2fffffffeULL, },
124 { 0x001c00050000e24eULL, 0xff8dfffffff5fe2aULL, },
125 { 0x000000002f18ffffULL, 0xc6f8ff88ea50e2a0ULL, },
128 reset_msa_registers();
130 gettimeofday(&start, NULL);
132 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
133 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
134 do_msa_SRA_H(b128_pattern[i], b128_pattern[j],
135 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
139 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
140 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
141 do_msa_SRA_H(b128_random[i], b128_random[j],
142 b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
143 (PATTERN_INPUTS_SHORT_COUNT)) +
144 RANDOM_INPUTS_SHORT_COUNT * i + j]);
148 gettimeofday(&end, NULL);
150 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
151 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
153 ret = check_results_128(isa_ase_name, group_name, instruction_name,
154 TEST_COUNT_TOTAL, elapsed_time,
155 &b128_result[0][0], &b128_expect[0][0]);
157 return ret;