1
Hi,
2
1
This patch series adds support for emulation of CRC32 instructions for
3
This patch series adds support for emulation of CRC32 instructions for
2
the Mips target in QEMU, skips NaN mode check for soft-float, adds a CLI
4
the Mips target in QEMU, enables CRC for mips64r6, skips NaN mode check
3
flag for enabling an MSA feature, and enables the MSA for
5
for soft-float, and adds a CLI flag for enabling an MSA feature.
4
MIPS64R2-generic.
5
6
6
There aren't tests for these improvements.
7
The CRC32 instructions are available in MD00087 Revision 6.06.
7
8
Since the disassembly for crc32 is hidden in commit 99029be1c28, the new
8
The patch 1/8 "Add CP0 MemoryMapID register implementation" from v2 has
9
version of the patch 1/3 is basically identical to v1, except tests
9
been dropped from v3 since it has been accepted and integrated into the
10
being added.
10
master branch.
11
12
The patch 3/8 "GTM19-448: Fix script to work without realpath" from v2
13
will be sent separately as it is a fix to a general bug and is intended
14
for other maintainers.
15
16
The patch 5/8 "Add micromips to P5600" from v2 has been dropped from v3
17
since the latest document for P5600 with eventually updated field
18
CP0_Config3_ISA that would support microMIPS hasn't been found.
19
20
The patch 6/8 "Revert use of clock_gettime for benchmarking" from v2 has
21
been dropped from v3 because it seems that clock_gettime and
22
CLOCK_MONOTONIC exist in MinGW headers and that QEMU builds with MinGW.
23
24
The patch 7/8 "target/mips: Enable MSA ASE for mips32r6-generic" from v2
25
has been dropped from v3 since it has been accepted and integrated into
26
the master branch.
27
28
When it comes to the patch 8/8 "target/mips: Enable MSA ASE for
29
mips64R2-generic" from v2, the cpu Loongson-3A4000 supports both
30
mips64r2 and the MSA, so I'm not sure whether to drop this patch.
31
32
Regarding the DSPRAM for I6500, I heard that the IP for the DSPRAM for
33
mips64r6 hasn't been published, but in the document "MIPS64® I6500
34
Multiprocessing System Programmer’s Guide" the DSPRAM is elaborated, so
35
I don't know whether to add support for the DSPRAM.
36
11
37
Most of the following patches are cherry-picked from the branch
12
Most of the following patches are cherry-picked from the branch
38
mips_rel/4_1_0/master on the MIPS' repository:
13
mips_rel/4_1_0/master on the MIPS' repository:
39
https://github.com/MIPS/gnutools-qemu/
14
https://github.com/MIPS/gnutools-qemu/
40
Further details on individual changes are included in the respective
15
Further details on individual changes are included in the respective
41
patches. An instance of a pipeline of QEMU CI jobs run with input
16
patches.
42
variable QEMU_CI=1 for this patch series is available here:
43
https://gitlab.com/rakicaleksandar1999/qemu/-/pipelines/1533819034
44
and for the master branch is available here:
45
https://gitlab.com/rakicaleksandar1999/qemu/-/pipelines/1533465414
46
17
47
We are open for a discussion.
18
Kind regards,
48
19
Aleksandar Rakic
diff view generated by jsdifflib
1
From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
2
1
Add emulation of MIPS' CRC32 (Cyclic Redundancy Check) instructions.
3
Add emulation of MIPS' CRC32 (Cyclic Redundancy Check) instructions.
2
Reuse zlib crc32() and Linux crc32c().
4
Reuse zlib crc32() and Linux crc32c().
5
6
Enable CRC for mips64r6.
3
7
4
Cherry-picked 4cc974938aee1588f852590509004e340c072940
8
Cherry-picked 4cc974938aee1588f852590509004e340c072940
5
from https://github.com/MIPS/gnutools-qemu
9
from https://github.com/MIPS/gnutools-qemu
6
10
7
Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
11
Signed-off-by: Yongbok Kim <yongbok.kim@mips.com>
8
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
12
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
9
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
13
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
10
Reviewed-by: Aleksandar Rikalo <arikalo@gmail.com>
14
Reviewed-by: Aleksandar Rikalo <arikalo@gmail.com>
11
---
15
---
12
target/mips/helper.h | 2 ++
16
target/mips/cpu-defs.c.inc | 10 +-
13
target/mips/meson.build | 1 +
17
target/mips/helper.h | 2 +
14
target/mips/tcg/op_helper.c | 26 ++++++++++++++++++++++++++
18
target/mips/meson.build | 1 +
15
target/mips/tcg/rel6.decode | 5 +++++
19
target/mips/tcg/op_helper.c | 27 +++
16
target/mips/tcg/rel6_translate.c | 14 ++++++++++++++
20
target/mips/tcg/translate.c | 37 +++++
17
target/mips/tcg/translate.c | 25 +++++++++++++++++++++++++
21
target/mips/tcg/translate.h | 1 +
18
target/mips/tcg/translate.h | 3 +++
22
tests/tcg/mips/include/wrappers_mips64r6.h | 35 ++++
19
7 files changed, 76 insertions(+)
23
tests/tcg/mips/user/isa/mips64r6/crc/Makefile | 34 ++++
24
.../isa/mips64r6/crc/test_mips64r6_crc32b.c | 154 ++++++++++++++++++
25
.../isa/mips64r6/crc/test_mips64r6_crc32cb.c | 154 ++++++++++++++++++
26
.../isa/mips64r6/crc/test_mips64r6_crc32cd.c | 154 ++++++++++++++++++
27
.../isa/mips64r6/crc/test_mips64r6_crc32ch.c | 154 ++++++++++++++++++
28
.../isa/mips64r6/crc/test_mips64r6_crc32cw.c | 154 ++++++++++++++++++
29
.../isa/mips64r6/crc/test_mips64r6_crc32d.c | 154 ++++++++++++++++++
30
.../isa/mips64r6/crc/test_mips64r6_crc32h.c | 154 ++++++++++++++++++
31
.../isa/mips64r6/crc/test_mips64r6_crc32w.c | 154 ++++++++++++++++++
32
16 files changed, 1375 insertions(+), 4 deletions(-)
33
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/Makefile
34
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32b.c
35
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cb.c
36
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cd.c
37
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32ch.c
38
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cw.c
39
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32d.c
40
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32h.c
41
create mode 100644 tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32w.c
20
42
43
diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/mips/cpu-defs.c.inc
46
+++ b/target/mips/cpu-defs.c.inc
47
@@ -XXX,XX +XXX,XX @@ const mips_def_t mips_defs[] =
48
(1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
49
.CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
50
(1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
51
- .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
52
- (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI),
53
+ .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_CRCP) | (1 << CP0C5_XNP) |
54
+ (1 << CP0C5_VP) | (1 << CP0C5_LLB) | (1 << CP0C5_MRP) |
55
+ (3 << CP0C5_GI),
56
.CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
57
(1 << CP0C5_FRE) | (1 << CP0C5_UFE),
58
.CP0_LLAddr_rw_bitmask = 0,
59
@@ -XXX,XX +XXX,XX @@ const mips_def_t mips_defs[] =
60
(1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
61
.CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
62
(1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
63
- .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
64
- (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI),
65
+ .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_CRCP) | (1 << CP0C5_XNP) |
66
+ (1 << CP0C5_VP) | (1 << CP0C5_LLB) | (1 << CP0C5_MRP) |
67
+ (3 << CP0C5_GI),
68
.CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
69
(1 << CP0C5_FRE) | (1 << CP0C5_UFE),
70
.CP0_LLAddr_rw_bitmask = 0,
21
diff --git a/target/mips/helper.h b/target/mips/helper.h
71
diff --git a/target/mips/helper.h b/target/mips/helper.h
22
index XXXXXXX..XXXXXXX 100644
72
index XXXXXXX..XXXXXXX 100644
23
--- a/target/mips/helper.h
73
--- a/target/mips/helper.h
24
+++ b/target/mips/helper.h
74
+++ b/target/mips/helper.h
25
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(bitswap, TCG_CALL_NO_RWG_SE, tl, tl)
75
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(bitswap, TCG_CALL_NO_RWG_SE, tl, tl)
...
...
77
+{
127
+{
78
+ uint8_t buf[8];
128
+ uint8_t buf[8];
79
+ target_ulong mask = ((sz * 8) == 64) ?
129
+ target_ulong mask = ((sz * 8) == 64) ?
80
+ (target_ulong) -1ULL :
130
+ (target_ulong) -1ULL :
81
+ ((1ULL << (sz * 8)) - 1);
131
+ ((1ULL << (sz * 8)) - 1);
132
+
82
+ m &= mask;
133
+ m &= mask;
83
+ stq_le_p(buf, m);
134
+ stq_le_p(buf, m);
84
+ return (int32_t) (crc32c(val, buf, sz) ^ 0xffffffff);
135
+ return (int32_t) (crc32c(val, buf, sz) ^ 0xffffffff);
85
+}
136
+}
86
+
137
+
87
void helper_fork(target_ulong arg1, target_ulong arg2)
138
void helper_fork(target_ulong arg1, target_ulong arg2)
88
{
139
{
89
/*
140
/*
90
diff --git a/target/mips/tcg/rel6.decode b/target/mips/tcg/rel6.decode
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/mips/tcg/rel6.decode
93
+++ b/target/mips/tcg/rel6.decode
94
@@ -XXX,XX +XXX,XX @@
95
96
&r rs rt rd sa
97
98
+&special3_crc rs rt c sz
99
+
100
@lsa ...... rs:5 rt:5 rd:5 ... sa:2 ...... &r
101
+@crc32 ...... rs:5 rt:5 ..... c:3 sz:2 ...... &special3_crc
102
103
LSA 000000 ..... ..... ..... 000 .. 000101 @lsa
104
DLSA 000000 ..... ..... ..... 000 .. 010101 @lsa
105
106
+CRC32 011111 ..... ..... 00000 ... .. 001111 @crc32
107
+
108
REMOVED 010011 ----- ----- ----- ----- ------ # COP1X (COP3)
109
110
REMOVED 011100 ----- ----- ----- ----- ------ # SPECIAL2
111
diff --git a/target/mips/tcg/rel6_translate.c b/target/mips/tcg/rel6_translate.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/mips/tcg/rel6_translate.c
114
+++ b/target/mips/tcg/rel6_translate.c
115
@@ -XXX,XX +XXX,XX @@ static bool trans_DLSA(DisasContext *ctx, arg_r *a)
116
}
117
return gen_dlsa(ctx, a->rd, a->rt, a->rs, a->sa);
118
}
119
+
120
+static bool trans_CRC32(DisasContext *ctx, arg_special3_crc *a)
121
+{
122
+ if (unlikely(!ctx->crcp) ||
123
+ unlikely((a->sz == 3) &&
124
+ (!(ctx->hflags & MIPS_HFLAG_64))) ||
125
+ unlikely((a->c >= 2))) {
126
+ gen_reserved_instruction(ctx);
127
+ return true;
128
+ }
129
+ gen_crc32(ctx, a->rt, a->rs, a->rt,
130
+ a->sz, a->c);
131
+ return true;
132
+}
133
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
141
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
134
index XXXXXXX..XXXXXXX 100644
142
index XXXXXXX..XXXXXXX 100644
135
--- a/target/mips/tcg/translate.c
143
--- a/target/mips/tcg/translate.c
136
+++ b/target/mips/tcg/translate.c
144
+++ b/target/mips/tcg/translate.c
145
@@ -XXX,XX +XXX,XX @@ enum {
146
OPC_LWE = 0x2F | OPC_SPECIAL3,
147
148
/* R6 */
149
+ OPC_CRC32 = 0x0F | OPC_SPECIAL3,
150
R6_OPC_PREF = 0x35 | OPC_SPECIAL3,
151
R6_OPC_CACHE = 0x25 | OPC_SPECIAL3,
152
R6_OPC_LL = 0x36 | OPC_SPECIAL3,
137
@@ -XXX,XX +XXX,XX @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
153
@@ -XXX,XX +XXX,XX @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
138
}
154
}
139
}
155
}
140
156
141
+void gen_crc32(DisasContext *ctx, int rd, int rs, int rt, int sz,
157
+static void gen_crc32(DisasContext *ctx, int rd, int rs, int rt, int sz,
142
+ int crc32c)
158
+ int crc32c)
143
+{
159
+{
144
+ TCGv t0;
160
+ TCGv t0;
145
+ TCGv t1;
161
+ TCGv t1;
146
+ TCGv_i32 tsz = tcg_constant_i32(1 << sz);
162
+ TCGv_i32 tsz = tcg_constant_i32(1 << sz);
...
...
163
+}
179
+}
164
+
180
+
165
static void decode_opc_special3_r6(CPUMIPSState *env, DisasContext *ctx)
181
static void decode_opc_special3_r6(CPUMIPSState *env, DisasContext *ctx)
166
{
182
{
167
int rs, rt, rd, sa;
183
int rs, rt, rd, sa;
184
@@ -XXX,XX +XXX,XX @@ static void decode_opc_special3_r6(CPUMIPSState *env, DisasContext *ctx)
185
186
op1 = MASK_SPECIAL3(ctx->opcode);
187
switch (op1) {
188
+ case OPC_CRC32:
189
+ if (unlikely(!ctx->crcp) ||
190
+ unlikely((extract32(ctx->opcode, 6, 2) == 3) &&
191
+ (!(ctx->hflags & MIPS_HFLAG_64))) ||
192
+ unlikely((extract32(ctx->opcode, 8, 3) >= 2))) {
193
+ gen_reserved_instruction(ctx);
194
+ }
195
+ gen_crc32(ctx, rt, rs, rt,
196
+ extract32(ctx->opcode, 6, 2),
197
+ extract32(ctx->opcode, 8, 3));
198
+ break;
199
case R6_OPC_PREF:
200
if (rt >= 24) {
201
/* hint codes 24-31 are reserved and signal RI */
168
@@ -XXX,XX +XXX,XX @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
202
@@ -XXX,XX +XXX,XX @@ static void mips_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
169
ctx->abs2008 = (env->active_fpu.fcr31 >> FCR31_ABS2008) & 1;
203
ctx->abs2008 = (env->active_fpu.fcr31 >> FCR31_ABS2008) & 1;
170
ctx->mi = (env->CP0_Config5 >> CP0C5_MI) & 1;
204
ctx->mi = (env->CP0_Config5 >> CP0C5_MI) & 1;
171
ctx->gi = (env->CP0_Config5 >> CP0C5_GI) & 3;
205
ctx->gi = (env->CP0_Config5 >> CP0C5_GI) & 3;
172
+ ctx->crcp = (env->CP0_Config5 >> CP0C5_CRCP) & 1;
206
+ ctx->crcp = (env->CP0_Config5 >> CP0C5_CRCP) & 1;
...
...
183
int gi;
217
int gi;
184
+ bool crcp;
218
+ bool crcp;
185
} DisasContext;
219
} DisasContext;
186
220
187
#define DISAS_STOP DISAS_TARGET_0
221
#define DISAS_STOP DISAS_TARGET_0
188
@@ -XXX,XX +XXX,XX @@ bool gen_lsa(DisasContext *ctx, int rd, int rt, int rs, int sa);
222
diff --git a/tests/tcg/mips/include/wrappers_mips64r6.h b/tests/tcg/mips/include/wrappers_mips64r6.h
189
bool gen_dlsa(DisasContext *ctx, int rd, int rt, int rs, int sa);
223
index XXXXXXX..XXXXXXX 100644
190
224
--- a/tests/tcg/mips/include/wrappers_mips64r6.h
191
void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel);
225
+++ b/tests/tcg/mips/include/wrappers_mips64r6.h
192
+void gen_crc32(DisasContext *ctx, int rd, int rs, int rt, int sz,
226
@@ -XXX,XX +XXX,XX @@
193
+ int crc32c);
227
#ifndef WRAPPERS_MIPS64R6_H
194
228
#define WRAPPERS_MIPS64R6_H
195
extern TCGv cpu_gpr[32], cpu_PC;
229
196
#if defined(TARGET_MIPS64)
230
+#include <string.h>
231
+
232
233
#define DO_MIPS64R6__RD__RS(suffix, mnemonic) \
234
static inline void do_mips64r6_##suffix(const void *input, \
235
@@ -XXX,XX +XXX,XX @@ DO_MIPS64R6__RD__RS_RT(DMULU, dmulu)
236
DO_MIPS64R6__RD__RS_RT(DMUHU, dmuhu)
237
238
239
+#define DO_MIPS64R6__RT__RS_RT(suffix, mnemonic) \
240
+static inline void do_mips64r6_##suffix(const void *input1, \
241
+ const void *input2, \
242
+ void *output) \
243
+{ \
244
+ if (strncmp(#mnemonic, "crc32", 5) == 0) \
245
+ __asm__ volatile ( \
246
+ ".set crc\n\t" \
247
+ ); \
248
+ \
249
+ __asm__ volatile ( \
250
+ "ld $t1, 0(%0)\n\t" \
251
+ "ld $t2, 0(%1)\n\t" \
252
+ #mnemonic " $t2, $t1, $t2\n\t" \
253
+ "sd $t2, 0(%2)\n\t" \
254
+ : \
255
+ : "r" (input1), "r" (input2), "r" (output) \
256
+ : "t0", "t1", "t2", "memory" \
257
+ ); \
258
+}
259
+
260
+DO_MIPS64R6__RT__RS_RT(CRC32B, crc32b)
261
+DO_MIPS64R6__RT__RS_RT(CRC32H, crc32h)
262
+DO_MIPS64R6__RT__RS_RT(CRC32W, crc32w)
263
+DO_MIPS64R6__RT__RS_RT(CRC32D, crc32d)
264
+
265
+DO_MIPS64R6__RT__RS_RT(CRC32CB, crc32cb)
266
+DO_MIPS64R6__RT__RS_RT(CRC32CH, crc32ch)
267
+DO_MIPS64R6__RT__RS_RT(CRC32CW, crc32cw)
268
+DO_MIPS64R6__RT__RS_RT(CRC32CD, crc32cd)
269
+
270
+
271
+
272
#endif
273
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/Makefile b/tests/tcg/mips/user/isa/mips64r6/crc/Makefile
274
new file mode 100644
275
index XXXXXXX..XXXXXXX
276
--- /dev/null
277
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/Makefile
278
@@ -XXX,XX +XXX,XX @@
279
+ifndef PREFIX
280
+ $(error "PREFIX not set, please export GNU Toolchain install directory.")
281
+endif
282
+
283
+ifndef SYSROOT
284
+ $(error "SYSROOT not set, please export GNU Toolchain system root directory.")
285
+endif
286
+
287
+SIM = ../../../../../../../build/qemu-mips64
288
+SIM_FLAGS = -L $(SYSROOT)
289
+
290
+CC = $(PREFIX)/bin/mips64-r6-linux-gnu-gcc
291
+
292
+TESTCASES = test_mips64r6_crc32b.tst
293
+TESTCASES += test_mips64r6_crc32h.tst
294
+TESTCASES += test_mips64r6_crc32w.tst
295
+TESTCASES += test_mips64r6_crc32d.tst
296
+TESTCASES += test_mips64r6_crc32cb.tst
297
+TESTCASES += test_mips64r6_crc32ch.tst
298
+TESTCASES += test_mips64r6_crc32cw.tst
299
+TESTCASES += test_mips64r6_crc32cd.tst
300
+
301
+all: $(TESTCASES)
302
+    @for case in $(TESTCASES); do \
303
+ echo $(SIM) $(SIM_FLAGS) ./$$case; \
304
+ $(SIM) $(SIM_FLAGS) ./$$case; \
305
+ echo $(RM) -rf ./$$case; \
306
+ $(RM) -rf ./$$case; \
307
+    done
308
+
309
+%.tst: %.c
310
+    $(CC) $< -o $@
311
+
312
+
313
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32b.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32b.c
314
new file mode 100644
315
index XXXXXXX..XXXXXXX
316
--- /dev/null
317
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32b.c
318
@@ -XXX,XX +XXX,XX @@
319
+/*
320
+ * Test program for MIPS64R6 instruction CRC32B
321
+ *
322
+ * Copyright (C) 2019 Wave Computing, Inc.
323
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
324
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
325
+ *
326
+ * This program is free software: you can redistribute it and/or modify
327
+ * it under the terms of the GNU General Public License as published by
328
+ * the Free Software Foundation, either version 2 of the License, or
329
+ * (at your option) any later version.
330
+ *
331
+ * This program is distributed in the hope that it will be useful,
332
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
333
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
334
+ * GNU General Public License for more details.
335
+ *
336
+ * You should have received a copy of the GNU General Public License
337
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
338
+ *
339
+ */
340
+
341
+#include <sys/time.h>
342
+#include <stdint.h>
343
+
344
+#include "../../../../include/wrappers_mips64r6.h"
345
+#include "../../../../include/test_inputs_64.h"
346
+#include "../../../../include/test_utils_64.h"
347
+
348
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
349
+
350
+int32_t main(void)
351
+{
352
+ char *isa_ase_name = "mips64r6";
353
+ char *group_name = "CRC with reversed polynomial 0xEDB88320";
354
+ char *instruction_name = "CRC32B";
355
+ int32_t ret;
356
+ uint32_t i, j;
357
+ struct timeval start, end;
358
+ double elapsed_time;
359
+
360
+ uint64_t b64_result[TEST_COUNT_TOTAL];
361
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
362
+ 0x0000000000ffffffULL, /* 0 */
363
+ 0x000000002d02ef8dULL,
364
+ 0x000000001bab0fd1ULL,
365
+ 0x0000000036561fa3ULL,
366
+ 0xffffffffbf1caddaULL,
367
+ 0xffffffff92e1bda8ULL,
368
+ 0x00000000278c7949ULL,
369
+ 0x000000000a71693bULL,
370
+ 0x000000002dfd1072ULL, /* 8 */
371
+ 0x0000000000000000ULL,
372
+ 0x0000000036a9e05cULL,
373
+ 0x000000001b54f02eULL,
374
+ 0xffffffff921e4257ULL,
375
+ 0xffffffffbfe35225ULL,
376
+ 0x000000000a8e96c4ULL,
377
+ 0x00000000277386b6ULL,
378
+ 0x000000001bfe5a84ULL, /* 16 */
379
+ 0x0000000036034af6ULL,
380
+ 0x0000000000aaaaaaULL,
381
+ 0x000000002d57bad8ULL,
382
+ 0xffffffffa41d08a1ULL,
383
+ 0xffffffff89e018d3ULL,
384
+ 0x000000003c8ddc32ULL,
385
+ 0x000000001170cc40ULL,
386
+ 0x0000000036fcb509ULL, /* 24 */
387
+ 0x000000001b01a57bULL,
388
+ 0x000000002da84527ULL,
389
+ 0x0000000000555555ULL,
390
+ 0xffffffff891fe72cULL,
391
+ 0xffffffffa4e2f75eULL,
392
+ 0x00000000118f33bfULL,
393
+ 0x000000003c7223cdULL,
394
+ 0xffffffffbf2f9ee9ULL, /* 32 */
395
+ 0xffffffff92d28e9bULL,
396
+ 0xffffffffa47b6ec7ULL,
397
+ 0xffffffff89867eb5ULL,
398
+ 0x0000000000ccccccULL,
399
+ 0x000000002d31dcbeULL,
400
+ 0xffffffff985c185fULL,
401
+ 0xffffffffb5a1082dULL,
402
+ 0xffffffff922d7164ULL, /* 40 */
403
+ 0xffffffffbfd06116ULL,
404
+ 0xffffffff8979814aULL,
405
+ 0xffffffffa4849138ULL,
406
+ 0x000000002dce2341ULL,
407
+ 0x0000000000333333ULL,
408
+ 0xffffffffb55ef7d2ULL,
409
+ 0xffffffff98a3e7a0ULL,
410
+ 0x0000000027fdbe55ULL, /* 48 */
411
+ 0x000000000a00ae27ULL,
412
+ 0x000000003ca94e7bULL,
413
+ 0x0000000011545e09ULL,
414
+ 0xffffffff981eec70ULL,
415
+ 0xffffffffb5e3fc02ULL,
416
+ 0x00000000008e38e3ULL,
417
+ 0x000000002d732891ULL,
418
+ 0x000000000aff51d8ULL, /* 56 */
419
+ 0x00000000270241aaULL,
420
+ 0x0000000011aba1f6ULL,
421
+ 0x000000003c56b184ULL,
422
+ 0xffffffffb51c03fdULL,
423
+ 0xffffffff98e1138fULL,
424
+ 0x000000002d8cd76eULL,
425
+ 0x000000000071c71cULL,
426
+ 0x0000000000286255ULL, /* 64 */
427
+ 0x00000000784a5a65ULL,
428
+ 0xffffffff9bdd0d3bULL,
429
+ 0xffffffffe7e61ce5ULL,
430
+ 0x00000000782fabf7ULL,
431
+ 0x00000000004d93c7ULL,
432
+ 0xffffffffe3dac499ULL,
433
+ 0xffffffff9fe1d547ULL,
434
+ 0xffffffff9b4ca0e5ULL, /* 72 */
435
+ 0xffffffffe32e98d5ULL,
436
+ 0x0000000000b9cf8bULL,
437
+ 0x000000007c82de55ULL,
438
+ 0xffffffffe7904f52ULL,
439
+ 0xffffffff9ff27762ULL,
440
+ 0x000000007c65203cULL,
441
+ 0x00000000005e31e2ULL,
442
+ };
443
+
444
+ gettimeofday(&start, NULL);
445
+
446
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
447
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
448
+ do_mips64r6_CRC32B(b64_pattern + i, b64_pattern + j,
449
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
450
+ }
451
+ }
452
+
453
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
454
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
455
+ do_mips64r6_CRC32B(b64_random + i, b64_random + j,
456
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
457
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
458
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
459
+ }
460
+ }
461
+
462
+ gettimeofday(&end, NULL);
463
+
464
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
465
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
466
+
467
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
468
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
469
+ b64_expect);
470
+
471
+ return ret;
472
+}
473
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cb.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cb.c
474
new file mode 100644
475
index XXXXXXX..XXXXXXX
476
--- /dev/null
477
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cb.c
478
@@ -XXX,XX +XXX,XX @@
479
+/*
480
+ * Test program for MIPS64R6 instruction CRC32CB
481
+ *
482
+ * Copyright (C) 2019 Wave Computing, Inc.
483
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
484
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
485
+ *
486
+ * This program is free software: you can redistribute it and/or modify
487
+ * it under the terms of the GNU General Public License as published by
488
+ * the Free Software Foundation, either version 2 of the License, or
489
+ * (at your option) any later version.
490
+ *
491
+ * This program is distributed in the hope that it will be useful,
492
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
493
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
494
+ * GNU General Public License for more details.
495
+ *
496
+ * You should have received a copy of the GNU General Public License
497
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
498
+ *
499
+ */
500
+
501
+#include <sys/time.h>
502
+#include <stdint.h>
503
+
504
+#include "../../../../include/wrappers_mips64r6.h"
505
+#include "../../../../include/test_inputs_64.h"
506
+#include "../../../../include/test_utils_64.h"
507
+
508
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
509
+
510
+int32_t main(void)
511
+{
512
+ char *isa_ase_name = "mips64r6";
513
+ char *group_name = "CRC with reversed polynomial 0x82F63B78";
514
+ char *instruction_name = "CRC32CB";
515
+ int32_t ret;
516
+ uint32_t i, j;
517
+ struct timeval start, end;
518
+ double elapsed_time;
519
+
520
+ uint64_t b64_result[TEST_COUNT_TOTAL];
521
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
522
+ 0x0000000000ffffffULL, /* 0 */
523
+ 0xffffffffad7d5351ULL,
524
+ 0x00000000647e6465ULL,
525
+ 0xffffffffc9fcc8cbULL,
526
+ 0x00000000237f7689ULL,
527
+ 0xffffffff8efdda27ULL,
528
+ 0xffffffff837defedULL,
529
+ 0x000000002eff4343ULL,
530
+ 0xffffffffad82acaeULL, /* 8 */
531
+ 0x0000000000000000ULL,
532
+ 0xffffffffc9033734ULL,
533
+ 0x0000000064819b9aULL,
534
+ 0xffffffff8e0225d8ULL,
535
+ 0x0000000023808976ULL,
536
+ 0x000000002e00bcbcULL,
537
+ 0xffffffff83821012ULL,
538
+ 0x00000000642b3130ULL, /* 16 */
539
+ 0xffffffffc9a99d9eULL,
540
+ 0x0000000000aaaaaaULL,
541
+ 0xffffffffad280604ULL,
542
+ 0x0000000047abb846ULL,
543
+ 0xffffffffea2914e8ULL,
544
+ 0xffffffffe7a92122ULL,
545
+ 0x000000004a2b8d8cULL,
546
+ 0xffffffffc9566261ULL, /* 24 */
547
+ 0x0000000064d4cecfULL,
548
+ 0xffffffffadd7f9fbULL,
549
+ 0x0000000000555555ULL,
550
+ 0xffffffffead6eb17ULL,
551
+ 0x00000000475447b9ULL,
552
+ 0x000000004ad47273ULL,
553
+ 0xffffffffe756deddULL,
554
+ 0x00000000234c45baULL, /* 32 */
555
+ 0xffffffff8ecee914ULL,
556
+ 0x0000000047cdde20ULL,
557
+ 0xffffffffea4f728eULL,
558
+ 0x0000000000ccccccULL,
559
+ 0xffffffffad4e6062ULL,
560
+ 0xffffffffa0ce55a8ULL,
561
+ 0x000000000d4cf906ULL,
562
+ 0xffffffff8e3116ebULL, /* 40 */
563
+ 0x0000000023b3ba45ULL,
564
+ 0xffffffffeab08d71ULL,
565
+ 0x00000000473221dfULL,
566
+ 0xffffffffadb19f9dULL,
567
+ 0x0000000000333333ULL,
568
+ 0x000000000db306f9ULL,
569
+ 0xffffffffa031aa57ULL,
570
+ 0xffffffff830c28f1ULL, /* 48 */
571
+ 0x000000002e8e845fULL,
572
+ 0xffffffffe78db36bULL,
573
+ 0x000000004a0f1fc5ULL,
574
+ 0xffffffffa08ca187ULL,
575
+ 0x000000000d0e0d29ULL,
576
+ 0x00000000008e38e3ULL,
577
+ 0xffffffffad0c944dULL,
578
+ 0x000000002e717ba0ULL, /* 56 */
579
+ 0xffffffff83f3d70eULL,
580
+ 0x000000004af0e03aULL,
581
+ 0xffffffffe7724c94ULL,
582
+ 0x000000000df1f2d6ULL,
583
+ 0xffffffffa0735e78ULL,
584
+ 0xffffffffadf36bb2ULL,
585
+ 0x000000000071c71cULL,
586
+ 0x0000000000286255ULL, /* 64 */
587
+ 0xffffffffcbefd6b4ULL,
588
+ 0xffffffffc334e94fULL,
589
+ 0xffffffffac268ec5ULL,
590
+ 0xffffffffcb8a2726ULL,
591
+ 0x00000000004d93c7ULL,
592
+ 0x000000000896ac3cULL,
593
+ 0x000000006784cbb6ULL,
594
+ 0xffffffffc3a54491ULL, /* 72 */
595
+ 0x000000000862f070ULL,
596
+ 0x0000000000b9cf8bULL,
597
+ 0x000000006faba801ULL,
598
+ 0xffffffffac50dd72ULL,
599
+ 0x0000000067976993ULL,
600
+ 0x000000006f4c5668ULL,
601
+ 0x00000000005e31e2ULL,
602
+ };
603
+
604
+ gettimeofday(&start, NULL);
605
+
606
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
607
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
608
+ do_mips64r6_CRC32CB(b64_pattern + i, b64_pattern + j,
609
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
610
+ }
611
+ }
612
+
613
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
614
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
615
+ do_mips64r6_CRC32CB(b64_random + i, b64_random + j,
616
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
617
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
618
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
619
+ }
620
+ }
621
+
622
+ gettimeofday(&end, NULL);
623
+
624
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
625
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
626
+
627
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
628
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
629
+ b64_expect);
630
+
631
+ return ret;
632
+}
633
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cd.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cd.c
634
new file mode 100644
635
index XXXXXXX..XXXXXXX
636
--- /dev/null
637
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cd.c
638
@@ -XXX,XX +XXX,XX @@
639
+/*
640
+ * Test program for MIPS64R6 instruction CRC32CD
641
+ *
642
+ * Copyright (C) 2019 Wave Computing, Inc.
643
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
644
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
645
+ *
646
+ * This program is free software: you can redistribute it and/or modify
647
+ * it under the terms of the GNU General Public License as published by
648
+ * the Free Software Foundation, either version 2 of the License, or
649
+ * (at your option) any later version.
650
+ *
651
+ * This program is distributed in the hope that it will be useful,
652
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
653
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
654
+ * GNU General Public License for more details.
655
+ *
656
+ * You should have received a copy of the GNU General Public License
657
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
658
+ *
659
+ */
660
+
661
+#include <sys/time.h>
662
+#include <stdint.h>
663
+
664
+#include "../../../../include/wrappers_mips64r6.h"
665
+#include "../../../../include/test_inputs_64.h"
666
+#include "../../../../include/test_utils_64.h"
667
+
668
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
669
+
670
+int32_t main(void)
671
+{
672
+ char *isa_ase_name = "mips64r6";
673
+ char *group_name = "CRC with reversed polynomial 0x82F63B78";
674
+ char *instruction_name = "CRC32CD";
675
+ int32_t ret;
676
+ uint32_t i, j;
677
+ struct timeval start, end;
678
+ double elapsed_time;
679
+
680
+ uint64_t b64_result[TEST_COUNT_TOTAL];
681
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
682
+ 0xffffffffb798b438ULL, /* 0 */
683
+ 0xffffffffc44ff94dULL,
684
+ 0xffffffff992a70ebULL,
685
+ 0xffffffffeafd3d9eULL,
686
+ 0x000000005152da26ULL,
687
+ 0x0000000022859753ULL,
688
+ 0x0000000015cb6d32ULL,
689
+ 0x00000000661c2047ULL,
690
+ 0x0000000073d74d75ULL, /* 8 */
691
+ 0x0000000000000000ULL,
692
+ 0x000000005d6589a6ULL,
693
+ 0x000000002eb2c4d3ULL,
694
+ 0xffffffff951d236bULL,
695
+ 0xffffffffe6ca6e1eULL,
696
+ 0xffffffffd184947fULL,
697
+ 0xffffffffa253d90aULL,
698
+ 0x0000000008f9ceacULL, /* 16 */
699
+ 0x000000007b2e83d9ULL,
700
+ 0x00000000264b0a7fULL,
701
+ 0x00000000559c470aULL,
702
+ 0xffffffffee33a0b2ULL,
703
+ 0xffffffff9de4edc7ULL,
704
+ 0xffffffffaaaa17a6ULL,
705
+ 0xffffffffd97d5ad3ULL,
706
+ 0xffffffffccb637e1ULL, /* 24 */
707
+ 0xffffffffbf617a94ULL,
708
+ 0xffffffffe204f332ULL,
709
+ 0xffffffff91d3be47ULL,
710
+ 0x000000002a7c59ffULL,
711
+ 0x0000000059ab148aULL,
712
+ 0x000000006ee5eeebULL,
713
+ 0x000000001d32a39eULL,
714
+ 0x0000000021e3b01bULL, /* 32 */
715
+ 0x000000005234fd6eULL,
716
+ 0x000000000f5174c8ULL,
717
+ 0x000000007c8639bdULL,
718
+ 0xffffffffc729de05ULL,
719
+ 0xffffffffb4fe9370ULL,
720
+ 0xffffffff83b06911ULL,
721
+ 0xfffffffff0672464ULL,
722
+ 0xffffffffe5ac4956ULL, /* 40 */
723
+ 0xffffffff967b0423ULL,
724
+ 0xffffffffcb1e8d85ULL,
725
+ 0xffffffffb8c9c0f0ULL,
726
+ 0x0000000003662748ULL,
727
+ 0x0000000070b16a3dULL,
728
+ 0x0000000047ff905cULL,
729
+ 0x000000003428dd29ULL,
730
+ 0xffffffffb89d59a6ULL, /* 48 */
731
+ 0xffffffffcb4a14d3ULL,
732
+ 0xffffffff962f9d75ULL,
733
+ 0xffffffffe5f8d000ULL,
734
+ 0x000000005e5737b8ULL,
735
+ 0x000000002d807acdULL,
736
+ 0x000000001ace80acULL,
737
+ 0x000000006919cdd9ULL,
738
+ 0x000000007cd2a0ebULL, /* 56 */
739
+ 0x000000000f05ed9eULL,
740
+ 0x0000000052606438ULL,
741
+ 0x0000000021b7294dULL,
742
+ 0xffffffff9a18cef5ULL,
743
+ 0xffffffffe9cf8380ULL,
744
+ 0xffffffffde8179e1ULL,
745
+ 0xffffffffad563494ULL,
746
+ 0x000000003a358bb3ULL, /* 64 */
747
+ 0xffffffff975446ebULL,
748
+ 0x0000000041d37ad6ULL,
749
+ 0x000000004be84fe1ULL,
750
+ 0xffffffff9671b1b3ULL,
751
+ 0x000000003b107cebULL,
752
+ 0xffffffffed9740d6ULL,
753
+ 0xffffffffe7ac75e1ULL,
754
+ 0xffffffffa1489696ULL, /* 72 */
755
+ 0x000000000c295bceULL,
756
+ 0xffffffffdaae67f3ULL,
757
+ 0xffffffffd09552c4ULL,
758
+ 0x0000000042bd7071ULL,
759
+ 0xffffffffefdcbd29ULL,
760
+ 0x00000000395b8114ULL,
761
+ 0x000000003360b423ULL,
762
+ };
763
+
764
+ gettimeofday(&start, NULL);
765
+
766
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
767
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
768
+ do_mips64r6_CRC32CD(b64_pattern + i, b64_pattern + j,
769
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
770
+ }
771
+ }
772
+
773
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
774
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
775
+ do_mips64r6_CRC32CD(b64_random + i, b64_random + j,
776
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
777
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
778
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
779
+ }
780
+ }
781
+
782
+ gettimeofday(&end, NULL);
783
+
784
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
785
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
786
+
787
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
788
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
789
+ b64_expect);
790
+
791
+ return ret;
792
+}
793
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32ch.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32ch.c
794
new file mode 100644
795
index XXXXXXX..XXXXXXX
796
--- /dev/null
797
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32ch.c
798
@@ -XXX,XX +XXX,XX @@
799
+/*
800
+ * Test program for MIPS64R6 instruction CRC32CH
801
+ *
802
+ * Copyright (C) 2019 Wave Computing, Inc.
803
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
804
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
805
+ *
806
+ * This program is free software: you can redistribute it and/or modify
807
+ * it under the terms of the GNU General Public License as published by
808
+ * the Free Software Foundation, either version 2 of the License, or
809
+ * (at your option) any later version.
810
+ *
811
+ * This program is distributed in the hope that it will be useful,
812
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
813
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
814
+ * GNU General Public License for more details.
815
+ *
816
+ * You should have received a copy of the GNU General Public License
817
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
818
+ *
819
+ */
820
+
821
+#include <sys/time.h>
822
+#include <stdint.h>
823
+
824
+#include "../../../../include/wrappers_mips64r6.h"
825
+#include "../../../../include/test_inputs_64.h"
826
+#include "../../../../include/test_utils_64.h"
827
+
828
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
829
+
830
+int32_t main(void)
831
+{
832
+ char *isa_ase_name = "mips64r6";
833
+ char *group_name = "CRC with reversed polynomial 0x82F63B78";
834
+ char *instruction_name = "CRC32CH";
835
+ int32_t ret;
836
+ uint32_t i, j;
837
+ struct timeval start, end;
838
+ double elapsed_time;
839
+
840
+ uint64_t b64_result[TEST_COUNT_TOTAL];
841
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
842
+ 0x000000000000ffffULL, /* 0 */
843
+ 0x000000000e9e77d2ULL,
844
+ 0xfffffffff92eaa4bULL,
845
+ 0xfffffffff7b02266ULL,
846
+ 0x00000000571acc93ULL,
847
+ 0x00000000598444beULL,
848
+ 0xfffffffff1e6ca77ULL,
849
+ 0xffffffffff78425aULL,
850
+ 0x000000000e9e882dULL, /* 8 */
851
+ 0x0000000000000000ULL,
852
+ 0xfffffffff7b0dd99ULL,
853
+ 0xfffffffff92e55b4ULL,
854
+ 0x000000005984bb41ULL,
855
+ 0x00000000571a336cULL,
856
+ 0xffffffffff78bda5ULL,
857
+ 0xfffffffff1e63588ULL,
858
+ 0xfffffffff92eff1eULL, /* 16 */
859
+ 0xfffffffff7b07733ULL,
860
+ 0x000000000000aaaaULL,
861
+ 0x000000000e9e2287ULL,
862
+ 0xffffffffae34cc72ULL,
863
+ 0xffffffffa0aa445fULL,
864
+ 0x0000000008c8ca96ULL,
865
+ 0x00000000065642bbULL,
866
+ 0xfffffffff7b088ccULL, /* 24 */
867
+ 0xfffffffff92e00e1ULL,
868
+ 0x000000000e9edd78ULL,
869
+ 0x0000000000005555ULL,
870
+ 0xffffffffa0aabba0ULL,
871
+ 0xffffffffae34338dULL,
872
+ 0x000000000656bd44ULL,
873
+ 0x0000000008c83569ULL,
874
+ 0x00000000571affa0ULL, /* 32 */
875
+ 0x000000005984778dULL,
876
+ 0xffffffffae34aa14ULL,
877
+ 0xffffffffa0aa2239ULL,
878
+ 0x000000000000ccccULL,
879
+ 0x000000000e9e44e1ULL,
880
+ 0xffffffffa6fcca28ULL,
881
+ 0xffffffffa8624205ULL,
882
+ 0x0000000059848872ULL, /* 40 */
883
+ 0x00000000571a005fULL,
884
+ 0xffffffffa0aaddc6ULL,
885
+ 0xffffffffae3455ebULL,
886
+ 0x000000000e9ebb1eULL,
887
+ 0x0000000000003333ULL,
888
+ 0xffffffffa862bdfaULL,
889
+ 0xffffffffa6fc35d7ULL,
890
+ 0xfffffffff1e6bbb0ULL, /* 48 */
891
+ 0xffffffffff78339dULL,
892
+ 0x0000000008c8ee04ULL,
893
+ 0x0000000006566629ULL,
894
+ 0xffffffffa6fc88dcULL,
895
+ 0xffffffffa86200f1ULL,
896
+ 0x0000000000008e38ULL,
897
+ 0x000000000e9e0615ULL,
898
+ 0xffffffffff78cc62ULL, /* 56 */
899
+ 0xfffffffff1e6444fULL,
900
+ 0x00000000065699d6ULL,
901
+ 0x0000000008c811fbULL,
902
+ 0xffffffffa862ff0eULL,
903
+ 0xffffffffa6fc7723ULL,
904
+ 0x000000000e9ef9eaULL,
905
+ 0x00000000000071c7ULL,
906
+ 0x0000000000002862ULL, /* 64 */
907
+ 0x000000001190c4cfULL,
908
+ 0x000000007b7fdbbeULL,
909
+ 0xffffffff9204da99ULL,
910
+ 0x000000001190a13eULL,
911
+ 0x0000000000004d93ULL,
912
+ 0x000000006aef52e2ULL,
913
+ 0xffffffff839453c5ULL,
914
+ 0x000000007b7f4a13ULL, /* 72 */
915
+ 0x000000006aefa6beULL,
916
+ 0x000000000000b9cfULL,
917
+ 0xffffffffe97bb8e8ULL,
918
+ 0xffffffff9204accaULL,
919
+ 0xffffffff83944067ULL,
920
+ 0xffffffffe97b5f16ULL,
921
+ 0x0000000000005e31ULL,
922
+ };
923
+
924
+ gettimeofday(&start, NULL);
925
+
926
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
927
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
928
+ do_mips64r6_CRC32CH(b64_pattern + i, b64_pattern + j,
929
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
930
+ }
931
+ }
932
+
933
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
934
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
935
+ do_mips64r6_CRC32CH(b64_random + i, b64_random + j,
936
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
937
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
938
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
939
+ }
940
+ }
941
+
942
+ gettimeofday(&end, NULL);
943
+
944
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
945
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
946
+
947
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
948
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
949
+ b64_expect);
950
+
951
+ return ret;
952
+}
953
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cw.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cw.c
954
new file mode 100644
955
index XXXXXXX..XXXXXXX
956
--- /dev/null
957
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32cw.c
958
@@ -XXX,XX +XXX,XX @@
959
+/*
960
+ * Test program for MIPS64R6 instruction CRC32CW
961
+ *
962
+ * Copyright (C) 2019 Wave Computing, Inc.
963
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
964
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
965
+ *
966
+ * This program is free software: you can redistribute it and/or modify
967
+ * it under the terms of the GNU General Public License as published by
968
+ * the Free Software Foundation, either version 2 of the License, or
969
+ * (at your option) any later version.
970
+ *
971
+ * This program is distributed in the hope that it will be useful,
972
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
973
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
974
+ * GNU General Public License for more details.
975
+ *
976
+ * You should have received a copy of the GNU General Public License
977
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
978
+ *
979
+ */
980
+
981
+#include <sys/time.h>
982
+#include <stdint.h>
983
+
984
+#include "../../../../include/wrappers_mips64r6.h"
985
+#include "../../../../include/test_inputs_64.h"
986
+#include "../../../../include/test_utils_64.h"
987
+
988
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
989
+
990
+int32_t main(void)
991
+{
992
+ char *isa_ase_name = "mips64r6";
993
+ char *group_name = "CRC with reversed polynomial 0x82F63B78";
994
+ char *instruction_name = "CRC32CW";
995
+ int32_t ret;
996
+ uint32_t i, j;
997
+ struct timeval start, end;
998
+ double elapsed_time;
999
+
1000
+ uint64_t b64_result[TEST_COUNT_TOTAL];
1001
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
1002
+ 0x0000000000000000ULL, /* 0 */
1003
+ 0xffffffffb798b438ULL,
1004
+ 0xffffffff91d3be47ULL,
1005
+ 0x00000000264b0a7fULL,
1006
+ 0x0000000070b16a3dULL,
1007
+ 0xffffffffc729de05ULL,
1008
+ 0x0000000063c5950aULL,
1009
+ 0xffffffffd45d2132ULL,
1010
+ 0xffffffffb798b438ULL, /* 8 */
1011
+ 0x0000000000000000ULL,
1012
+ 0x00000000264b0a7fULL,
1013
+ 0xffffffff91d3be47ULL,
1014
+ 0xffffffffc729de05ULL,
1015
+ 0x0000000070b16a3dULL,
1016
+ 0xffffffffd45d2132ULL,
1017
+ 0x0000000063c5950aULL,
1018
+ 0xffffffff91d3be47ULL, /* 16 */
1019
+ 0x00000000264b0a7fULL,
1020
+ 0x0000000000000000ULL,
1021
+ 0xffffffffb798b438ULL,
1022
+ 0xffffffffe162d47aULL,
1023
+ 0x0000000056fa6042ULL,
1024
+ 0xfffffffff2162b4dULL,
1025
+ 0x00000000458e9f75ULL,
1026
+ 0x00000000264b0a7fULL, /* 24 */
1027
+ 0xffffffff91d3be47ULL,
1028
+ 0xffffffffb798b438ULL,
1029
+ 0x0000000000000000ULL,
1030
+ 0x0000000056fa6042ULL,
1031
+ 0xffffffffe162d47aULL,
1032
+ 0x00000000458e9f75ULL,
1033
+ 0xfffffffff2162b4dULL,
1034
+ 0x0000000070b16a3dULL, /* 32 */
1035
+ 0xffffffffc729de05ULL,
1036
+ 0xffffffffe162d47aULL,
1037
+ 0x0000000056fa6042ULL,
1038
+ 0x0000000000000000ULL,
1039
+ 0xffffffffb798b438ULL,
1040
+ 0x000000001374ff37ULL,
1041
+ 0xffffffffa4ec4b0fULL,
1042
+ 0xffffffffc729de05ULL, /* 40 */
1043
+ 0x0000000070b16a3dULL,
1044
+ 0x0000000056fa6042ULL,
1045
+ 0xffffffffe162d47aULL,
1046
+ 0xffffffffb798b438ULL,
1047
+ 0x0000000000000000ULL,
1048
+ 0xffffffffa4ec4b0fULL,
1049
+ 0x000000001374ff37ULL,
1050
+ 0x0000000063c5950aULL, /* 48 */
1051
+ 0xffffffffd45d2132ULL,
1052
+ 0xfffffffff2162b4dULL,
1053
+ 0x00000000458e9f75ULL,
1054
+ 0x000000001374ff37ULL,
1055
+ 0xffffffffa4ec4b0fULL,
1056
+ 0x0000000000000000ULL,
1057
+ 0xffffffffb798b438ULL,
1058
+ 0xffffffffd45d2132ULL, /* 56 */
1059
+ 0x0000000063c5950aULL,
1060
+ 0x00000000458e9f75ULL,
1061
+ 0xfffffffff2162b4dULL,
1062
+ 0xffffffffa4ec4b0fULL,
1063
+ 0x000000001374ff37ULL,
1064
+ 0xffffffffb798b438ULL,
1065
+ 0x0000000000000000ULL,
1066
+ 0x0000000000000000ULL, /* 64 */
1067
+ 0xffffffffea0755b2ULL,
1068
+ 0x0000000008b188e6ULL,
1069
+ 0xffffffffff3cc8d9ULL,
1070
+ 0xffffffffea0755b2ULL,
1071
+ 0x0000000000000000ULL,
1072
+ 0xffffffffe2b6dd54ULL,
1073
+ 0x00000000153b9d6bULL,
1074
+ 0x0000000008b188e6ULL, /* 72 */
1075
+ 0xffffffffe2b6dd54ULL,
1076
+ 0x0000000000000000ULL,
1077
+ 0xfffffffff78d403fULL,
1078
+ 0xffffffffff3cc8d9ULL,
1079
+ 0x00000000153b9d6bULL,
1080
+ 0xfffffffff78d403fULL,
1081
+ 0x0000000000000000ULL,
1082
+ };
1083
+
1084
+ gettimeofday(&start, NULL);
1085
+
1086
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
1087
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
1088
+ do_mips64r6_CRC32CW(b64_pattern + i, b64_pattern + j,
1089
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
1090
+ }
1091
+ }
1092
+
1093
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
1094
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
1095
+ do_mips64r6_CRC32CW(b64_random + i, b64_random + j,
1096
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
1097
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
1098
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
1099
+ }
1100
+ }
1101
+
1102
+ gettimeofday(&end, NULL);
1103
+
1104
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
1105
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
1106
+
1107
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
1108
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
1109
+ b64_expect);
1110
+
1111
+ return ret;
1112
+}
1113
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32d.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32d.c
1114
new file mode 100644
1115
index XXXXXXX..XXXXXXX
1116
--- /dev/null
1117
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32d.c
1118
@@ -XXX,XX +XXX,XX @@
1119
+/*
1120
+ * Test program for MIPS64R6 instruction CRC32D
1121
+ *
1122
+ * Copyright (C) 2019 Wave Computing, Inc.
1123
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
1124
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
1125
+ *
1126
+ * This program is free software: you can redistribute it and/or modify
1127
+ * it under the terms of the GNU General Public License as published by
1128
+ * the Free Software Foundation, either version 2 of the License, or
1129
+ * (at your option) any later version.
1130
+ *
1131
+ * This program is distributed in the hope that it will be useful,
1132
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1133
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1134
+ * GNU General Public License for more details.
1135
+ *
1136
+ * You should have received a copy of the GNU General Public License
1137
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
1138
+ *
1139
+ */
1140
+
1141
+#include <sys/time.h>
1142
+#include <stdint.h>
1143
+
1144
+#include "../../../../include/wrappers_mips64r6.h"
1145
+#include "../../../../include/test_inputs_64.h"
1146
+#include "../../../../include/test_utils_64.h"
1147
+
1148
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
1149
+
1150
+int32_t main(void)
1151
+{
1152
+ char *isa_ase_name = "mips64r6";
1153
+ char *group_name = "CRC with reversed polynomial 0xEDB88320";
1154
+ char *instruction_name = "CRC32D";
1155
+ int32_t ret;
1156
+ uint32_t i, j;
1157
+ struct timeval start, end;
1158
+ double elapsed_time;
1159
+
1160
+ uint64_t b64_result[TEST_COUNT_TOTAL];
1161
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
1162
+ 0xffffffffdebb20e3ULL, /* 0 */
1163
+ 0x0000000044660075ULL,
1164
+ 0x000000001e20c2aeULL,
1165
+ 0xffffffff84fde238ULL,
1166
+ 0x00000000281d7ce7ULL,
1167
+ 0xffffffffb2c05c71ULL,
1168
+ 0xffffffffd660a024ULL,
1169
+ 0x000000004cbd80b2ULL,
1170
+ 0xffffffff9add2096ULL, /* 8 */
1171
+ 0x0000000000000000ULL,
1172
+ 0x000000005a46c2dbULL,
1173
+ 0xffffffffc09be24dULL,
1174
+ 0x000000006c7b7c92ULL,
1175
+ 0xfffffffff6a65c04ULL,
1176
+ 0xffffffff9206a051ULL,
1177
+ 0x0000000008db80c7ULL,
1178
+ 0x000000005449dd0fULL, /* 16 */
1179
+ 0xffffffffce94fd99ULL,
1180
+ 0xffffffff94d23f42ULL,
1181
+ 0x000000000e0f1fd4ULL,
1182
+ 0xffffffffa2ef810bULL,
1183
+ 0x000000003832a19dULL,
1184
+ 0x000000005c925dc8ULL,
1185
+ 0xffffffffc64f7d5eULL,
1186
+ 0x00000000102fdd7aULL, /* 24 */
1187
+ 0xffffffff8af2fdecULL,
1188
+ 0xffffffffd0b43f37ULL,
1189
+ 0x000000004a691fa1ULL,
1190
+ 0xffffffffe689817eULL,
1191
+ 0x000000007c54a1e8ULL,
1192
+ 0x0000000018f45dbdULL,
1193
+ 0xffffffff82297d2bULL,
1194
+ 0xffffffffa7157447ULL, /* 32 */
1195
+ 0x000000003dc854d1ULL,
1196
+ 0x00000000678e960aULL,
1197
+ 0xfffffffffd53b69cULL,
1198
+ 0x0000000051b32843ULL,
1199
+ 0xffffffffcb6e08d5ULL,
1200
+ 0xffffffffafcef480ULL,
1201
+ 0x000000003513d416ULL,
1202
+ 0xffffffffe3737432ULL, /* 40 */
1203
+ 0x0000000079ae54a4ULL,
1204
+ 0x0000000023e8967fULL,
1205
+ 0xffffffffb935b6e9ULL,
1206
+ 0x0000000015d52836ULL,
1207
+ 0xffffffff8f0808a0ULL,
1208
+ 0xffffffffeba8f4f5ULL,
1209
+ 0x000000007175d463ULL,
1210
+ 0x000000007a6adc3eULL, /* 48 */
1211
+ 0xffffffffe0b7fca8ULL,
1212
+ 0xffffffffbaf13e73ULL,
1213
+ 0x00000000202c1ee5ULL,
1214
+ 0xffffffff8ccc803aULL,
1215
+ 0x000000001611a0acULL,
1216
+ 0x0000000072b15cf9ULL,
1217
+ 0xffffffffe86c7c6fULL,
1218
+ 0x000000003e0cdc4bULL, /* 56 */
1219
+ 0xffffffffa4d1fcddULL,
1220
+ 0xfffffffffe973e06ULL,
1221
+ 0x00000000644a1e90ULL,
1222
+ 0xffffffffc8aa804fULL,
1223
+ 0x000000005277a0d9ULL,
1224
+ 0x0000000036d75c8cULL,
1225
+ 0xffffffffac0a7c1aULL,
1226
+ 0xffffffffed857593ULL, /* 64 */
1227
+ 0xffffffffe0b6f95fULL,
1228
+ 0x00000000253b462cULL,
1229
+ 0xffffffffe15579b9ULL,
1230
+ 0x0000000074897c83ULL,
1231
+ 0x0000000079baf04fULL,
1232
+ 0xffffffffbc374f3cULL,
1233
+ 0x00000000785970a9ULL,
1234
+ 0xffffffffa6bae0a9ULL, /* 72 */
1235
+ 0xffffffffab896c65ULL,
1236
+ 0x000000006e04d316ULL,
1237
+ 0xffffffffaa6aec83ULL,
1238
+ 0x000000005ae171feULL,
1239
+ 0x0000000057d2fd32ULL,
1240
+ 0xffffffff925f4241ULL,
1241
+ 0x0000000056317dd4ULL,
1242
+ };
1243
+
1244
+ gettimeofday(&start, NULL);
1245
+
1246
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
1247
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
1248
+ do_mips64r6_CRC32D(b64_pattern + i, b64_pattern + j,
1249
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
1250
+ }
1251
+ }
1252
+
1253
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
1254
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
1255
+ do_mips64r6_CRC32D(b64_random + i, b64_random + j,
1256
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
1257
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
1258
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
1259
+ }
1260
+ }
1261
+
1262
+ gettimeofday(&end, NULL);
1263
+
1264
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
1265
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
1266
+
1267
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
1268
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
1269
+ b64_expect);
1270
+
1271
+ return ret;
1272
+}
1273
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32h.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32h.c
1274
new file mode 100644
1275
index XXXXXXX..XXXXXXX
1276
--- /dev/null
1277
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32h.c
1278
@@ -XXX,XX +XXX,XX @@
1279
+/*
1280
+ * Test program for MIPS64R6 instruction CRC32H
1281
+ *
1282
+ * Copyright (C) 2019 Wave Computing, Inc.
1283
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
1284
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
1285
+ *
1286
+ * This program is free software: you can redistribute it and/or modify
1287
+ * it under the terms of the GNU General Public License as published by
1288
+ * the Free Software Foundation, either version 2 of the License, or
1289
+ * (at your option) any later version.
1290
+ *
1291
+ * This program is distributed in the hope that it will be useful,
1292
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1293
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1294
+ * GNU General Public License for more details.
1295
+ *
1296
+ * You should have received a copy of the GNU General Public License
1297
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
1298
+ *
1299
+ */
1300
+
1301
+#include <sys/time.h>
1302
+#include <stdint.h>
1303
+
1304
+#include "../../../../include/wrappers_mips64r6.h"
1305
+#include "../../../../include/test_inputs_64.h"
1306
+#include "../../../../include/test_utils_64.h"
1307
+
1308
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
1309
+
1310
+int32_t main(void)
1311
+{
1312
+ char *isa_ase_name = "mips64r6";
1313
+ char *group_name = "CRC with reversed polynomial 0xEDB88320";
1314
+ char *instruction_name = "CRC32H";
1315
+ int32_t ret;
1316
+ uint32_t i, j;
1317
+ struct timeval start, end;
1318
+ double elapsed_time;
1319
+
1320
+ uint64_t b64_result[TEST_COUNT_TOTAL];
1321
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
1322
+ 0x000000000000ffffULL, /* 0 */
1323
+ 0xffffffffbe2612ffULL,
1324
+ 0xffffffffdccda6c0ULL,
1325
+ 0x0000000062eb4bc0ULL,
1326
+ 0x000000004bbbc8eaULL,
1327
+ 0xfffffffff59d25eaULL,
1328
+ 0x0000000022259ac0ULL,
1329
+ 0xffffffff9c0377c0ULL,
1330
+ 0xffffffffbe26ed00ULL, /* 8 */
1331
+ 0x0000000000000000ULL,
1332
+ 0x0000000062ebb43fULL,
1333
+ 0xffffffffdccd593fULL,
1334
+ 0xfffffffff59dda15ULL,
1335
+ 0x000000004bbb3715ULL,
1336
+ 0xffffffff9c03883fULL,
1337
+ 0x000000002225653fULL,
1338
+ 0xffffffffdccdf395ULL, /* 16 */
1339
+ 0x0000000062eb1e95ULL,
1340
+ 0x000000000000aaaaULL,
1341
+ 0xffffffffbe2647aaULL,
1342
+ 0xffffffff9776c480ULL,
1343
+ 0x0000000029502980ULL,
1344
+ 0xfffffffffee896aaULL,
1345
+ 0x0000000040ce7baaULL,
1346
+ 0x0000000062ebe16aULL, /* 24 */
1347
+ 0xffffffffdccd0c6aULL,
1348
+ 0xffffffffbe26b855ULL,
1349
+ 0x0000000000005555ULL,
1350
+ 0x000000002950d67fULL,
1351
+ 0xffffffff97763b7fULL,
1352
+ 0x0000000040ce8455ULL,
1353
+ 0xfffffffffee86955ULL,
1354
+ 0x000000004bbbfbd9ULL, /* 32 */
1355
+ 0xfffffffff59d16d9ULL,
1356
+ 0xffffffff9776a2e6ULL,
1357
+ 0x0000000029504fe6ULL,
1358
+ 0x000000000000ccccULL,
1359
+ 0xffffffffbe2621ccULL,
1360
+ 0x00000000699e9ee6ULL,
1361
+ 0xffffffffd7b873e6ULL,
1362
+ 0xfffffffff59de926ULL, /* 40 */
1363
+ 0x000000004bbb0426ULL,
1364
+ 0x000000002950b019ULL,
1365
+ 0xffffffff97765d19ULL,
1366
+ 0xffffffffbe26de33ULL,
1367
+ 0x0000000000003333ULL,
1368
+ 0xffffffffd7b88c19ULL,
1369
+ 0x00000000699e6119ULL,
1370
+ 0x000000002225eb07ULL, /* 48 */
1371
+ 0xffffffff9c030607ULL,
1372
+ 0xfffffffffee8b238ULL,
1373
+ 0x0000000040ce5f38ULL,
1374
+ 0x00000000699edc12ULL,
1375
+ 0xffffffffd7b83112ULL,
1376
+ 0x0000000000008e38ULL,
1377
+ 0xffffffffbe266338ULL,
1378
+ 0xffffffff9c03f9f8ULL, /* 56 */
1379
+ 0x00000000222514f8ULL,
1380
+ 0x0000000040cea0c7ULL,
1381
+ 0xfffffffffee84dc7ULL,
1382
+ 0xffffffffd7b8ceedULL,
1383
+ 0x00000000699e23edULL,
1384
+ 0xffffffffbe269cc7ULL,
1385
+ 0x00000000000071c7ULL,
1386
+ 0x0000000000002862ULL, /* 64 */
1387
+ 0x0000000026a17af6ULL,
1388
+ 0xffffffffaa919152ULL,
1389
+ 0xffffffffcb865590ULL,
1390
+ 0x0000000026a11f07ULL,
1391
+ 0x0000000000004d93ULL,
1392
+ 0xffffffff8c30a637ULL,
1393
+ 0xffffffffed2762f5ULL,
1394
+ 0xffffffffaa9100ffULL, /* 72 */
1395
+ 0xffffffff8c30526bULL,
1396
+ 0x000000000000b9cfULL,
1397
+ 0x0000000061177d0dULL,
1398
+ 0xffffffffcb8623c3ULL,
1399
+ 0xffffffffed277157ULL,
1400
+ 0x0000000061179af3ULL,
1401
+ 0x0000000000005e31ULL
1402
+ };
1403
+
1404
+ gettimeofday(&start, NULL);
1405
+
1406
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
1407
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
1408
+ do_mips64r6_CRC32H(b64_pattern + i, b64_pattern + j,
1409
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
1410
+ }
1411
+ }
1412
+
1413
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
1414
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
1415
+ do_mips64r6_CRC32H(b64_random + i, b64_random + j,
1416
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
1417
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
1418
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
1419
+ }
1420
+ }
1421
+
1422
+ gettimeofday(&end, NULL);
1423
+
1424
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
1425
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
1426
+
1427
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
1428
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
1429
+ b64_expect);
1430
+
1431
+ return ret;
1432
+}
1433
diff --git a/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32w.c b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32w.c
1434
new file mode 100644
1435
index XXXXXXX..XXXXXXX
1436
--- /dev/null
1437
+++ b/tests/tcg/mips/user/isa/mips64r6/crc/test_mips64r6_crc32w.c
1438
@@ -XXX,XX +XXX,XX @@
1439
+/*
1440
+ * Test program for MIPS64R6 instruction CRC32W
1441
+ *
1442
+ * Copyright (C) 2019 Wave Computing, Inc.
1443
+ * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
1444
+ * Copyright (C) 2025 Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
1445
+ *
1446
+ * This program is free software: you can redistribute it and/or modify
1447
+ * it under the terms of the GNU General Public License as published by
1448
+ * the Free Software Foundation, either version 2 of the License, or
1449
+ * (at your option) any later version.
1450
+ *
1451
+ * This program is distributed in the hope that it will be useful,
1452
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1453
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1454
+ * GNU General Public License for more details.
1455
+ *
1456
+ * You should have received a copy of the GNU General Public License
1457
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
1458
+ *
1459
+ */
1460
+
1461
+#include <sys/time.h>
1462
+#include <stdint.h>
1463
+
1464
+#include "../../../../include/wrappers_mips64r6.h"
1465
+#include "../../../../include/test_inputs_64.h"
1466
+#include "../../../../include/test_utils_64.h"
1467
+
1468
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_64_COUNT + RANDOM_INPUTS_64_COUNT)
1469
+
1470
+int32_t main(void)
1471
+{
1472
+ char *isa_ase_name = "mips64r6";
1473
+ char *group_name = "CRC with reversed polynomial 0xEDB88320";
1474
+ char *instruction_name = "CRC32W";
1475
+ int32_t ret;
1476
+ uint32_t i, j;
1477
+ struct timeval start, end;
1478
+ double elapsed_time;
1479
+
1480
+ uint64_t b64_result[TEST_COUNT_TOTAL];
1481
+ uint64_t b64_expect[TEST_COUNT_TOTAL] = {
1482
+ 0x0000000000000000ULL, /* 0 */
1483
+ 0xffffffffdebb20e3ULL,
1484
+ 0x000000004a691fa1ULL,
1485
+ 0xffffffff94d23f42ULL,
1486
+ 0xffffffff8f0808a0ULL,
1487
+ 0x0000000051b32843ULL,
1488
+ 0x0000000065069dceULL,
1489
+ 0xffffffffbbbdbd2dULL,
1490
+ 0xffffffffdebb20e3ULL, /* 8 */
1491
+ 0x0000000000000000ULL,
1492
+ 0xffffffff94d23f42ULL,
1493
+ 0x000000004a691fa1ULL,
1494
+ 0x0000000051b32843ULL,
1495
+ 0xffffffff8f0808a0ULL,
1496
+ 0xffffffffbbbdbd2dULL,
1497
+ 0x0000000065069dceULL,
1498
+ 0x000000004a691fa1ULL, /* 16 */
1499
+ 0xffffffff94d23f42ULL,
1500
+ 0x0000000000000000ULL,
1501
+ 0xffffffffdebb20e3ULL,
1502
+ 0xffffffffc5611701ULL,
1503
+ 0x000000001bda37e2ULL,
1504
+ 0x000000002f6f826fULL,
1505
+ 0xfffffffff1d4a28cULL,
1506
+ 0xffffffff94d23f42ULL, /* 24 */
1507
+ 0x000000004a691fa1ULL,
1508
+ 0xffffffffdebb20e3ULL,
1509
+ 0x0000000000000000ULL,
1510
+ 0x000000001bda37e2ULL,
1511
+ 0xffffffffc5611701ULL,
1512
+ 0xfffffffff1d4a28cULL,
1513
+ 0x000000002f6f826fULL,
1514
+ 0xffffffff8f0808a0ULL, /* 32 */
1515
+ 0x0000000051b32843ULL,
1516
+ 0xffffffffc5611701ULL,
1517
+ 0x000000001bda37e2ULL,
1518
+ 0x0000000000000000ULL,
1519
+ 0xffffffffdebb20e3ULL,
1520
+ 0xffffffffea0e956eULL,
1521
+ 0x0000000034b5b58dULL,
1522
+ 0x0000000051b32843ULL, /* 40 */
1523
+ 0xffffffff8f0808a0ULL,
1524
+ 0x000000001bda37e2ULL,
1525
+ 0xffffffffc5611701ULL,
1526
+ 0xffffffffdebb20e3ULL,
1527
+ 0x0000000000000000ULL,
1528
+ 0x0000000034b5b58dULL,
1529
+ 0xffffffffea0e956eULL,
1530
+ 0x0000000065069dceULL, /* 48 */
1531
+ 0xffffffffbbbdbd2dULL,
1532
+ 0x000000002f6f826fULL,
1533
+ 0xfffffffff1d4a28cULL,
1534
+ 0xffffffffea0e956eULL,
1535
+ 0x0000000034b5b58dULL,
1536
+ 0x0000000000000000ULL,
1537
+ 0xffffffffdebb20e3ULL,
1538
+ 0xffffffffbbbdbd2dULL, /* 56 */
1539
+ 0x0000000065069dceULL,
1540
+ 0xfffffffff1d4a28cULL,
1541
+ 0x000000002f6f826fULL,
1542
+ 0x0000000034b5b58dULL,
1543
+ 0xffffffffea0e956eULL,
1544
+ 0xffffffffdebb20e3ULL,
1545
+ 0x0000000000000000ULL,
1546
+ 0x0000000000000000ULL, /* 64 */
1547
+ 0xffffffff90485967ULL,
1548
+ 0x000000006dfb974aULL,
1549
+ 0x00000000083e4538ULL,
1550
+ 0xffffffff90485967ULL,
1551
+ 0x0000000000000000ULL,
1552
+ 0xfffffffffdb3ce2dULL,
1553
+ 0xffffffff98761c5fULL,
1554
+ 0x000000006dfb974aULL, /* 72 */
1555
+ 0xfffffffffdb3ce2dULL,
1556
+ 0x0000000000000000ULL,
1557
+ 0x0000000065c5d272ULL,
1558
+ 0x00000000083e4538ULL,
1559
+ 0xffffffff98761c5fULL,
1560
+ 0x0000000065c5d272ULL,
1561
+ 0x0000000000000000ULL,
1562
+ };
1563
+
1564
+ gettimeofday(&start, NULL);
1565
+
1566
+ for (i = 0; i < PATTERN_INPUTS_64_SHORT_COUNT; i++) {
1567
+ for (j = 0; j < PATTERN_INPUTS_64_SHORT_COUNT; j++) {
1568
+ do_mips64r6_CRC32W(b64_pattern + i, b64_pattern + j,
1569
+ b64_result + (PATTERN_INPUTS_64_SHORT_COUNT * i + j));
1570
+ }
1571
+ }
1572
+
1573
+ for (i = 0; i < RANDOM_INPUTS_64_SHORT_COUNT; i++) {
1574
+ for (j = 0; j < RANDOM_INPUTS_64_SHORT_COUNT; j++) {
1575
+ do_mips64r6_CRC32W(b64_random + i, b64_random + j,
1576
+ b64_result + (((PATTERN_INPUTS_64_SHORT_COUNT) *
1577
+ (PATTERN_INPUTS_64_SHORT_COUNT)) +
1578
+ RANDOM_INPUTS_64_SHORT_COUNT * i + j));
1579
+ }
1580
+ }
1581
+
1582
+ gettimeofday(&end, NULL);
1583
+
1584
+ elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
1585
+ elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
1586
+
1587
+ ret = check_results_64(isa_ase_name, group_name, instruction_name,
1588
+ TEST_COUNT_TOTAL, elapsed_time, b64_result,
1589
+ b64_expect);
1590
+
1591
+ return ret;
1592
+}
197
--
1593
--
198
2.34.1
1594
2.34.1
diff view generated by jsdifflib
1
From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
2
1
Skip NaN mode check for soft-float since NaN mode is irrelevant if an ELF
3
Skip NaN mode check for soft-float since NaN mode is irrelevant if an ELF
2
binary's FPU mode is soft-float, i.e. it doesn't utilize a FPU.
4
binary's FPU mode is soft-float, i.e. it doesn't utilize a FPU.
3
5
4
Cherry-picked 63492a56485f6b755fccf7ad623f7a189bfc79b6
6
Cherry-picked 63492a56485f6b755fccf7ad623f7a189bfc79b6
5
from https://github.com/MIPS/gnutools-qemu
7
from https://github.com/MIPS/gnutools-qemu
...
...
diff view generated by jsdifflib
1
From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
2
1
Enable MSA ASE using a CLI flag -cpu <cpu>,msa=on.
3
Enable MSA ASE using a CLI flag -cpu <cpu>,msa=on.
2
4
3
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
5
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
4
---
6
---
5
target/mips/cpu.c | 16 ++++++++++++++++
7
target/mips/cpu.c | 16 ++++++++++++++++
...
...
diff view generated by jsdifflib
Deleted patch
1
Enable MSA ASE for mips64R2-generic CPU.
2
1
3
Cherry-picked 60f6ae8d3d685ba1ea5d301222fb72b67f39264f
4
from https://github.com/MIPS/gnutools-qemu
5
6
Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com>
7
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
8
---
9
target/mips/cpu-defs.c.inc | 4 +++-
10
1 file changed, 3 insertions(+), 1 deletion(-)
11
12
diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/mips/cpu-defs.c.inc
15
+++ b/target/mips/cpu-defs.c.inc
16
@@ -XXX,XX +XXX,XX @@ const mips_def_t mips_defs[] =
17
(2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
18
(1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
19
.CP0_Config2 = MIPS_CONFIG2,
20
- .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
21
+ .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA) |
22
+ (1 << CP0C3_VInt) | (1 << CP0C3_MSAP),
23
+ .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn),
24
.CP0_LLAddr_rw_bitmask = 0,
25
.CP0_LLAddr_shift = 0,
26
.SYNCI_Step = 32,
27
--
28
2.34.1
diff view generated by jsdifflib