public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Mariam Arutunian <mariamarutunian@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC/RFA] [PATCH 02/12] Add built-ins and tests for bit-forward and bit-reversed CRCs
Date: Mon, 27 May 2024 08:38:24 +0200	[thread overview]
Message-ID: <CAFiYyc1wkbC6txo2T_t_e3C0hApNzKKjF1ooDmJU6Ncxq2Lm1A@mail.gmail.com> (raw)
In-Reply-To: <CAE65F3PzOKXiuBGC0WxvBssjVNJCJUN23E6a6Kh6iiLWgek96w@mail.gmail.com>

On Fri, May 24, 2024 at 10:44 AM Mariam Arutunian
<mariamarutunian@gmail.com> wrote:
>
> This patch introduces new built-in functions to GCC for computing bit-forward and bit-reversed CRCs.
> These builtins aim to provide efficient CRC calculation capabilities.
> When the target architecture supports CRC operations (as indicated by the presence of a CRC optab),
> the builtins will utilize the expander to generate CRC code.
> In the absence of hardware support, the builtins default to generating code for a table-based CRC calculation.

I wonder whether for embedded target use we should arrange for the
table-based CRC calculation
to be out-of-line and implemented in a way so uses across TUs can be
merged?  I guess a generic implementation
inside libgcc is difficult?

