]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH v6 01/12] Implement internal functions for efficient CRC computation.
authorMariam Arutunian <mariamarutunian@gmail.com>
Mon, 11 Nov 2024 19:48:34 +0000 (12:48 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Thu, 28 Nov 2024 14:34:01 +0000 (07:34 -0700)
commitbb46d05ad64e4e0acb3307e76bab340aa8587d3e
tree3f2bbf5efd898212a2dfc0fdd2a1ed4d7a0c9f71
parentbcb764ec7c063326a17eb6213313cc9c0fd348b3
[PATCH v6 01/12] Implement internal functions for efficient CRC computation.

Add two new internal functions (IFN_CRC, IFN_CRC_REV), to provide faster
CRC generation.
One performs bit-forward and the other bit-reversed CRC computation.
If CRC optabs are supported, they are used for the CRC computation.
Otherwise, table-based CRC is generated.
The supported data and CRC sizes are 8, 16, 32, and 64 bits.
The polynomial is without the leading 1.
A table with 256 elements is used to store precomputed CRCs.
For the reflection of inputs and the output, a simple algorithm involving
SHIFT, AND, and OR operations is used.

gcc/

* doc/md.texi (crc@var{m}@var{n}4, crc_rev@var{m}@var{n}4): Document.
* expr.cc (calculate_crc): New function.
(assemble_crc_table): Likewise.
(generate_crc_table): Likewise.
(calculate_table_based_CRC): Likewise.
(expand_crc_table_based): Likewise.
(gen_common_operation_to_reflect): Likewise.
(reflect_64_bit_value): Likewise.
(reflect_32_bit_value): Likewise.
(reflect_16_bit_value): Likewise.
(reflect_8_bit_value): Likewise.
(generate_reflecting_code_standard): Likewise.
(expand_reversed_crc_table_based): Likewise.
* expr.h (generate_reflecting_code_standard): New function declaration.
(expand_crc_table_based): Likewise.
(expand_reversed_crc_table_based): Likewise.
* internal-fn.cc: (crc_direct): Define.
(direct_crc_optab_supported_p): Likewise.
(expand_crc_optab_fn): New function
* internal-fn.def (CRC, CRC_REV): New internal functions.
* optabs.def (crc_optab, crc_rev_optab): New optabs.

Signed-off-by: Mariam Arutunian <mariamarutunian@gmail.com>
Co-authored-by: Joern Rennecke <joern.rennecke@embecosm.com>
Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
gcc/doc/md.texi
gcc/expr.cc
gcc/expr.h
gcc/internal-fn.cc
gcc/internal-fn.def
gcc/optabs.def