[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Type.cpp iCall.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 8 22:19:55 PST 2004


Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.119 -> 1.120
Type.cpp updated: 1.87 -> 1.88
iCall.cpp updated: 1.22 -> 1.23

---
Log message:

Start using the new and improve interface to FunctionType arguments



---
Diffs of the changes:  (+29 -38)

Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.119 llvm/lib/VMCore/AsmWriter.cpp:1.120
--- llvm/lib/VMCore/AsmWriter.cpp:1.119	Sun Feb  8 15:52:30 2004
+++ llvm/lib/VMCore/AsmWriter.cpp	Sun Feb  8 22:14:01 2004
@@ -153,15 +153,14 @@
   case Type::FunctionTyID: {
     const FunctionType *FTy = cast<FunctionType>(Ty);
     Result = calcTypeName(FTy->getReturnType(), TypeStack, TypeNames) + " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Result += ", ";
       Result += calcTypeName(*I, TypeStack, TypeNames);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Result += ", ";
+      if (FTy->getNumParams()) Result += ", ";
       Result += "...";
     }
     Result += ")";
@@ -517,15 +516,14 @@
 std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
   if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
     printType(FTy->getReturnType()) << " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Out << ", ";
       printType(*I);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Out << ", ";
+      if (FTy->getNumParams()) Out << ", ";
       Out << "...";
     }
     Out << ")";
@@ -689,7 +687,7 @@
 
   // Finish printing arguments...
   if (FT->isVarArg()) {
-    if (FT->getParamTypes().size()) Out << ", ";
+    if (FT->getNumParams()) Out << ", ";
     Out << "...";  // Output varargs portion of signature!
   }
   Out << ")";


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.87 llvm/lib/VMCore/Type.cpp:1.88
--- llvm/lib/VMCore/Type.cpp:1.87	Tue Dec 30 21:19:37 2003
+++ llvm/lib/VMCore/Type.cpp	Sun Feb  8 22:14:01 2004
@@ -190,15 +190,14 @@
   case Type::FunctionTyID: {
     const FunctionType *FTy = cast<FunctionType>(Ty);
     Result = getTypeDescription(FTy->getReturnType(), TypeStack) + " (";
-    for (FunctionType::ParamTypes::const_iterator
-           I = FTy->getParamTypes().begin(),
-           E = FTy->getParamTypes().end(); I != E; ++I) {
-      if (I != FTy->getParamTypes().begin())
+    for (FunctionType::param_iterator I = FTy->param_begin(),
+           E = FTy->param_end(); I != E; ++I) {
+      if (I != FTy->param_begin())
         Result += ", ";
       Result += getTypeDescription(*I, TypeStack);
     }
     if (FTy->isVarArg()) {
-      if (!FTy->getParamTypes().empty()) Result += ", ";
+      if (FTy->getNumParams()) Result += ", ";
       Result += "...";
     }
     Result += ")";
@@ -528,13 +527,11 @@
   } else if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
     const FunctionType *FTy2 = cast<FunctionType>(Ty2);
     if (FTy->isVarArg() != FTy2->isVarArg() ||
-        FTy->getParamTypes().size() != FTy2->getParamTypes().size() ||
+        FTy->getNumParams() != FTy2->getNumParams() ||
         !TypesEqual(FTy->getReturnType(), FTy2->getReturnType(), EqTypes))
       return false;
-    const FunctionType::ParamTypes &FTyP = FTy->getParamTypes();
-    const FunctionType::ParamTypes &FTy2P = FTy2->getParamTypes();
-    for (unsigned i = 0, e = FTyP.size(); i != e; ++i)
-      if (!TypesEqual(FTyP[i], FTy2P[i], EqTypes))
+    for (unsigned i = 0, e = FTy2->getNumParams(); i != e; ++i)
+      if (!TypesEqual(FTy->getParamType(i), FTy2->getParamType(i), EqTypes))
         return false;
     return true;
   } else {
@@ -736,8 +733,8 @@
 FunctionValType FunctionValType::get(const FunctionType *FT) {
   // Build up a FunctionValType
   std::vector<const Type *> ParamTypes;
-  ParamTypes.reserve(FT->getParamTypes().size());
-  for (unsigned i = 0, e = FT->getParamTypes().size(); i != e; ++i)
+  ParamTypes.reserve(FT->getNumParams());
+  for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
     ParamTypes.push_back(FT->getParamType(i));
   return FunctionValType(FT->getReturnType(), ParamTypes, FT->isVarArg());
 }


Index: llvm/lib/VMCore/iCall.cpp
diff -u llvm/lib/VMCore/iCall.cpp:1.22 llvm/lib/VMCore/iCall.cpp:1.23
--- llvm/lib/VMCore/iCall.cpp:1.22	Thu Nov 20 11:45:12 2003
+++ llvm/lib/VMCore/iCall.cpp	Sun Feb  8 22:14:01 2004
@@ -31,14 +31,13 @@
   Operands.reserve(1+params.size());
   Operands.push_back(Use(Func, this));
 
-  const FunctionType *MTy = 
+  const FunctionType *FTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(params.size() == PL.size() || 
-	 (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == FTy->getNumParams() || 
+          (FTy->isVarArg() && params.size() > FTy->getNumParams())) &&
 	 "Calling a function with bad signature");
-  for (unsigned i = 0; i < params.size(); i++)
+  for (unsigned i = 0; i != params.size(); i++)
     Operands.push_back(Use(params[i], this));
 }
 
@@ -53,8 +52,7 @@
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(PL.empty() && "Calling a function with bad signature");
+  assert(MTy->getNumParams() == 0 && "Calling a function with bad signature");
 }
 
 CallInst::CallInst(Value *Func, Value* A, const std::string &Name,
@@ -68,8 +66,8 @@
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert(PL.size() == 1 || (MTy->isVarArg() && PL.empty()) &&
+  assert((MTy->getNumParams() == 1 ||
+          (MTy->isVarArg() && MTy->getNumParams() == 0)) &&
 	 "Calling a function with bad signature");
   Operands.push_back(Use(A, this));
 }
@@ -115,9 +113,8 @@
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
   
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert((params.size() == PL.size()) || 
-	 (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == MTy->getNumParams()) || 
+	 (MTy->isVarArg() && params.size() > MTy->getNumParams()) &&
 	 "Calling a function with bad signature");
   
   for (unsigned i = 0; i < params.size(); i++)
@@ -138,9 +135,8 @@
   const FunctionType *MTy = 
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
   
-  const FunctionType::ParamTypes &PL = MTy->getParamTypes();
-  assert((params.size() == PL.size()) || 
-	 (MTy->isVarArg() && params.size() > PL.size()) &&
+  assert((params.size() == MTy->getNumParams()) || 
+	 (MTy->isVarArg() && params.size() > MTy->getNumParams()) &&
 	 "Calling a function with bad signature");
   
   for (unsigned i = 0; i < params.size(); i++)





More information about the llvm-commits mailing list