[llvm-commits] [llvm] r129678 - in /llvm/trunk/utils/TableGen: CodeGenInstruction.h FastISelEmitter.cpp

Chris Lattner sabre at nondot.org
Sun Apr 17 15:24:13 PDT 2011


Author: lattner
Date: Sun Apr 17 17:24:13 2011
New Revision: 129678

URL: http://llvm.org/viewvc/llvm-project?rev=129678&view=rev
Log:
change OperandsSignature to use SmallVector<char> instead of std::vector<string>
since the strings are always exactly one character, and there are usually only 2-3 operands.


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

Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=129678&r1=129677&r2=129678&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Sun Apr 17 17:24:13 2011
@@ -137,6 +137,7 @@
     bool isVariadic;
 
     // Provide transparent accessors to the operand list.
+    bool empty() const { return OperandList.empty(); }
     unsigned size() const { return OperandList.size(); }
     const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
     OperandInfo &operator[](unsigned i) { return OperandList[i]; }

Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=129678&r1=129677&r2=129678&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Sun Apr 17 17:24:13 2011
@@ -40,7 +40,7 @@
 /// types. It has utility methods for emitting text based on the operands.
 ///
 struct OperandsSignature {
-  std::vector<std::string> Operands;
+  SmallVector<char, 3> Operands;
 
   bool operator<(const OperandsSignature &O) const {
     return Operands < O.Operands;
@@ -57,11 +57,11 @@
 
     if (!InstPatNode->isLeaf()) {
       if (InstPatNode->getOperator()->getName() == "imm") {
-        Operands.push_back("i");
+        Operands.push_back('i');
         return true;
       }
       if (InstPatNode->getOperator()->getName() == "fpimm") {
-        Operands.push_back("f");
+        Operands.push_back('f');
         return true;
       }
     }
@@ -78,11 +78,11 @@
 
       if (!Op->isLeaf()) {
         if (Op->getOperator()->getName() == "imm") {
-          Operands.push_back("i");
+          Operands.push_back('i');
           continue;
         }
         if (Op->getOperator()->getName() == "fpimm") {
-          Operands.push_back("f");
+          Operands.push_back('f');
           continue;
         }
         // For now, ignore other non-leaf nodes.
@@ -122,18 +122,18 @@
           return false;
       } else
         DstRC = RC;
-      Operands.push_back("r");
+      Operands.push_back('r');
     }
     return true;
   }
 
   void PrintParameters(raw_ostream &OS) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
-      if (Operands[i] == "r") {
+      if (Operands[i] == 'r') {
         OS << "unsigned Op" << i << ", bool Op" << i << "IsKill";
-      } else if (Operands[i] == "i") {
+      } else if (Operands[i] == 'i') {
         OS << "uint64_t imm" << i;
-      } else if (Operands[i] == "f") {
+      } else if (Operands[i] == 'f') {
         OS << "ConstantFP *f" << i;
       } else {
         assert("Unknown operand kind!");
@@ -155,13 +155,13 @@
 
       if (PrintedArg)
         OS << ", ";
-      if (Operands[i] == "r") {
+      if (Operands[i] == 'r') {
         OS << "Op" << i << ", Op" << i << "IsKill";
         PrintedArg = true;
-      } else if (Operands[i] == "i") {
+      } else if (Operands[i] == 'i') {
         OS << "imm" << i;
         PrintedArg = true;
-      } else if (Operands[i] == "f") {
+      } else if (Operands[i] == 'f') {
         OS << "f" << i;
         PrintedArg = true;
       } else {
@@ -173,11 +173,11 @@
 
   void PrintArguments(raw_ostream &OS) const {
     for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
-      if (Operands[i] == "r") {
+      if (Operands[i] == 'r') {
         OS << "Op" << i << ", Op" << i << "IsKill";
-      } else if (Operands[i] == "i") {
+      } else if (Operands[i] == 'i') {
         OS << "imm" << i;
-      } else if (Operands[i] == "f") {
+      } else if (Operands[i] == 'f') {
         OS << "f" << i;
       } else {
         assert("Unknown operand kind!");
@@ -266,7 +266,7 @@
     if (!Op->isSubClassOf("Instruction"))
       continue;
     CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
-    if (II.Operands.size() == 0)
+    if (II.Operands.empty())
       continue;
 
     // For now, ignore multi-instruction patterns.





More information about the llvm-commits mailing list