diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2007-04-22 19:24:39 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2007-04-22 19:24:39 +0000 |
commit | 43c7f37942a35398fd1e14b22f435f483a0ee863 (patch) | |
tree | 7b5086671d5743f3187e8f8f3bc6d7fe1e507b39 /lib/VMCore/Instructions.cpp | |
parent | cb403d69fb620d4df66233d27a6f8c545ce0d0e4 (diff) |
PR400 work phase 1. Add attributed load/store instructions for volatile/align to LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index e0c2a5e6bb..2bd350080e 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -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 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertBef) { setVolatile(false); + setAlignment(0); AssertOK(); setName(Name); } @@ -713,6 +715,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE) : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertAE) { setVolatile(false); + setAlignment(0); AssertOK(); setName(Name); } @@ -722,6 +725,17 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, : 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 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertAE) { setVolatile(isVolatile); + setAlignment(0); AssertOK(); setName(Name); } @@ -741,6 +756,7 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef) : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertBef) { setVolatile(false); + setAlignment(0); AssertOK(); if (Name && Name[0]) setName(Name); } @@ -749,6 +765,7 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE) : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertAE) { setVolatile(false); + setAlignment(0); AssertOK(); if (Name && Name[0]) setName(Name); } @@ -758,6 +775,7 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, : UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), Load, Ptr, InsertBef) { setVolatile(isVolatile); + setAlignment(0); AssertOK(); if (Name && Name[0]) setName(Name); } @@ -767,10 +785,15 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, : 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 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore) Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(false); + setAlignment(0); AssertOK(); } @@ -798,6 +822,7 @@ StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(false); + setAlignment(0); AssertOK(); } @@ -807,6 +832,17 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, 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 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, 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 //===----------------------------------------------------------------------===// |