llvm.org GIT mirror llvm / 8a25ef9
[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 Peter Zotov 5 years ago
2 changed file(s) with 10 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
17061706
17071707 /**
17081708 * Obtain the preferred alignment of the value.
1709 * @see llvm::AllocaInst::getAlignment()
17091710 * @see llvm::LoadInst::getAlignment()
17101711 * @see llvm::StoreInst::getAlignment()
17111712 * @see llvm::GlobalValue::getAlignment()
17141715
17151716 /**
17161717 * Set the preferred alignment of the value.
1718 * @see llvm::AllocaInst::setAlignment()
17171719 * @see llvm::LoadInst::setAlignment()
17181720 * @see llvm::StoreInst::setAlignment()
17191721 * @see llvm::GlobalValue::setAlignment()
12671267 Value *P = unwrap(V);
12681268 if (GlobalValue *GV = dyn_cast(P))
12691269 return GV->getAlignment();
1270 if (AllocaInst *AI = dyn_cast(P))
1271 return AI->getAlignment();
12701272 if (LoadInst *LI = dyn_cast(P))
12711273 return LI->getAlignment();
12721274 if (StoreInst *SI = dyn_cast(P))
12731275 return SI->getAlignment();
12741276
1275 llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
1277 llvm_unreachable(
1278 "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
12761279 }
12771280
12781281 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
12791282 Value *P = unwrap(V);
12801283 if (GlobalValue *GV = dyn_cast(P))
12811284 GV->setAlignment(Bytes);
1285 else if (AllocaInst *AI = dyn_cast(P))
1286 AI->setAlignment(Bytes);
12821287 else if (LoadInst *LI = dyn_cast(P))
12831288 LI->setAlignment(Bytes);
12841289 else if (StoreInst *SI = dyn_cast(P))
12851290 SI->setAlignment(Bytes);
12861291 else
1287 llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
1292 llvm_unreachable(
1293 "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
12881294 }
12891295
12901296 /*--.. Operations on global variables ......................................--*/