]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/bn/asm/x86_64-gcc.c
mark all block comments that need format preserving so that
[thirdparty/openssl.git] / crypto / bn / asm / x86_64-gcc.c
CommitLineData
41b76195 1#include "../bn_lcl.h"
93c4ba07 2#if !(defined(__GNUC__) && __GNUC__>=2)
c8a0d0aa
AP
3# include "../bn_asm.c" /* kind of dirty hack for Sun Studio */
4#else
1d97c843 5/*-
2f98abbc
AP
6 * x86_64 BIGNUM accelerator version 0.1, December 2002.
7 *
8 * Implemented by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
9 * project.
10 *
11 * Rights for redistribution and usage in source and binary forms are
12 * granted according to the OpenSSL license. Warranty of any kind is
13 * disclaimed.
14 *
15 * Q. Version 0.1? It doesn't sound like Andy, he used to assign real
16 * versions, like 1.0...
17 * A. Well, that's because this code is basically a quick-n-dirty
18 * proof-of-concept hack. As you can see it's implemented with
19 * inline assembler, which means that you're bound to GCC and that
1809e858 20 * there might be enough room for further improvement.
2f98abbc
AP
21 *
22 * Q. Why inline assembler?
1809e858
AP
23 * A. x86_64 features own ABI which I'm not familiar with. This is
24 * why I decided to let the compiler take care of subroutine
25 * prologue/epilogue as well as register allocation. For reference.
26 * Win64 implements different ABI for AMD64, different from Linux.
2f98abbc
AP
27 *
28 * Q. How much faster does it get?
1809e858
AP
29 * A. 'apps/openssl speed rsa dsa' output with no-asm:
30 *
31 * sign verify sign/s verify/s
32 * rsa 512 bits 0.0006s 0.0001s 1683.8 18456.2
33 * rsa 1024 bits 0.0028s 0.0002s 356.0 6407.0
34 * rsa 2048 bits 0.0172s 0.0005s 58.0 1957.8
35 * rsa 4096 bits 0.1155s 0.0018s 8.7 555.6
36 * sign verify sign/s verify/s
37 * dsa 512 bits 0.0005s 0.0006s 2100.8 1768.3
38 * dsa 1024 bits 0.0014s 0.0018s 692.3 559.2
39 * dsa 2048 bits 0.0049s 0.0061s 204.7 165.0
40 *
41 * 'apps/openssl speed rsa dsa' output with this module:
42 *
43 * sign verify sign/s verify/s
44 * rsa 512 bits 0.0004s 0.0000s 2767.1 33297.9
45 * rsa 1024 bits 0.0012s 0.0001s 867.4 14674.7
46 * rsa 2048 bits 0.0061s 0.0002s 164.0 5270.0
47 * rsa 4096 bits 0.0384s 0.0006s 26.1 1650.8
48 * sign verify sign/s verify/s
49 * dsa 512 bits 0.0002s 0.0003s 4442.2 3786.3
50 * dsa 1024 bits 0.0005s 0.0007s 1835.1 1497.4
51 * dsa 2048 bits 0.0016s 0.0020s 620.4 504.6
52 *
53 * For the reference. IA-32 assembler implementation performs
54 * very much like 64-bit code compiled with no-asm on the same
55 * machine.
2f98abbc
AP
56 */
57
be0d31b1 58#if defined(_WIN64) || !defined(__LP64__)
93c4ba07
AP
59#define BN_ULONG unsigned long long
60#else
2f98abbc 61#define BN_ULONG unsigned long
93c4ba07 62#endif
2f98abbc 63
41b76195
DSH
64#undef mul
65#undef mul_add
66
1d97c843 67/*-
2f98abbc
AP
68