aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-25 23:55:21 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-25 23:55:21 +0000
commit03d7651c3652e1f0cc86e79b26585d86818da9cf (patch)
treeb37623b927e150417e2964ee0464745404207d39 /lib/VMCore
parent460d51e0c029814cd901a2642bcaa7d776ff5929 (diff)
Remove Value::{isName, getNameRef}.
Also, change MDString to use a StringRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp41
-rw-r--r--lib/VMCore/AutoUpgrade.cpp18
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp3
-rw-r--r--lib/VMCore/Value.cpp12
-rw-r--r--lib/VMCore/ValueSymbolTable.cpp2
5 files changed, 28 insertions, 48 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 9b3d2edd78..bb117e1418 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -66,10 +66,9 @@ static const Module *getModuleFromVal(const Value *V) {
// PrintEscapedString - Print each character of the specified string, escaping
// it if it is not printable or if it is an escape char.
-static void PrintEscapedString(const char *Str, unsigned Length,
- raw_ostream &Out) {
- for (unsigned i = 0; i != Length; ++i) {
- unsigned char C = Str[i];
+static void PrintEscapedString(const StringRef &Name, raw_ostream &Out) {
+ for (unsigned i = 0, e = Name.size(); i != e; ++i) {
+ unsigned char C = Name[i];
if (isprint(C) && C != '\\' && C != '"')
Out << C;
else
@@ -77,12 +76,6 @@ static void PrintEscapedString(const char *Str, unsigned Length,
}
}
-// PrintEscapedString - Print each character of the specified string, escaping
-// it if it is not printable or if it is an escape char.
-static void PrintEscapedString(const std::string &Str, raw_ostream &Out) {
- PrintEscapedString(Str.c_str(), Str.size(), Out);
-}
-
enum PrefixType {
GlobalPrefix,
LabelPrefix,
@@ -93,9 +86,9 @@ enum PrefixType {
/// PrintLLVMName - Turn the specified name into an 'LLVM name', which is either
/// prefixed with % (if the string only contains simple characters) or is
/// surrounded with ""'s (if it has special chars in it). Print it out.
-static void PrintLLVMName(raw_ostream &OS, const char *NameStr,
- unsigned NameLen, PrefixType Prefix) {
- assert(NameStr && "Cannot get empty name!");
+static void PrintLLVMName(raw_ostream &OS, const StringRef &Name,
+ PrefixType Prefix) {
+ assert(Name.data() && "Cannot get empty name!");
switch (Prefix) {
default: llvm_unreachable("Bad prefix!");
case NoPrefix: break;
@@ -105,10 +98,10 @@ static void PrintLLVMName(raw_ostream &OS, const char *NameStr,
}
// Scan the name to see if it needs quotes first.
- bool NeedsQuotes = isdigit(NameStr[0]);
+ bool NeedsQuotes = isdigit(Name[0]);
if (!NeedsQuotes) {
- for (unsigned i = 0; i != NameLen; ++i) {
- char C = NameStr[i];
+ for (unsigned i = 0, e = Name.size(); i != e; ++i) {
+ char C = Name[i];
if (!isalnum(C) && C != '-' && C != '.' && C != '_') {
NeedsQuotes = true;
break;
@@ -118,14 +111,14 @@ static void PrintLLVMName(raw_ostream &OS, const char *NameStr,
// If we didn't need any quotes, just write out the name in one blast.
if (!NeedsQuotes) {
- OS.write(NameStr, NameLen);
+ OS << Name;
return;
}
// Okay, we need quotes. Output the quotes and escape any scary characters as
// needed.
OS << '"';
- PrintEscapedString(NameStr, NameLen, OS);
+ PrintEscapedString(Name, OS);
OS << '"';
}
@@ -133,7 +126,7 @@ static void PrintLLVMName(raw_ostream &OS, const char *NameStr,
/// prefixed with % (if the string only contains simple characters) or is
/// surrounded with ""'s (if it has special chars in it). Print it out.
static void PrintLLVMName(raw_ostream &OS, const Value *V) {
- PrintLLVMName(OS, V->getNameStart(), V->getNameLen(),
+ PrintLLVMName(OS, V->getName(),
isa<GlobalValue>(V) ? GlobalPrefix : LocalPrefix);
}
@@ -433,7 +426,7 @@ static void AddModuleTypesToPrinter(TypePrinting &TP,
// Get the name as a string and insert it into TypeNames.
std::string NameStr;
raw_string_ostream NameOS(NameStr);
- PrintLLVMName(NameOS, TI->first.c_str(), TI->first.length(), LocalPrefix);
+ PrintLLVMName(NameOS, TI->first, LocalPrefix);
TP.addTypeName(Ty, NameOS.str());
}
@@ -1138,7 +1131,7 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
if (const MDString *MDS = dyn_cast<MDString>(V)) {
Out << "!\"";
- PrintEscapedString(MDS->begin(), MDS->length(), Out);
+ PrintEscapedString(MDS->getString(), Out);
Out << '"';
return;
}
@@ -1474,7 +1467,7 @@ void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) {
for (TypeSymbolTable::const_iterator TI = ST.begin(), TE = ST.end();
TI != TE; ++TI) {
Out << '\t';
- PrintLLVMName(Out, &TI->first[0], TI->first.size(), LocalPrefix);
+ PrintLLVMName(Out, TI->first, LocalPrefix);
Out << " = type ";
// Make sure we print out at least one level of the type structure, so
@@ -1605,7 +1598,7 @@ void AssemblyWriter::printArgument(const Argument *Arg,
void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
if (BB->hasName()) { // Print out the label if it exists...
Out << "\n";
- PrintLLVMName(Out, BB->getNameStart(), BB->getNameLen(), LabelPrefix);
+ PrintLLVMName(Out, BB->getName(), LabelPrefix);
Out << ':';
} else if (!BB->use_empty()) { // Don't print block # of no uses...
Out << "\n; <label>:";
@@ -1982,7 +1975,7 @@ void Value::print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const {
TypePrinter.print(MDS->getType(), OS);
OS << ' ';
OS << "!\"";
- PrintEscapedString(MDS->begin(), MDS->length(), OS);
+ PrintEscapedString(MDS->getString(), OS);
OS << '"';
} else if (const MDNode *N = dyn_cast<MDNode>(this)) {
SlotTracker SlotTable(N);
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp
index ca2e57d4b7..c771500d91 100644
--- a/lib/VMCore/AutoUpgrade.cpp
+++ b/lib/VMCore/AutoUpgrade.cpp
@@ -241,23 +241,23 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
bool isMovSD = false, isShufPD = false;
bool isUnpckhPD = false, isUnpcklPD = false;
bool isPunpckhQPD = false, isPunpcklQPD = false;
- if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadh.pd") == 0)
+ if (F->getName() == "llvm.x86.sse2.loadh.pd")
isLoadH = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.loadl.pd") == 0)
+ else if (F->getName() == "llvm.x86.sse2.loadl.pd")
isLoadL = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.movl.dq") == 0)
+ else if (F->getName() == "llvm.x86.sse2.movl.dq")
isMovL = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.movs.d") == 0)
+ else if (F->getName() == "llvm.x86.sse2.movs.d")
isMovSD = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.shuf.pd") == 0)
+ else if (F->getName() == "llvm.x86.sse2.shuf.pd")
isShufPD = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.unpckh.pd") == 0)
+ else if (F->getName() == "llvm.x86.sse2.unpckh.pd")
isUnpckhPD = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.unpckl.pd") == 0)
+ else if (F->getName() == "llvm.x86.sse2.unpckl.pd")
isUnpcklPD = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.punpckh.qdq") == 0)
+ else if (F->getName() == "llvm.x86.sse2.punpckh.qdq")
isPunpckhQPD = true;
- else if (strcmp(F->getNameStart(), "llvm.x86.sse2.punpckl.qdq") == 0)
+ else if (F->getName() == "llvm.x86.sse2.punpckl.qdq")
isPunpcklQPD = true;
if (isLoadH || isLoadL || isMovL || isMovSD || isShufPD ||
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index 8e6c7778b9..edd76fc031 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -188,8 +188,7 @@ Constant *LLVMContextImpl::getConstantVector(const VectorType *Ty,
void LLVMContextImpl::erase(MDString *M) {
sys::SmartScopedWriter<true> Writer(ConstantsLock);
- MDStringCache.erase(MDStringCache.find(StringRef(M->StrBegin,
- M->length())));
+ MDStringCache.erase(MDStringCache.find(M->getString()));
}
void LLVMContextImpl::erase(MDNode *M) {
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index d020c399fd..9d6af5a334 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -165,13 +165,6 @@ unsigned Value::getNameLen() const {
return Name ? Name->getKeyLength() : 0;
}
-/// isName - Return true if this value has the name specified by the provided
-/// nul terminated string.
-bool Value::isName(const char *N) const {
- unsigned InLen = strlen(N);
- return InLen == getNameLen() && memcmp(getNameStart(), N, InLen) == 0;
-}
-
std::string Value::getNameStr() const {
if (Name == 0) return "";
@@ -179,11 +172,6 @@ std::string Value::getNameStr() const {
Name->getKeyData()+Name->getKeyLength());
}
-StringRef Value::getNameRef() const {
- if (Name == 0) return StringRef();
- return StringRef(Name->getKeyData(), Name->getKeyLength());
-}
-
void Value::setName(const Twine &Name) {
SmallString<32> NameData;
Name.toVector(NameData);
diff --git a/lib/VMCore/ValueSymbolTable.cpp b/lib/VMCore/ValueSymbolTable.cpp
index eae3bf2800..525f3f04d0 100644
--- a/lib/VMCore/ValueSymbolTable.cpp
+++ b/lib/VMCore/ValueSymbolTable.cpp
@@ -43,7 +43,7 @@ void ValueSymbolTable::reinsertValue(Value* V) {
}
// Otherwise, there is a naming conflict. Rename this value.
- SmallString<128> UniqueName(V->getNameStart(), V->getNameEnd());
+ SmallString<128> UniqueName(V->getName().begin(), V->getName().end());
// The name is too already used, just free it so we can allocate a new name.
V->Name->Destroy();