diff options
author | Anders Waldenborg <anders@0x63.nu> | 2013-10-29 09:02:02 +0000 |
---|---|---|
committer | Anders Waldenborg <anders@0x63.nu> | 2013-10-29 09:02:02 +0000 |
commit | 213a63fe53fc93f2cb3ba3b70048e6599350f24b (patch) | |
tree | 15b9bbc67019a1eb380ec58ad75f98a996bfed46 /llvm/lib | |
parent | 4952448b5672027deecc8808a5510b20a3b5293f (diff) | |
download | bcm5719-llvm-213a63fe53fc93f2cb3ba3b70048e6599350f24b.tar.gz bcm5719-llvm-213a63fe53fc93f2cb3ba3b70048e6599350f24b.zip |
llvm-c: Make LLVM{Get,Set}Alignment work on {Load,Store}Inst too
Patch by Peter Zotov
Differential Revision: http://llvm-reviews.chandlerc.com/D1910
llvm-svn: 193597
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 16af7332d3c..f681b2e140b 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1240,12 +1240,30 @@ void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz) { ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz)); } -unsigned LLVMGetAlignment(LLVMValueRef Global) { - return unwrap<GlobalValue>(Global)->getAlignment(); +/*--.. Operations on global variables, load and store instructions .........--*/ + +unsigned LLVMGetAlignment(LLVMValueRef V) { + Value *P = unwrap<Value>(V); + if (GlobalValue *GV = dyn_cast<GlobalValue>(P)) + return GV->getAlignment(); + if (LoadInst *LI = dyn_cast<LoadInst>(P)) + return LI->getAlignment(); + if (StoreInst *SI = dyn_cast<StoreInst>(P)) + return SI->getAlignment(); + + llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment"); } -void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes) { - unwrap<GlobalValue>(Global)->setAlignment(Bytes); +void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) { + Value *P = unwrap<Value>(V); + if (GlobalValue *GV = dyn_cast<GlobalValue>(P)) + GV->setAlignment(Bytes); + else if (LoadInst *LI = dyn_cast<LoadInst>(P)) + LI->setAlignment(Bytes); + else if (StoreInst *SI = dyn_cast<StoreInst>(P)) + SI->setAlignment(Bytes); + + llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment"); } /*--.. Operations on global variables ......................................--*/ |