[llvm-commits] [llvm] r94244 - 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 lib/CodeGen/AsmPrinter/DwarfPrinter.cpp lib/CodeGen/AsmPrinter/DwarfPrinter.h
Chris Lattner
sabre at nondot.org
Fri Jan 22 14:56:55 PST 2010
Author: lattner
Date: Fri Jan 22 16:56:55 2010
New Revision: 94244
URL: http://llvm.org/viewvc/llvm-project?rev=94244&view=rev
Log:
move sleb printing out of asmprinter into dwarf printer, make clients
handle the comment better, MCize the non-.sleb case.
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
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h
Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Jan 22 16:56:55 2010
@@ -252,10 +252,6 @@
/// representing an unsigned leb128 value.
void PrintULEB128(unsigned Value) const;
- /// PrintSLEB128 - Print a series of hexidecimal values(separated by commas)
- /// representing a signed leb128 value.
- void PrintSLEB128(int Value) const;
-
//===------------------------------------------------------------------===//
// Emission and print routines
//
@@ -263,16 +259,11 @@
/// 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 Twine &Comment) const;
- void EOL(const Twine &Comment, unsigned Encoding) const;
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value.
void EmitULEB128Bytes(unsigned Value) const;
- /// EmitSLEB128Bytes - print an assembler byte data directive to compose a
- /// signed leb128 value.
- void EmitSLEB128Bytes(int Value) const;
-
/// EmitInt8 - Emit a byte directive and value.
///
void EmitInt8(int Value) const;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jan 22 16:56:55 2010
@@ -672,22 +672,6 @@
} while (Value);
}
-/// PrintSLEB128 - Print a series of hexadecimal values (separated by commas)
-/// representing a signed leb128 value.
-void AsmPrinter::PrintSLEB128(int Value) const {
- int Sign = Value >> (8 * sizeof(Value) - 1);
- bool IsMore;
-
- 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";
- O.write_hex(Byte);
- if (IsMore) O << ", ";
- } while (IsMore);
-}
//===--------------------------------------------------------------------===//
// Emission and print routines
@@ -707,26 +691,13 @@
/// unsigned leb128 value.
void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
if (MAI->hasLEB128()) {
- O << "\t.uleb128\t"
- << Value;
+ O << "\t.uleb128\t" << Value;
} else {
O << MAI->getData8bitsDirective();
PrintULEB128(Value);
}
}
-/// EmitSLEB128Bytes - print an assembler byte data directive to compose a
-/// signed leb128 value.
-void AsmPrinter::EmitSLEB128Bytes(int Value) const {
- if (MAI->hasLEB128()) {
- O << "\t.sleb128\t"
- << Value;
- } else {
- O << MAI->getData8bitsDirective();
- PrintSLEB128(Value);
- }
-}
-
/// EmitInt8 - Emit a byte directive and value.
///
void AsmPrinter::EmitInt8(int Value) const {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Fri Jan 22 16:56:55 2010
@@ -200,7 +200,7 @@
case dwarf::DW_FORM_ref8: // Fall thru
case dwarf::DW_FORM_data8: Size = 8; break;
case dwarf::DW_FORM_udata: Asm->EmitULEB128Bytes(Integer); return;
- case dwarf::DW_FORM_sdata: Asm->EmitSLEB128Bytes(Integer); return;
+ case dwarf::DW_FORM_sdata: D->EmitSLEB128(Integer, ""); return;
default: llvm_unreachable("DIE Value form not supported yet");
}
Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jan 22 16:56:55 2010
@@ -2624,7 +2624,7 @@
// ... otherwise use long hand.
Asm->EmitInt8(dwarf::DW_LNS_advance_line);
Asm->EOL("DW_LNS_advance_line");
- Asm->EmitSLEB128Bytes(Offset); Asm->EOL("Line Offset");
+ EmitSLEB128(Offset, "Line Offset");
Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EOL("DW_LNS_copy");
}
} else {
@@ -2675,8 +2675,7 @@
Asm->EOL("CIE Augmentation");
Asm->EmitULEB128Bytes(1);
Asm->EOL("CIE Code Alignment Factor");
- Asm->EmitSLEB128Bytes(stackGrowth);
- Asm->EOL("CIE Data Alignment Factor");
+ EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false));
Asm->EOL("CIE RA Column");
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Fri Jan 22 16:56:55 2010
@@ -177,8 +177,7 @@
// Round out reader.
Asm->EmitULEB128Bytes(1);
Asm->EOL("CIE Code Alignment Factor");
- Asm->EmitSLEB128Bytes(stackGrowth);
- Asm->EOL("CIE Data Alignment Factor");
+ EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
Asm->EOL("CIE Return Address Column");
@@ -894,17 +893,13 @@
//
// Used by the runtime to match the type of the thrown exception to the
// type of the catch clauses or the types in the exception specification.
-
- Asm->EmitSLEB128Bytes(Action.ValueForTypeID);
- Asm->EOL("TypeInfo index");
+ EmitSLEB128(Action.ValueForTypeID, "TypeInfo index");
// Action Record
//
// Self-relative signed displacement in bytes of the next action record,
// or 0 if there is no next action record.
-
- Asm->EmitSLEB128Bytes(Action.NextAction);
- Asm->EOL("Next action");
+ EmitSLEB128(Action.NextAction, "Next action");
}
// Emit the Catch TypeInfos.
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Fri Jan 22 16:56:55 2010
@@ -85,6 +85,36 @@
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}
+/// PrintSLEB128 - Print a series of hexadecimal values (separated by commas)
+/// representing a signed leb128 value.
+static void PrintSLEB128(MCStreamer &O, int Value) {
+ int Sign = Value >> (8 * sizeof(Value) - 1);
+ bool IsMore;
+
+ do {
+ unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
+ Value >>= 7;
+ IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
+ if (IsMore) Byte |= 0x80;
+
+ O.EmitIntValue(Byte, 1, /*addrspace*/0);
+ } while (IsMore);
+}
+
+/// EmitSLEB128 - print the specified signed leb128 value.
+void DwarfPrinter::EmitSLEB128(int Value, const char *Desc) const {
+ if (Asm->VerboseAsm && Desc)
+ Asm->OutStreamer.AddComment(Desc);
+
+ if (MAI->hasLEB128()) {
+ O << "\t.sleb128\t" << Value;
+ Asm->OutStreamer.AddBlankLine();
+ } else {
+ PrintSLEB128(Asm->OutStreamer, Value);
+ }
+}
+
+
/// PrintLabelName - Print label name in form used by Dwarf writer.
///
@@ -267,8 +297,7 @@
Asm->EOL("DW_CFA_offset_extended_sf");
Asm->EmitULEB128Bytes(Reg);
Asm->EOL("Reg");
- Asm->EmitSLEB128Bytes(Offset);
- Asm->EOL("Offset");
+ EmitSLEB128(Offset, "Offset");
} else if (Reg < 64) {
Asm->EmitInt8(dwarf::DW_CFA_offset + Reg);
Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")");
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h?rev=94244&r1=94243&r2=94244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Fri Jan 22 16:56:55 2010
@@ -87,11 +87,14 @@
/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
/// encoding. If verbose assembly output is enabled, we output comments
- /// describing the encoding. Desc is an optional string saying what the
- /// encoding is specifying (e.g. "LSDA").
- void EmitEncodingByte(unsigned Val, const char *Desc = 0);
+ /// describing the encoding. Desc is a string saying what the encoding is
+ /// specifying (e.g. "LSDA").
+ void EmitEncodingByte(unsigned Val, const char *Desc);
+
+ /// EmitSLEB128 - print the specified signed leb128 value.
+ void EmitSLEB128(int Value, const char *Desc) const;
+
-
/// PrintLabelName - Print label name in form used by Dwarf writer.
///
void PrintLabelName(const DWLabel &Label) const {
More information about the llvm-commits
mailing list