[PATCH] C API: implement LLVM{Get,Set}InstructionAlignment
Peter Zotov
whitequark at whitequark.org
Sat Oct 12 08:53:01 PDT 2013
Existing LLVM{Get,Set}Alignment functions do not work on instructions,
as they use unwrap<GlobalValue>.
http://llvm-reviews.chandlerc.com/D1910
Files:
include/llvm-c/Core.h
lib/IR/Core.cpp
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -2495,6 +2495,8 @@
const char *Name);
LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
+unsigned LLVMGetInstructionAlignment(LLVMValueRef MemoryAccessInst);
+void LLVMSetInstructionAlignment(LLVMValueRef MemoryAccessInst, unsigned Alignment);
/* Casts */
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -2207,6 +2207,20 @@
return cast<StoreInst>(P)->setVolatile(isVolatile);
}
+unsigned LLVMGetInstructionAlignment(LLVMValueRef MemAccessInst) {
+ Value *P = unwrap<Value>(MemAccessInst);
+ if (LoadInst *LI = dyn_cast<LoadInst>(P))
+ return LI->getAlignment();
+ return cast<StoreInst>(P)->getAlignment();
+}
+
+void LLVMSetInstructionAlignment(LLVMValueRef MemAccessInst, unsigned Alignment) {
+ Value *P = unwrap<Value>(MemAccessInst);
+ if (LoadInst *LI = dyn_cast<LoadInst>(P))
+ return LI->setAlignment(Alignment);
+ return cast<StoreInst>(P)->setAlignment(Alignment);
+}
+
/*--.. Casts ...............................................................--*/
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1910.1.patch
Type: text/x-patch
Size: 1463 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131012/b1ef3e4f/attachment.bin>
More information about the llvm-commits
mailing list