[llvm-commits] CVS: llvm/utils/TableGen/AsmWriterEmitter.cpp CodeEmitterGen.cpp CodeGenInstruction.h CodeGenTarget.cpp

Chris Lattner sabre at nondot.org
Wed Nov 15 15:23:17 PST 2006



Changes in directory llvm/utils/TableGen:

AsmWriterEmitter.cpp updated: 1.45 -> 1.46
CodeEmitterGen.cpp updated: 1.50 -> 1.51
CodeGenInstruction.h updated: 1.24 -> 1.25
CodeGenTarget.cpp updated: 1.78 -> 1.79
---
Log message:

Remove the isTwoAddress property from the CodeGenInstruction class.  It should
not be used for anything other than backwards compat constraint handling.

Add support for a new DisableEncoding property which contains a list of 
registers that should not be encoded by the generated code emitter.  Convert
the codeemitter generator to use this, fixing some PPC JIT regressions.




---
Diffs of the changes:  (+53 -19)

 AsmWriterEmitter.cpp |   11 +++--------
 CodeEmitterGen.cpp   |   18 +++++++++---------
 CodeGenInstruction.h |   25 ++++++++++++++++++++++++-
 CodeGenTarget.cpp    |   18 +++++++++++++++++-
 4 files changed, 53 insertions(+), 19 deletions(-)


Index: llvm/utils/TableGen/AsmWriterEmitter.cpp
diff -u llvm/utils/TableGen/AsmWriterEmitter.cpp:1.45 llvm/utils/TableGen/AsmWriterEmitter.cpp:1.46
--- llvm/utils/TableGen/AsmWriterEmitter.cpp:1.45	Sun Nov  5 13:31:28 2006
+++ llvm/utils/TableGen/AsmWriterEmitter.cpp	Wed Nov 15 17:23:02 2006
@@ -220,16 +220,11 @@
         unsigned OpNo = CGI.getOperandNamed(VarName);
         CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
 
-        // If this is a two-address instruction, verify the second operand isn't
-        // used.
-        unsigned MIOp = OpInfo.MIOperandNo;
-        if (CGI.isTwoAddress && MIOp == 1)
-          throw "Should refer to operand #0 instead of #1 for two-address"
-                " instruction '" + CGI.TheDef->getName() + "'!";
-        
-        if (CurVariant == Variant || CurVariant == ~0U) 
+        if (CurVariant == Variant || CurVariant == ~0U) {
+          unsigned MIOp = OpInfo.MIOperandNo;
           Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName, MIOp,
                                               Modifier));
+        }
       }
       LastEmitted = VarEnd;
     }


Index: llvm/utils/TableGen/CodeEmitterGen.cpp
diff -u llvm/utils/TableGen/CodeEmitterGen.cpp:1.50 llvm/utils/TableGen/CodeEmitterGen.cpp:1.51
--- llvm/utils/TableGen/CodeEmitterGen.cpp:1.50	Thu Nov  2 19:48:30 2006
+++ llvm/utils/TableGen/CodeEmitterGen.cpp	Wed Nov 15 17:23:02 2006
@@ -125,7 +125,8 @@
     
     BitsInit *BI = R->getValueAsBitsInit("Inst");
     const std::vector<RecordVal> &Vals = R->getValues();
-
+    CodeGenInstruction &CGI = Target.getInstruction(InstName);
+    
     // Loop over all of the fields in the instruction, determining which are the
     // operands to the instruction.
     unsigned op = 0;
@@ -154,16 +155,15 @@
             }
 
             if (!gotOp) {
+              /// If this operand is not supposed to be emitted by the generated
+              /// emitter, skip it.
+              while (CGI.isFlatOperandNotEmitted(op))
+                ++op;
+              
               Case += "      // op: " + VarName + "\n"
                    +  "      op = getMachineOpValue(MI, MI.getOperand("
-                   +  utostr(op++)
-                   +  "));\n";
+                   +  utostr(op++) + "));\n";
               gotOp = true;
-              
-              // If this is a two-address instruction and we just got the dest
-              // op, skip the src op.
-              if (op == 1 && Target.getInstruction(InstName).isTwoAddress)
-                ++op;
             }
             
             unsigned opMask = (1 << N) - 1;
@@ -185,7 +185,7 @@
       }
     }
 
