From eed37bad011c8d3843611ecabfaf279eebf68a02 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 30 Apr 2005 03:44:07 +0000 Subject: [PATCH] Add llvm.sqrt intrinsic, patch contributed by Morten Ofstad git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21627 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Intrinsics.h | 1 + lib/Analysis/BasicAliasAnalysis.cpp | 2 +- lib/VMCore/Function.cpp | 1 + lib/VMCore/Verifier.cpp | 10 ++++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/llvm/Intrinsics.h b/include/llvm/Intrinsics.h index 569f80a187e..7acd5ca71a3 100644 --- a/include/llvm/Intrinsics.h +++ b/include/llvm/Intrinsics.h @@ -63,6 +63,7 @@ namespace Intrinsic { // libm related functions. isunordered, // Return true if either argument is a NaN + sqrt, // Input/Output intrinsics. readport, diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 7d9e21cb94c..21c6543f754 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -702,7 +702,7 @@ namespace { static const char *DoesntAccessMemoryTable[] = { // LLVM intrinsics: "llvm.frameaddress", "llvm.returnaddress", "llvm.readport", - "llvm.isunordered", + "llvm.isunordered", "llvm.sqrt", "abs", "labs", "llabs", "imaxabs", "fabs", "fabsf", "fabsl", "trunc", "truncf", "truncl", "ldexp", diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 2672e892c74..6740c6bbb0d 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -245,6 +245,7 @@ unsigned Function::getIntrinsicID() const { if (getName() == "llvm.setjmp") return Intrinsic::setjmp; if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp; if (getName() == "llvm.siglongjmp") return Intrinsic::siglongjmp; + if (getName() == "llvm.sqrt") return Intrinsic::sqrt; break; case 'v': if (getName() == "llvm.va_copy") return Intrinsic::vacopy; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index da14c00065e..d7b8f509621 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -723,6 +723,16 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { NumArgs = 2; break; + case Intrinsic::sqrt: + 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->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; -- 2.34.1