From: Robert Widmann Date: Mon, 25 Mar 2019 20:58:58 +0000 (+0000) Subject: [LLVM-C] Add binding to look up intrinsic by name X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45fd445aa04d9269a51c4aa9753f175621a72229;p=llvm [LLVM-C] Add binding to look up intrinsic by name Summary: Add a binding to Function::lookupIntrinsicID so clients don't have to go searching the ID table themselves. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59697 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356948 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 9c521899c95..393250f7f8c 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -2402,6 +2402,13 @@ LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); */ void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn); +/** + * Obtain the intrinsic ID number which matches the given function name. + * + * @see llvm::Function::lookupIntrinsicID() + */ +unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen); + /** * Obtain the ID number from a function instance. * diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 1b8ad4823f9..aa6bc542b4e 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -2329,6 +2329,10 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID, return strdup(Str.c_str()); } +unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) { + return Function::lookupIntrinsicID({Name, NameLen}); +} + LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID) { auto IID = llvm_map_to_intrinsic_id(ID); return llvm::Intrinsic::isOverloaded(IID);