@@ -42,12 +42,8 @@ test_main:
4242 jal smoke_alu_zba
4343 jal smoke_alu_zbb
4444 jal smoke_alu_zbc
45- jal smoke_alu_zbf
4645 jal smoke_alu_zbp
47- jal smoke_alu_zbr
4846 jal smoke_alu_zbs
49- jal smoke_alu_b_misc
50- jal smoke_alu_zbt
5147 jal smoke_alu_b_imm
5248 jal smoke_csr
5349 jal smoke_fence
@@ -207,9 +203,8 @@ smoke_alu_zba:
207203/**
208204 * Checks the instructions from the zbb extension
209205 *
210- * Note: rev8 , orc.b , and zext.h are pseudo instructions
211- * for grevi , gorci , and pack respectively ,
212- * which are tested in `smoke_alu_b_imm` and `smoke_alu_zbp`.
206+ * Note: the immediate Zbb permutation ops rev8 and orc.b (and brev8) are checked
207+ * in `smoke_alu_b_imm`; zext.h is checked in `smoke_alu_zbp`.
213208 */
214209smoke_alu_zbb:
215210 li t0, 3
@@ -259,73 +254,44 @@ smoke_alu_zbc:
259254 ret
260255
261256/**
262- * Checks the instructions from the zbf extension
263- *
264- * Note: pack and packh are not checked here
265- * but in covered in `smoke_alu_zbp`.
266- * /
267- smoke_alu_zbf:
268- li t0 , 0x0e0a47f3
269- li t1 , 0x0e1fcff3
270- .option push
271- .option arch , + zbf0p93
272- bfp t0 , t0 , t0
273- .option pop
274- check t0 , t1
275- ret
276-
277- / **
278- * Checks the instructions from the zbp extension
257+ * Checks the ratified Zbkb / Zbkx instructions: pack, packh, zext.h (Zbb pseudo),
258+ * xperm4, xperm8, zip, unzip.
279259 *
280260 * Note: andn, orn, xnor, rol, and ror are not checked here
281261 * but in `smoke_alu_zbb`.
282262 */
283263smoke_alu_zbp:
284264 .option push
285- .option arch , + zbp0p93
265+ .option arch, +zbkb, +zbkx
286266 li t0, 0xcc9fd6b6
287267 li t1, 0x7ce71003
268+ li t3, 0x7ce7cc9f
288269 pack t2, t0, t1
289- packu t3 , t0 , t1
290270 packh t2, t2, t3
291271
292272 li t0, 0x00009fb6
293273 check t0, t2
294274
275+ // zext.h (Zbb): pack rd, rs , x0 -> zero-extend the low halfword.
276+ zext.h t2, t3
277+ li t0, 0x0000cc9f
278+ check t0, t2
279+
280+ li t0, 0x00f7f9ff
295281 li t2, 0x04030001
296- xperm.n t3 , t3 , t2
297- xperm.b t3 , t3 , t2
298- xperm.h t3 , t3 , t2
299- li t0 , 0x000000f7
282+ xperm4 t3, t3, t2
283+ xperm8 t3, t3, t2
300284 check t3, t0
301285
302- li t0 , 4
303- grev t1 , t1 , t0
304- shfl t1 , t1 , t0
305- gorc t1 , t1 , t0
306- unshfl t1 , t1 , t0
307- .option pop
308-
309- li t0 , 0xffff3131
286+ // zip/unzip (Zbkb): zip interleaves the low/high halfwords bit-by-bit; unzip
287+ // is its inverse. zip(0x0000ffff) = 0x55555555, unzip(0x55555555) = 0x0000ffff.
288+ li t0, 0x0000ffff
289+ zip t1, t0
290+ li t2, 0x55555555
291+ check t2, t1
292+ unzip t1, t1
310293 check t0, t1
311- ret
312-
313- / **
314- * Checks the instructions from the zbr extension
315- * /
316- smoke_alu_zbr:
317- li t0 , 0xabdca651
318- li t1 , 0xac605e47
319- .option push
320- .option arch , + zbr0p93
321- crc32 .b t0 , t0
322- crc32 .h t0 , t0
323- crc32 .w t0 , t0
324- crc32c.b t0 , t0
325- crc32c.h t0 , t0
326- crc32c.w t0 , t0
327294 .option pop
328- check t1 , t0
329295 ret
330296
331297/**
@@ -344,79 +310,36 @@ smoke_alu_zbs:
344310
345311 ret
346312
347- / **
348- * Checks the instructions from the zbt extension
349- * /
350- smoke_alu_zbt:
351- .option push
352- .option arch , + zbt0p93
353- li t0 , 7
354- li t1 , 4
355- li t2 , 0x5d76fb6b
356- li t3 , 0xe5693902
357- fsl t2 , t2 , t3 , t0
358- fsr t2 , t2 , t3 , t1
359- cmix t2 , t0 , t2 , t3
360-
361- li t1 , 0xe5693907
362- check t1 , t2
363-
364- cmov t2 , t0 , t3 , t2
365- check t2 , t3
366- .option pop
367-
368- ret
369-
370- / **
371- * Checks the `slo` and `sro` instructions
372- * /
373- smoke_alu_b_misc:
374- li t0 , 0x9bfae1bb
375- li t1 , 8
376- li t2 , 4
377- //slo t0 , t0 , t1
378- .insn r OP , 0b001 , 0b0010000 , t0 , t0 , t1
379- //sro t0 , t0 , t2
380- .insn r OP , 0b101 , 0b0010000 , t0 , t0 , t2
381-
382- li t1 , 0xffae1bbf
383- check t0 , t1
384- ret
385-
386313/**
387314 * Checks the immediate bitmanip instructions.
388- *
389- * This is a superset of RV32B's immediate instructions.
390315 */
391316smoke_alu_b_imm:
392317 li t0, 0xfcec24cf
393- //sloi t0 , t0 , 7
394- .insn i OP_IMM , 0b001 , t0 , t0 , 0x207
395318 // zbs
396319 bclri t0, t0, 3
397320 bseti t0, t0, 31
398321 binvi t0, t0, 19
399322 bexti t1, t0, 8
400- // zbt
401- .option push
402- .option arch , + zbt0p93
403- fsri t0 , t0 , t1 , 4
404- .option pop
405- //sroi t0 , t0 , 5
406- .insn i OP_IMM , 0b101 , t0 , t0 , 0x205
407323 // zbb
408324 rori t0, t0, 16
409- // zbp
410- .option push
411- .option arch , + zbp0p93
412- grevi t0 , t0 , 4
413- shfli t0 , t0 , 4
414- gorci t0 , t0 , 2
415- unshfli t0 , t0 , 4
416- .option pop
325+ li t1, 0x24c7fce4
326+ check t0, t1
417327
418- li t1 , 0xf0ffafff
328+ // zbb/zbkb immediate permutations
329+ .option push
330+ .option arch, +zbb, +zbkb
331+ li t0, 0x12345678
332+ brev8 t0, t0
333+ li t1, 0x482c6a1e
334+ check t0, t1
335+ rev8 t0, t0
336+ li t1, 0x1e6a2c48
419337 check t0, t1
338+ li t0, 0x12000034
339+ orc.b t0, t0
340+ li t1, 0xff0000ff
341+ check t0, t1
342+ .option pop
420343 ret
421344
422345/**
0 commit comments