From e87e380a179d14284cd5d6cd65a52ace7a98de45 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 7 Mar 2016 15:49:53 +0100 Subject: [PATCH] Unified - adapt the generation of sha assembler to use GENERATE This gets rid of the BEGINRAW..ENDRAW sections in crypto/sha/build.info. This also moves the assembler generating perl scripts to take the output file name as last command line argument, where necessary. Reviewed-by: Andy Polyakov --- crypto/sha/Makefile.in | 20 +++---- crypto/sha/asm/sha1-586.pl | 5 ++ crypto/sha/asm/sha1-ia64.pl | 4 +- crypto/sha/asm/sha256-586.pl | 5 ++ crypto/sha/asm/sha512-586.pl | 5 ++ crypto/sha/asm/sha512-ia64.pl | 2 +- crypto/sha/build.info | 108 +++++++++++++--------------------- 7 files changed, 70 insertions(+), 79 deletions(-) diff --git a/crypto/sha/Makefile.in b/crypto/sha/Makefile.in index ba06085b33..e2d20aa1c0 100644 --- a/crypto/sha/Makefile.in +++ b/crypto/sha/Makefile.in @@ -40,32 +40,32 @@ lib: $(LIBOBJ) @touch lib sha1-586.s: asm/sha1-586.pl ../perlasm/x86asm.pl - $(PERL) asm/sha1-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ + $(PERL) asm/sha1-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) $@ sha256-586.s: asm/sha256-586.pl ../perlasm/x86asm.pl - $(PERL) asm/sha256-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ + $(PERL) asm/sha256-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) $@ sha512-586.s: asm/sha512-586.pl ../perlasm/x86asm.pl - $(PERL) asm/sha512-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ + $(PERL) asm/sha512-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) $@ sha1-ia64.s: asm/sha1-ia64.pl - (cd asm; $(PERL) sha1-ia64.pl ../$@ $(CFLAGS)) + (cd asm; $(PERL) sha1-ia64.pl $(CFLAGS) ../$@) sha256-ia64.s: asm/sha512-ia64.pl - (cd asm; $(PERL) sha512-ia64.pl ../$@ $(CFLAGS)) + (cd asm; $(PERL) sha512-ia64.pl $(CFLAGS) ../$@) sha512-ia64.s: asm/sha512-ia64.pl - (cd asm; $(PERL) sha512-ia64.pl ../$@ $(CFLAGS)) + (cd asm; $(PERL) sha512-ia64.pl $(CFLAGS) ../$@) sha256-armv4.S: asm/sha256-armv4.pl $(PERL) $< $(PERLASM_SCHEME) $@ sha1-alpha.s: asm/sha1-alpha.pl (preproc=$$$$.$@.S; trap "rm $$preproc" INT; \ - $(PERL) asm/sha1-alpha.pl > $$preproc && \ + $(PERL) asm/sha1-alpha.pl $$preproc && \ $(CC) -E -P $$preproc > $@ && rm $$preproc) # Solaris make has to be explicitly told -sha1-x86_64.s: asm/sha1-x86_64.pl; $(PERL) asm/sha1-x86_64.pl $(PERLASM_SCHEME) > $@ -sha1-mb-x86_64.s: asm/sha1-mb-x86_64.pl; $(PERL) asm/sha1-mb-x86_64.pl $(PERLASM_SCHEME) > $@ +sha1-x86_64.s: asm/sha1-x86_64.pl; $(PERL) asm/sha1-x86_64.pl $(PERLASM_SCHEME) $@ +sha1-mb-x86_64.s: asm/sha1-mb-x86_64.pl; $(PERL) asm/sha1-mb-x86_64.pl $(PERLASM_SCHEME) $@ sha256-x86_64.s:asm/sha512-x86_64.pl; $(PERL) asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ -sha256-mb-x86_64.s: asm/sha256-mb-x86_64.pl; $(PERL) asm/sha256-mb-x86_64.pl $(PERLASM_SCHEME) > $@ +sha256-mb-x86_64.s: asm/sha256-mb-x86_64.pl; $(PERL) asm/sha256-mb-x86_64.pl $(PERLASM_SCHEME) $@ sha512-x86_64.s:asm/sha512-x86_64.pl; $(PERL) asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ sha1-sparcv9.S: asm/sha1-sparcv9.pl; $(PERL) asm/sha1-sparcv9.pl $(PERLASM_SCHEME) $@ sha256-sparcv9.S:asm/sha512-sparcv9.pl; $(PERL) asm/sha512-sparcv9.pl $(PERLASM_SCHEME) $@ diff --git a/crypto/sha/asm/sha1-586.pl b/crypto/sha/asm/sha1-586.pl index e0b5d83b62..cd71d1ca64 100644 --- a/crypto/sha/asm/sha1-586.pl +++ b/crypto/sha/asm/sha1-586.pl @@ -113,6 +113,9 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; +$output=pop; +open STDOUT,">$output"; + &asm_init($ARGV[0],"sha1-586.pl",$ARGV[$#ARGV] eq "386"); $xmm=$ymm=0; @@ -1474,3 +1477,5 @@ sub Xtail_avx() &asciz("SHA1 block transform for x86, CRYPTOGAMS by "); &asm_finish(); + +close STDOUT; diff --git a/crypto/sha/asm/sha1-ia64.pl b/crypto/sha/asm/sha1-ia64.pl index 02d35d1614..a9d2b7c71d 100644 --- a/crypto/sha/asm/sha1-ia64.pl +++ b/crypto/sha/asm/sha1-ia64.pl @@ -14,6 +14,8 @@ # Performance under big-endian OS such as HP-UX is 179MBps*1GHz, which # is >50% better than HP C and >2x better than gcc. +$output = pop; + $code=<<___; .ident \"sha1-ia64.s, version 1.3\" .ident \"IA-64 ISA artwork by Andy Polyakov \" @@ -301,5 +303,5 @@ $code.=<<___; stringz "SHA1 block transform for IA64, CRYPTOGAMS by " ___ -$output=shift and open STDOUT,">$output"; +open STDOUT,">$output" if $output; print $code; diff --git a/crypto/sha/asm/sha256-586.pl b/crypto/sha/asm/sha256-586.pl index e907714381..55d833a8bb 100644 --- a/crypto/sha/asm/sha256-586.pl +++ b/crypto/sha/asm/sha256-586.pl @@ -63,6 +63,9 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; +$output=pop; +open STDOUT,">$output"; + &asm_init($ARGV[0],"sha512-586.pl",$ARGV[$#ARGV] eq "386"); $xmm=$avx=0; @@ -1279,3 +1282,5 @@ sub bodyx_00_15 () { # +10% &function_end_B("sha256_block_data_order"); &asm_finish(); + +close STDOUT; diff --git a/crypto/sha/asm/sha512-586.pl b/crypto/sha/asm/sha512-586.pl index 2f6a202c37..d0f9101092 100644 --- a/crypto/sha/asm/sha512-586.pl +++ b/crypto/sha/asm/sha512-586.pl @@ -50,6 +50,9 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; +$output=pop; +open STDOUT,">$output"; + &asm_init($ARGV[0],"sha512-586.pl",$ARGV[$#ARGV] eq "386"); $sse2=0; @@ -909,3 +912,5 @@ sub BODY_00_15_ssse3 { # "phase-less" copy of BODY_00_15_sse2 &asciz("SHA512 block transform for x86, CRYPTOGAMS by "); &asm_finish(); + +close STDOUT; diff --git a/crypto/sha/asm/sha512-ia64.pl b/crypto/sha/asm/sha512-ia64.pl index 59f889a095..4f472d12b8 100755 --- a/crypto/sha/asm/sha512-ia64.pl +++ b/crypto/sha/asm/sha512-ia64.pl @@ -68,7 +68,7 @@ # To generate code, pass the file name with either 256 or 512 in its # name and compiler flags. -$output=shift; +$output=pop; if ($output =~ /512.*\.[s|asm]/) { $SZ=8; diff --git a/crypto/sha/build.info b/crypto/sha/build.info index 2543414774..9f095a8c02 100644 --- a/crypto/sha/build.info +++ b/crypto/sha/build.info @@ -2,74 +2,48 @@ LIBS=../../libcrypto SOURCE[../../libcrypto]=\ sha1dgst.c sha1_one.c sha256.c sha512.c {- $target{sha1_asm_src} -} -BEGINRAW[Makefile] +GENERATE[sha1-586.s]=asm/sha1-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) +DEPEND[sha1-586.s]=../perlasm/x86asm.pl +GENERATE[sha256-586.s]=asm/sha256-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) +DEPEND[sha256-586.s]=../perlasm/x86asm.pl +GENERATE[sha512-586.s]=asm/sha512-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) +DEPEND[sha512-586.s]=../perlasm/x86asm.pl + +GENERATE[sha1-ia64.s]=sha1-ia64.pl $(CFLAGS) +GENERATE[sha256-ia64.s]=sha512-ia64.pl $(CFLAGS) +GENERATE[sha512-ia64.s]=sha512-ia64.pl $(CFLAGS) + +GENERATE[sha256-armv4.S]=asm/sha256-armv4.pl $(PERLASM_SCHEME) + +GENERATE[sha1-alpha.s]=asm/sha1-alpha.pl + +GENERATE[sha1-x86_64.s]=asm/sha1-x86_64.pl $(PERLASM_SCHEME) +GENERATE[sha1-mb-x86_64.s]=asm/sha1-mb-x86_64.pl $(PERLASM_SCHEME) +GENERATE[sha256-x86_64.s]=asm/sha512-x86_64.pl $(PERLASM_SCHEME) +GENERATE[sha256-mb-x86_64.s]=asm/sha256-mb-x86_64.pl $(PERLASM_SCHEME) +GENERATE[sha512-x86_64.s]=asm/sha512-x86_64.pl $(PERLASM_SCHEME) + +GENERATE[sha1-sparcv9.S]=asm/sha1-sparcv9.pl $(PERLASM_SCHEME) +GENERATE[sha256-sparcv9.S]=asm/sha512-sparcv9.pl $(PERLASM_SCHEME) +GENERATE[sha512-sparcv9.S]=asm/sha512-sparcv9.pl $(PERLASM_SCHEME) + +GENERATE[sha1-ppc.s]=asm/sha1-ppc.pl $(PERLASM_SCHEME) +GENERATE[sha256-ppc.s]=asm/sha512-ppc.pl $(PERLASM_SCHEME) +GENERATE[sha512-ppc.s]=asm/sha512-ppc.pl $(PERLASM_SCHEME) +GENERATE[sha256p8-ppc.s]=asm/sha512p8-ppc.pl $(PERLASM_SCHEME) +GENERATE[sha512p8-ppc.s]=asm/sha512p8-ppc.pl $(PERLASM_SCHEME) + +GENERATE[sha1-parisc.s]=asm/sha1-parisc.pl $(PERLASM_SCHEME) +GENERATE[sha256-parisc.s]=asm/sha512-parisc.pl $(PERLASM_SCHEME) +GENERATE[sha512-parisc.s]=asm/sha512-parisc.pl $(PERLASM_SCHEME) + +GENERATE[sha1-mips.S]=asm/sha1-mips.pl $(PERLASM_SCHEME) +GENERATE[sha256-mips.S]=asm/sha512-mips.pl $(PERLASM_SCHEME) +GENERATE[sha512-mips.S]=asm/sha512-mips.pl $(PERLASM_SCHEME) + +BEGINRAW[Makefile(unix)] ##### SHA assembler implementations -{- $builddir -}/sha1-586.s: {- $sourcedir -}/asm/sha1-586.pl {- $sourcetop -}/crypto/perlasm/x86asm.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ -{- $builddir -}/sha256-586.s: {- $sourcedir -}/asm/sha256-586.pl {- $sourcetop -}/crypto/perlasm/x86asm.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha256-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ -{- $builddir -}/sha512-586.s: {- $sourcedir -}/asm/sha512-586.pl {- $sourcetop -}/crypto/perlasm/x86asm.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@ - -{- $builddir -}/sha1-ia64.s: {- $sourcedir -}/asm/sha1-ia64.pl - (cd asm; CC="$(CC)" $(PERL) sha1-ia64.pl ../$@ $(CFLAGS)) -{- $builddir -}/sha256-ia64.s: {- $sourcedir -}/asm/sha512-ia64.pl - (cd asm; CC="$(CC)" $(PERL) sha512-ia64.pl ../$@ $(CFLAGS)) -{- $builddir -}/sha512-ia64.s: {- $sourcedir -}/asm/sha512-ia64.pl - (cd asm; CC="$(CC)" $(PERL) sha512-ia64.pl ../$@ $(CFLAGS)) - -{- $builddir -}/sha256-armv4.S: {- $sourcedir -}/asm/sha256-armv4.pl - CC="$(CC)" $(PERL) $< $(PERLASM_SCHEME) $@ - -{- $builddir -}/sha1-alpha.s: {- $sourcedir -}/asm/sha1-alpha.pl - (preproc=$$$$.$@.S; trap "rm $$preproc" INT; \ - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-alpha.pl > $$preproc && \ - $(CC) -E -P $$preproc > $@ && rm $$preproc) - -# Solaris make has to be explicitly told -{- $builddir -}/sha1-x86_64.s: {- $sourcedir -}/asm/sha1-x86_64.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-x86_64.pl $(PERLASM_SCHEME) > $@ -{- $builddir -}/sha1-mb-x86_64.s: {- $sourcedir -}/asm/sha1-mb-x86_64.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-mb-x86_64.pl $(PERLASM_SCHEME) > $@ -{- $builddir -}/sha256-x86_64.s:{- $sourcedir -}/asm/sha512-x86_64.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256-mb-x86_64.s: {- $sourcedir -}/asm/sha256-mb-x86_64.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha256-mb-x86_64.pl $(PERLASM_SCHEME) > $@ -{- $builddir -}/sha512-x86_64.s:{- $sourcedir -}/asm/sha512-x86_64.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha1-sparcv9.S: {- $sourcedir -}/asm/sha1-sparcv9.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-sparcv9.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256-sparcv9.S:{- $sourcedir -}/asm/sha512-sparcv9.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-sparcv9.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha512-sparcv9.S:{- $sourcedir -}/asm/sha512-sparcv9.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-sparcv9.pl $(PERLASM_SCHEME) $@ - -{- $builddir -}/sha1-ppc.s: {- $sourcedir -}/asm/sha1-ppc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-ppc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256-ppc.s: {- $sourcedir -}/asm/sha512-ppc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-ppc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha512-ppc.s: {- $sourcedir -}/asm/sha512-ppc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-ppc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256p8-ppc.s: {- $sourcedir -}/asm/sha512p8-ppc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512p8-ppc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha512p8-ppc.s: {- $sourcedir -}/asm/sha512p8-ppc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512p8-ppc.pl $(PERLASM_SCHEME) $@ - -{- $builddir -}/sha1-parisc.s: {- $sourcedir -}/asm/sha1-parisc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-parisc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256-parisc.s:{- $sourcedir -}/asm/sha512-parisc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-parisc.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha512-parisc.s:{- $sourcedir -}/asm/sha512-parisc.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-parisc.pl $(PERLASM_SCHEME) $@ - -{- $builddir -}/sha1-mips.S: {- $sourcedir -}/asm/sha1-mips.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha1-mips.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha256-mips.S: {- $sourcedir -}/asm/sha512-mips.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-mips.pl $(PERLASM_SCHEME) $@ -{- $builddir -}/sha512-mips.S: {- $sourcedir -}/asm/sha512-mips.pl - CC="$(CC)" $(PERL) {- $sourcedir -}/asm/sha512-mips.pl $(PERLASM_SCHEME) $@ - # GNU make "catch all" {- $builddir -}/sha1-%.S: {- $sourcedir -}/asm/sha1-%.pl CC="$(CC)" $(PERL) $< $(PERLASM_SCHEME) $@ @@ -77,4 +51,4 @@ BEGINRAW[Makefile] CC="$(CC)" $(PERL) $< $(PERLASM_SCHEME) $@ {- $builddir -}/sha512-%.S: {- $sourcedir -}/asm/sha512-%.pl CC="$(CC)" $(PERL) $< $(PERLASM_SCHEME) $@ -ENDRAW[Makefile] +ENDRAW[Makefile(unix)] -- 2.40.0