[llvm-commits] [llvm] r106251 - in /llvm/trunk/lib/Target/X86: X86InstrFormats.td X86InstrSSE.td

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Thu Jun 17 16:05:30 PDT 2010


Author: bruno
Date: Thu Jun 17 18:05:30 2010
New Revision: 106251

URL: http://llvm.org/viewvc/llvm-project?rev=106251&view=rev
Log:
Use new tablegen resources in SSE tablegen code. This will
be done incrementally and intermixed with the adding of more
AVX instructions. This is a first step in that direction

Modified:
    llvm/trunk/lib/Target/X86/X86InstrFormats.td
    llvm/trunk/lib/Target/X86/X86InstrSSE.td

Modified: llvm/trunk/lib/Target/X86/X86InstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFormats.td?rev=106251&r1=106250&r2=106251&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrFormats.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrFormats.td Thu Jun 17 18:05:30 2010
@@ -214,6 +214,17 @@
   let CodeSize = 3;
 }
 
+// SI - SSE 1 & 2 scalar instructions
+class SI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern>
+      : I<o, F, outs, ins, asm, pattern> {
+  let Predicates = !if(hasVEX_4VPrefix /* VEX_4V */,
+            !if(!eq(Prefix, 11 /* XD */), [HasAVX, HasSSE2], [HasAVX, HasSSE1]),
+            !if(!eq(Prefix, 12 /* XS */), [HasSSE2], [HasSSE1]));
+
+  // AVX instructions have a 'v' prefix in the mnemonic
+  let AsmString = !if(hasVEX_4VPrefix, !strconcat("v", asm), asm);
+}
+
 // SSE1 Instruction Templates:
 // 
 //   SSI   - SSE1 instructions with XS prefix.

Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=106251&r1=106250&r2=106251&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Jun 17 18:05:30 2010
@@ -646,6 +646,17 @@
     defm FsANDN : sse12_fp_alias_pack_logical<0x55, "andn", undef, 1, 1, 0>;
 }
 
+/// sse12_fp_scalar - SSE 1 & 2 scalar instructions class
+multiclass sse12_fp_scalar<bits<8> opc, string OpcodeStr, SDNode OpNode,
+                           RegisterClass RC, X86MemOperand memop> {
+  let isCommutable = 1 in {
+    def rr : SI<opc, MRMSrcReg, (outs RC:$dst), (ins RC:$src1, RC:$src2),
+                OpcodeStr, [(set RC:$dst, (OpNode RC:$src1, RC:$src2))]>;
+  }
+  def rm : SI<opc, MRMSrcMem, (outs RC:$dst), (ins RC:$src1, memop:$src2),
+              OpcodeStr, [(set RC:$dst, (OpNode RC:$src1, (load addr:$src2)))]>;
+}
+
 /// basic_sse12_fp_binop_rm - SSE 1 & 2 binops come in both scalar and
 /// vector forms.
 ///
@@ -660,66 +671,30 @@
 let Constraints = "$src1 = $dst" in {
 multiclass basic_sse12_fp_binop_rm<bits<8> opc, string OpcodeStr,
                                  SDNode OpNode, bit Commutable = 0> {
-  // Scalar operation, reg+reg.
-  def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2),
-                 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
-                 [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> {
-    let isCommutable = Commutable;
-  }
-
-  def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2),
-                 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
-                 [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> {
-    let isCommutable = Commutable;
-  }
-
-  def V#NAME#SSrr : VSSI<opc, MRMSrcReg, (outs FR32:$dst),
-                 (ins FR32:$src1, FR32:$src2),
-                 !strconcat(OpcodeStr,
-                            "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
-                 []> {
-    let isCommutable = Commutable;
-    let Constraints = "";
-    let isAsmParserOnly = 1;
-  }
-
-  def V#NAME#SDrr : VSDI<opc, MRMSrcReg, (outs FR64:$dst),
-                 (ins FR64:$src1, FR64:$src2),
-                 !strconcat(OpcodeStr,
-                            "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
-                 []> {
-    let isCommutable = Commutable;
-    let Constraints = "";
-    let isAsmParserOnly = 1;
-  }
-
-  // Scalar operation, reg+mem.
-  def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst),
-                                 (ins FR32:$src1, f32mem:$src2),
-                 !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
-                 [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>;
-
-  def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst),
-                                 (ins FR64:$src1, f64mem:$src2),
-                 !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
-                 [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>;
-
-  def V#NAME#SSrm : VSSI<opc, MRMSrcMem, (outs FR32:$dst),
-                 (ins FR32:$src1, f32mem:$src2),
-                 !strconcat(OpcodeStr,
-                            "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
-                 []> {
-    let Constraints = "";
-    let isAsmParserOnly = 1;
-  }
 
-  def V#NAME#SDrm : VSDI<opc, MRMSrcMem, (outs FR64:$dst),
-                 (ins FR64:$src1, f64mem:$src2),
-                 !strconcat(OpcodeStr,
-                            "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
-                 []> {
-    let Constraints = "";
-    let isAsmParserOnly = 1;
+  let Constraints = "", isAsmParserOnly = 1, hasVEX_4VPrefix = 1 in {
+    // Scalar operation, reg+reg.
+    let Prefix = 12 /* XS */ in
+      defm V#NAME#SS : sse12_fp_scalar<opc,
+        !strconcat(OpcodeStr, "ss\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
+                   OpNode, FR32, f32mem>;
+
+    let Prefix = 11 /* XD */ in
+      defm V#NAME#SD : sse12_fp_scalar<opc,
+        !strconcat(OpcodeStr, "sd\t{$src2, $src1, $dst|$dst, $src1, $src2}"),
+                   OpNode, FR64, f64mem>;
+  }
+
+  let Constraints = "$src1 = $dst" in {
+    // Scalar operation, reg+reg.
+    let Prefix = 12 /* XS */ in
+      defm SS : sse12_fp_scalar<opc,
+                      !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"),
+                      OpNode, FR32, f32mem>;
+    let Prefix = 11 /* XD */ in
+      defm SD : sse12_fp_scalar<opc,
+                      !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"),
+                      OpNode, FR64, f64mem>;
   }
 
   // Vector operation, reg+reg.
@@ -863,8 +838,11 @@
 // Arithmetic instructions
 defm ADD : basic_sse12_fp_binop_rm<0x58, "add", fadd, 1>;
 defm MUL : basic_sse12_fp_binop_rm<0x59, "mul", fmul, 1>;
-defm SUB : basic_sse12_fp_binop_rm<0x5C, "sub", fsub>;
-defm DIV : basic_sse12_fp_binop_rm<0x5E, "div", fdiv>;
+
+let isCommutable = 0 in {
+  defm SUB : basic_sse12_fp_binop_rm<0x5C, "sub", fsub>;
+  defm DIV : basic_sse12_fp_binop_rm<0x5E, "div", fdiv>;
+}
 
 /// sse12_fp_binop_rm - Other SSE 1 & 2 binops
 ///





More information about the llvm-commits mailing list