[llvm-commits] [llvm] r93680 - 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/DwarfPrinter.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Jan 16 23:46:39 PST 2010
Author: d0k
Date: Sun Jan 17 01:46:39 2010
New Revision: 93680
URL: http://llvm.org/viewvc/llvm-project?rev=93680&view=rev
Log:
Switch some functions to take Twines, eliminate uses of StringExtras.h.
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/DwarfPrinter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=93680&r1=93679&r2=93680&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Sun Jan 17 01:46:39 2010
@@ -53,6 +53,7 @@
class Mangler;
class MCAsmInfo;
class TargetLoweringObjectFile;
+ class Twine;
class Type;
class formatted_raw_ostream;
@@ -262,14 +263,13 @@
/// 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
/// then it will be printed first. Comments should not contain '\n'.
void EOL() const;
- void EOL(const std::string &Comment) const;
- void EOL(const char* Comment) const;
- void EOL(const char *Comment, unsigned Encoding) const;
+ void EOL(const Twine &Comment) const;
+ void EOL(const Twine &Comment, unsigned Encoding) const;
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value.
@@ -302,7 +302,7 @@
void EmitString(const char *String, unsigned Size) const;
/// EmitFile - Emit a .file directive.
- void EmitFile(unsigned Number, const std::string &Name) const;
+ 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=93680&r1=93679&r2=93680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sun Jan 17 01:46:39 2010
@@ -43,7 +43,6 @@
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/StringExtras.h"
#include <cerrno>
using namespace llvm;
@@ -523,12 +522,11 @@
/// PrintULEB128 - Print a series of hexadecimal values (separated by commas)
/// representing an unsigned leb128 value.
void AsmPrinter::PrintULEB128(unsigned Value) const {
- char Buffer[20];
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
if (Value) Byte |= 0x80;
- O << "0x" << utohex_buffer(Byte, Buffer+20);
+ PrintHex(Byte);
if (Value) O << ", ";
} while (Value);
}
@@ -538,14 +536,13 @@
void AsmPrinter::PrintSLEB128(int Value) const {
int Sign = Value >> (8 * sizeof(Value) - 1);
bool IsMore;
- char Buffer[20];
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
if (IsMore) Byte |= 0x80;
- O << "0x" << utohex_buffer(Byte, Buffer+20);
+ PrintHex(Byte);
if (IsMore) O << ", ";
} while (IsMore);
}
@@ -556,9 +553,9 @@
/// PrintHex - Print a value as a hexadecimal value.
///
-void AsmPrinter::PrintHex(int Value) const {
- char Buffer[20];
- O << "0x" << utohex_buffer(static_cast<unsigned>(Value), Buffer+20);
+void AsmPrinter::PrintHex(uint64_t Value) const {
+ O << "0x";
+ O.write_hex(Value);
}
/// EOL - Print a newline character to asm stream. If a comment is present
@@ -567,18 +564,8 @@
O << '\n';
}
-void AsmPrinter::EOL(const std::string &Comment) const {
- if (VerboseAsm && !Comment.empty()) {
- O.PadToColumn(MAI->getCommentColumn());
- O << MAI->getCommentString()
- << ' '
- << Comment;
- }
- O << '\n';
-}
-
-void AsmPrinter::EOL(const char* Comment) const {
- if (VerboseAsm && *Comment) {
+void AsmPrinter::EOL(const Twine &Comment) const {
+ if (VerboseAsm && !Comment.isTriviallyEmpty()) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< ' '
@@ -624,8 +611,8 @@
return 0;
}
-void AsmPrinter::EOL(const char *Comment, unsigned Encoding) const {
- if (VerboseAsm && *Comment) {
+void AsmPrinter::EOL(const Twine &Comment, unsigned Encoding) const {
+ if (VerboseAsm && !Comment.isTriviallyEmpty()) {
O.PadToColumn(MAI->getCommentColumn());
O << MAI->getCommentString()
<< ' '
@@ -755,7 +742,7 @@
/// 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 << " \"";
for (unsigned i = 0, N = Name.size(); i < N; ++i)
printStringChar(O, Name[i]);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=93680&r1=93679&r2=93680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Sun Jan 17 01:46:39 2010
@@ -13,6 +13,7 @@
#include "DIE.h"
#include "DwarfPrinter.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h"
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=93680&r1=93679&r2=93680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Jan 17 01:46:39 2010
@@ -2343,14 +2343,10 @@
// Emit the code (index) for the abbreviation.
Asm->EmitULEB128Bytes(AbbrevNumber);
- if (Asm->isVerbose())
- Asm->EOL(std::string("Abbrev [" +
- utostr(AbbrevNumber) +
- "] 0x" + utohexstr(Die->getOffset()) +
- ":0x" + utohexstr(Die->getSize()) + " " +
- dwarf::TagString(Abbrev->getTag())));
- else
- Asm->EOL();
+ Asm->EOL("Abbrev [" + Twine(AbbrevNumber) + "] 0x" +
+ Twine::utohexstr(Die->getOffset()) + ":0x" +
+ Twine::utohexstr(Die->getSize()) + " " +
+ dwarf::TagString(Abbrev->getTag()));
SmallVector<DIEValue*, 32> &Values = Die->getValues();
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=93680&r1=93679&r2=93680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Sun Jan 17 01:46:39 2010
@@ -24,7 +24,6 @@
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/ADT/StringExtras.h"
using namespace llvm;
Dwarf::Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
@@ -225,10 +224,7 @@
Asm->EOL("Offset");
} else if (Reg < 64) {
Asm->EmitInt8(dwarf::DW_CFA_offset + Reg);
- if (Asm->isVerbose())
- Asm->EOL("DW_CFA_offset + Reg (" + utostr(Reg) + ")");
- else
- Asm->EOL();
+ Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")");
Asm->EmitULEB128Bytes(Offset);
Asm->EOL("Offset");
} else {
More information about the llvm-commits
mailing list