-    std::vector<std::string> &InstList =  CaseMap[Case];
+    std::vector<std::string> &InstList = CaseMap[Case];
     InstList.push_back(InstName);
   }
 


Index: llvm/utils/TableGen/CodeGenInstruction.h
diff -u llvm/utils/TableGen/CodeGenInstruction.h:1.24 llvm/utils/TableGen/CodeGenInstruction.h:1.25
--- llvm/utils/TableGen/CodeGenInstruction.h:1.24	Tue Nov 14 20:38:17 2006
+++ llvm/utils/TableGen/CodeGenInstruction.h	Wed Nov 15 17:23:02 2006
@@ -57,6 +57,11 @@
       unsigned MIOperandNo;
       unsigned MINumOperands;   // The number of operands.
 
+      /// DoNotEncode - Bools are set to true in this vector for each operand in
+      /// the DisableEncoding list.  These should not be emitted by the code
+      /// emitter.
+      std::vector<bool> DoNotEncode;
+      
       /// MIOperandInfo - Default MI operand type. Note an operand may be made
       /// up of multiple MI operands.
       DagInit *MIOperandInfo;
@@ -82,7 +87,6 @@
     bool isCall;
     bool isLoad;
     bool isStore;
-    bool isTwoAddress;
     bool isPredicated;
     bool isConvertibleToThreeAddress;
     bool isCommutable;
@@ -107,6 +111,25 @@
       return OperandList[Op.first].MIOperandNo + Op.second;
     }
     
+    /// getSubOperandNumber - Unflatten a operand number into an
+    /// operand/suboperand pair.
+    std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const {
+      for (unsigned i = 0; ; ++i) {
+        assert(i < OperandList.size() && "Invalid flat operand #");
+        if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
+          return std::make_pair(i, Op-OperandList[i].MIOperandNo);
+      }
+    }
+    
+    
+    /// isFlatOperandNotEmitted - Return true if the specified flat operand #
+    /// should not be emitted with the code emitter.
+    bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
+      std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo);
+      if (OperandList[Op.first].DoNotEncode.size() > Op.second)
+        return OperandList[Op.first].DoNotEncode[Op.second];
+      return false;
+    }
 
     CodeGenInstruction(Record *R, const std::string &AsmStr);
 


Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.78 llvm/utils/TableGen/CodeGenTarget.cpp:1.79
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.78	Tue Nov 14 20:38:17 2006
+++ llvm/utils/TableGen/CodeGenTarget.cpp	Wed Nov 15 17:23:02 2006
@@ -343,7 +343,7 @@
   isCall       = R->getValueAsBit("isCall");
   isLoad       = R->getValueAsBit("isLoad");
   isStore      = R->getValueAsBit("isStore");
-  isTwoAddress = R->getValueAsBit("isTwoAddress");
+  bool isTwoAddress = R->getValueAsBit("isTwoAddress");
   isPredicated = false;   // set below.
   isConvertibleToThreeAddress = R->getValueAsBit("isConvertibleToThreeAddress");
   isCommutable = R->getValueAsBit("isCommutable");
@@ -413,6 +413,7 @@
     MIOperandNo += NumOps;
   }
 
+  // Parse Constraints.
   ParseConstraints(R->getValueAsString("Constraints"), this);
   
   // For backward compatibility: isTwoAddress means operand 1 is tied to
@@ -430,6 +431,21 @@
     for (unsigned j = 0, e = OperandList[op].MINumOperands; j != e; ++j)
       if (OperandList[op].Constraints[j].empty())
         OperandList[op].Constraints[j] = "0";
+  
+  // Parse the DisableEncoding field.
+  std::string DisableEncoding = R->getValueAsString("DisableEncoding");
+  while (1) {
+    std::string OpName = getToken(DisableEncoding, " ,\t");
+    if (OpName.empty()) break;
+
+    // Figure out which operand this is.
+    std::pair<unsigned,unsigned> Op = ParseOperandName(OpName, false);
+
+    // Mark the operand as not-to-be encoded.
+    if (Op.second >= OperandList[Op.first].DoNotEncode.size())
+      OperandList[Op.first].DoNotEncode.resize(Op.second+1);
+    OperandList[Op.first].DoNotEncode[Op.second] = true;
+  }
 }
 
 






More information about the llvm-commits mailing list