[llvm-commits] [llvm] r164688 - /llvm/trunk/include/llvm/IRBuilder.h

Chandler Carruth chandlerc at gmail.com
Wed Sep 26 03:27:40 PDT 2012


Author: chandlerc
Date: Wed Sep 26 05:27:40 2012
New Revision: 164688

URL: http://llvm.org/viewvc/llvm-project?rev=164688&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/IRBuilder.h

Modified: llvm/trunk/include/llvm/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IRBuilder.h?rev=164688&r1=164687&r2=164688&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IRBuilder.h Wed Sep 26 05:27:40 2012
@@ -810,6 +810,31 @@
   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));





More information about the llvm-commits mailing list