[llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Mar 9 14:06:16 PST 2006



Changes in directory llvm/lib/VMCore:

Verifier.cpp updated: 1.149 -> 1.150
---
Log message:

Use the autogenerated intrinsic verifier


---
Diffs of the changes:  (+5 -266)

 Verifier.cpp |  271 +----------------------------------------------------------
 1 files changed, 5 insertions(+), 266 deletions(-)


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.149 llvm/lib/VMCore/Verifier.cpp:1.150
--- llvm/lib/VMCore/Verifier.cpp:1.149	Thu Mar  9 14:01:50 2006
+++ llvm/lib/VMCore/Verifier.cpp	Thu Mar  9 16:06:04 2006
@@ -676,273 +676,12 @@
 ///
 void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
   Function *IF = CI.getCalledFunction();
-  const FunctionType *FT = IF->getFunctionType();
+  const FunctionType *FTy = IF->getFunctionType();
   Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF);
-  unsigned NumArgs = 0;
-
-  // FIXME: this should check the return type of each intrinsic as well, also
-  // arguments!
-  switch (ID) {
-  case Intrinsic::vastart:
-    Assert1(CI.getParent()->getParent()->getFunctionType()->isVarArg(),
-            "llvm.va_start intrinsic may only occur in function with variable"
-            " args!", &CI);
-    NumArgs = 1;
-    break;
-  case Intrinsic::vaend:          NumArgs = 1; break;
-  case Intrinsic::vacopy:         NumArgs = 2; break;
-
-  case Intrinsic::returnaddress:
-  case Intrinsic::frameaddress:
-    Assert1(isa<PointerType>(FT->getReturnType()),
-            "llvm.(frame|return)address must return pointers", IF);
-    Assert1(FT->getNumParams() == 1 && isa<ConstantInt>(CI.getOperand(1)),
-       "llvm.(frame|return)address require a single constant integer argument",
-            &CI);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::isunordered_f32:
-    Assert1(FT->getNumParams() == 2,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == Type::BoolTy,
-            "Return type is not bool!", IF);
-    Assert1(FT->getParamType(0) == FT->getParamType(1),
-            "Arguments must be of the same type!", IF);
-    Assert1(FT->getParamType(0) == Type::FloatTy,
-            "Arguments must be a 32-bit floating point type!", IF);
-    NumArgs = 2;
-    break;
-
-  case Intrinsic::isunordered_f64:
-    Assert1(FT->getNumParams() == 2,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == Type::BoolTy,
-            "Return type is not bool!", IF);
-    Assert1(FT->getParamType(0) == FT->getParamType(1),
-            "Arguments must be of the same type!", IF);
-    Assert1(FT->getParamType(0) == Type::DoubleTy,
-            "Argument is not a 64-bit floating point type!", IF);
-    NumArgs = 2;
-    break;
-
-  case Intrinsic::readcyclecounter:
-    Assert1(FT->getNumParams() == 0,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == Type::ULongTy,
-            "Return type is not ulong!", IF);
-    NumArgs = 0;
-    break;
-
-  case Intrinsic::bswap_i16:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getReturnType() == Type::UShortTy,
-            "Return type is not ushort!", IF);
-    NumArgs = 1;
-    break;    
-
-  case Intrinsic::bswap_i32:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getReturnType() == Type::UIntTy,
-            "Return type is not uint!", IF);
-    NumArgs = 1;
-    break;    
-
-  case Intrinsic::bswap_i64:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getReturnType() == Type::ULongTy,
-            "Return type is not ulong!", IF);
-    NumArgs = 1;
-    break;    
-    
-  case Intrinsic::ctpop_i8:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UByteTy,
-            "Argument is not ubyte!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::ctpop_i16:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UShortTy,
-            "Argument is not ushort!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::ctpop_i32:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UIntTy, "Argument is not uint!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::ctpop_i64:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::ULongTy, "Argument is not ulong!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::ctlz_i8:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UByteTy, "Argument is not ubyte!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::ctlz_i16:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UShortTy,
-            "Argument is not ushort!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::ctlz_i32:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UIntTy, "Argument is not uint!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::ctlz_i64:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::ULongTy, "Argument is not ulong!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::cttz_i8:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UByteTy, "Argument is not ubyte!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::cttz_i16:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UShortTy,
-            "Argument is not ushort!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::cttz_i32:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::UIntTy, "Argument is not uint!", IF);
-    NumArgs = 1;
-    break;
-  case Intrinsic::cttz_i64:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type does not match source type", IF);
-    Assert1(FT->getParamType(0) == Type::ULongTy, "Argument Is not ulong!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::sqrt_f32:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getParamType(0) == Type::FloatTy,
-            "Argument is not a 32-bit floating point type!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type is not the same as argument type!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::sqrt_f64:
-    Assert1(FT->getNumParams() == 1,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(FT->getParamType(0) == Type::DoubleTy,
-            "Argument is not a 64-bit floating point type!", IF);
-    Assert1(FT->getReturnType() == FT->getParamType(0),
-            "Return type is not the same as argument type!", IF);
-    NumArgs = 1;
-    break;
-
-  case Intrinsic::setjmp:          NumArgs = 1; break;
-  case Intrinsic::longjmp:         NumArgs = 2; break;
-  case Intrinsic::sigsetjmp:       NumArgs = 2; break;
-  case Intrinsic::siglongjmp:      NumArgs = 2; break;
-
-  case Intrinsic::gcroot:
-    Assert1(FT->getNumParams() == 2,
-            "Illegal # arguments for intrinsic function!", IF);
-    Assert1(isa<Constant>(CI.getOperand(2)),
-            "Second argument to llvm.gcroot must be a constant!", &CI);
-    NumArgs = 2;
-    break;
-  case Intrinsic::gcread:          NumArgs = 2; break;
-  case Intrinsic::gcwrite:         NumArgs = 3; break;
-
-  case Intrinsic::dbg_stoppoint:   NumArgs = 4; break;
-  case Intrinsic::dbg_region_start:NumArgs = 1; break;
-  case Intrinsic::dbg_region_end:  NumArgs = 1; break;
-  case Intrinsic::dbg_func_start:  NumArgs = 1; break;
-
-  case Intrinsic::memcpy_i32:      NumArgs = 4; break;
-  case Intrinsic::memcpy_i64:      NumArgs = 4; break;
-  case Intrinsic::memmove_i32:     NumArgs = 4; break;
-  case Intrinsic::memmove_i64:     NumArgs = 4; break;
-  case Intrinsic::memset_i32:      NumArgs = 4; break;
-  case Intrinsic::memset_i64:      NumArgs = 4; break;
-
-  case Intrinsic::stacksave:
-    NumArgs = 0;
-    Assert1(CI.getType() == PointerType::get(Type::SByteTy),
-            "llvm.stacksave must return an sbyte*", &CI);
-    break;
-  case Intrinsic::stackrestore:
-    NumArgs = 1;
-    Assert1(CI.getOperand(1)->getType() == PointerType::get(Type::SByteTy),
-            "llvm.stackrestore must take an sbyte*", &CI);
-    Assert1(CI.getType() == Type::VoidTy,
-            "llvm.stackrestore return void", &CI);
-    break;
-  case Intrinsic::prefetch:        NumArgs = 3; break;
-  case Intrinsic::pcmarker:
-    NumArgs = 1;
-    Assert1(isa<Constant>(CI.getOperand(1)),
-            "First argument to llvm.pcmarker must be a constant!", &CI);
-    break;
-
-  case Intrinsic::not_intrinsic:
-    assert(0 && "Invalid intrinsic!"); NumArgs = 0; break;
-  }
-
-  Assert1(FT->getNumParams() == NumArgs || (FT->getNumParams() < NumArgs &&
-                                             FT->isVarArg()),
-          "Illegal # arguments for intrinsic function!", IF);
+  
+#define GET_INTRINSIC_VERIFIER
+#include "llvm/Intrinsics.gen"
+#undef GET_INTRINSIC_VERIFIER
 }
 
 






More information about the llvm-commits mailing list