AESNI perlasm update.
authorAndy Polyakov <appro@openssl.org>
Sun, 26 Apr 2009 17:58:58 +0000 (17:58 +0000)
committerAndy Polyakov <appro@openssl.org>
Sun, 26 Apr 2009 17:58:58 +0000 (17:58 +0000)
crypto/perlasm/x86_64-xlate.pl
crypto/perlasm/x86asm.pl
crypto/perlasm/x86masm.pl

index 131109d..6776bf3 100755 (executable)
@@ -662,6 +662,7 @@ while($line=<>) {
                $insn = $opcode->out($#args>=1?$args[$#args]->size():$sz);
            } else {
                $insn = $opcode->out();
                $insn = $opcode->out($#args>=1?$args[$#args]->size():$sz);
            } else {
                $insn = $opcode->out();
+               $insn .= $sz if (map($_->out() =~ /xmm|mmx/,@args));
                @args = reverse(@args);
                undef $sz if ($nasm && $opcode->mnemonic() eq "lea");
            }
                @args = reverse(@args);
                undef $sz if ($nasm && $opcode->mnemonic() eq "lea");
            }
index 28080ca..34244c1 100644 (file)
@@ -80,6 +80,23 @@ sub ::movq
     {  &::generic("movq",@_);                  }
 }
 
     {  &::generic("movq",@_);                  }
 }
 
+# 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,@_); }
+
 # label management
 $lbdecor="L";          # local label decoration, set by package
 $label="000";
 # label management
 $lbdecor="L";          # local label decoration, set by package
 $label="000";
index 3365114..2e2b315 100644 (file)
@@ -16,9 +16,11 @@ sub ::generic
     # fix hexadecimal constants
     for (@arg) { s/0x([0-9a-f]+)/0$1h/oi; }
 
     # fix hexadecimal constants
     for (@arg) { s/0x([0-9a-f]+)/0$1h/oi; }
 
-    # fix xmm references
-    $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i);
-    $arg[1] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[0]=~/\bxmm[0-7]\b/i);
+    if ($opcode !~ /movq/)
+    {  # fix xmm references
+       $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i);
+       $arg[1] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[0]=~/\bxmm[0-7]\b/i);
+    }
 
     &::emit($opcode,@arg);
   1;
 
     &::emit($opcode,@arg);
   1;