LLVM API Documentation
00001 //===-- PIC16DebugInfo.h - Interfaces for PIC16 Debug Information ============// 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 // This file contains the helper functions for representing debug information. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef PIC16DBG_H 00015 #define PIC16DBG_H 00016 00017 #include "llvm/Analysis/DebugInfo.h" 00018 #include "llvm/Module.h" 00019 #include "llvm/Target/TargetAsmInfo.h" 00020 #include <map> 00021 00022 namespace llvm { 00023 class MachineFunction; 00024 class DebugLoc; 00025 namespace PIC16Dbg { 00026 enum VarType { 00027 T_NULL, 00028 T_VOID, 00029 T_CHAR, 00030 T_SHORT, 00031 T_INT, 00032 T_LONG, 00033 T_FLOAT, 00034 T_DOUBLE, 00035 T_STRUCT, 00036 T_UNION, 00037 T_ENUM, 00038 T_MOE, 00039 T_UCHAR, 00040 T_USHORT, 00041 T_UINT, 00042 T_ULONG 00043 }; 00044 enum DerivedType { 00045 DT_NONE, 00046 DT_PTR, 00047 DT_FCN, 00048 DT_ARY 00049 }; 00050 enum TypeSize { 00051 S_BASIC = 5, 00052 S_DERIVED = 3 00053 }; 00054 enum DbgClass { 00055 C_NULL, 00056 C_AUTO, 00057 C_EXT, 00058 C_STAT, 00059 C_REG, 00060 C_EXTDEF, 00061 C_LABEL, 00062 C_ULABEL, 00063 C_MOS, 00064 C_ARG, 00065 C_STRTAG, 00066 C_MOU, 00067 C_UNTAG, 00068 C_TPDEF, 00069 C_USTATIC, 00070 C_ENTAG, 00071 C_MOE, 00072 C_REGPARM, 00073 C_FIELD, 00074 C_AUTOARG, 00075 C_LASTENT, 00076 C_BLOCK = 100, 00077 C_FCN, 00078 C_EOS, 00079 C_FILE, 00080 C_LINE, 00081 C_ALIAS, 00082 C_HIDDEN, 00083 C_EOF, 00084 C_LIST, 00085 C_SECTION, 00086 C_EFCN = 255 00087 }; 00088 enum SymbolSize { 00089 AuxSize =20 00090 }; 00091 } 00092 00093 class formatted_raw_ostream; 00094 00095 class PIC16DbgInfo { 00096 formatted_raw_ostream &O; 00097 const TargetAsmInfo *TAI; 00098 std::string CurFile; 00099 unsigned CurLine; 00100 00101 // EmitDebugDirectives is set if debug information is available. Default 00102 // value for it is false. 00103 bool EmitDebugDirectives; 00104 00105 public: 00106 PIC16DbgInfo(formatted_raw_ostream &o, const TargetAsmInfo *T) 00107 : O(o), TAI(T) { 00108 CurFile = ""; 00109 CurLine = 0; 00110 EmitDebugDirectives = false; 00111 } 00112 00113 void BeginModule (Module &M); 00114 void BeginFunction (const MachineFunction &MF); 00115 void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL, 00116 bool IsInBeginFunction = false); 00117 void EndFunction (const MachineFunction &MF); 00118 void EndModule (Module &M); 00119 00120 00121 private: 00122 void SwitchToCU (GlobalVariable *CU); 00123 void SwitchToLine (unsigned Line, bool IsInBeginFunction = false); 00124 00125 void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux, 00126 int Aux[], std::string &TypeName); 00127 void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo); 00128 void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo, 00129 bool &HasAux, int Aux[], 00130 std::string &TypeName); 00131 00132 void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo, 00133 bool &HasAux, int Aux[], 00134 std::string &TypeName); 00135 void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo, 00136 bool &HasAux, int Aux[], 00137 std::string &TypeName); 00138 00139 void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo, 00140 bool &HasAux, int Aux[], 00141 std::string &TypeName); 00142 void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo); 00143 00144 unsigned GetTypeDebugNumber(std::string &Type); 00145 short getStorageClass(DIGlobalVariable DIGV); 00146 void EmitFunctBeginDI(const Function *F); 00147 void EmitCompositeTypeDecls(Module &M); 00148 void EmitCompositeTypeElements (DICompositeType CTy, std::string Suffix); 00149 void EmitFunctEndDI(const Function *F, unsigned Line); 00150 void EmitAuxEntry(const std::string VarName, int Aux[], 00151 int num = PIC16Dbg::AuxSize, std::string TagName = ""); 00152 inline void EmitSymbol(std::string Name, short Class, 00153 unsigned short Type = PIC16Dbg::T_NULL, 00154 unsigned long Value = 0); 00155 void EmitVarDebugInfo(Module &M); 00156 void EmitEOF(); 00157 }; 00158 } // end namespace llvm; 00159 #endif