diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-11-28 13:14:05 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-11-28 13:14:05 +0100 |
commit | bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e (patch) | |
tree | 4d092d8732e61733b96acf348003dc3af0aed485 /include | |
parent | 9f3f0b829b62f11f350867d2350e2af8639ec890 (diff) |
libiberty: Use x86 HW optimized sha1
Nick has approved this patch (+ small ld change to use it for --build-id=),
so I'm commiting it to GCC as master as well.
If anyone from ARM would be willing to implement it similarly with
vsha1{cq,mq,pq,h,su0q,su1q}_u32 intrinsics, it could be a useful linker
speedup on those hosts as well, the intent in sha1.c was that
sha1_hw_process_bytes, sha1_hw_process_block functions
would be defined whenever
defined (HAVE_X86_SHA1_HW_SUPPORT) || defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT)
but the body of sha1_hw_process_block and sha1_choose_process_bytes
would then have #elif defined (HAVE_WHATEVERELSE_SHA1_HW_SUPPORT) for
the other arch support, similarly for any target attributes on
sha1_hw_process_block if needed.
2023-11-28 Jakub Jelinek <jakub@redhat.com>
include/
* sha1.h (sha1_process_bytes_fn): New typedef.
(sha1_choose_process_bytes): Declare.
libiberty/
* configure.ac (HAVE_X86_SHA1_HW_SUPPORT): New check.
* sha1.c: If HAVE_X86_SHA1_HW_SUPPORT is defined, include x86intrin.h
and cpuid.h.
(sha1_hw_process_bytes, sha1_hw_process_block,
sha1_choose_process_bytes): New functions.
* config.in: Regenerated.
* configure: Regenerated.
Diffstat (limited to 'include')
-rw-r--r-- | include/sha1.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/sha1.h b/include/sha1.h index eb86fbb250a..6c94a4740a5 100644 --- a/include/sha1.h +++ b/include/sha1.h @@ -108,6 +108,13 @@ extern void sha1_process_block (const void *buffer, size_t len, extern void sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx); +typedef void (*sha1_process_bytes_fn) (const void *, size_t, + struct sha1_ctx *); + +/* Return sha1_process_bytes or some hardware optimized version thereof + depending on current CPU. */ +extern sha1_process_bytes_fn sha1_choose_process_bytes (void); + /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted |