[llvm-commits] CVS: llvm/utils/TableGen/CodeGenTarget.cpp CodeGenTarget.h DAGISelEmitter.cpp DAGISelEmitter.h

Evan Cheng evan.cheng at apple.com
Wed May 17 13:38:11 PDT 2006



Changes in directory llvm/utils/TableGen:

CodeGenTarget.cpp updated: 1.64 -> 1.65
CodeGenTarget.h updated: 1.26 -> 1.27
DAGISelEmitter.cpp updated: 1.203 -> 1.204
DAGISelEmitter.h updated: 1.63 -> 1.64
---
Log message:

Remove PointerType from target definition. Use abstract type MVT::iPTR to
represent pointer type.


---
Diffs of the changes:  (+93 -65)

 CodeGenTarget.cpp  |   58 ++++++++++++++++------------------
 CodeGenTarget.h    |    3 -
 DAGISelEmitter.cpp |   88 +++++++++++++++++++++++++++++++++++------------------
 DAGISelEmitter.h   |    9 ++++-
 4 files changed, 93 insertions(+), 65 deletions(-)


Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.64 llvm/utils/TableGen/CodeGenTarget.cpp:1.65
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.64	Tue May 16 02:05:30 2006
+++ llvm/utils/TableGen/CodeGenTarget.cpp	Wed May 17 15:37:59 2006
@@ -30,12 +30,7 @@
 /// getValueType - Return the MCV::ValueType that the specified TableGen record
 /// corresponds to.
 MVT::ValueType llvm::getValueType(Record *Rec, const CodeGenTarget *CGT) {
-  MVT::ValueType VT = (MVT::ValueType)Rec->getValueAsInt("Value");
-  if (VT == MVT::iPTR) {
-    assert(CGT && "Use a pointer type in a place that isn't supported yet!");
-    VT = CGT->getPointerType();
-  }
-  return VT;
+  return (MVT::ValueType)Rec->getValueAsInt("Value");
 }
 
 std::string llvm::getName(MVT::ValueType T) {
@@ -63,35 +58,37 @@
   case MVT::v2f32: return "v2f32";
   case MVT::v4f32: return "v4f32";
   case MVT::v2f64: return "v2f64";
+  case MVT::iPTR:  return "TLI.getPointetTy()";
   default: assert(0 && "ILLEGAL VALUE TYPE!"); return "";
   }
 }
 
 std::string llvm::getEnumName(MVT::ValueType T) {
   switch (T) {
-  case MVT::Other: return "Other";
-  case MVT::i1:    return "i1";
-  case MVT::i8:    return "i8";
-  case MVT::i16:   return "i16";
-  case MVT::i32:   return "i32";
-  case MVT::i64:   return "i64";
-  case MVT::i128:  return "i128";
-  case MVT::f32:   return "f32";
-  case MVT::f64:   return "f64";
-  case MVT::f80:   return "f80";
-  case MVT::f128:  return "f128";
-  case MVT::Flag:  return "Flag";
-  case MVT::isVoid:return "isVoid";
-  case MVT::v8i8:  return "v8i8";
-  case MVT::v4i16: return "v4i16";
-  case MVT::v2i32: return "v2i32";
-  case MVT::v16i8: return "v16i8";
-  case MVT::v8i16: return "v8i16";
-  case MVT::v4i32: return "v4i32";
-  case MVT::v2i64: return "v2i64";
-  case MVT::v2f32: return "v2f32";
-  case MVT::v4f32: return "v4f32";
-  case MVT::v2f64: return "v2f64";
+  case MVT::Other: return "MVT::Other";
+  case MVT::i1:    return "MVT::i1";
+  case MVT::i8:    return "MVT::i8";
+  case MVT::i16:   return "MVT::i16";
+  case MVT::i32:   return "MVT::i32";
+  case MVT::i64:   return "MVT::i64";
+  case MVT::i128:  return "MVT::i128";
+  case MVT::f32:   return "MVT::f32";
+  case MVT::f64:   return "MVT::f64";
+  case MVT::f80:   return "MVT::f80";
+  case MVT::f128:  return "MVT::f128";
+  case MVT::Flag:  return "MVT::Flag";
+  case MVT::isVoid:return "MVT::isVoid";
+  case MVT::v8i8:  return "MVT::v8i8";
+  case MVT::v4i16: return "MVT::v4i16";
+  case MVT::v2i32: return "MVT::v2i32";
+  case MVT::v16i8: return "MVT::v16i8";
+  case MVT::v8i16: return "MVT::v8i16";
+  case MVT::v4i32: return "MVT::v4i32";
+  case MVT::v2i64: return "MVT::v2i64";
+  case MVT::v2f32: return "MVT::v2f32";
+  case MVT::v4f32: return "MVT::v4f32";
+  case MVT::v2f64: return "MVT::v2f64";
+  case MVT::iPTR:  return "TLI.getPointetTy()";
   default: assert(0 && "ILLEGAL VALUE TYPE!"); return "";
   }
 }
