Changes in directory llvm/lib/VMCore:
Function.cpp updated: 1.99 -> 1.100 Verifier.cpp updated: 1.142 -> 1.143 --- Log message: For PR411: http://llvm.cs.uiuc.edu/PR411 : This patch is an incremental step towards supporting a flat symbol table. It de-overloads the intrinsic functions by providing type-specific intrinsics and arranging for automatically upgrading from the old overloaded name to the new non-overloaded name. Specifically: llvm.isunordered -> llvm.isunordered.f32, llvm.isunordered.f64 llvm.sqrt -> llvm.sqrt.f32, llvm.sqrt.f64 llvm.ctpop -> llvm.ctpop.i8, llvm.ctpop.i16, llvm.ctpop.i32, llvm.ctpop.i64 llvm.ctlz -> llvm.ctlz.i8, llvm.ctlz.i16, llvm.ctlz.i32, llvm.ctlz.i64 llvm.cttz -> llvm.cttz.i8, llvm.cttz.i16, llvm.cttz.i32, llvm.cttz.i64 New code should not use the overloaded intrinsic names. Warnings will be emitted if they are used. --- Diffs of the changes: (+205 -54) Function.cpp | 98 ++++++++++++++++++++--------------- Verifier.cpp | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 205 insertions(+), 54 deletions(-) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.99 llvm/lib/VMCore/Function.cpp:1.100 --- llvm/lib/VMCore/Function.cpp:1.99 Sun Jan 15 02:40:16 2006 +++ llvm/lib/VMCore/Function.cpp Mon Jan 16 15:12:35 2006 @@ -200,79 +200,93 @@ /// llvm/Intrinsics.h. /// unsigned Function::getIntrinsicID() const { - if (getName().size() < 5 || getName()[4] != '.' || getName()[0] != 'l' || - getName()[1] != 'l' || getName()[2] != 'v' || getName()[3] != 'm') + const std::string& Name = this->getName(); + if (Name.size() < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l' + || Name[2] != 'v' || Name[3] != 'm') return 0; // All intrinsics start with 'llvm.' - assert(getName().size() != 5 && "'llvm.' is an invalid intrinsic name!"); + assert(Name.size() != 5 && "'llvm.' is an invalid intrinsic name!"); - switch (getName()[5]) { + switch (Name[5]) { case 'b': - if (getName() == "llvm.bswap.i16") return Intrinsic::bswap_i16; - if (getName() == "llvm.bswap.i32") return Intrinsic::bswap_i32; - if (getName() == "llvm.bswap.i64") return Intrinsic::bswap_i64; + if (Name == "llvm.bswap.i16") return Intrinsic::bswap_i16; + if (Name == "llvm.bswap.i32") return Intrinsic::bswap_i32; + if (Name == "llvm.bswap.i64") return Intrinsic::bswap_i64; break; case 'c': - if (getName() == "llvm.ctpop") return Intrinsic::ctpop; - if (getName() == "llvm.cttz") return Intrinsic::cttz; - if (getName() == "llvm.ctlz") return Intrinsic::ctlz; + if (Name == "llvm.ctpop.i8") return Intrinsic::ctpop_i8; + if (Name == "llvm.ctpop.i16") return Intrinsic::ctpop_i16; + if (Name == "llvm.ctpop.i32") return Intrinsic::ctpop_i32; + if (Name == "llvm.ctpop.i64") return Intrinsic::ctpop_i64; + if (Name == "llvm.cttz.i8") return Intrinsic::cttz_i8; + if (Name == "llvm.cttz.i16") return Intrinsic::cttz_i16; + if (Name == "llvm.cttz.i32") return Intrinsic::cttz_i32; + if (Name == "llvm.cttz.i64") return Intrinsic::cttz_i64; + if (Name == "llvm.ctlz.i8") return Intrinsic::ctlz_i8; + if (Name == "llvm.ctlz.i16") return Intrinsic::ctlz_i16; + if (Name == "llvm.ctlz.i32") return Intrinsic::ctlz_i32; + if (Name == "llvm.ctlz.i64") return Intrinsic::ctlz_i64; break; case 'd': - if (getName() == "llvm.dbg.stoppoint") return Intrinsic::dbg_stoppoint; - if (getName() == "llvm.dbg.region.start")return Intrinsic::dbg_region_start; - if (getName() == "llvm.dbg.region.end") return Intrinsic::dbg_region_end; - if (getName() == "llvm.dbg.func.start") return Intrinsic::dbg_func_start; - if (getName() == "llvm.dbg.declare") return Intrinsic::dbg_declare; + if (Name == "llvm.dbg.stoppoint") return Intrinsic::dbg_stoppoint; + if (Name == "llvm.dbg.region.start")return Intrinsic::dbg_region_start; + if (Name == "llvm.dbg.region.end") return Intrinsic::dbg_region_end; + if (Name == "llvm.dbg.func.start") return Intrinsic::dbg_func_start; + if (Name == "llvm.dbg.declare") return Intrinsic::dbg_declare; break; case 'f': - if (getName() == "llvm.frameaddress") return Intrinsic::frameaddress; + if (Name == "llvm.frameaddress") return Intrinsic::frameaddress; break; case 'g': - if (getName() == "llvm.gcwrite") return Intrinsic::gcwrite; - if (getName() == "llvm.gcread") return Intrinsic::gcread; - if (getName() == "llvm.gcroot") return Intrinsic::gcroot; + if (Name == "llvm.gcwrite") return Intrinsic::gcwrite; + if (Name == "llvm.gcread") return Intrinsic::gcread; + if (Name == "llvm.gcroot") return Intrinsic::gcroot; break; case 'i': - if (getName() == "llvm.isunordered") return Intrinsic::isunordered; + if (Name == "llvm.isunordered.f32") + return Intrinsic::isunordered_f32; + if (Name == "llvm.isunordered.f64") + return Intrinsic::isunordered_f64; break; case 'l': - if (getName() == "llvm.longjmp") return Intrinsic::longjmp; + if (Name == "llvm.longjmp") return Intrinsic::longjmp; break; case 'm': - if (getName() == "llvm.memcpy") return Intrinsic::memcpy; - if (getName() == "llvm.memmove") return Intrinsic::memmove; - if (getName() == "llvm.memset") return Intrinsic::memset; + if (Name == "llvm.memcpy") return Intrinsic::memcpy; + if (Name == "llvm.memmove") return Intrinsic::memmove; + if (Name == "llvm.memset") return Intrinsic::memset; break; case 'p': - if (getName() == "llvm.prefetch") return Intrinsic::prefetch; - if (getName() == "llvm.pcmarker") return Intrinsic::pcmarker; + if (Name == "llvm.prefetch") return Intrinsic::prefetch; + if (Name == "llvm.pcmarker") return Intrinsic::pcmarker; break; case 'r': - if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress; - if (getName() == "llvm.readport") return Intrinsic::readport; - if (getName() == "llvm.readio") return Intrinsic::readio; - if (getName() == "llvm.readcyclecounter") return Intrinsic::readcyclecounter; + if (Name == "llvm.returnaddress") return Intrinsic::returnaddress; + if (Name == "llvm.readport") return Intrinsic::readport; + if (Name == "llvm.readio") return Intrinsic::readio; + if (Name == "llvm.readcyclecounter") return Intrinsic::readcyclecounter; break; case 's': - if (getName() == "llvm.setjmp") return Intrinsic::setjmp; - if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp; - if (getName() == "llvm.siglongjmp") return Intrinsic::siglongjmp; - if (getName() == "llvm.stackrestore") return Intrinsic::stackrestore; - if (getName() == "llvm.stacksave") return Intrinsic::stacksave; - if (getName() == "llvm.sqrt") return Intrinsic::sqrt; + if (Name == "llvm.setjmp") return Intrinsic::setjmp; + if (Name == "llvm.sigsetjmp") return Intrinsic::sigsetjmp; + if (Name == "llvm.siglongjmp") return Intrinsic::siglongjmp; + if (Name == "llvm.stackrestore") return Intrinsic::stackrestore; + if (Name == "llvm.stacksave") return Intrinsic::stacksave; + if (Name == "llvm.sqrt.f32") return Intrinsic::sqrt_f32; + if (Name == "llvm.sqrt.f64") return Intrinsic::sqrt_f64; break; case 'v': - if (getName() == "llvm.va_copy") return Intrinsic::vacopy; - if (getName() == "llvm.va_end") return Intrinsic::vaend; - if (getName() == "llvm.va_start") return Intrinsic::vastart; + if (Name == "llvm.va_copy") return Intrinsic::vacopy; + if (Name == "llvm.va_end") return Intrinsic::vaend; + if (Name == "llvm.va_start") return Intrinsic::vastart; break; case 'w': - if (getName() == "llvm.writeport") return Intrinsic::writeport; - if (getName() == "llvm.writeio") return Intrinsic::writeio; + if (Name == "llvm.writeport") return Intrinsic::writeport; + if (Name == "llvm.writeio") return Intrinsic::writeio; break; } // The "llvm." namespace is reserved! - assert(0 && "Unknown LLVM intrinsic function!"); + assert(!"Unknown LLVM intrinsic function!"); return 0; } Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.142 llvm/lib/VMCore/Verifier.cpp:1.143 --- llvm/lib/VMCore/Verifier.cpp:1.142 Sun Jan 15 15:58:50 2006 +++ llvm/lib/VMCore/Verifier.cpp Mon Jan 16 15:12:35 2006 @@ -128,7 +128,8 @@ if (I->isExternal()) visitFunction(*I); } - for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) + for (Module::global_iterator I = M.global_begin(), E = M.global_end(); + I != E; ++I) visitGlobalVariable(*I); // If the module is broken, abort at this time. @@ -729,15 +730,27 @@ break; } - case Intrinsic::isunordered: + 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)->isFloatingPoint(), - "Argument is not a floating point 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; @@ -779,23 +792,147 @@ NumArgs = 1; break; - case Intrinsic::ctpop: - case Intrinsic::ctlz: - case Intrinsic::cttz: + 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)->isIntegral(), - "Argument must be of an int type!", IF); + Assert1(FT->getParamType(0) == Type::UByteTy + || FT->getParamType(0) == Type::SByteTy, + "Argument must be a byte type!", 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 + || FT->getParamType(0) == Type::ShortTy, + "Argument must be a short type!", 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 + || FT->getParamType(0) == Type::IntTy, + "Argument must be an int type!", 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 + || FT->getParamType(0) == Type::LongTy, + "Argument must be a long type!", 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 + || FT->getParamType(0) == Type::SByteTy, + "Argument must be a byte type!", 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 + || FT->getParamType(0) == Type::ShortTy, + "Argument must be a short type!", 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 + || FT->getParamType(0) == Type::IntTy, + "Argument must be an int type!", 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 + || FT->getParamType(0) == Type::LongTy, + "Argument must be a long type!", 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 + || FT->getParamType(0) == Type::SByteTy, + "Argument must be a byte type!", 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 + || FT->getParamType(0) == Type::ShortTy, + "Argument must be a short type!", 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 + || FT->getParamType(0) == Type::IntTy, + "Argument must be an int type!", 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 + || FT->getParamType(0) == Type::LongTy, + "Argument must be a long type!", 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: + case Intrinsic::sqrt_f64: Assert1(FT->getNumParams() == 1, "Illegal # arguments for intrinsic function!", IF); - Assert1(FT->getParamType(0)->isFloatingPoint(), - "Argument is not a floating point type!", 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; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits