[llvm-commits] Patch to add set/get of AllocaInst alignment to the C bindings

Antony Hosking hosking at cs.purdue.edu
Mon Oct 1 10:58:53 PDT 2012


Sorry, yes, should be:

Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h       (revision 164945)
+++ include/llvm-c/Core.h       (working copy)
@@ -2431,6 +2431,9 @@
 LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
 void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
 
+unsigned LLVMGetAllocaAlignment(LLVMValueRef Alloca);
+void LLVMSetAllocaAlignment(LLVMValueRef Alloca, unsigned Bytes);
+
 /* Casts */
 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
                             LLVMTypeRef DestTy, const char *Name);
Index: lib/VMCore/Core.cpp
===================================================================
--- lib/VMCore/Core.cpp (revision 164945)
+++ lib/VMCore/Core.cpp (working copy)
@@ -2112,6 +2112,14 @@
   return cast<StoreInst>(P)->setVolatile(isVolatile);
 }
 
+unsigned LLVMGetAllocaAlignment(LLVMValueRef Alloca) {
+  return unwrap<AllocaInst>(Alloca)->getAlignment();
+}
+
+void LLVMSetAllocaAlignment(LLVMValueRef Alloca, unsigned Bytes) {
+  unwrap<AllocaInst>(Alloca)->setAlignment(Bytes);
+}
+
 /*--.. Casts ...............................................................--*/
 
 LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val,

On Oct 1, 2012, at 1:18 PM, Benjamin Kramer <benny.kra at gmail.com> wrote:

> 
> On 30.09.2012, at 21:45, Antony Hosking <hosking at cs.purdue.edu> wrote:
> 
>> Please accept this patch to allow C binding access to the SetAlignment and GetAlignment methods for AllocaInst.
> 
> 
>> Index: include/llvm-c/Core.h
>> ===================================================================
>> --- include/llvm-c/Core.h	(revision 164918)
>> +++ include/llvm-c/Core.h	(working copy)
>> @@ -2431,6 +2431,9 @@
>> LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
>> void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
>> 
>> +unsigned LLVMGetAllocaAlignment(LLVMValueRef Alloca);
>> +void LLVMSetAllocaAlignment(LLVMValueRef Alloca, unsigned Bytes);
>> +
>> /* Casts */
>> LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
>>                             LLVMTypeRef DestTy, const char *Name);
>> Index: lib/VMCore/Core.cpp
>> ===================================================================
>> --- lib/VMCore/Core.cpp	(revision 164918)
>> +++ lib/VMCore/Core.cpp	(working copy)
>> @@ -2112,6 +2112,14 @@
>>   return cast<StoreInst>(P)->setVolatile(isVolatile);
>> }
>> 
>> +unsigned LLVMGetAllocaAlignment(LLVMValueRef Alloca) {
>> +  return unwrap<AllocaInst>(Alloca)->getAlignment();
>> +}
>> +
>> +void SetAllocaAlignment(LLVMValueRef Alloca, unsigned Bytes) {
>> +  unwrap<AllocaInst>(Alloca)->setAlignment(Bytes);
>> +}
> 
> Declaration doesn't match the prototype in Core.h, making it impossible to call.
> 
> - Ben
> 
>> +
>> /*--.. Casts ...............................................................--*/
>> 
>> LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val,





More information about the llvm-commits mailing list