diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-22 22:56:55 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-22 22:56:55 +0000 |
| commit | bb9078a6b26f38594cde6fd0dcd17eca25ef0319 (patch) | |
| tree | 5b0930565a7fa07c585f0b431e78cd08e5051bbf /lib/CodeGen/AsmPrinter/DwarfPrinter.cpp | |
| parent | bc5201f8371f9041e79efcca3b158335da5c2604 (diff) | |
move sleb printing out of asmprinter into dwarf printer, make clients
handle the comment better, MCize the non-.sleb case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfPrinter.cpp')
| -rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfPrinter.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp index 99b46d61a0..df8b2d2425 100644 --- a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp @@ -85,6 +85,36 @@ void DwarfPrinter::EmitEncodingByte(unsigned Val, const char *Desc) { 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 @@ void DwarfPrinter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID, 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) + ")"); |
