Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 1 | //===-- PIC16DebugInfo.h - Interfaces for PIC16 Debug Information ============// |
| 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 the helper functions for representing debug information. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PIC16DBG_H |
| 15 | #define PIC16DBG_H |
| 16 | |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 17 | #include "llvm/Analysis/DebugInfo.h" |
| 18 | #include "llvm/Module.h" |
| 19 | #include "llvm/Target/TargetAsmInfo.h" |
| 20 | #include <map> |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 23 | class MachineFunction; |
| 24 | class DebugLoc; |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 25 | namespace PIC16Dbg { |
| 26 | enum VarType { |
| 27 | T_NULL, |
| 28 | T_VOID, |
| 29 | T_CHAR, |
| 30 | T_SHORT, |
| 31 | T_INT, |
| 32 | T_LONG, |
| 33 | T_FLOAT, |
| 34 | T_DOUBLE, |
| 35 | T_STRUCT, |
| 36 | T_UNION, |
| 37 | T_ENUM, |
| 38 | T_MOE, |
| 39 | T_UCHAR, |
| 40 | T_USHORT, |
| 41 | T_UINT, |
| 42 | T_ULONG |
| 43 | }; |
| 44 | enum DerivedType { |
| 45 | DT_NONE, |
| 46 | DT_PTR, |
| 47 | DT_FCN, |
| 48 | DT_ARY |
| 49 | }; |
| 50 | enum TypeSize { |
| 51 | S_BASIC = 5, |
| 52 | S_DERIVED = 3 |
| 53 | }; |
| 54 | enum DbgClass { |
| 55 | C_NULL, |
| 56 | C_AUTO, |
| 57 | C_EXT, |
| 58 | C_STAT, |
| 59 | C_REG, |
| 60 | C_EXTDEF, |
| 61 | C_LABEL, |
| 62 | C_ULABEL, |
| 63 | C_MOS, |
| 64 | C_ARG, |
| 65 | C_STRTAG, |
| 66 | C_MOU, |
| 67 | C_UNTAG, |
| 68 | C_TPDEF, |
| 69 | C_USTATIC, |
| 70 | C_ENTAG, |
| 71 | C_MOE, |
| 72 | C_REGPARM, |
| 73 | C_FIELD, |
| 74 | C_AUTOARG, |
| 75 | C_LASTENT, |
| 76 | C_BLOCK = 100, |
| 77 | C_FCN, |
| 78 | C_EOS, |
| 79 | C_FILE, |
| 80 | C_LINE, |
| 81 | C_ALIAS, |
| 82 | C_HIDDEN, |
| 83 | C_EOF, |
| 84 | C_LIST, |
| 85 | C_SECTION, |
| 86 | C_EFCN = 255 |
| 87 | }; |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 88 | enum SymbolSize { |
| 89 | AuxSize =20 |
| 90 | }; |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 91 | } |
| 92 | |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 93 | class formatted_raw_ostream; |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 94 | |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 95 | class PIC16DbgInfo { |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 96 | formatted_raw_ostream &O; |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 97 | const TargetAsmInfo *TAI; |
Sanjiv Gupta | 3fc7e53 | 2009-06-03 16:27:49 +0000 | [diff] [blame] | 98 | std::string CurFile; |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 99 | unsigned CurLine; |
| 100 | |
Sanjiv Gupta | dcb6da3 | 2009-06-13 17:35:54 +0000 | [diff] [blame] | 101 | // EmitDebugDirectives is set if debug information is available. Default |
| 102 | // value for it is false. |
| 103 | bool EmitDebugDirectives; |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 104 | |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 105 | public: |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 106 | PIC16DbgInfo(formatted_raw_ostream &o, const TargetAsmInfo *T) |
| 107 | : O(o), TAI(T) { |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 108 | CurFile = ""; |
| 109 | CurLine = 0; |
Sanjiv Gupta | dcb6da3 | 2009-06-13 17:35:54 +0000 | [diff] [blame] | 110 | EmitDebugDirectives = false; |
Sanjiv Gupta | 3fc7e53 | 2009-06-03 16:27:49 +0000 | [diff] [blame] | 111 | } |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 112 | |
| 113 | void BeginModule (Module &M); |
| 114 | void BeginFunction (const MachineFunction &MF); |
| 115 | void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL, |
| 116 | bool IsInBeginFunction = false); |
| 117 | void EndFunction (const MachineFunction &MF); |
| 118 | void EndModule (Module &M); |
| 119 | |
| 120 | |
| 121 | private: |
| 122 | void SwitchToCU (GlobalVariable *CU); |
| 123 | void SwitchToLine (unsigned Line, bool IsInBeginFunction = false); |
| 124 | |
| 125 | void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux, |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 126 | int Aux[], std::string &TypeName); |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 127 | void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo); |
| 128 | void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo, |
| 129 | bool &HasAux, int Aux[], |
| 130 | std::string &TypeName); |
| 131 | |
| 132 | void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo, |
| 133 | bool &HasAux, int Aux[], |
| 134 | std::string &TypeName); |
| 135 | void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo, |
| 136 | bool &HasAux, int Aux[], |
| 137 | std::string &TypeName); |
| 138 | |
| 139 | void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo, |
| 140 | bool &HasAux, int Aux[], |
| 141 | std::string &TypeName); |
| 142 | void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo); |
| 143 | |
| 144 | unsigned GetTypeDebugNumber(std::string &Type); |
| 145 | short getStorageClass(DIGlobalVariable DIGV); |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 146 | void EmitFunctBeginDI(const Function *F); |
Sanjiv Gupta | dcb6da3 | 2009-06-13 17:35:54 +0000 | [diff] [blame] | 147 | void EmitCompositeTypeDecls(Module &M); |
Sanjiv Gupta | bfa79b8 | 2009-08-15 14:36:48 +0000 | [diff] [blame^] | 148 | void EmitCompositeTypeElements (DICompositeType CTy, std::string Suffix); |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 149 | void EmitFunctEndDI(const Function *F, unsigned Line); |
Sanjiv Gupta | dcb6da3 | 2009-06-13 17:35:54 +0000 | [diff] [blame] | 150 | void EmitAuxEntry(const std::string VarName, int Aux[], |
Sanjiv Gupta | bde7942 | 2009-06-16 09:45:18 +0000 | [diff] [blame] | 151 | int num = PIC16Dbg::AuxSize, std::string TagName = ""); |
Sanjiv Gupta | dcb6da3 | 2009-06-13 17:35:54 +0000 | [diff] [blame] | 152 | inline void EmitSymbol(std::string Name, short Class, |
| 153 | unsigned short Type = PIC16Dbg::T_NULL, |
| 154 | unsigned long Value = 0); |
Sanjiv Gupta | dd4694b | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 155 | void EmitVarDebugInfo(Module &M); |
Sanjiv Gupta | 3fc7e53 | 2009-06-03 16:27:49 +0000 | [diff] [blame] | 156 | void EmitEOF(); |
Sanjiv Gupta | a57bc3b | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 157 | }; |
| 158 | } // end namespace llvm; |
| 159 | #endif |