Collect and coalesce DBG_VALUE instructions before emitting the function.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
1 //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for writing dwarf debug info into asm files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef CODEGEN_ASMPRINTER_DWARFDEBUG_H__
15 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
16
17 #include "llvm/CodeGen/AsmPrinter.h"
18 #include "llvm/CodeGen/MachineLocation.h"
19 #include "DIE.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/FoldingSet.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/ADT/UniqueVector.h"
25 #include "llvm/Support/Allocator.h"
26 #include "llvm/Support/DebugLoc.h"
27
28 namespace llvm {
29
30 class CompileUnit;
31 class DbgConcreteScope;
32 class DbgScope;
33 class DbgVariable;
34 class MachineFrameInfo;
35 class MachineModuleInfo;
36 class MachineOperand;
37 class MCAsmInfo;
38 class DIEAbbrev;
39 class DIE;
40 class DIEBlock;
41 class DIEEntry;
42
43 class DIEnumerator;
44 class DIDescriptor;
45 class DIVariable;
46 class DIGlobal;
47 class DIGlobalVariable;
48 class DISubprogram;
49 class DIBasicType;
50 class DIDerivedType;
51 class DIType;
52 class DINameSpace;
53 class DISubrange;
54 class DICompositeType;
55 class DITemplateTypeParameter;
56 class DITemplateValueParameter;
57
58 //===----------------------------------------------------------------------===//
59 /// SrcLineInfo - This class is used to record source line correspondence.
60 ///
61 class SrcLineInfo {
62   unsigned Line;                     // Source line number.
63   unsigned Column;                   // Source column.
64   unsigned SourceID;                 // Source ID number.
65   MCSymbol *Label;                   // Label in code ID number.
66 public:
67   SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
68     : Line(L), Column(C), SourceID(S), Label(label) {}
69
70   // Accessors
71   unsigned getLine() const { return Line; }
72   unsigned getColumn() const { return Column; }
73   unsigned getSourceID() const { return SourceID; }
74   MCSymbol *getLabel() const { return Label; }
75 };
76
77 /// DotDebugLocEntry - This struct describes location entries emitted in
78 /// .debug_loc section.
79 typedef struct DotDebugLocEntry {
80   const MCSymbol *Begin;
81   const MCSymbol *End;
82   MachineLocation Loc;
83   bool Merged;
84   DotDebugLocEntry() : Begin(0), End(0), Merged(false) {}
85   DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L) 
86     : Begin(B), End(E), Loc(L), Merged(false) {}
87   /// Empty entries are also used as a trigger to emit temp label. Such
88   /// labels are referenced is used to find debug_loc offset for a given DIE.
89   bool isEmpty() { return Begin == 0 && End == 0; }
90   bool isMerged() { return Merged; }
91   void Merge(DotDebugLocEntry *Next) {
92     if (!(Begin && Loc == Next->Loc && End == Next->Begin))
93       return;
94     Next->Begin = Begin;
95     Merged = true;
96   }
97 } DotDebugLocEntry;
98
99 class DwarfDebug {
100   /// Asm - Target of Dwarf emission.
101   AsmPrinter *Asm;
102
103   /// MMI - Collected machine module information.
104   MachineModuleInfo *MMI;
105
106   //===--------------------------------------------------------------------===//
107   // Attributes used to construct specific Dwarf sections.
108   //
109
110   CompileUnit *FirstCU;
111   DenseMap <const MDNode *, CompileUnit *> CUMap;
112
113   /// AbbreviationsSet - Used to uniquely define abbreviations.
114   ///
115   FoldingSet<DIEAbbrev> AbbreviationsSet;
116
117   /// Abbreviations - A list of all the unique abbreviations in use.
118   ///
119   std::vector<DIEAbbrev *> Abbreviations;
120
121   /// SourceIdMap - Source id map, i.e. pair of directory id and source file
122   /// id mapped to a unique id.
123   StringMap<unsigned> SourceIdMap;
124
125   /// DIEBlocks - A list of all the DIEBlocks in use.
126   std::vector<DIEBlock *> DIEBlocks;
127
128   // DIEValueAllocator - All DIEValues are allocated through this allocator.
129   BumpPtrAllocator DIEValueAllocator;
130
131   /// StringPool - A String->Symbol mapping of strings used by indirect
132   /// references.
133   StringMap<std::pair<MCSymbol*, unsigned> > StringPool;
134   unsigned NextStringPoolNumber;
135   
136   MCSymbol *getStringPoolEntry(StringRef Str);
137
138   /// SectionMap - Provides a unique id per text section.
139   ///
140   UniqueVector<const MCSection*> SectionMap;
141
142   /// CurrentFnDbgScope - Top level scope for the current function.
143   ///
144   DbgScope *CurrentFnDbgScope;
145   
146   /// CurrentFnArguments - List of Arguments (DbgValues) for current function.
147   SmallVector<DbgVariable *, 8> CurrentFnArguments;
148
149   /// DbgScopeMap - Tracks the scopes in the current function.  Owns the
150   /// contained DbgScope*s.
151   ///
152   DenseMap<const MDNode *, DbgScope *> DbgScopeMap;
153
154   /// ConcreteScopes - Tracks the concrete scopees in the current function.
155   /// These scopes are also included in DbgScopeMap.
156   DenseMap<const MDNode *, DbgScope *> ConcreteScopes;
157
158   /// AbstractScopes - Tracks the abstract scopes a module. These scopes are
159   /// not included DbgScopeMap.  AbstractScopes owns its DbgScope*s.
160   DenseMap<const MDNode *, DbgScope *> AbstractScopes;
161
162   /// AbstractSPDies - Collection of abstract subprogram DIEs.
163   DenseMap<const MDNode *, DIE *> AbstractSPDies;
164
165   /// AbstractScopesList - Tracks abstract scopes constructed while processing
166   /// a function. This list is cleared during endFunction().
167   SmallVector<DbgScope *, 4>AbstractScopesList;
168
169   /// AbstractVariables - Collection on abstract variables.  Owned by the
170   /// DbgScopes in AbstractScopes.
171   DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
172
173   /// DbgVariableToFrameIndexMap - Tracks frame index used to find 
174   /// variable's value.
175   DenseMap<const DbgVariable *, int> DbgVariableToFrameIndexMap;
176
177   /// DbgVariableToDbgInstMap - Maps DbgVariable to corresponding DBG_VALUE
178   /// machine instruction.
179   DenseMap<const DbgVariable *, const MachineInstr *> DbgVariableToDbgInstMap;
180
181   /// DotDebugLocEntries - Collection of DotDebugLocEntry.
182   SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
183
184   /// UseDotDebugLocEntry - DW_AT_location attributes for the DIEs in this set
185   /// idetifies corresponding .debug_loc entry offset.
186   SmallPtrSet<const DIE *, 4> UseDotDebugLocEntry;
187
188   /// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
189   /// DbgVariable, if any.
190   DenseMap<const DbgVariable *, const DbgVariable *> VarToAbstractVarMap;
191
192   /// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked
193   /// (at the end of the module) as DW_AT_inline.
194   SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
195
196   /// ContainingTypeMap - This map is used to keep track of subprogram DIEs that
197   /// need DW_AT_containing_type attribute. This attribute points to a DIE that
198   /// corresponds to the MDNode mapped with the subprogram DIE.
199   DenseMap<DIE *, const MDNode *> ContainingTypeMap;
200
201   typedef SmallVector<DbgScope *, 2> ScopeVector;
202
203   /// InlineInfo - Keep track of inlined functions and their location.  This
204   /// information is used to populate debug_inlined section.
205   typedef std::pair<const MCSymbol *, DIE *> InlineInfoLabels;
206   DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
207   SmallVector<const MDNode *, 4> InlinedSPNodes;
208
209   // ProcessedSPNodes - This is a collection of subprogram MDNodes that
210   // are processed to create DIEs.
211   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
212
213   /// LabelsBeforeInsn - Maps instruction with label emitted before 
214   /// instruction.
215   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
216
217   /// LabelsAfterInsn - Maps instruction with label emitted after
218   /// instruction.
219   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
220
221   /// UserVariables - Every user variable mentioned by a DBG_VALUE instruction
222   /// in order of appearance.
223   SmallVector<const MDNode*, 8> UserVariables;
224
225   /// DbgValues - For each user variable, keep a list of DBG_VALUE
226   /// instructions in order. The list can also contain normal instructions that
227   /// clobber the previous DBG_VALUE.
228   typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
229     DbgValueHistoryMap;
230   DbgValueHistoryMap DbgValues;
231
232   SmallVector<const MCSymbol *, 8> DebugRangeSymbols;
233
234   /// Previous instruction's location information. This is used to determine
235   /// label location to indicate scope boundries in dwarf debug info.
236   DebugLoc PrevInstLoc;
237   MCSymbol *PrevLabel;
238
239   struct FunctionDebugFrameInfo {
240     unsigned Number;
241     std::vector<MachineMove> Moves;
242
243     FunctionDebugFrameInfo(unsigned Num, const std::vector<MachineMove> &M)
244       : Number(Num), Moves(M) {}
245   };
246
247   std::vector<FunctionDebugFrameInfo> DebugFrames;
248
249   // Section Symbols: these are assembler temporary labels that are emitted at
250   // the beginning of each supported dwarf section.  These are used to form
251   // section offsets and are created by EmitSectionLabels.
252   MCSymbol *DwarfFrameSectionSym, *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
253   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
254   MCSymbol *DwarfDebugLocSectionSym;
255   MCSymbol *FunctionBeginSym, *FunctionEndSym;
256
257   DIEInteger *DIEIntegerOne;
258 private:
259
260   /// getNumSourceIds - Return the number of unique source ids.
261   unsigned getNumSourceIds() const {
262     return SourceIdMap.size();
263   }
264
265   /// assignAbbrevNumber - Define a unique number for the abbreviation.
266   ///
267   void assignAbbrevNumber(DIEAbbrev &Abbrev);
268
269   /// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
270   /// information entry.
271   DIEEntry *createDIEEntry(DIE *Entry);
272
273   /// addUInt - Add an unsigned integer attribute data and value.
274   ///
275   void addUInt(DIE *Die, unsigned Attribute, unsigned Form, uint64_t Integer);
276
277   /// addSInt - Add an signed integer attribute data and value.
278   ///
279   void addSInt(DIE *Die, unsigned Attribute, unsigned Form, int64_t Integer);
280
281   /// addString - Add a string attribute data and value.
282   ///
283   void addString(DIE *Die, unsigned Attribute, unsigned Form,
284                  const StringRef Str);
285
286   /// addLabel - Add a Dwarf label attribute data and value.
287   ///
288   void addLabel(DIE *Die, unsigned Attribute, unsigned Form,
289                 const MCSymbol *Label);
290
291   /// addDelta - Add a label delta attribute data and value.
292   ///
293   void addDelta(DIE *Die, unsigned Attribute, unsigned Form,
294                 const MCSymbol *Hi, const MCSymbol *Lo);
295
296   /// addDIEEntry - Add a DIE attribute data and value.
297   ///
298   void addDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry);
299   
300   /// addBlock - Add block data.
301   ///
302   void addBlock(DIE *Die, unsigned Attribute, unsigned Form, DIEBlock *Block);
303
304   /// addSourceLine - Add location information to specified debug information
305   /// entry.
306   void addSourceLine(DIE *Die, DIVariable V);
307   void addSourceLine(DIE *Die, DIGlobalVariable G);
308   void addSourceLine(DIE *Die, DISubprogram SP);
309   void addSourceLine(DIE *Die, DIType Ty);
310   void addSourceLine(DIE *Die, DINameSpace NS);
311
312   /// addAddress - Add an address attribute to a die based on the location
313   /// provided.
314   void addAddress(DIE *Die, unsigned Attribute,
315                   const MachineLocation &Location);
316
317   /// addRegisterAddress - Add register location entry in variable DIE.
318   bool addRegisterAddress(DIE *Die, const MachineOperand &MO);
319
320   /// addConstantValue - Add constant value entry in variable DIE.
321   bool addConstantValue(DIE *Die, const MachineOperand &MO);
322   bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned);
323
324   /// addConstantFPValue - Add constant value entry in variable DIE.
325   bool addConstantFPValue(DIE *Die, const MachineOperand &MO);
326
327   /// addComplexAddress - Start with the address based on the location provided,
328   /// and generate the DWARF information necessary to find the actual variable
329   /// (navigating the extra location information encoded in the type) based on
330   /// the starting location.  Add the DWARF information to the die.
331   ///
332   void addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
333                          const MachineLocation &Location);
334
335   // FIXME: Should be reformulated in terms of addComplexAddress.
336   /// addBlockByrefAddress - Start with the address based on the location
337   /// provided, and generate the DWARF information necessary to find the
338   /// actual Block variable (navigating the Block struct) based on the
339   /// starting location.  Add the DWARF information to the die.  Obsolete,
340   /// please use addComplexAddress instead.
341   ///
342   void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
343                             const MachineLocation &Location);
344
345   /// addVariableAddress - Add DW_AT_location attribute for a DbgVariable based
346   /// on provided frame index.
347   void addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI);
348
349   /// addToContextOwner - Add Die into the list of its context owner's children.
350   void addToContextOwner(DIE *Die, DIDescriptor Context);
351
352   /// addType - Add a new type attribute to the specified entity.
353   void addType(DIE *Entity, DIType Ty);
354
355  
356   /// getOrCreateNameSpace - Create a DIE for DINameSpace.
357   DIE *getOrCreateNameSpace(DINameSpace NS);
358
359   /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
360   /// given DIType.
361   DIE *getOrCreateTypeDIE(DIType Ty);
362
363   /// getOrCreateTemplateTypeParameterDIE - Find existing DIE or create new DIE 
364   /// for the given DITemplateTypeParameter.
365   DIE *getOrCreateTemplateTypeParameterDIE(DITemplateTypeParameter TP);
366
367   /// getOrCreateTemplateValueParameterDIE - Find existing DIE or create new DIE 
368   /// for the given DITemplateValueParameter.
369   DIE *getOrCreateTemplateValueParameterDIE(DITemplateValueParameter TVP);
370
371   void addPubTypes(DISubprogram SP);
372
373   /// constructTypeDIE - Construct basic type die from DIBasicType.
374   void constructTypeDIE(DIE &Buffer,
375                         DIBasicType BTy);
376
377   /// constructTypeDIE - Construct derived type die from DIDerivedType.
378   void constructTypeDIE(DIE &Buffer,
379                         DIDerivedType DTy);
380
381   /// constructTypeDIE - Construct type DIE from DICompositeType.
382   void constructTypeDIE(DIE &Buffer,
383                         DICompositeType CTy);
384
385   /// constructSubrangeDIE - Construct subrange DIE from DISubrange.
386   void constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy);
387
388   /// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
389   void constructArrayTypeDIE(DIE &Buffer, 
390                              DICompositeType *CTy);
391
392   /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
393   DIE *constructEnumTypeDIE(DIEnumerator ETy);
394
395   /// createMemberDIE - Create new member DIE.
396   DIE *createMemberDIE(DIDerivedType DT);
397
398   /// createSubprogramDIE - Create new DIE using SP.
399   DIE *createSubprogramDIE(DISubprogram SP);
400
401   /// getOrCreateDbgScope - Create DbgScope for the scope.
402   DbgScope *getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt);
403
404   DbgScope *getOrCreateAbstractScope(const MDNode *N);
405
406   /// findAbstractVariable - Find abstract variable associated with Var.
407   DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
408
409   /// updateSubprogramScopeDIE - Find DIE for the given subprogram and 
410   /// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
411   /// If there are global variables in this scope then create and insert
412   /// DIEs for these variables.
413   DIE *updateSubprogramScopeDIE(const MDNode *SPNode);
414
415   /// constructLexicalScope - Construct new DW_TAG_lexical_block 
416   /// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
417   DIE *constructLexicalScopeDIE(DbgScope *Scope);
418
419   /// constructInlinedScopeDIE - This scope represents inlined body of
420   /// a function. Construct DIE to represent this concrete inlined copy
421   /// of the function.
422   DIE *constructInlinedScopeDIE(DbgScope *Scope);
423
424   /// constructVariableDIE - Construct a DIE for the given DbgVariable.
425   DIE *constructVariableDIE(DbgVariable *DV, DbgScope *S);
426
427   /// constructScopeDIE - Construct a DIE for this scope.
428   DIE *constructScopeDIE(DbgScope *Scope);
429
430   /// EmitSectionLabels - Emit initial Dwarf sections with a label at
431   /// the start of each one.
432   void EmitSectionLabels();
433
434   /// emitDIE - Recusively Emits a debug information entry.
435   ///
436   void emitDIE(DIE *Die);
437
438   /// computeSizeAndOffset - Compute the size and offset of a DIE.
439   ///
440   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset, bool Last);
441
442   /// computeSizeAndOffsets - Compute the size and offset of all the DIEs.
443   ///
444   void computeSizeAndOffsets();
445
446   /// EmitDebugInfo - Emit the debug info section.
447   ///
448   void emitDebugInfo();
449
450   /// emitAbbreviations - Emit the abbreviation section.
451   ///
452   void emitAbbreviations() const;
453
454   /// emitEndOfLineMatrix - Emit the last address of the section and the end of
455   /// the line matrix.
456   ///
457   void emitEndOfLineMatrix(unsigned SectionEnd);
458
459   /// emitCommonDebugFrame - Emit common frame info into a debug frame section.
460   ///
461   void emitCommonDebugFrame();
462
463   /// emitFunctionDebugFrame - Emit per function frame info into a debug frame
464   /// section.
465   void emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo);
466
467   /// emitDebugPubNames - Emit visible names into a debug pubnames section.
468   ///
469   void emitDebugPubNames();
470
471   /// emitDebugPubTypes - Emit visible types into a debug pubtypes section.
472   ///
473   void emitDebugPubTypes();
474
475   /// emitDebugStr - Emit visible names into a debug str section.
476   ///
477   void emitDebugStr();
478
479   /// emitDebugLoc - Emit visible names into a debug loc section.
480   ///
481   void emitDebugLoc();
482
483   /// EmitDebugARanges - Emit visible names into a debug aranges section.
484   ///
485   void EmitDebugARanges();
486
487   /// emitDebugRanges - Emit visible names into a debug ranges section.
488   ///
489   void emitDebugRanges();
490
491   /// emitDebugMacInfo - Emit visible names into a debug macinfo section.
492   ///
493   void emitDebugMacInfo();
494
495   /// emitDebugInlineInfo - Emit inline info using following format.
496   /// Section Header:
497   /// 1. length of section
498   /// 2. Dwarf version number
499   /// 3. address size.
500   ///
501   /// Entries (one "entry" for each function that was inlined):
502   ///
503   /// 1. offset into __debug_str section for MIPS linkage name, if exists; 
504   ///   otherwise offset into __debug_str for regular function name.
505   /// 2. offset into __debug_str section for regular function name.
506   /// 3. an unsigned LEB128 number indicating the number of distinct inlining 
507   /// instances for the function.
508   /// 
509   /// The rest of the entry consists of a {die_offset, low_pc}  pair for each 
510   /// inlined instance; the die_offset points to the inlined_subroutine die in
511   /// the __debug_info section, and the low_pc is the starting address  for the
512   ///  inlining instance.
513   void emitDebugInlineInfo();
514
515   /// GetOrCreateSourceID - Look up the source id with the given directory and
516   /// source file names. If none currently exists, create a new id and insert it
517   /// in the SourceIds map.
518   unsigned GetOrCreateSourceID(StringRef DirName, StringRef FullName);
519
520   /// constructCompileUnit - Create new CompileUnit for the given 
521   /// metadata node with tag DW_TAG_compile_unit.
522   void constructCompileUnit(const MDNode *N);
523
524   /// getCompielUnit - Get CompileUnit DIE.
525   CompileUnit *getCompileUnit(const MDNode *N) const;
526
527   /// constructGlobalVariableDIE - Construct global variable DIE.
528   void constructGlobalVariableDIE(const MDNode *N);
529
530   /// construct SubprogramDIE - Construct subprogram DIE.
531   void constructSubprogramDIE(const MDNode *N);
532
533   /// recordSourceLine - Register a source line with debug info. Returns the
534   /// unique label that was emitted and which provides correspondence to
535   /// the source line list.
536   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope);
537   
538   /// recordVariableFrameIndex - Record a variable's index.
539   void recordVariableFrameIndex(const DbgVariable *V, int Index);
540
541   /// findVariableFrameIndex - Return true if frame index for the variable
542   /// is found. Update FI to hold value of the index.
543   bool findVariableFrameIndex(const DbgVariable *V, int *FI);
544
545   /// findDbgScope - Find DbgScope for the debug loc attached with an 
546   /// instruction.
547   DbgScope *findDbgScope(const MachineInstr *MI);
548
549   /// identifyScopeMarkers() - Indentify instructions that are marking
550   /// beginning of or end of a scope.
551   void identifyScopeMarkers();
552
553   /// extractScopeInformation - Scan machine instructions in this function
554   /// and collect DbgScopes. Return true, if atleast one scope was found.
555   bool extractScopeInformation();
556   
557   /// addCurrentFnArgument - If Var is an current function argument that add
558   /// it in CurrentFnArguments list.
559   bool addCurrentFnArgument(const MachineFunction *MF,
560                             DbgVariable *Var, DbgScope *Scope);
561
562   /// collectVariableInfo - Populate DbgScope entries with variables' info.
563   void collectVariableInfo(const MachineFunction *,
564                            SmallPtrSet<const MDNode *, 16> &ProcessedVars);
565   
566   /// collectVariableInfoFromMMITable - Collect variable information from
567   /// side table maintained by MMI.
568   void collectVariableInfoFromMMITable(const MachineFunction * MF,
569                                        SmallPtrSet<const MDNode *, 16> &P);
570
571   /// requestLabelBeforeInsn - Ensure that a label will be emitted before MI.
572   void requestLabelBeforeInsn(const MachineInstr *MI) {
573     LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
574   }
575
576   /// getLabelBeforeInsn - Return Label preceding the instruction.
577   const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
578
579   /// requestLabelAfterInsn - Ensure that a label will be emitted after MI.
580   void requestLabelAfterInsn(const MachineInstr *MI) {
581     LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
582   }
583
584   /// getLabelAfterInsn - Return Label immediately following the instruction.
585   const MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
586
587 public:
588   //===--------------------------------------------------------------------===//
589   // Main entry points.
590   //
591   DwarfDebug(AsmPrinter *A, Module *M);
592   ~DwarfDebug();
593
594   /// beginModule - Emit all Dwarf sections that should come prior to the
595   /// content.
596   void beginModule(Module *M);
597
598   /// endModule - Emit all Dwarf sections that should come after the content.
599   ///
600   void endModule();
601
602   /// beginFunction - Gather pre-function debug information.  Assumes being
603   /// emitted immediately after the function entry point.
604   void beginFunction(const MachineFunction *MF);
605
606   /// endFunction - Gather and emit post-function debug information.
607   ///
608   void endFunction(const MachineFunction *MF);
609
610   /// beginInstruction - Process beginning of an instruction.
611   void beginInstruction(const MachineInstr *MI);
612
613   /// endInstruction - Prcess end of an instruction.
614   void endInstruction(const MachineInstr *MI);
615 };
616 } // End of namespace llvm
617
618 #endif