mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
add a new DwarfPrinter::EmitEncodingByte method which handles
pretty printing encoding comments and eliminates redundancy on the client side. We now get pretty dwarf like this again: .byte 255 ## @LPStart Encoding = omit .byte 0 ## @TType Encoding = absptr .byte 0x28 ## @TType base offset .byte 3 ## Call site Encoding = udata4 .byte 0x1a ## Call site table size ... llvm-svn: 94239
This commit is contained in:
parent
7b52485bbd
commit
576e41a375
@ -703,56 +703,6 @@ void AsmPrinter::EOL(const Twine &Comment) const {
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
static const char *DecodeDWARFEncoding(unsigned Encoding) {
|
||||
switch (Encoding) {
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
return "absptr";
|
||||
case dwarf::DW_EH_PE_omit:
|
||||
return "omit";
|
||||
case dwarf::DW_EH_PE_pcrel:
|
||||
return "pcrel";
|
||||
case dwarf::DW_EH_PE_udata4:
|
||||
return "udata4";
|
||||
case dwarf::DW_EH_PE_udata8:
|
||||
return "udata8";
|
||||
case dwarf::DW_EH_PE_sdata4:
|
||||
return "sdata4";
|
||||
case dwarf::DW_EH_PE_sdata8:
|
||||
return "sdata8";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
|
||||
return "pcrel udata4";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
|
||||
return "pcrel sdata4";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
|
||||
return "pcrel udata8";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
|
||||
return "pcrel sdata8";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata4:
|
||||
return "indirect pcrel udata4";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata4:
|
||||
return "indirect pcrel sdata4";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata8:
|
||||
return "indirect pcrel udata8";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata8:
|
||||
return "indirect pcrel sdata8";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AsmPrinter::EOL(const Twine &Comment, unsigned Encoding) const {
|
||||
if (VerboseAsm && !Comment.isTriviallyEmpty()) {
|
||||
O.PadToColumn(MAI->getCommentColumn());
|
||||
O << MAI->getCommentString()
|
||||
<< ' '
|
||||
<< Comment;
|
||||
|
||||
if (const char *EncStr = DecodeDWARFEncoding(Encoding))
|
||||
O << " (" << EncStr << ')';
|
||||
}
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
|
||||
/// unsigned leb128 value.
|
||||
void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
|
||||
|
@ -185,8 +185,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||
Asm->EmitULEB128Bytes(AugmentationSize);
|
||||
Asm->EOL("Augmentation Size");
|
||||
|
||||
Asm->EmitInt8(PerEncoding);
|
||||
Asm->EOL("Personality", PerEncoding);
|
||||
EmitEncodingByte(PerEncoding, "Personality");
|
||||
|
||||
// If there is a personality, we need to indicate the function's location.
|
||||
if (PersonalityRef) {
|
||||
@ -197,11 +196,8 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||
O << MAI->getData32bitsDirective() << *PersonalityRef;
|
||||
Asm->EOL("Personality");
|
||||
|
||||
Asm->EmitInt8(LSDAEncoding);
|
||||
Asm->EOL("LSDA Encoding", LSDAEncoding);
|
||||
|
||||
Asm->EmitInt8(FDEEncoding);
|
||||
Asm->EOL("FDE Encoding", FDEEncoding);
|
||||
EmitEncodingByte(LSDAEncoding, "LSDA");
|
||||
EmitEncodingByte(FDEEncoding, "FDE");
|
||||
}
|
||||
|
||||
// Indicate locations of general callee saved registers in frame.
|
||||
@ -784,11 +780,8 @@ void DwarfException::EmitExceptionTable() {
|
||||
}
|
||||
|
||||
// Emit the header.
|
||||
Asm->EmitInt8(dwarf::DW_EH_PE_omit);
|
||||
Asm->EOL("@LPStart format", dwarf::DW_EH_PE_omit);
|
||||
|
||||
Asm->EmitInt8(TTypeFormat);
|
||||
Asm->EOL("@TType format", TTypeFormat);
|
||||
EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
|
||||
EmitEncodingByte(TTypeFormat, "@TType");
|
||||
|
||||
if (HaveTTData) {
|
||||
Asm->EmitULEB128Bytes(TyOffset);
|
||||
@ -797,8 +790,7 @@ void DwarfException::EmitExceptionTable() {
|
||||
|
||||
// SjLj Exception handling
|
||||
if (IsSJLJ) {
|
||||
Asm->EmitInt8(dwarf::DW_EH_PE_udata4);
|
||||
Asm->EOL("Call site format", dwarf::DW_EH_PE_udata4);
|
||||
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
|
||||
Asm->EmitULEB128Bytes(SizeSites);
|
||||
Asm->EOL("Call site table length");
|
||||
|
||||
@ -842,8 +834,7 @@ void DwarfException::EmitExceptionTable() {
|
||||
// supposed to throw.
|
||||
|
||||
// Emit the landing pad call site table.
|
||||
Asm->EmitInt8(dwarf::DW_EH_PE_udata4);
|
||||
Asm->EOL("Call site format", dwarf::DW_EH_PE_udata4);
|
||||
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
|
||||
Asm->EmitULEB128Bytes(SizeSites);
|
||||
Asm->EOL("Call site table size");
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
@ -41,6 +42,50 @@ void DwarfPrinter::PrintRelDirective(bool Force32Bit, bool isInSection) const {
|
||||
O << MAI->getData64bitsDirective();
|
||||
}
|
||||
|
||||
static const char *DecodeDWARFEncoding(unsigned Encoding) {
|
||||
switch (Encoding) {
|
||||
case dwarf::DW_EH_PE_absptr: return "absptr";
|
||||
case dwarf::DW_EH_PE_omit: return "omit";
|
||||
case dwarf::DW_EH_PE_pcrel: return "pcrel";
|
||||
case dwarf::DW_EH_PE_udata4: return "udata4";
|
||||
case dwarf::DW_EH_PE_udata8: return "udata8";
|
||||
case dwarf::DW_EH_PE_sdata4: return "sdata4";
|
||||
case dwarf::DW_EH_PE_sdata8: return "sdata8";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4: return "pcrel udata4";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4: return "pcrel sdata4";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8: return "pcrel udata8";
|
||||
case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8: return "pcrel sdata8";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata4:
|
||||
return "indirect pcrel udata4";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata4:
|
||||
return "indirect pcrel sdata4";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_udata8:
|
||||
return "indirect pcrel udata8";
|
||||
case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |dwarf::DW_EH_PE_sdata8:
|
||||
return "indirect pcrel sdata8";
|
||||
}
|
||||
|
||||
return "<unknown encoding>";
|
||||
}
|
||||
|
||||
/// 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 DwarfPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
|
||||
if (Asm->VerboseAsm) {
|
||||
if (Desc != 0)
|
||||
Asm->OutStreamer.AddComment(Twine(Desc)+" Encoding = " +
|
||||
Twine(DecodeDWARFEncoding(Val)));
|
||||
else
|
||||
Asm->OutStreamer.AddComment(Twine("Encoding = ") +
|
||||
DecodeDWARFEncoding(Val));
|
||||
}
|
||||
|
||||
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
|
||||
}
|
||||
|
||||
|
||||
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
||||
///
|
||||
void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const {
|
||||
|
@ -73,6 +73,7 @@ protected:
|
||||
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
|
||||
const char *flavor);
|
||||
public:
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Accessors.
|
||||
//
|
||||
@ -84,6 +85,12 @@ public:
|
||||
void PrintRelDirective(bool Force32Bit = false,
|
||||
bool isInSection = false) const;
|
||||
|
||||
/// 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);
|
||||
|
||||
|
||||
/// PrintLabelName - Print label name in form used by Dwarf writer.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user