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 | e922c0201916e0b980ab3cfe91e1413e68d55647 (patch) | |
tree | 663be741b84470d97945f01da459a3627af683fd /include | |
parent | 7cf12c7efd37dc12c3ed536a3f4c373dddac2b85 (diff) |
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 'include')
-rw-r--r-- | include/llvm/Analysis/ConstantFolding.h | 10 | ||||
-rw-r--r-- | include/llvm/Analysis/LoopPass.h | 1 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolution.h | 2 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpander.h | 6 | ||||
-rw-r--r-- | include/llvm/Analysis/ValueTracking.h | 4 | ||||
-rw-r--r-- | include/llvm/BasicBlock.h | 2 | ||||
-rw-r--r-- | include/llvm/CallGraphSCCPass.h | 1 | ||||
-rw-r--r-- | include/llvm/CodeGen/CallingConvLower.h | 6 | ||||
-rw-r--r-- | include/llvm/CodeGen/FastISel.h | 1 | ||||
-rw-r--r-- | include/llvm/Function.h | 2 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 10 | ||||
-rw-r--r-- | include/llvm/Pass.h | 16 | ||||
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 8 | ||||
-rw-r--r-- | include/llvm/Support/TargetFolder.h | 2 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/PromoteMemToReg.h | 2 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/ValueMapper.h | 2 | ||||
-rw-r--r-- | include/llvm/Value.h | 4 |
17 files changed, 34 insertions, 45 deletions
diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 6c8acf0c27..3e393ff691 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -29,13 +29,13 @@ namespace llvm { /// is returned. Note that this function can only fail when attempting to fold /// instructions like loads and stores, which have no constant expression form. /// -Constant *ConstantFoldInstruction(Instruction *I, LLVMContext *Context, +Constant *ConstantFoldInstruction(Instruction *I, LLVMContext &Context, const TargetData *TD = 0); /// ConstantFoldConstantExpression - Attempt to fold the constant expression /// using the specified TargetData. If successful, the constant result is /// result is returned, if not, null is returned. -Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext *Context, +Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext &Context, const TargetData *TD = 0); /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -46,7 +46,7 @@ Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext *Context, /// Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, Constant*const * Ops, unsigned NumOps, - LLVMContext *Context, + LLVMContext &Context, const TargetData *TD = 0); /// ConstantFoldCompareInstOperands - Attempt to constant fold a compare @@ -55,7 +55,7 @@ Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, /// Constant *ConstantFoldCompareInstOperands(unsigned Predicate, Constant*const * Ops, unsigned NumOps, - LLVMContext *Context, + LLVMContext &Context, const TargetData *TD = 0); @@ -63,7 +63,7 @@ Constant *ConstantFoldCompareInstOperands(unsigned Predicate, /// getelementptr constantexpr, return the constant value being addressed by the /// constant expression, or null if something is funny and we can't decide. Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE, - LLVMContext *Context); + LLVMContext &Context); /// canConstantFoldCallTo - Return true if its even possible to fold a call to /// the specified function. diff --git a/include/llvm/Analysis/LoopPass.h b/include/llvm/Analysis/LoopPass.h index a6a23c6b61..7659b5bf45 100644 --- a/include/llvm/Analysis/LoopPass.h +++ b/include/llvm/Analysis/LoopPass.h @@ -37,7 +37,6 @@ public: // Initialization and finalization hooks. virtual bool doInitialization(Loop *L, LPPassManager &LPM) { - Context = L->getHeader()->getContext(); return false; } diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index d22f5e42af..b2d95129e2 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -368,7 +368,7 @@ namespace llvm { static char ID; // Pass identification, replacement for typeid ScalarEvolution(); - LLVMContext *getContext() const { return Context; } + LLVMContext &getContext() const { return F->getContext(); } /// isSCEVable - Test if values of the given type are analyzable within /// the SCEV framework. This primarily includes integer types, and it diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 645ce9ecec..9266bf9713 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -38,8 +38,8 @@ namespace llvm { friend struct SCEVVisitor<SCEVExpander, Value*>; public: explicit SCEVExpander(ScalarEvolution &se) - : SE(se), Builder(*se.getContext(), - TargetFolder(se.TD, *se.getContext())) {} + : SE(se), Builder(se.getContext(), + TargetFolder(se.TD, se.getContext())) {} /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or @@ -61,7 +61,7 @@ namespace llvm { } private: - LLVMContext *getContext() const { return SE.getContext(); } + LLVMContext &getContext() const { return SE.getContext(); } /// InsertBinop - Insert the specified binary operator, doing a small amount /// of work to avoid inserting an obviously redundant operation. diff --git a/include/llvm/Analysis/ValueTracking.h b/include/llvm/Analysis/ValueTracking.h index ec04cb1fc4..1ebd9c26c4 100644 --- a/include/llvm/Analysis/ValueTracking.h +++ b/include/llvm/Analysis/ValueTracking.h @@ -65,13 +65,13 @@ namespace llvm { Value *FindInsertedValue(Value *V, const unsigned *idx_begin, const unsigned *idx_end, - LLVMContext *Context, + LLVMContext &Context, Instruction *InsertBefore = 0); /// This is a convenience wrapper for finding values indexed by a single index /// only. inline Value *FindInsertedValue(Value *V, const unsigned Idx, - LLVMContext *Context, + LLVMContext &Context, Instruction *InsertBefore = 0) { const unsigned Idxs[1] = { Idx }; return FindInsertedValue(V, &Idxs[0], &Idxs[1], Context, InsertBefore); diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 4f4da1ca2f..a20309fa84 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -88,7 +88,7 @@ private: public: /// getContext - Get the context in which this basic block lives, /// or null if it is not currently attached to a function. - LLVMContext *getContext() const; + LLVMContext &getContext() const; /// Instruction iterators... typedef InstListType::iterator iterator; diff --git a/include/llvm/CallGraphSCCPass.h b/include/llvm/CallGraphSCCPass.h index 8d5d7c3edf..85e83e50f4 100644 --- a/include/llvm/CallGraphSCCPass.h +++ b/include/llvm/CallGraphSCCPass.h @@ -38,7 +38,6 @@ struct CallGraphSCCPass : public Pass { /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. virtual bool doInitialization(CallGraph &CG) { - Context = &CG.getModule().getContext(); return false; } diff --git a/include/llvm/CodeGen/CallingConvLower.h b/include/llvm/CodeGen/CallingConvLower.h index 67e2776865..702ac1427c 100644 --- a/include/llvm/CodeGen/CallingConvLower.h +++ b/include/llvm/CodeGen/CallingConvLower.h @@ -142,19 +142,19 @@ class CCState { const TargetMachine &TM; const TargetRegisterInfo &TRI; SmallVector<CCValAssign, 16> &Locs; - LLVMContext *Context; + LLVMContext &Context; unsigned StackOffset; SmallVector<uint32_t, 16> UsedRegs; public: CCState(unsigned CC, bool isVarArg, const TargetMachine &TM, - SmallVector<CCValAssign, 16> &locs, LLVMContext *C); + SmallVector<CCValAssign, 16> &locs, LLVMContext &C); void addLoc(const CCValAssign &V) { Locs.push_back(V); } - LLVMContext *getContext() const { return Context; } + LLVMContext &getContext() const { return Context; } const TargetMachine &getTarget() const { return TM; } unsigned getCallingConv() const { return CallingConv; } bool isVarArg() const { return IsVarArg; } diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index 857267c011..c7b1a42d06 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -60,7 +60,6 @@ protected: const TargetData &TD; const TargetInstrInfo &TII; const TargetLowering &TLI; - LLVMContext *Context; public: /// startNewBlock - Set the current block to which generated machine diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 04c1442400..3bf65ff475 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -129,7 +129,7 @@ public: /// getContext - Return a pointer to the LLVMContext associated with this /// function, or NULL if this function is not bound to a context yet. - LLVMContext *getContext() const; + LLVMContext &getContext() const; /// isVarArg - Return true if this function takes a variable number of /// arguments. diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 5e60635a03..63a3dc0212 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -645,8 +645,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getParent()->getContext()-> - makeCmpResultType(LHS->getType()), + ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -667,7 +666,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()), + ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -821,8 +820,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getParent()->getContext()-> - makeCmpResultType(LHS->getType()), + ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && @@ -841,7 +839,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext()->makeCmpResultType(LHS->getType()), + ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 51186fa2db..3043fc0db5 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -48,7 +48,6 @@ class ImmutablePass; class PMStack; class AnalysisResolver; class PMDataManager; -class LLVMContext; // AnalysisID - Use the PassInfo to identify a pass... typedef const PassInfo* AnalysisID; @@ -78,9 +77,6 @@ class Pass { void operator=(const Pass&); // DO NOT IMPLEMENT Pass(const Pass &); // DO NOT IMPLEMENT -protected: - LLVMContext *Context; - public: explicit Pass(intptr_t pid) : Resolver(0), PassID(pid) { assert(pid && "pid cannot be 0"); @@ -281,11 +277,8 @@ public: /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// - virtual bool doInitialization(Module &M) { - Context = &M.getContext(); - return false; - } - + virtual bool doInitialization(Module &M) { return false; } + /// runOnFunction - Virtual method overriden by subclasses to do the /// per-function processing of the pass. /// @@ -336,10 +329,7 @@ public: /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// - virtual bool doInitialization(Module &M) { - Context = &M.getContext(); - return false; - } + virtual bool doInitialization(Module &M) { return false; } /// doInitialization - Virtual method overridden by BasicBlockPass subclasses /// to do any necessary per-function initialization. diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 2ef13a789f..835a28622f 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -51,22 +51,22 @@ public: IRBuilder(LLVMContext &C) : Context(C), Folder(C) { ClearInsertionPoint(); } explicit IRBuilder(BasicBlock *TheBB, const T& F) - : Context(*TheBB->getParent()->getContext()), Folder(F) { + : Context(TheBB->getContext()), Folder(F) { SetInsertPoint(TheBB); } explicit IRBuilder(BasicBlock *TheBB) - : Context(*TheBB->getParent()->getContext()), Folder(Context) { + : Context(TheBB->getContext()), Folder(Context) { SetInsertPoint(TheBB); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) - : Context(*TheBB->getParent()->getContext()), Folder(F) { + : Context(TheBB->getContext()), Folder(F) { SetInsertPoint(TheBB, IP); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) - : Context(*TheBB->getParent()->getContext()), Folder(Context) { + : Context(TheBB->getContext()), Folder(Context) { SetInsertPoint(TheBB, IP); } diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index d2661ca9f3..1e49850f68 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -35,7 +35,7 @@ class TargetFolder { /// Fold - Fold the constant using target specific information. Constant *Fold(Constant *C) const { if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) - if (Constant *CF = ConstantFoldConstantExpression(CE, &Context, TD)) + if (Constant *CF = ConstantFoldConstantExpression(CE, Context, TD)) return CF; return C; } diff --git a/include/llvm/Transforms/Utils/PromoteMemToReg.h b/include/llvm/Transforms/Utils/PromoteMemToReg.h index 91d51e2539..71a077e862 100644 --- a/include/llvm/Transforms/Utils/PromoteMemToReg.h +++ b/include/llvm/Transforms/Utils/PromoteMemToReg.h @@ -40,7 +40,7 @@ bool isAllocaPromotable(const AllocaInst *AI); /// void PromoteMemToReg(const std::vector<AllocaInst*> &Allocas, DominatorTree &DT, DominanceFrontier &DF, - LLVMContext *Context, + LLVMContext &Context, AliasSetTracker *AST = 0); } // End llvm namespace diff --git a/include/llvm/Transforms/Utils/ValueMapper.h b/include/llvm/Transforms/Utils/ValueMapper.h index dd294bbf82..d31edab5b5 100644 --- a/include/llvm/Transforms/Utils/ValueMapper.h +++ b/include/llvm/Transforms/Utils/ValueMapper.h @@ -23,7 +23,7 @@ namespace llvm { class LLVMContext; typedef DenseMap<const Value *, Value *> ValueMapTy; - Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext *Context); + Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext &Context); void RemapInstruction(Instruction *I, ValueMapTy &VM); } // End llvm namespace diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 7e7b415ffd..b220930c28 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -40,6 +40,7 @@ typedef StringMapEntry<Value*> ValueName; class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; +class LLVMContext; //===----------------------------------------------------------------------===// // Value Class @@ -101,6 +102,9 @@ public: /// inline const Type *getType() const { return VTy; } + /// All values hold a context through their type. + LLVMContext &getContext() const; + // All values can potentially be named... inline bool hasName() const { return Name != 0; } ValueName *getValueName() const { return Name; } |