Landing pad-less eh for PPC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey 2007-01-29 18:51:14 +00:00
parent 9e9225cb01
commit 072200c36d
7 changed files with 234 additions and 129 deletions

View File

@ -7,11 +7,11 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains support for writing Dwarf debug info into asm files. For // This file contains support for writing Dwarf debug and exception info into
// Details on the Dwarf 3 specfication see DWARF Debugging Information Format // asm files. For Details on the Dwarf 3 specfication see DWARF Debugging
// V.3 reference manual http://dwarf.freestandards.org , // Information Format V.3 reference manual http://dwarf.freestandards.org ,
// //
// The role of the Dwarf Writer class is to extract debug information from the // The role of the Dwarf Writer class is to extract information from the
// MachineModuleInfo object, organize it in Dwarf form and then emit it into asm // MachineModuleInfo object, organize it in Dwarf form and then emit it into asm
// the current asm file using data and high level Dwarf directives. // the current asm file using data and high level Dwarf directives.
// //
@ -25,7 +25,8 @@
namespace llvm { namespace llvm {
class AsmPrinter; class AsmPrinter;
class Dwarf; class DwarfDebug;
class DwarfException;
class MachineModuleInfo; class MachineModuleInfo;
class MachineFunction; class MachineFunction;
class Module; class Module;
@ -37,9 +38,13 @@ class TargetAsmInfo;
class DwarfWriter { class DwarfWriter {
private: private:
/// DM - Provides the DwarfWriter implementation. /// DD - Provides the DwarfWriter debug implementation.
/// ///
Dwarf *DW; DwarfDebug *DD;
/// DE - Provides the DwarfWriter exception implementation.
///
DwarfException *DE;
public: public:

View File

@ -202,6 +202,10 @@ namespace llvm {
//===--- Global Variable Emission Directives --------------------------===// //===--- Global Variable Emission Directives --------------------------===//
/// GlobalDirective - This is the directive used to declare a global entity.
///
const char *GlobalDirective; // Defaults to NULL.
/// SetDirective - This is the name of a directive that can be used to tell /// SetDirective - This is the name of a directive that can be used to tell
/// the assembler to set the value of a variable to some expression. /// the assembler to set the value of a variable to some expression.
const char *SetDirective; // Defaults to null. const char *SetDirective; // Defaults to null.
@ -250,6 +254,10 @@ namespace llvm {
/// ///
bool HasDotFile; // Defaults to false. bool HasDotFile; // Defaults to false.
/// SupportsExceptionHandling - True if target supports exception handling.
///
bool SupportsExceptionHandling; // Defaults to false.
/// RequiresFrameSection - true if the Dwarf2 output needs a frame section /// RequiresFrameSection - true if the Dwarf2 output needs a frame section
/// ///
bool DwarfRequiresFrameSection; // Defaults to true. bool DwarfRequiresFrameSection; // Defaults to true.
@ -440,6 +448,9 @@ namespace llvm {
const char *getSixteenByteConstantSection() const { const char *getSixteenByteConstantSection() const {
return SixteenByteConstantSection; return SixteenByteConstantSection;
} }
const char *getGlobalDirective() const {
return GlobalDirective;
}
const char *getSetDirective() const { const char *getSetDirective() const {
return SetDirective; return SetDirective;
} }
@ -473,6 +484,9 @@ namespace llvm {
bool hasDotFile() const { bool hasDotFile() const {
return HasDotFile; return HasDotFile;
} }
bool getSupportsExceptionHandling() const {
return SupportsExceptionHandling;
}
bool getDwarfRequiresFrameSection() const { bool getDwarfRequiresFrameSection() const {
return DwarfRequiresFrameSection; return DwarfRequiresFrameSection;
} }

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains support for writing dwarf debug info into asm files. // This file contains support for writing dwarf info into asm files.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -180,7 +180,7 @@ public:
/// Emit - Print the abbreviation using the specified Dwarf writer. /// Emit - Print the abbreviation using the specified Dwarf writer.
/// ///
void Emit(const Dwarf &DW) const; void Emit(const DwarfDebug &DD) const;
#ifndef NDEBUG #ifndef NDEBUG
void print(std::ostream *O) { void print(std::ostream *O) {
@ -313,11 +313,11 @@ public:
/// EmitValue - Emit value via the Dwarf writer. /// EmitValue - Emit value via the Dwarf writer.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const = 0; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const = 0;
/// SizeOf - Return the size of a value in bytes. /// SizeOf - Return the size of a value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const = 0; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const = 0;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
/// ///
@ -363,11 +363,11 @@ public:
/// EmitValue - Emit integer of appropriate size. /// EmitValue - Emit integer of appropriate size.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of integer value in bytes. /// SizeOf - Determine size of integer value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
/// ///
@ -400,11 +400,11 @@ public:
/// EmitValue - Emit string value. /// EmitValue - Emit string value.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of string value in bytes. /// SizeOf - Determine size of string value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const { virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const {
return String.size() + sizeof(char); // sizeof('\0'); return String.size() + sizeof(char); // sizeof('\0');
} }
@ -439,11 +439,11 @@ public:
/// EmitValue - Emit label value. /// EmitValue - Emit label value.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of label value in bytes. /// SizeOf - Determine size of label value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
/// ///
@ -477,11 +477,11 @@ public:
/// EmitValue - Emit label value. /// EmitValue - Emit label value.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of label value in bytes. /// SizeOf - Determine size of label value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
/// ///
@ -515,11 +515,11 @@ public:
/// EmitValue - Emit delta value. /// EmitValue - Emit delta value.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of delta value in bytes. /// SizeOf - Determine size of delta value in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
/// ///
@ -557,11 +557,11 @@ public:
/// EmitValue - Emit debug information entry offset. /// EmitValue - Emit debug information entry offset.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of debug information entry in bytes. /// SizeOf - Determine size of debug information entry in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const { virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const {
return sizeof(int32_t); return sizeof(int32_t);
} }
@ -609,7 +609,7 @@ public:
/// ComputeSize - calculate the size of the block. /// ComputeSize - calculate the size of the block.
/// ///
unsigned ComputeSize(Dwarf &DW); unsigned ComputeSize(DwarfDebug &DD);
/// BestForm - Choose the best form for data. /// BestForm - Choose the best form for data.
/// ///
@ -622,11 +622,11 @@ public:
/// EmitValue - Emit block data. /// EmitValue - Emit block data.
/// ///
virtual void EmitValue(const Dwarf &DW, unsigned Form) const; virtual void EmitValue(const DwarfDebug &DD, unsigned Form) const;
/// SizeOf - Determine size of block data in bytes. /// SizeOf - Determine size of block data in bytes.
/// ///
virtual unsigned SizeOf(const Dwarf &DW, unsigned Form) const; virtual unsigned SizeOf(const DwarfDebug &DD, unsigned Form) const;
/// Profile - Used to gather unique data for the value folding set. /// Profile - Used to gather unique data for the value folding set.
@ -720,14 +720,14 @@ public:
/// getDieMapSlotFor - Returns the debug information entry map slot for the /// getDieMapSlotFor - Returns the debug information entry map slot for the
/// specified debug descriptor. /// specified debug descriptor.
DIE *&getDieMapSlotFor(DebugInfoDesc *DD) { DIE *&getDieMapSlotFor(DebugInfoDesc *DID) {
return DescToDieMap[DD]; return DescToDieMap[DID];
} }
/// getDIEntrySlotFor - Returns the debug information entry proxy slot for the /// getDIEntrySlotFor - Returns the debug information entry proxy slot for the
/// specified debug descriptor. /// specified debug descriptor.
DIEntry *&getDIEntrySlotFor(DebugInfoDesc *DD) { DIEntry *&getDIEntrySlotFor(DebugInfoDesc *DID) {
return DescToDIEntryMap[DD]; return DescToDIEntryMap[DID];
} }
/// AddDie - Adds or interns the DIE to the compile unit. /// AddDie - Adds or interns the DIE to the compile unit.
@ -750,14 +750,14 @@ public:
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// Dwarf - Emits Dwarf debug and exception handling directives. /// Dwarf - Emits general Dwarf directives.
/// ///
class Dwarf { class Dwarf {
private: protected:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Core attributes used by the Dwarf writer. // Core attributes used by the Dwarf writer.
// //
// //
@ -802,6 +802,41 @@ private:
/// ///
unsigned SubprogramCount; unsigned SubprogramCount;
Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
: O(OS)
, Asm(A)
, TAI(T)
, TD(Asm->TM.getTargetData())
, RI(Asm->TM.getRegisterInfo())
, M(NULL)
, MF(NULL)
, MMI(NULL)
, didInitial(false)
, shouldEmit(false)
, SubprogramCount(0)
{
}
public:
//===--------------------------------------------------------------------===//
// Accessors.
//
AsmPrinter *getAsm() const { return Asm; }
const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
/// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
///
bool ShouldEmitDwarf() const { return shouldEmit; }
};
//===----------------------------------------------------------------------===//
/// DwarfDebug - Emits Dwarf debug directives.
///
class DwarfDebug : public Dwarf {
private:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Attributes used to construct specific Dwarf sections. // Attributes used to construct specific Dwarf sections.
// //
@ -845,11 +880,6 @@ private:
public: public:
//===--------------------------------------------------------------------===//
// Accessors.
//
AsmPrinter *getAsm() const { return Asm; }
/// PrintLabelName - Print label name in form used by Dwarf writer. /// PrintLabelName - Print label name in form used by Dwarf writer.
/// ///
void PrintLabelName(DWLabel Label) const { void PrintLabelName(DWLabel Label) const {
@ -2466,26 +2496,12 @@ private:
} }
} }
/// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
///
bool ShouldEmitDwarf() const { return shouldEmit; }
public: public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Main entry points. // Main entry points.
// //
Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) DwarfDebug(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
: O(OS) : Dwarf(OS, A, T)
, Asm(A)
, TAI(T)
, TD(Asm->TM.getTargetData())
, RI(Asm->TM.getRegisterInfo())
, M(NULL)
, MF(NULL)
, MMI(NULL)
, didInitial(false)
, shouldEmit(false)
, SubprogramCount(0)
, CompileUnits() , CompileUnits()
, AbbreviationsSet(InitAbbreviationsSetSize) , AbbreviationsSet(InitAbbreviationsSetSize)
, Abbreviations() , Abbreviations()
@ -2497,17 +2513,13 @@ public:
, SectionSourceLines() , SectionSourceLines()
{ {
} }
virtual ~Dwarf() { virtual ~DwarfDebug() {
for (unsigned i = 0, N = CompileUnits.size(); i < N; ++i) for (unsigned i = 0, N = CompileUnits.size(); i < N; ++i)
delete CompileUnits[i]; delete CompileUnits[i];
for (unsigned j = 0, M = Values.size(); j < M; ++j) for (unsigned j = 0, M = Values.size(); j < M; ++j)
delete Values[j]; delete Values[j];
} }
// Accessors.
//
const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
/// SetModuleInfo - Set machine module information when it's known that pass /// SetModuleInfo - Set machine module information when it's known that pass
/// manager has created it. Set by the target AsmPrinter. /// manager has created it. Set by the target AsmPrinter.
void SetModuleInfo(MachineModuleInfo *mmi) { void SetModuleInfo(MachineModuleInfo *mmi) {
@ -2539,14 +2551,12 @@ public:
this->M = M; this->M = M;
if (!ShouldEmitDwarf()) return; if (!ShouldEmitDwarf()) return;
Asm->EOL("Dwarf Begin Module");
} }
/// EndModule - Emit all Dwarf sections that should come after the content. /// EndModule - Emit all Dwarf sections that should come after the content.
/// ///
void EndModule() { void EndModule() {
if (!ShouldEmitDwarf()) return; if (!ShouldEmitDwarf()) return;
Asm->EOL("Dwarf End Module");
// Standard sections final addresses. // Standard sections final addresses.
Asm->SwitchToTextSection(TAI->getTextSection()); Asm->SwitchToTextSection(TAI->getTextSection());
@ -2597,7 +2607,6 @@ public:
this->MF = MF; this->MF = MF;
if (!ShouldEmitDwarf()) return; if (!ShouldEmitDwarf()) return;
Asm->EOL("Dwarf Begin Function");
// Begin accumulating function debug information. // Begin accumulating function debug information.
MMI->BeginFunction(MF); MMI->BeginFunction(MF);
@ -2606,14 +2615,19 @@ public:
EmitLabel("func_begin", ++SubprogramCount); EmitLabel("func_begin", ++SubprogramCount);
} }
/// PreExceptionEndFunction - Close off function before exception handling
/// tables.
void PreExceptionEndFunction() {
if (!ShouldEmitDwarf()) return;
// Define end label for subprogram.
EmitLabel("func_end", SubprogramCount);
}
/// EndFunction - Gather and emit post-function debug information. /// EndFunction - Gather and emit post-function debug information.
/// ///
void EndFunction() { void EndFunction() {
if (!ShouldEmitDwarf()) return; if (!ShouldEmitDwarf()) return;
Asm->EOL("Dwarf End Function");
// Define end label for subprogram.
EmitLabel("func_end", SubprogramCount);
// Get function line info. // Get function line info.
const std::vector<SourceLineInfo> &LineInfos = MMI->getSourceLines(); const std::vector<SourceLineInfo> &LineInfos = MMI->getSourceLines();
@ -2642,37 +2656,99 @@ public:
} }
}; };
//===----------------------------------------------------------------------===//
/// DwarfException - Emits Dwarf exception handling directives.
///
class DwarfException : public Dwarf {
public:
//===--------------------------------------------------------------------===//
// Main entry points.
//
DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
: Dwarf(OS, A, T)
{}
virtual ~DwarfException() {}
/// SetModuleInfo - Set machine module information when it's known that pass
/// manager has created it. Set by the target AsmPrinter.
void SetModuleInfo(MachineModuleInfo *mmi) {
// Make sure initial declarations are made.
if (!MMI && TAI->getSupportsExceptionHandling()) {
MMI = mmi;
shouldEmit = true;
}
}
/// BeginModule - Emit all exception information that should come prior to the
/// content.
void BeginModule(Module *M) {
this->M = M;
if (!ShouldEmitDwarf()) return;
}
/// EndModule - Emit all exception information that should come after the
/// content.
void EndModule() {
if (!ShouldEmitDwarf()) return;
}
/// BeginFunction - Gather pre-function exception information. Assumes being
/// emitted immediately after the function entry point.
void BeginFunction(MachineFunction *MF) {
this->MF = MF;
if (!ShouldEmitDwarf()) return;
}
/// EndFunction - Gather and emit post-function exception information.
///
void EndFunction() {
if (!ShouldEmitDwarf()) return;
if (const char *GlobalDirective = TAI->getGlobalDirective())
O << GlobalDirective << getAsm()->CurrentFnName << ".eh\n";
O << getAsm()->CurrentFnName << ".eh = 0\n";
if (const char *UsedDirective = TAI->getUsedDirective())
O << UsedDirective << getAsm()->CurrentFnName << ".eh\n";
}
};
} // End of namespace llvm } // End of namespace llvm
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// Emit - Print the abbreviation using the specified Dwarf writer. /// Emit - Print the abbreviation using the specified Dwarf writer.
/// ///
void DIEAbbrev::Emit(const Dwarf &DW) const { void DIEAbbrev::Emit(const DwarfDebug &DD) const {
// Emit its Dwarf tag type. // Emit its Dwarf tag type.
DW.getAsm()->EmitULEB128Bytes(Tag); DD.getAsm()->EmitULEB128Bytes(Tag);
DW.getAsm()->EOL(TagString(Tag)); DD.getAsm()->EOL(TagString(Tag));
// Emit whether it has children DIEs. // Emit whether it has children DIEs.
DW.getAsm()->EmitULEB128Bytes(ChildrenFlag); DD.getAsm()->EmitULEB128Bytes(ChildrenFlag);
DW.getAsm()->EOL(ChildrenString(ChildrenFlag)); DD.getAsm()->EOL(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.
DW.getAsm()->EmitULEB128Bytes(AttrData.getAttribute()); DD.getAsm()->EmitULEB128Bytes(AttrData.getAttribute());
DW.getAsm()->EOL(AttributeString(AttrData.getAttribute())); DD.getAsm()->EOL(AttributeString(AttrData.getAttribute()));
// Emit form type. // Emit form type.
DW.getAsm()->EmitULEB128Bytes(AttrData.getForm()); DD.getAsm()->EmitULEB128Bytes(AttrData.getForm());
DW.getAsm()->EOL(FormEncodingString(AttrData.getForm())); DD.getAsm()->EOL(FormEncodingString(AttrData.getForm()));
} }
// Mark end of abbreviation. // Mark end of abbreviation.
DW.getAsm()->EmitULEB128Bytes(0); DW.getAsm()->EOL("EOM(1)"); DD.getAsm()->EmitULEB128Bytes(0); DD.getAsm()->EOL("EOM(1)");
DW.getAsm()->EmitULEB128Bytes(0); DW.getAsm()->EOL("EOM(2)"); DD.getAsm()->EmitULEB128Bytes(0); DD.getAsm()->EOL("EOM(2)");
} }
#ifndef NDEBUG #ifndef NDEBUG
@ -2708,26 +2784,26 @@ void DIEValue::dump() {
/// EmitValue - Emit integer of appropriate size. /// EmitValue - Emit integer of appropriate size.
/// ///
void DIEInteger::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEInteger::EmitValue(const DwarfDebug &DD, unsigned Form) const {
switch (Form) { switch (Form) {
case DW_FORM_flag: // Fall thru case DW_FORM_flag: // Fall thru
case DW_FORM_ref1: // Fall thru case DW_FORM_ref1: // Fall thru
case DW_FORM_data1: DW.getAsm()->EmitInt8(Integer); break; case DW_FORM_data1: DD.getAsm()->EmitInt8(Integer); break;
case DW_FORM_ref2: // Fall thru case DW_FORM_ref2: // Fall thru
case DW_FORM_data2: DW.getAsm()->EmitInt16(Integer); break; case DW_FORM_data2: DD.getAsm()->EmitInt16(Integer); break;
case DW_FORM_ref4: // Fall thru case DW_FORM_ref4: // Fall thru
case DW_FORM_data4: DW.getAsm()->EmitInt32(Integer); break; case DW_FORM_data4: DD.getAsm()->EmitInt32(Integer); break;
case DW_FORM_ref8: // Fall thru case DW_FORM_ref8: // Fall thru
case DW_FORM_data8: DW.getAsm()->EmitInt64(Integer); break; case DW_FORM_data8: DD.getAsm()->EmitInt64(Integer); break;
case DW_FORM_udata: DW.getAsm()->EmitULEB128Bytes(Integer); break; case DW_FORM_udata: DD.getAsm()->EmitULEB128Bytes(Integer); break;
case DW_FORM_sdata: DW.getAsm()->EmitSLEB128Bytes(Integer); break; case DW_FORM_sdata: DD.getAsm()->EmitSLEB128Bytes(Integer); break;
default: assert(0 && "DIE Value form not supported yet"); break; default: assert(0 && "DIE Value form not supported yet"); break;
} }
} }
/// SizeOf - Determine size of integer value in bytes. /// SizeOf - Determine size of integer value in bytes.
/// ///
unsigned DIEInteger::SizeOf(const Dwarf &DW, unsigned Form) const { unsigned DIEInteger::SizeOf(const DwarfDebug &DD, unsigned Form) const {
switch (Form) { switch (Form) {
case DW_FORM_flag: // Fall thru case DW_FORM_flag: // Fall thru
case DW_FORM_ref1: // Fall thru case DW_FORM_ref1: // Fall thru
@ -2738,8 +2814,8 @@ unsigned DIEInteger::SizeOf(const Dwarf &DW, unsigned Form) const {
case DW_FORM_data4: return sizeof(int32_t); case DW_FORM_data4: return sizeof(int32_t);
case DW_FORM_ref8: // Fall thru case DW_FORM_ref8: // Fall thru
case DW_FORM_data8: return sizeof(int64_t); case DW_FORM_data8: return sizeof(int64_t);
case DW_FORM_udata: return DW.getAsm()->SizeULEB128(Integer); case DW_FORM_udata: return DD.getAsm()->SizeULEB128(Integer);
case DW_FORM_sdata: return DW.getAsm()->SizeSLEB128(Integer); case DW_FORM_sdata: return DD.getAsm()->SizeSLEB128(Integer);
default: assert(0 && "DIE Value form not supported yet"); break; default: assert(0 && "DIE Value form not supported yet"); break;
} }
return 0; return 0;
@ -2749,72 +2825,72 @@ unsigned DIEInteger::SizeOf(const Dwarf &DW, unsigned Form) const {
/// EmitValue - Emit string value. /// EmitValue - Emit string value.
/// ///
void DIEString::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEString::EmitValue(const DwarfDebug &DD, unsigned Form) const {
DW.getAsm()->EmitString(String); DD.getAsm()->EmitString(String);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// EmitValue - Emit label value. /// EmitValue - Emit label value.
/// ///
void DIEDwarfLabel::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEDwarfLabel::EmitValue(const DwarfDebug &DD, unsigned Form) const {
DW.EmitReference(Label); DD.EmitReference(Label);
} }
/// SizeOf - Determine size of label value in bytes. /// SizeOf - Determine size of label value in bytes.
/// ///
unsigned DIEDwarfLabel::SizeOf(const Dwarf &DW, unsigned Form) const { unsigned DIEDwarfLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
return DW.getTargetAsmInfo()->getAddressSize(); return DD.getTargetAsmInfo()->getAddressSize();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// EmitValue - Emit label value. /// EmitValue - Emit label value.
/// ///
void DIEObjectLabel::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEObjectLabel::EmitValue(const DwarfDebug &DD, unsigned Form) const {
DW.EmitReference(Label); DD.EmitReference(Label);
} }
/// SizeOf - Determine size of label value in bytes. /// SizeOf - Determine size of label value in bytes.
/// ///
unsigned DIEObjectLabel::SizeOf(const Dwarf &DW, unsigned Form) const { unsigned DIEObjectLabel::SizeOf(const DwarfDebug &DD, unsigned Form) const {
return DW.getTargetAsmInfo()->getAddressSize(); return DD.getTargetAsmInfo()->getAddressSize();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// EmitValue - Emit delta value. /// EmitValue - Emit delta value.
/// ///
void DIEDelta::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEDelta::EmitValue(const DwarfDebug &DD, unsigned Form) const {
bool IsSmall = Form == DW_FORM_data4; bool IsSmall = Form == DW_FORM_data4;
DW.EmitDifference(LabelHi, LabelLo, IsSmall); DD.EmitDifference(LabelHi, LabelLo, IsSmall);
} }
/// SizeOf - Determine size of delta value in bytes. /// SizeOf - Determine size of delta value in bytes.
/// ///
unsigned DIEDelta::SizeOf(const Dwarf &DW, unsigned Form) const { unsigned DIEDelta::SizeOf(const DwarfDebug &DD, unsigned Form) const {
if (Form == DW_FORM_data4) return 4; if (Form == DW_FORM_data4) return 4;
return DW.getTargetAsmInfo()->getAddressSize(); return DD.getTargetAsmInfo()->getAddressSize();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// EmitValue - Emit debug information entry offset. /// EmitValue - Emit debug information entry offset.
/// ///
void DIEntry::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEntry::EmitValue(const DwarfDebug &DD, unsigned Form) const {
DW.getAsm()->EmitInt32(Entry->getOffset()); DD.getAsm()->EmitInt32(Entry->getOffset());
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// ComputeSize - calculate the size of the block. /// ComputeSize - calculate the size of the block.
/// ///
unsigned DIEBlock::ComputeSize(Dwarf &DW) { unsigned DIEBlock::ComputeSize(DwarfDebug &DD) {
if (!Size) { if (!Size) {
const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData(); const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData();
for (unsigned i = 0, N = Values.size(); i < N; ++i) { for (unsigned i = 0, N = Values.size(); i < N; ++i) {
Size += Values[i]->SizeOf(DW, AbbrevData[i].getForm()); Size += Values[i]->SizeOf(DD, AbbrevData[i].getForm());
} }
} }
return Size; return Size;
@ -2822,31 +2898,31 @@ unsigned DIEBlock::ComputeSize(Dwarf &DW) {
/// EmitValue - Emit block data. /// EmitValue - Emit block data.
/// ///
void DIEBlock::EmitValue(const Dwarf &DW, unsigned Form) const { void DIEBlock::EmitValue(const DwarfDebug &DD, unsigned Form) const {
switch (Form) { switch (Form) {
case DW_FORM_block1: DW.getAsm()->EmitInt8(Size); break; case DW_FORM_block1: DD.getAsm()->EmitInt8(Size); break;
case DW_FORM_block2: DW.getAsm()->EmitInt16(Size); break; case DW_FORM_block2: DD.getAsm()->EmitInt16(Size); break;
case DW_FORM_block4: DW.getAsm()->EmitInt32(Size); break; case DW_FORM_block4: DD.getAsm()->EmitInt32(Size); break;
case DW_FORM_block: DW.getAsm()->EmitULEB128Bytes(Size); break; case DW_FORM_block: DD.getAsm()->EmitULEB128Bytes(Size); break;
default: assert(0 && "Improper form for block"); break; default: assert(0 && "Improper form for block"); break;
} }
const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData(); const std::vector<DIEAbbrevData> &AbbrevData = Abbrev.getData();
for (unsigned i = 0, N = Values.size(); i < N; ++i) { for (unsigned i = 0, N = Values.size(); i < N; ++i) {
DW.getAsm()->EOL(""); DD.getAsm()->EOL("");
Values[i]->EmitValue(DW, AbbrevData[i].getForm()); Values[i]->EmitValue(DD, AbbrevData[i].getForm());
} }
} }
/// SizeOf - Determine size of block data in bytes. /// SizeOf - Determine size of block data in bytes.
/// ///
unsigned DIEBlock::SizeOf(const Dwarf &DW, unsigned Form) const { unsigned DIEBlock::SizeOf(const DwarfDebug &DD, unsigned Form) const {
switch (Form) { switch (Form) {
case DW_FORM_block1: return Size + sizeof(int8_t); case DW_FORM_block1: return Size + sizeof(int8_t);
case DW_FORM_block2: return Size + sizeof(int16_t); case DW_FORM_block2: return Size + sizeof(int16_t);
case DW_FORM_block4: return Size + sizeof(int32_t); case DW_FORM_block4: return Size + sizeof(int32_t);
case DW_FORM_block: return Size + DW.getAsm()->SizeULEB128(Size); case DW_FORM_block: return Size + DD.getAsm()->SizeULEB128(Size);
default: assert(0 && "Improper form for block"); break; default: assert(0 && "Improper form for block"); break;
} }
return 0; return 0;
@ -2941,39 +3017,47 @@ void DIE::dump() {
DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A, DwarfWriter::DwarfWriter(std::ostream &OS, AsmPrinter *A,
const TargetAsmInfo *T) { const TargetAsmInfo *T) {
DW = new Dwarf(OS, A, T); DE = new DwarfException(OS, A, T);
DD = new DwarfDebug(OS, A, T);
} }
DwarfWriter::~DwarfWriter() { DwarfWriter::~DwarfWriter() {
delete DW; delete DE;
delete DD;
} }
/// SetModuleInfo - Set machine module info when it's known that pass manager /// SetModuleInfo - Set machine module info when it's known that pass manager
/// has created it. Set by the target AsmPrinter. /// has created it. Set by the target AsmPrinter.
void DwarfWriter::SetModuleInfo(MachineModuleInfo *MMI) { void DwarfWriter::SetModuleInfo(MachineModuleInfo *MMI) {
DW->SetModuleInfo(MMI); DE->SetModuleInfo(MMI);
DD->SetModuleInfo(MMI);
} }
/// BeginModule - Emit all Dwarf sections that should come prior to the /// BeginModule - Emit all Dwarf sections that should come prior to the
/// content. /// content.
void DwarfWriter::BeginModule(Module *M) { void DwarfWriter::BeginModule(Module *M) {
DW->BeginModule(M); DE->BeginModule(M);
DD->BeginModule(M);
} }
/// EndModule - Emit all Dwarf sections that should come after the content. /// EndModule - Emit all Dwarf sections that should come after the content.
/// ///
void DwarfWriter::EndModule() { void DwarfWriter::EndModule() {
DW->EndModule(); DE->EndModule();
DD->EndModule();
} }
/// BeginFunction - Gather pre-function debug information. Assumes being /// BeginFunction - Gather pre-function debug information. Assumes being
/// emitted immediately after the function entry point. /// emitted immediately after the function entry point.
void DwarfWriter::BeginFunction(MachineFunction *MF) { void DwarfWriter::BeginFunction(MachineFunction *MF) {
DW->BeginFunction(MF); DE->BeginFunction(MF);
DD->BeginFunction(MF);
} }
/// EndFunction - Gather and emit post-function debug information. /// EndFunction - Gather and emit post-function debug information.
/// ///
void DwarfWriter::EndFunction() { void DwarfWriter::EndFunction() {
DW->EndFunction(); DD->PreExceptionEndFunction();
DE->EndFunction();
DD->EndFunction();
} }

View File

@ -756,8 +756,7 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
// Prepare for debug frame info. // Prepare for frame info.
bool hasDebugInfo = MMI && MMI->hasDebugInfo();
unsigned FrameLabelId = 0; unsigned FrameLabelId = 0;
// Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it, // Scan the prolog, looking for an UPDATE_VRSAVE instruction. If we find it,
@ -819,7 +818,7 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment(); unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
unsigned MaxAlign = MFI->getMaxAlignment(); unsigned MaxAlign = MFI->getMaxAlignment();
if (hasDebugInfo) { if (MMI) {
// Mark effective beginning of when frame pointer becomes valid. // Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID(); FrameLabelId = MMI->NextLabelID();
BuildMI(MBB, MBBI, TII.get(PPC::LABEL)).addImm(FrameLabelId); BuildMI(MBB, MBBI, TII.get(PPC::LABEL)).addImm(FrameLabelId);
@ -870,7 +869,7 @@ void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
} }
} }
if (hasDebugInfo) { if (MMI) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves(); std::vector<MachineMove> &Moves = MMI->getFrameMoves();
if (NegFrameSize) { if (NegFrameSize) {

View File

@ -51,12 +51,14 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
PrivateGlobalPrefix = "L"; PrivateGlobalPrefix = "L";
ConstantPoolSection = "\t.const\t"; ConstantPoolSection = "\t.const\t";
JumpTableDataSection = ".const"; JumpTableDataSection = ".const";
GlobalDirective = "\t.globl\t";
CStringSection = "\t.cstring"; CStringSection = "\t.cstring";
StaticCtorsSection = ".mod_init_func"; StaticCtorsSection = ".mod_init_func";
StaticDtorsSection = ".mod_term_func"; StaticDtorsSection = ".mod_term_func";
UsedDirective = "\t.no_dead_strip\t"; UsedDirective = "\t.no_dead_strip\t";
WeakRefDirective = "\t.weak_reference\t"; WeakRefDirective = "\t.weak_reference\t";
HiddenDirective = "\t.private_extern\t"; HiddenDirective = "\t.private_extern\t";
SupportsExceptionHandling = true;
// In non-PIC modes, emit a special label before jump tables so that the // In non-PIC modes, emit a special label before jump tables so that the
// linker can perform more accurate dead code stripping. // linker can perform more accurate dead code stripping.

View File

@ -59,6 +59,7 @@ TargetAsmInfo::TargetAsmInfo() :
FourByteConstantSection(0), FourByteConstantSection(0),
EightByteConstantSection(0), EightByteConstantSection(0),
SixteenByteConstantSection(0), SixteenByteConstantSection(0),
GlobalDirective(0),
SetDirective(0), SetDirective(0),
LCOMMDirective(0), LCOMMDirective(0),
COMMDirective("\t.comm\t"), COMMDirective("\t.comm\t"),
@ -70,6 +71,7 @@ TargetAsmInfo::TargetAsmInfo() :
HasLEB128(false), HasLEB128(false),
HasDotLoc(false), HasDotLoc(false),
HasDotFile(false), HasDotFile(false),
SupportsExceptionHandling(false),
DwarfRequiresFrameSection(true), DwarfRequiresFrameSection(true),
DwarfAbbrevSection(".debug_abbrev"), DwarfAbbrevSection(".debug_abbrev"),
DwarfInfoSection(".debug_info"), DwarfInfoSection(".debug_info"),

View File

@ -997,8 +997,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineInstr *MI; MachineInstr *MI;
MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
// Prepare for debug frame info. // Prepare for frame info.
bool hasDebugInfo = MMI && MMI->hasDebugInfo();
unsigned FrameLabelId = 0; unsigned FrameLabelId = 0;
// Get the number of bytes to allocate from the FrameInfo // Get the number of bytes to allocate from the FrameInfo
@ -1023,7 +1022,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
} }
} }
if (hasDebugInfo) { if (MMI) {
// Mark effective beginning of when frame pointer becomes valid. // Mark effective beginning of when frame pointer becomes valid.
FrameLabelId = MMI->NextLabelID(); FrameLabelId = MMI->NextLabelID();
BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(FrameLabelId); BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(FrameLabelId);
@ -1053,7 +1052,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MBB.insert(MBBI, MI); MBB.insert(MBBI, MI);
} }
if (hasDebugInfo) { if (MMI) {
std::vector<MachineMove> &Moves = MMI->getFrameMoves(); std::vector<MachineMove> &Moves = MMI->getFrameMoves();
if (NumBytes) { if (NumBytes) {