>
> The builtins are defined as follows:
> __builtin_rev_crc16_data8,
> __builtin_rev_crc32_data8, __builtin_rev_crc32_data16, __builtin_rev_crc32_data32
> __builtin_crc8_data8,
> __builtin_crc16_data16, __builtin_crc16_data8,
> __builtin_crc32_data8, __builtin_crc32_data16, __builtin_crc32_data32,
> __builtin_crc64_data8, __builtin_crc64_data16,  __builtin_crc64_data32, __builtin_crc64_data64
>
> Each builtin takes three parameters:
> crc: The initial CRC value.
> data: The data to be processed.
> polynomial: The CRC polynomial without the leading 1.
>
> To validate the correctness of these builtins, this patch also includes additions to the GCC testsuite.
> This enhancement allows GCC to offer developers high-performance CRC computation options
> that automatically adapt to the capabilities of the target hardware.
>
> Co-authored-by: Joern Rennecke <joern.rennecke@embecosm.com>
>
> Not complete. May continue the work if these built-ins are needed.
>
> gcc/
>
>  * builtin-types.def (BT_FN_UINT8_UINT8_UINT8_CONST_SIZE): Define.
>  (BT_FN_UINT16_UINT16_UINT8_CONST_SIZE): Likewise.
>           (BT_FN_UINT16_UINT16_UINT16_CONST_SIZE): Likewise.
>           (BT_FN_UINT32_UINT32_UINT8_CONST_SIZE): Likewise.
>           (BT_FN_UINT32_UINT32_UINT16_CONST_SIZE): Likewise.
>           (BT_FN_UINT32_UINT32_UINT32_CONST_SIZE): Likewise.
>           (BT_FN_UINT64_UINT64_UINT8_CONST_SIZE): Likewise.
>           (BT_FN_UINT64_UINT64_UINT16_CONST_SIZE): Likewise.
>           (BT_FN_UINT64_UINT64_UINT32_CONST_SIZE): Likewise.
>           (BT_FN_UINT64_UINT64_UINT64_CONST_SIZE): Likewise.
>           * builtins.cc (associated_internal_fn): Handle BUILT_IN_CRC8_DATA8,
>           BUILT_IN_CRC16_DATA8, BUILT_IN_CRC16_DATA16,
>           BUILT_IN_CRC32_DATA8, BUILT_IN_CRC32_DATA16, BUILT_IN_CRC32_DATA32,
>           BUILT_IN_CRC64_DATA8, BUILT_IN_CRC64_DATA16, BUILT_IN_CRC64_DATA32,
>           BUILT_IN_CRC64_DATA64,
>           BUILT_IN_REV_CRC8_DATA8,
>           BUILT_IN_REV_CRC16_DATA8, BUILT_IN_REV_CRC16_DATA16,
>           BUILT_IN_REV_CRC32_DATA8, BUILT_IN_REV_CRC32_DATA16, BUILT_IN_REV_CRC32_DATA32.
>           (expand_builtin_crc_table_based): New function.
>           (expand_builtin): Handle BUILT_IN_CRC8_DATA8,
>           BUILT_IN_CRC16_DATA8, BUILT_IN_CRC16_DATA16,
>           BUILT_IN_CRC32_DATA8, BUILT_IN_CRC32_DATA16, BUILT_IN_CRC32_DATA32,
>           BUILT_IN_CRC64_DATA8, BUILT_IN_CRC64_DATA16, BUILT_IN_CRC64_DATA32,
>           BUILT_IN_CRC64_DATA64,
>           BUILT_IN_REV_CRC8_DATA8,
>           BUILT_IN_REV_CRC16_DATA8, BUILT_IN_REV_CRC16_DATA16,
>           BUILT_IN_REV_CRC32_DATA8, BUILT_IN_REV_CRC32_DATA16, BUILT_IN_REV_CRC32_DATA32.
>           * builtins.def (BUILT_IN_CRC8_DATA8): New builtin.
>           (BUILT_IN_CRC16_DATA8): Likewise.
>           (BUILT_IN_CRC16_DATA16): Likewise.
>           (BUILT_IN_CRC32_DATA8): Likewise.
>           (BUILT_IN_CRC32_DATA16): Likewise.
>           (BUILT_IN_CRC32_DATA32): Likewise.
>           (BUILT_IN_CRC64_DATA8): Likewise.
>           (BUILT_IN_CRC64_DATA16): Likewise.
>           (BUILT_IN_CRC64_DATA32): Likewise.
>           (BUILT_IN_CRC64_DATA64): Likewise.
>           (BUILT_IN_REV_CRC8_DATA8): New builtin.
>           (BUILT_IN_REV_CRC16_DATA8): Likewise.
>           (BUILT_IN_REV_CRC16_DATA16): Likewise.
>           (BUILT_IN_REV_CRC32_DATA8): Likewise.
>           (BUILT_IN_REV_CRC32_DATA16): Likewise.
>           (BUILT_IN_REV_CRC32_DATA32): Likewise.
>           * builtins.h (expand_builtin_crc_table_based): New function declaration.
>           * doc/extend.texti (__builtin_rev_crc16_data8,
>           (__builtin_rev_crc32_data32, __builtin_rev_crc32_data8,
>           __builtin_rev_crc32_data16, __builtin_crc8_data8,
>           __builtin_crc16_data16, __builtin_crc16_data8,
>           __builtin_crc32_data32, __builtin_crc32_data8,
>           __builtin_crc32_data16, __builtin_crc64_data64,
>           __builtin_crc64_data8, __builtin_crc64_data16,
>           __builtin_crc64_data32): Document.
>
>       gcc/testsuite/
>
>          * gcc.c-torture/compile/crc-builtin-rev-target32.c
>          * gcc.c-torture/compile/crc-builtin-rev-target64.c
>          * gcc.c-torture/compile/crc-builtin-target32.c
>          * gcc.c-torture/compile/crc-builtin-target64.c
>
> Signed-off-by: Mariam Arutunian <mariamarutunian@gmail.com>

  parent reply	other threads:[~2024-05-27  6:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24  8:41 Mariam Arutunian
2024-05-25 18:16 ` Jeff Law
2024-05-27  6:38 ` Richard Biener [this message]
2024-05-27 15:16   ` Jeff Law
2024-05-28  6:44     ` Richard Biener
2024-06-01  4:53       ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc1wkbC6txo2T_t_e3C0hApNzKKjF1ooDmJU6Ncxq2Lm1A@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mariamarutunian@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).