10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
+ #include " Boolean.h"
13
14
#include " Floating.h"
14
15
#include " Function.h"
16
+ #include " FunctionPointer.h"
17
+ #include " Integral.h"
15
18
#include " IntegralAP.h"
16
19
#include " Opcode.h"
17
20
#include " PrimType.h"
@@ -86,6 +89,40 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const {
86
89
87
90
LLVM_DUMP_METHOD void Program::dump () const { dump (llvm::errs ()); }
88
91
92
+ static const char *primTypeToString (PrimType T) {
93
+ switch (T) {
94
+ case PT_Sint8:
95
+ return " Sint8" ;
96
+ case PT_Uint8:
97
+ return " Uint8" ;
98
+ case PT_Sint16:
99
+ return " Sint16" ;
100
+ case PT_Uint16:
101
+ return " Uint16" ;
102
+ case PT_Sint32:
103
+ return " Sint32" ;
104
+ case PT_Uint32:
105
+ return " Uint32" ;
106
+ case PT_Sint64:
107
+ return " Sint64" ;
108
+ case PT_Uint64:
109
+ return " Uint64" ;
110
+ case PT_IntAP:
111
+ return " IntAP" ;
112
+ case PT_IntAPS:
113
+ return " IntAPS" ;
114
+ case PT_Bool:
115
+ return " Bool" ;
116
+ case PT_Float:
117
+ return " Float" ;
118
+ case PT_Ptr:
119
+ return " Ptr" ;
120
+ case PT_FnPtr:
121
+ return " FnPtr" ;
122
+ }
123
+ llvm_unreachable (" Unhandled PrimType" );
124
+ }
125
+
89
126
LLVM_DUMP_METHOD void Program::dump (llvm::raw_ostream &OS) const {
90
127
{
91
128
ColorScope SC (OS, true , {llvm::raw_ostream::BRIGHT_RED, true });
@@ -100,9 +137,10 @@ LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
100
137
unsigned GI = 0 ;
101
138
for (const Global *G : Globals) {
102
139
const Descriptor *Desc = G->block ()->getDescriptor ();
140
+ Pointer GP = getPtrGlobal (GI);
141
+
103
142
OS << GI << " : " << (void *)G->block () << " " ;
104
143
{
105
- Pointer GP = getPtrGlobal (GI);
106
144
ColorScope SC (OS, true ,
107
145
GP.isInitialized ()
108
146
? TerminalColor{llvm::raw_ostream::GREEN, false }
@@ -111,6 +149,15 @@ LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
111
149
}
112
150
Desc->dump (OS);
113
151
OS << " \n " ;
152
+ if (Desc->isPrimitive () && !Desc->isDummy ()) {
153
+ OS << " " ;
154
+ {
155
+ ColorScope SC (OS, true , {llvm::raw_ostream::BRIGHT_CYAN, false });
156
+ OS << primTypeToString (Desc->getPrimType ()) << " " ;
157
+ }
158
+ TYPE_SWITCH (Desc->getPrimType (), { GP.deref <T>().print (OS); });
159
+ OS << " \n " ;
160
+ }
114
161
++GI;
115
162
}
116
163
0 commit comments