llvm.org GIT mirror llvm / 001dbfe
Move the ConstantInt uniquing table into LLVMContextImpl. This exposed a number of issues in our current context-passing stuff, which is also fixed here git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76089 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
34 changed file(s) with 173 addition(s) and 91 deletion(s). Raw diff Collapse all Expand all
7979 }
8080
8181 //ret i32 0
82 ReturnInst::Create(ConstantInt::get(APInt(32, 0)), bb);
82 ReturnInst::Create(getGlobalContext().getConstantInt(APInt(32, 0)), bb);
8383 }
8484
8585 int main(int argc, char **argv) {
8686 cl::ParseCommandLineOptions(argc, argv, " BrainF compiler\n");
8787
88 LLVMContext Context;
88 LLVMContext &Context = getGlobalContext();
8989
9090 if (InputFilename == "") {
9191 std::cerr<<"Error: You must specify the filename of the program to "
3636
3737 // Initialization and finalization hooks.
3838 virtual bool doInitialization(Loop *L, LPPassManager &LPM) {
39 Context = L->getHeader()->getContext();
3940 return false;
4041 }
4142
2121 #define LLVM_CALL_GRAPH_SCC_PASS_H
2222
2323 #include "llvm/Pass.h"
24 #include "llvm/Analysis/CallGraph.h"
2425
2526 namespace llvm {
2627
3637 /// doInitialization - This method is called before the SCC's of the program
3738 /// has been processed, allowing the pass to do initialization as necessary.
3839 virtual bool doInitialization(CallGraph &CG) {
40 Context = &CG.getModule().getContext();
3941 return false;
4042 }
4143
4949 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
5050 ConstantInt(const IntegerType *Ty, const APInt& V);
5151 APInt Val;
52 friend class LLVMContextImpl;
5253 protected:
5354 // allocate space for exactly zero operands
5455 void *operator new(size_t s) {
100101 if (TheFalseVal) return TheFalseVal;
101102 return CreateTrueFalseVals(false);
102103 }
103
104 /// Return a ConstantInt with the specified value and an implied Type. The
105 /// type is the integer type that corresponds to the bit width of the value.
106 static ConstantInt *get(const APInt &V);
107104
108105 /// getType - Specialize the getType() method to always return an IntegerType,
109106 /// which reduces the amount of casting needed in parts of the compiler.
9292 ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V);
9393 Constant *getConstantIntSigned(const Type *Ty, int64_t V);
9494
95 /// Return a ConstantInt with the specified value and an implied Type. The
96 /// type is the integer type that corresponds to the bit width of the value.
9597 ConstantInt* getConstantInt(const APInt& V);
9698
9799 /// If Ty is a vector type, return a Constant with a splat of the given
311311 AliasAnalysis::AliasResult
312312 BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
313313 const Value *V2, unsigned V2Size) {
314 Context = &V1->getType()->getContext();
315
314316 // Strip off any constant expression casts if they exist
315317 if (const ConstantExpr *CE = dyn_cast(V1))
316318 if (CE->isCast() && isa(CE->getOperand(0)->getType()))
528530 return MayAlias;
529531
530532 const PointerType *GEPPointerTy = cast(BasePtr1Ty);
533
534 Context = &GEPPointerTy->getContext();
531535
532536 // Find the (possibly empty) initial sequence of equal values... which are not
533537 // necessarily constants.
190190 }
191191
192192 const SCEV *ScalarEvolution::getConstant(const APInt& Val) {
193 return getConstant(ConstantInt::get(Val));
193 return getConstant(Context->getConstantInt(Val));
194194 }
195195
196196 const SCEV *
15161516 ++Idx;
15171517 while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
15181518 // We found two constants, fold them together!
1519 ConstantInt *Fold = ConstantInt::get(LHSC->getValue()->getValue() *
1519 ConstantInt *Fold = Context->getConstantInt(LHSC->getValue()->getValue() *
15201520 RHSC->getValue()->getValue());
15211521 Ops[0] = getConstant(Fold);
15221522 Ops.erase(Ops.begin()+1); // Erase the folded element
18671867 assert(Idx < Ops.size());
18681868 while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
18691869 // We found two constants, fold them together!
1870 ConstantInt *Fold = ConstantInt::get(
1870 ConstantInt *Fold = Context->getConstantInt(
18711871 APIntOps::smax(LHSC->getValue()->getValue(),
18721872 RHSC->getValue()->getValue()));
18731873 Ops[0] = getConstant(Fold);
19641964 assert(Idx < Ops.size());
19651965 while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
19661966 // We found two constants, fold them together!
1967 ConstantInt *Fold = ConstantInt::get(
1967 ConstantInt *Fold = Context->getConstantInt(
19681968 APIntOps::umax(LHSC->getValue()->getValue(),
19691969 RHSC->getValue()->getValue()));
19701970 Ops[0] = getConstant(Fold);
28862886 // Turn shift left of a constant amount into a multiply.
28872887 if (ConstantInt *SA = dyn_cast(U->getOperand(1))) {
28882888 uint32_t BitWidth = cast(V->getType())->getBitWidth();
2889 Constant *X = ConstantInt::get(
2889 Constant *X = Context->getConstantInt(
28902890 APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
28912891 return getMulExpr(getSCEV(U->getOperand(0)), getSCEV(X));
28922892 }
28962896 // Turn logical shift right of a constant into a unsigned divide.
28972897 if (ConstantInt *SA = dyn_cast(U->getOperand(1))) {
28982898 uint32_t BitWidth = cast(V->getType())->getBitWidth();
2899 Constant *X = ConstantInt::get(
2899 Constant *X = Context->getConstantInt(
29002900 APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth)));
29012901 return getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(X));
29022902 }
107107 if (isExact) {
108108 APInt IntVal(IntBitWidth, 2, x);
109109
110 unsigned IntegerReg = getRegForValue(ConstantInt::get(IntVal));
110 unsigned IntegerReg = getRegForValue(Context->getConstantInt(IntVal));
111111 if (IntegerReg != 0)
112112 Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
113113 }
23042304 ISD::SETLT);
23052305
23062306 // Build a 64 bit pair (0, FF) in the constant pool, with FF in the lo bits.
2307 SDValue FudgePtr = DAG.getConstantPool(ConstantInt::get(FF.zext(64)),
2307 SDValue FudgePtr = DAG.getConstantPool(
2308 DAG.getContext()->getConstantInt(FF.zext(64)),
23082309 TLI.getPointerTy());
23092310
23102311 // Get a pointer to FF if the sign bit was set, or to 0 otherwise.
873873 }
874874
875875 SDValue SelectionDAG::getConstant(const APInt &Val, MVT VT, bool isT) {
876 return getConstant(*ConstantInt::get(Val), VT, isT);
876 return getConstant(*Context->getConstantInt(Val), VT, isT);
877877 }
878878
879879 SDValue SelectionDAG::getConstant(const ConstantInt &Val, MVT VT, bool isT) {
24052405 // Convert the ConstantVector mask operand into an array of ints, with -1
24062406 // representing undef values.
24072407 SmallVector MaskElts;
2408 cast(I.getOperand(2))->getVectorElements(*Context, MaskElts);
2408 cast(I.getOperand(2))->getVectorElements(*DAG.getContext(),
2409 MaskElts);
24092410 unsigned MaskNumElts = MaskElts.size();
24102411 for (unsigned i = 0; i != MaskNumElts; ++i) {
24112412 if (isa(MaskElts[i]))
907907
908908 bool DAE::runOnModule(Module &M) {
909909 bool Changed = false;
910 Context = &M.getContext();
910911
911912 // First pass: Do a simple check to see if any functions can have their "..."
912913 // removed. We can do this if they never call va_start. This loop cannot be
7676 //
7777 bool DTE::runOnModule(Module &M) {
7878 bool Changed = false;
79 Context = &M.getContext();
7980
8081 TypeSymbolTable &ST = M.getTypeSymbolTable();
8182 std::set UsedTypes = getAnalysis().getTypes();
4242 if (Named.size() == 0) {
4343 return false; // Nothing to extract
4444 }
45
46 Context = &M.getContext();
4547
4648 if (deleteStuff)
4749 return deleteGV();
5757
5858 bool GlobalDCE::runOnModule(Module &M) {
5959 bool Changed = false;
60 Context = &M.getContext();
61
6062 // Loop over the module, adding globals which are obviously necessary.
6163 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
6264 Changed |= RemoveUnusedGlobalValue(*I);
24752475
24762476 bool GlobalOpt::runOnModule(Module &M) {
24772477 bool Changed = false;
2478 Context = &M.getContext();
24782479
24792480 // Try to find the llvm.globalctors list.
24802481 GlobalVariable *GlobalCtors = FindGlobalCtors(M);
5454 bool IPCP::runOnModule(Module &M) {
5555 bool Changed = false;
5656 bool LocalChange = true;
57
58 Context = &M.getContext();
5759
5860 // FIXME: instead of using smart algorithms, we just iterate until we stop
5961 // making changes.
4343 X("indmemrem","Indirect Malloc and Free Removal");
4444
4545 bool IndMemRemPass::runOnModule(Module &M) {
46 Context = &M.getContext();
47
4648 // In theory, all direct calls of malloc and free should be promoted
4749 // to intrinsics. Therefore, this goes through and finds where the
4850 // address of free or malloc are taken and replaces those with bounce
100100 bool InternalizePass::runOnModule(Module &M) {
101101 CallGraph *CG = getAnalysisIfAvailable();
102102 CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : 0;
103
104 Context = &M.getContext();
103105
104106 if (ExternalNames.empty()) {
105107 // Return if we're not in 'all but main' mode and have no external api
133133 bool LowerSetJmp::runOnModule(Module& M) {
134134 bool Changed = false;
135135
136 Context = &M.getContext();
137
136138 // These are what the functions are called.
137139 Function* SetJmp = M.getFunction("llvm.setjmp");
138140 Function* LongJmp = M.getFunction("llvm.longjmp");
614614 bool MergeFunctions::runOnModule(Module &M) {
615615 bool Changed = false;
616616
617 Context = &M.getContext();
618
617619 std::map > FnMap;
618620
619621 for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
140140 }
141141
142142 bool PartialInliner::runOnModule(Module& M) {
143 Context = &M.getContext();
144
143145 std::vector worklist;
144146 worklist.reserve(M.size());
145147 for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI)
107107
108108
109109 bool PartSpec::runOnModule(Module &M) {
110 Context = &M.getContext();
111
110112 bool Changed = false;
111113 for (Module::iterator I = M.begin(); I != M.end(); ++I) {
112114 Function &F = *I;
6969 // function into the appropriate instruction.
7070 //
7171 void RaiseAllocations::doInitialization(Module &M) {
72 Context = &M.getContext();
7273
7374 // Get Malloc and free prototypes if they exist!
7475 MallocFunc = M.getFunction("malloc");
4141
4242 bool StripDeadPrototypesPass::runOnModule(Module &M) {
4343 bool MadeChange = false;
44 Context = &M.getContext();
4445
4546 // Erase dead function prototypes.
4647 for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
373373 }
374374
375375 bool StripSymbols::runOnModule(Module &M) {
376 Context = &M.getContext();
376377 bool Changed = false;
377378 Changed |= StripDebugInfo(M);
378379 if (!OnlyDebugInfo)
904904 class VISIBILITY_HIDDEN ValueRanges {
905905 ValueNumbering &VN;
906906 TargetData *TD;
907 LLVMContext *Context;
907908
908909 class VISIBILITY_HIDDEN ScopedRange {
909910 typedef std::vector >
10241025
10251026 public:
10261027
1027 ValueRanges(ValueNumbering &VN, TargetData *TD) : VN(VN), TD(TD) {}
1028 ValueRanges(ValueNumbering &VN, TargetData *TD, LLVMContext *C) :
1029 VN(VN), TD(TD), Context(C) {}
10281030
10291031 #ifndef NDEBUG
10301032 virtual ~ValueRanges() {}
11661168 Value *V = VN.value(n); // XXX: redesign worklist.
11671169 const Type *Ty = V->getType();
11681170 if (Ty->isInteger()) {
1169 addToWorklist(V, ConstantInt::get(*I), ICmpInst::ICMP_EQ, VRP);
1171 addToWorklist(V, Context->getConstantInt(*I), ICmpInst::ICMP_EQ, VRP);
11701172 return;
11711173 } else if (const PointerType *PTy = dyn_cast(Ty)) {
11721174 assert(*I == 0 && "Pointer is null but not zero?");
16771679 Top(DTDFS->getNodeForBlock(TopInst->getParent())),
16781680 TopBB(TopInst->getParent()),
16791681 TopInst(TopInst),
1680 modified(modified)
1682 modified(modified),
1683 Context(TopInst->getParent()->getContext())
16811684 {
16821685 assert(Top && "VRPSolver created for unreachable basic block.");
16831686 assert(Top->getBlock() == TopInst->getParent() && "Context mismatch.");
17781781
17791782 if (ConstantInt *CI = dyn_cast(Canonical)) {
17801783 if (ConstantInt *Arg = dyn_cast(LHS)) {
1781 add(RHS, ConstantInt::get(CI->getValue() ^ Arg->getValue()),
1784 add(RHS,
1785 Context->getConstantInt(CI->getValue() ^ Arg->getValue()),
17821786 ICmpInst::ICMP_EQ, NewContext);
17831787 }
17841788 }
24032407 DomTreeDFS::Node *Root = DTDFS->getRootNode();
24042408 VN = new ValueNumbering(DTDFS);
24052409 IG = new InequalityGraph(*VN, Root);
2406 VR = new ValueRanges(*VN, TD);
2410 VR = new ValueRanges(*VN, TD, Context);
24072411 WorkList.push_back(Root);
24082412
24092413 do {
25252529
25262530 void PredicateSimplifier::Forwards::visitSExtInst(SExtInst &SI) {
25272531 VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &SI);
2532 LLVMContext *Context = SI.getParent()->getContext();
25282533 uint32_t SrcBitWidth = cast(SI.getSrcTy())->getBitWidth();
25292534 uint32_t DstBitWidth = cast(SI.getDestTy())->getBitWidth();
25302535 APInt Min(APInt::getHighBitsSet(DstBitWidth, DstBitWidth-SrcBitWidth+1));
25312536 APInt Max(APInt::getLowBitsSet(DstBitWidth, SrcBitWidth-1));
2532 VRP.add(ConstantInt::get(Min), &SI, ICmpInst::ICMP_SLE);
2533 VRP.add(ConstantInt::get(Max), &SI, ICmpInst::ICMP_SGE);
2537 VRP.add(Context->getConstantInt(Min), &SI, ICmpInst::ICMP_SLE);
2538 VRP.add(Context->getConstantInt(Max), &SI, ICmpInst::ICMP_SGE);
25342539 VRP.solve();
25352540 }
25362541
25372542 void PredicateSimplifier::Forwards::visitZExtInst(ZExtInst &ZI) {
25382543 VRPSolver VRP(VN, IG, UB, VR, PS->DTDFS, PS->modified, &ZI);
2544 LLVMContext *Context = ZI.getParent()->getContext();
25392545 uint32_t SrcBitWidth = cast(ZI.getSrcTy())->getBitWidth();
25402546 uint32_t DstBitWidth = cast(ZI.getDestTy())->getBitWidth();
25412547 APInt Max(APInt::getLowBitsSet(DstBitWidth, SrcBitWidth));
2542 VRP.add(ConstantInt::get(Max), &ZI, ICmpInst::ICMP_UGE);
2548 VRP.add(Context->getConstantInt(Max), &ZI, ICmpInst::ICMP_UGE);
25432549 VRP.solve();
25442550 }
25452551
26282634
26292635 Pred = IC.getPredicate();
26302636
2637 LLVMContext *Context = IC.getParent()->getContext();
2638
26312639 if (ConstantInt *Op1 = dyn_cast(IC.getOperand(1))) {
26322640 ConstantInt *NextVal = 0;
26332641 switch (Pred) {
26352643 case ICmpInst::ICMP_SLT:
26362644 case ICmpInst::ICMP_ULT:
26372645 if (Op1->getValue() != 0)
2638 NextVal = ConstantInt::get(Op1->getValue()-1);
2646 NextVal = Context->getConstantInt(Op1->getValue()-1);
26392647 break;
26402648 case ICmpInst::ICMP_SGT:
26412649 case ICmpInst::ICMP_UGT:
26422650 if (!Op1->getValue().isAllOnesValue())
2643 NextVal = ConstantInt::get(Op1->getValue()+1);
2651 NextVal = Context->getConstantInt(Op1->getValue()+1);
26442652 break;
26452653 }
26462654
16611661 }
16621662
16631663 bool IPSCCP::runOnModule(Module &M) {
1664 Context = &M.getContext();
1665
16641666 SCCPSolver Solver;
1667 Solver.setContext(Context);
16651668
16661669 // Loop over all functions, marking arguments to those with their addresses
16671670 // taken or that are external as overdefined.
17291729 /// doInitialization - Add attributes to well-known functions.
17301730 ///
17311731 bool SimplifyLibCalls::doInitialization(Module &M) {
1732 Context = &M.getContext();
1733
17321734 Modified = false;
17331735 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
17341736 Function &F = *I;
114114 // doInitialization - Make sure that there is a prototype for abort in the
115115 // current module.
116116 bool LowerInvoke::doInitialization(Module &M) {
117 Context = &M.getContext();
118
117119 const Type *VoidPtrTy = Context->getPointerTypeUnqual(Type::Int8Ty);
118120 AbortMessage = 0;
119121 if (ExpensiveEHSupport) {
187187 TrueFalseCleanup.Register();
188188
189189 return WhichOne ? TheTrueVal : TheFalseVal;
190 }
191
192
193 namespace {
194 struct DenseMapAPIntKeyInfo {
195 struct KeyTy {
196 APInt val;
197 const Type* type;
198 KeyTy(const APInt& V, const Type* Ty) : val(V), type(Ty) {}
199 KeyTy(const KeyTy& that) : val(that.val), type(that.type) {}
200 bool operator==(const KeyTy& that) const {
201 return type == that.type && this->val == that.val;
202 }
203 bool operator!=(const KeyTy& that) const {
204 return !this->operator==(that);
205 }
206 };
207 static inline KeyTy getEmptyKey() { return KeyTy(APInt(1,0), 0); }
208 static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1,1), 0); }
209 static unsigned getHashValue(const KeyTy &Key) {
210 return DenseMapInfo::getHashValue(Key.type) ^
211 Key.val.getHashValue();
212 }
213 static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {
214 return LHS == RHS;
215 }
216 static bool isPod() { return false; }
217 };
218 }
219
220
221 typedef DenseMap
222 DenseMapAPIntKeyInfo> IntMapTy;
223 static ManagedStatic IntConstants;
224
225 // Get a ConstantInt from an APInt. Note that the value stored in the DenseMap
226 // as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
227 // operator== and operator!= to ensure that the DenseMap doesn't attempt to
228 // compare APInt's of different widths, which would violate an APInt class
229 // invariant which generates an assertion.
230 ConstantInt *ConstantInt::get(const APInt& V) {
231 // Get the corresponding integer type for the bit width of the value.
232 const IntegerType *ITy = IntegerType::get(V.getBitWidth());
233 // get an existing value or the insertion position
234 DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
235
236 ConstantsLock->reader_acquire();
237 ConstantInt *&Slot = (*IntConstants)[Key];
238 ConstantsLock->reader_release();
239
240 if (!Slot) {
241 sys::SmartScopedWriter Writer(*ConstantsLock);
242 ConstantInt *&NewSlot = (*IntConstants)[Key];
243 if (!Slot) {
244 NewSlot = new ConstantInt(ITy, V);
245 }
246
247 return NewSlot;
248 } else {
249 return Slot;
250 }
251190 }
252191
253192 //===----------------------------------------------------------------------===//
2828 return *GlobalContext;
2929 }
3030
31 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
31 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
3232 LLVMContext::~LLVMContext() { delete pImpl; }
3333
3434 // Constant accessors
116116 }
117117
118118 ConstantInt* LLVMContext::getConstantInt(const APInt& V) {
119 return ConstantInt::get(V);
119 return pImpl->getConstantInt(V);
120120 }
121121
122122 Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) {
0 //===--------------- LLVMContextImpl.cpp - Implementation ------*- C++ -*--===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements LLVMContextImpl, the opaque implementation
10 // of LLVMContext.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "LLVMContextImpl.h"
15 #include "llvm/Constants.h"
16 #include "llvm/DerivedTypes.h"
17 #include "llvm/LLVMContext.h"
18 using namespace llvm;
19
20 // Get a ConstantInt from an APInt. Note that the value stored in the DenseMap
21 // as the key, is a DenseMapAPIntKeyInfo::KeyTy which has provided the
22 // operator== and operator!= to ensure that the DenseMap doesn't attempt to
23 // compare APInt's of different widths, which would violate an APInt class
24 // invariant which generates an assertion.
25 ConstantInt *LLVMContextImpl::getConstantInt(const APInt& V) {
26 // Get the corresponding integer type for the bit width of the value.
27 const IntegerType *ITy = Context.getIntegerType(V.getBitWidth());
28 // get an existing value or the insertion position
29 DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);
30
31 ConstantsLock.reader_acquire();
32 ConstantInt *&Slot = IntConstants[Key];
33 ConstantsLock.reader_release();
34
35 if (!Slot) {
36 sys::SmartScopedWriter Writer(ConstantsLock);
37 ConstantInt *&NewSlot = IntConstants[Key];
38 if (!Slot) {
39 NewSlot = new ConstantInt(ITy, V);
40 }
41
42 return NewSlot;
43 } else {
44 return Slot;
45 }
46 }
47
None //===-- llvm/SymbolTableListTraitsImpl.h - Implementation ------*- C++ -*--===//
0 //===----------------- LLVMContextImpl.h - Implementation ------*- C++ -*--===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #ifndef LLVM_LLVMCONTEXT_IMPL_H
1515 #define LLVM_LLVMCONTEXT_IMPL_H
1616
17 #include "llvm/System/RWMutex.h"
18 #include "llvm/ADT/APInt.h"
19 #include "llvm/ADT/DenseMap.h"
20
1721 namespace llvm {
22
23 class ConstantInt;
24 class LLVMContext;
25 class Type;
26
27 struct DenseMapAPIntKeyInfo {
28 struct KeyTy {
29 APInt val;
30 const Type* type;
31 KeyTy(const APInt& V, const Type* Ty) : val(V), type(Ty) {}
32 KeyTy(const KeyTy& that) : val(that.val), type(that.type) {}
33 bool operator==(const KeyTy& that) const {
34 return type == that.type && this->val == that.val;
35 }
36 bool operator!=(const KeyTy& that) const {
37 return !this->operator==(that);
38 }
39 };
40 static inline KeyTy getEmptyKey() { return KeyTy(APInt(1,0), 0); }
41 static inline KeyTy getTombstoneKey() { return KeyTy(APInt(1,1), 0); }
42 static unsigned getHashValue(const KeyTy &Key) {
43 return DenseMapInfo::getHashValue(Key.type) ^
44 Key.val.getHashValue();
45 }
46 static bool isEqual(const KeyTy &LHS, const KeyTy &RHS) {
47 return LHS == RHS;
48 }
49 static bool isPod() { return false; }
50 };
51
1852 class LLVMContextImpl {
19
53 sys::SmartRWMutex ConstantsLock;
54
55 typedef DenseMap
56 DenseMapAPIntKeyInfo> IntMapTy;
57 IntMapTy IntConstants;
58
59 LLVMContext &Context;
60 LLVMContextImpl();
61 LLVMContextImpl(const LLVMContextImpl&);
62 public:
63 LLVMContextImpl(LLVMContext &C) : Context(C) { }
64
65 /// Return a ConstantInt with the specified value and an implied Type. The
66 /// type is the integer type that corresponds to the bit width of the value.
67 ConstantInt* getConstantInt(const APInt &V);
2068 };
2169
2270 }