Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / mips / user / ase / msa / shift / test_msa_srar_b.c
blobdcda9c2c959dbb65255e76b0c754896f332b4b27
1 /*
2 * Test program for MSA instruction SRAR.B
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 = "SRAR.B";
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 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */
47 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
48 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
49 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
50 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
51 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
52 { 0x0000ff0000ff0000ULL, 0xff0000ff0000ff00ULL, },
53 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
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 { 0xebebebebebebebebULL, 0xebebebebebebebebULL, },
65 { 0xfdfdfdfdfdfdfdfdULL, 0xfdfdfdfdfdfdfdfdULL, },
66 { 0xfbfbfbfbfbfbfbfbULL, 0xfbfbfbfbfbfbfbfbULL, },
67 { 0xf5f5f5f5f5f5f5f5ULL, 0xf5f5f5f5f5f5f5f5ULL, },
68 { 0xf5ffaaf5ffaaf5ffULL, 0xaaf5ffaaf5ffaaf5ULL, },
69 { 0xfbd5fffbd5fffbd5ULL, 0xfffbd5fffbd5fffbULL, },
70 { 0x0101010101010101ULL, 0x0101010101010101ULL, }, /* 24 */
71 { 0x5555555555555555ULL, 0x5555555555555555ULL, },
72 { 0x1515151515151515ULL, 0x1515151515151515ULL, },
73 { 0x0303030303030303ULL, 0x0303030303030303ULL, },
74 { 0x0505050505050505ULL, 0x0505050505050505ULL, },
75 { 0x0b0b0b0b0b0b0b0bULL, 0x0b0b0b0b0b0b0b0bULL, },
76 { 0x0b01550b01550b01ULL, 0x550b01550b01550bULL, },
77 { 0x052b01052b01052bULL, 0x01052b01052b0105ULL, },
78 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */
79 { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
80 { 0xf3f3f3f3f3f3f3f3ULL, 0xf3f3f3f3f3f3f3f3ULL, },
81 { 0xfefefefefefefefeULL, 0xfefefefefefefefeULL, },
82 { 0xfdfdfdfdfdfdfdfdULL, 0xfdfdfdfdfdfdfdfdULL, },
83 { 0xfafafafafafafafaULL, 0xfafafafafafafafaULL, },
84 { 0xfaffccfaffccfaffULL, 0xccfaffccfaffccfaULL, },
85 { 0xfde600fde600fde6ULL, 0x00fde600fde600fdULL, },
86 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */
87 { 0x3333333333333333ULL, 0x3333333333333333ULL, },
88 { 0x0d0d0d0d0d0d0d0dULL, 0x0d0d0d0d0d0d0d0dULL, },
89 { 0x0202020202020202ULL, 0x0202020202020202ULL, },
90 { 0x0303030303030303ULL, 0x0303030303030303ULL, },
91 { 0x0606060606060606ULL, 0x0606060606060606ULL, },
92 { 0x0601330601330601ULL, 0x3306013306013306ULL, },
93 { 0x031a00031a00031aULL, 0x00031a00031a0003ULL, },
94 { 0x00ff0000ff0000ffULL, 0x0000ff0000ff0000ULL, }, /* 48 */
95 { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
96 { 0xf9e40ef9e40ef9e4ULL, 0x0ef9e40ef9e40ef9ULL, },
97 { 0xfffc02fffc02fffcULL, 0x02fffc02fffc02ffULL, },
98 { 0xfef904fef904fef9ULL, 0x04fef904fef904feULL, },
99 { 0xfcf207fcf207fcf2ULL, 0x07fcf207fcf207fcULL, },
100 { 0xfcfe38fcfe38fcfeULL, 0x38fcfe38fcfe38fcULL, },
101 { 0xfec700fec700fec7ULL, 0x00fec700fec700feULL, },
102 { 0x0001000001000001ULL, 0x0000010000010000ULL, }, /* 56 */
103 { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
104 { 0x071cf2071cf2071cULL, 0xf2071cf2071cf207ULL, },
105 { 0x0104fe0104fe0104ULL, 0xfe0104fe0104fe01ULL, },
106 { 0x0207fc0207fc0207ULL, 0xfc0207fc0207fc02ULL, },
107 { 0x040ef9040ef9040eULL, 0xf9040ef9040ef904ULL, },
108 { 0x0402c70402c70402ULL, 0xc70402c70402c704ULL, },
109 { 0x0239000239000239ULL, 0x0002390002390002ULL, },
110 { 0x881b00fd28190340ULL, 0x09010101000fb001ULL, }, /* 64 */
111 { 0xf102e6fa010c0140ULL, 0x130101180001ec01ULL, },
112 { 0xf91b00f314010b40ULL, 0x01670001000ffe01ULL, },
113 { 0x880100fe01311501ULL, 0x02340b5eff1fec0cULL, },
114 { 0xfbf000064de5fe08ULL, 0x0200f70000085200ULL, },
115 { 0xffff000c02f20008ULL, 0x0500f70701001500ULL, },
116 { 0x00f0001927fff908ULL, 0x00f7ff0003080300ULL, },
117 { 0xfbff000301caf200ULL, 0x01fcbb1a0b1015fcULL, },
118 { 0xac17fffbb9f4fc80ULL, 0x0500f900ff052501ULL, }, /* 72 */
119 { 0xf601aef5fefaff80ULL, 0x0a00f900fd000901ULL, },
120 { 0xfb17ffebdd00f180ULL, 0x00d8ff00f5050101ULL, },
121 { 0xac01fffdffe8e3feULL, 0x01ecc6ffd60b0914ULL, },
122 { 0x701400055e0cff4eULL, 0xf200f1ffff08e2faULL, },
123 { 0x0e01160a0306004eULL, 0xe300f1f6fd01f9faULL, },
124 { 0x071400132f00fc4eULL, 0xfff1fe00f508fffaULL, },
125 { 0x700100020119f901ULL, 0xfcf988d8d511f9a0ULL, },
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_SRAR_B(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_SRAR_B(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;