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
This commit is contained in:
Chris Lattner 2010-03-08 22:23:36 +00:00
parent 0e822407b2
commit b98b1bf432
10 changed files with 138 additions and 177 deletions

View File

@ -3,7 +3,6 @@ add_llvm_library(LLVMAsmPrinter
DIE.cpp DIE.cpp
DwarfDebug.cpp DwarfDebug.cpp
DwarfException.cpp DwarfException.cpp
DwarfLabel.cpp
DwarfPrinter.cpp DwarfPrinter.cpp
DwarfWriter.cpp DwarfWriter.cpp
OcamlGCPrinter.cpp OcamlGCPrinter.cpp

View File

@ -273,8 +273,7 @@ unsigned DIEDwarfLabel::SizeOf(const TargetData *TD, unsigned Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIEDwarfLabel::print(raw_ostream &O) { void DIEDwarfLabel::print(raw_ostream &O) {
O << "Lbl: "; O << "Lbl: " << Label->getName();
Label.print(O);
} }
#endif #endif
@ -310,9 +309,7 @@ void DIEObjectLabel::print(raw_ostream &O) {
/// ///
void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const { void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const {
bool IsSmall = Form == dwarf::DW_FORM_data4; bool IsSmall = Form == dwarf::DW_FORM_data4;
D->EmitSectionOffset(Label.getTag(), Section.getTag(), D->EmitSectionOffset(Label, Section, IsSmall, IsEH, UseSet);
Label.getNumber(), Section.getNumber(),
IsSmall, IsEH, UseSet);
D->getAsm()->O << '\n'; // FIXME: Necesssary? D->getAsm()->O << '\n'; // FIXME: Necesssary?
} }
@ -325,11 +322,8 @@ unsigned DIESectionOffset::SizeOf(const TargetData *TD, unsigned Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIESectionOffset::print(raw_ostream &O) { void DIESectionOffset::print(raw_ostream &O) {
O << "Off: "; O << "Off: " << Label->getName() << "-" << Section->getName()
Label.print(O); << "-" << IsEH << "-" << UseSet;
O << "-";
Section.print(O);
O << "-" << IsEH << "-" << UseSet;
} }
#endif #endif
@ -353,10 +347,7 @@ unsigned DIEDelta::SizeOf(const TargetData *TD, unsigned Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIEDelta::print(raw_ostream &O) { void DIEDelta::print(raw_ostream &O) {
O << "Del: "; O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
LabelHi.print(O);
O << "-";
LabelLo.print(O);
} }
#endif #endif

View File

@ -14,7 +14,6 @@
#ifndef CODEGEN_ASMPRINTER_DIE_H__ #ifndef CODEGEN_ASMPRINTER_DIE_H__
#define CODEGEN_ASMPRINTER_DIE_H__ #define CODEGEN_ASMPRINTER_DIE_H__
#include "DwarfLabel.h"
#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
@ -26,6 +25,7 @@ namespace llvm {
class DwarfPrinter; class DwarfPrinter;
class TargetData; class TargetData;
class MCSymbol; class MCSymbol;
class raw_ostream;
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a
@ -308,10 +308,11 @@ namespace llvm {
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// DIEDwarfLabel - A Dwarf internal label expression DIE. /// DIEDwarfLabel - A Dwarf internal label expression DIE.
// //
/// FIXME: Merge into DIEObjectLabel.
class DIEDwarfLabel : public DIEValue { class DIEDwarfLabel : public DIEValue {
const DWLabel Label; const MCSymbol *Label;
public: public:
explicit DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {} explicit DIEDwarfLabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
/// EmitValue - Emit label value. /// EmitValue - Emit label value.
/// ///
@ -362,12 +363,12 @@ namespace llvm {
/// DIESectionOffset - A section offset DIE. /// DIESectionOffset - A section offset DIE.
/// ///
class DIESectionOffset : public DIEValue { class DIESectionOffset : public DIEValue {
const DWLabel Label; const MCSymbol *Label;
const DWLabel Section; const MCSymbol *Section;
bool IsEH : 1; bool IsEH : 1;
bool UseSet : 1; bool UseSet : 1;
public: public:
DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec, DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec,
bool isEH = false, bool useSet = true) bool isEH = false, bool useSet = true)
: DIEValue(isSectionOffset), Label(Lab), Section(Sec), : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
IsEH(isEH), UseSet(useSet) {} IsEH(isEH), UseSet(useSet) {}
@ -395,10 +396,10 @@ namespace llvm {
/// DIEDelta - A simple label difference DIE. /// DIEDelta - A simple label difference DIE.
/// ///
class DIEDelta : public DIEValue { class DIEDelta : public DIEValue {
const DWLabel LabelHi; const MCSymbol *LabelHi;
const DWLabel LabelLo; const MCSymbol *LabelLo;
public: public:
DIEDelta(const DWLabel &Hi, const DWLabel &Lo) DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
: DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
/// EmitValue - Emit delta value. /// EmitValue - Emit delta value.

View File

@ -366,7 +366,8 @@ void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
/// addLabel - Add a Dwarf label attribute data and value. /// addLabel - Add a Dwarf label attribute data and value.
/// ///
void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form, void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form,
const DWLabel &Label) { const MCSymbol *Label) {
// FIXME: Merge into DIEObjectLabel?
DIEValue *Value = new DIEDwarfLabel(Label); DIEValue *Value = new DIEDwarfLabel(Label);
DIEValues.push_back(Value); DIEValues.push_back(Value);
Die->addValue(Attribute, Form, 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. /// addSectionOffset - Add a section offset label attribute data and value.
/// ///
void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, 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) { bool isEH, bool useSet) {
DIEValue *Value = new DIESectionOffset(Label, Section, isEH, useSet); DIEValue *Value = new DIESectionOffset(Label, Section, isEH, useSet);
DIEValues.push_back(Value); 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. /// addDelta - Add a label delta attribute data and value.
/// ///
void DwarfDebug::addDelta(DIE *Die, unsigned Attribute, unsigned Form, 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); DIEValue *Value = new DIEDelta(Hi, Lo);
DIEValues.push_back(Value); DIEValues.push_back(Value);
Die->addValue(Attribute, Form, 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, 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, addLabel(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
DWLabel("func_end", SubprogramCount)); getDWLabel("func_end", SubprogramCount));
MachineLocation Location(RI->getFrameRegister(*MF)); MachineLocation Location(RI->getFrameRegister(*MF));
addAddress(SPDie, dwarf::DW_AT_frame_base, Location); addAddress(SPDie, dwarf::DW_AT_frame_base, Location);
@ -1382,15 +1383,11 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) {
return ScopeDIE; return ScopeDIE;
addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
StartID ? StartID ? getDWLabel("label", StartID)
DWLabel("label", StartID) : getDWLabel("func_begin", SubprogramCount));
: DWLabel("func_begin", SubprogramCount));
addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
EndID ? EndID ? getDWLabel("label", EndID)
DWLabel("label", EndID) : getDWLabel("func_end", SubprogramCount));
: DWLabel("func_end", SubprogramCount));
return ScopeDIE; return ScopeDIE;
} }
@ -1418,9 +1415,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
dwarf::DW_FORM_ref4, OriginDIE); dwarf::DW_FORM_ref4, OriginDIE);
addLabel(ScopeDIE, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 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, addLabel(ScopeDIE, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr,
DWLabel("label", EndID)); getDWLabel("label", EndID));
InlinedSubprogramDIEs.insert(OriginDIE); InlinedSubprogramDIEs.insert(OriginDIE);
@ -1643,8 +1640,9 @@ CompileUnit *DwarfDebug::constructCompileUnit(MDNode *N) {
unsigned ID = GetOrCreateSourceID(Dir, FN); unsigned ID = GetOrCreateSourceID(Dir, FN);
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); 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, 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); false);
addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string, addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string,
DIUnit.getProducer()); DIUnit.getProducer());
@ -2445,7 +2443,8 @@ void DwarfDebug::emitDebugInfo() {
Asm->EmitInt32(ContentSize); EOL("Length of Compilation Unit Info"); Asm->EmitInt32(ContentSize); EOL("Length of Compilation Unit Info");
Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF version number"); 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"); EOL("Offset Into Abbrev. Section");
Asm->EmitInt8(TD->getPointerSize()); EOL("Address Size (in bytes)"); Asm->EmitInt8(TD->getPointerSize()); EOL("Address Size (in bytes)");
@ -2726,8 +2725,8 @@ DwarfDebug::emitFunctionDebugFrame(const FunctionDebugFrameInfo&DebugFrameInfo){
EmitLabel("debug_frame_begin", DebugFrameInfo.Number); EmitLabel("debug_frame_begin", DebugFrameInfo.Number);
EmitSectionOffset("debug_frame_common", "section_debug_frame", EmitSectionOffset(getTempLabel("debug_frame_common"),
0, 0, true, false); getTempLabel("section_debug_frame"), true, false);
EOL("FDE CIE offset"); EOL("FDE CIE offset");
EmitReference("func_begin", DebugFrameInfo.Number); EmitReference("func_begin", DebugFrameInfo.Number);
@ -2759,8 +2758,9 @@ void DwarfDebug::emitDebugPubNames() {
Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF Version"); Asm->EmitInt16(dwarf::DWARF_VERSION); EOL("DWARF Version");
EmitSectionOffset("info_begin", "section_info", EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()),
ModuleCU->getID(), 0, true, false); getTempLabel("section_info"),
true, false);
EOL("Offset of Compilation Unit Info"); EOL("Offset of Compilation Unit Info");
EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(), EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(),
@ -2798,8 +2798,8 @@ void DwarfDebug::emitDebugPubTypes() {
if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("DWARF Version"); if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("DWARF Version");
Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EmitInt16(dwarf::DWARF_VERSION);
EmitSectionOffset("info_begin", "section_info", EmitSectionOffset(getDWLabel("info_begin", ModuleCU->getID()),
ModuleCU->getID(), 0, true, false); getTempLabel("section_info"), true, false);
EOL("Offset of Compilation ModuleCU Info"); EOL("Offset of Compilation ModuleCU Info");
EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(), EmitDifference("info_end", ModuleCU->getID(), "info_begin", ModuleCU->getID(),
@ -2961,12 +2961,13 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->OutStreamer.EmitBytes(Name, 0); Asm->OutStreamer.EmitBytes(Name, 0);
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator. Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
} else } else
EmitSectionOffset("string", "section_str", EmitSectionOffset(getDWLabel("string",
StringPool.idFor(getRealLinkageName(LName)), false, true); StringPool.idFor(getRealLinkageName(LName))),
getTempLabel("section_str"), true);
EOL("MIPS linkage name"); EOL("MIPS linkage name");
EmitSectionOffset("string", "section_str", EmitSectionOffset(getDWLabel("string", StringPool.idFor(Name)),
StringPool.idFor(Name), false, true); getTempLabel("section_str"), false, true);
EOL("Function name"); EOL("Function name");
EmitULEB128(Labels.size(), "Inline count"); EmitULEB128(Labels.size(), "Inline count");

View File

@ -243,7 +243,7 @@ class DwarfDebug : public DwarfPrinter {
/// addLabel - Add a Dwarf label attribute data and value. /// addLabel - Add a Dwarf label attribute data and value.
/// ///
void addLabel(DIE *Die, unsigned Attribute, unsigned Form, void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
const DWLabel &Label); const MCSymbol *Label);
/// addObjectLabel - Add an non-Dwarf label attribute data and value. /// 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. /// addSectionOffset - Add a section offset label attribute data and value.
/// ///
void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, 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); bool isEH = false, bool useSet = true);
/// addDelta - Add a label delta attribute data and value. /// addDelta - Add a label delta attribute data and value.
/// ///
void addDelta(DIE *Die, unsigned Attribute, unsigned Form, 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. /// addDIEEntry - Add a DIE attribute data and value.
/// ///

View File

@ -230,8 +230,9 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
EmitLabel("eh_frame_begin", EHFrameInfo.Number); EmitLabel("eh_frame_begin", EHFrameInfo.Number);
EmitSectionOffset("eh_frame_begin", "eh_frame_common", EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number),
EHFrameInfo.Number, EHFrameInfo.PersonalityIndex, getDWLabel("eh_frame_common",
EHFrameInfo.PersonalityIndex),
true, true, false); true, true, false);
EOL("FDE CIE offset"); EOL("FDE CIE offset");
@ -819,12 +820,14 @@ void DwarfException::EmitExceptionTable() {
// Offset of the call site relative to the previous call site, counted in // 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 // number of 16-byte bundles. The first call site is counted relative to
// the start of the procedure fragment. // the start of the procedure fragment.
EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount, EmitSectionOffset(getDWLabel(BeginTag, BeginNumber),
getDWLabel("eh_func_begin", SubprogramCount),
true, true); true, true);
EOL("Region start"); EOL("Region start");
if (!S.EndLabel) if (!S.EndLabel)
EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber, EmitDifference(getDWLabel("eh_func_end", SubprogramCount),
getDWLabel(BeginTag, BeginNumber),
true); true);
else else
EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, true); EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, true);
@ -837,7 +840,8 @@ void DwarfException::EmitExceptionTable() {
Asm->OutStreamer.AddComment("Landing pad"); Asm->OutStreamer.AddComment("Landing pad");
Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/); Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
} else { } else {
EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount, EmitSectionOffset(getDWLabel("label", S.PadLabel),
getDWLabel("eh_func_begin", SubprogramCount),
true, true); true, true);
EOL("Landing pad"); EOL("Landing pad");
} }

