Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/IR/Instructions.cpp
Show First 20 Lines • Show All 1,132 Lines • ▼ Show 20 Lines | |||||
void LoadInst::AssertOK() { | void LoadInst::AssertOK() { | ||||
assert(getOperand(0)->getType()->isPointerTy() && | assert(getOperand(0)->getType()->isPointerTy() && | ||||
"Ptr must have pointer type."); | "Ptr must have pointer type."); | ||||
assert(!(isAtomic() && getAlignment() == 0) && | assert(!(isAtomic() && getAlignment() == 0) && | ||||
"Alignment required for atomic load"); | "Alignment required for atomic load"); | ||||
} | } | ||||
LoadInst::LoadInst(Value *Ptr, const Twine &Name, Instruction *InsertBef) | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, | ||||
: LoadInst(Ptr, Name, /*isVolatile=*/false, InsertBef) {} | Instruction *InsertBef) | ||||
: LoadInst(Ty, Ptr, Name, /*isVolatile=*/false, InsertBef) {} | |||||
LoadInst::LoadInst(Value *Ptr, const Twine &Name, BasicBlock *InsertAE) | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, | ||||
: LoadInst(Ptr, Name, /*isVolatile=*/false, InsertAE) {} | BasicBlock *InsertAE) | ||||
: LoadInst(Ty, Ptr, Name, /*isVolatile=*/false, InsertAE) {} | |||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
Instruction *InsertBef) | Instruction *InsertBef) | ||||
: LoadInst(Ty, Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {} | : LoadInst(Ty, Ptr, Name, isVolatile, /*Align=*/0, InsertBef) {} | ||||
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
BasicBlock *InsertAE) | BasicBlock *InsertAE) | ||||
: LoadInst(Ptr, Name, isVolatile, /*Align=*/0, InsertAE) {} | : LoadInst(Ty, Ptr, Name, isVolatile, /*Align=*/0, InsertAE) {} | ||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
unsigned Align, Instruction *InsertBef) | unsigned Align, Instruction *InsertBef) | ||||
: LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic, | : LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic, | ||||
SyncScope::System, InsertBef) {} | SyncScope::System, InsertBef) {} | ||||
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
unsigned Align, BasicBlock *InsertAE) | unsigned Align, BasicBlock *InsertAE) | ||||
: LoadInst(Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic, | : LoadInst(Ty, Ptr, Name, isVolatile, Align, AtomicOrdering::NotAtomic, | ||||
SyncScope::System, InsertAE) {} | SyncScope::System, InsertAE) {} | ||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
unsigned Align, AtomicOrdering Order, | unsigned Align, AtomicOrdering Order, | ||||
SyncScope::ID SSID, Instruction *InsertBef) | SyncScope::ID SSID, Instruction *InsertBef) | ||||
: UnaryInstruction(Ty, Load, Ptr, InsertBef) { | : UnaryInstruction(Ty, Load, Ptr, InsertBef) { | ||||
assert(Ty == cast<PointerType>(Ptr->getType())->getElementType()); | assert(Ty == cast<PointerType>(Ptr->getType())->getElementType()); | ||||
setVolatile(isVolatile); | setVolatile(isVolatile); | ||||
setAlignment(Align); | setAlignment(Align); | ||||
setAtomic(Order, SSID); | setAtomic(Order, SSID); | ||||
AssertOK(); | AssertOK(); | ||||
setName(Name); | setName(Name); | ||||
} | } | ||||
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile, | LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile, | ||||
unsigned Align, AtomicOrdering Order, | unsigned Align, AtomicOrdering Order, SyncScope::ID SSID, | ||||
SyncScope::ID SSID, | |||||
BasicBlock *InsertAE) | BasicBlock *InsertAE) | ||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), | : UnaryInstruction(Ty, Load, Ptr, InsertAE) { | ||||
Load, Ptr, InsertAE) { | assert(Ty == cast<PointerType>(Ptr->getType())->getElementType()); | ||||
setVolatile(isVolatile); | setVolatile(isVolatile); | ||||
setAlignment(Align); | setAlignment(Align); | ||||
setAtomic(Order, SSID); | setAtomic(Order, SSID); | ||||
AssertOK(); | AssertOK(); | ||||
setName(Name); | setName(Name); | ||||
} | } | ||||
LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef) | |||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), | |||||
Load, Ptr, InsertBef) { | |||||
setVolatile(false); | |||||
setAlignment(0); | |||||
setAtomic(AtomicOrdering::NotAtomic); | |||||
AssertOK(); | |||||
if (Name && Name[0]) setName(Name); | |||||
} | |||||
LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE) | |||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), | |||||
Load, Ptr, InsertAE) { | |||||
setVolatile(false); | |||||
setAlignment(0); | |||||
setAtomic(AtomicOrdering::NotAtomic); | |||||
AssertOK(); | |||||
if (Name && Name[0]) setName(Name); | |||||
} | |||||
LoadInst::LoadInst(Type *Ty, Value *Ptr, const char *Name, bool isVolatile, | |||||
Instruction *InsertBef) | |||||
: UnaryInstruction(Ty, Load, Ptr, InsertBef) { | |||||
assert(Ty == cast<PointerType>(Ptr->getType())->getElementType()); | |||||
setVolatile(isVolatile); | |||||
setAlignment(0); | |||||
setAtomic(AtomicOrdering::NotAtomic); | |||||
AssertOK(); | |||||
if (Name && Name[0]) setName(Name); | |||||
} | |||||
LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, | |||||
BasicBlock *InsertAE) | |||||
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(), | |||||
Load, Ptr, InsertAE) { | |||||
setVolatile(isVolatile); | |||||
setAlignment(0); | |||||
setAtomic(AtomicOrdering::NotAtomic); | |||||
AssertOK(); | |||||
if (Name && Name[0]) setName(Name); | |||||
} | |||||
void LoadInst::setAlignment(unsigned Align) { | void LoadInst::setAlignment(unsigned Align) { | ||||
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); | assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); | ||||
assert(Align <= MaximumAlignment && | assert(Align <= MaximumAlignment && | ||||
"Alignment is greater than MaximumAlignment!"); | "Alignment is greater than MaximumAlignment!"); | ||||
setInstructionSubclassData((getSubclassDataFromInstruction() & ~(31 << 1)) | | setInstructionSubclassData((getSubclassDataFromInstruction() & ~(31 << 1)) | | ||||
((Log2_32(Align)+1)<<1)); | ((Log2_32(Align)+1)<<1)); | ||||
assert(getAlignment() == Align && "Alignment representation error!"); | assert(getAlignment() == Align && "Alignment representation error!"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,634 Lines • ▼ Show 20 Lines | AllocaInst *Result = new AllocaInst(getAllocatedType(), | ||||
getType()->getAddressSpace(), | getType()->getAddressSpace(), | ||||
(Value *)getOperand(0), getAlignment()); | (Value *)getOperand(0), getAlignment()); | ||||
Result->setUsedWithInAlloca(isUsedWithInAlloca()); | Result->setUsedWithInAlloca(isUsedWithInAlloca()); | ||||
Result->setSwiftError(isSwiftError()); | Result->setSwiftError(isSwiftError()); | ||||
return Result; | return Result; | ||||
} | } | ||||
LoadInst *LoadInst::cloneImpl() const { | LoadInst *LoadInst::cloneImpl() const { | ||||
return new LoadInst(getOperand(0), Twine(), isVolatile(), | return new LoadInst(getType(), getOperand(0), Twine(), isVolatile(), | ||||
getAlignment(), getOrdering(), getSyncScopeID()); | getAlignment(), getOrdering(), getSyncScopeID()); | ||||
} | } | ||||
StoreInst *StoreInst::cloneImpl() const { | StoreInst *StoreInst::cloneImpl() const { | ||||
return new StoreInst(getOperand(0), getOperand(1), isVolatile(), | return new StoreInst(getOperand(0), getOperand(1), isVolatile(), | ||||
getAlignment(), getOrdering(), getSyncScopeID()); | getAlignment(), getOrdering(), getSyncScopeID()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |