aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGordon Henriksen <gordonhenriksen@mac.com>2008-03-19 01:11:35 +0000
committerGordon Henriksen <gordonhenriksen@mac.com>2008-03-19 01:11:35 +0000
commitdc1ce7bdc6e32e7a4c4a110caa32834730183c1b (patch)
tree9844c6c709f7e226211ac1b0178257a29780f262 /lib
parent94202018c51d662c793a77a5e8239f3a35e11e60 (diff)
downloadexternal_llvm-dc1ce7bdc6e32e7a4c4a110caa32834730183c1b.zip
external_llvm-dc1ce7bdc6e32e7a4c4a110caa32834730183c1b.tar.gz
external_llvm-dc1ce7bdc6e32e7a4c4a110caa32834730183c1b.tar.bz2
C and Objective Caml bindings for the various getParent methods of the IR.
Based on Erick Tryzelaar's patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48523 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Core.cpp70
1 files changed, 47 insertions, 23 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 665f0ac..a44f96d 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -215,7 +215,7 @@ LLVMTypeRef LLVMOpaqueType() {
return wrap(llvm::OpaqueType::get());
}
-/* Operations on type handles */
+/*--.. Operations on type handles ..........................................--*/
LLVMTypeHandleRef LLVMCreateTypeHandle(LLVMTypeRef PotentiallyAbstractTy) {
return wrap(new PATypeHolder(unwrap(PotentiallyAbstractTy)));
@@ -546,6 +546,10 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
+LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global) {
+ return wrap(unwrap<GlobalValue>(Global)->getParent());
+}
+
int LLVMIsDeclaration(LLVMValueRef Global) {
return unwrap<GlobalValue>(Global)->isDeclaration();
}
@@ -646,26 +650,6 @@ void LLVMDeleteFunction(LLVMValueRef Fn) {
unwrap<Function>(Fn)->eraseFromParent();
}
-unsigned LLVMCountParams(LLVMValueRef FnRef) {
- // This function is strictly redundant to
- // LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(FnRef)))
- return unwrap<Function>(FnRef)->getArgumentList().size();
-}
-
-LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
- Function::arg_iterator AI = unwrap<Function>(FnRef)->arg_begin();
- while (index --> 0)
- AI++;
- return wrap(AI);
-}
-
-void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
- Function *Fn = unwrap<Function>(FnRef);
- for (Function::arg_iterator I = Fn->arg_begin(),
- E = Fn->arg_end(); I != E; I++)
- *ParamRefs++ = wrap(I);
-}
-
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn) {
if (Function *F = dyn_cast<Function>(unwrap(Fn)))
return F->getIntrinsicID();
@@ -693,10 +677,36 @@ void LLVMSetCollector(LLVMValueRef Fn, const char *Coll) {
F->clearCollector();
}
+/*--.. Operations on parameters ............................................--*/
+
+unsigned LLVMCountParams(LLVMValueRef FnRef) {
+ // This function is strictly redundant to
+ // LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(FnRef)))
+ return unwrap<Function>(FnRef)->getArgumentList().size();
+}
+
+void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
+ Function *Fn = unwrap<Function>(FnRef);
+ for (Function::arg_iterator I = Fn->arg_begin(),
+ E = Fn->arg_end(); I != E; I++)
+ *ParamRefs++ = wrap(I);
+}
+
+LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
+ Function::arg_iterator AI = unwrap<Function>(FnRef)->arg_begin();
+ while (index --> 0)
+ AI++;
+ return wrap(AI);
+}
+
+LLVMValueRef LLVMGetParamParent(LLVMValueRef V) {
+ return wrap(unwrap<Argument>(V)->getParent());
+}
+
/*--.. Operations on basic blocks ..........................................--*/
-LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb) {
- return wrap(static_cast<Value*>(unwrap(Bb)));
+LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB) {
+ return wrap(static_cast<Value*>(unwrap(BB)));
}
int LLVMValueIsBasicBlock(LLVMValueRef Val) {
@@ -707,6 +717,10 @@ LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val) {
return wrap(unwrap<BasicBlock>(Val));
}
+LLVMValueRef LLVMGetBasicBlockParent(LLVMValueRef V) {
+ return wrap(unwrap<BasicBlock>(V)->getParent());
+}
+
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef) {
return unwrap<Function>(FnRef)->getBasicBlockList().size();
}
@@ -736,6 +750,12 @@ void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef) {
unwrap(BBRef)->eraseFromParent();
}
+/*--.. Operations on instructions ..........................................--*/
+
+LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst) {
+ return wrap(unwrap<Instruction>(Inst)->getParent());
+}
+
/*--.. Call and invoke instructions ........................................--*/
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {
@@ -795,6 +815,10 @@ void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block) {
unwrap(Builder)->SetInsertPoint(BB);
}
+LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder) {
+ return wrap(unwrap(Builder)->GetInsertBlock());
+}
+
void LLVMDisposeBuilder(LLVMBuilderRef Builder) {
delete unwrap(Builder);
}