Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/cctest/compiler/test-instruction.cc

Issue 699083003: [turbofan] extend register allocator testing with control flow (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/compiler/code-generator.h" 8 #include "src/compiler/code-generator.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 BasicBlock* b1 = R.schedule.NewBasicBlock(); 151 BasicBlock* b1 = R.schedule.NewBasicBlock();
152 BasicBlock* b2 = R.schedule.NewBasicBlock(); 152 BasicBlock* b2 = R.schedule.NewBasicBlock();
153 BasicBlock* b3 = R.schedule.end(); 153 BasicBlock* b3 = R.schedule.end();
154 154
155 R.schedule.AddGoto(b0, b1); 155 R.schedule.AddGoto(b0, b1);
156 R.schedule.AddGoto(b1, b2); 156 R.schedule.AddGoto(b1, b2);
157 R.schedule.AddGoto(b2, b3); 157 R.schedule.AddGoto(b2, b3);
158 158
159 R.allocCode(); 159 R.allocCode();
160 160
161 R.code->StartBlock(b0); 161 R.code->StartBlock(b0->GetRpoNumber());
162 int i0 = R.NewInstr(); 162 int i0 = R.NewInstr();
163 int i1 = R.NewInstr(); 163 int i1 = R.NewInstr();
164 R.code->EndBlock(b0); 164 R.code->EndBlock(b0->GetRpoNumber());
165 R.code->StartBlock(b1); 165 R.code->StartBlock(b1->GetRpoNumber());
166 int i2 = R.NewInstr(); 166 int i2 = R.NewInstr();
167 int i3 = R.NewInstr(); 167 int i3 = R.NewInstr();
168 int i4 = R.NewInstr(); 168 int i4 = R.NewInstr();
169 int i5 = R.NewInstr(); 169 int i5 = R.NewInstr();
170 R.code->EndBlock(b1); 170 R.code->EndBlock(b1->GetRpoNumber());
171 R.code->StartBlock(b2); 171 R.code->StartBlock(b2->GetRpoNumber());
172 int i6 = R.NewInstr(); 172 int i6 = R.NewInstr();
173 int i7 = R.NewInstr(); 173 int i7 = R.NewInstr();
174 int i8 = R.NewInstr(); 174 int i8 = R.NewInstr();
175 R.code->EndBlock(b2); 175 R.code->EndBlock(b2->GetRpoNumber());
176 R.code->StartBlock(b3); 176 R.code->StartBlock(b3->GetRpoNumber());
177 R.code->EndBlock(b3); 177 R.code->EndBlock(b3->GetRpoNumber());
178 178
179 CHECK_EQ(b0, R.GetBasicBlock(i0)); 179 CHECK_EQ(b0, R.GetBasicBlock(i0));
180 CHECK_EQ(b0, R.GetBasicBlock(i1)); 180 CHECK_EQ(b0, R.GetBasicBlock(i1));
181 181
182 CHECK_EQ(b1, R.GetBasicBlock(i2)); 182 CHECK_EQ(b1, R.GetBasicBlock(i2));
183 CHECK_EQ(b1, R.GetBasicBlock(i3)); 183 CHECK_EQ(b1, R.GetBasicBlock(i3));
184 CHECK_EQ(b1, R.GetBasicBlock(i4)); 184 CHECK_EQ(b1, R.GetBasicBlock(i4));
185 CHECK_EQ(b1, R.GetBasicBlock(i5)); 185 CHECK_EQ(b1, R.GetBasicBlock(i5));
186 186
187 CHECK_EQ(b2, R.GetBasicBlock(i6)); 187 CHECK_EQ(b2, R.GetBasicBlock(i6));
(...skipping 16 matching lines...) Expand all
204 204
205 TEST(InstructionIsGapAt) { 205 TEST(InstructionIsGapAt) {
206 InstructionTester R; 206 InstructionTester R;
207 207
208 BasicBlock* b0 = R.schedule.start(); 208 BasicBlock* b0 = R.schedule.start();
209 R.schedule.AddReturn(b0, R.Int32Constant(1)); 209 R.schedule.AddReturn(b0, R.Int32Constant(1));
210 210
211 R.allocCode(); 211 R.allocCode();
212 TestInstr* i0 = TestInstr::New(R.zone(), 100); 212 TestInstr* i0 = TestInstr::New(R.zone(), 100);
213 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 213 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
214 R.code->StartBlock(b0); 214 R.code->StartBlock(b0->GetRpoNumber());
215 R.code->AddInstruction(i0); 215 R.code->AddInstruction(i0);
216 R.code->AddInstruction(g); 216 R.code->AddInstruction(g);
217 R.code->EndBlock(b0); 217 R.code->EndBlock(b0->GetRpoNumber());
218 218
219 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 219 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart());
220 220
221 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 221 CHECK_EQ(true, R.code->IsGapAt(0)); // Label
222 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 222 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap
223 CHECK_EQ(false, R.code->IsGapAt(2)); // i0 223 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
224 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap 224 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
225 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap 225 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
226 CHECK_EQ(false, R.code->IsGapAt(5)); // g 226 CHECK_EQ(false, R.code->IsGapAt(5)); // g
227 } 227 }
228 228
229 229
230 TEST(InstructionIsGapAt2) { 230 TEST(InstructionIsGapAt2) {
231 InstructionTester R; 231 InstructionTester R;
232 232
233 BasicBlock* b0 = R.schedule.start(); 233 BasicBlock* b0 = R.schedule.start();
234 BasicBlock* b1 = R.schedule.end(); 234 BasicBlock* b1 = R.schedule.end();
235 R.schedule.AddGoto(b0, b1); 235 R.schedule.AddGoto(b0, b1);
236 R.schedule.AddReturn(b1, R.Int32Constant(1)); 236 R.schedule.AddReturn(b1, R.Int32Constant(1));
237 237
238 R.allocCode(); 238 R.allocCode();
239 TestInstr* i0 = TestInstr::New(R.zone(), 100); 239 TestInstr* i0 = TestInstr::New(R.zone(), 100);
240 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 240 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
241 R.code->StartBlock(b0); 241 R.code->StartBlock(b0->GetRpoNumber());
242 R.code->AddInstruction(i0); 242 R.code->AddInstruction(i0);
243 R.code->AddInstruction(g); 243 R.code->AddInstruction(g);
244 R.code->EndBlock(b0); 244 R.code->EndBlock(b0->GetRpoNumber());
245 245
246 TestInstr* i1 = TestInstr::New(R.zone(), 102); 246 TestInstr* i1 = TestInstr::New(R.zone(), 102);
247 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl(); 247 TestInstr* g1 = TestInstr::New(R.zone(), 104)->MarkAsControl();
248 R.code->StartBlock(b1); 248 R.code->StartBlock(b1->GetRpoNumber());
249 R.code->AddInstruction(i1); 249 R.code->AddInstruction(i1);
250 R.code->AddInstruction(g1); 250 R.code->AddInstruction(g1);
251 R.code->EndBlock(b1); 251 R.code->EndBlock(b1->GetRpoNumber());
252 252
253 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 253 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart());
254 254
255 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 255 CHECK_EQ(true, R.code->IsGapAt(0)); // Label
256 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 256 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap
257 CHECK_EQ(false, R.code->IsGapAt(2)); // i0 257 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
258 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap 258 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
259 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap 259 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
260 CHECK_EQ(false, R.code->IsGapAt(5)); // g 260 CHECK_EQ(false, R.code->IsGapAt(5)); // g
261 261
(...skipping 10 matching lines...) Expand all
272 272
273 TEST(InstructionAddGapMove) { 273 TEST(InstructionAddGapMove) {
274 InstructionTester R; 274 InstructionTester R;
275 275
276 BasicBlock* b0 = R.schedule.start(); 276 BasicBlock* b0 = R.schedule.start();
277 R.schedule.AddReturn(b0, R.Int32Constant(1)); 277 R.schedule.AddReturn(b0, R.Int32Constant(1));
278 278
279 R.allocCode(); 279 R.allocCode();
280 TestInstr* i0 = TestInstr::New(R.zone(), 100); 280 TestInstr* i0 = TestInstr::New(R.zone(), 100);
281 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl(); 281 TestInstr* g = TestInstr::New(R.zone(), 103)->MarkAsControl();
282 R.code->StartBlock(b0); 282 R.code->StartBlock(b0->GetRpoNumber());
283 R.code->AddInstruction(i0); 283 R.code->AddInstruction(i0);
284 R.code->AddInstruction(g); 284 R.code->AddInstruction(g);
285 R.code->EndBlock(b0); 285 R.code->EndBlock(b0->GetRpoNumber());
286 286
287 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart()); 287 CHECK_EQ(true, R.code->InstructionAt(0)->IsBlockStart());
288 288
289 CHECK_EQ(true, R.code->IsGapAt(0)); // Label 289 CHECK_EQ(true, R.code->IsGapAt(0)); // Label
290 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap 290 CHECK_EQ(true, R.code->IsGapAt(1)); // Gap
291 CHECK_EQ(false, R.code->IsGapAt(2)); // i0 291 CHECK_EQ(false, R.code->IsGapAt(2)); // i0
292 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap 292 CHECK_EQ(true, R.code->IsGapAt(3)); // Gap
293 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap 293 CHECK_EQ(true, R.code->IsGapAt(4)); // Gap
294 CHECK_EQ(false, R.code->IsGapAt(5)); // g 294 CHECK_EQ(false, R.code->IsGapAt(5)); // g
295 295
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 CHECK_EQ(inputs[z], m->InputAt(z)); 358 CHECK_EQ(inputs[z], m->InputAt(z));
359 } 359 }
360 360
361 for (size_t z = 0; z < k; z++) { 361 for (size_t z = 0; z < k; z++) {
362 CHECK_EQ(temps[z], m->TempAt(z)); 362 CHECK_EQ(temps[z], m->TempAt(z));
363 } 363 }
364 } 364 }
365 } 365 }
366 } 366 }
367 } 367 }
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | test/unittests/compiler/register-allocator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698