look up instructions by record, not by name.
authorChris Lattner <sabre@nondot.org>
Fri, 19 Mar 2010 00:07:20 +0000 (00:07 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 19 Mar 2010 00:07:20 +0000 (00:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98904 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeEmitterGen.cpp
utils/TableGen/CodeGenDAGPatterns.cpp
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/CodeGenTarget.h
utils/TableGen/DAGISelEmitter.cpp
utils/TableGen/DAGISelMatcherGen.cpp
utils/TableGen/FastISelEmitter.cpp

index f1857f506e622696c47b5048319baeb93437fb86..a057dec7ce3b4038dac446a7135a9083ee1ae979 100644 (file)
@@ -156,7 +156,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
 
     BitsInit *BI = R->getValueAsBitsInit("Inst");
     const std::vector<RecordVal> &Vals = R->getValues();
-    CodeGenInstruction &CGI = Target.getInstruction(InstName);
+    CodeGenInstruction &CGI = Target.getInstruction(R);
     
     // Loop over all of the fields in the instruction, determining which are the
     // operands to the instruction.
index 9fd557f03b821a4fcb8332c75b79f67241d49882..fafcd8c30ef9fafcaf3cbe4c021ef40b45b3958d 100644 (file)
@@ -1141,7 +1141,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
            "Only supports zero or one result instrs!");
 
     CodeGenInstruction &InstInfo =
-      CDP.getTargetInfo().getInstruction(getOperator()->getName());
+      CDP.getTargetInfo().getInstruction(getOperator());
     
     EEVT::TypeSet ResultType;
     
@@ -2083,7 +2083,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
       std::vector<Record*> Results;
       std::vector<Record*> Operands;
       
-      CodeGenInstruction &InstInfo =Target.getInstruction(Instrs[i]->getName());
+      CodeGenInstruction &InstInfo = Target.getInstruction(Instrs[i]);
 
       if (InstInfo.OperandList.size() != 0) {
         if (InstInfo.NumDefs == 0) {
@@ -2150,7 +2150,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
 
     // Parse the operands list from the (ops) list, validating it.
     assert(I->getArgList().empty() && "Args list should still be empty here!");
-    CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]->getName());
+    CodeGenInstruction &CGI = Target.getInstruction(Instrs[i]);
 
     // Check that all of the results occur first in the list.
     std::vector<Record*> Results;
index ec6a31fd195f4d270044363394bd3890ce605259..499d8aca9e16c23cdb5b7aa46fd05fdc2e6b8b2d 100644 (file)
@@ -138,6 +138,12 @@ Record *CodeGenTarget::getInstructionSet() const {
   return TargetRec->getValueAsDef("InstructionSet");
 }
 
+
+CodeGenInstruction &CodeGenTarget::getInstruction(const Record *InstRec) const {
+  return getInstruction(InstRec->getName());
+}
+
+
 /// getAsmParser - Return the AssemblyParser definition for this target.
 ///
 Record *CodeGenTarget::getAsmParser() const {
index 1df74af36220be6b194d7b90a251365e153f275b..d20e868da726007e721146121ed3603965c5c9eb 100644 (file)
@@ -193,12 +193,15 @@ public:
     if (Instructions.empty()) ReadInstructions();
     return Instructions;
   }
-
+private:
   CodeGenInstruction &getInstruction(const std::string &Name) const {
     const std::map<std::string, CodeGenInstruction> &Insts = getInstructions();
     assert(Insts.count(Name) && "Not an instruction!");
     return const_cast<CodeGenInstruction&>(Insts.find(Name)->second);
   }
+public:
+  
+  CodeGenInstruction &getInstruction(const Record *InstRec) const;  
 
   typedef std::map<std::string,
                    CodeGenInstruction>::const_iterator inst_iterator;
index 73feac16512040131c497d496c7adee36d3c0693..ef9b73451158c0078ab8e6043a642cff4d763e96 100644 (file)
@@ -75,7 +75,7 @@ static unsigned getResultPatternCost(TreePatternNode *P,
   Record *Op = P->getOperator();
   if (Op->isSubClassOf("Instruction")) {
     Cost++;
-    CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op->getName());
+    CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
     if (II.usesCustomInserter)
       Cost += 10;
   }
index 4d0b74b53101a6a73c90c54249b2e0fb872be0e7..0d7d9ae73a54d164915a9145243999657f7a6f38 100644 (file)
@@ -627,7 +627,7 @@ EmitResultInstructionAsOperand(const TreePatternNode *N,
                                SmallVectorImpl<unsigned> &OutputOps) {
   Record *Op = N->getOperator();
   const CodeGenTarget &CGT = CGP.getTargetInfo();
-  CodeGenInstruction &II = CGT.getInstruction(Op->getName());
+  CodeGenInstruction &II = CGT.getInstruction(Op);
   const DAGInstruction &Inst = CGP.getInstruction(Op);
   
   // If we can, get the pattern for the instruction we're generating.  We derive
index b94ded64526108ee624f2abdd18eaaacf8ada0e3..52f9563ec7264f8d3c999d8609b7261831b973d6 100644 (file)
@@ -254,7 +254,7 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
     Record *Op = Dst->getOperator();
     if (!Op->isSubClassOf("Instruction"))
       continue;
-    CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op->getName());
+    CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
     if (II.OperandList.empty())
       continue;