-//===-- llvm/CodeGen/DwarfCompileUnit.h - Dwarf Compile Unit ---*- C++ -*--===//
+//===-- llvm/CodeGen/DwarfUnit.h - Dwarf Compile Unit ---*- C++ -*--===//
//
// The LLVM Compiler Infrastructure
//
class DbgVariable;
//===----------------------------------------------------------------------===//
-/// CompileUnit - This dwarf writer support class manages information associated
+/// Unit - This dwarf writer support class manages information associated
/// with a source file.
-class CompileUnit {
+class Unit {
+protected:
/// UniqueID - a numeric ID unique among all CUs in the module
unsigned UniqueID;
/// Node - MDNode for the compile unit.
DICompileUnit Node;
- /// Language - Language for the translation unit associated with this CU.
- uint16_t Language;
-
/// CUDie - Compile unit debug information entry.
const OwningPtr<DIE> CUDie;
// DIEIntegerOne - A preallocated DIEValue because 1 is used frequently.
DIEInteger *DIEIntegerOne;
+ Unit(unsigned UID, DIE *D, DICompileUnit CU, AsmPrinter *A, DwarfDebug *DW,
+ DwarfUnits *DWU);
+
public:
- CompileUnit(unsigned UID, DIE *D, DICompileUnit CU, AsmPrinter *A,
- DwarfDebug *DW, DwarfUnits *DWU);
- CompileUnit(unsigned UID, DIE *D, uint16_t Language, AsmPrinter *A,
- DwarfDebug *DW, DwarfUnits *DWU);
- ~CompileUnit();
+ virtual ~Unit();
// Accessors.
unsigned getUniqueID() const { return UniqueID; }
- uint16_t getLanguage() const { return Language; }
+ virtual uint16_t getLanguage() const = 0;
DICompileUnit getNode() const { return Node; }
DIE *getCUDie() const { return CUDie.get(); }
const StringMap<const DIE *> &getGlobalNames() const { return GlobalNames; }
///
void addGlobalName(StringRef Name, DIE *Die, DIScope Context);
- /// addGlobalType - Add a new global type to the compile unit.
- void addGlobalType(DIType Ty);
-
- /// addPubTypes - Add a set of types from the subprogram to the global types.
- void addPubTypes(DISubprogram SP);
-
/// addAccelName - Add a new name to the name accelerator table.
void addAccelName(StringRef Name, const DIE *Die);
void addLabel(DIEBlock *Die, dwarf::Form Form, const MCSymbol *Label);
- /// addLabelAddress - Add a dwarf label attribute data and value using
- /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
- void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
+ /// addSectionLabel - Add a Dwarf section label attribute data and value.
+ ///
+ void addSectionLabel(DIE *Die, dwarf::Attribute Attribute,
+ const MCSymbol *Label);
+
+ /// addSectionOffset - Add an offset into a section attribute data and value.
+ ///
+ void addSectionOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer);
/// addOpAddress - Add a dwarf op address data and value using the
/// form given and an op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
void addOpAddress(DIEBlock *Die, const MCSymbol *Label);
- /// addDelta - Add a label delta attribute data and value.
- void addDelta(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form,
- const MCSymbol *Hi, const MCSymbol *Lo);
+ /// addSectionDelta - Add a label delta attribute data and value.
+ void addSectionDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
+ const MCSymbol *Lo);
/// addDIEEntry - Add a DIE attribute data and value.
void addDIEEntry(DIE *Die, dwarf::Attribute Attribute, DIE *Entry);
/// getOrCreateContextDIE - Get context owner's DIE.
DIE *getOrCreateContextDIE(DIScope Context);
- /// createGlobalVariableDIE - create global variable DIE.
- void createGlobalVariableDIE(DIGlobalVariable GV);
-
/// constructContainingTypeDIEs - Construct DIEs for types that contain
/// vtables.
void constructContainingTypeDIEs();
DIE *createAndAddDIE(unsigned Tag, DIE &Parent,
DIDescriptor N = DIDescriptor());
- /// constructTypeDIEImpl - Construct type DIE that is not a type unit
- /// reference from a DICompositeType.
- void constructTypeDIEImpl(DIE &Buffer, DICompositeType CTy);
-
/// Compute the size of a header for this unit, not including the initial
/// length field.
unsigned getHeaderSize() const {
/// Emit the header for this unit, not including the initial length field.
void emitHeader(const MCSection *ASection, const MCSymbol *ASectionSym);
+protected:
+ /// getOrCreateStaticMemberDIE - Create new static data member DIE.
+ DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
+
private:
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
void constructTemplateValueParameterDIE(DIE &Buffer,
DITemplateValueParameter TVP);
- /// getOrCreateStaticMemberDIE - Create new static data member DIE.
- DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
-
/// getLowerBoundDefault - Return the default lower bound for an array. If the
/// DWARF version doesn't handle the language, return -1.
int64_t getDefaultLowerBound() const;
/// If this is a named finished type then include it in the list of types for
/// the accelerator tables.
- void updateAcceleratorTables(DIType Ty, const DIE *TyDIE);
+ void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE *TyDIE);
};
+class CompileUnit : public Unit {
+public:
+ CompileUnit(unsigned UID, DIE *D, DICompileUnit Node, AsmPrinter *A,
+ DwarfDebug *DW, DwarfUnits *DWU);
+
+ /// createGlobalVariableDIE - create global variable DIE.
+ void createGlobalVariableDIE(DIGlobalVariable GV);
+
+ /// addLabelAddress - Add a dwarf label attribute data and value using
+ /// either DW_FORM_addr or DW_FORM_GNU_addr_index.
+ void addLabelAddress(DIE *Die, dwarf::Attribute Attribute, MCSymbol *Label);
+
+ uint16_t getLanguage() const { return getNode().getLanguage(); }
+};
+
+class TypeUnit : public Unit {
+private:
+ uint16_t Language;
+
+public:
+ TypeUnit(unsigned UID, DIE *D, uint16_t Language, AsmPrinter *A,
+ DwarfDebug *DW, DwarfUnits *DWU);
+
+ uint16_t getLanguage() const { return Language; }
+};
} // end llvm namespace
#endif