diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-22 00:24:57 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-22 00:24:57 +0000 |
commit | 175b6540352920afd47979cecb8c2667a3f7fdd3 (patch) | |
tree | 663be741b84470d97945f01da459a3627af683fd /lib/VMCore | |
parent | bdb23b3806e83737a67a023a729547caf03fc533 (diff) | |
download | external_llvm-175b6540352920afd47979cecb8c2667a3f7fdd3.zip external_llvm-175b6540352920afd47979cecb8c2667a3f7fdd3.tar.gz external_llvm-175b6540352920afd47979cecb8c2667a3f7fdd3.tar.bz2 |
Get rid of the Pass+Context magic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 56 | ||||
-rw-r--r-- | lib/VMCore/BasicBlock.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/Value.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 3 |
5 files changed, 37 insertions, 36 deletions
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index c3405fc..016a339 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -27,7 +27,7 @@ using namespace llvm; static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { assert(F && "Illegal to upgrade a non-existent Function."); - LLVMContext* Context = F->getContext(); + LLVMContext &Context = F->getContext(); // Get the Function's name. const std::string& Name = F->getName(); @@ -167,7 +167,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') { const llvm::Type *VT = - Context->getVectorType(Context->getIntegerType(64), 1); + Context.getVectorType(Context.getIntegerType(64), 1); // We don't have to do anything if the parameter already has // the correct type. @@ -232,7 +232,7 @@ bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) { // order to seamlessly integrate with existing context. void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Function *F = CI->getCalledFunction(); - LLVMContext* Context = F->getContext(); + LLVMContext &Context = F->getContext(); assert(F && "CallInst has no function associated with it."); @@ -266,60 +266,60 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Value *Op0 = CI->getOperand(1); ShuffleVectorInst *SI = NULL; if (isLoadH || isLoadL) { - Value *Op1 = Context->getUndef(Op0->getType()); + Value *Op1 = Context.getUndef(Op0->getType()); Value *Addr = new BitCastInst(CI->getOperand(2), - Context->getPointerTypeUnqual(Type::DoubleTy), + Context.getPointerTypeUnqual(Type::DoubleTy), "upgraded.", CI); Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI); - Value *Idx = Context->getConstantInt(Type::Int32Ty, 0); + Value *Idx = Context.getConstantInt(Type::Int32Ty, 0); Op1 = InsertElementInst::Create(Op1, Load, Idx, "upgraded.", CI); if (isLoadH) { - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 0)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 0)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2)); } else { - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1)); } - Value *Mask = Context->getConstantVector(Idxs); + Value *Mask = Context.getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isMovL) { - Constant *Zero = Context->getConstantInt(Type::Int32Ty, 0); + Constant *Zero = Context.getConstantInt(Type::Int32Ty, 0); Idxs.push_back(Zero); Idxs.push_back(Zero); Idxs.push_back(Zero); Idxs.push_back(Zero); - Value *ZeroV = Context->getConstantVector(Idxs); + Value *ZeroV = Context.getConstantVector(Idxs); Idxs.clear(); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 4)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 5)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 3)); - Value *Mask = Context->getConstantVector(Idxs); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 4)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 5)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 3)); + Value *Mask = Context.getConstantVector(Idxs); SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI); } else if (isMovSD || isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { Value *Op1 = CI->getOperand(2); if (isMovSD) { - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1)); } else if (isUnpckhPD || isPunpckhQPD) { - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 1)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 3)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 1)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 3)); } else { - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 0)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, 2)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 0)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, 2)); } - Value *Mask = Context->getConstantVector(Idxs); + Value *Mask = Context.getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isShufPD) { Value *Op1 = CI->getOperand(2); unsigned MaskVal = cast<ConstantInt>(CI->getOperand(3))->getZExtValue(); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, MaskVal & 1)); - Idxs.push_back(Context->getConstantInt(Type::Int32Ty, + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, MaskVal & 1)); + Idxs.push_back(Context.getConstantInt(Type::Int32Ty, ((MaskVal >> 1) & 1)+2)); - Value *Mask = Context->getConstantVector(Idxs); + Value *Mask = Context.getConstantVector(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 4a4bf28..df27811 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -30,8 +30,8 @@ ValueSymbolTable *BasicBlock::getValueSymbolTable() { return 0; } -LLVMContext *BasicBlock::getContext() const { - return Parent ? Parent->getContext() : 0; +LLVMContext &BasicBlock::getContext() const { + return getType()->getContext(); } // Explicit instantiation of SymbolTableListTraits since some of the methods @@ -203,7 +203,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, PN->replaceAllUsesWith(PN->getOperand(0)); else // We are left with an infinite loop with no entries: kill the PHI. - PN->replaceAllUsesWith(getContext()->getUndef(PN->getType())); + PN->replaceAllUsesWith(getContext().getUndef(PN->getType())); getInstList().pop_front(); // Remove the PHI node } diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 23adaed..4923842 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -115,10 +115,8 @@ void Argument::removeAttr(Attributes attr) { // Helper Methods in Function //===----------------------------------------------------------------------===// -LLVMContext *Function::getContext() const { - const Module* M = getParent(); - if (M) return &M->getContext(); - return 0; +LLVMContext &Function::getContext() const { + return getType()->getContext(); } const FunctionType *Function::getFunctionType() const { diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index ab2e35c..07fbfc6 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -386,6 +386,8 @@ Value *Value::DoPHITranslation(const BasicBlock *CurBB, return this; } +LLVMContext &Value::getContext() const { return VTy->getContext(); } + //===----------------------------------------------------------------------===// // ValueHandleBase Class //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 897e62c..4b15e3a 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1490,6 +1490,7 @@ static std::string IntrinsicParam(unsigned ArgNo, unsigned NumRets) { bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, int VT, unsigned ArgNo, std::string &Suffix) { const FunctionType *FTy = F->getFunctionType(); + LLVMContext &Context = FTy->getContext(); unsigned NumElts = 0; const Type *EltTy = Ty; @@ -1619,7 +1620,7 @@ bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, "vector elements!", F); return false; } - } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT(*Context) != EltTy) { + } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT(Context) != EltTy) { CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is wrong!", F); return false; } else if (EltTy != Ty) { |