@@ -104,7 +101,7 @@
 
 /// getTarget - Return the current instance of the Target class.
 ///
-CodeGenTarget::CodeGenTarget() : PointerType(MVT::Other) {
+CodeGenTarget::CodeGenTarget() {
   std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
   if (Targets.size() == 0)
     throw std::string("ERROR: No 'Target' subclasses defined!");
@@ -114,7 +111,6 @@
 
   // Read in all of the CalleeSavedRegisters.
   CalleeSavedRegisters =TargetRec->getValueAsListOfDefs("CalleeSavedRegisters");
-  PointerType = getValueType(TargetRec->getValueAsDef("PointerType"));
 }
 
 


Index: llvm/utils/TableGen/CodeGenTarget.h
diff -u llvm/utils/TableGen/CodeGenTarget.h:1.26 llvm/utils/TableGen/CodeGenTarget.h:1.27
--- llvm/utils/TableGen/CodeGenTarget.h:1.26	Tue May 16 02:05:30 2006
+++ llvm/utils/TableGen/CodeGenTarget.h	Wed May 17 15:37:59 2006
@@ -43,7 +43,6 @@
 class CodeGenTarget {
   Record *TargetRec;
   std::vector<Record*> CalleeSavedRegisters;
-  MVT::ValueType PointerType;
 
   mutable std::map<std::string, CodeGenInstruction> Instructions;
   mutable std::vector<CodeGenRegister> Registers;
@@ -63,8 +62,6 @@
     return CalleeSavedRegisters;
   }
 
-  MVT::ValueType getPointerType() const { return PointerType; }
-
   /// getInstructionSet - Return the InstructionSet object.
   ///
   Record *getInstructionSet() const;


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.203 llvm/utils/TableGen/DAGISelEmitter.cpp:1.204
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.203	Tue May 16 02:05:30 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Wed May 17 15:37:59 2006
@@ -156,7 +156,7 @@
     return NodeToApply->UpdateNodeType(x.SDTCisVT_Info.VT, TP);
   case SDTCisPtrTy: {
     // Operand must be same as target pointer type.
-    return NodeToApply->UpdateNodeType(CGT.getPointerType(), TP);
+    return NodeToApply->UpdateNodeType(MVT::iPTR, TP);
   }
   case SDTCisInt: {
     // If there is only one integer type supported, this must be it.
@@ -346,6 +346,18 @@
     setTypes(ExtVTs);
     return true;
   }
+
+  if (getExtTypeNum(0) == MVT::iPTR) {
+    if (ExtVTs[0] == MVT::iPTR || ExtVTs[0] == MVT::isInt)
+      return false;
+    if (isExtIntegerInVTs(ExtVTs)) {
+      std::vector<unsigned char> FVTs = FilterEVTs(ExtVTs, MVT::isInteger);
+      if (FVTs.size()) {
+        setTypes(ExtVTs);
+        return true;
+      }
+    }
+  }
   
   if (ExtVTs[0] == MVT::isInt && isExtIntegerInVTs(getExtTypes())) {
     assert(hasTypeSet() && "should be handled above!");
@@ -355,6 +367,16 @@
     setTypes(FVTs);
     return true;
   }
+  if (ExtVTs[0] == MVT::iPTR && isExtIntegerInVTs(getExtTypes())) {
+    //assert(hasTypeSet() && "should be handled above!");
+    std::vector<unsigned char> FVTs = FilterEVTs(getExtTypes(), MVT::isInteger);
+    if (getExtTypes() == FVTs)
+      return false;
+    if (FVTs.size()) {
+      setTypes(FVTs);
+      return true;
+    }
+  }      
   if (ExtVTs[0] == MVT::isFP  && isExtFloatingPointInVTs(getExtTypes())) {
     assert(hasTypeSet() && "should be handled above!");
     std::vector<unsigned char> FVTs =
@@ -374,7 +396,11 @@
       (getExtTypeNum(0) == MVT::isFP  && isExtFloatingPointInVTs(ExtVTs))) {
     setTypes(ExtVTs);
     return true;
-  }      
+  }
+  if (getExtTypeNum(0) == MVT::isInt && ExtVTs[0] == MVT::iPTR) {
+    setTypes(ExtVTs);
+    return true;
+  }
 
   if (isLeaf()) {
     dump();
@@ -402,6 +428,7 @@
   case MVT::isInt: OS << ":isInt"; break;
   case MVT::isFP : OS << ":isFP"; break;
   case MVT::isUnknown: ; /*OS << ":?";*/ break;
+  case MVT::iPTR:  OS << ":iPTR"; break;
   default:  OS << ":" << getTypeNum(0); break;
   }
 
