[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Instructions.cpp
Christopher Lamb
christopher.lamb at gmail.com
Sat Apr 21 01:17:12 PDT 2007
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.270 -> 1.271
Instructions.cpp updated: 1.85 -> 1.86
---
Log message:
add support for alignment attributes on load/store instructions
---
Diffs of the changes: (+49 -0)
AsmWriter.cpp | 7 +++++++
Instructions.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.270 llvm/lib/VMCore/AsmWriter.cpp:1.271
--- llvm/lib/VMCore/AsmWriter.cpp:1.270 Tue Apr 17 19:57:22 2007
+++ llvm/lib/VMCore/AsmWriter.cpp Sat Apr 21 03:16:25 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";
Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.85 llvm/lib/VMCore/Instructions.cpp:1.86
--- llvm/lib/VMCore/Instructions.cpp:1.85 Fri Apr 13 19:12:57 2007
+++ llvm/lib/VMCore/Instructions.cpp Sat Apr 21 03:16:25 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 {
@@ -685,6 +686,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setVolatile(false);
+ setAlignment(0);
AssertOK();
setName(Name);
}
@@ -693,6 +695,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setVolatile(false);
+ setAlignment(0);
AssertOK();
setName(Name);
}
@@ -702,6 +705,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);
}
@@ -711,6 +725,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setVolatile(isVolatile);
+ setAlignment(0);
AssertOK();
setName(Name);
}
@@ -721,6 +736,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setVolatile(false);
+ setAlignment(0);
AssertOK();
if (Name && Name[0]) setName(Name);
}
@@ -729,6 +745,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertAE) {
setVolatile(false);
+ setAlignment(0);
AssertOK();
if (Name && Name[0]) setName(Name);
}
@@ -738,6 +755,7 @@
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Ptr, InsertBef) {
setVolatile(isVolatile);
+ setAlignment(0);
AssertOK();
if (Name && Name[0]) setName(Name);
}
@@ -747,10 +765,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
@@ -770,6 +793,7 @@
Ops[0].init(val, this);
Ops[1].init(addr, this);
setVolatile(false);
+ setAlignment(0);
AssertOK();
}
@@ -778,6 +802,7 @@
Ops[0].init(val, this);
Ops[1].init(addr, this);
setVolatile(false);
+ setAlignment(0);
AssertOK();
}
@@ -787,6 +812,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();
}
@@ -796,9 +832,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
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list