mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
This mechanical patch moves type handling into CompileUnit from DwarfDebug. In case of multiple compile unit in one object file, each compile unit is responsible for its own set of type entries anyway. This refactoring makes this obvious.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129402 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d5f323d70b
commit
3cbee30eac
@ -5,6 +5,7 @@ add_llvm_library(LLVMAsmPrinter
|
||||
AsmPrinterInlineAsm.cpp
|
||||
DIE.cpp
|
||||
DwarfCFIException.cpp
|
||||
DwarfCompileUnit.cpp
|
||||
DwarfDebug.cpp
|
||||
DwarfException.cpp
|
||||
DwarfTableException.cpp
|
||||
|
@ -15,12 +15,19 @@
|
||||
#define CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
|
||||
|
||||
#include "DIE.h"
|
||||
#include "llvm/Analysis/DebugInfo.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class DwarfDebug;
|
||||
class MachineLocation;
|
||||
class MachineOperand;
|
||||
class ConstantInt;
|
||||
class DbgVariable;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// CompileUnit - This dwarf writer support class manages information associate
|
||||
/// with a source file.
|
||||
@ -33,6 +40,11 @@ class CompileUnit {
|
||||
///
|
||||
const OwningPtr<DIE> CUDie;
|
||||
|
||||
/// Asm - Target of Dwarf emission.
|
||||
AsmPrinter *Asm;
|
||||
|
||||
DwarfDebug *DD;
|
||||
|
||||
/// IndexTyDie - An anonymous type for index type. Owned by CUDie.
|
||||
DIE *IndexTyDie;
|
||||
|
||||
@ -52,9 +64,12 @@ class CompileUnit {
|
||||
///
|
||||
StringMap<DIE*> GlobalTypes;
|
||||
|
||||
/// DIEBlocks - A list of all the DIEBlocks in use.
|
||||
std::vector<DIEBlock *> DIEBlocks;
|
||||
|
||||
public:
|
||||
CompileUnit(unsigned I, DIE *D)
|
||||
: ID(I), CUDie(D), IndexTyDie(0) {}
|
||||
CompileUnit(unsigned I, DIE *D, AsmPrinter *A, DwarfDebug *D);
|
||||
~CompileUnit();
|
||||
|
||||
// Accessors.
|
||||
unsigned getID() const { return ID; }
|
||||
@ -80,6 +95,10 @@ public:
|
||||
/// specified debug variable.
|
||||
DIE *getDIE(const MDNode *N) { return MDNodeToDieMap.lookup(N); }
|
||||
|
||||
DIEBlock *getDIEBlock() {
|
||||
return new (DIEValueAllocator) DIEBlock();
|
||||
}
|
||||
|
||||
/// insertDIE - Insert DIE into the map.
|
||||
void insertDIE(const MDNode *N, DIE *D) {
|
||||
MDNodeToDieMap.insert(std::make_pair(N, D));
|
||||
@ -116,7 +135,144 @@ public:
|
||||
void setIndexTyDie(DIE *D) {
|
||||
IndexTyDie = D;
|
||||
}
|
||||
public:
|
||||
|
||||
/// addUInt - Add an unsigned integer attribute data and value.
|
||||
///
|
||||
void addUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer);
|
||||
|
||||
/// addSInt - Add an signed integer attribute data and value.
|
||||
///
|
||||
void addSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer);
|
||||
|
||||
/// addString - Add a string attribute data and value.
|
||||
///
|
||||
void addString(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const StringRef Str);
|
||||
|
||||
/// addLabel - Add a Dwarf label attribute data and value.
|
||||
///
|
||||
void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const MCSymbol *Label);
|
||||
|
||||
/// addDelta - Add a label delta attribute data and value.
|
||||
///
|
||||
void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const MCSymbol *Hi, const MCSymbol *Lo);
|
||||
|
||||
/// addDIEEntry - Add a DIE attribute data and value.
|
||||
///
|
||||
void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry);
|
||||
|
||||
/// addBlock - Add block data.
|
||||
///
|
||||
void addBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block);
|
||||
|
||||
/// addSourceLine - Add location information to specified debug information
|
||||
/// entry.
|
||||
void addSourceLine(DIE *Die, DIVariable V);
|
||||
void addSourceLine(DIE *Die, DIGlobalVariable G);
|
||||
void addSourceLine(DIE *Die, DISubprogram SP);
|
||||
void addSourceLine(DIE *Die, DIType Ty);
|
||||
void addSourceLine(DIE *Die, DINameSpace NS);
|
||||
|
||||
/// addAddress - Add an address attribute to a die based on the location
|
||||
/// provided.
|
||||
void addAddress(DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
/// addRegisterAddress - Add register location entry in variable DIE.
|
||||
bool addRegisterAddress(DIE *Die, const MachineOperand &MO);
|
||||
|
||||
/// addConstantValue - Add constant value entry in variable DIE.
|
||||
bool addConstantValue(DIE *Die, const MachineOperand &MO);
|
||||
bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned);
|
||||
|
||||
/// addConstantFPValue - Add constant value entry in variable DIE.
|
||||
bool addConstantFPValue(DIE *Die, const MachineOperand &MO);
|
||||
|
||||
/// addTemplateParams - Add template parameters in buffer.
|
||||
void addTemplateParams(DIE &Buffer, DIArray TParams);
|
||||
|
||||
/// addComplexAddress - Start with the address based on the location provided,
|
||||
/// and generate the DWARF information necessary to find the actual variable
|
||||
/// (navigating the extra location information encoded in the type) based on
|
||||
/// the starting location. Add the DWARF information to the die.
|
||||
///
|
||||
void addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
// FIXME: Should be reformulated in terms of addComplexAddress.
|
||||
/// addBlockByrefAddress - Start with the address based on the location
|
||||
/// provided, and generate the DWARF information necessary to find the
|
||||
/// actual Block variable (navigating the Block struct) based on the
|
||||
/// starting location. Add the DWARF information to the die. Obsolete,
|
||||
/// please use addComplexAddress instead.
|
||||
///
|
||||
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
/// addVariableAddress - Add DW_AT_location attribute for a DbgVariable based
|
||||
/// on provided frame index.
|
||||
void addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI);
|
||||
|
||||
/// addToContextOwner - Add Die into the list of its context owner's children.
|
||||
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
||||
|
||||
/// addType - Add a new type attribute to the specified entity.
|
||||
void addType(DIE *Entity, DIType Ty);
|
||||
|
||||
/// getOrCreateNameSpace - Create a DIE for DINameSpace.
|
||||
DIE *getOrCreateNameSpace(DINameSpace NS);
|
||||
|
||||
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
|
||||
/// given DIType.
|
||||
DIE *getOrCreateTypeDIE(DIType Ty);
|
||||
|
||||
/// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE
|
||||
/// for the given DITemplateTypeParameter.
|
||||
DIE *getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP);
|
||||
|
||||
/// getOrCreateTemplateValueParameterDIE - Find existing DIE or create new DIE
|
||||
/// for the given DITemplateValueParameter.
|
||||
DIE *getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TVP);
|
||||
|
||||
/// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
|
||||
/// information entry.
|
||||
DIEEntry *createDIEEntry(DIE *Entry);
|
||||
|
||||
void addPubTypes(DISubprogram SP);
|
||||
|
||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DIBasicType BTy);
|
||||
|
||||
/// constructTypeDIE - Construct derived type die from DIDerivedType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DIDerivedType DTy);
|
||||
|
||||
/// constructTypeDIE - Construct type DIE from DICompositeType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DICompositeType CTy);
|
||||
|
||||
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
|
||||
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
|
||||
|
||||
/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
|
||||
void constructArrayTypeDIE(DIE &Buffer,
|
||||
DICompositeType *CTy);
|
||||
|
||||
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
||||
DIE *constructEnumTypeDIE(DIEnumerator ETy);
|
||||
|
||||
/// createMemberDIE - Create new member DIE.
|
||||
DIE *createMemberDIE(DIDerivedType DT);
|
||||
|
||||
private:
|
||||
|
||||
// DIEValueAllocator - All DIEValues are allocated through this allocator.
|
||||
BumpPtrAllocator DIEValueAllocator;
|
||||
DIEInteger *DIEIntegerOne;
|
||||
};
|
||||
|
||||
} // end llvm namespace
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,7 @@
|
||||
|
||||
#include "llvm/CodeGen/AsmPrinter.h"
|
||||
#include "llvm/CodeGen/MachineLocation.h"
|
||||
#include "llvm/Analysis/DebugInfo.h"
|
||||
#include "DIE.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
@ -39,21 +40,6 @@ class DIEAbbrev;
|
||||
class DIE;
|
||||
class DIEBlock;
|
||||
class DIEEntry;
|
||||
class DIArray;
|
||||
class DIEnumerator;
|
||||
class DIDescriptor;
|
||||
class DIVariable;
|
||||
class DIGlobal;
|
||||
class DIGlobalVariable;
|
||||
class DISubprogram;
|
||||
class DIBasicType;
|
||||
class DIDerivedType;
|
||||
class DIType;
|
||||
class DINameSpace;
|
||||
class DISubrange;
|
||||
class DICompositeType;
|
||||
class DITemplateTypeParameter;
|
||||
class DITemplateValueParameter;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// SrcLineInfo - This class is used to record source line correspondence.
|
||||
@ -96,6 +82,43 @@ typedef struct DotDebugLocEntry {
|
||||
}
|
||||
} DotDebugLocEntry;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// DbgVariable - This class is used to track local variable information.
|
||||
///
|
||||
class DbgVariable {
|
||||
DIVariable Var; // Variable Descriptor.
|
||||
DIE *TheDIE; // Variable DIE.
|
||||
unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
|
||||
public:
|
||||
// AbsVar may be NULL.
|
||||
DbgVariable(DIVariable V) : Var(V), TheDIE(0), DotDebugLocOffset(~0U) {}
|
||||
|
||||
// Accessors.
|
||||
DIVariable getVariable() const { return Var; }
|
||||
void setDIE(DIE *D) { TheDIE = D; }
|
||||
DIE *getDIE() const { return TheDIE; }
|
||||
void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
|
||||
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
||||
StringRef getName() const { return Var.getName(); }
|
||||
unsigned getTag() const { return Var.getTag(); }
|
||||
bool variableHasComplexAddress() const {
|
||||
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
||||
return Var.hasComplexAddress();
|
||||
}
|
||||
bool isBlockByrefVariable() const {
|
||||
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
||||
return Var.isBlockByrefVariable();
|
||||
}
|
||||
unsigned getNumAddrElements() const {
|
||||
assert(Var.Verify() && "Invalid complex DbgVariable!");
|
||||
return Var.getNumAddrElements();
|
||||
}
|
||||
uint64_t getAddrElement(unsigned i) const {
|
||||
return Var.getAddrElement(i);
|
||||
}
|
||||
DIType getType() const;
|
||||
};
|
||||
|
||||
class DwarfDebug {
|
||||
/// Asm - Target of Dwarf emission.
|
||||
AsmPrinter *Asm;
|
||||
@ -122,12 +145,6 @@ class DwarfDebug {
|
||||
/// id mapped to a unique id.
|
||||
StringMap<unsigned> SourceIdMap;
|
||||
|
||||
/// DIEBlocks - A list of all the DIEBlocks in use.
|
||||
std::vector<DIEBlock *> DIEBlocks;
|
||||
|
||||
// DIEValueAllocator - All DIEValues are allocated through this allocator.
|
||||
BumpPtrAllocator DIEValueAllocator;
|
||||
|
||||
/// StringPool - A String->Symbol mapping of strings used by indirect
|
||||
/// references.
|
||||
StringMap<std::pair<MCSymbol*, unsigned> > StringPool;
|
||||
@ -244,6 +261,9 @@ class DwarfDebug {
|
||||
|
||||
std::vector<FunctionDebugFrameInfo> DebugFrames;
|
||||
|
||||
// DIEValueAllocator - All DIEValues are allocated through this allocator.
|
||||
BumpPtrAllocator DIEValueAllocator;
|
||||
|
||||
// Section Symbols: these are assembler temporary labels that are emitted at
|
||||
// the beginning of each supported dwarf section. These are used to form
|
||||
// section offsets and are created by EmitSectionLabels.
|
||||
@ -252,149 +272,12 @@ class DwarfDebug {
|
||||
MCSymbol *DwarfDebugLocSectionSym;
|
||||
MCSymbol *FunctionBeginSym, *FunctionEndSym;
|
||||
|
||||
DIEInteger *DIEIntegerOne;
|
||||
|
||||
private:
|
||||
|
||||
/// assignAbbrevNumber - Define a unique number for the abbreviation.
|
||||
///
|
||||
void assignAbbrevNumber(DIEAbbrev &Abbrev);
|
||||
|
||||
/// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
|
||||
/// information entry.
|
||||
DIEEntry *createDIEEntry(DIE *Entry);
|
||||
|
||||
/// addUInt - Add an unsigned integer attribute data and value.
|
||||
///
|
||||
void addUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer);
|
||||
|
||||
/// addSInt - Add an signed integer attribute data and value.
|
||||
///
|
||||
void addSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer);
|
||||
|
||||
/// addString - Add a string attribute data and value.
|
||||
///
|
||||
void addString(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const StringRef Str);
|
||||
|
||||
/// addLabel - Add a Dwarf label attribute data and value.
|
||||
///
|
||||
void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const MCSymbol *Label);
|
||||
|
||||
/// addDelta - Add a label delta attribute data and value.
|
||||
///
|
||||
void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
|
||||
const MCSymbol *Hi, const MCSymbol *Lo);
|
||||
|
||||
/// addDIEEntry - Add a DIE attribute data and value.
|
||||
///
|
||||
void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry);
|
||||
|
||||
/// addBlock - Add block data.
|
||||
///
|
||||
void addBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block);
|
||||
|
||||
/// addSourceLine - Add location information to specified debug information
|
||||
/// entry.
|
||||
void addSourceLine(DIE *Die, DIVariable V);
|
||||
void addSourceLine(DIE *Die, DIGlobalVariable G);
|
||||
void addSourceLine(DIE *Die, DISubprogram SP);
|
||||
void addSourceLine(DIE *Die, DIType Ty);
|
||||
void addSourceLine(DIE *Die, DINameSpace NS);
|
||||
|
||||
/// addAddress - Add an address attribute to a die based on the location
|
||||
/// provided.
|
||||
void addAddress(DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
/// addRegisterAddress - Add register location entry in variable DIE.
|
||||
bool addRegisterAddress(DIE *Die, const MachineOperand &MO);
|
||||
|
||||
/// addConstantValue - Add constant value entry in variable DIE.
|
||||
bool addConstantValue(DIE *Die, const MachineOperand &MO);
|
||||
bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned);
|
||||
|
||||
/// addConstantFPValue - Add constant value entry in variable DIE.
|
||||
bool addConstantFPValue(DIE *Die, const MachineOperand &MO);
|
||||
|
||||
/// addTemplateParams - Add template parameters in buffer.
|
||||
void addTemplateParams(DIE &Buffer, DIArray TParams);
|
||||
|
||||
/// addComplexAddress - Start with the address based on the location provided,
|
||||
/// and generate the DWARF information necessary to find the actual variable
|
||||
/// (navigating the extra location information encoded in the type) based on
|
||||
/// the starting location. Add the DWARF information to the die.
|
||||
///
|
||||
void addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
// FIXME: Should be reformulated in terms of addComplexAddress.
|
||||
/// addBlockByrefAddress - Start with the address based on the location
|
||||
/// provided, and generate the DWARF information necessary to find the
|
||||
/// actual Block variable (navigating the Block struct) based on the
|
||||
/// starting location. Add the DWARF information to the die. Obsolete,
|
||||
/// please use addComplexAddress instead.
|
||||
///
|
||||
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
||||
const MachineLocation &Location);
|
||||
|
||||
/// addVariableAddress - Add DW_AT_location attribute for a DbgVariable based
|
||||
/// on provided frame index.
|
||||
void addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI);
|
||||
|
||||
/// addToContextOwner - Add Die into the list of its context owner's children.
|
||||
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
||||
|
||||
/// addType - Add a new type attribute to the specified entity.
|
||||
void addType(DIE *Entity, DIType Ty);
|
||||
|
||||
|
||||
/// getOrCreateNameSpace - Create a DIE for DINameSpace.
|
||||
DIE *getOrCreateNameSpace(DINameSpace NS);
|
||||
|
||||
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
|
||||
/// given DIType.
|
||||
DIE *getOrCreateTypeDIE(DIType Ty);
|
||||
|
||||
/// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE
|
||||
/// for the given DITemplateTypeParameter.
|
||||
DIE *getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP);
|
||||
|
||||
/// getOrCreateTemplateValueParameterDIE - Find existing DIE or create new DIE
|
||||
/// for the given DITemplateValueParameter.
|
||||
DIE *getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TVP);
|
||||
|
||||
void addPubTypes(DISubprogram SP);
|
||||
|
||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DIBasicType BTy);
|
||||
|
||||
/// constructTypeDIE - Construct derived type die from DIDerivedType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DIDerivedType DTy);
|
||||
|
||||
/// constructTypeDIE - Construct type DIE from DICompositeType.
|
||||
void constructTypeDIE(DIE &Buffer,
|
||||
DICompositeType CTy);
|
||||
|
||||
/// constructSubrangeDIE - Construct subrange DIE from DISubrange.
|
||||
void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
|
||||
|
||||
/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
|
||||
void constructArrayTypeDIE(DIE &Buffer,
|
||||
DICompositeType *CTy);
|
||||
|
||||
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
|
||||
DIE *constructEnumTypeDIE(DIEnumerator ETy);
|
||||
|
||||
/// createMemberDIE - Create new member DIE.
|
||||
DIE *createMemberDIE(DIDerivedType DT);
|
||||
|
||||
/// createSubprogramDIE - Create new DIE using SP.
|
||||
DIE *createSubprogramDIE(DISubprogram SP);
|
||||
|
||||
/// getOrCreateDbgScope - Create DbgScope for the scope.
|
||||
DbgScope *getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt);
|
||||
|
||||
@ -509,11 +392,6 @@ private:
|
||||
/// inlining instance.
|
||||
void emitDebugInlineInfo();
|
||||
|
||||
/// GetOrCreateSourceID - Look up the source id with the given directory and
|
||||
/// source file names. If none currently exists, create a new id and insert it
|
||||
/// in the SourceIds map.
|
||||
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FullName);
|
||||
|
||||
/// constructCompileUnit - Create new CompileUnit for the given
|
||||
/// metadata node with tag DW_TAG_compile_unit.
|
||||
void constructCompileUnit(const MDNode *N);
|
||||
@ -609,6 +487,14 @@ public:
|
||||
|
||||
/// endInstruction - Prcess end of an instruction.
|
||||
void endInstruction(const MachineInstr *MI);
|
||||
|
||||
/// GetOrCreateSourceID - Look up the source id with the given directory and
|
||||
/// source file names. If none currently exists, create a new id and insert it
|
||||
/// in the SourceIds map.
|
||||
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FullName);
|
||||
|
||||
/// createSubprogramDIE - Create new DIE using SP.
|
||||
DIE *createSubprogramDIE(DISubprogram SP);
|
||||
};
|
||||
} // End of namespace llvm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user