perlasm/x86*: add support to SSE>2 and pclmulqdq. x86_64-xlate.pl provides
[openssl.git] / crypto / perlasm / x86asm.pl
index 34244c1ce0d05bb63cdee5ac22b73c35fbbc0553..f09152adb6ec85d25e354bec33514fafb3fe008e 100644 (file)
@@ -80,6 +80,27 @@ sub ::movq
     {  &::generic("movq",@_);                  }
 }
 
+# SSE>2 instructions
+my %regrm = (  "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3,
+               "esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7  );
+sub ::pextrd
+{ my($dst,$src,$imm)=@_;
+    if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/)
+    {  &data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm);   }
+}
+
+sub ::pinsrd
+{ my($dst,$src,$imm)=@_;
+    if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/)
+    {  &data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm);   }
+}
+
+sub ::pshufb
+{ my($dst,$src)=@_;
+    if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/)
+    {  &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2);        }
+}
+
 # AESNI extenstion
 sub ::aeskeygenassist
 { my($dst,$src,$imm)=@_;
@@ -97,6 +118,12 @@ 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);   }
+}
+
 # label management
 $lbdecor="L";          # local label decoration, set by package
 $label="000";