move uleb printing from asmprinter to dwarfprinter, mcize,

cleanup and eliminate a bunch more uses of "EOL".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94250 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-22 23:18:42 +00:00
parent bf1f76b493
commit 894d75aa01
8 changed files with 83 additions and 135 deletions

View File

@ -245,13 +245,6 @@ namespace llvm {
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV); bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
public: public:
//===------------------------------------------------------------------===//
/// LEB 128 number encoding.
/// PrintULEB128 - Print a series of hexidecimal values(separated by commas)
/// representing an unsigned leb128 value.
void PrintULEB128(unsigned Value) const;
//===------------------------------------------------------------------===// //===------------------------------------------------------------------===//
// Emission and print routines // Emission and print routines
// //
@ -260,10 +253,6 @@ namespace llvm {
/// then it will be printed first. Comments should not contain '\n'. /// then it will be printed first. Comments should not contain '\n'.
void EOL(const Twine &Comment) const; void EOL(const Twine &Comment) const;
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value.
void EmitULEB128Bytes(unsigned Value) const;
/// EmitInt8 - Emit a byte directive and value. /// EmitInt8 - Emit a byte directive and value.
/// ///
void EmitInt8(int Value) const; void EmitInt8(int Value) const;

View File

@ -655,24 +655,6 @@ void AsmPrinter::EmitXXStructorList(Constant *List) {
} }
} }
//===----------------------------------------------------------------------===//
/// LEB 128 number encoding.
/// PrintULEB128 - Print a series of hexadecimal values (separated by commas)
/// representing an unsigned leb128 value.
void AsmPrinter::PrintULEB128(unsigned Value) const {
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
if (Value) Byte |= 0x80;
O << "0x";
O.write_hex(Byte);
if (Value) O << ", ";
} while (Value);
}
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Emission and print routines // Emission and print routines
// //
@ -687,17 +669,6 @@ void AsmPrinter::EOL(const Twine &Comment) const {
O << '\n'; O << '\n';
} }
/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
/// unsigned leb128 value.
void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
if (MAI->hasLEB128()) {
O << "\t.uleb128\t" << Value;
} else {
O << MAI->getData8bitsDirective();
PrintULEB128(Value);
}
}
/// EmitInt8 - Emit a byte directive and value. /// EmitInt8 - Emit a byte directive and value.
/// ///
void AsmPrinter::EmitInt8(int Value) const { void AsmPrinter::EmitInt8(int Value) const {

View File

@ -53,31 +53,33 @@ void DIEAbbrev::Profile(FoldingSetNodeID &ID) const {
/// Emit - Print the abbreviation using the specified asm printer. /// Emit - Print the abbreviation using the specified asm printer.
/// ///
void DIEAbbrev::Emit(const AsmPrinter *Asm) const { void DIEAbbrev::Emit(const DwarfPrinter *DP) const {
// Emit its Dwarf tag type. // Emit its Dwarf tag type.
Asm->EmitULEB128Bytes(Tag); // FIXME: Doing work even in non-asm-verbose runs.
Asm->EOL(dwarf::TagString(Tag)); DP->EmitULEB128(Tag, dwarf::TagString(Tag));
// Emit whether it has children DIEs. // Emit whether it has children DIEs.
Asm->EmitULEB128Bytes(ChildrenFlag); // FIXME: Doing work even in non-asm-verbose runs.
Asm->EOL(dwarf::ChildrenString(ChildrenFlag)); DP->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) {
const DIEAbbrevData &AttrData = Data[i]; const DIEAbbrevData &AttrData = Data[i];
// Emit attribute type. // Emit attribute type.
Asm->EmitULEB128Bytes(AttrData.getAttribute()); // FIXME: Doing work even in non-asm-verbose runs.
Asm->EOL(dwarf::AttributeString(AttrData.getAttribute())); DP->EmitULEB128(AttrData.getAttribute(),
dwarf::AttributeString(AttrData.getAttribute()));
// Emit form type. // Emit form type.
Asm->EmitULEB128Bytes(AttrData.getForm()); // FIXME: Doing work even in non-asm-verbose runs.
Asm->EOL(dwarf::FormEncodingString(AttrData.getForm())); DP->EmitULEB128(AttrData.getForm(),
dwarf::FormEncodingString(AttrData.getForm()));
} }
// Mark end of abbreviation. // Mark end of abbreviation.
Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(1)"); DP->EmitULEB128(0, "EOM(1)");
Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(2)"); DP->EmitULEB128(0, "EOM(2)");
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -199,7 +201,7 @@ 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: Asm->EmitULEB128Bytes(Integer); return; case dwarf::DW_FORM_udata: D->EmitULEB128(Integer); return;
case dwarf::DW_FORM_sdata: D->EmitSLEB128(Integer, ""); return; case dwarf::DW_FORM_sdata: D->EmitSLEB128(Integer, ""); return;
default: llvm_unreachable("DIE Value form not supported yet"); default: llvm_unreachable("DIE Value form not supported yet");
} }
@ -395,7 +397,7 @@ void DIEBlock::EmitValue(DwarfPrinter *D, unsigned Form) const {
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: Asm->EmitULEB128Bytes(Size); break; case dwarf::DW_FORM_block: D->EmitULEB128(Size); break;
default: llvm_unreachable("Improper form for block"); break; default: llvm_unreachable("Improper form for block"); break;
} }