@@ -603,19 +630,22 @@
         // At some point, it may make sense for this tree pattern to have
         // multiple types.  Assert here that it does not, so we revisit this
         // code when appropriate.
-        assert(getExtTypes().size() >= 1 && "TreePattern does not have a type!");
+        assert(getExtTypes().size() >= 1 && "TreePattern doesn't have a type!");
         MVT::ValueType VT = getTypeNum(0);
         for (unsigned i = 1, e = getExtTypes().size(); i != e; ++i)
           assert(getTypeNum(i) == VT && "TreePattern has too many types!");
         
-        unsigned Size = MVT::getSizeInBits(getTypeNum(0));
-        // Make sure that the value is representable for this type.
-        if (Size < 32) {
-          int Val = (II->getValue() << (32-Size)) >> (32-Size);
-          if (Val != II->getValue())
-            TP.error("Sign-extended integer value '" + itostr(II->getValue()) +
-                     "' is out of range for type 'MVT::" + 
-                     getEnumName(getTypeNum(0)) + "'!");
+        VT = getTypeNum(0);
+        if (VT != MVT::iPTR) {
+          unsigned Size = MVT::getSizeInBits(VT);
+          // Make sure that the value is representable for this type.
+          if (Size < 32) {
+            int Val = (II->getValue() << (32-Size)) >> (32-Size);
+            if (Val != II->getValue())
+              TP.error("Sign-extended integer value '" + itostr(II->getValue())+
+                       "' is out of range for type '" + 
+                       getEnumName(getTypeNum(0)) + "'!");
+          }
         }
       }
       
@@ -652,8 +682,7 @@
                utostr(getNumChildren()-1) + " operands!");
 
     // Apply type info to the intrinsic ID.
