aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-23 03:11:46 +0000
committerChris Lattner <sabre@nondot.org>2010-01-23 03:11:46 +0000
commit4cf202ba066a1310d8968c8d069787254934e59b (patch)
treec11be4e2c2e98a26772d0e2778384080638a2a0b
parent4fe5d72765121893f77139889958d4f5e5ca69c5 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94277 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h6
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp23
-rw-r--r--lib/CodeGen/AsmPrinter/DIE.cpp4
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp36
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp4
5 files changed, 27 insertions, 46 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 305d246298..b45be2752b 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -265,12 +265,6 @@ namespace llvm {
///
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;
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index fcab4aa5e9..50842078b4 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -715,29 +715,6 @@ static void printStringChar(formatted_raw_ostream &O, unsigned char C) {
}
}
-/// 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 << " \"";
diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp
index 3bdc50d893..349e0ac40f 100644
--- a/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -242,7 +242,9 @@ void DIEInteger::print(raw_ostream &O) {
/// 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
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index cc2ff8c571..513987f902 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -344,7 +344,7 @@ void DwarfDebug::addSInt(DIE *Die, unsigned Attribute,
/// 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 @@ void DwarfDebug::emitDebugLines() {
// 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 @@ void DwarfDebug::emitDebugLines() {
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 @@ void DwarfDebug::emitCommonDebugFrame() {
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 @@ void DwarfDebug::emitDebugPubNames() {
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 @@ void DwarfDebug::emitDebugPubTypes() {
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 @@ void DwarfDebug::emitDebugStr() {
// 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 @@ void DwarfDebug::emitDebugInlineInfo() {
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",
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index 3cb9d3b511..9a1c41c2a6 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -146,7 +146,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
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 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
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.