[llvm-commits] [llvm] r136431 - /llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp

Owen Anderson resistor at mac.com
Thu Jul 28 16:56:20 PDT 2011


Author: resistor
Date: Thu Jul 28 18:56:20 2011
New Revision: 136431

URL: http://llvm.org/viewvc/llvm-project?rev=136431&view=rev
Log:
Enhance the fixed-length decoder emitter to support tied operands.

Modified:
    llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp

Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=136431&r1=136430&r2=136431&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Thu Jul 28 18:56:20 2011
@@ -1223,6 +1223,17 @@
   for (unsigned i = 0; i < In->getNumArgs(); ++i)
     InOutOperands.push_back(std::make_pair(In->getArg(i), In->getArgName(i)));
 
+  // Search for tied operands, so that we can correctly instantiate
+  // operands that are not explicitly represented in the encoding.
+  std::map<Init*, std::string> TiedNames;
+  for (unsigned i = 0; i < CGI.Operands.size(); ++i) {
+    int tiedTo = CGI.Operands[i].getTiedRegister();
+    if (tiedTo != -1) {
+      TiedNames[InOutOperands[i].first] = InOutOperands[tiedTo].second;
+      TiedNames[InOutOperands[tiedTo].first] = InOutOperands[i].second;
+    }
+  }
+
   // For each operand, see if we can figure out where it is encoded.
   for (std::vector<std::pair<Init*, std::string> >::iterator
        NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) {
@@ -1269,7 +1280,8 @@
 
       VarInit *Var = dynamic_cast<VarInit*>(BI->getVariable());
       assert(Var);
-      if (Var->getName() != NI->second) {
+      if (Var->getName() != NI->second &&
+          Var->getName() != TiedNames[NI->first]) {
         if (Base != ~0U) {
           OpInfo.addField(Base, Width, Offset);
           Base = ~0U;





More information about the llvm-commits mailing list