blob: 2ccaba32372c3e80f8d3252c81682c21c27ee5b7 [file] [log] [blame]
Sanjiv Guptaa57bc3b2009-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 Guptadd4694b2009-05-28 18:24:11 +000017#include "llvm/Analysis/DebugInfo.h"
18#include "llvm/Module.h"
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +000019
20namespace llvm {
Sanjiv Guptabde79422009-06-16 09:45:18 +000021 class MachineFunction;
22 class DebugLoc;
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +000023 namespace PIC16Dbg {
24 enum VarType {
25 T_NULL,
26 T_VOID,
27 T_CHAR,
28 T_SHORT,
29 T_INT,
30 T_LONG,
31 T_FLOAT,
32 T_DOUBLE,
33 T_STRUCT,
34 T_UNION,
35 T_ENUM,
36 T_MOE,
37 T_UCHAR,
38 T_USHORT,
39 T_UINT,
40 T_ULONG
41 };
42 enum DerivedType {
43 DT_NONE,
44 DT_PTR,
45 DT_FCN,
46 DT_ARY
47 };
48 enum TypeSize {
49 S_BASIC = 5,
50 S_DERIVED = 3
51 };
52 enum DbgClass {
53 C_NULL,
54 C_AUTO,
55 C_EXT,
56 C_STAT,
57 C_REG,
58 C_EXTDEF,
59 C_LABEL,
60 C_ULABEL,
61 C_MOS,
62 C_ARG,
63 C_STRTAG,
64 C_MOU,
65 C_UNTAG,
66 C_TPDEF,
67 C_USTATIC,
68 C_ENTAG,
69 C_MOE,
70 C_REGPARM,
71 C_FIELD,
72 C_AUTOARG,
73 C_LASTENT,
74 C_BLOCK = 100,
75 C_FCN,
76 C_EOS,
77 C_FILE,
78 C_LINE,
79 C_ALIAS,
80 C_HIDDEN,
81 C_EOF,
82 C_LIST,
83 C_SECTION,
84 C_EFCN = 255
85 };
Sanjiv Guptadd4694b2009-05-28 18:24:11 +000086 enum SymbolSize {
87 AuxSize =20
88 };
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +000089 }
90
David Greene71847812009-07-14 20:18:05 +000091 class formatted_raw_ostream;
Sanjiv Guptadd4694b2009-05-28 18:24:11 +000092
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +000093 class PIC16DbgInfo {
David Greene71847812009-07-14 20:18:05 +000094 formatted_raw_ostream &O;
Chris Lattner33adcfb2009-08-22 21:43:10 +000095 const MCAsmInfo *MAI;
Sanjiv Gupta3fc7e532009-06-03 16:27:49 +000096 std::string CurFile;
Sanjiv Guptabde79422009-06-16 09:45:18 +000097 unsigned CurLine;
98
Sanjiv Guptadcb6da32009-06-13 17:35:54 +000099 // EmitDebugDirectives is set if debug information is available. Default
100 // value for it is false.
101 bool EmitDebugDirectives;
Sanjiv Guptabde79422009-06-16 09:45:18 +0000102
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +0000103 public:
Chris Lattnere4d110b2009-08-22 20:56:12 +0000104 PIC16DbgInfo(formatted_raw_ostream &o, const MCAsmInfo *T)
Chris Lattner33adcfb2009-08-22 21:43:10 +0000105 : O(o), MAI(T) {
Sanjiv Guptabde79422009-06-16 09:45:18 +0000106 CurFile = "";
107 CurLine = 0;
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000108 EmitDebugDirectives = false;
Sanjiv Gupta3fc7e532009-06-03 16:27:49 +0000109 }
Sanjiv Guptabde79422009-06-16 09:45:18 +0000110
111 void BeginModule (Module &M);
112 void BeginFunction (const MachineFunction &MF);
113 void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL,
114 bool IsInBeginFunction = false);
115 void EndFunction (const MachineFunction &MF);
116 void EndModule (Module &M);
117
118
119 private:
120 void SwitchToCU (GlobalVariable *CU);
121 void SwitchToLine (unsigned Line, bool IsInBeginFunction = false);
122
123 void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux,
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +0000124 int Aux[], std::string &TypeName);
Sanjiv Guptabde79422009-06-16 09:45:18 +0000125 void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo);
126 void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo,
127 bool &HasAux, int Aux[],
128 std::string &TypeName);
129
130 void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo,
131 bool &HasAux, int Aux[],
132 std::string &TypeName);
133 void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo,
134 bool &HasAux, int Aux[],
135 std::string &TypeName);
136
137 void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo,
138 bool &HasAux, int Aux[],
139 std::string &TypeName);
140 void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo);
141
142 unsigned GetTypeDebugNumber(std::string &Type);
143 short getStorageClass(DIGlobalVariable DIGV);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000144 void EmitFunctBeginDI(const Function *F);
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000145 void EmitCompositeTypeDecls(Module &M);
Sanjiv Guptabfa79b82009-08-15 14:36:48 +0000146 void EmitCompositeTypeElements (DICompositeType CTy, std::string Suffix);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000147 void EmitFunctEndDI(const Function *F, unsigned Line);
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000148 void EmitAuxEntry(const std::string VarName, int Aux[],
Sanjiv Guptabde79422009-06-16 09:45:18 +0000149 int num = PIC16Dbg::AuxSize, std::string TagName = "");
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000150 inline void EmitSymbol(std::string Name, short Class,
151 unsigned short Type = PIC16Dbg::T_NULL,
152 unsigned long Value = 0);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000153 void EmitVarDebugInfo(Module &M);
Sanjiv Gupta3fc7e532009-06-03 16:27:49 +0000154 void EmitEOF();
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +0000155 };
156} // end namespace llvm;
157#endif