-    MVT::ValueType PtrTy = ISE.getTargetInfo().getPointerType();
-    MadeChange |= getChild(0)->UpdateNodeType(PtrTy, TP);
+    MadeChange |= getChild(0)->UpdateNodeType(MVT::iPTR, TP);
     
     for (unsigned i = 1, e = getNumChildren(); i != e; ++i) {
       MVT::ValueType OpVT = Int.ArgVTs[i];
@@ -1862,10 +1891,11 @@
 /// patterns before small ones.  This is used to determine the size of a
 /// pattern.
 static unsigned getPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
-  assert(isExtIntegerInVTs(P->getExtTypes()) || 
-         isExtFloatingPointInVTs(P->getExtTypes()) ||
-         P->getExtTypeNum(0) == MVT::isVoid ||
-         P->getExtTypeNum(0) == MVT::Flag && 
+  assert((isExtIntegerInVTs(P->getExtTypes()) || 
+          isExtFloatingPointInVTs(P->getExtTypes()) ||
+          P->getExtTypeNum(0) == MVT::isVoid ||
+          P->getExtTypeNum(0) == MVT::Flag ||
+          P->getExtTypeNum(0) == MVT::iPTR) && 
          "Not a valid pattern node to size!");
   unsigned Size = 2;  // The node itself.
   // If the root node is a ConstantSDNode, increases its size.
@@ -2340,7 +2370,7 @@
         emitDecl("Tmp" + utostr(ResNo));
         emitCode("Tmp" + utostr(ResNo) + 
                  " = CurDAG->getTargetConstant(Tmp" + utostr(ResNo) + 
-                 "C, MVT::" + getEnumName(N->getTypeNum(0)) + ");");
+                 "C, " + getEnumName(N->getTypeNum(0)) + ");");
       } else if (!N->isLeaf() && N->getOperator()->getName() == "texternalsym"){
         Record *Op = OperatorMap[N->getName()];
         // Transform ExternalSymbol to TargetExternalSymbol
@@ -2348,7 +2378,7 @@
           emitDecl("Tmp" + utostr(ResNo));
           emitCode("Tmp" + utostr(ResNo) + " = CurDAG->getTarget"
                    "ExternalSymbol(cast<ExternalSymbolSDNode>(" +
-                   Val + ")->getSymbol(), MVT::" +
+                   Val + ")->getSymbol(), " +
                    getEnumName(N->getTypeNum(0)) + ");");
         } else {
           emitDecl("Tmp" + utostr(ResNo));
@@ -2361,7 +2391,7 @@
           emitDecl("Tmp" + utostr(ResNo));
           emitCode("Tmp" + utostr(ResNo) + " = CurDAG->getTarget"
                    "GlobalAddress(cast<GlobalAddressSDNode>(" + Val +
-                   ")->getGlobal(), MVT::" + getEnumName(N->getTypeNum(0)) +
+                   ")->getGlobal(), " + getEnumName(N->getTypeNum(0)) +
                    ");");
         } else {
           emitDecl("Tmp" + utostr(ResNo));
@@ -2420,7 +2450,7 @@
         if (DI->getDef()->isSubClassOf("Register")) {
           emitDecl("Tmp" + utostr(ResNo));
           emitCode("Tmp" + utostr(ResNo) + " = CurDAG->getRegister(" +
-                   ISE.getQualifiedName(DI->getDef()) + ", MVT::" +
+                   ISE.getQualifiedName(DI->getDef()) + ", " +
                    getEnumName(N->getTypeNum(0)) + ");");
           return std::make_pair(1, ResNo);
         }
@@ -2430,7 +2460,7 @@
         emitDecl("Tmp" + utostr(ResNo));
         emitCode("Tmp" + utostr(ResNo) + 
                  " = CurDAG->getTargetConstant(" + itostr(II->getValue()) +
-                 ", MVT::" + getEnumName(N->getTypeNum(0)) + ");");
+                 ", " + getEnumName(N->getTypeNum(0)) + ");");
         return std::make_pair(1, ResNo);
       }
     
@@ -2552,7 +2582,7 @@
           // Result types.
           if (PatResults > 0) { 
             if (N->getTypeNum(0) != MVT::isVoid)
-              Code += ", MVT::" + getEnumName(N->getTypeNum(0));
+              Code += ", " + getEnumName(N->getTypeNum(0));
           }
           if (NodeHasChain)
             Code += ", MVT::Other";
@@ -2572,7 +2602,7 @@
           // Output order: results, chain, flags
           // Result types.
           if (PatResults > 0 && N->getTypeNum(0) != MVT::isVoid)
-            Code += ", MVT::" + getEnumName(N->getTypeNum(0));
+            Code += ", " + getEnumName(N->getTypeNum(0));
           if (NodeHasChain)
             Code += ", MVT::Other";
           if (NodeHasOutFlag)
@@ -2606,7 +2636,7 @@
           // Output order: results, chain, flags
           // Result types.
           if (NumResults > 0 && N->getTypeNum(0) != MVT::isVoid)
