Add some convenience methods to IRBuilder for constructing aligned loads

and stores. These will be used in subsequnet patches to SROA to more
systematically manage the alignment on loads and stores.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2012-09-26 10:27:40 +00:00
parent 9f4df20fe0
commit 4d7aa6dbce

View File

@ -810,6 +810,31 @@ public:
StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) {
return Insert(new StoreInst(Val, Ptr, isVolatile));
}
// Provided to resolve 'CreateAlignedLoad(Ptr, Align, "...")' correctly,
// instead of converting the string to 'bool' for the isVolatile parameter.
LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name) {
LoadInst *LI = CreateLoad(Ptr, Name);
LI->setAlignment(Align);
return LI;
}
LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align,
const Twine &Name = "") {
LoadInst *LI = CreateLoad(Ptr, Name);
LI->setAlignment(Align);
return LI;
}
LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile,
const Twine &Name = "") {
LoadInst *LI = CreateLoad(Ptr, isVolatile, Name);
LI->setAlignment(Align);
return LI;
}
StoreInst *CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align,
bool isVolatile = false) {
StoreInst *SI = CreateStore(Val, Ptr, isVolatile);
SI->setAlignment(Align);
return SI;
}
FenceInst *CreateFence(AtomicOrdering Ordering,
SynchronizationScope SynchScope = CrossThread) {
return Insert(new FenceInst(Context, Ordering, SynchScope));