DIE.cpp
DwarfDebug.cpp
DwarfException.cpp
- DwarfLabel.cpp
DwarfPrinter.cpp
DwarfWriter.cpp
OcamlGCPrinter.cpp
#ifndef NDEBUG
void DIEDwarfLabel::print(raw_ostream &O) {
- O << "Lbl: ";
- Label.print(O);
+ O << "Lbl: " << Label->getName();
}
#endif
///
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?
}
#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
#ifndef NDEBUG
void DIEDelta::print(raw_ostream &O) {
- O << "Del: ";
- LabelHi.print(O);
- O << "-";
- LabelLo.print(O);
+ O << "Del: " << LabelHi->getName() << "-" << LabelLo->getName();
}
#endif
#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"
class DwarfPrinter;
class TargetData;
class MCSymbol;
+ class raw_ostream;
//===--------------------------------------------------------------------===//
/// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a
//===--------------------------------------------------------------------===//
/// 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.
///
/// 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) {}
/// 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.
/// 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);
/// 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);
/// 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);
}
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);
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;
}
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);
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());
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)");
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);
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(),
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(),
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");
/// 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.
///
/// 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.
///
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");
// 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);
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");
}
+++ /dev/null
-//===--- 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
+++ /dev/null
-//===--- 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
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)
/// 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;
/// 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";
}
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 {
/// 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) {
O << "-";
PrintLabelName(TagLo, NumberLo);
O << "\n";
-
+
PrintRelDirective(IsSmall);
PrintLabelName("set", SetCounter, Flavor);
++SetCounter;
}
}
-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;
O << "\t.set\t";
PrintLabelName("set", SetCounter, Flavor);
O << ",";
- PrintLabelName(Label, LabelNumber);
+ PrintLabelName(Label);
if (!printAbsolute) {
O << "-";
- PrintLabelName(Section, SectionNumber);
+ PrintLabelName(Section);
}
O << "\n";
++SetCounter;
} else {
PrintRelDirective(IsSmall, true);
- PrintLabelName(Label, LabelNumber);
+ PrintLabelName(Label);
if (!printAbsolute) {
O << "-";
- PrintLabelName(Section, SectionNumber);
+ PrintLabelName(Section);
}
}
}
#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"
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;
/// 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.