summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2014-03-05 05:05:34 +0000
committerPeter Zotov <whitequark@whitequark.org>2014-03-05 05:05:34 +0000
commit9f584e67f4258dbcce982dba84c4aeda3c0e4617 (patch)
treea00b20f4b726169f0bb9569c2df0e7e098c19a69
parentce30de925b86cc79cc8ae0bf7d0056dd22475de6 (diff)
downloadbcm5719-llvm-9f584e67f4258dbcce982dba84c4aeda3c0e4617.tar.gz
bcm5719-llvm-9f584e67f4258dbcce982dba84c4aeda3c0e4617.zip
[C API] Implement LLVM{Get,Set}Alignment for AllocaInst.
Patch by Manuel Jacob. llvm-svn: 202936
-rw-r--r--llvm/include/llvm-c/Core.h2
-rw-r--r--llvm/lib/IR/Core.cpp10
2 files changed, 10 insertions, 2 deletions
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index af1e01d8e1b..437023bfba6 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -1707,6 +1707,7 @@ void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
/**
* Obtain the preferred alignment of the value.
+ * @see llvm::AllocaInst::getAlignment()
* @see llvm::LoadInst::getAlignment()
* @see llvm::StoreInst::getAlignment()
* @see llvm::GlobalValue::getAlignment()
@@ -1715,6 +1716,7 @@ unsigned LLVMGetAlignment(LLVMValueRef V);
/**
* Set the preferred alignment of the value.
+ * @see llvm::AllocaInst::setAlignment()
* @see llvm::LoadInst::setAlignment()
* @see llvm::StoreInst::setAlignment()
* @see llvm::GlobalValue::setAlignment()
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index c78ddae60be..f63263fd1f5 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1268,24 +1268,30 @@ unsigned LLVMGetAlignment(LLVMValueRef V) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
return GV->getAlignment();
+ if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ return AI->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");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
Value *P = unwrap<Value>(V);
if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
GV->setAlignment(Bytes);
+ else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
+ AI->setAlignment(Bytes);
else if (LoadInst *LI = dyn_cast<LoadInst>(P))
LI->setAlignment(Bytes);
else if (StoreInst *SI = dyn_cast<StoreInst>(P))
SI->setAlignment(Bytes);
else
- llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
+ llvm_unreachable(
+ "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
}
/*--.. Operations on global variables ......................................--*/
OpenPOWER on IntegriCloud