First and foremost, sorry about how big this PR is. Most of the changes are in generated files though. I'm open to any alterations you might have in mind. I want to make these changes in preparation for CPU runtime detection; if not in this repository, then to minimize the differences with a fork that does.
The biggest part of this PR adds a prefix (${pre}) to the beginning of labels for internal routines for assembly files that have multiple implementations. This allows us to include both portable & non-portable implementations. Then select the right implementation based on the defines.
As an overview, this will:
Add prefixes to internal functions in these files:
ct*_inverse_mod_384-x86_64.pl
mul*_mont_256-x86_64.pl
mul*_mont_384-x86_64.pl
Remove #if defined(...) checks in assembly.S.
So both implementations will be available.
Remove sha256_emit, sha256_bcopy, sha256_hcopy from non-portable implementation.
These routines are the exact same in sha256-x86_64.pl and sha256-portable-x86_64.pl.
Rename K256 table in portable implementation, it conflicted with the other one.
Rename sha256_block_data_order in the portable file to sha256_block_data_order_portable.
This conflicted with the label in the other assembly file.
Include mach-o/sha256-portable-x86_64.s for apple/x86_64.
Guess this wasn't necessary before?
Build/include sha256-portable-x86_64.s for win64.
Guess this wasn't necessary before either?
Alter sha256_block "selector" preprocessor code.
Needed to differentiate between portable/non-portable for x86.
Thought this was a little more clear.
Other considerations:
The size of the built library (libblst.a) has increased from 243K to 268K, or ~10% bigger.
I'm actually surprised it's not more of a difference, shows how small the assembly is.
Also, for most of the replacements I did this in vim, for each of those perlasm files:
First and foremost, sorry about how big this PR is. Most of the changes are in generated files though. I'm open to any alterations you might have in mind. I want to make these changes in preparation for CPU runtime detection; if not in this repository, then to minimize the differences with a fork that does.
The biggest part of this PR adds a prefix (
${pre}
) to the beginning of labels for internal routines for assembly files that have multiple implementations. This allows us to include both portable & non-portable implementations. Then select the right implementation based on the defines.As an overview, this will:
ct*_inverse_mod_384-x86_64.pl
mul*_mont_256-x86_64.pl
mul*_mont_384-x86_64.pl
#if defined(...)
checks inassembly.S
.sha256_emit
,sha256_bcopy
,sha256_hcopy
from non-portable implementation.sha256-x86_64.pl
andsha256-portable-x86_64.pl
.K256
table in portable implementation, it conflicted with the other one.sha256_block_data_order
in the portable file tosha256_block_data_order_portable
.mach-o/sha256-portable-x86_64.s
for apple/x86_64.sha256-portable-x86_64.s
for win64.Other considerations:
libblst.a
) has increased from 243K to 268K, or ~10% bigger.Also, for most of the replacements I did this in vim, for each of those perlasm files: