blob: d126d851b50e0c8387eea7c1edbf94436b8db87d [file] [log] [blame]
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +00001//===-- 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 Gupta14eba042009-05-28 18:24:11 +000017#include "llvm/Analysis/DebugInfo.h"
18#include "llvm/Module.h"
19#include "llvm/Target/TargetAsmInfo.h"
20#include <map>
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000021
22namespace llvm {
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +000023 class MachineFunction;
24 class DebugLoc;
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000025 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 Gupta14eba042009-05-28 18:24:11 +000088 enum SymbolSize {
89 AuxSize =20
90 };
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000091 }
92
Sanjiv Gupta14eba042009-05-28 18:24:11 +000093 class raw_ostream;
94
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000095 class PIC16DbgInfo {
Sanjiv Gupta14eba042009-05-28 18:24:11 +000096 raw_ostream &O;
97 const TargetAsmInfo *TAI;
Sanjiv Guptaa3dda892009-06-03 16:27:49 +000098 std::string CurFile;
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +000099 unsigned CurLine;
100
Sanjiv Gupta170289f2009-06-13 17:35:54 +0000101 // EmitDebugDirectives is set if debug information is available. Default
102 // value for it is false.
103 bool EmitDebugDirectives;
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000104
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +0000105 public:
Sanjiv Guptaa3dda892009-06-03 16:27:49 +0000106 PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) {
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000107 CurFile = "";
108 CurLine = 0;
Sanjiv Gupta170289f2009-06-13 17:35:54 +0000109 EmitDebugDirectives = false;
Sanjiv Guptaa3dda892009-06-03 16:27:49 +0000110 }
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000111
112 void BeginModule (Module &M);
113 void BeginFunction (const MachineFunction &MF);
114 void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL,
115 bool IsInBeginFunction = false);
116 void EndFunction (const MachineFunction &MF);
117 void EndModule (Module &M);
118
119
120 private:
121 void SwitchToCU (GlobalVariable *CU);
122 void SwitchToLine (unsigned Line, bool IsInBeginFunction = false);
123
124 void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux,
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +0000125 int Aux[], std::string &TypeName);
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000126 void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo);
127 void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo,
128 bool &HasAux, int Aux[],
129 std::string &TypeName);
130
131 void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo,
132 bool &HasAux, int Aux[],
133 std::string &TypeName);
134 void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo,
135 bool &HasAux, int Aux[],
136 std::string &TypeName);
137
138 void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo,
139 bool &HasAux, int Aux[],
140 std::string &TypeName);
141 void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo);
142
143 unsigned GetTypeDebugNumber(std::string &Type);
144 short getStorageClass(DIGlobalVariable DIGV);
Sanjiv Gupta14eba042009-05-28 18:24:11 +0000145 void EmitFunctBeginDI(const Function *F);
Sanjiv Gupta170289f2009-06-13 17:35:54 +0000146 void EmitCompositeTypeDecls(Module &M);
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000147 void EmitCompositeTypeElements (DICompositeType CTy,
148 std::string UniqueSuffix);
Sanjiv Gupta14eba042009-05-28 18:24:11 +0000149 void EmitFunctEndDI(const Function *F, unsigned Line);
Sanjiv Gupta170289f2009-06-13 17:35:54 +0000150 void EmitAuxEntry(const std::string VarName, int Aux[],
Sanjiv Gupta02d1ffd2009-06-16 09:45:18 +0000151 int num = PIC16Dbg::AuxSize, std::string TagName = "");
Sanjiv Gupta170289f2009-06-13 17:35:54 +0000152 inline void EmitSymbol(std::string Name, short Class,
153 unsigned short Type = PIC16Dbg::T_NULL,
154 unsigned long Value = 0);
Sanjiv Gupta14eba042009-05-28 18:24:11 +0000155 void EmitVarDebugInfo(Module &M);
Sanjiv Guptaa3dda892009-06-03 16:27:49 +0000156 void EmitEOF();
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +0000157 };
158} // end namespace llvm;
159#endif