summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-10-23 21:09:37 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-10-23 21:09:37 +0000
commit8acf2956b8b47596103517e024acc8e686c17353 (patch)
treeb7f3e36b0d915c2125c7094ea8af3b06e5c47c3c /llvm/lib/VMCore/Instructions.cpp
parent9a14b84ac559e85672ce9c463eba7bf23ba4b6a2 (diff)
downloadbcm5719-llvm-8acf2956b8b47596103517e024acc8e686c17353.tar.gz
bcm5719-llvm-8acf2956b8b47596103517e024acc8e686c17353.zip
Remove AllocationInst. Since MallocInst went away, AllocaInst is the only subclass of AllocationInst, so it no longer is necessary.
llvm-svn: 84969
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp60
1 files changed, 47 insertions, 13 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index e212d5c542a..99a28594e6c 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -838,7 +838,7 @@ void BranchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
//===----------------------------------------------------------------------===//
-// AllocationInst Implementation
+// AllocaInst Implementation
//===----------------------------------------------------------------------===//
static Value *getAISize(LLVMContext &Context, Value *Amt) {
@@ -853,20 +853,54 @@ static Value *getAISize(LLVMContext &Context, Value *Amt) {
return Amt;
}
-AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const Twine &Name,
- Instruction *InsertBefore)
- : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
+AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize,
+ const Twine &Name, Instruction *InsertBefore)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), ArraySize), InsertBefore) {
+ setAlignment(0);
+ assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
+ setName(Name);
+}
+
+AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize,
+ const Twine &Name, BasicBlock *InsertAtEnd)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
+ setAlignment(0);
+ assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
+ setName(Name);
+}
+
+AllocaInst::AllocaInst(const Type *Ty, const Twine &Name,
+ Instruction *InsertBefore)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), 0), InsertBefore) {
+ setAlignment(0);
+ assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
+ setName(Name);
+}
+
+AllocaInst::AllocaInst(const Type *Ty, const Twine &Name,
+ BasicBlock *InsertAtEnd)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
+ getAISize(Ty->getContext(), 0), InsertAtEnd) {
+ setAlignment(0);
+ assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
+ setName(Name);
+}
+
+AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
+ const Twine &Name, Instruction *InsertBefore)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
getAISize(Ty->getContext(), ArraySize), InsertBefore) {
setAlignment(Align);
assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
setName(Name);
}
-AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- unsigned Align, const Twine &Name,
- BasicBlock *InsertAtEnd)
- : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
+AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align,
+ const Twine &Name, BasicBlock *InsertAtEnd)
+ : UnaryInstruction(PointerType::getUnqual(Ty), Alloca,
getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
setAlignment(Align);
assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!");
@@ -874,22 +908,22 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
}
// Out of line virtual method, so the vtable, etc has a home.
-AllocationInst::~AllocationInst() {
+AllocaInst::~AllocaInst() {
}
-void AllocationInst::setAlignment(unsigned Align) {
+void AllocaInst::setAlignment(unsigned Align) {
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
SubclassData = Log2_32(Align) + 1;
assert(getAlignment() == Align && "Alignment representation error!");
}
-bool AllocationInst::isArrayAllocation() const {
+bool AllocaInst::isArrayAllocation() const {
if (ConstantInt *CI = dyn_cast<ConstantInt>(getOperand(0)))
return CI->getZExtValue() != 1;
return true;
}
-const Type *AllocationInst::getAllocatedType() const {
+const Type *AllocaInst::getAllocatedType() const {
return getType()->getElementType();
}
OpenPOWER on IntegriCloud