Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.89 -> 1.90
AsmWriter.cpp updated: 1.273 -> 1.274
---
Log message:

PR400: http://llvm.org/PR400  work phase 1. Add attributed load/store 
instructions for volatile/align to LLVM.


---
Diffs of the changes:  (+49 -0)

 AsmWriter.cpp    |    7 +++++++
 Instructions.cpp |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.89 
llvm/lib/VMCore/Instructions.cpp:1.90
--- llvm/lib/VMCore/Instructions.cpp:1.89       Sun Apr 22 12:28:03 2007
+++ llvm/lib/VMCore/Instructions.cpp    Sun Apr 22 14:24:39 2007
@@ -20,6 +20,7 @@
 #include "llvm/ParameterAttributes.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/ConstantRange.h"
+#include "llvm/Support/MathExtras.h"
 using namespace llvm;
 
 unsigned CallSite::getCallingConv() const {
@@ -705,6 +706,7 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertBef) {
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
   setName(Name);
 }
@@ -713,6 +715,7 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertAE) {
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
   setName(Name);
 }
@@ -722,6 +725,17 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertBef) {
   setVolatile(isVolatile);
+  setAlignment(0);
+  AssertOK();
+  setName(Name);
+}
+
+LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, 
+                   unsigned Align, Instruction *InsertBef)
+  : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
+                     Load, Ptr, InsertBef) {
+  setVolatile(isVolatile);
+  setAlignment(Align);
   AssertOK();
   setName(Name);
 }
@@ -731,6 +745,7 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertAE) {
   setVolatile(isVolatile);
+  setAlignment(0);
   AssertOK();
   setName(Name);
 }
@@ -741,6 +756,7 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertBef) {
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
   if (Name && Name[0]) setName(Name);
 }
@@ -749,6 +765,7 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertAE) {
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
   if (Name && Name[0]) setName(Name);
 }
@@ -758,6 +775,7 @@
 : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                    Load, Ptr, InsertBef) {
   setVolatile(isVolatile);
+  setAlignment(0);
   AssertOK();
   if (Name && Name[0]) setName(Name);
 }
@@ -767,10 +785,15 @@
   : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
                      Load, Ptr, InsertAE) {
   setVolatile(isVolatile);
+  setAlignment(0);
   AssertOK();
   if (Name && Name[0]) setName(Name);
 }
 
+void LoadInst::setAlignment(unsigned Align) {
+  assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
+  SubclassData = (SubclassData & 1) | ((Log2_32(Align)+1)<<1);
+}
 
 
//===----------------------------------------------------------------------===//
 //                           StoreInst Implementation
@@ -790,6 +813,7 @@
   Ops[0].init(val, this);
   Ops[1].init(addr, this);
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
 }
 
@@ -798,6 +822,7 @@
   Ops[0].init(val, this);
   Ops[1].init(addr, this);
   setVolatile(false);
+  setAlignment(0);
   AssertOK();
 }
 
@@ -807,6 +832,17 @@
   Ops[0].init(val, this);
   Ops[1].init(addr, this);
   setVolatile(isVolatile);
+  setAlignment(0);
+  AssertOK();
+}
+
+StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
+                     unsigned Align, Instruction *InsertBefore)
+  : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
+  Ops[0].init(val, this);
+  Ops[1].init(addr, this);
+  setVolatile(isVolatile);
+  setAlignment(Align);
   AssertOK();
 }
 
@@ -816,9 +852,15 @@
   Ops[0].init(val, this);
   Ops[1].init(addr, this);
   setVolatile(isVolatile);
+  setAlignment(0);
   AssertOK();
 }
 
+void StoreInst::setAlignment(unsigned Align) {
+  assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
+  SubclassData = (SubclassData & 1) | ((Log2_32(Align)+1)<<1);
+}
+
 
//===----------------------------------------------------------------------===//
 //                       GetElementPtrInst Implementation
 
//===----------------------------------------------------------------------===//


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.273 llvm/lib/VMCore/AsmWriter.cpp:1.274
--- llvm/lib/VMCore/AsmWriter.cpp:1.273 Sun Apr 22 00:46:44 2007
+++ llvm/lib/VMCore/AsmWriter.cpp       Sun Apr 22 14:24:39 2007
@@ -1307,6 +1307,13 @@
       writeOperand(I.getOperand(i), PrintAllTypes);
     }
   }
+  
+  // Print post operand alignment for load/store
+  if (isa<LoadInst>(I) && cast<LoadInst>(I).getAlignment()) {
+    Out << ", align " << cast<LoadInst>(I).getAlignment();
+  } else if (isa<StoreInst>(I) && cast<StoreInst>(I).getAlignment()) {
+    Out << ", align " << cast<StoreInst>(I).getAlignment();
+  }
 
   printInfoComment(I);
   Out << "\n";



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to