[llvm-branch-commits] [llvm-branch] r91556 - in /llvm/branches/Apple/Zoidberg: include/llvm/Target/TargetInstrDesc.h lib/CodeGen/MachineInstr.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td utils/TableGen/CodeGenInstruction.cpp

Jim Grosbach grosbach at apple.com
Wed Dec 16 11:45:06 PST 2009


Author: grosbach
Date: Wed Dec 16 13:45:06 2009
New Revision: 91556

URL: http://llvm.org/viewvc/llvm-project?rev=91556&view=rev
Log:
merge 91554 91555

Modified:
    llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrDesc.h
    llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineInstr.cpp
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrInfo.td
    llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrThumb2.td
    llvm/branches/Apple/Zoidberg/utils/TableGen/CodeGenInstruction.cpp

Modified: llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrDesc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrDesc.h?rev=91556&r1=91555&r2=91556&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrDesc.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrDesc.h Wed Dec 16 13:45:06 2009
@@ -25,9 +25,10 @@
 //===----------------------------------------------------------------------===//
   
 namespace TOI {
-  // Operand constraints: only "tied_to" for now.
+  // Operand constraints
   enum OperandConstraint {
-    TIED_TO = 0  // Must be allocated the same register as.
+    TIED_TO = 0,    // Must be allocated the same register as.
+    EARLY_CLOBBER   // Operand is an early clobber register operand
   };
   
   /// OperandFlags - These are flags set on operands, but should be considered

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineInstr.cpp?rev=91556&r1=91555&r2=91556&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/MachineInstr.cpp Wed Dec 16 13:45:06 2009
@@ -555,8 +555,13 @@
       Operands.back().ParentMI = this;
   
       // If the operand is a register, update the operand's use list.
-      if (Op.isReg())
+      if (Op.isReg()) {
         Operands.back().AddRegOperandToRegInfo(RegInfo);
+        // If the register operand is flagged as early, mark the operand as such
+        unsigned OpNo = Operands.size() - 1;
+        if (TID->getOperandConstraint(OpNo, TOI::EARLY_CLOBBER) != -1)
+          Operands[OpNo].setIsEarlyClobber(true);
+      }
       return;
     }
   }
@@ -573,8 +578,12 @@
 
     // Do explicitly set the reginfo for this operand though, to ensure the
     // next/prev fields are properly nulled out.
-    if (Operands[OpNo].isReg())
+    if (Operands[OpNo].isReg()) {
       Operands[OpNo].AddRegOperandToRegInfo(0);
+      // If the register operand is flagged as early, mark the operand as such
+      if (TID->getOperandConstraint(OpNo, TOI::EARLY_CLOBBER) != -1)
+        Operands[OpNo].setIsEarlyClobber(true);
+    }
 
   } else if (Operands.size()+1 <= Operands.capacity()) {
     // Otherwise, we have to remove register operands from their register use
@@ -594,8 +603,12 @@
     Operands.insert(Operands.begin()+OpNo, Op);
     Operands[OpNo].ParentMI = this;
 
-    if (Operands[OpNo].isReg())
+    if (Operands[OpNo].isReg()) {
       Operands[OpNo].AddRegOperandToRegInfo(RegInfo);
+      // If the register operand is flagged as early, mark the operand as such
+      if (TID->getOperandConstraint(OpNo, TOI::EARLY_CLOBBER) != -1)
+        Operands[OpNo].setIsEarlyClobber(true);
+    }
     
     // Re-add all the implicit ops.
     for (unsigned i = OpNo+1, e = Operands.size(); i != e; ++i) {
@@ -613,6 +626,11 @@
   
     // Re-add all the operands.
     AddRegOperandsToUseLists(*RegInfo);
+
+      // If the register operand is flagged as early, mark the operand as such
+    if (Operands[OpNo].isReg()
+        && TID->getOperandConstraint(OpNo, TOI::EARLY_CLOBBER) != -1)
+      Operands[OpNo].setIsEarlyClobber(true);
   }
 }
 

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrInfo.td?rev=91556&r1=91555&r2=91556&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrInfo.td (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrInfo.td Wed Dec 16 13:45:06 2009
@@ -1735,7 +1735,7 @@
                     []>;
 }
 
-let mayStore = 1 in {
+let mayStore = 1, Constraints = "@earlyclobber $success" in {
 def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
                     NoItinerary,
                     "strexb", "\t$success, $src, [$ptr]",

Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrThumb2.td
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrThumb2.td?rev=91556&r1=91555&r2=91556&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrThumb2.td (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMInstrThumb2.td Wed Dec 16 13:45:06 2009
@@ -1106,7 +1106,7 @@
                       []>;
 }
 
-let mayStore = 1 in {
+let mayStore = 1, Constraints = "@earlyclobber $success" in {
 def t2STREXB : Thumb2I<(outs GPR:$success), (ins GPR:$src, GPR:$ptr),
                       AddrModeNone, Size4Bytes, NoItinerary,
                       "strexb", "\t$success, $src, [$ptr]", "",

Modified: llvm/branches/Apple/Zoidberg/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/utils/TableGen/CodeGenInstruction.cpp?rev=91556&r1=91555&r2=91556&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/branches/Apple/Zoidberg/utils/TableGen/CodeGenInstruction.cpp Wed Dec 16 13:45:06 2009
@@ -18,14 +18,35 @@
 using namespace llvm;
 
 static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
-  // FIXME: Only supports TIED_TO for now.
+  // EARLY_CLOBBER: @early $reg
+  std::string::size_type wpos = CStr.find_first_of(" \t");
+  std::string::size_type start = CStr.find_first_not_of(" \t");
+  std::string Tok = CStr.substr(start, wpos - start);
+  if (Tok == "@earlyclobber") {
+    std::string Name = CStr.substr(wpos+1);
+    wpos = Name.find_first_not_of(" \t");
+    if (wpos == std::string::npos)
+      throw "Illegal format for @earlyclobber constraint: '" + CStr + "'";
+    Name = Name.substr(wpos);
+    std::pair<unsigned,unsigned> Op =
+      I->ParseOperandName(Name, false);
+
+    // Build the string for the operand
+    std::string OpConstraint = "(1 << TOI::EARLY_CLOBBER)";
+    if (!I->OperandList[Op.first].Constraints[Op.second].empty())
+      throw "Operand '" + Name + "' cannot have multiple constraints!";
+    I->OperandList[Op.first].Constraints[Op.second] = OpConstraint;
+    return;
+  }
+
+  // Only other constraint is "TIED_TO" for now.
   std::string::size_type pos = CStr.find_first_of('=');
   assert(pos != std::string::npos && "Unrecognized constraint");
-  std::string::size_type start = CStr.find_first_not_of(" \t");
+  start = CStr.find_first_not_of(" \t");
   std::string Name = CStr.substr(start, pos - start);
 
   // TIED_TO: $src1 = $dst
-  std::string::size_type wpos = Name.find_first_of(" \t");
+  wpos = Name.find_first_of(" \t");
   if (wpos == std::string::npos)
     throw "Illegal format for tied-to constraint: '" + CStr + "'";
   std::string DestOpName = Name.substr(0, wpos);
@@ -47,7 +68,6 @@
   std::string OpConstraint =
   "((" + utostr(FlatOpNo) + " << 16) | (1 << TOI::TIED_TO))";
 
-
   if (!I->OperandList[DestOp.first].Constraints[DestOp.second].empty())
     throw "Operand '" + DestOpName + "' cannot have multiple constraints!";
   I->OperandList[DestOp.first].Constraints[DestOp.second] = OpConstraint;





More information about the llvm-branch-commits mailing list