From 64090bd2d468ec70b9644bdf492684dd278de8a7 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 14 Jul 2011 19:09:08 +0000 Subject: [PATCH] Add LLVMConstNamedStruct to the C api to let its users create constants of named struct types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135178 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 3 +++ lib/VMCore/Core.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index fc33ab7f824..a4456dd13e4 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -565,6 +565,9 @@ LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length); LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed); +LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, + LLVMValueRef *ConstantVals, + unsigned Count); LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); /* Constant expressions */ diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index b59f6c78c52..f5bec303a4e 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -595,6 +595,16 @@ LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count, Packed); } + +LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, + LLVMValueRef *ConstantVals, + unsigned Count) { + Constant **Elements = unwrap(ConstantVals, Count); + const StructType *Ty = cast(unwrap(StructTy)); + + return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count))); +} + LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) { return wrap(ConstantVector::get(ArrayRef( unwrap(ScalarConstantVals, Size), Size))); -- 2.34.1