1 //===--- lib/CodeGen/DwarfPrinter.h - Dwarf Printer -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Emit general DWARF directives.
12 //===----------------------------------------------------------------------===//
14 #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
15 #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
17 #include "llvm/CodeGen/MachineLocation.h"
18 #include "llvm/Support/Compiler.h"
19 #include "llvm/Support/FormattedStream.h"
24 class MachineFunction;
25 class MachineModuleInfo;
29 class TargetRegisterInfo;
38 //===-------------------------------------------------------------==---===//
39 // Core attributes used by the DWARF printer.
42 /// O - Stream to .s file.
45 /// Asm - Target of Dwarf emission.
48 /// MAI - Target asm information.
54 /// RI - Register Information.
55 const TargetRegisterInfo *RI;
57 /// M - Current module.
60 /// MF - Current machine function.
61 const MachineFunction *MF;
63 /// MMI - Collected machine module information.
64 MachineModuleInfo *MMI;
66 /// SubprogramCount - The running count of functions being compiled.
67 unsigned SubprogramCount;
69 DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T);
72 //===------------------------------------------------------------------===//
75 const AsmPrinter *getAsm() const { return Asm; }
76 MachineModuleInfo *getMMI() const { return MMI; }
77 const MCAsmInfo *getMCAsmInfo() const { return MAI; }
78 const TargetData *getTargetData() const { return TD; }
80 /// getDWLabel - Return the MCSymbol corresponding to the assembler temporary
81 /// label with the specified stem and unique ID.
82 MCSymbol *getDWLabel(const char *Name, unsigned ID) const;
84 /// getTempLabel - Return an assembler temporary label with the specified
86 MCSymbol *getTempLabel(const char *Name) const;
88 /// SizeOfEncodedValue - Return the size of the encoding in bytes.
89 unsigned SizeOfEncodedValue(unsigned Encoding) const;
91 void PrintRelDirective(unsigned Encoding) const;
92 void PrintRelDirective(bool Force32Bit = false) const;
94 /// EOL - Print a newline character to asm stream. If a comment is present
95 /// then it will be printed first. Comments should not contain '\n'.
96 void EOL(const Twine &Comment) const;
98 /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
99 /// encoding. If verbose assembly output is enabled, we output comments
100 /// describing the encoding. Desc is a string saying what the encoding is
101 /// specifying (e.g. "LSDA").
102 void EmitEncodingByte(unsigned Val, const char *Desc);
104 /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
105 void EmitCFAByte(unsigned Val);
108 /// EmitSLEB128 - emit the specified signed leb128 value.
109 void EmitSLEB128(int Value, const char *Desc) const;
111 /// EmitULEB128 - emit the specified unsigned leb128 value.
112 void EmitULEB128(unsigned Value, const char *Desc = 0,
113 unsigned PadTo = 0) const;
116 /// EmitReference - Emit a reference to a label.
118 void EmitReference(const MCSymbol *Label, bool IsPCRelative = false,
119 bool Force32Bit = false) const;
121 void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
122 void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
124 /// EmitDifference - Emit the difference between two labels.
125 void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
126 bool IsSmall = false);
128 /// EmitSectionOffset - Emit Label-Section or use a special purpose directive
129 /// to emit a section offset if the target has one.
130 void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
131 bool IsSmall = false, bool isEH = false);
133 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
135 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
136 const std::vector<MachineMove> &Moves, bool isEH);
139 } // end llvm namespace