[PATCH] D16942: Add C binding for AllocaInst::getAllocatedType
Amaury SECHET via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 18:43:39 PST 2016
deadalnix created this revision.
deadalnix added reviewers: bogner, chandlerc, echristo, dblaikie, joker.eph, Wallbraker.
deadalnix added a subscriber: llvm-commits.
deadalnix added a dependency: D16912: Improve the C API echo test tool to emit basic block is the right order..
Comes with an awesome test.
Depends on D16912
http://reviews.llvm.org/D16942
Files:
include/llvm-c/Core.h
lib/IR/Core.cpp
tools/llvm-c-test/echo.cpp
Index: tools/llvm-c-test/echo.cpp
===================================================================
--- tools/llvm-c-test/echo.cpp
+++ tools/llvm-c-test/echo.cpp
@@ -306,8 +306,8 @@
break;
}
case LLVMAlloca: {
- // TODO: Add a binding for AllocaInst::getAllocatedType
- LLVMTypeRef Ty = LLVMGetElementType(LLVMTypeOf(Src));
+ LLVMContextRef Ctx = LLVMGetModuleContext(get_module(Builder));
+ LLVMTypeRef Ty = clone_type(LLVMGetAllocatedType(Src), Ctx);
Dst = LLVMBuildAlloca(Builder, Ty, Name);
break;
}
Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -2134,6 +2134,12 @@
return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
}
+/*--.. Operations on alloca instructions (only) ............................--*/
+
+LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca) {
+ return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
+}
+
/*--.. Operations on phi nodes .............................................--*/
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -2506,6 +2506,24 @@
*/
/**
+ * @defgroup LLVMCCoreValueInstructionAlloca Allocas
+ *
+ * Functions in this group only apply to instructions that map to
+ * llvm::Alloca instances.
+ *
+ * @{
+ */
+
+/**
+ * Obtain the type that is being allocated by the alloca instruction.
+ */
+LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
+
+/**
+ * @}
+ */
+
+/**
* @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
*
* Functions in this group only apply to instructions that map to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16942.47072.patch
Type: text/x-patch
Size: 1817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160206/3c07f671/attachment.bin>
More information about the llvm-commits
mailing list