move uleb/sleb printing into AsmPrinter from DwarfPrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100344 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-04 19:09:29 +00:00
parent 17fedf216b
commit 7e1a8f882f
9 changed files with 135 additions and 113 deletions

View File

@ -313,6 +313,16 @@ namespace llvm {
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
unsigned Size) const; unsigned Size) const;
//===------------------------------------------------------------------===//
// Dwarf Emission Helper Routines
//===------------------------------------------------------------------===//
/// EmitSLEB128 - emit the specified signed leb128 value.
void EmitSLEB128(int Value, const char *Desc = 0) const;
/// EmitULEB128 - emit the specified unsigned leb128 value.
void EmitULEB128(unsigned Value, const char *Desc = 0,
unsigned PadTo = 0) const;
//===------------------------------------------------------------------===// //===------------------------------------------------------------------===//
// Inline Asm Support // Inline Asm Support

View File

@ -0,0 +1,71 @@
//===-- AsmPrinterDwarf.cpp - AsmPrinter Dwarf Support --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Dwarf emissions parts of AsmPrinter.
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "asm-printer"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/ADT/Twine.h"
using namespace llvm;
/// EmitSLEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitSLEB128(int Value, const char *Desc) const {
if (isVerbose() && Desc)
OutStreamer.AddComment(Desc);
if (MAI->hasLEB128()) {
// FIXME: MCize.
OutStreamer.EmitRawText("\t.sleb128\t" + Twine(Value));
return;
}
// If we don't have .sleb128, emit as .bytes.
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;
OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (IsMore);
}
/// EmitULEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitULEB128(unsigned Value, const char *Desc,
unsigned PadTo) const {
if (isVerbose() && Desc)
OutStreamer.AddComment(Desc);
if (MAI->hasLEB128() && PadTo == 0) {
// FIXME: MCize.
OutStreamer.EmitRawText("\t.uleb128\t" + Twine(Value));
return;
}
// If we don't have .uleb128 or we want to emit padding, emit as .bytes.
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
if (Value || PadTo != 0) Byte |= 0x80;
OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (Value);
if (PadTo) {
if (PadTo > 1)
OutStreamer.EmitFill(PadTo - 1, 0x80/*fillval*/, 0/*addrspace*/);
OutStreamer.EmitFill(1, 0/*fillval*/, 0/*addrspace*/);
}
}

View File

@ -1,4 +1,4 @@
//===-- AsmPrinter.cpp - Common AsmPrinter code ---------------------------===// //===-- AsmPrinterInlineAsm.cpp - AsmPrinter Inline Asm Handling ----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -7,13 +7,13 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements the AsmPrinter class. // This file implements the inline assembler pieces of the AsmPrinter class.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "asm-printer" #define DEBUG_TYPE "asm-printer"
#include "llvm/InlineAsm.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/InlineAsm.h"
#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"

View File

