]> granicus.if.org Git - openssl/commitdiff
perlasm/x86asm.pl: move aesni and pclmulqdq opcodes to aesni-x86.pl and
authorAndy Polyakov <appro@openssl.org>
Mon, 26 Jul 2010 21:42:07 +0000 (21:42 +0000)
committerAndy Polyakov <appro@openssl.org>
Mon, 26 Jul 2010 21:42:07 +0000 (21:42 +0000)
ghash-x86.pl.

crypto/aes/asm/aesni-x86.pl
crypto/modes/asm/ghash-x86.pl
crypto/perlasm/x86asm.pl

index 26888549c02a67213ad6fbe53718d57951c9910a..1a1bf539cd45cfc1ee8a278d78c94506eed161c5 100644 (file)
@@ -59,6 +59,23 @@ $rndkey1="xmm4";
 $ivec="xmm5";
 $in0="xmm6";
 $in1="xmm7";   $inout3="xmm7";
+
+# AESNI extenstion
+sub aeskeygenassist
+{ my($dst,$src,$imm)=@_;
+    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
+    {  &data_byte(0x66,0x0f,0x3a,0xdf,0xc0|($1<<3)|$2,$imm);   }
+}
+sub aescommon
+{ my($opcodelet,$dst,$src)=@_;
+    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
+    {  &data_byte(0x66,0x0f,0x38,$opcodelet,0xc0|($1<<3)|$2);}
+}
+sub aesimc     { aescommon(0xdb,@_); }
+sub aesenc     { aescommon(0xdc,@_); }
+sub aesenclast { aescommon(0xdd,@_); }
+sub aesdec     { aescommon(0xde,@_); }
+sub aesdeclast { aescommon(0xdf,@_); }
 \f
 # Inline version of internal aesni_[en|de]crypt1
 { my $sn;
@@ -66,7 +83,7 @@ sub aesni_inline_generate1
 { my ($p,$inout)=@_; $inout=$inout0 if (!defined($inout));
   $sn++;
 
-    &$movekey          ($rndkey0,&QWP(0,$key));
+    &movdqu            ($rndkey0,&QWP(0,$key));
     &$movekey          ($rndkey1,&QWP(16,$key));
     &lea               ($key,&DWP(32,$key));
     &pxor              ($inout,$rndkey0);
@@ -83,7 +100,7 @@ sub aesni_generate1  # fully unrolled loop
 { my ($p,$inout)=@_; $inout=$inout0 if (!defined($inout));
 
     &function_begin_B("_aesni_${p}rypt1");
-       &$movekey       ($rndkey0,&QWP(0,$key));
+       &movdqu         ($rndkey0,&QWP(0,$key));
        &$movekey       ($rndkey1,&QWP(0x10,$key));
        &pxor           ($inout,$rndkey0);
        &$movekey       ($rndkey0,&QWP(0x20,$key));
@@ -130,7 +147,7 @@ sub aesni_generate1 # fully unrolled loop
 &function_begin_B("${PREFIX}_encrypt");
        &mov    ("eax",&wparam(0));
        &mov    ($key,&wparam(2));
-       &movups ($inout0,&QWP(0,"eax"));
+       &movdqu ($inout0,&QWP(0,"eax"));
        &mov    ($rounds,&DWP(240,$key));
        &mov    ("eax",&wparam(1));
        if ($inline)
@@ -146,7 +163,7 @@ sub aesni_generate1 # fully unrolled loop
 &function_begin_B("${PREFIX}_decrypt");
        &mov    ("eax",&wparam(0));
        &mov    ($key,&wparam(2));
-       &movups ($inout0,&QWP(0,"eax"));
+       &movdqu ($inout0,&QWP(0,"eax"));
        &mov    ($rounds,&DWP(240,$key));
        &mov    ("eax",&wparam(1));
        if ($inline)
index 2805bad0ba93a21d9f672235baae91949c8d7bf8..a768a056f36a49d07fdd42eac12bd25378717c25 100644 (file)
@@ -812,6 +812,12 @@ $len="ebx";
 
 &static_label("bswap");
 
+sub pclmulqdq
+{ my($dst,$src,$imm)=@_;
+    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
+    {  &data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm);   }
+}
+
 sub clmul64x64_T2 {    # minimal "register" pressure
 my ($Xhi,$Xi,$Hkey)=@_;
 
index d39bc28b227d4b6d3999be0df3ed03095b8d9714..e0b228eb5572f0be9af3e6d2ec8f5789d87bd774 100644 (file)
@@ -107,31 +107,6 @@ sub ::pshufb
     {  &::generic("pshufb",@_);                }
 }
 
-# AESNI extenstion
-sub ::aeskeygenassist
-{ my($dst,$src,$imm)=@_;
-    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
-    {  &::data_byte(0x66,0x0f,0x3a,0xdf,0xc0|($1<<3)|$2,$imm); }
-}
-sub ::aescommon
-{ my($opcodelet,$dst,$src)=@_;
-    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
-    {  &::data_byte(0x66,0x0f,0x38,$opcodelet,0xc0|($1<<3)|$2);}
-}
-sub ::aesimc           { ::aescommon(0xdb,@_); }
-sub ::aesenc           { ::aescommon(0xdc,@_); }
-sub ::aesenclast       { ::aescommon(0xdd,@_); }
-sub ::aesdec           { ::aescommon(0xde,@_); }
-sub ::aesdeclast       { ::aescommon(0xdf,@_); }
-
-sub ::pclmulqdq
-{ my($dst,$src,$imm)=@_;
-    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
-    {  &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); }
-    else
-    {  &::generic("pclmulqdq",@_);             }
-}
-
 # label management
 $lbdecor="L";          # local label decoration, set by package
 $label="000";