-            Code += ", MVT::" + getEnumName(N->getTypeNum(0));
+            Code += ", " + getEnumName(N->getTypeNum(0));
           if (NodeHasChain)
             Code += ", MVT::Other";
           if (NodeHasOutFlag)
@@ -2717,7 +2747,7 @@
         std::string Code = "  Result = CurDAG->SelectNodeTo(N.Val, " +
           II.Namespace + "::" + II.TheDef->getName();
         if (N->getTypeNum(0) != MVT::isVoid)
-          Code += ", MVT::" + getEnumName(N->getTypeNum(0));
+          Code += ", " + getEnumName(N->getTypeNum(0));
         if (NodeHasOutFlag)
           Code += ", MVT::Flag";
         for (unsigned i = 0, e = Ops.size(); i != e; ++i)
@@ -2730,7 +2760,7 @@
         Code = "  ResNode = CurDAG->getTargetNode(" +
                II.Namespace + "::" + II.TheDef->getName();
         if (N->getTypeNum(0) != MVT::isVoid)
-          Code += ", MVT::" + getEnumName(N->getTypeNum(0));
+          Code += ", " + getEnumName(N->getTypeNum(0));
         if (NodeHasOutFlag)
           Code += ", MVT::Flag";
         for (unsigned i = 0, e = Ops.size(); i != e; ++i)
@@ -2834,7 +2864,7 @@
                        RootName + utostr(OpNo) + ");");
               emitCode("ResNode = CurDAG->getCopyToReg(" + ChainName +
                        ", CurDAG->getRegister(" + ISE.getQualifiedName(RR) +
-                       ", MVT::" + getEnumName(RVT) + "), " +
+                       ", " + getEnumName(RVT) + "), " +
                        RootName + utostr(OpNo) + ", InFlag).Val;");
               emitCode(ChainName + " = SDOperand(ResNode, 0);");
               emitCode("InFlag = SDOperand(ResNode, 1);");
@@ -2882,7 +2912,7 @@
               ChainName = "Chain";
             }
             emitCode("ResNode = CurDAG->getCopyFromReg(" + ChainName + ", " +
-                     ISE.getQualifiedName(RR) + ", MVT::" + getEnumName(RVT) +
+                     ISE.getQualifiedName(RR) + ", " + getEnumName(RVT) +
                      ", InFlag).Val;");
             emitCode(ChainName + " = SDOperand(ResNode, 1);");
             emitCode("InFlag = SDOperand(ResNode, 2);");


Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.63 llvm/utils/TableGen/DAGISelEmitter.h:1.64
--- llvm/utils/TableGen/DAGISelEmitter.h:1.63	Wed Apr 19 15:36:09 2006
+++ llvm/utils/TableGen/DAGISelEmitter.h	Wed May 17 15:37:59 2006
@@ -169,10 +169,15 @@
     void setName(const std::string &N) { Name = N; }
     
     bool isLeaf() const { return Val != 0; }
-    bool hasTypeSet() const { return Types[0] < MVT::LAST_VALUETYPE; }
+    bool hasTypeSet() const {
+      return (Types[0] < MVT::LAST_VALUETYPE) || (Types[0] == MVT::iPTR);
+    }
     bool isTypeCompletelyUnknown() const {
       return Types[0] == MVT::isUnknown;
     }
+    bool isTypeDynamicallyResolved() const {
+      return Types[0] == MVT::iPTR;
+    }
     MVT::ValueType getTypeNum(unsigned Num) const {
       assert(hasTypeSet() && "Doesn't have a type yet!");
       assert(Types.size() > Num && "Type num out of range!");
@@ -247,7 +252,7 @@
     /// ContainsUnresolvedType - Return true if this tree contains any
     /// unresolved types.
     bool ContainsUnresolvedType() const {
-      if (!hasTypeSet()) return true;
+      if (!hasTypeSet() && !isTypeDynamicallyResolved()) return true;
       for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
         if (getChild(i)->ContainsUnresolvedType()) return true;
       return false;






More information about the llvm-commits mailing list