Precompute InstAlias operand mapping to result instruction operand indices.
authorBob Wilson <bob.wilson@apple.com>
Thu, 20 Jan 2011 18:38:02 +0000 (18:38 +0000)
committerBob Wilson <bob.wilson@apple.com>
Thu, 20 Jan 2011 18:38:02 +0000 (18:38 +0000)
There should be no functional change from this, but I think it's simpler this
way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123931 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/AsmMatcherEmitter.cpp
utils/TableGen/CodeGenInstruction.cpp
utils/TableGen/CodeGenInstruction.h

index be1cd709ca917364e6c5a5be645c9d51b40f458e..78840fec38bbc56dcb783162607ed59b8c1b31ab 100644 (file)
@@ -1213,7 +1213,7 @@ void AsmMatcherInfo::BuildAliasOperandReference(MatchableInfo *II,
         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;
index 08005fb5e1c1e58c1013d0b94991021527688522..6b1fc6ed1a68d4e9e4ca3544f2d73f6a92d514ad 100644 (file)
@@ -439,6 +439,7 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
                                                                               
         // Now that it is validated, add it.
         ResultOperands.push_back(ResultOperand(ADI->getDef()));
+        ResultInstOperandIndex.push_back(i);
         ++AliasOpNo;
         continue;
       }
@@ -454,6 +455,7 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
 
         // 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 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
       // 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 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
                       ResultOpRec->getName() +
                       " for integer result operand!");
       ResultOperands.push_back(ResultOperand(II->getValue()));
+      ResultInstOperandIndex.push_back(i);
       ++AliasOpNo;
       continue;
     }
@@ -513,21 +517,3 @@ CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) {
                   " 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;
-  }
-}
index d58bfb12968d1c709158148ce754942ea7e705c7..fb0e50c08b76955042563902d242d18f987d1945 100644 (file)
@@ -296,13 +296,12 @@ namespace llvm {
     
     /// 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;
   };    
 }