summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRobert Widmann <devteam.codafi@gmail.com>2019-02-05 18:05:44 +0000
committerRobert Widmann <devteam.codafi@gmail.com>2019-02-05 18:05:44 +0000
commitd5444ccf17cb016779c6ace75e41826173497361 (patch)
treea0db02f9c042adf60bb9baf0cf9a738610d5575f /llvm/lib
parentb26134bf9213d50a506b33803a3410b812f9470a (diff)
downloadbcm5719-llvm-d5444ccf17cb016779c6ace75e41826173497361.tar.gz
bcm5719-llvm-d5444ccf17cb016779c6ace75e41826173497361.zip
[LLVM-C] Add Bindings to GlobalIFunc
Summary: Adds the standard gauntlet of accessors for global indirect functions and updates the echo test. Now it would be nice to have a target abstraction so one could know if they have access to a suitable ELF linker and runtime. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56177 llvm-svn: 353193
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Core.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 21711780af5..1b8ad4823f9 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2463,6 +2463,71 @@ void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
A->addAttr(Attribute::getWithAlignment(A->getContext(), align));
}
+/*--.. Operations on ifuncs ................................................--*/
+
+LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
+ const char *Name, size_t NameLen,
+ LLVMTypeRef Ty, unsigned AddrSpace,
+ LLVMValueRef Resolver) {
+ return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
+ GlobalValue::ExternalLinkage,
+ StringRef(Name, NameLen),
+ unwrap<Constant>(Resolver), unwrap(M)));
+}
+
+LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
+ const char *Name, size_t NameLen) {
+ return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
+}
+
+LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M) {
+ Module *Mod = unwrap(M);
+ Module::ifunc_iterator I = Mod->ifunc_begin();
+ if (I == Mod->ifunc_end())
+ return nullptr;
+ return wrap(&*I);
+}
+
+LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M) {
+ Module *Mod = unwrap(M);
+ Module::ifunc_iterator I = Mod->ifunc_end();
+ if (I == Mod->ifunc_begin())
+ return nullptr;
+ return wrap(&*--I);
+}
+
+LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc) {
+ GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
+ Module::ifunc_iterator I(GIF);
+ if (++I == GIF->getParent()->ifunc_end())
+ return nullptr;
+ return wrap(&*I);
+}
+
+LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc) {
+ GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
+ Module::ifunc_iterator I(GIF);
+ if (I == GIF->getParent()->ifunc_begin())
+ return nullptr;
+ return wrap(&*--I);
+}
+
+LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc) {
+ return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
+}
+
+void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver) {
+ unwrap<GlobalIFunc>(IFunc)->setResolver(unwrap<Constant>(Resolver));
+}
+
+void LLVMEraseGlobalIFunc(LLVMValueRef IFunc) {
+ unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
+}
+
+void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc) {
+ unwrap<GlobalIFunc>(IFunc)->removeFromParent();
+}
+
/*--.. Operations on basic blocks ..........................................--*/
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
OpenPOWER on IntegriCloud