blob: 0b94645a8c7b335e69fa42f3147ca85da438f5fa [file] [log] [blame]
Bill Wendlingbbee8c92009-05-15 00:11:17 +00001//===--- lib/CodeGen/DwarfPrinter.h - Dwarf Printer -------------*- 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// Emit general DWARF directives.
11//
12//===----------------------------------------------------------------------===//
13
Bill Wendlingb12b3d72009-05-15 09:23:25 +000014#ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
15#define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
Bill Wendlingbbee8c92009-05-15 00:11:17 +000016
Bill Wendlingbbee8c92009-05-15 00:11:17 +000017#include "llvm/CodeGen/MachineLocation.h"
18#include "llvm/Support/Compiler.h"
Chris Lattnerad653482010-01-22 22:09:00 +000019#include "llvm/Support/FormattedStream.h"
Bill Wendlingbbee8c92009-05-15 00:11:17 +000020#include <vector>
21
22namespace llvm {
Chris Lattner57939f62010-01-22 22:19:51 +000023class AsmPrinter;
24class MachineFunction;
25class MachineModuleInfo;
26class Module;
27class MCAsmInfo;
28class TargetData;
29class TargetRegisterInfo;
Anton Korobeynikovd779bcb2010-02-15 22:35:59 +000030class GlobalValue;
Chris Lattner57939f62010-01-22 22:19:51 +000031class MCSymbol;
Chris Lattner05ae1d22010-01-22 23:47:11 +000032class Twine;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000033
Chris Lattnerb21f1042010-01-22 22:23:57 +000034class DwarfPrinter {
Chris Lattner57939f62010-01-22 22:19:51 +000035protected:
Duncan Sands3ef960d2010-02-07 21:09:22 +000036 ~DwarfPrinter() {}
37
Chris Lattner57939f62010-01-22 22:19:51 +000038 //===-------------------------------------------------------------==---===//
39 // Core attributes used by the DWARF printer.
40 //
Bill Wendlingbbee8c92009-05-15 00:11:17 +000041
Chris Lattner57939f62010-01-22 22:19:51 +000042 /// O - Stream to .s file.
43 raw_ostream &O;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000044
Chris Lattner57939f62010-01-22 22:19:51 +000045 /// Asm - Target of Dwarf emission.
46 AsmPrinter *Asm;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000047
Chris Lattner57939f62010-01-22 22:19:51 +000048 /// MAI - Target asm information.
49 const MCAsmInfo *MAI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000050
Chris Lattner57939f62010-01-22 22:19:51 +000051 /// TD - Target data.
52 const TargetData *TD;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000053
Chris Lattner57939f62010-01-22 22:19:51 +000054 /// RI - Register Information.
55 const TargetRegisterInfo *RI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000056
Chris Lattner57939f62010-01-22 22:19:51 +000057 /// M - Current module.
58 Module *M;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000059
Chris Lattner57939f62010-01-22 22:19:51 +000060 /// MF - Current machine function.
Chris Lattner69a76972010-01-26 23:18:02 +000061 const MachineFunction *MF;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000062
Chris Lattner57939f62010-01-22 22:19:51 +000063 /// MMI - Collected machine module information.
64 MachineModuleInfo *MMI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000065
Chris Lattner57939f62010-01-22 22:19:51 +000066 /// SubprogramCount - The running count of functions being compiled.
67 unsigned SubprogramCount;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000068
Chris Lattner819669a2010-03-09 00:00:15 +000069 DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T);
Chris Lattner57939f62010-01-22 22:19:51 +000070public:
Chris Lattnerd705acf2010-01-22 22:38:16 +000071
Chris Lattner57939f62010-01-22 22:19:51 +000072 //===------------------------------------------------------------------===//
73 // Accessors.
74 //
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; }
Bill Wendlingbbee8c92009-05-15 00:11:17 +000079
Chris Lattnerbe4c2fc2010-03-08 22:23:36 +000080 /// 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;
83
84 /// getTempLabel - Return an assembler temporary label with the specified
85 /// name.
86 MCSymbol *getTempLabel(const char *Name) const;
87
Anton Korobeynikovd779bcb2010-02-15 22:35:59 +000088 /// SizeOfEncodedValue - Return the size of the encoding in bytes.
89 unsigned SizeOfEncodedValue(unsigned Encoding) const;
90
Chris Lattnerd705acf2010-01-22 22:38:16 +000091 /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
92 /// encoding. If verbose assembly output is enabled, we output comments
Chris Lattner20f334f2010-01-22 22:56:55 +000093 /// describing the encoding. Desc is a string saying what the encoding is
94 /// specifying (e.g. "LSDA").
95 void EmitEncodingByte(unsigned Val, const char *Desc);
Chris Lattnerd705acf2010-01-22 22:38:16 +000096
Chris Lattnerab4cf952010-01-22 23:40:08 +000097 /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
98 void EmitCFAByte(unsigned Val);
99
100
Chris Lattnerbcc79432010-01-22 23:18:42 +0000101 /// EmitSLEB128 - emit the specified signed leb128 value.
Chris Lattner20f334f2010-01-22 22:56:55 +0000102 void EmitSLEB128(int Value, const char *Desc) const;
Chris Lattnerbcc79432010-01-22 23:18:42 +0000103
104 /// EmitULEB128 - emit the specified unsigned leb128 value.
Bill Wendlinga7888ea2010-02-24 23:34:35 +0000105 void EmitULEB128(unsigned Value, const char *Desc = 0,
106 unsigned PadTo = 0) const;
Chris Lattnerbcc79432010-01-22 23:18:42 +0000107
Chris Lattner20f334f2010-01-22 22:56:55 +0000108
Chris Lattner57939f62010-01-22 22:19:51 +0000109 /// EmitReference - Emit a reference to a label.
110 ///
Anton Korobeynikovd779bcb2010-02-15 22:35:59 +0000111 void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
112 void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
113
Chris Lattner1fd01822010-01-26 20:20:43 +0000114 /// EmitDifference - Emit the difference between two labels.
Chris Lattnerbe4c2fc2010-03-08 22:23:36 +0000115 void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
116 bool IsSmall = false);
Chris Lattnerf8bfa882010-03-08 23:23:25 +0000117
Chris Lattner84c27b22010-03-09 00:17:58 +0000118 /// EmitSectionOffset - Emit Label-Section or use a special purpose directive
119 /// to emit a section offset if the target has one.
Chris Lattnerbe4c2fc2010-03-08 22:23:36 +0000120 void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
Chris Lattnerf8bfa882010-03-08 23:23:25 +0000121 bool IsSmall = false, bool isEH = false);
Chris Lattnerbe4c2fc2010-03-08 22:23:36 +0000122
Chris Lattner57939f62010-01-22 22:19:51 +0000123 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
124 /// frame.
Chris Lattnerdd4f4f82010-03-13 08:05:25 +0000125 void EmitFrameMoves(MCSymbol *BaseLabel,
Chris Lattner57939f62010-01-22 22:19:51 +0000126 const std::vector<MachineMove> &Moves, bool isEH);
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000127};
128
129} // end llvm namespace
130
131#endif