mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 15:40:46 +00:00
[C API] Implement LLVM{Get,Set}Alignment for AllocaInst.
Patch by Manuel Jacob. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202936 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c75dc7412b
commit
8a25ef92fb
@ -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
Block a user