LLVM API Documentation
00001 //===--- lib/CodeGen/DwarfPrinter.h - Dwarf Printer -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // Emit general DWARF directives. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__ 00015 #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__ 00016 00017 #include "DwarfLabel.h" 00018 #include "llvm/CodeGen/MachineLocation.h" 00019 #include "llvm/Support/Compiler.h" 00020 #include "llvm/Support/raw_ostream.h" 00021 #include <vector> 00022 00023 namespace llvm { 00024 class AsmPrinter; 00025 class MachineFunction; 00026 class MachineModuleInfo; 00027 class Module; 00028 class TargetAsmInfo; 00029 class TargetData; 00030 class TargetRegisterInfo; 00031 00032 class VISIBILITY_HIDDEN Dwarf { 00033 protected: 00034 //===-------------------------------------------------------------==---===// 00035 // Core attributes used by the DWARF printer. 00036 // 00037 00038 /// O - Stream to .s file. 00039 /// 00040 raw_ostream &O; 00041 00042 /// Asm - Target of Dwarf emission. 00043 /// 00044 AsmPrinter *Asm; 00045 00046 /// TAI - Target asm information. 00047 /// 00048 const TargetAsmInfo *TAI; 00049 00050 /// TD - Target data. 00051 /// 00052 const TargetData *TD; 00053 00054 /// RI - Register Information. 00055 /// 00056 const TargetRegisterInfo *RI; 00057 00058 /// M - Current module. 00059 /// 00060 Module *M; 00061 00062 /// MF - Current machine function. 00063 /// 00064 MachineFunction *MF; 00065 00066 /// MMI - Collected machine module information. 00067 /// 00068 MachineModuleInfo *MMI; 00069 00070 /// SubprogramCount - The running count of functions being compiled. 00071 /// 00072 unsigned SubprogramCount; 00073 00074 /// Flavor - A unique string indicating what dwarf producer this is, used to 00075 /// unique labels. 00076 /// 00077 const char * const Flavor; 00078 00079 /// SetCounter - A unique number for each '.set' directive. 00080 /// 00081 unsigned SetCounter; 00082 00083 Dwarf(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T, 00084 const char *flavor); 00085 public: 00086 //===------------------------------------------------------------------===// 00087 // Accessors. 00088 // 00089 const AsmPrinter *getAsm() const { return Asm; } 00090 MachineModuleInfo *getMMI() const { return MMI; } 00091 const TargetAsmInfo *getTargetAsmInfo() const { return TAI; } 00092 const TargetData *getTargetData() const { return TD; } 00093 00094 void PrintRelDirective(bool Force32Bit = false, 00095 bool isInSection = false) const; 00096 00097 00098 /// PrintLabelName - Print label name in form used by Dwarf writer. 00099 /// 00100 void PrintLabelName(const DWLabel &Label) const { 00101 PrintLabelName(Label.getTag(), Label.getNumber()); 00102 } 00103 void PrintLabelName(const char *Tag, unsigned Number) const; 00104 void PrintLabelName(const char *Tag, unsigned Number, 00105 const char *Suffix) const; 00106 00107 /// EmitLabel - Emit location label for internal use by Dwarf. 00108 /// 00109 void EmitLabel(const DWLabel &Label) const { 00110 EmitLabel(Label.getTag(), Label.getNumber()); 00111 } 00112 void EmitLabel(const char *Tag, unsigned Number) const; 00113 00114 /// EmitReference - Emit a reference to a label. 00115 /// 00116 void EmitReference(const DWLabel &Label, bool IsPCRelative = false, 00117 bool Force32Bit = false) const { 00118 EmitReference(Label.getTag(), Label.getNumber(), 00119 IsPCRelative, Force32Bit); 00120 } 00121 void EmitReference(const char *Tag, unsigned Number, 00122 bool IsPCRelative = false, 00123 bool Force32Bit = false) const; 00124 void EmitReference(const std::string &Name, bool IsPCRelative = false, 00125 bool Force32Bit = false) const; 00126 00127 /// EmitDifference - Emit the difference between two labels. Some 00128 /// assemblers do not behave with absolute expressions with data directives, 00129 /// so there is an option (needsSet) to use an intermediary set expression. 00130 void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo, 00131 bool IsSmall = false) { 00132 EmitDifference(LabelHi.getTag(), LabelHi.getNumber(), 00133 LabelLo.getTag(), LabelLo.getNumber(), 00134 IsSmall); 00135 } 00136 void EmitDifference(const char *TagHi, unsigned NumberHi, 00137 const char *TagLo, unsigned NumberLo, 00138 bool IsSmall = false); 00139 00140 void EmitSectionOffset(const char* Label, const char* Section, 00141 unsigned LabelNumber, unsigned SectionNumber, 00142 bool IsSmall = false, bool isEH = false, 00143 bool useSet = true); 00144 00145 /// EmitFrameMoves - Emit frame instructions to describe the layout of the 00146 /// frame. 00147 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID, 00148 const std::vector<MachineMove> &Moves, bool isEH); 00149 }; 00150 00151 } // end llvm namespace 00152 00153 #endif