Remove SSLeay history, etc., from docs
[openssl.git] / crypto / perlasm / x86_64-xlate.pl
index bd165b152b833a157221af4df1e47554f80e4cec..aae8288386d3189ec8aa7482565f4e985b2a5634 100755 (executable)
@@ -121,7 +121,7 @@ my %globals;
                $self->{sz} = "";
            } elsif ($self->{op} =~ /^v/) { # VEX
                $self->{sz} = "";
-           } elsif ($self->{op} =~ /movq/ && $line =~ /%xmm/) {
+           } elsif ($self->{op} =~ /mov[dq]/ && $line =~ /%xmm/) {
                $self->{sz} = "";
            } elsif ($self->{op} =~ /([a-z]{3,})([qlwb])$/) {
                $self->{op} = $1;
@@ -270,15 +270,20 @@ my %globals;
                sprintf "%s%s(%%%s)",   $self->{asterisk},$self->{label},$self->{base};
            }
        } else {
-           %szmap = (  b=>"BYTE$PTR", w=>"WORD$PTR", l=>"DWORD$PTR",
-                       q=>"QWORD$PTR",o=>"OWORD$PTR",x=>"XMMWORD$PTR",
-                       y=>"" );
+           %szmap = (  b=>"BYTE$PTR",  w=>"WORD$PTR",
+                       l=>"DWORD$PTR", d=>"DWORD$PTR",
+                       q=>"QWORD$PTR", o=>"OWORD$PTR",
+                       x=>"XMMWORD$PTR", y=>"YMMWORD$PTR", z=>"ZMMWORD$PTR" );
 
            $self->{label} =~ s/\./\$/g;
            $self->{label} =~ s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/ig;
            $self->{label} = "($self->{label})" if ($self->{label} =~ /[\*\+\-\/]/);
-           $sz="q" if ($self->{asterisk} || opcode->mnemonic() =~ /^v?movq$/);
-           $sz="l" if (opcode->mnemonic() =~ /^v?movd$/);
+
+           ($self->{asterisk})                                 && ($sz="q") ||
+           (opcode->mnemonic() =~ /^v?mov([qd])$/)             && ($sz=$1)  ||
+           (opcode->mnemonic() =~ /^v?pinsr([qdwb])$/)         && ($sz=$1)  ||
+           (opcode->mnemonic() =~ /^vpbroadcast([qdwb])$/)     && ($sz=$1)  ||
+           (opcode->mnemonic() =~ /^vinsert[fi]128$/)          && ($sz="x");
 
            if (defined($self->{index})) {
                sprintf "%s[%s%s*%d%s]",$szmap{$sz},
@@ -536,7 +541,7 @@ my %globals;
                                        $v="$current_segment\tENDS\n" if ($current_segment);
                                        $current_segment = ".text\$";
                                        $v.="$current_segment\tSEGMENT ";
-                                       $v.=$masm>=$masmref ? "ALIGN(64)" : "PAGE";
+                                       $v.=$masm>=$masmref ? "ALIGN(256)" : "PAGE";
                                        $v.=" 'CODE'";
                                    }
                                    $self->{value} = $v;
@@ -778,6 +783,19 @@ my $rdrand = sub {
     }
 };
 
+my $rdseed = sub {
+    if (shift =~ /%[er](\w+)/) {
+      my @opcode=();
+      my $dst=$1;
+       if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; }
+       rex(\@opcode,0,$1,8);
+       push @opcode,0x0f,0xc7,0xf8|($dst&7);
+       @opcode;
+    } else {
+       ();
+    }
+};
+
 sub rxb {
  local *opcode=shift;
  my ($dst,$src1,$src2,$rxb)=@_;
@@ -821,6 +839,8 @@ if ($nasm) {
     print <<___;
 default        rel
 %define XMMWORD
+%define YMMWORD
+%define ZMMWORD
 ___
 } elsif ($masm) {
     print <<___;
@@ -834,6 +854,7 @@ while($line=<>) {
     $line =~ s|[#!].*$||;      # get rid of asm-style comments...
     $line =~ s|/\*.*\*/||;     # ... and C-style comments...
     $line =~ s|^\s+||;         # ... and skip white spaces in beginning
+    $line =~ s|\s+$||;         # ... and at the end
 
     undef $label;
     undef $opcode;
@@ -883,6 +904,7 @@ while($line=<>) {
                    # $insn.=$sz compensates for movq, pinsrw, ...
                    if ($arg =~ /^xmm[0-9]+$/) { $insn.=$sz; $sz="x" if(!$sz); last; }
                    if ($arg =~ /^ymm[0-9]+$/) { $insn.=$sz; $sz="y" if(!$sz); last; }
+                   if ($arg =~ /^zmm[0-9]+$/) { $insn.=$sz; $sz="z" if(!$sz); last; }
                    if ($arg =~ /^mm[0-9]+$/)  { $insn.=$sz; $sz="q" if(!$sz); last; }
                }
                @args = reverse(@args);