summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/perlasm/x86asm.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/perlasm/x86asm.pl')
-rw-r--r--src/lib/libcrypto/perlasm/x86asm.pl69
1 files changed, 15 insertions, 54 deletions
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl
index eb543db2f6..4756a28e59 100644
--- a/src/lib/libcrypto/perlasm/x86asm.pl
+++ b/src/lib/libcrypto/perlasm/x86asm.pl
@@ -33,6 +33,13 @@ sub ::emit
33 else { push(@out,"\t$opcode\t".join(',',@_)."\n"); } 33 else { push(@out,"\t$opcode\t".join(',',@_)."\n"); }
34} 34}
35 35
36sub ::emitraw
37{ my $opcode=shift;
38
39 if ($#_==-1) { push(@out,"$opcode\n"); }
40 else { push(@out,"$opcode\t".join(',',@_)."\n"); }
41}
42
36sub ::LB 43sub ::LB
37{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'"; 44{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'";
38 $1."l"; 45 $1."l";
@@ -80,57 +87,6 @@ sub ::movq
80 { &::generic("movq",@_); } 87 { &::generic("movq",@_); }
81} 88}
82 89
83# SSE>2 instructions
84my %regrm = ( "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3,
85 "esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7 );
86sub ::pextrd
87{ my($dst,$src,$imm)=@_;
88 if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/)
89 { &::data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm); }
90 else
91 { &::generic("pextrd",@_); }
92}
93
94sub ::pinsrd
95{ my($dst,$src,$imm)=@_;
96 if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/)
97 { &::data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm); }
98 else
99 { &::generic("pinsrd",@_); }
100}
101
102sub ::pshufb
103{ my($dst,$src)=@_;
104 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
105 { &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2); }
106 else
107 { &::generic("pshufb",@_); }
108}
109
110sub ::palignr
111{ my($dst,$src,$imm)=@_;
112 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
113 { &::data_byte(0x66,0x0f,0x3a,0x0f,0xc0|($1<<3)|$2,$imm); }
114 else
115 { &::generic("palignr",@_); }
116}
117
118sub ::pclmulqdq
119{ my($dst,$src,$imm)=@_;
120 if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
121 { &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); }
122 else
123 { &::generic("pclmulqdq",@_); }
124}
125
126sub ::rdrand
127{ my ($dst)=@_;
128 if ($dst =~ /(e[a-dsd][ixp])/)
129 { &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
130 else
131 { &::generic("rdrand",@_); }
132}
133
134# label management 90# label management
135$lbdecor="L"; # local label decoration, set by package 91$lbdecor="L"; # local label decoration, set by package
136$label="000"; 92$label="000";
@@ -218,7 +174,7 @@ sub ::asm_init
218 $filename=$fn; 174 $filename=$fn;
219 $i386=$cpu; 175 $i386=$cpu;
220 176
221 $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$android=0; 177 $elf=$cpp=$coff=$aout=$macosx=$win32=$netware=$mwerks=$openbsd=0;
222 if (($type eq "elf")) 178 if (($type eq "elf"))
223 { $elf=1; require "x86gas.pl"; } 179 { $elf=1; require "x86gas.pl"; }
224 elsif (($type eq "a\.out")) 180 elsif (($type eq "a\.out"))
@@ -235,8 +191,10 @@ sub ::asm_init
235 { $win32=1; require "x86masm.pl"; } 191 { $win32=1; require "x86masm.pl"; }
236 elsif (($type eq "macosx")) 192 elsif (($type eq "macosx"))
237 { $aout=1; $macosx=1; require "x86gas.pl"; } 193 { $aout=1; $macosx=1; require "x86gas.pl"; }
238 elsif (($type eq "android")) 194 elsif (($type eq "openbsd-elf"))
239 { $elf=1; $android=1; require "x86gas.pl"; } 195 { $openbsd=$elf=1; require "x86gas.pl"; }
196 elsif (($type eq "openbsd-a.out"))
197 { $openbsd=1; require "x86gas.pl"; }
240 else 198 else
241 { print STDERR <<"EOF"; 199 { print STDERR <<"EOF";
242Pick one target type from 200Pick one target type from
@@ -244,6 +202,8 @@ Pick one target type from
244 a.out - DJGPP, elder OpenBSD, etc. 202 a.out - DJGPP, elder OpenBSD, etc.
245 coff - GAS/COFF such as Win32 targets 203 coff - GAS/COFF such as Win32 targets
246 win32n - Windows 95/Windows NT NASM format 204 win32n - Windows 95/Windows NT NASM format
205 openbsd-elf - OpenBSD elf
206 openbsd-a.out - OpenBSD a.out
247 nw-nasm - NetWare NASM format 207 nw-nasm - NetWare NASM format
248 macosx - Mac OS X 208 macosx - Mac OS X
249EOF 209EOF
@@ -253,6 +213,7 @@ EOF
253 $pic=0; 213 $pic=0;
254 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); } 214 for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); }
255 215
216 ::emitraw("#include <machine/asm.h>\n") if $openbsd;
256 $filename =~ s/\.pl$//; 217 $filename =~ s/\.pl$//;
257 &file($filename); 218 &file($filename);
258} 219}