Use the autogenerated intrinsic verifier

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-03-09 22:06:04 +00:00
parent f97a00e681
commit 3b816b7aa7

View File

@ -676,273 +676,12 @@ void Verifier::visitInstruction(Instruction &I) {
///
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
}