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

Side by Side Diff: test/unittests/compiler/arm/instruction-selector-arm-unittest.cc

Issue 1477413002: Move RMA::Label out of the class, so it can be forward declared. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: RawLabel -> RawMachineLabel Created 5 years 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
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 <limits> 5 #include <limits>
6 6
7 #include "test/unittests/compiler/instruction-selector-unittest.h" 7 #include "test/unittests/compiler/instruction-selector-unittest.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 namespace compiler { 11 namespace compiler {
12 12
13 namespace { 13 namespace {
14 14
15 typedef RawMachineAssembler::Label MLabel;
16 typedef Node* (RawMachineAssembler::*Constructor)(Node*, Node*); 15 typedef Node* (RawMachineAssembler::*Constructor)(Node*, Node*);
17 16
18 17
19 // Data processing instructions. 18 // Data processing instructions.
20 struct DPI { 19 struct DPI {
21 Constructor constructor; 20 Constructor constructor;
22 const char* constructor_name; 21 const char* constructor_name;
23 ArchOpcode arch_opcode; 22 ArchOpcode arch_opcode;
24 ArchOpcode reverse_arch_opcode; 23 ArchOpcode reverse_arch_opcode;
25 ArchOpcode test_arch_opcode; 24 ArchOpcode test_arch_opcode;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 239 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
241 EXPECT_EQ(1U, s[0]->OutputCount()); 240 EXPECT_EQ(1U, s[0]->OutputCount());
242 } 241 }
243 } 242 }
244 } 243 }
245 244
246 245
247 TEST_P(InstructionSelectorDPITest, BranchWithParameters) { 246 TEST_P(InstructionSelectorDPITest, BranchWithParameters) {
248 const DPI dpi = GetParam(); 247 const DPI dpi = GetParam();
249 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 248 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
250 MLabel a, b; 249 RawMachineLabel a, b;
251 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); 250 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b);
252 m.Bind(&a); 251 m.Bind(&a);
253 m.Return(m.Int32Constant(1)); 252 m.Return(m.Int32Constant(1));
254 m.Bind(&b); 253 m.Bind(&b);
255 m.Return(m.Int32Constant(0)); 254 m.Return(m.Int32Constant(0));
256 Stream s = m.Build(); 255 Stream s = m.Build();
257 ASSERT_EQ(1U, s.size()); 256 ASSERT_EQ(1U, s.size());
258 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 257 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
259 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 258 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
260 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 259 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
261 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 260 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
262 } 261 }
263 262
264 263
265 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { 264 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) {
266 const DPI dpi = GetParam(); 265 const DPI dpi = GetParam();
267 TRACED_FOREACH(int32_t, imm, kImmediates) { 266 TRACED_FOREACH(int32_t, imm, kImmediates) {
268 StreamBuilder m(this, kMachInt32, kMachInt32); 267 StreamBuilder m(this, kMachInt32, kMachInt32);
269 MLabel a, b; 268 RawMachineLabel a, b;
270 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, 269 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a,
271 &b); 270 &b);
272 m.Bind(&a); 271 m.Bind(&a);
273 m.Return(m.Int32Constant(1)); 272 m.Return(m.Int32Constant(1));
274 m.Bind(&b); 273 m.Bind(&b);
275 m.Return(m.Int32Constant(0)); 274 m.Return(m.Int32Constant(0));
276 Stream s = m.Build(); 275 Stream s = m.Build();
277 ASSERT_EQ(1U, s.size()); 276 ASSERT_EQ(1U, s.size());
278 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 277 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
279 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 278 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
280 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 279 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
281 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 280 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
282 } 281 }
283 TRACED_FOREACH(int32_t, imm, kImmediates) { 282 TRACED_FOREACH(int32_t, imm, kImmediates) {
284 StreamBuilder m(this, kMachInt32, kMachInt32); 283 StreamBuilder m(this, kMachInt32, kMachInt32);
285 MLabel a, b; 284 RawMachineLabel a, b;
286 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, 285 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a,
287 &b); 286 &b);
288 m.Bind(&a); 287 m.Bind(&a);
289 m.Return(m.Int32Constant(1)); 288 m.Return(m.Int32Constant(1));
290 m.Bind(&b); 289 m.Bind(&b);
291 m.Return(m.Int32Constant(0)); 290 m.Return(m.Int32Constant(0));
292 Stream s = m.Build(); 291 Stream s = m.Build();
293 ASSERT_EQ(1U, s.size()); 292 ASSERT_EQ(1U, s.size());
294 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 293 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
295 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 294 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
296 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 295 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
297 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 296 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
298 } 297 }
299 } 298 }
300 299
301 300
302 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { 301 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) {
303 const DPI dpi = GetParam(); 302 const DPI dpi = GetParam();
304 TRACED_FOREACH(Shift, shift, kShifts) { 303 TRACED_FOREACH(Shift, shift, kShifts) {
305 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 304 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
306 MLabel a, b; 305 RawMachineLabel a, b;
307 m.Branch((m.*dpi.constructor)( 306 m.Branch((m.*dpi.constructor)(
308 m.Parameter(0), 307 m.Parameter(0),
309 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), 308 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))),
310 &a, &b); 309 &a, &b);
311 m.Bind(&a); 310 m.Bind(&a);
312 m.Return(m.Int32Constant(1)); 311 m.Return(m.Int32Constant(1));
313 m.Bind(&b); 312 m.Bind(&b);
314 m.Return(m.Int32Constant(0)); 313 m.Return(m.Int32Constant(0));
315 Stream s = m.Build(); 314 Stream s = m.Build();
316 ASSERT_EQ(1U, s.size()); 315 ASSERT_EQ(1U, s.size());
317 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 316 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
318 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 317 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
319 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 318 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
320 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 319 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
321 } 320 }
322 TRACED_FOREACH(Shift, shift, kShifts) { 321 TRACED_FOREACH(Shift, shift, kShifts) {
323 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 322 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
324 MLabel a, b; 323 RawMachineLabel a, b;
325 m.Branch((m.*dpi.constructor)( 324 m.Branch((m.*dpi.constructor)(
326 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), 325 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)),
327 m.Parameter(2)), 326 m.Parameter(2)),
328 &a, &b); 327 &a, &b);
329 m.Bind(&a); 328 m.Bind(&a);
330 m.Return(m.Int32Constant(1)); 329 m.Return(m.Int32Constant(1));
331 m.Bind(&b); 330 m.Bind(&b);
332 m.Return(m.Int32Constant(0)); 331 m.Return(m.Int32Constant(0));
333 Stream s = m.Build(); 332 Stream s = m.Build();
334 ASSERT_EQ(1U, s.size()); 333 ASSERT_EQ(1U, s.size());
335 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 334 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
336 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); 335 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode());
337 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 336 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
338 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 337 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
339 } 338 }
340 } 339 }
341 340
342 341
343 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { 342 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) {
344 const DPI dpi = GetParam(); 343 const DPI dpi = GetParam();
345 TRACED_FOREACH(Shift, shift, kShifts) { 344 TRACED_FOREACH(Shift, shift, kShifts) {
346 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 345 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
347 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 346 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
348 MLabel a, b; 347 RawMachineLabel a, b;
349 m.Branch((m.*dpi.constructor)(m.Parameter(0), 348 m.Branch((m.*dpi.constructor)(m.Parameter(0),
350 (m.*shift.constructor)( 349 (m.*shift.constructor)(
351 m.Parameter(1), m.Int32Constant(imm))), 350 m.Parameter(1), m.Int32Constant(imm))),
352 &a, &b); 351 &a, &b);
353 m.Bind(&a); 352 m.Bind(&a);
354 m.Return(m.Int32Constant(1)); 353 m.Return(m.Int32Constant(1));
355 m.Bind(&b); 354 m.Bind(&b);
356 m.Return(m.Int32Constant(0)); 355 m.Return(m.Int32Constant(0));
357 Stream s = m.Build(); 356 Stream s = m.Build();
358 ASSERT_EQ(1U, s.size()); 357 ASSERT_EQ(1U, s.size());
359 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 358 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
360 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 359 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
361 ASSERT_EQ(5U, s[0]->InputCount()); 360 ASSERT_EQ(5U, s[0]->InputCount());
362 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 361 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
363 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 362 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
364 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 363 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
365 } 364 }
366 } 365 }
367 TRACED_FOREACH(Shift, shift, kShifts) { 366 TRACED_FOREACH(Shift, shift, kShifts) {
368 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { 367 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
369 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 368 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
370 MLabel a, b; 369 RawMachineLabel a, b;
371 m.Branch((m.*dpi.constructor)( 370 m.Branch((m.*dpi.constructor)(
372 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), 371 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)),
373 m.Parameter(1)), 372 m.Parameter(1)),
374 &a, &b); 373 &a, &b);
375 m.Bind(&a); 374 m.Bind(&a);
376 m.Return(m.Int32Constant(1)); 375 m.Return(m.Int32Constant(1));
377 m.Bind(&b); 376 m.Bind(&b);
378 m.Return(m.Int32Constant(0)); 377 m.Return(m.Int32Constant(0));
379 Stream s = m.Build(); 378 Stream s = m.Build();
380 ASSERT_EQ(1U, s.size()); 379 ASSERT_EQ(1U, s.size());
381 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 380 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
382 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); 381 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode());
383 ASSERT_EQ(5U, s[0]->InputCount()); 382 ASSERT_EQ(5U, s[0]->InputCount());
384 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); 383 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2)));
385 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 384 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
386 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 385 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
387 } 386 }
388 } 387 }
389 } 388 }
390 389
391 390
392 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { 391 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) {
393 const DPI dpi = GetParam(); 392 const DPI dpi = GetParam();
394 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 393 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
395 MLabel a, b; 394 RawMachineLabel a, b;
396 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), 395 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)),
397 m.Int32Constant(0)), 396 m.Int32Constant(0)),
398 &a, &b); 397 &a, &b);
399 m.Bind(&a); 398 m.Bind(&a);
400 m.Return(m.Int32Constant(1)); 399 m.Return(m.Int32Constant(1));
401 m.Bind(&b); 400 m.Bind(&b);
402 m.Return(m.Int32Constant(0)); 401 m.Return(m.Int32Constant(0));
403 Stream s = m.Build(); 402 Stream s = m.Build();
404 ASSERT_EQ(1U, s.size()); 403 ASSERT_EQ(1U, s.size());
405 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 404 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
406 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 405 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
407 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 406 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
408 EXPECT_EQ(kEqual, s[0]->flags_condition()); 407 EXPECT_EQ(kEqual, s[0]->flags_condition());
409 } 408 }
410 409
411 410
412 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { 411 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) {
413 const DPI dpi = GetParam(); 412 const DPI dpi = GetParam();
414 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 413 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
415 MLabel a, b; 414 RawMachineLabel a, b;
416 m.Branch( 415 m.Branch(
417 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), 416 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)),
418 m.Int32Constant(0)), 417 m.Int32Constant(0)),
419 &a, &b); 418 &a, &b);
420 m.Bind(&a); 419 m.Bind(&a);
421 m.Return(m.Int32Constant(1)); 420 m.Return(m.Int32Constant(1));
422 m.Bind(&b); 421 m.Bind(&b);
423 m.Return(m.Int32Constant(0)); 422 m.Return(m.Int32Constant(0));
424 Stream s = m.Build(); 423 Stream s = m.Build();
425 ASSERT_EQ(1U, s.size()); 424 ASSERT_EQ(1U, s.size());
426 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 425 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
427 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 426 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
428 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 427 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
429 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 428 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
430 } 429 }
431 430
432 431
433 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { 432 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) {
434 const DPI dpi = GetParam(); 433 const DPI dpi = GetParam();
435 TRACED_FOREACH(int32_t, imm, kImmediates) { 434 TRACED_FOREACH(int32_t, imm, kImmediates) {
436 StreamBuilder m(this, kMachInt32, kMachInt32); 435 StreamBuilder m(this, kMachInt32, kMachInt32);
437 MLabel a, b; 436 RawMachineLabel a, b;
438 m.Branch(m.Word32Equal( 437 m.Branch(m.Word32Equal(
439 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), 438 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)),
440 m.Int32Constant(0)), 439 m.Int32Constant(0)),
441 &a, &b); 440 &a, &b);
442 m.Bind(&a); 441 m.Bind(&a);
443 m.Return(m.Int32Constant(1)); 442 m.Return(m.Int32Constant(1));
444 m.Bind(&b); 443 m.Bind(&b);
445 m.Return(m.Int32Constant(0)); 444 m.Return(m.Int32Constant(0));
446 Stream s = m.Build(); 445 Stream s = m.Build();
447 ASSERT_EQ(1U, s.size()); 446 ASSERT_EQ(1U, s.size());
448 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 447 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
449 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 448 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
450 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 449 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
451 EXPECT_EQ(kEqual, s[0]->flags_condition()); 450 EXPECT_EQ(kEqual, s[0]->flags_condition());
452 } 451 }
453 TRACED_FOREACH(int32_t, imm, kImmediates) { 452 TRACED_FOREACH(int32_t, imm, kImmediates) {
454 StreamBuilder m(this, kMachInt32, kMachInt32); 453 StreamBuilder m(this, kMachInt32, kMachInt32);
455 MLabel a, b; 454 RawMachineLabel a, b;
456 m.Branch(m.Word32Equal( 455 m.Branch(m.Word32Equal(
457 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), 456 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)),
458 m.Int32Constant(0)), 457 m.Int32Constant(0)),
459 &a, &b); 458 &a, &b);
460 m.Bind(&a); 459 m.Bind(&a);
461 m.Return(m.Int32Constant(1)); 460 m.Return(m.Int32Constant(1));
462 m.Bind(&b); 461 m.Bind(&b);
463 m.Return(m.Int32Constant(0)); 462 m.Return(m.Int32Constant(0));
464 Stream s = m.Build(); 463 Stream s = m.Build();
465 ASSERT_EQ(1U, s.size()); 464 ASSERT_EQ(1U, s.size());
466 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 465 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
467 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 466 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
468 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 467 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
469 EXPECT_EQ(kEqual, s[0]->flags_condition()); 468 EXPECT_EQ(kEqual, s[0]->flags_condition());
470 } 469 }
471 } 470 }
472 471
473 472
474 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { 473 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) {
475 const DPI dpi = GetParam(); 474 const DPI dpi = GetParam();
476 TRACED_FOREACH(int32_t, imm, kImmediates) { 475 TRACED_FOREACH(int32_t, imm, kImmediates) {
477 StreamBuilder m(this, kMachInt32, kMachInt32); 476 StreamBuilder m(this, kMachInt32, kMachInt32);
478 MLabel a, b; 477 RawMachineLabel a, b;
479 m.Branch(m.Word32NotEqual( 478 m.Branch(m.Word32NotEqual(
480 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), 479 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)),
481 m.Int32Constant(0)), 480 m.Int32Constant(0)),
482 &a, &b); 481 &a, &b);
483 m.Bind(&a); 482 m.Bind(&a);
484 m.Return(m.Int32Constant(1)); 483 m.Return(m.Int32Constant(1));
485 m.Bind(&b); 484 m.Bind(&b);
486 m.Return(m.Int32Constant(0)); 485 m.Return(m.Int32Constant(0));
487 Stream s = m.Build(); 486 Stream s = m.Build();
488 ASSERT_EQ(1U, s.size()); 487 ASSERT_EQ(1U, s.size());
489 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); 488 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode());
490 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 489 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
491 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 490 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
492 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); 491 EXPECT_EQ(kNotEqual, s[0]->flags_condition());
493 } 492 }
494 TRACED_FOREACH(int32_t, imm, kImmediates) { 493 TRACED_FOREACH(int32_t, imm, kImmediates) {
495 StreamBuilder m(this, kMachInt32, kMachInt32); 494 StreamBuilder m(this, kMachInt32, kMachInt32);
496 MLabel a, b; 495 RawMachineLabel a, b;
497 m.Branch(m.Word32NotEqual( 496 m.Branch(m.Word32NotEqual(
498 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), 497 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)),
499 m.Int32Constant(0)), 498 m.Int32Constant(0)),
500 &a, &b); 499 &a, &b);
501 m.Bind(&a); 500 m.Bind(&a);
502 m.Return(m.Int32Constant(1)); 501 m.Return(m.Int32Constant(1));
503 m.Bind(&b); 502 m.Bind(&b);
504 m.Return(m.Int32Constant(0)); 503 m.Return(m.Int32Constant(0));
505 Stream s = m.Build(); 504 Stream s = m.Build();
506 ASSERT_EQ(1U, s.size()); 505 ASSERT_EQ(1U, s.size());
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); 884 EXPECT_EQ(kFlags_set, s[0]->flags_mode());
886 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 885 EXPECT_EQ(kOverflow, s[0]->flags_condition());
887 } 886 }
888 } 887 }
889 } 888 }
890 889
891 890
892 TEST_P(InstructionSelectorODPITest, BranchWithParameters) { 891 TEST_P(InstructionSelectorODPITest, BranchWithParameters) {
893 const ODPI odpi = GetParam(); 892 const ODPI odpi = GetParam();
894 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 893 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
895 MLabel a, b; 894 RawMachineLabel a, b;
896 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 895 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
897 m.Branch(m.Projection(1, n), &a, &b); 896 m.Branch(m.Projection(1, n), &a, &b);
898 m.Bind(&a); 897 m.Bind(&a);
899 m.Return(m.Int32Constant(0)); 898 m.Return(m.Int32Constant(0));
900 m.Bind(&b); 899 m.Bind(&b);
901 m.Return(m.Projection(0, n)); 900 m.Return(m.Projection(0, n));
902 Stream s = m.Build(); 901 Stream s = m.Build();
903 ASSERT_EQ(1U, s.size()); 902 ASSERT_EQ(1U, s.size());
904 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 903 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
905 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 904 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
906 EXPECT_EQ(4U, s[0]->InputCount()); 905 EXPECT_EQ(4U, s[0]->InputCount());
907 EXPECT_EQ(1U, s[0]->OutputCount()); 906 EXPECT_EQ(1U, s[0]->OutputCount());
908 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 907 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
909 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 908 EXPECT_EQ(kOverflow, s[0]->flags_condition());
910 } 909 }
911 910
912 911
913 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { 912 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) {
914 const ODPI odpi = GetParam(); 913 const ODPI odpi = GetParam();
915 TRACED_FOREACH(int32_t, imm, kImmediates) { 914 TRACED_FOREACH(int32_t, imm, kImmediates) {
916 StreamBuilder m(this, kMachInt32, kMachInt32); 915 StreamBuilder m(this, kMachInt32, kMachInt32);
917 MLabel a, b; 916 RawMachineLabel a, b;
918 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); 917 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm));
919 m.Branch(m.Projection(1, n), &a, &b); 918 m.Branch(m.Projection(1, n), &a, &b);
920 m.Bind(&a); 919 m.Bind(&a);
921 m.Return(m.Int32Constant(0)); 920 m.Return(m.Int32Constant(0));
922 m.Bind(&b); 921 m.Bind(&b);
923 m.Return(m.Projection(0, n)); 922 m.Return(m.Projection(0, n));
924 Stream s = m.Build(); 923 Stream s = m.Build();
925 ASSERT_EQ(1U, s.size()); 924 ASSERT_EQ(1U, s.size());
926 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 925 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
927 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 926 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
928 ASSERT_EQ(4U, s[0]->InputCount()); 927 ASSERT_EQ(4U, s[0]->InputCount());
929 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 928 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
930 EXPECT_EQ(1U, s[0]->OutputCount()); 929 EXPECT_EQ(1U, s[0]->OutputCount());
931 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 930 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
932 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 931 EXPECT_EQ(kOverflow, s[0]->flags_condition());
933 } 932 }
934 TRACED_FOREACH(int32_t, imm, kImmediates) { 933 TRACED_FOREACH(int32_t, imm, kImmediates) {
935 StreamBuilder m(this, kMachInt32, kMachInt32); 934 StreamBuilder m(this, kMachInt32, kMachInt32);
936 MLabel a, b; 935 RawMachineLabel a, b;
937 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); 936 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0));
938 m.Branch(m.Projection(1, n), &a, &b); 937 m.Branch(m.Projection(1, n), &a, &b);
939 m.Bind(&a); 938 m.Bind(&a);
940 m.Return(m.Int32Constant(0)); 939 m.Return(m.Int32Constant(0));
941 m.Bind(&b); 940 m.Bind(&b);
942 m.Return(m.Projection(0, n)); 941 m.Return(m.Projection(0, n));
943 Stream s = m.Build(); 942 Stream s = m.Build();
944 ASSERT_EQ(1U, s.size()); 943 ASSERT_EQ(1U, s.size());
945 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); 944 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode());
946 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); 945 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode());
947 ASSERT_EQ(4U, s[0]->InputCount()); 946 ASSERT_EQ(4U, s[0]->InputCount());
948 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 947 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
949 EXPECT_EQ(1U, s[0]->OutputCount()); 948 EXPECT_EQ(1U, s[0]->OutputCount());
950 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 949 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
951 EXPECT_EQ(kOverflow, s[0]->flags_condition()); 950 EXPECT_EQ(kOverflow, s[0]->flags_condition());
952 } 951 }
953 } 952 }
954 953
955 954
956 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { 955 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) {
957 const ODPI odpi = GetParam(); 956 const ODPI odpi = GetParam();
958 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 957 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
959 MLabel a, b; 958 RawMachineLabel a, b;
960 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 959 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
961 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); 960 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b);
962 m.Bind(&a); 961 m.Bind(&a);
963 m.Return(m.Projection(0, n)); 962 m.Return(m.Projection(0, n));
964 m.Bind(&b); 963 m.Bind(&b);
965 m.Return(m.Int32Constant(0)); 964 m.Return(m.Int32Constant(0));
966 Stream s = m.Build(); 965 Stream s = m.Build();
967 ASSERT_EQ(1U, s.size()); 966 ASSERT_EQ(1U, s.size());
968 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 967 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
969 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 968 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
970 EXPECT_EQ(4U, s[0]->InputCount()); 969 EXPECT_EQ(4U, s[0]->InputCount());
971 EXPECT_EQ(1U, s[0]->OutputCount()); 970 EXPECT_EQ(1U, s[0]->OutputCount());
972 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); 971 EXPECT_EQ(kFlags_branch, s[0]->flags_mode());
973 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); 972 EXPECT_EQ(kNotOverflow, s[0]->flags_condition());
974 } 973 }
975 974
976 975
977 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { 976 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) {
978 const ODPI odpi = GetParam(); 977 const ODPI odpi = GetParam();
979 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 978 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
980 MLabel a, b; 979 RawMachineLabel a, b;
981 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); 980 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1));
982 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); 981 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b);
983 m.Bind(&a); 982 m.Bind(&a);
984 m.Return(m.Projection(0, n)); 983 m.Return(m.Projection(0, n));
985 m.Bind(&b); 984 m.Bind(&b);
986 m.Return(m.Int32Constant(0)); 985 m.Return(m.Int32Constant(0));
987 Stream s = m.Build(); 986 Stream s = m.Build();
988 ASSERT_EQ(1U, s.size()); 987 ASSERT_EQ(1U, s.size());
989 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); 988 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode());
990 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); 989 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode());
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 EXPECT_EQ(kArmClz, s[0]->arch_opcode()); 2779 EXPECT_EQ(kArmClz, s[0]->arch_opcode());
2781 ASSERT_EQ(1U, s[0]->InputCount()); 2780 ASSERT_EQ(1U, s[0]->InputCount());
2782 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 2781 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2783 ASSERT_EQ(1U, s[0]->OutputCount()); 2782 ASSERT_EQ(1U, s[0]->OutputCount());
2784 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 2783 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
2785 } 2784 }
2786 2785
2787 } // namespace compiler 2786 } // namespace compiler
2788 } // namespace internal 2787 } // namespace internal
2789 } // namespace v8 2788 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-native-calls.cc ('k') | test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698