View File

@ -101,7 +101,7 @@ namespace llvm {
/// Emit - Print the abbreviation using the specified asm printer. /// Emit - Print the abbreviation using the specified asm printer.
/// ///
void Emit(const AsmPrinter *Asm) const; void Emit(const DwarfPrinter *Asm) const;
#ifndef NDEBUG #ifndef NDEBUG
void print(raw_ostream &O); void print(raw_ostream &O);

View File

@ -2350,12 +2350,12 @@ void DwarfDebug::emitDIE(DIE *Die) {
Asm->O << '\n'; Asm->O << '\n';
// Emit the code (index) for the abbreviation. // Emit the code (index) for the abbreviation.
Asm->EmitULEB128Bytes(AbbrevNumber); if (Asm->VerboseAsm)
Asm->OutStreamer.AddComment("Abbrev [" + Twine(AbbrevNumber) + "] 0x" +
Asm->EOL("Abbrev [" + Twine(AbbrevNumber) + "] 0x" + 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);
SmallVector<DIEValue*, 32> &Values = Die->getValues(); SmallVector<DIEValue*, 32> &Values = Die->getValues();
const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData(); const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData();
@ -2448,16 +2448,15 @@ 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.)
Asm->EmitULEB128Bytes(Abbrev->getNumber()); EmitULEB128(Abbrev->getNumber(), "Abbreviation Code");
Asm->EOL("Abbreviation Code");
// Emit the abbreviations data. // Emit the abbreviations data.
Abbrev->Emit(Asm); Abbrev->Emit(this);
Asm->O << '\n'; Asm->O << '\n';
} }
// Mark end of abbreviations. // Mark end of abbreviations.
Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(3)"); EmitULEB128(0, "EOM(3)");
EmitLabel("abbrev_end", 0); EmitLabel("abbrev_end", 0);
Asm->O << '\n'; Asm->O << '\n';
@ -2476,10 +2475,8 @@ void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
// Mark end of matrix. // Mark end of matrix.
Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence"); Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence");
Asm->EmitULEB128Bytes(1);
Asm->O << '\n';
Asm->EmitInt8(1); Asm->EmitInt8(1);
Asm->O << '\n'; Asm->EmitInt8(1);
} }
/// emitDebugLines - Emit source line information. /// emitDebugLines - Emit source line information.
@ -2545,12 +2542,9 @@ void DwarfDebug::emitDebugLines() {
std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI); std::pair<unsigned, unsigned> Id = getSourceDirectoryAndFileIds(SI);
Asm->EmitString(getSourceFileName(Id.second)); Asm->EmitString(getSourceFileName(Id.second));
Asm->EOL("Source"); Asm->EOL("Source");
Asm->EmitULEB128Bytes(Id.first); EmitULEB128(Id.first, "Directory #");
Asm->EOL("Directory #"); EmitULEB128(0, "Mod date");
Asm->EmitULEB128Bytes(0); EmitULEB128(0, "File size");
Asm->EOL("Mod date");
Asm->EmitULEB128Bytes(0);
Asm->EOL("File size");
} }
Asm->EmitInt8(0); Asm->EOL("End of files"); Asm->EmitInt8(0); Asm->EOL("End of files");
@ -2604,7 +2598,7 @@ void DwarfDebug::emitDebugLines() {
if (Source != LineInfo.getSourceID()) { if (Source != LineInfo.getSourceID()) {
Source = LineInfo.getSourceID(); Source = LineInfo.getSourceID();
Asm->EmitInt8(dwarf::DW_LNS_set_file); Asm->EOL("DW_LNS_set_file"); Asm->EmitInt8(dwarf::DW_LNS_set_file); Asm->EOL("DW_LNS_set_file");
Asm->EmitULEB128Bytes(Source); Asm->EOL("New Source"); EmitULEB128(Source, "New Source");
} }
// If change of line. // If change of line.
@ -2673,8 +2667,7 @@ void DwarfDebug::emitCommonDebugFrame() {
Asm->EOL("CIE Version"); Asm->EOL("CIE Version");
Asm->EmitString(""); Asm->EmitString("");
Asm->EOL("CIE Augmentation"); Asm->EOL("CIE Augmentation");
Asm->EmitULEB128Bytes(1); EmitULEB128(1, "CIE Code Alignment Factor");
Asm->EOL("CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false)); Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false));
Asm->EOL("CIE RA Column"); Asm->EOL("CIE RA Column");
@ -2941,7 +2934,7 @@ void DwarfDebug::emitDebugInlineInfo() {
EmitSectionOffset("string", "section_str", EmitSectionOffset("string", "section_str",
StringPool.idFor(Name), false, true); StringPool.idFor(Name), false, true);
Asm->EOL("Function name"); Asm->EOL("Function name");
Asm->EmitULEB128Bytes(Labels.size()); Asm->EOL("Inline count"); 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

@ -175,15 +175,12 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
Asm->EOL("CIE Augmentation"); Asm->EOL("CIE Augmentation");
// Round out reader. // Round out reader.
Asm->EmitULEB128Bytes(1); EmitULEB128(1, "CIE Code Alignment Factor");
Asm->EOL("CIE Code Alignment Factor");
EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true)); Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
Asm->EOL("CIE Return Address Column"); Asm->EOL("CIE Return Address Column");
Asm->EmitULEB128Bytes(AugmentationSize); EmitULEB128(AugmentationSize, "Augmentation Size");
Asm->EOL("Augmentation Size");
EmitEncodingByte(PerEncoding, "Personality"); EmitEncodingByte(PerEncoding, "Personality");
// 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.
@ -277,16 +274,14 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
if (MMI->getPersonalities()[0] != NULL) { if (MMI->getPersonalities()[0] != NULL) {
if (Asm->TM.getLSDAEncoding() != DwarfLSDAEncoding::EightByte) { if (Asm->TM.getLSDAEncoding() != DwarfLSDAEncoding::EightByte) {
Asm->EmitULEB128Bytes(4); EmitULEB128(4, "Augmentation size");
Asm->EOL("Augmentation size");
if (EHFrameInfo.hasLandingPads) if (EHFrameInfo.hasLandingPads)
EmitReference("exception", EHFrameInfo.Number, true, true); EmitReference("exception", EHFrameInfo.Number, true, true);
else else
Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
} else { } else {
Asm->EmitULEB128Bytes(TD->getPointerSize()); EmitULEB128(TD->getPointerSize(), "Augmentation size");
Asm->EOL("Augmentation size");
if (EHFrameInfo.hasLandingPads) { if (EHFrameInfo.hasLandingPads) {
EmitReference("exception", EHFrameInfo.Number, true, false); EmitReference("exception", EHFrameInfo.Number, true, false);
@ -298,8 +293,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Asm->EOL("Language Specific Data Area"); Asm->EOL("Language Specific Data Area");
} else { } else {
Asm->EmitULEB128Bytes(0); EmitULEB128(0, "Augmentation size");
Asm->EOL("Augmentation size");
} }
// Indicate locations of function specific callee saved registers in frame. // Indicate locations of function specific callee saved registers in frame.
@ -782,16 +776,13 @@ void DwarfException::EmitExceptionTable() {
EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart"); EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
EmitEncodingByte(TTypeFormat, "@TType"); EmitEncodingByte(TTypeFormat, "@TType");
if (HaveTTData) { if (HaveTTData)
Asm->EmitULEB128Bytes(TyOffset); EmitULEB128(TyOffset, "@TType base offset");
Asm->EOL("@TType base offset");
}
// SjLj Exception handling // SjLj Exception handling
if (IsSJLJ) { if (IsSJLJ) {
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Asm->EmitULEB128Bytes(SizeSites); EmitULEB128(SizeSites, "Call site table length");
Asm->EOL("Call site table length");
// Emit the landing pad site information. // Emit the landing pad site information.
unsigned idx = 0; unsigned idx = 0;
@ -801,14 +792,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.
Asm->EmitULEB128Bytes(idx); EmitULEB128(idx, "Landing pad");
Asm->EOL("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.
Asm->EmitULEB128Bytes(S.Action); EmitULEB128(S.Action, "Action");
Asm->EOL("Action");
} }
} else { } else {
// DWARF Exception handling // DWARF Exception handling
@ -834,8 +823,7 @@ void DwarfException::EmitExceptionTable() {
// Emit the landing pad call site table. // Emit the landing pad call site table.
EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Asm->EmitULEB128Bytes(SizeSites); EmitULEB128(SizeSites, "Call site table size");
Asm->EOL("Call site table size");
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) {
@ -879,8 +867,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.
Asm->EmitULEB128Bytes(S.Action); EmitULEB128(S.Action, "Action");
Asm->EOL("Action");
} }
} }
@ -921,11 +908,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;
Asm->EmitULEB128Bytes(TypeID); EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0);
if (TypeID != 0)
Asm->EOL("Exception specification");
else
Asm->O << '\n';
} }
Asm->EmitAlignment(2, 0, 0, false); Asm->EmitAlignment(2, 0, 0, false);

View File

@ -85,9 +85,18 @@ void DwarfPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
} }
/// PrintSLEB128 - Print a series of hexadecimal values (separated by commas) /// EmitSLEB128 - emit the specified signed leb128 value.
/// representing a signed leb128 value. void DwarfPrinter::EmitSLEB128(int Value, const char *Desc) const {
static void PrintSLEB128(MCStreamer &O, int Value) { if (Asm->VerboseAsm && Desc)
Asm->OutStreamer.AddComment(Desc);
if (MAI->hasLEB128()) {
O << "\t.sleb128\t" << Value;
Asm->OutStreamer.AddBlankLine();
return;
}
// If we don't have .sleb128, emit as .bytes.
int Sign = Value >> (8 * sizeof(Value) - 1); int Sign = Value >> (8 * sizeof(Value) - 1);
bool IsMore; bool IsMore;
@ -97,23 +106,29 @@ static void PrintSLEB128(MCStreamer &O, int Value) {
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0; IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
if (IsMore) Byte |= 0x80; if (IsMore) Byte |= 0x80;
O.EmitIntValue(Byte, 1, /*addrspace*/0); Asm->OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (IsMore); } while (IsMore);
} }
/// EmitSLEB128 - print the specified signed leb128 value. /// EmitULEB128 - emit the specified signed leb128 value.
void DwarfPrinter::EmitSLEB128(int Value, const char *Desc) const { void DwarfPrinter::EmitULEB128(unsigned Value, const char *Desc) const {
if (Asm->VerboseAsm && Desc) if (Asm->VerboseAsm && Desc)
Asm->OutStreamer.AddComment(Desc); Asm->OutStreamer.AddComment(Desc);
if (MAI->hasLEB128()) { if (MAI->hasLEB128()) {
O << "\t.sleb128\t" << Value; O << "\t.uleb128\t" << Value;
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer.AddBlankLine();
} else { return;
PrintSLEB128(Asm->OutStreamer, Value);
} }
}
// If we don't have .uleb128, emit as .bytes.
do {
unsigned char Byte = static_cast<unsigned char>(Value & 0x7f);
Value >>= 7;
if (Value) Byte |= 0x80;
Asm->OutStreamer.EmitIntValue(Byte, 1, /*addrspace*/0);
} while (Value);
}
/// PrintLabelName - Print label name in form used by Dwarf writer. /// PrintLabelName - Print label name in form used by Dwarf writer.
@ -267,14 +282,11 @@ void DwarfPrinter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
} else { } else {
Asm->EmitInt8(dwarf::DW_CFA_def_cfa); Asm->EmitInt8(dwarf::DW_CFA_def_cfa);
Asm->EOL("DW_CFA_def_cfa"); Asm->EOL("DW_CFA_def_cfa");
Asm->EmitULEB128Bytes(RI->getDwarfRegNum(Src.getReg(), isEH)); EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register");
Asm->EOL("Register");
} }
int Offset = -Src.getOffset(); int Offset = -Src.getOffset();
EmitULEB128(Offset, "Offset");
Asm->EmitULEB128Bytes(Offset);
Asm->EOL("Offset");
} else { } else {
llvm_unreachable("Machine move not supported yet."); llvm_unreachable("Machine move not supported yet.");
} }
@ -283,8 +295,7 @@ void DwarfPrinter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
if (Dst.isReg()) { if (Dst.isReg()) {
Asm->EmitInt8(dwarf::DW_CFA_def_cfa_register); Asm->EmitInt8(dwarf::DW_CFA_def_cfa_register);
Asm->EOL("DW_CFA_def_cfa_register"); Asm->EOL("DW_CFA_def_cfa_register");
Asm->EmitULEB128Bytes(RI->getDwarfRegNum(Dst.getReg(), isEH)); EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register");
Asm->EOL("Register");
} else { } else {
llvm_unreachable("Machine move not supported yet."); llvm_unreachable("Machine move not supported yet.");
} }
@ -295,21 +306,17 @@ void DwarfPrinter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
if (Offset < 0) { if (Offset < 0) {
Asm->EmitInt8(dwarf::DW_CFA_offset_extended_sf); Asm->EmitInt8(dwarf::DW_CFA_offset_extended_sf);
Asm->EOL("DW_CFA_offset_extended_sf"); Asm->EOL("DW_CFA_offset_extended_sf");
Asm->EmitULEB128Bytes(Reg); EmitULEB128(Reg, "Reg");
Asm->EOL("Reg");
EmitSLEB128(Offset, "Offset"); EmitSLEB128(Offset, "Offset");
} else if (Reg < 64) { } else if (Reg < 64) {
Asm->EmitInt8(dwarf::DW_CFA_offset + Reg); Asm->EmitInt8(dwarf::DW_CFA_offset + Reg);
Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")"); Asm->EOL("DW_CFA_offset + Reg (" + Twine(Reg) + ")");
Asm->EmitULEB128Bytes(Offset); EmitULEB128(Offset, "Offset");
Asm->EOL("Offset");
} else { } else {
Asm->EmitInt8(dwarf::DW_CFA_offset_extended); Asm->EmitInt8(dwarf::DW_CFA_offset_extended);
Asm->EOL("DW_CFA_offset_extended"); Asm->EOL("DW_CFA_offset_extended");
Asm->EmitULEB128Bytes(Reg); EmitULEB128(Reg, "Reg");
Asm->EOL("Reg"); EmitULEB128(Offset, "Offset");
Asm->EmitULEB128Bytes(Offset);
Asm->EOL("Offset");
} }
} }
} }

View File

@ -91,9 +91,12 @@ public:
/// specifying (e.g. "LSDA"). /// specifying (e.g. "LSDA").
void EmitEncodingByte(unsigned Val, const char *Desc); void EmitEncodingByte(unsigned Val, const char *Desc);
/// EmitSLEB128 - print the specified signed leb128 value. /// EmitSLEB128 - emit the specified signed leb128 value.
void EmitSLEB128(int Value, const char *Desc) const; void EmitSLEB128(int Value, const char *Desc) const;
/// EmitULEB128 - emit the specified unsigned leb128 value.
void EmitULEB128(unsigned Value, const char *Desc = 0) const;
/// PrintLabelName - Print label name in form used by Dwarf writer. /// PrintLabelName - Print label name in form used by Dwarf writer.
/// ///