forked from OSchip/llvm-project
[C API] Implement LLVM{Get,Set}Alignment for AllocaInst.
Patch by Manuel Jacob. llvm-svn: 202936
This commit is contained in:
parent
ce30de925b
commit
9f584e67f4
|
@ -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()
|
||||
|
|
|
@ -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 ......................................--*/
|
||||
|
|
Loading…
Reference in New Issue