forked from SEL4PROJ/chronos4.2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfdump.c
228 lines (185 loc) · 5.63 KB
/
infdump.c
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*******************************************************************************
*
* Chronos: A Timing Analyzer for Embedded Software
* =============================================================================
* http://www.comp.nus.edu.sg/~rpembed/chronos/
*
* Infeasible path analysis for Chronos
* Vivy Suhendra
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* 03/2007 infdump.c
*
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "isa.h"
#include "cfg.h"
#include "infeasible.h"
extern prog_t prog;
void printInstr( de_inst_t *is ) {
// printf( "0x%x %s %s %s %s", is->addr, is->op, is->r1, is->r2, is->r3 );
// fflush( stdout );
}
void fprintInstr(FILE *fp, de_inst_t *is ) {
// fprintf(fp, "0x%x %s %s %s %s", is->addr, is->op, is->r1, is->r2, is->r3 );
// fflush( fp );
}
static UNUSED
int printInstructions(void) {
/*
int i, j, k;
inf_proc_t *ip;
inf_node_t *ib;
insn_t *is;
for( i = 0; i < num_insn_st; i++ ) {
is = &(insnlist_st[i]);
printf( "[st,--,%2d] 0x%s %s %s %s %s\n", i, is->addr, is->op, is->r1, is->r2, is->r3 );
}
for( i = 0; i < prog.num_procs; i++ ) {
ip = &(inf_procs[i]);
for( j = 0; j < ip->num_bb; j++ ) {
ib = &(ip->inf_cfg[j]);
for( k = 0; k < ib->num_insn; k++ ) {
is = &(ib->insnlist[k]);
printf( "[%2d,%2d,%2d] 0x%s %s %s %s %s\n", i, j, k, is->addr, is->op, is->r1, is->r2, is->r3 );
}
}
}
*/
return 0;
}
static
char *getDirName( int dir ) {
switch( dir ) {
case GT: return "GT";
case GE: return "GE";
case LT: return "LT";
case LE: return "LE";
case EQ: return "EQ";
case NE: return "NE";
case NA: return "NA";
default:
return "";
}
}
static
int printBAConflict( BA_conflict_t *cf ) {
int i;
if( cf->conflict_dir == JUMP )
printf( "-- <%d::%d> JUMP", cf->conflict_src->bb->id, cf->conflict_src->lineno );
else if( cf->conflict_dir == FALL )
printf( "-- <%d::%d> FALL", cf->conflict_src->bb->id, cf->conflict_src->lineno );
for( i = 0; i < cf->num_nullifiers; i++ )
printf( " _<%d::%d> ", cf->nullifier_list[i]->bb->id, cf->nullifier_list[i]->lineno );
printf( "\n" );
return 0;
}
static
int printBBConflict( BB_conflict_t *cf ) {
int i;
if( cf->conflict_dir == JJ )
printf( "-- <%d> JUMP/JUMP", cf->conflict_src->bb->id );
else if( cf->conflict_dir == JF )
printf( "-- <%d> JUMP/FALL", cf->conflict_src->bb->id );
else if( cf->conflict_dir == FJ )
printf( "-- <%d> FALL/JUMP", cf->conflict_src->bb->id );
else if( cf->conflict_dir == FF )
printf( "-- <%d> FALL/FALL", cf->conflict_src->bb->id );
for( i = 0; i < cf->num_nullifiers; i++ )
printf( " _<%d::%d>", cf->nullifier_list[i]->bb->id, cf->nullifier_list[i]->lineno );
printf( "\n" );
return 0;
}
static
int printBranch( branch_t *br, char printcf ) {
int i;
if( br == NULL )
return -1;
printf( "B <%d,%3d>", br->bb->proc->id, br->bb->id );
printf( " rhs:" );
if( br->rhs_var )
printf( "var" );
else
printf( "%3d", br->rhs );
printf( " jump:%s", getDirName( br->jump_cond ));
printf( " deri:%s\n", br->deritree );
if( !printcf )
return 0;
/*
if( br->num_conflicts ) {
printf( "- outgoing conflicts:" );
for( i = 0; i < br->num_conflicts; i++ ) {
if( br->conflictdir_jump[i] != -1 )
printf( " %d (%sx%s)", br->conflicts[i]->bb->id, getDirName( br->jump_cond ), getDirName( br->conflictdir_jump[i] ));
if( br->conflictdir_fall[i] != -1 )
printf( " %d (%sx%s)", br->conflicts[i]->bb->id, getDirName( neg(br->jump_cond) ), getDirName( br->conflictdir_fall[i] ));
}
printf( "\n" );
}
if( br->num_incfs ) {
printf( "- incoming conflicts:" );
for( i = 0; i < inf_procs[br->bb->proc->id].num_bb; i++ )
if( br->in_conflict[i] )
printf( " %d", i );
printf( "\n" );
}
*/
if( br->num_BA_conflicts > 0 ) {
printf( "- BA conflicts:\n" );
for( i = 0; i < br->num_BA_conflicts; i++ )
printBAConflict( &(br->BA_conflict_list[i]) );
}
if( br->num_BB_conflicts > 0 ) {
printf( "- BB conflicts:\n" );
for( i = 0; i < br->num_BB_conflicts; i++ )
printBBConflict( &(br->BB_conflict_list[i]) );
}
return 0;
}
static
int printAssign( assign_t *assg, char printcf ) {
printf( "A <%d,%3d,%3d> ", assg->bb->proc->id, assg->bb->id, assg->lineno );
printf( "rhs:" );
if( assg->rhs_var )
printf( "var " );
else
printf( "%3d ", assg->rhs );
printf( "deri:%s\n", assg->deritree );
if( !printcf )
return 0;
/*
if( assg->num_conflicts ) {
int i;
printf( "- outgoing conflicts:" );
for( i = 0; i < assg->num_conflicts; i++ )
printf( " %d(%d)", assg->conflicts[i]->bb->id, assg->conflictdir[i] );
printf( "\n" );
}
*/
return 0;
}
static UNUSED
int printEffects( char printcf ) {
int i, j, k;
inf_node_t *ib;
printf( "--------------------------------\n" );
for( i = 0; i < prog.num_procs; i++ ) {
for( j = 0; j < inf_procs[i].num_bb; j++ ) {
ib = &(inf_procs[i].inf_cfg[j]);
for( k = 0; k < ib->num_assign; k++ )
printAssign( ib->assignlist[k], printcf );
printBranch( ib->branch, printcf );
}
}
printf( "--------------------------------\n" );
return 0;
}