View File

@ -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

View File

@ -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

View File

@ -37,6 +37,27 @@ DwarfPrinter::DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL), RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
SubprogramCount(0), Flavor(flavor), SetCounter(1) {} 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. /// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const { unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
if (Encoding == dwarf::DW_EH_PE_omit) 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. /// 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 { void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number) const {
// FIXME: REMOVE.
O << MAI->getPrivateGlobalPrefix() << Tag; O << MAI->getPrivateGlobalPrefix() << Tag;
if (Number) O << Number; if (Number) O << Number;
} }
void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number, void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number,
const char *Suffix) const { const char *Suffix) const {
// FIXME: REMOVE.
O << MAI->getPrivateGlobalPrefix() << Tag; O << MAI->getPrivateGlobalPrefix() << Tag;
if (Number) O << Number; if (Number) O << Number;
O << Suffix; O << Suffix;
@ -207,6 +235,7 @@ void DwarfPrinter::PrintLabelName(const char *Tag, unsigned Number,
/// EmitLabel - Emit location label for internal use by Dwarf. /// EmitLabel - Emit location label for internal use by Dwarf.
/// ///
void DwarfPrinter::EmitLabel(const char *Tag, unsigned Number) const { void DwarfPrinter::EmitLabel(const char *Tag, unsigned Number) const {
// FIXME: REMOVE.
PrintLabelName(Tag, Number); PrintLabelName(Tag, Number);
O << ":\n"; O << ":\n";
} }
@ -235,12 +264,8 @@ void DwarfPrinter::EmitReference(const MCSymbol *Sym, bool IsPCRelative,
void DwarfPrinter::EmitReference(const char *Tag, unsigned Number, void DwarfPrinter::EmitReference(const char *Tag, unsigned Number,
unsigned Encoding) const { unsigned Encoding) const {
SmallString<64> Name; // FIXME: REMOVE.
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() EmitReference(getDWLabel(Tag, Number), Encoding);
<< Tag << Number;
MCSymbol *Sym = Asm->OutContext.GetOrCreateSymbol(Name.str());
EmitReference(Sym, Encoding);
} }
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const { void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
@ -258,6 +283,31 @@ void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const
Asm->MMI, Encoding);; Asm->MMI, Encoding);;
} }
/// 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 /// 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. /// supports .set, we emit a .set of a temporary and then use it in the .word.
void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi, void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
@ -272,7 +322,7 @@ void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
O << "-"; O << "-";
PrintLabelName(TagLo, NumberLo); PrintLabelName(TagLo, NumberLo);
O << "\n"; O << "\n";
PrintRelDirective(IsSmall); PrintRelDirective(IsSmall);
PrintLabelName("set", SetCounter, Flavor); PrintLabelName("set", SetCounter, Flavor);
++SetCounter; ++SetCounter;
@ -284,9 +334,8 @@ void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
} }
} }
void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section, void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
unsigned LabelNumber, const MCSymbol *Section,
unsigned SectionNumber,
bool IsSmall, bool isEH, bool IsSmall, bool isEH,
bool useSet) { bool useSet) {
bool printAbsolute = false; bool printAbsolute = false;
@ -300,11 +349,11 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section,
O << "\t.set\t"; O << "\t.set\t";
PrintLabelName("set", SetCounter, Flavor); PrintLabelName("set", SetCounter, Flavor);
O << ","; O << ",";
PrintLabelName(Label, LabelNumber); PrintLabelName(Label);
if (!printAbsolute) { if (!printAbsolute) {
O << "-"; O << "-";
PrintLabelName(Section, SectionNumber); PrintLabelName(Section);
} }
O << "\n"; O << "\n";
@ -313,11 +362,11 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section,
++SetCounter; ++SetCounter;
} else { } else {
PrintRelDirective(IsSmall, true); PrintRelDirective(IsSmall, true);
PrintLabelName(Label, LabelNumber); PrintLabelName(Label);
if (!printAbsolute) { if (!printAbsolute) {
O << "-"; O << "-";
PrintLabelName(Section, SectionNumber); PrintLabelName(Section);
} }
} }
} }

