blob: 031dcf092f047ed6e7726af233c9e2c84f85e3ee [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;
Chris Lattner84e679b2010-04-02 20:21:22 +000022 class DebugLoc;
Chris Lattnerb23569a2010-04-04 08:18:47 +000023 class MCStreamer;
24
Sanjiv Guptaa57bc3b2009-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 Guptadd4694b2009-05-28 18:24:11 +000088 enum SymbolSize {
89 AuxSize =20
90 };
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +000091 }
92
93 class PIC16DbgInfo {
Chris Lattnerb23569a2010-04-04 08:18:47 +000094 MCStreamer &OS;
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 Lattnerb23569a2010-04-04 08:18:47 +0000104 PIC16DbgInfo(MCStreamer &os, const MCAsmInfo *T) : OS(os), MAI(T) {
Sanjiv Guptabde79422009-06-16 09:45:18 +0000105 CurFile = "";
106 CurLine = 0;
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000107 EmitDebugDirectives = false;
Sanjiv Gupta3fc7e532009-06-03 16:27:49 +0000108 }
Sanjiv Guptabde79422009-06-16 09:45:18 +0000109
110 void BeginModule (Module &M);
111 void BeginFunction (const MachineFunction &MF);
112 void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL,
113 bool IsInBeginFunction = false);
114 void EndFunction (const MachineFunction &MF);
115 void EndModule (Module &M);
116
117
118 private:
Devang Patele4b27562009-08-28 23:24:31 +0000119 void SwitchToCU (MDNode *CU);
Sanjiv Guptabde79422009-06-16 09:45:18 +0000120 void SwitchToLine (unsigned Line, bool IsInBeginFunction = false);
121
122 void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux,
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +0000123 int Aux[], std::string &TypeName);
Sanjiv Guptabde79422009-06-16 09:45:18 +0000124 void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo);
125 void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo,
126 bool &HasAux, int Aux[],
127 std::string &TypeName);
128
129 void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo,
130 bool &HasAux, int Aux[],
131 std::string &TypeName);
132 void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo,
133 bool &HasAux, int Aux[],
134 std::string &TypeName);
135
136 void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo,
137 bool &HasAux, int Aux[],
138 std::string &TypeName);
139 void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo);
140
141 unsigned GetTypeDebugNumber(std::string &Type);
142 short getStorageClass(DIGlobalVariable DIGV);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000143 void EmitFunctBeginDI(const Function *F);
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000144 void EmitCompositeTypeDecls(Module &M);
Sanjiv Guptabfa79b82009-08-15 14:36:48 +0000145 void EmitCompositeTypeElements (DICompositeType CTy, std::string Suffix);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000146 void EmitFunctEndDI(const Function *F, unsigned Line);
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000147 void EmitAuxEntry(const std::string VarName, int Aux[],
Sanjiv Guptabde79422009-06-16 09:45:18 +0000148 int num = PIC16Dbg::AuxSize, std::string TagName = "");
Sanjiv Guptadcb6da32009-06-13 17:35:54 +0000149 inline void EmitSymbol(std::string Name, short Class,
150 unsigned short Type = PIC16Dbg::T_NULL,
151 unsigned long Value = 0);
Sanjiv Guptadd4694b2009-05-28 18:24:11 +0000152 void EmitVarDebugInfo(Module &M);
Sanjiv Gupta3fc7e532009-06-03 16:27:49 +0000153 void EmitEOF();
Sanjiv Guptaa57bc3b2009-05-22 13:58:45 +0000154 };
155} // end namespace llvm;
156#endif