diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-08 22:23:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-08 22:23:36 +0000 |
commit | b98b1bf43259052d1b06b90cc643a47bb239e2bb (patch) | |
tree | cbab47ef86ec41a0d614c68862f9ded56168eab2 | |
parent | 0e822407b283d4334bb4506255e52bc2887786b1 (diff) | |
download | external_llvm-b98b1bf43259052d1b06b90cc643a47bb239e2bb.zip external_llvm-b98b1bf43259052d1b06b90cc643a47bb239e2bb.tar.gz external_llvm-b98b1bf43259052d1b06b90cc643a47bb239e2bb.tar.bz2 |
elimiante the DWLabel class, using MCSymbol instead. Start
switching some stuff over to passing around MCSymbol* instead
of stem+ID.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97993 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/AsmPrinter/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DIE.cpp | 19 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DIE.h | 19 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 55 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 6 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfException.cpp | 14 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfLabel.cpp | 32 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfLabel.h | 52 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfPrinter.cpp | 77 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfPrinter.h | 40 |
10 files changed, 138 insertions, 177 deletions
diff --git a/lib/CodeGen/AsmPrinter/CMakeLists.txt b/lib/CodeGen/AsmPrinter/CMakeLists.txt index 066aaab..7dc1fb5 100644 --- a/lib/CodeGen/AsmPrinter/CMakeLists.txt +++ b/lib/CodeGen/AsmPrinter/CMakeLists.txt @@ -3,7 +3,6 @@ add_llvm_library(LLVMAsmPrinter DIE.cpp DwarfDebug.cpp DwarfException.cpp - DwarfLabel.cpp DwarfPrinter.cpp DwarfWriter.cpp OcamlGCPrinter.cpp diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp index 63360c0..abe719d 100644 --- a/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/lib/CodeGen/AsmPrinter/DIE.cpp @@ -273,8 +273,7 @@ unsigned DIEDwarfLabel::SizeOf(const TargetData *TD, unsigned Form) const { #ifndef NDEBUG void DIEDwarfLabel::print(raw_ostream &O) { - O << "Lbl: "; - Label.print(O); + O << "Lbl: " << Label->getName(); } #endif @@ -310,9 +309,7 @@ void DIEObjectLabel::print(raw_ostream &O) { /// void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const { bool IsSmall = Form == dwarf::DW_FORM_data4; - D->EmitSectionOffset(Label.getTag(), Section.getTag(), - Label.getNumber(), Section.getNumber(), - IsSmall, IsEH, UseSet); + D->EmitSectionOffset(Label, Section, IsSmall, IsEH, UseSet); D->getAsm()->O << '\n'; // FIXME: Necesssary? } @@ -325,11 +322,8 @@ unsigned DIESectionOffset::SizeOf(const TargetData *TD, unsigned Form) const { #ifndef NDEBUG void DIESectionOffset::print(raw_ostream &O) { - O << "Off: "; - Label.print(O); - O << "-"; - Section.print(O); - O << "-" << IsEH << "-" << UseSet; + O << "Off: " << Label->getName() << "-" << Section->getName() + << "-" << IsEH << "-" << UseSet; } #endif @@ -353,10 +347,7 @@ unsigned DIEDelta::SizeOf(const TargetData *TD, unsigned Form) const { #ifndef NDEBUG void DIEDelta::print(raw_ostream &O) { - O << "Del: "; - LabelHi.print(O); - O << "-"; - LabelLo.print(O); + O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName(); } #endif diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h index af90289..30b91df 100644 --- a/lib/CodeGen/AsmPrinter/DIE.h +++ b/lib/CodeGen/AsmPrinter/DIE.h @@ -14,7 +14,6 @@ #ifndef CODEGEN_ASMPRINTER_DIE_H__ #define CODEGEN_ASMPRINTER_DIE_H__ -#include "DwarfLabel.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" @@ -26,6 +25,7 @@ namespace llvm { class DwarfPrinter; class TargetData; class MCSymbol; + class raw_ostream; //===--------------------------------------------------------------------===// /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a @@ -308,10 +308,11 @@ namespace llvm { //===--------------------------------------------------------------------===// /// DIEDwarfLabel - A Dwarf internal label expression DIE. // + /// FIXME: Merge into DIEObjectLabel. class DIEDwarfLabel : public DIEValue { - const DWLabel Label; + const MCSymbol *Label; public: - explicit DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {} + explicit DIEDwarfLabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {} /// EmitValue - Emit label value. /// @@ -362,12 +363,12 @@ namespace llvm { /// DIESectionOffset - A section offset DIE. /// class DIESectionOffset : public DIEValue { - const DWLabel Label; - const DWLabel Section; + const MCSymbol *Label; + const MCSymbol *Section; bool IsEH : 1; bool UseSet : 1; public: - DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec, + DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec, bool isEH = false, bool useSet = true) : DIEValue(isSectionOffset), Label(Lab), Section(Sec), IsEH(isEH), UseSet(useSet) {} @@ -395,10 +396,10 @@ namespace llvm { /// DIEDelta - A simple label difference DIE. /// class DIEDelta : public DIEValue { - const DWLabel LabelHi; - const DWLabel LabelLo; + const MCSymbol *LabelHi; + const MCSymbol *LabelLo; public: - DIEDelta(const DWLabel &Hi, const DWLabel &Lo) + DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} /// EmitValue - Emit delta value. diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 111c5aa..22c0129 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -366,7 +366,8 @@ void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form, /// addLabel - Add a Dwarf label attribute data and value. /// void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Label) { + const MCSymbol *Label) { + // FIXME: Merge into DIEObjectLabel? DIEValue *Value = new DIEDwarfLabel(Label); DIEValues.push_back(Value); Die->addValue(Attribute, Form, Value); @@ -384,7 +385,7 @@ void DwarfDebug::addObjectLabel(DIE *Die, unsigned Attribute, unsigned Form, /// addSectionOffset - Add a section offset label attribute data and value. /// void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Label, const DWLabel &Section, + const MCSymbol *Label,const MCSymbol *Section, bool isEH, bool useSet) { DIEValue *Value = new DIESectionOffset(Label, Section, isEH, useSet); DIEValues.push_back(Value); @@ -394,7 +395,7 @@ void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, /// addDelta - Add a label delta attribute data and value. /// void DwarfDebug::addDelta(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Hi, const DWLabel &Lo) { + const MCSymbol *Hi, const MCSymbol *Lo) { DIEValue *Value = new DIEDelta(Hi, Lo); DIEValues.push_back(Value); Die->addValue(Attribute, Form, Value); @@ -1355,9 +1356,9 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) { } addLabel(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("func_begin", SubprogramCount)); + getDWLabel("func_begin", SubprogramCount)); addLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("func_end", SubprogramCount)); + getDWLabel("func_end", SubprogramCount)); MachineLocation Location(RI->getFrameRegister(*MF)); addAddress(SPDie, dwarf::DW_AT_frame_base, Location); @@ -1382,15 +1383,11 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) { return ScopeDIE; addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - StartID ? - DWLabel("label", StartID) - : DWLabel("func_begin", SubprogramCount)); + StartID ? getDWLabel("label", StartID) + : getDWLabel("func_begin", SubprogramCount)); addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - EndID ? - DWLabel("label", EndID) - : DWLabel("func_end", SubprogramCount)); - - + EndID ? getDWLabel("label", EndID) + : getDWLabel("func_end", SubprogramCount)); return ScopeDIE; } @@ -1418,9 +1415,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) { dwarf::DW_FORM_ref4, OriginDIE); addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, - DWLabel("label", StartID)); + getDWLabel("label", StartID)); addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, - DWLabel("label", EndID)); + getDWLabel("label", EndID)); InlinedSubprogramDIEs.insert(OriginDIE); @@ -1643,8 +1640,9 @@ CompileUnit *DwarfDebug::constructCompileUnit(MDNode *N) { unsigned ID = GetOrCreateSourceID(Dir, FN); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); + // FIXME: Why getting the delta between two identical labels?? addSectionOffset(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, - DWLabel("section_line", 0), DWLabel("section_line", 0), + getTempLabel("section_line"), getTempLabel("section_line"), false); addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string, DIUnit.getProducer()); @@ -2445,7 +2443,8 @@ void DwarfDebug::emitDebugInfo() { Asm->EmitInt32(ContentSize); EOL("Length of Compilation Unit Info"); Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF version number"); - EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false); + EmitSectionOffset(getTempLabel("abbrev_begin"),getTempLabel("section_abbrev"), + true, false); EOL("Offset Into Abbrev. Section"); Asm->EmitInt8(TD->getPointerSize()); EOL("Address Size (in bytes)"); @@ -2726,8 +2725,8 @@ DwarfDebug::emitFunctionDebugFrame(const FunctionDebugFrameInfo&DebugFrameInfo){ EmitLabel("debug_frame_begin", DebugFrameInfo.Number); - EmitSectionOffset("debug_frame_common", "section_debug_frame", - 0, 0, true, false); + EmitSectionOffset(getTempLabel("debug_frame_common"), + getTempLabel("section_debug_frame"), true, false); EOL("FDE CIE offset"); EmitReference("func_begin", DebugFrameInfo.Number); @@ -2759,8 +2758,9 @@ void DwarfDebug::emitDebugPubNames() { Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF Version"); - EmitSectionOffset("info_begin", "section_info", - ModuleCU->getID(), 0, true, false); + EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()), + getTempLabel("section_info"), + true, false); EOL("Offset of Compilation Unit Info"); EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(), @@ -2798,8 +2798,8 @@ void DwarfDebug::emitDebugPubTypes() { if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("DWARF Version"); Asm->EmitInt16(dwarf::DWARF_VERSION); - EmitSectionOffset("info_begin", "section_info", - ModuleCU->getID(), 0, true, false); + EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()), + getTempLabel("section_info"), true, false); EOL("Offset of Compilation ModuleCU Info"); EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(), @@ -2961,12 +2961,13 @@ void DwarfDebug::emitDebugInlineInfo() { Asm->OutStreamer.EmitBytes(Name, 0); Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator. } else - EmitSectionOffset("string", "section_str", - StringPool.idFor(getRealLinkageName(LName)), false, true); + EmitSectionOffset(getDWLabel("string", + StringPool.idFor(getRealLinkageName(LName))), + getTempLabel("section_str"), true); EOL("MIPS linkage name"); - EmitSectionOffset("string", "section_str", - StringPool.idFor(Name), false, true); + EmitSectionOffset(getDWLabel("string", StringPool.idFor(Name)), + getTempLabel("section_str"), false, true); EOL("Function name"); EmitULEB128(Labels.size(), "Inline count"); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index fab67ba..23704eb 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -243,7 +243,7 @@ class DwarfDebug : public DwarfPrinter { /// addLabel - Add a Dwarf label attribute data and value. /// void addLabel(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Label); + const MCSymbol *Label); /// addObjectLabel - Add an non-Dwarf label attribute data and value. /// @@ -253,13 +253,13 @@ class DwarfDebug : public DwarfPrinter { /// addSectionOffset - Add a section offset label attribute data and value. /// void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Label, const DWLabel &Section, + const MCSymbol *Label, const MCSymbol *Section, bool isEH = false, bool useSet = true); /// addDelta - Add a label delta attribute data and value. /// void addDelta(DIE *Die, unsigned Attribute, unsigned Form, - const DWLabel &Hi, const DWLabel &Lo); + const MCSymbol *Hi, const MCSymbol *Lo); /// addDIEEntry - Add a DIE attribute data and value. /// diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp index 2b08ba4..f00e8e1 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -230,8 +230,9 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) { EmitLabel("eh_frame_begin", EHFrameInfo.Number); - EmitSectionOffset("eh_frame_begin", "eh_frame_common", - EHFrameInfo.Number, EHFrameInfo.PersonalityIndex, + EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number), + getDWLabel("eh_frame_common", + EHFrameInfo.PersonalityIndex), true, true, false); EOL("FDE CIE offset"); @@ -819,12 +820,14 @@ void DwarfException::EmitExceptionTable() { // Offset of the call site relative to the previous call site, counted in // number of 16-byte bundles. The first call site is counted relative to // the start of the procedure fragment. - EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount, + EmitSectionOffset(getDWLabel(BeginTag, BeginNumber), + getDWLabel("eh_func_begin", SubprogramCount), true, true); EOL("Region start"); if (!S.EndLabel) - EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber, + EmitDifference(getDWLabel("eh_func_end", SubprogramCount), + getDWLabel(BeginTag, BeginNumber), true); else EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, true); @@ -837,7 +840,8 @@ void DwarfException::EmitExceptionTable() { Asm->OutStreamer.AddComment("Landing pad"); Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/); } else { - EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount, + EmitSectionOffset(getDWLabel("label", S.PadLabel), + getDWLabel("eh_func_begin", SubprogramCount), true, true); EOL("Landing pad"); } diff --git a/lib/CodeGen/AsmPrinter/DwarfLabel.cpp b/lib/CodeGen/AsmPrinter/DwarfLabel.cpp deleted file mode 100644 index 6e9293a..0000000 --- a/lib/CodeGen/AsmPrinter/DwarfLabel.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===--- lib/CodeGen/DwarfLabel.cpp - Dwarf Label -------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// DWARF Labels -// -//===----------------------------------------------------------------------===// - -#include "DwarfLabel.h" -#include "llvm/ADT/FoldingSet.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -/// Profile - Used to gather unique data for the folding set. -/// -void DWLabel::Profile(FoldingSetNodeID &ID) const { - ID.AddString(Tag); - ID.AddInteger(Number); -} - -#ifndef NDEBUG -void DWLabel::print(raw_ostream &O) const { - O << "." << Tag; - if (Number) O << Number; -} -#endif diff --git a/lib/CodeGen/AsmPrinter/DwarfLabel.h b/lib/CodeGen/AsmPrinter/DwarfLabel.h deleted file mode 100644 index 0c0cc4b..0000000 --- a/lib/CodeGen/AsmPrinter/DwarfLabel.h +++ /dev/null @@ -1,52 +0,0 @@ -//===--- lib/CodeGen/DwarfLabel.h - Dwarf Label -----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// DWARF Labels. -// -//===----------------------------------------------------------------------===// - -#ifndef CODEGEN_ASMPRINTER_DWARFLABEL_H__ -#define CODEGEN_ASMPRINTER_DWARFLABEL_H__ - -namespace llvm { - class FoldingSetNodeID; - class raw_ostream; - - //===--------------------------------------------------------------------===// - /// DWLabel - Labels are used to track locations in the assembler file. - /// Labels appear in the form @verbatim <prefix><Tag><Number> @endverbatim, - /// where the tag is a category of label (Ex. location) and number is a value - /// unique in that category. - class DWLabel { - /// Tag - Label category tag. Should always be a statically declared C - /// string. - /// - const char *Tag; - - /// Number - Value to make label unique. - /// - unsigned Number; - public: - DWLabel(const char *T, unsigned N) : Tag(T), Number(N) {} - - // Accessors. - const char *getTag() const { return Tag; } - unsigned getNumber() const { return Number; } - - /// Profile - Used to gather unique data for the folding set. - /// - void Profile(FoldingSetNodeID &ID) const; - -#ifndef NDEBUG - void print(raw_ostream &O) const; -#endif - }; -} // end llvm namespace - -#endif diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp index 28ff0eb..26f4c5f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp @@ -37,6 +37,27 @@ DwarfPrinter::DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T, RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL), SubprogramCount(0), Flavor(flavor), SetCounter(1) {} + +/// getDWLabel - Return the MCSymbol corresponding to the assembler temporary +/// label with the specified stem and unique ID. +MCSymbol *DwarfPrinter::getDWLabel(const char *Name, unsigned ID) const { + // FIXME: REMOVE this. However, there is stuff in EH that passes counters in + // here that can be zero. + + //assert(ID && "Should use getTempLabel if no ID"); + if (ID == 0) return getTempLabel(Name); + return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + + Twine(Name) + Twine(ID)); +} + +/// getTempLabel - Return the MCSymbol corresponding to the assembler temporary +/// label with the specified name. +MCSymbol *DwarfPrinter::getTempLabel(const char *Name) const { + return Asm->OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + + Name); +} + + /// SizeOfEncodedValue - Return the size of the encoding in bytes. unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const { if (Encoding == dwarf::DW_EH_PE_omit) @@ -193,12 +214,19 @@ void DwarfPrinter::EmitULEB128(unsigned Value, const char *Desc, /// PrintLabelName - Print label name in form used by Dwarf writer. /// +void DwarfPrinter::PrintLabelName(const MCSymbol *Label) const { + // FIXME: REMOVE. + O << Label->getName(); +} + void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const { + // FIXME: REMOVE. O << MAI->getPrivateGlobalPrefix() << Tag; if (Number) O << Number; } void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number, const char *Suffix) const { + // FIXME: REMOVE. O << MAI->getPrivateGlobalPrefix() << Tag; if (Number) O << Number; O << Suffix; @@ -207,6 +235,7 @@ void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number, /// EmitLabel - Emit location label for internal use by Dwarf. /// void DwarfPrinter::EmitLabel(const char *Tag, unsigned Number) const { + // FIXME: REMOVE. PrintLabelName(Tag, Number); O << ":\n"; } @@ -235,12 +264,8 @@ void DwarfPrinter::EmitReference(const MCSymbol *Sym, bool IsPCRelative, void DwarfPrinter::EmitReference(const char *Tag, unsigned Number, unsigned Encoding) const { - SmallString<64> Name; - raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() - << Tag << Number; - - MCSymbol *Sym = Asm->OutContext.GetOrCreateSymbol(Name.str()); - EmitReference(Sym, Encoding); + // FIXME: REMOVE. + EmitReference(getDWLabel(Tag, Number), Encoding); } void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const { @@ -260,6 +285,31 @@ void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const /// EmitDifference - Emit the difference between two labels. If this assembler /// supports .set, we emit a .set of a temporary and then use it in the .word. +void DwarfPrinter::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo, + bool IsSmall) { + if (MAI->hasSetDirective()) { + // FIXME: switch to OutStreamer.EmitAssignment. + O << "\t.set\t"; + PrintLabelName("set", SetCounter, Flavor); + O << ","; + PrintLabelName(TagHi); + O << "-"; + PrintLabelName(TagLo); + O << "\n"; + + PrintRelDirective(IsSmall); + PrintLabelName("set", SetCounter, Flavor); + ++SetCounter; + } else { + PrintRelDirective(IsSmall); + PrintLabelName(TagHi); + O << "-"; + PrintLabelName(TagLo); + } +} + +/// EmitDifference - Emit the difference between two labels. If this assembler +/// supports .set, we emit a .set of a temporary and then use it in the .word. void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi, const char *TagLo, unsigned NumberLo, bool IsSmall) { @@ -272,7 +322,7 @@ void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi, O << "-"; PrintLabelName(TagLo, NumberLo); O << "\n"; - + PrintRelDirective(IsSmall); PrintLabelName("set", SetCounter, Flavor); ++SetCounter; @@ -284,9 +334,8 @@ void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi, } } -void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section, - unsigned LabelNumber, - unsigned SectionNumber, +void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label, + const MCSymbol *Section, bool IsSmall, bool isEH, bool useSet) { bool printAbsolute = false; @@ -300,11 +349,11 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section, O << "\t.set\t"; PrintLabelName("set", SetCounter, Flavor); O << ","; - PrintLabelName(Label, LabelNumber); + PrintLabelName(Label); if (!printAbsolute) { O << "-"; - PrintLabelName(Section, SectionNumber); + PrintLabelName(Section); } O << "\n"; @@ -313,11 +362,11 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section, ++SetCounter; } else { PrintRelDirective(IsSmall, true); - PrintLabelName(Label, LabelNumber); + PrintLabelName(Label); if (!printAbsolute) { O << "-"; - PrintLabelName(Section, SectionNumber); + PrintLabelName(Section); } } } diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.h b/lib/CodeGen/AsmPrinter/DwarfPrinter.h index bd715f2..bb72523 100644 --- a/lib/CodeGen/AsmPrinter/DwarfPrinter.h +++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.h @@ -14,7 +14,6 @@ #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__ #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__ -#include "DwarfLabel.h" #include "llvm/CodeGen/MachineLocation.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/FormattedStream.h" @@ -86,6 +85,14 @@ public: const MCAsmInfo *getMCAsmInfo() const { return MAI; } const TargetData *getTargetData() const { return TD; } + /// getDWLabel - Return the MCSymbol corresponding to the assembler temporary + /// label with the specified stem and unique ID. + MCSymbol *getDWLabel(const char *Name, unsigned ID) const; + + /// getTempLabel - Return an assembler temporary label with the specified + /// name. + MCSymbol *getTempLabel(const char *Name) const; + /// SizeOfEncodedValue - Return the size of the encoding in bytes. unsigned SizeOfEncodedValue(unsigned Encoding) const; @@ -117,54 +124,47 @@ public: /// PrintLabelName - Print label name in form used by Dwarf writer. /// - void PrintLabelName(const DWLabel &Label) const { - PrintLabelName(Label.getTag(), Label.getNumber()); - } + void PrintLabelName(const MCSymbol *Label) const; void PrintLabelName(const char *Tag, unsigned Number) const; void PrintLabelName(const char *Tag, unsigned Number, const char *Suffix) const; /// EmitLabel - Emit location label for internal use by Dwarf. /// - void EmitLabel(const DWLabel &Label) const { - EmitLabel(Label.getTag(), Label.getNumber()); - } + void EmitLabel(const MCSymbol *Label) const; void EmitLabel(const char *Tag, unsigned Number) const; /// EmitReference - Emit a reference to a label. /// - void EmitReference(const DWLabel &Label, bool IsPCRelative = false, - bool Force32Bit = false) const { - EmitReference(Label.getTag(), Label.getNumber(), - IsPCRelative, Force32Bit); - } + void EmitReference(const MCSymbol *Label, bool IsPCRelative = false, + bool Force32Bit = false) const; void EmitReference(const char *Tag, unsigned Number, bool IsPCRelative = false, bool Force32Bit = false) const; void EmitReference(const std::string &Name, bool IsPCRelative = false, bool Force32Bit = false) const; - void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false, - bool Force32Bit = false) const; void EmitReference(const char *Tag, unsigned Number, unsigned Encoding) const; void EmitReference(const MCSymbol *Sym, unsigned Encoding) const; void EmitReference(const GlobalValue *GV, unsigned Encoding) const; /// EmitDifference - Emit the difference between two labels. - void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo, - bool IsSmall = false) { - EmitDifference(LabelHi.getTag(), LabelHi.getNumber(), - LabelLo.getTag(), LabelLo.getNumber(), - IsSmall); - } + void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo, + bool IsSmall = false); void EmitDifference(const char *TagHi, unsigned NumberHi, const char *TagLo, unsigned NumberLo, bool IsSmall = false); + void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section, + bool IsSmall = false, bool isEH = false, + bool useSet = true); + +#if 0 void EmitSectionOffset(const char* Label, const char* Section, unsigned LabelNumber, unsigned SectionNumber, bool IsSmall = false, bool isEH = false, bool useSet = true); +#endif /// EmitFrameMoves - Emit frame instructions to describe the layout of the /// frame. |