llvm.org GIT mirror llvm / 04e3b1e
move some method definitions to files that make sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99927 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
3 changed file(s) with 54 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
19451945 const char *ConstantExpr::getOpcodeName() const {
19461946 return Instruction::getOpcodeName(getOpcode());
19471947 }
1948
1949
1950
1951 GetElementPtrConstantExpr::
1952 GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList,
1953 const Type *DestTy)
1954 : ConstantExpr(DestTy, Instruction::GetElementPtr,
1955 OperandTraits::op_end(this)
1956 - (IdxList.size()+1), IdxList.size()+1) {
1957 OperandList[0] = C;
1958 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
1959 OperandList[i+1] = IdxList[i];
1960 }
1961
19481962
19491963 //===----------------------------------------------------------------------===//
19501964 // replaceUsesOfWithOnConstant implementations
2828 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
2929 LLVMContext::~LLVMContext() { delete pImpl; }
3030
31 GetElementPtrConstantExpr::GetElementPtrConstantExpr
32 (Constant *C,
33 const std::vector &IdxList,
34 const Type *DestTy)
35 : ConstantExpr(DestTy, Instruction::GetElementPtr,
36 OperandTraits::op_end(this)
37 - (IdxList.size()+1),
38 IdxList.size()+1) {
39 OperandList[0] = C;
40 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
41 OperandList[i+1] = IdxList[i];
31
32 #ifndef NDEBUG
33 /// isValidName - Return true if Name is a valid custom metadata handler name.
34 static bool isValidName(StringRef MDName) {
35 if (MDName.empty())
36 return false;
37
38 if (!isalpha(MDName[0]))
39 return false;
40
41 for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E;
42 ++I) {
43 if (!isalnum(*I) && *I != '_' && *I != '-' && *I != '.')
44 return false;
45 }
46 return true;
47 }
48 #endif
49
50 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
51 unsigned LLVMContext::getMDKindID(StringRef Name) const {
52 assert(isValidName(Name) && "Invalid MDNode name");
53
54 unsigned &Entry = pImpl->CustomMDKindNames[Name];
55
56 // If this is new, assign it its ID.
57 if (Entry == 0) Entry = pImpl->CustomMDKindNames.size();
58 return Entry;
4259 }
4360
61 /// getHandlerNames - Populate client supplied smallvector using custome
62 /// metadata name and ID.
63 void LLVMContext::getMDKindNames(SmallVectorImpl &Names) const {
64 Names.resize(pImpl->CustomMDKindNames.size()+1);
65 Names[0] = "";
66 for (StringMap::const_iterator I = pImpl->CustomMDKindNames.begin(),
67 E = pImpl->CustomMDKindNames.end(); I != E; ++I)
68 // MD Handlers are numbered from 1.
69 Names[I->second] = I->first();
70 }
71
72
411411 }
412412
413413 //===----------------------------------------------------------------------===//
414 // LLVMContext MDKind naming implementation.
415 //
416
417 #ifndef NDEBUG
418 /// isValidName - Return true if Name is a valid custom metadata handler name.
419 static bool isValidName(StringRef MDName) {
420 if (MDName.empty())
421 return false;
422
423 if (!isalpha(MDName[0]))
424 return false;
425
426 for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E;
427 ++I) {
428 if (!isalnum(*I) && *I != '_' && *I != '-' && *I != '.')
429 return false;
430 }
431 return true;
432 }
433 #endif
434
435 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
436 unsigned LLVMContext::getMDKindID(StringRef Name) const {
437 assert(isValidName(Name) && "Invalid MDNode name");
438
439 unsigned &Entry = pImpl->CustomMDKindNames[Name];
440
441 // If this is new, assign it its ID.
442 if (Entry == 0) Entry = pImpl->CustomMDKindNames.size();
443 return Entry;
444 }
445
446 /// getHandlerNames - Populate client supplied smallvector using custome
447 /// metadata name and ID.
448 void LLVMContext::getMDKindNames(SmallVectorImpl &Names) const {
449 Names.resize(pImpl->CustomMDKindNames.size()+1);
450 Names[0] = "";
451 for (StringMap::const_iterator I = pImpl->CustomMDKindNames.begin(),
452 E = pImpl->CustomMDKindNames.end(); I != E; ++I)
453 // MD Handlers are numbered from 1.
454 Names[I->second] = I->first();
455 }
456
457 //===----------------------------------------------------------------------===//
458414 // Instruction Metadata method implementations.
459415 //
460416