@ -1,5 +1,6 @@
add_llvm_library(LLVMAsmPrinter add_llvm_library(LLVMAsmPrinter
AsmPrinter.cpp AsmPrinter.cpp
AsmPrinterDwarf.cpp
AsmPrinterInlineAsm.cpp AsmPrinterInlineAsm.cpp
DIE.cpp DIE.cpp
DwarfDebug.cpp DwarfDebug.cpp

View File

@ -57,11 +57,11 @@ void DIEAbbrev::Profile(FoldingSetNodeID &ID) const {
void DIEAbbrev::Emit(const DwarfPrinter *DP) const { void DIEAbbrev::Emit(const DwarfPrinter *DP) const {
// Emit its Dwarf tag type. // Emit its Dwarf tag type.
// FIXME: Doing work even in non-asm-verbose runs. // FIXME: Doing work even in non-asm-verbose runs.
DP->EmitULEB128(Tag, dwarf::TagString(Tag)); DP->getAsm()->EmitULEB128(Tag, dwarf::TagString(Tag));
// Emit whether it has children DIEs. // Emit whether it has children DIEs.
// FIXME: Doing work even in non-asm-verbose runs. // FIXME: Doing work even in non-asm-verbose runs.
DP->EmitULEB128(ChildrenFlag, dwarf::ChildrenString(ChildrenFlag)); DP->getAsm()->EmitULEB128(ChildrenFlag, dwarf::ChildrenString(ChildrenFlag));
// For each attribute description. // For each attribute description.
for (unsigned i = 0, N = Data.size(); i < N; ++i) { for (unsigned i = 0, N = Data.size(); i < N; ++i) {
@ -69,18 +69,18 @@ void DIEAbbrev::Emit(const DwarfPrinter *DP) const {
// Emit attribute type. // Emit attribute type.
// FIXME: Doing work even in non-asm-verbose runs. // FIXME: Doing work even in non-asm-verbose runs.
DP->EmitULEB128(AttrData.getAttribute(), DP->getAsm()->EmitULEB128(AttrData.getAttribute(),
dwarf::AttributeString(AttrData.getAttribute())); dwarf::AttributeString(AttrData.getAttribute()));
// Emit form type. // Emit form type.
// FIXME: Doing work even in non-asm-verbose runs. // FIXME: Doing work even in non-asm-verbose runs.
DP->EmitULEB128(AttrData.getForm(), DP->getAsm()->EmitULEB128(AttrData.getForm(),
dwarf::FormEncodingString(AttrData.getForm())); dwarf::FormEncodingString(AttrData.getForm()));
} }
// Mark end of abbreviation. // Mark end of abbreviation.
DP->EmitULEB128(0, "EOM(1)"); DP->getAsm()->EmitULEB128(0, "EOM(1)");
DP->EmitULEB128(0, "EOM(2)"); DP->getAsm()->EmitULEB128(0, "EOM(2)");
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -201,8 +201,8 @@ void DIEInteger::EmitValue(DwarfPrinter *D, unsigned Form) const {
case dwarf::DW_FORM_data4: Size = 4; break; case dwarf::DW_FORM_data4: Size = 4; break;
case dwarf::DW_FORM_ref8: // Fall thru case dwarf::DW_FORM_ref8: // Fall thru
case dwarf::DW_FORM_data8: Size = 8; break; case dwarf::DW_FORM_data8: Size = 8; break;
case dwarf::DW_FORM_udata: D->EmitULEB128(Integer); return; case dwarf::DW_FORM_udata: Asm->EmitULEB128(Integer); return;
case dwarf::DW_FORM_sdata: D->EmitSLEB128(Integer, ""); return; case dwarf::DW_FORM_sdata: Asm->EmitSLEB128(Integer); return;
default: llvm_unreachable("DIE Value form not supported yet"); default: llvm_unreachable("DIE Value form not supported yet");
} }
Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(Integer, Size, 0/*addrspace*/);
@ -339,11 +339,11 @@ unsigned DIEBlock::ComputeSize(const TargetData *TD) {
void DIEBlock::EmitValue(DwarfPrinter *D, unsigned Form) const { void DIEBlock::EmitValue(DwarfPrinter *D, unsigned Form) const {
const AsmPrinter *Asm = D->getAsm(); const AsmPrinter *Asm = D->getAsm();
switch (Form) { switch (Form) {
default: assert(0 && "Improper form for block"); break;
case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break; case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break;
case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break; case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break;
case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break; case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break;
case dwarf::DW_FORM_block: D->EmitULEB128(Size); break; case dwarf::DW_FORM_block: Asm->EmitULEB128(Size); break;
default: llvm_unreachable("Improper form for block"); break;
} }
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev.getData(); const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev.getData();

View File

@ -2496,7 +2496,7 @@ void DwarfDebug::emitDIE(DIE *Die) {
Twine::utohexstr(Die->getOffset()) + ":0x" + Twine::utohexstr(Die->getOffset()) + ":0x" +
Twine::utohexstr(Die->getSize()) + " " + Twine::utohexstr(Die->getSize()) + " " +
dwarf::TagString(Abbrev->getTag())); dwarf::TagString(Abbrev->getTag()));
EmitULEB128(AbbrevNumber); Asm->EmitULEB128(AbbrevNumber);
const SmallVector<DIEValue*, 32> &Values = Die->getValues(); const SmallVector<DIEValue*, 32> &Values = Die->getValues();
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData(); const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
@ -2596,14 +2596,14 @@ void DwarfDebug::emitAbbreviations() const {
const DIEAbbrev *Abbrev = Abbreviations[i]; const DIEAbbrev *Abbrev = Abbreviations[i];
// Emit the abbrevations code (base 1 index.) // Emit the abbrevations code (base 1 index.)
EmitULEB128(Abbrev->getNumber(), "Abbreviation Code"); Asm->EmitULEB128(Abbrev->getNumber(), "Abbreviation Code");
// Emit the abbreviations data. // Emit the abbreviations data.
Abbrev->Emit(this); Abbrev->Emit(this);
} }
// Mark end of abbreviations. // Mark end of abbreviations.
EmitULEB128(0, "EOM(3)"); Asm->EmitULEB128(0, "EOM(3)");
Asm->OutStreamer.EmitLabel(getTempLabel("abbrev_end")); Asm->OutStreamer.EmitLabel(getTempLabel("abbrev_end"));
} }
@ -2713,9 +2713,9 @@ void DwarfDebug::emitDebugLines() {
if (Asm->isVerbose()) Asm->OutStreamer.AddComment("Source"); if (Asm->isVerbose()) Asm->OutStreamer.AddComment("Source");
Asm->OutStreamer.EmitBytes(StringRef(FN.c_str(), FN.size()+1), 0); Asm->OutStreamer.EmitBytes(StringRef(FN.c_str(), FN.size()+1), 0);
EmitULEB128(Id.first, "Directory #"); Asm->EmitULEB128(Id.first, "Directory #");
EmitULEB128(0, "Mod date"); Asm->EmitULEB128(0, "Mod date");
EmitULEB128(0, "File size"); Asm->EmitULEB128(0, "File size");
} }
Asm->OutStreamer.AddComment("End of files"); Asm->OutStreamer.AddComment("End of files");
@ -2769,7 +2769,7 @@ void DwarfDebug::emitDebugLines() {
Source = LineInfo.getSourceID(); Source = LineInfo.getSourceID();
Asm->OutStreamer.AddComment("DW_LNS_set_file"); Asm->OutStreamer.AddComment("DW_LNS_set_file");
Asm->EmitInt8(dwarf::DW_LNS_set_file); Asm->EmitInt8(dwarf::DW_LNS_set_file);
EmitULEB128(Source, "New Source"); Asm->EmitULEB128(Source, "New Source");
} }
// If change of line. // If change of line.
@ -2790,7 +2790,7 @@ void DwarfDebug::emitDebugLines() {
// ... otherwise use long hand. // ... otherwise use long hand.
Asm->OutStreamer.AddComment("DW_LNS_advance_line"); Asm->OutStreamer.AddComment("DW_LNS_advance_line");
Asm->EmitInt8(dwarf::DW_LNS_advance_line); Asm->EmitInt8(dwarf::DW_LNS_advance_line);
EmitSLEB128(Offset, "Line Offset"); Asm->EmitSLEB128(Offset, "Line Offset");
Asm->OutStreamer.AddComment("DW_LNS_copy"); Asm->OutStreamer.AddComment("DW_LNS_copy");
Asm->EmitInt8(dwarf::DW_LNS_copy); Asm->EmitInt8(dwarf::DW_LNS_copy);
} }
@ -2840,8 +2840,8 @@ void DwarfDebug::emitCommonDebugFrame() {
Asm->EmitInt8(dwarf::DW_CIE_VERSION); Asm->EmitInt8(dwarf::DW_CIE_VERSION);
Asm->OutStreamer.AddComment("CIE Augmentation"); Asm->OutStreamer.AddComment("CIE Augmentation");
Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator. Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator.
EmitULEB128(1, "CIE Code Alignment Factor"); Asm->EmitULEB128(1, "CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->OutStreamer.AddComment("CIE RA Column"); Asm->OutStreamer.AddComment("CIE RA Column");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false)); Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false));
@ -3102,7 +3102,7 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->OutStreamer.AddComment("Function name"); Asm->OutStreamer.AddComment("Function name");
EmitSectionOffset(getStringPoolEntry(Name), getTempLabel("section_str"), EmitSectionOffset(getStringPoolEntry(Name), getTempLabel("section_str"),
true); true);
EmitULEB128(Labels.size(), "Inline count"); Asm->EmitULEB128(Labels.size(), "Inline count");
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(), for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
LE = Labels.end(); LI != LE; ++LI) { LE = Labels.end(); LI != LE; ++LI) {

View File

@ -127,13 +127,13 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0); Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
// Round out reader. // Round out reader.
EmitULEB128(1, "CIE Code Alignment Factor"); Asm->EmitULEB128(1, "CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->OutStreamer.AddComment("CIE Return Address Column"); Asm->OutStreamer.AddComment("CIE Return Address Column");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true)); Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
if (Augmentation[0]) { if (Augmentation[0]) {
EmitULEB128(AugmentationSize, "Augmentation Size"); Asm->EmitULEB128(AugmentationSize, "Augmentation Size");
// If there is a personality, we need to indicate the function's location. // If there is a personality, we need to indicate the function's location.
if (PersonalityFn) { if (PersonalityFn) {
@ -235,7 +235,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
if (MMI->getPersonalities()[0] != NULL) { if (MMI->getPersonalities()[0] != NULL) {
unsigned Size = SizeOfEncodedValue(LSDAEncoding); unsigned Size = SizeOfEncodedValue(LSDAEncoding);
EmitULEB128(Size, "Augmentation size"); Asm->EmitULEB128(Size, "Augmentation size");
Asm->OutStreamer.AddComment("Language Specific Data Area"); Asm->OutStreamer.AddComment("Language Specific Data Area");
if (EHFrameInfo.hasLandingPads) if (EHFrameInfo.hasLandingPads)
EmitReference(getDWLabel("exception", EHFrameInfo.Number),LSDAEncoding); EmitReference(getDWLabel("exception", EHFrameInfo.Number),LSDAEncoding);
@ -243,7 +243,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
} else { } else {
EmitULEB128(0, "Augmentation size"); Asm->EmitULEB128(0, "Augmentation size");
} }
// Indicate locations of function specific callee saved registers in frame. // Indicate locations of function specific callee saved registers in frame.
@ -730,7 +730,7 @@ void DwarfException::EmitExceptionTable() {
if (HaveTTData) { if (HaveTTData) {
// Account for any extra padding that will be added to the call site table // Account for any extra padding that will be added to the call site table
// length. // length.
EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign); Asm->EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign);
SizeAlign = 0; SizeAlign = 0;
} }
@ -739,7 +739,7 @@ void DwarfException::EmitExceptionTable() {
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
// Add extra padding if it wasn't added to the TType base offset. // Add extra padding if it wasn't added to the TType base offset.
EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign); Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
// Emit the landing pad site information. // Emit the landing pad site information.
unsigned idx = 0; unsigned idx = 0;
@ -749,12 +749,12 @@ void DwarfException::EmitExceptionTable() {
// Offset of the landing pad, counted in 16-byte bundles relative to the // Offset of the landing pad, counted in 16-byte bundles relative to the
// @LPStart address. // @LPStart address.
EmitULEB128(idx, "Landing pad"); Asm->EmitULEB128(idx, "Landing pad");
// Offset of the first associated action record, relative to the start of // Offset of the first associated action record, relative to the start of
// the action table. This value is biased by 1 (1 indicates the start of // the action table. This value is biased by 1 (1 indicates the start of
// the action table), and 0 indicates that there are no actions. // the action table), and 0 indicates that there are no actions.
EmitULEB128(S.Action, "Action"); Asm->EmitULEB128(S.Action, "Action");
} }
} else { } else {
// DWARF Exception handling // DWARF Exception handling
@ -782,7 +782,7 @@ void DwarfException::EmitExceptionTable() {
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
// Add extra padding if it wasn't added to the TType base offset. // Add extra padding if it wasn't added to the TType base offset.
EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign); Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
for (SmallVectorImpl<CallSiteEntry>::const_iterator for (SmallVectorImpl<CallSiteEntry>::const_iterator
I = CallSites.begin(), E = CallSites.end(); I != E; ++I) { I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
@ -818,7 +818,7 @@ void DwarfException::EmitExceptionTable() {
// Offset of the first associated action record, relative to the start of // Offset of the first associated action record, relative to the start of
// the action table. This value is biased by 1 (1 indicates the start of // the action table. This value is biased by 1 (1 indicates the start of
// the action table), and 0 indicates that there are no actions. // the action table), and 0 indicates that there are no actions.
EmitULEB128(S.Action, "Action"); Asm->EmitULEB128(S.Action, "Action");
} }
} }
@ -838,13 +838,13 @@ void DwarfException::EmitExceptionTable() {
// //
// Used by the runtime to match the type of the thrown exception to the // 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. // type of the catch clauses or the types in the exception specification.
EmitSLEB128(Action.ValueForTypeID, " TypeInfo index"); Asm->EmitSLEB128(Action.ValueForTypeID, " TypeInfo index");
// Action Record // Action Record
// //
// Self-relative signed displacement in bytes of the next action record, // Self-relative signed displacement in bytes of the next action record,
// or 0 if there is no next action record. // or 0 if there is no next action record.
EmitSLEB128(Action.NextAction, " Next action"); Asm->EmitSLEB128(Action.NextAction, " Next action");
} }
// Emit the Catch TypeInfos. // Emit the Catch TypeInfos.
@ -871,7 +871,7 @@ void DwarfException::EmitExceptionTable() {
for (std::vector<unsigned>::const_iterator for (std::vector<unsigned>::const_iterator
I = FilterIds.begin(), E = FilterIds.end(); I < E; ++I) { I = FilterIds.begin(), E = FilterIds.end(); I < E; ++I) {
unsigned TypeID = *I; unsigned TypeID = *I;
EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0); Asm->EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0);
} }
Asm->EmitAlignment(2, 0, 0, false); Asm->EmitAlignment(2, 0, 0, false);

View File

@ -133,58 +133,6 @@ void DwarfPrinter::EmitCFAByte(unsigned Val) {
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
} }
/// EmitSLEB128 - emit the specified signed leb128 value.
void DwarfPrinter::EmitSLEB128(int Value, const char *Desc) const {
if (Asm->isVerbose() && Desc)
Asm->OutStreamer.AddComment(Desc);
if (MAI->hasLEB128()) {
// FIXME: MCize.
Asm->OutStreamer.EmitRawText("\t.sleb128\t" + Twine(Value));
return;
}
// If we don't have .sleb128, emit as .bytes.
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;
Asm->OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (IsMore);
}
/// EmitULEB128 - emit the specified signed leb128 value.
void DwarfPrinter::EmitULEB128(unsigned Value, const char *Desc,
unsigned PadTo) const {
if (Asm->isVerbose() && Desc)
Asm->OutStreamer.AddComment(Desc);
if (MAI->hasLEB128() && PadTo == 0) {
// FIXME: MCize.
Asm->OutStreamer.EmitRawText("\t.uleb128\t" + Twine(Value));
return;
}
// If we don't have .uleb128 or we want to emit padding, emit as .bytes.
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
if (Value || PadTo != 0) Byte |= 0x80;
Asm->OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (Value);
if (PadTo) {
if (PadTo > 1)
Asm->OutStreamer.EmitFill(PadTo - 1, 0x80/*fillval*/, 0/*addrspace*/);
Asm->OutStreamer.EmitFill(1, 0/*fillval*/, 0/*addrspace*/);
}
}
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const { void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
@ -269,11 +217,11 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
EmitCFAByte(dwarf::DW_CFA_def_cfa_offset); EmitCFAByte(dwarf::DW_CFA_def_cfa_offset);
} else { } else {
EmitCFAByte(dwarf::DW_CFA_def_cfa); EmitCFAByte(dwarf::DW_CFA_def_cfa);
EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register"); Asm->EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register");
} }
int Offset = -Src.getOffset(); int Offset = -Src.getOffset();
EmitULEB128(Offset, "Offset"); Asm->EmitULEB128(Offset, "Offset");
} else { } else {
llvm_unreachable("Machine move not supported yet."); llvm_unreachable("Machine move not supported yet.");
} }
@ -281,7 +229,7 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
Src.getReg() == MachineLocation::VirtualFP) { Src.getReg() == MachineLocation::VirtualFP) {
if (Dst.isReg()) { if (Dst.isReg()) {
EmitCFAByte(dwarf::DW_CFA_def_cfa_register); EmitCFAByte(dwarf::DW_CFA_def_cfa_register);
EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register"); Asm->EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register");
} else { } else {
llvm_unreachable("Machine move not supported yet."); llvm_unreachable("Machine move not supported yet.");
} }
@ -291,15 +239,15 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
if (Offset < 0) { if (Offset < 0) {
EmitCFAByte(dwarf::DW_CFA_offset_extended_sf); EmitCFAByte(dwarf::DW_CFA_offset_extended_sf);
EmitULEB128(Reg, "Reg"); Asm->EmitULEB128(Reg, "Reg");
EmitSLEB128(Offset, "Offset"); Asm->EmitSLEB128(Offset, "Offset");
} else if (Reg < 64) { } else if (Reg < 64) {
EmitCFAByte(dwarf::DW_CFA_offset + Reg); EmitCFAByte(dwarf::DW_CFA_offset + Reg);
EmitULEB128(Offset, "Offset"); Asm->EmitULEB128(Offset, "Offset");
} else { } else {
EmitCFAByte(dwarf::DW_CFA_offset_extended); EmitCFAByte(dwarf::DW_CFA_offset_extended);
EmitULEB128(Reg, "Reg"); Asm->EmitULEB128(Reg, "Reg");
EmitULEB128(Offset, "Offset"); Asm->EmitULEB128(Offset, "Offset");
} }
} }
} }

View File

@ -95,14 +95,6 @@ public:
void EmitCFAByte(unsigned Val); void EmitCFAByte(unsigned Val);
/// EmitSLEB128 - emit the specified signed leb128 value.
void EmitSLEB128(int Value, const char *Desc) const;
/// EmitULEB128 - emit the specified unsigned leb128 value.
void EmitULEB128(unsigned Value, const char *Desc = 0,
unsigned PadTo = 0) const;
/// EmitReference - Emit a reference to a label. /// EmitReference - Emit a reference to a label.
/// ///
void EmitReference(const MCSymbol *Sym, unsigned Encoding) const; void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;