[llvm-commits] [llvm] r118119 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td utils/TableGen/AsmMatcherEmitter.cpp

Chris Lattner sabre at nondot.org
Tue Nov 2 16:40:41 PDT 2010


Author: lattner
Date: Tue Nov  2 18:40:41 2010
New Revision: 118119

URL: http://llvm.org/viewvc/llvm-project?rev=118119&view=rev
Log:
Completely reject instructions that have an operand in their
ins/outs list that isn't specified by their asmstring.  Previously
the asmmatcher would just force a 0 register into it, which clearly
isn't right.  Mark a bunch of ARM instructions that use this as 
isCodeGenOnly.  Some of them are clearly pseudo instructions (like
t2TBB) others use a weird hasExtraSrcRegAllocReq thing that will
either need to be removed or the asmmatcher will need to be taught
about it (someday).


Modified:
    llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
    llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=118119&r1=118118&r2=118119&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Nov  2 18:40:41 2010
@@ -1352,39 +1352,41 @@
     def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
                 "b\t$target", [(br bb:$target)]>;
 
-  let isNotDuplicable = 1, isIndirectBranch = 1 in {
-  def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
-                    IIC_Br, "mov\tpc, $target$jt",
-                    [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
-    let Inst{11-4}  = 0b00000000;
-    let Inst{15-12} = 0b1111;
-    let Inst{20}    = 0; // S Bit
-    let Inst{24-21} = 0b1101;
-    let Inst{27-25} = 0b000;
-  }
-  def BR_JTm : JTI<(outs),
-                   (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
-                   IIC_Br, "ldr\tpc, $target$jt",
-                   [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
-                     imm:$id)]> {
-    let Inst{15-12} = 0b1111;
-    let Inst{20}    = 1; // L bit
-    let Inst{21}    = 0; // W bit
-    let Inst{22}    = 0; // B bit
-    let Inst{24}    = 1; // P bit
-    let Inst{27-25} = 0b011;
-  }
-  def BR_JTadd : JTI<(outs),
-                   (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
-                    IIC_Br, "add\tpc, $target, $idx$jt",
-                    [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
-                      imm:$id)]> {
-    let Inst{15-12} = 0b1111;
-    let Inst{20}    = 0; // S bit
-    let Inst{24-21} = 0b0100;
-    let Inst{27-25} = 0b000;
-  }
-  } // isNotDuplicable = 1, isIndirectBranch = 1
+    let isNotDuplicable = 1, isIndirectBranch = 1,
+        // FIXME: $imm field is not specified by asm string.  Mark as cgonly.
+        isCodeGenOnly = 1 in {
+    def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
+                      IIC_Br, "mov\tpc, $target$jt",
+                      [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
+      let Inst{11-4}  = 0b00000000;
+      let Inst{15-12} = 0b1111;
+      let Inst{20}    = 0; // S Bit
+      let Inst{24-21} = 0b1101;
+      let Inst{27-25} = 0b000;
+    }
+    def BR_JTm : JTI<(outs),
+                     (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
+                     IIC_Br, "ldr\tpc, $target$jt",
+                     [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
+                       imm:$id)]> {
+      let Inst{15-12} = 0b1111;
+      let Inst{20}    = 1; // L bit
+      let Inst{21}    = 0; // W bit
+      let Inst{22}    = 0; // B bit
+      let Inst{24}    = 1; // P bit
+      let Inst{27-25} = 0b011;
+    }
+    def BR_JTadd : JTI<(outs),
+                     (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
+                      IIC_Br, "add\tpc, $target, $idx$jt",
+                      [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
+                        imm:$id)]> {
+      let Inst{15-12} = 0b1111;
+      let Inst{20}    = 0; // S bit
+      let Inst{24-21} = 0b0100;
+      let Inst{27-25} = 0b000;
+    }
+    } // isNotDuplicable = 1, isIndirectBranch = 1
   } // isBarrier = 1
 
   // FIXME: should be able to write a pattern for ARMBrcond, but can't use
