FILE compilers_laba fopen dump txt FOR_EACH_BB bb gimple_stmt_iterator

 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
FILE* compilers_laba = fopen("dump.txt", "w");
FOR_EACH_BB (bb) {
gimple_stmt_iterator si;
for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) {
gimple phi = gsi_stmt (si);
fprintf(compilers_laba, "gimple phi code: %d\n", gimple_code(phi));
}
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) {
gimple stmt = gsi_stmt (si);
fprintf(compilers_laba, "gimple stmt code: %d", gimple_code(stmt));
switch (gimple_code(stmt)) {
case GIMPLE_ASSIGN:
fprintf(compilers_laba, " GIMPLE_ASSIGN\n");
print_gimple_stmt (compilers_laba, stmt, 0, TDF_SLIM);
break;
case GIMPLE_CALL:
fprintf(compilers_laba, " GIMPLE_CALL\n");
print_gimple_stmt (compilers_laba, stmt, 0, TDF_SLIM);
break;
default:
//check gimple rhs class
fprintf(compilers_laba, "\ngimple rhs class: ");
switch (get_gimple_rhs_class(gimple_expr_code(stmt))) {
case GIMPLE_INVALID_RHS: /* The expression cannot be used on the RHS. */
fprintf(compilers_laba, "INVALID RHS\n");
break;
case GIMPLE_TERNARY_RHS: /* The expression is a ternary operation. */
fprintf(compilers_laba, "TERNARY RHS\n");
break;
case GIMPLE_BINARY_RHS: /* The expression is a binary operation. */
fprintf(compilers_laba, "BINARY RHS\n");
break;
case GIMPLE_UNARY_RHS: /* The expression is a unary operation. */
fprintf(compilers_laba, "UNARY RHS\n");
break;
case GIMPLE_SINGLE_RHS: /* The expression is a single object (an SSA name, a _DECL, a _REF, etc. */
fprintf(compilers_laba, "SINGLE RHS\n");
break;
}
}
}
}
fclose(compilers_laba);