Switch some functions to take Twines, eliminate uses of StringExtras.h.

llvm-svn: 93680
This commit is contained in:
Benjamin Kramer 2010-01-17 07:46:39 +00:00
parent fa1edea9ce
commit 4d128a2387
5 changed files with 21 additions and 41 deletions

View File

@ -53,6 +53,7 @@ namespace llvm {
class Mangler; class Mangler;
class MCAsmInfo; class MCAsmInfo;
class TargetLoweringObjectFile; class TargetLoweringObjectFile;
class Twine;
class Type; class Type;
class formatted_raw_ostream; class formatted_raw_ostream;
@ -262,14 +263,13 @@ namespace llvm {
/// PrintHex - Print a value as a hexidecimal value. /// PrintHex - Print a value as a hexidecimal value.
/// ///
void PrintHex(int Value) const; void PrintHex(uint64_t Value) const;
/// EOL - Print a newline character to asm stream. If a comment is present /// EOL - Print a newline character to asm stream. If a comment is present
/// then it will be printed first. Comments should not contain '\n'. /// then it will be printed first. Comments should not contain '\n'.
void EOL() const; void EOL() const;
void EOL(const std::string &Comment) const; void EOL(const Twine &Comment) const;
void EOL(const char* Comment) const; void EOL(const Twine &Comment, unsigned Encoding) const;
void EOL(const char *Comment, unsigned Encoding) const;
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value. /// unsigned leb128 value.
@ -302,7 +302,7 @@ namespace llvm {
void EmitString(const char *String, unsigned Size) const; void EmitString(const char *String, unsigned Size) const;
/// EmitFile - Emit a .file directive. /// EmitFile - Emit a .file directive.
void EmitFile(unsigned Number, const std::string &Name) const; void EmitFile(unsigned Number, StringRef Name) const;
//===------------------------------------------------------------------===// //===------------------------------------------------------------------===//

View File

@ -43,7 +43,6 @@
#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include <cerrno> #include <cerrno>
using namespace llvm; using namespace llvm;
@ -523,12 +522,11 @@ void AsmPrinter::EmitXXStructorList(Constant *List) {
/// PrintULEB128 - Print a series of hexadecimal values (separated by commas) /// PrintULEB128 - Print a series of hexadecimal values (separated by commas)
/// representing an unsigned leb128 value. /// representing an unsigned leb128 value.
void AsmPrinter::PrintULEB128(unsigned Value) const { void AsmPrinter::PrintULEB128(unsigned Value) const {
char Buffer[20];
do { do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f); unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7; Value >>= 7;
if (Value) Byte |= 0x80; if (Value) Byte |= 0x80;
O << "0x" << utohex_buffer(Byte, Buffer+20); PrintHex(Byte);
if (Value) O << ", "; if (Value) O << ", ";
} while (Value); } while (Value);
} }
@ -538,14 +536,13 @@ void AsmPrinter::PrintULEB128(unsigned Value) const {
void AsmPrinter::PrintSLEB128(int Value) const { void AsmPrinter::PrintSLEB128(int Value) const {
int Sign = Value >> (8 * sizeof(Value) - 1); int Sign = Value >> (8 * sizeof(Value) - 1);
bool IsMore; bool IsMore;
char Buffer[20];
do { do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f); unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7; Value >>= 7;
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
if (IsMore) Byte |= 0x80; if (IsMore) Byte |= 0x80;
O << "0x" << utohex_buffer(Byte, Buffer+20); PrintHex(Byte);
if (IsMore) O << ", "; if (IsMore) O << ", ";
} while (IsMore); } while (IsMore);
} }
@ -556,9 +553,9 @@ void AsmPrinter::PrintSLEB128(int Value) const {
/// PrintHex - Print a value as a hexadecimal value. /// PrintHex - Print a value as a hexadecimal value.
/// ///
void AsmPrinter::PrintHex(int Value) const { void AsmPrinter::PrintHex(uint64_t Value) const {
char Buffer[20]; O << "0x";
O << "0x" << utohex_buffer(static_cast<unsigned>(Value), Buffer+20); O.write_hex(Value);
} }
/// EOL - Print a newline character to asm stream. If a comment is present /// EOL - Print a newline character to asm stream. If a comment is present
@ -567,18 +564,8 @@ void AsmPrinter::EOL() const {
O << '\n'; O << '\n';
} }
void AsmPrinter::EOL(const std::string &Comment) const { void AsmPrinter::EOL(const Twine &Comment) const {
if (VerboseAsm && !Comment.empty()) { if (VerboseAsm && !Comment.isTriviallyEmpty()) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< ' '
<< Comment;
}
O << '\n';
}
void AsmPrinter::EOL(const char* Comment) const {
if (VerboseAsm && *Comment) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() O << MAI->getCommentString()
<< ' ' << ' '
@ -624,8 +611,8 @@ static const char *DecodeDWARFEncoding(unsigned Encoding) {
return 0; return 0;
} }
void AsmPrinter::EOL(const char *Comment, unsigned Encoding) const { void AsmPrinter::EOL(const Twine &Comment, unsigned Encoding) const {
if (VerboseAsm && *Comment) { if (VerboseAsm && !Comment.isTriviallyEmpty()) {
O.PadToColumn(MAI->getCommentColumn()); O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString() O << MAI->getCommentString()
<< ' ' << ' '
@ -755,7 +742,7 @@ void AsmPrinter::EmitString(const char *String, unsigned Size) const {
/// EmitFile - Emit a .file directive. /// EmitFile - Emit a .file directive.
void AsmPrinter::EmitFile(unsigned Number, const std::string &Name) const { void AsmPrinter::EmitFile(unsigned Number, StringRef Name) const {
O << "\t.file\t" << Number << " \""; O << "\t.file\t" << Number << " \"";
for (unsigned i = 0, N = Name.size(); i < N; ++i) for (unsigned i = 0, N = Name.size(); i < N; ++i)
printStringChar(O, Name[i]); printStringChar(O, Name[i]);

View File

@ -13,6 +13,7 @@
#include "DIE.h" #include "DIE.h"
#include "DwarfPrinter.h" #include "DwarfPrinter.h"
#include "llvm/ADT/Twine.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"

View File

@ -2343,14 +2343,10 @@ void DwarfDebug::emitDIE(DIE *Die) {
// Emit the code (index) for the abbreviation. // Emit the code (index) for the abbreviation.
Asm->EmitULEB128Bytes(AbbrevNumber); Asm->EmitULEB128Bytes(AbbrevNumber);
if (Asm->isVerbose()) Asm->EOL("Abbrev [" + Twine(AbbrevNumber) + "] 0x" +
Asm->EOL(std::string("Abbrev [" + Twine::utohexstr(Die->getOffset()) + ":0x" +
utostr(AbbrevNumber) + Twine::utohexstr(Die->getSize()) + " " +
"] 0x" + utohexstr(Die->getOffset()) + dwarf::TagString(Abbrev->getTag()));
":0x" + utohexstr(Die->getSize()) + " " +
dwarf::TagString(Abbrev->getTag())));
else
Asm->EOL();
SmallVector<DIEValue*, 32> &Values = Die->getValues(); SmallVector<DIEValue*, 32> &Values = Die->getValues();
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData(); const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();

View File

@ -24,7 +24,6 @@
#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm; using namespace llvm;
Dwarf::Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T, Dwarf::Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
@ -225,10 +224,7 @@ void Dwarf::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
Asm->EOL("Offset"); Asm->EOL("Offset");
} else if (Reg < 64) { } else if (Reg < 64) {
Asm->EmitInt8(dwarf::DW_CFA_offset + Reg); Asm->EmitInt8(dwarf::DW_CFA_offset + Reg);
if (Asm->isVerbose()) Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")");
Asm->EOL("DW_CFA_offset + Reg (" + utostr(Reg) + ")");
else
Asm->EOL();
Asm->EmitULEB128Bytes(Offset); Asm->EmitULEB128Bytes(Offset);
Asm->EOL("Offset"); Asm->EOL("Offset");
} else { } else {