8
8
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
10
printf("\n\n-- If pattern --\n\n");
10
printf("\n\n-- If pattern --\n\n", "the_var");
12
Block *b_a = new Block("// block A\n");
13
Block *b_b = new Block("// block B\n");
14
Block *b_c = new Block("// block C\n");
12
Block *b_a = new Block("// block A\n", "the_var");
13
Block *b_b = new Block("// block B\n", "the_var");
14
Block *b_c = new Block("// block C\n", "the_var");
16
16
b_a->AddBranchTo(b_b, "check == 10", "atob();");
17
17
b_a->AddBranchTo(b_c, NULL, "atoc();");
34
34
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
36
printf("\n\n-- If-else pattern --\n\n");
36
printf("\n\n-- If-else pattern --\n\n", "the_var");
38
Block *b_a = new Block("// block A\n");
39
Block *b_b = new Block("// block B\n");
40
Block *b_c = new Block("// block C\n");
41
Block *b_d = new Block("// block D\n");
38
Block *b_a = new Block("// block A\n", "the_var");
39
Block *b_b = new Block("// block B\n", "the_var");
40
Block *b_c = new Block("// block C\n", "the_var");
41
Block *b_d = new Block("// block D\n", "the_var");
43
43
b_a->AddBranchTo(b_b, "check == 15");
44
44
b_a->AddBranchTo(b_c, NULL);
64
64
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
66
printf("\n\n-- Loop + tail pattern --\n\n");
66
printf("\n\n-- Loop + tail pattern --\n\n", "the_var");
68
Block *b_a = new Block("// block A\nvar check = maybe();\n");
69
Block *b_b = new Block("// block B\n");
70
Block *b_c = new Block("// block C\n");
68
Block *b_a = new Block("// block A\nvar check = maybe();\n", "the_var");
69
Block *b_b = new Block("// block B\n", "the_var");
70
Block *b_c = new Block("// block C\n", "the_var");
72
72
b_a->AddBranchTo(b_b, NULL);
90
90
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
92
printf("\n\n-- Loop with phi to head \n\n");
92
printf("\n\n-- Loop with phi to head \n\n", "the_var");
94
94
void *block_map[10000];
95
95
void *rl = rl_new_relooper();
96
void *b1 = rl_new_block("// code 1");
96
void *b1 = rl_new_block("// code 1", "the_var");
98
98
rl_relooper_add_block(rl, block_map[1]);
99
void *b2 = rl_new_block("// code 2");
99
void *b2 = rl_new_block("// code 2", "the_var");
100
100
block_map[2] = b2;
101
101
rl_relooper_add_block(rl, block_map[2]);
102
void *b3 = rl_new_block("// code 3");
102
void *b3 = rl_new_block("// code 3", "the_var");
103
103
block_map[3] = b3;
104
104
rl_relooper_add_block(rl, block_map[3]);
105
void *b4 = rl_new_block("// code 4");
105
void *b4 = rl_new_block("// code 4", "the_var");
106
106
block_map[4] = b4;
107
107
rl_relooper_add_block(rl, block_map[4]);
108
void *b5 = rl_new_block("// code 5");
108
void *b5 = rl_new_block("// code 5", "the_var");
109
109
block_map[5] = b5;
110
110
rl_relooper_add_block(rl, block_map[5]);
111
void *b6 = rl_new_block("// code 6");
111
void *b6 = rl_new_block("// code 6", "the_var");
112
112
block_map[6] = b6;
113
113
rl_relooper_add_block(rl, block_map[6]);
114
void *b7 = rl_new_block("// code 7");
114
void *b7 = rl_new_block("// code 7", "the_var");
115
115
block_map[7] = b7;
116
116
rl_relooper_add_block(rl, block_map[7]);
117
117
rl_block_add_branch_to(block_map[1], block_map[2], NULL, "var $i_0 = 0;var $x_0 = 5; ");
133
133
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
135
printf("\n\n-- phi on split dead ends --\n\n");
135
printf("\n\n-- phi on split dead ends --\n\n", "the_var");
137
Block *b_a = new Block("// block A...................................................................................................\n");
138
Block *b_b = new Block("// block B...................................................................................................\n");
139
Block *b_c = new Block("// block C...................................................................................................\n");
140
Block *b_d = new Block("// block D\n"); // small and splittable!
141
Block *b_e = new Block("// block E\n");
137
Block *b_a = new Block("// block A...................................................................................................\n", "the_var");
138
Block *b_b = new Block("// block B...................................................................................................\n", "the_var");
139
Block *b_c = new Block("// block C...................................................................................................\n", "the_var");
140
Block *b_d = new Block("// block D\n", "the_var"); // small and splittable!
141
Block *b_e = new Block("// block E\n", "the_var");
143
143
b_a->AddBranchTo(b_b, "chak()", "atob();");
144
144
b_a->AddBranchTo(b_c, NULL, "atoc();");
165
165
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
167
printf("\n\n-- Unbalanced with a dead end --\n\n");
167
printf("\n\n-- Unbalanced with a dead end --\n\n", "the_var");
169
Block *b_a = new Block("// block A\n");
170
Block *b_b = new Block("// block B\n");
171
Block *b_c = new Block("return C;\n");
172
Block *b_d = new Block("// block D\n");
169
Block *b_a = new Block("// block A\n", "the_var");
170
Block *b_b = new Block("// block B\n", "the_var");
171
Block *b_c = new Block("return C;\n", "the_var");
172
Block *b_d = new Block("// block D\n", "the_var");
174
174
b_a->AddBranchTo(b_b, "check == 10");
175
175
b_a->AddBranchTo(b_c, NULL); // c is a dead end
195
195
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
197
printf("\n\n-- if (expensive || expensive2) X else Y; Z --\n\n");
197
printf("\n\n-- if (expensive || expensive2) X else Y; Z --\n\n", "the_var");
199
Block *b_a = new Block("// block A\n");
200
Block *b_b = new Block("// block B\n");
201
Block *b_c = new Block("// block C;\n");
202
Block *b_d = new Block("// block D\n");
203
Block *b_e = new Block("// block E\n");
204
Block *b_f = new Block("// block F\n");
199
Block *b_a = new Block("// block A\n", "the_var");
200
Block *b_b = new Block("// block B\n", "the_var");
201
Block *b_c = new Block("// block C;\n", "the_var");
202
Block *b_d = new Block("// block D\n", "the_var");
203
Block *b_e = new Block("// block E\n", "the_var");
204
Block *b_f = new Block("// block F\n", "the_var");
206
206
b_a->AddBranchTo(b_c, "expensive()");
207
207
b_a->AddBranchTo(b_b, NULL);
236
236
Relooper::SetOutputBuffer(buffer, sizeof(buffer));
238
printf("\n\n-- conditional loop --\n\n");
238
printf("\n\n-- conditional loop --\n\n", "the_var");
240
Block *b_a = new Block("// block A\n");
241
Block *b_b = new Block("// block B\n");
242
Block *b_c = new Block("// block C\n");
240
Block *b_a = new Block("// block A\n", "the_var");
241
Block *b_b = new Block("// block B\n", "the_var");
242
Block *b_c = new Block("// block C\n", "the_var");
244
244
b_a->AddBranchTo(b_b, "shouldLoop()");
245
245
b_a->AddBranchTo(b_c, NULL);