[llvm-commits] [llvm] r123931 - in /llvm/trunk/utils/TableGen: AsmMatcherEmitter.cpp CodeGenInstruction.cpp CodeGenInstruction.h

Bob Wilson bob.wilson at apple.com
Thu Jan 20 10:38:02 PST 2011


Author: bwilson
Date: Thu Jan 20 12:38:02 2011
New Revision: 123931

URL: http://llvm.org/viewvc/llvm-project?rev=123931&view=rev
Log:
Precompute InstAlias operand mapping to result instruction operand indices.

There should be no functional change from this, but I think it's simpler this
way.

Modified:
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
    llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
    llvm/trunk/utils/TableGen/CodeGenInstruction.h

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=123931&r1=123930&r2=123931&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Thu Jan 20 12:38:02 2011
@@ -1213,7 +1213,7 @@
         CGA.ResultOperands[i].getName() == OperandName) {
       // It's safe to go with the first one we find, because CodeGenInstAlias
       // validates that all operands with the same name have the same record.
-      unsigned ResultIdx =CGA.getResultInstOperandIndexForResultOperandIndex(i);
+      unsigned ResultIdx = CGA.ResultInstOperandIndex[i];
       Op.Class = getOperandClass(CGA.ResultInst->Operands[ResultIdx]);
       Op.SrcOpName = OperandName;
       return;

Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=123931&r1=123930&r2=123931&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Thu Jan 20 12:38:02 2011
@@ -439,6 +439,7 @@
                                                                               
         // Now that it is validated, add it.
         ResultOperands.push_back(ResultOperand(ADI->getDef()));
+        ResultInstOperandIndex.push_back(i);
         ++AliasOpNo;
         continue;
       }
@@ -454,6 +455,7 @@
 
         // Now that it is validated, add it.
         ResultOperands.push_back(ResultOperand(static_cast<Record*>(0)));
+        ResultInstOperandIndex.push_back(i);
         ++AliasOpNo;
         continue;
       }
@@ -485,6 +487,7 @@
       // Now that it is validated, add it.
       ResultOperands.push_back(ResultOperand(Result->getArgName(AliasOpNo),
                                              ADI->getDef()));
+      ResultInstOperandIndex.push_back(i);
       ++AliasOpNo;
       continue;
     }
@@ -500,6 +503,7 @@
                       ResultOpRec->getName() +
                       " for integer result operand!");
       ResultOperands.push_back(ResultOperand(II->getValue()));
+      ResultInstOperandIndex.push_back(i);
       ++AliasOpNo;
       continue;
     }
@@ -513,21 +517,3 @@
                   " instruction expects " + utostr(ResultInst->Operands.size())+
                   " operands!");
 }
-
-/// getResultInstOperandIndexForResultOperandIndex - Given an index into the
-/// ResultOperands array, translate it to a valid index in ResultInst's
-/// operand list.
-unsigned CodeGenInstAlias::
-getResultInstOperandIndexForResultOperandIndex(unsigned OpNo) const {
-  unsigned OpIdx = 0;
-  
-  for (unsigned i = 0;; ++i) {
-    assert(i != ResultInst->Operands.size() && "Didn't find entry");
-    if (ResultInst->Operands[i].getTiedRegister() != -1)
-      continue;
-
-    if (OpIdx == OpNo) return i;
-
-    ++OpIdx;
-  }
-}

Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=123931&r1=123930&r2=123931&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Thu Jan 20 12:38:02 2011
@@ -296,13 +296,12 @@
     
     /// ResultOperands - The decoded operands for the result instruction.
     std::vector<ResultOperand> ResultOperands;
+
+    /// ResultInstOperandIndex - For each operand, this vector holds the
+    /// corresponding index of an operand in the result instruction.
+    std::vector<unsigned> ResultInstOperandIndex;
     
     CodeGenInstAlias(Record *R, CodeGenTarget &T);
-    
-    /// getResultInstOperandIndexForResultOperandIndex - Given an index into the
-    /// ResultOperands array, translate it to a valid index in ResultInst's
-    /// operand list.
-    unsigned getResultInstOperandIndexForResultOperandIndex(unsigned i) const;
   };    
 }
 





More information about the llvm-commits mailing list