[llvm-commits] [llvm] r94277 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DIE.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfException.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 22 19:11:46 PST 2010
Author: lattner
Date: Fri Jan 22 21:11:46 2010
New Revision: 94277
URL: http://llvm.org/viewvc/llvm-project?rev=94277&view=rev
Log:
remove one form of EmitString, just use EmitBytes instead. We must
be careful to add a \0 at the end though, because EmitString didn't
do this.
Modified:
llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=94277&r1=94276&r2=94277&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 22 21:11:46 2010
@@ -265,12 +265,6 @@
///
void EmitInt64(uint64_t Value) const;
- /// EmitString - Emit a string with quotes and a null terminator.
- /// Special characters are emitted properly.
- /// @verbatim (Eg. '\t') @endverbatim
- void EmitString(const StringRef String) const;
- void EmitString(const char *String, unsigned Size) const;
-
/// EmitFile - Emit a .file directive.
void EmitFile(unsigned Number, StringRef Name) const;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94277&r1=94276&r2=94277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 22 21:11:46 2010
@@ -715,29 +715,6 @@
}
}
-/// EmitString - Emit a string with quotes and a null terminator.
-/// Special characters are emitted properly.
-/// \literal (Eg. '\t') \endliteral
-void AsmPrinter::EmitString(const StringRef String) const {
- EmitString(String.data(), String.size());
-}
-
-void AsmPrinter::EmitString(const char *String, unsigned Size) const {
- const char* AscizDirective = MAI->getAscizDirective();
- if (AscizDirective)
- O << AscizDirective;
- else
- O << MAI->getAsciiDirective();
- O << '\"';
- for (unsigned i = 0; i < Size; ++i)
- printStringChar(O, String[i]);
- if (AscizDirective)
- O << '\"';
- else
- O << "\\0\"";
-}
-
-
/// EmitFile - Emit a .file directive.
void AsmPrinter::EmitFile(unsigned Number, StringRef Name) const {
O << "\t.file\t" << Number << " \"";
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=94277&r1=94276&r2=94277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Fri Jan 22 21:11:46 2010
@@ -242,7 +242,9 @@
/// EmitValue - Emit string value.
///
void DIEString::EmitValue(DwarfPrinter *D, unsigned Form) const {
- D->getAsm()->EmitString(Str);
+ D->getAsm()->OutStreamer.EmitBytes(Str, /*addrspace*/0);
+ // Emit nul terminator.
+ D->getAsm()->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0);
}
#ifndef NDEBUG
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=94277&r1=94276&r2=94277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jan 22 21:11:46 2010
@@ -344,7 +344,7 @@
/// addString - Add a string attribute data and value. DIEString only
/// keeps string reference.
void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
- const StringRef String) {
+ StringRef String) {
DIEValue *Value = new DIEString(String);
DIEValues.push_back(Value);
Die->addValue(Attribute, Form, Value);
@@ -2526,8 +2526,9 @@
// Emit directories.
for (unsigned DI = 1, DE = getNumSourceDirectories()+1; DI != DE; ++DI) {
- Asm->EmitString(getSourceDirectoryName(DI));
- EOL("Directory");
+ const std::string &Dir = getSourceDirectoryName(DI);
+ if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Directory");
+ Asm->OutStreamer.EmitBytes(StringRef(Dir.c_str(), Dir.size()+1), 0);
}
Asm->EmitInt8(0); EOL("End of directories");
@@ -2536,8 +2537,10 @@
for (unsigned SI = 1, SE = getNumSourceIds()+1; SI != SE; ++SI) {
// Remember source id starts at 1.
std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
- Asm->EmitString(getSourceFileName(Id.second));
- EOL("Source");
+ const std::string &FN = getSourceFileName(Id.second);
+ if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("Source");
+ Asm->OutStreamer.EmitBytes(StringRef(FN.c_str(), FN.size()+1), 0);
+
EmitULEB128(Id.first, "Directory #");
EmitULEB128(0, "Mod date");
EmitULEB128(0, "File size");
@@ -2661,7 +2664,7 @@
EOL("CIE Identifier Tag");
Asm->EmitInt8(dwarf::DW_CIE_VERSION);
EOL("CIE Version");
- Asm->EmitString("");
+ Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator.
EOL("CIE Augmentation");
EmitULEB128(1, "CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
@@ -2743,7 +2746,10 @@
DIE * Entity = GI->second;
Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
- Asm->EmitString(Name, strlen(Name)); EOL("External Name");
+
+ if (Asm->VerboseAsm)
+ Asm->OutStreamer.AddComment("External Name");
+ Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)+1), 0);
}
Asm->EmitInt32(0); EOL("End Mark");
@@ -2778,7 +2784,9 @@
DIE * Entity = GI->second;
Asm->EmitInt32(Entity->getOffset()); EOL("DIE offset");
- Asm->EmitString(Name, strlen(Name)); EOL("External Name");
+
+ if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("External Name");
+ Asm->OutStreamer.EmitBytes(StringRef(Name, strlen(Name)), 0);
}
Asm->EmitInt32(0); EOL("End Mark");
@@ -2803,8 +2811,7 @@
// Emit the string itself.
const std::string &String = StringPool[StringID];
- Asm->EmitString(String);
- Asm->O << '\n';
+ Asm->OutStreamer.EmitBytes(StringRef(String.c_str(), String.size()+1), 0);
}
Asm->O << '\n';
@@ -2920,11 +2927,12 @@
StringRef LName = SP.getLinkageName();
StringRef Name = SP.getName();
- if (LName.empty())
- Asm->EmitString(Name);
- else
+ if (LName.empty()) {
+ Asm->OutStreamer.EmitBytes(Name, 0);
+ Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
+ } else
EmitSectionOffset("string", "section_str",
- StringPool.idFor(getRealLinkageName(LName)), false, true);
+ StringPool.idFor(getRealLinkageName(LName)), false, true);
EOL("MIPS linkage name");
EmitSectionOffset("string", "section_str",
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=94277&r1=94276&r2=94277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Fri Jan 22 21:11:46 2010
@@ -146,7 +146,7 @@
unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
- char Augmentation[5] = { 0 };
+ char Augmentation[6] = { 0 };
unsigned AugmentationSize = 0;
char *APtr = Augmentation + 1;
@@ -171,7 +171,7 @@
if (APtr != Augmentation + 1)
Augmentation[0] = 'z';
- Asm->EmitString(Augmentation);
+ Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
EOL("CIE Augmentation");
// Round out reader.
More information about the llvm-commits
mailing list