View File

@ -14,7 +14,6 @@
#ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__ #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
#define CODEGEN_ASMPRINTER_DWARFPRINTER_H__ #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
#include "DwarfLabel.h"
#include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
@ -86,6 +85,14 @@ public:
const MCAsmInfo *getMCAsmInfo() const { return MAI; } const MCAsmInfo *getMCAsmInfo() const { return MAI; }
const TargetData *getTargetData() const { return TD; } 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. /// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned SizeOfEncodedValue(unsigned Encoding) const; unsigned SizeOfEncodedValue(unsigned Encoding) const;
@ -117,54 +124,47 @@ public:
/// PrintLabelName - Print label name in form used by Dwarf writer. /// PrintLabelName - Print label name in form used by Dwarf writer.
/// ///
void PrintLabelName(const DWLabel &Label) const { void PrintLabelName(const MCSymbol *Label) const;
PrintLabelName(Label.getTag(), Label.getNumber());
}
void PrintLabelName(const char *Tag, unsigned Number) const; void PrintLabelName(const char *Tag, unsigned Number) const;
void PrintLabelName(const char *Tag, unsigned Number, void PrintLabelName(const char *Tag, unsigned Number,
const char *Suffix) const; const char *Suffix) const;
/// EmitLabel - Emit location label for internal use by Dwarf. /// EmitLabel - Emit location label for internal use by Dwarf.
/// ///
void EmitLabel(const DWLabel &Label) const { void EmitLabel(const MCSymbol *Label) const;
EmitLabel(Label.getTag(), Label.getNumber());
}
void EmitLabel(const char *Tag, unsigned Number) const; void EmitLabel(const char *Tag, unsigned Number) const;
/// EmitReference - Emit a reference to a label. /// EmitReference - Emit a reference to a label.
/// ///
void EmitReference(const DWLabel &Label, bool IsPCRelative = false, void EmitReference(const MCSymbol *Label, bool IsPCRelative = false,
bool Force32Bit = false) const { bool Force32Bit = false) const;
EmitReference(Label.getTag(), Label.getNumber(),
IsPCRelative, Force32Bit);
}
void EmitReference(const char *Tag, unsigned Number, void EmitReference(const char *Tag, unsigned Number,
bool IsPCRelative = false, bool IsPCRelative = false,
bool Force32Bit = false) const; bool Force32Bit = false) const;
void EmitReference(const std::string &Name, bool IsPCRelative = false, void EmitReference(const std::string &Name, bool IsPCRelative = false,
bool Force32Bit = false) const; 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 char *Tag, unsigned Number, unsigned Encoding) const;
void EmitReference(const MCSymbol *Sym, unsigned Encoding) const; void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
void EmitReference(const GlobalValue *GV, unsigned Encoding) const; void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
/// EmitDifference - Emit the difference between two labels. /// EmitDifference - Emit the difference between two labels.
void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo, void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
bool IsSmall = false) { bool IsSmall = false);
EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
LabelLo.getTag(), LabelLo.getNumber(),
IsSmall);
}
void EmitDifference(const char *TagHi, unsigned NumberHi, void EmitDifference(const char *TagHi, unsigned NumberHi,
const char *TagLo, unsigned NumberLo, const char *TagLo, unsigned NumberLo,
bool IsSmall = false); 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, void EmitSectionOffset(const char* Label, const char* Section,
unsigned LabelNumber, unsigned SectionNumber, unsigned LabelNumber, unsigned SectionNumber,
bool IsSmall = false, bool isEH = false, bool IsSmall = false, bool isEH = false,
bool useSet = true); bool useSet = true);
#endif
/// EmitFrameMoves - Emit frame instructions to describe the layout of the /// EmitFrameMoves - Emit frame instructions to describe the layout of the
/// frame. /// frame.