-
Notifications
You must be signed in to change notification settings - Fork 1
/
record.cpp
89 lines (78 loc) · 2.1 KB
/
record.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
std::ofstream logfile;
std::ofstream treefile;
static int treeCount = 100;
void openLog(const char * fname)
{
logfile.open(fname);
}
void closeLog()
{
logfile.close();
}
void startDigraph(int blockId)
{
std::stringstream fname_stream;
fname_stream << "reports/" << "tree_" << blockId << "_" << treeCount << ".dot";
treefile.open(fname_stream.str().c_str());
treefile << "digraph G {" << std::endl;
treeCount++;
}
void endDigraph()
{
treefile << "}" << std::endl;
treefile.close();
}
void emit_tree(PlatformLevel * p)
{
if(p)
{
treefile << p->id << " [label=\"" << p->getStr() << "\", shape=\"record\"];" << std::endl;
for(std::vector<DeviceLevel*>::iterator it = p->devices.begin() ;
it != p->devices.end() ; it++)
{
treefile << p->id << " -> " << (*it)->id << ";" << std::endl;
treefile << (*it)->id << " [label=\"" << (*it)->getStr() << "\", shape=\"record\"];" << std::endl;
emit_tree(*it);
}
}
}
void emit_tree(DeviceLevel * p)
{
std::vector<BlockLevel*> blocks = p->blockList;
for(std::vector<BlockLevel*>::iterator it = blocks.begin() ;
it != blocks.end() ; it++)
{
treefile << p->id << " -> " << (*it)->id << ";" << std::endl;
treefile << (*it)->id << " [label=\"" << (*it)->getStr() << "\", shape=\"record\"];" << std::endl;
emit_tree(*it);
}
}
void emit_tree(BlockLevel * p)
{
for(std::vector<ThreadLevel*>::iterator it = p->threads.begin() ;
it != p->threads.end() ; it++)
{
treefile << p->id << " -> " << (*it)->id << ";" << std::endl;
treefile << (*it)->id << " [label=\"" << (*it)->getStr() << "\", shape=\"record\"];" << std::endl;
emit_tree(*it);
}
}
void emit_tree(ThreadLevel * p)
{
for(std::vector<ElementLevel*>::iterator it = p->elements.begin() ;
it != p->elements.end() ; it++)
{
// Label with dumpStmts
treefile << p->id << " -> " << (*it)->id << ";" << std::endl;
treefile << (*it)->id << " [label=\"" << (*it)->getStr() << "\", shape=\"record\"];" << std::endl;
}
}
void emit_tree(ElementLevel * e)
{
{
}
}
void emit_tree(EBasicBlock * bb)
{
emit_tree(bb->p);
}