diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-07-21 16:50:35 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-07-21 16:50:35 +0000 |
commit | 2b7f265048ce0b5fdea04360160f036d679824d7 (patch) | |
tree | e1fb495a3cb4de8b7ac41a113257dc9fd64560f7 /llvm/lib/IR | |
parent | 34d17fb54d56b57caf77734cb7428d0b4fc19ae6 (diff) | |
download | bcm5719-llvm-2b7f265048ce0b5fdea04360160f036d679824d7.tar.gz bcm5719-llvm-2b7f265048ce0b5fdea04360160f036d679824d7.zip |
IR: Extract a function 'printLLVMNameWithoutPrefix' from 'PrintLLVMName'. NFC.
This commit extracts the code that prints out a name of an LLVM value without a
prefix from a function 'PrintLLVMName' into a publicly accessible function named
'printLLVMNameWithoutPrefix'.
This change would be useful for MIR serialization, as it would allow the MIR
printer to reuse this function to print out the names of the external symbol
machine operands.
Reviewers: Duncan P. N. Exon Smith
llvm-svn: 242803
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index adc620db897..d2d15b3a665 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -343,18 +343,8 @@ enum PrefixType { NoPrefix }; -/// 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, StringRef Name, PrefixType Prefix) { +void llvm::printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name) { assert(!Name.empty() && "Cannot get empty name!"); - switch (Prefix) { - case NoPrefix: break; - case GlobalPrefix: OS << '@'; break; - case ComdatPrefix: OS << '$'; break; - case LabelPrefix: break; - case LocalPrefix: OS << '%'; break; - } // Scan the name to see if it needs quotes first. bool NeedsQuotes = isdigit(static_cast<unsigned char>(Name[0])); @@ -386,9 +376,31 @@ static void PrintLLVMName(raw_ostream &OS, StringRef Name, PrefixType Prefix) { OS << '"'; } -/// 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. +/// 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, StringRef Name, PrefixType Prefix) { + switch (Prefix) { + case NoPrefix: + break; + case GlobalPrefix: + OS << '@'; + break; + case ComdatPrefix: + OS << '$'; + break; + case LabelPrefix: + break; + case LocalPrefix: + OS << '%'; + break; + } + printLLVMNameWithoutPrefix(OS, Name); +} + +/// 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 Value *V) { PrintLLVMName(OS, V->getName(), isa<GlobalValue>(V) ? GlobalPrefix : LocalPrefix); |