move EmitEncodingByte to AsmPrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100349 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-04 20:04:21 +00:00
parent 7a101f45c1
commit ca6190b108
3 changed files with 51 additions and 50 deletions

View File

@ -82,3 +82,47 @@ void AsmPrinter::EmitCFAByte(unsigned Val) const {
OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}
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 AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
if (isVerbose()) {
if (Desc != 0)
OutStreamer.AddComment(Twine(Desc)+" Encoding = " +
Twine(DecodeDWARFEncoding(Val)));
else
OutStreamer.AddComment(Twine("Encoding = ") +
DecodeDWARFEncoding(Val));
}
OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}

View File

@ -138,14 +138,14 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
// If there is a personality, we need to indicate the function's location.
if (PersonalityFn) {
EmitEncodingByte(PerEncoding, "Personality");
Asm->EmitEncodingByte(PerEncoding, "Personality");
Asm->OutStreamer.AddComment("Personality");
EmitReference(PersonalityFn, PerEncoding);
}
if (UsesLSDA[Index])
EmitEncodingByte(LSDAEncoding, "LSDA");
Asm->EmitEncodingByte(LSDAEncoding, "LSDA");
if (FDEEncoding != dwarf::DW_EH_PE_absptr)
EmitEncodingByte(FDEEncoding, "FDE");
Asm->EmitEncodingByte(FDEEncoding, "FDE");
}
// Indicate locations of general callee saved registers in frame.
@ -699,8 +699,8 @@ void DwarfException::EmitExceptionTable() {
Asm->getFunctionNumber()));
// Emit the LSDA header.
EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
EmitEncodingByte(TTypeEncoding, "@TType");
Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
Asm->EmitEncodingByte(TTypeEncoding, "@TType");
// The type infos need to be aligned. GCC does this by inserting padding just
// before the type infos. However, this changes the size of the exception
@ -743,7 +743,7 @@ void DwarfException::EmitExceptionTable() {
// SjLj Exception handling
if (IsSJLJ) {
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
// Add extra padding if it wasn't added to the TType base offset.
Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
@ -786,7 +786,7 @@ void DwarfException::EmitExceptionTable() {
// supposed to throw.
// Emit the landing pad call site table.
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
// Add extra padding if it wasn't added to the TType base offset.
Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);

View File

@ -57,49 +57,6 @@ unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
return 0;
}
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->isVerbose()) {
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*/);
}
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();