From 3258c45d0fee21fc09ed7f5ae104a9c61ae4237a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 3 Nov 2008 22:55:43 +0000 Subject: [PATCH] Add C bindings for extractvalue and insertvalue. Patch by Frits van Bommel! llvm-svn: 58650 --- include/llvm-c/Core.h | 10 ++++++++++ lib/VMCore/Core.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index e00f0fba17b..ed301030b66 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -371,6 +371,11 @@ LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant); +LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, + unsigned NumIdx); +LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, + LLVMValueRef ElementValueConstant, + unsigned *IdxList, unsigned NumIdx); /* Operations on global variables, functions, and aliases (globals) */ LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); @@ -605,6 +610,11 @@ LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name); +LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, + unsigned Index, const char *Name); +LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, + LLVMValueRef EltVal, unsigned Index, + const char *Name); /*===-- Module providers --------------------------------------------------===*/ diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index afc1c905fc0..7d1fa12d230 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -541,6 +541,20 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, unwrap(MaskConstant))); } +LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, + unsigned NumIdx) { + return wrap(ConstantExpr::getExtractValue(unwrap(AggConstant), + IdxList, NumIdx)); +} + +LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, + LLVMValueRef ElementValueConstant, + unsigned *IdxList, unsigned NumIdx) { + return wrap(ConstantExpr::getInsertValue(unwrap(AggConstant), + unwrap(ElementValueConstant), + IdxList, NumIdx)); +} + /*--.. Operations on global variables, functions, and aliases (globals) ....--*/ LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global) { @@ -1326,6 +1340,18 @@ LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, unwrap(Mask), Name)); } +LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, + unsigned Index, const char *Name) { + return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name)); +} + +LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, + LLVMValueRef EltVal, unsigned Index, + const char *Name) { + return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal), + Index, Name)); +} + /*===-- Module providers --------------------------------------------------===*/