@@ -1494,7 +1496,8 @@
                    IIC_iLoad_bh_r, "ldrsb", "\t$dst, $addr",
                    [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
 
-let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
+let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
+    isCodeGenOnly = 1 in { // $dst2 doesn't exist in asmstring?
 // Load doubleword
 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
                  IIC_iLoad_d_r, "ldrd", "\t$dst1, $addr",
@@ -1595,7 +1598,8 @@
                [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
 
 // Store doubleword
-let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
+let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
+    isCodeGenOnly = 1 in  // $src2 doesn't exist in asm string
 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
                StMiscFrm, IIC_iStore_d_r,
                "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;

Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=118119&r1=118118&r2=118119&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Nov  2 18:40:41 2010
@@ -931,7 +931,8 @@
 defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
                       UnOpFrag<(sextloadi8  node:$Src)>>;
 
-let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
+let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
+    isCodeGenOnly = 1 in { // $dst doesn't exist in asmstring?
 // Load doubleword
 def t2LDRDi8  : T2Ii8s4<1, 0, 1, (outs rGPR:$dst1, rGPR:$dst2),
                         (ins t2addrmode_imm8s4:$addr),
@@ -1078,7 +1079,8 @@
                    BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
 
 // Store doubleword
-let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
+let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
+    isCodeGenOnly = 1 in  // $src2 doesn't exist in asm string
 def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
                        (ins GPR:$src1, GPR:$src2, t2addrmode_imm8s4:$addr),
                IIC_iStore_d_r, "strd", "\t$src1, $addr", []>;
@@ -1195,6 +1197,7 @@
     let Inst{11-8} = 0b1100;
   }
 
+  let isCodeGenOnly = 1 in   // $base doesn't exist in asmstring?
   def pci : T2I<(outs), (ins GPR:$base, neg_zero:$imm), IIC_iLoad_i, opc,
                 "\t[pc, $imm]", []> {
     let Inst{31-25} = 0b1111100;
@@ -2457,7 +2460,8 @@
   let Inst{12} = 1;
 }
 
-let isNotDuplicable = 1, isIndirectBranch = 1 in {
+let isNotDuplicable = 1, isIndirectBranch = 1,
+    isCodeGenOnly = 1 in { // $id doesn't exist in asmstring, should be lowered.
 def t2BR_JT :
     T2JTI<(outs),
           (ins GPR:$target, GPR:$index, jt2block_operand:$jt, i32imm:$id),
@@ -2472,6 +2476,7 @@
 }
 
 // FIXME: Add a non-pc based case that can be predicated.
+let isCodeGenOnly = 1 in  // $id doesn't exist in asm string, should be lowered.
 def t2TBB :
     T2JTI<(outs),
         (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),
@@ -2483,6 +2488,7 @@
   let Inst{7-4} = 0b0000; // B form
 }
 
+let isCodeGenOnly = 1 in  // $id doesn't exist in asm string, should be lowered.
 def t2TBH :
     T2JTI<(outs),
         (ins tb_addrmode:$index, jt2block_operand:$jt, i32imm:$id),

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=118119&r1=118118&r2=118119&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Nov  2 18:40:41 2010
@@ -1176,27 +1176,21 @@
         continue;
       }
       
+      // Otherwise, this must be a tied operand if not, it is something that is
+      // mentioned in the ins/outs list but not in the asm string.
+      int TiedOp = OpInfo.getTiedRegister();
+      if (TiedOp == -1)
+        throw TGError(II.TheDef->getLoc(), "Instruction '" +
+                      II.TheDef->getName() + "' has operand '" + OpInfo.Name +
+                      "' that doesn't appear in asm string!");
 
       // If this operand is tied to a previous one, just copy the MCInst operand
       // from the earlier one.
-      int TiedOp = OpInfo.getTiedRegister();
-      if (TiedOp != -1) {
-        // Copy the tied operand.  We can only tie single MCOperand values.
-        assert(OpInfo.MINumOperands == 1 && "Not a singular MCOperand");
-        assert(i > unsigned(TiedOp) && "Tied operand preceeds its target!");
-        CaseOS << "    Inst.addOperand(Inst.getOperand(" << TiedOp << "));\n";
-        Signature += "__Tie" + itostr(TiedOp);
-        continue;
-      }
-
-      // Otherwise this is some sort of dummy operand that is mentioned in the
-      // ins/outs list but not mentioned in the asmstring, brutalize a dummy
-      // value into the operand.
-      // FIXME: This is a terrible hack: If an MCInst operand doesn't occur in
-      // the asmstring, there is no way to parse something meaningful.
-      // Just assume it is a zero register for now.
-      CaseOS << "    Inst.addOperand(MCOperand::CreateReg(0));\n";
-      Signature += "__Imp";
+      // Copy the tied operand.  We can only tie single MCOperand values.
+      assert(OpInfo.MINumOperands == 1 && "Not a singular MCOperand");
+      assert(i > unsigned(TiedOp) && "Tied operand preceeds its target!");
+      CaseOS << "    Inst.addOperand(Inst.getOperand(" << TiedOp << "));\n";
+      Signature += "__Tie" + itostr(TiedOp);
     }
     
     II.ConversionFnKind = Signature;





More information about the llvm-commits mailing list