On Mon, Sep 21, 2026 at 03:07:41PM +0530, Avinash Jayakar wrote:
> Hi,
> 
> I have incorporated the changes mentioned in the review of v1 and v2
> https://gcc.gnu.org/pipermail/gcc-patches/2026-September/730358.html
> https://gcc.gnu.org/pipermail/gcc-patches/2026-September/731788.html
> 
> Changes from v2:
> - Commit message reworded.
> - Removed extra lines in rs6000-builtin.cc
> - Group builtin function (base and extended mnemonic) in documentation.
> - Update the comment in test cases for justifying load instructions.
> Changes from v1:
> - Add documentation relevant to this patch.
> - Expand the macros used in test sha-builtins-2.c
> - Move the parameter check in rs6000_expand_builtin after constant check
> is done.
> - Correct formatting in crypto.md and remove the & contraint.
> 
> Bootstrapped and regtested on ppc64le. Ok for trunk?
> 
> Thanks,
> Avinash Jayakar
> 
> This patch adds new builtins for SHA2 and SHAPAD instructions which may
> or may not be supported in a future processor.
> 
> Following are the new builtins added to support sha2 and shapad:
> void __builtin_dmsha2hash (__dmr1024*, __dmr1024*, uint1);
> void __builtin_dmxxshapad (__dmr1024*, vec_t, uint2, uint1, uint2);
> 
> Following are the builtins to support the extended mnemonics:
> void __builtin_dmsha256hash (__dmr1024*, __dmr1024*);
> void __builtin_dmsha512hash (__dmr1024*, __dmr1024*);
> void __builtin_dmxxsha3512pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxsha3384pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxsha3256pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxsha3224pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxshake256pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxshake128pad (__dmr1024*, vec_t, uint1);
> void __builtin_dmxxsha384512pad (__dmr1024*, vec_t);
> void __builtin_dmxxsha224256pad (__dmr1024*, vec_t);
> 
> The parameter check in dmxxshapad is done such that if argument 3
> corresponding to ID is 1 and argument 5 corresponding to BL is 0 or 1
> the compiler throws an error. And the test 3 validates this. Although
> the assembler captures this error, it would be better for the compiler
> as well to throw this error as it will be caught earlier with better
> error information.
> 
> 2026-09-21  Avinash Jayakar  <[email protected]>
> 
> gcc/ChangeLog:
>       * config/rs6000/crypto.md (UNSPEC_DMSHA2HASH): New unspec entry.
>       (UNSPEC_DMSHA256HASH): Likewise.
>       (UNSPEC_DMSHA512HASH): Likewise.
>       (UNSPEC_DMXXSHAPAD): Likewise.
>       (UNSPEC_DMXXSHA3512PAD): Likewise.
>       (UNSPEC_DMXXSHA3384PAD): Likewise.
>       (UNSPEC_DMXXSHA3256PAD): Likewise.
>       (UNSPEC_DMXXSHA3224PAD): Likewise.
>       (UNSPEC_DMXXSHAKE256PAD): Likewise.
>       (UNSPEC_DMXXSHAKE128PAD): Likewise.
>       (UNSPEC_DMXXSHA384512PAD): Likewise.
>       (UNSPEC_DMXXSHA224256PAD): Likewise.
>       (SHA2_code): Iterator for sha2 extended mnemonics.
>       (SHA2_insn): Attribute for sha2 extended mnemonics.
>       (SHAPAD_code): Iterator for sha3/shake padding extended mnemonics.
>       (SHAPAD_insn): Attribute for sha3/shake padding extended mnemonics.
>       (SHA2PAD_code): Iterator for sha2 padding extended mnemonics.
>       (SHA2PAD_insn): Attribute for sha2 padding extended mnemonics.
>       (dmsha2hash): New define_insn for base sha2.
>       (<SHA2_insn>): New define_insn for sha2 extended mnemonics.
>       (dmshapad): New define_insn for base shapad.
>       (<SHAPAD_insn>): New define_insn for sha3/shake padding extended
>       mnemonics.
>       (<SHA2PAD_insn>): New define_insn for sha2 padding extended mnemonics.
>       * config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Error
>       handling for shapad builtin arguments.
>       * config/rs6000/rs6000-builtins.def: Add new builtin definitions for
>       SHA2/3.
>       * doc/extend.texi: Document the added builtins.
> 
> gcc/testsuite/ChangeLog:
>       * gcc.target/powerpc/sha-builtins-1.c: New test.
>       * gcc.target/powerpc/sha-builtins-2.c: New test.
>       * gcc.target/powerpc/sha-builtins-3.c: New test.
>       * gcc.target/powerpc/sha-builtins-4.c: New test.

This is ok for the master branch.  Adding newlines like Surya suggested
can make it more readable.

-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: [email protected]

Reply via email to