On 9/13/24 5:05 AM, Mariam Arutunian wrote:
If the target is ZBC or ZBKC, it uses clmul instruction for the CRC
calculation. Otherwise, if the target is ZBKB, generates
table-based
CRC, but for reversing inputs and the output uses bswap and brev8
instructions. Add new tests to check CRC generation for ZBC,
ZBKC and
ZBKB targets.
gcc/
* expr.cc (gf2n_poly_long_div_quotient): New function.
* expr.h (gf2n_poly_long_div_quotient): New function declaration.
* hwint.cc (reflect_hwi): New function.
* hwint.h (reflect_hwi): New function declaration.
gcc/config/riscv/
* bitmanip.md (crc_rev<ANYI1:mode><ANYI:mode>4): New expander for
reversed CRC.
(crc<SUBX1:mode><SUBX:mode>4): New expander for bit-forward CRC.
* iterators.md (SUBX1, ANYI1): New iterators.
* riscv-protos.h (generate_reflecting_code_using_brev): New
function declaration.
(expand_crc_using_clmul): Likewise.
(expand_reversed_crc_using_clmul): Likewise.
* riscv.cc (generate_reflecting_code_using_brev): New function.
(expand_crc_using_clmul): Likewise.
(expand_reversed_crc_using_clmul): Likewise.
* riscv.md (UNSPEC_CRC, UNSPEC_CRC_REV): New unspecs.
gcc/testsuite/gcc.target/riscv/
* crc-1-zbc.c: New test.
* crc-1-zbkc.c: Likewise.
* crc-10-zbc.c: Likewise.
* crc-10-zbkc.c: Likewise.
* crc-12-zbc.c: Likewise.
* crc-12-zbkc.c: Likewise.
* crc-13-zbc.c: Likewise.
* crc-13-zbkc.c: Likewise.
* crc-14-zbc.c: Likewise.
* crc-14-zbkc.c: Likewise.
* crc-17-zbc.c: Likewise.
* crc-17-zbkc.c: Likewise.
* crc-18-zbc.c: Likewise.
* crc-18-zbkc.c: Likewise.
* crc-21-zbc.c: Likewise.
* crc-21-zbkc.c: Likewise.
* crc-22-rv64-zbc.c: Likewise.
* crc-22-rv64-zbkb.c: Likewise.
* crc-22-rv64-zbkc.c: Likewise.
* crc-23-zbc.c: Likewise.
* crc-23-zbkc.c: Likewise.
* crc-4-zbc.c: Likewise.
* crc-4-zbkb.c: Likewise.
* crc-4-zbkc.c: Likewise.
* crc-5-zbc.c: Likewise.
* crc-5-zbkb.c: Likewise.
* crc-5-zbkc.c: Likewise.
* crc-6-zbc.c: Likewise.
* crc-6-zbkc.c: Likewise.
* crc-7-zbc.c: Likewise.
* crc-7-zbkc.c: Likewise.
* crc-8-zbc.c: Likewise.
* crc-8-zbkb.c: Likewise.
* crc-8-zbkc.c: Likewise.
* crc-9-zbc.c: Likewise.
* crc-9-zbkc.c: Likewise.
* crc-CCIT-data16-zbc.c: Likewise.
* crc-CCIT-data16-zbkc.c: Likewise.
* crc-CCIT-data8-zbc.c: Likewise.
* crc-CCIT-data8-zbkc.c: Likewise.
* crc-coremark-16bitdata-zbc.c: Likewise.
* crc-coremark-16bitdata-zbkc.c: Likewise.
Minor nit. Looks like you added a spurious blank line in hwint.h.
You used camelcase for the "reflectedValue" in hwint.cc. Just use
"reflectedvalue".
With those fixed this is OK.
jeff