diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-03-23 22:21:29 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-03-23 22:21:29 +0000 |
commit | 4733be38930ae81716bba9ae75a8281bcb180634 (patch) | |
tree | 1bc1e3c5aedcb104095cf8486ba6b0a52369362b /lib/VMCore/Core.cpp | |
parent | 82818eb2234fae36d6f2ba25a88839ddc6d3dd14 (diff) | |
download | external_llvm-4733be38930ae81716bba9ae75a8281bcb180634.zip external_llvm-4733be38930ae81716bba9ae75a8281bcb180634.tar.gz external_llvm-4733be38930ae81716bba9ae75a8281bcb180634.tar.bz2 |
Objective Caml bindings for basic block, function, global, and arg iterators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Core.cpp')
-rw-r--r-- | lib/VMCore/Core.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index ac7738b..59b9b1a 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -628,7 +628,7 @@ LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar) { LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar) { GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar); Module::global_iterator I = GV; - if (I == GV->getParent()->global_end()) + if (I == GV->getParent()->global_begin()) return 0; return wrap(--I); } @@ -705,7 +705,7 @@ LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn) { LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn) { Function *Func = unwrap<Function>(Fn); Module::iterator I = Func; - if (I == Func->getParent()->end()) + if (I == Func->getParent()->begin()) return 0; return wrap(--I); } @@ -767,6 +767,38 @@ LLVMValueRef LLVMGetParamParent(LLVMValueRef V) { return wrap(unwrap<Argument>(V)->getParent()); } +LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn) { + Function *Func = unwrap<Function>(Fn); + Function::arg_iterator I = Func->arg_begin(); + if (I == Func->arg_end()) + return 0; + return wrap(I); +} + +LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn) { + Function *Func = unwrap<Function>(Fn); + Function::arg_iterator I = Func->arg_end(); + if (I == Func->arg_begin()) + return 0; + return wrap(--I); +} + +LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg) { + Argument *A = unwrap<Argument>(Arg); + Function::arg_iterator I = A; + if (++I == A->getParent()->arg_end()) + return 0; + return wrap(I); +} + +LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg) { + Argument *A = unwrap<Argument>(Arg); + Function::arg_iterator I = A; + if (I == A->getParent()->arg_begin()) + return 0; + return wrap(--I); +} + /*--.. Operations on basic blocks ..........................................--*/ LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) { @@ -781,8 +813,8 @@ LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val) { return wrap(unwrap<BasicBlock>(Val)); } -LLVMValueRef LLVMGetBasicBlockParent(LLVMValueRef V) { - return wrap(unwrap<BasicBlock>(V)->getParent()); +LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB) { + return wrap(unwrap(BB)->getParent()); } unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef) { |