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

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

Issue 636543002: [turbofan] fix vreg mapping for instruction selector tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "test/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 89 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
90 Node* param1 = m.Parameter(0); 90 Node* param1 = m.Parameter(0);
91 Node* param2 = m.Parameter(1); 91 Node* param2 = m.Parameter(1);
92 Node* add = m.Int32Add(param1, param2); 92 Node* add = m.Int32Add(param1, param2);
93 m.Return(m.Int32Add(add, param1)); 93 m.Return(m.Int32Add(add, param1));
94 Stream s = m.Build(); 94 Stream s = m.Build();
95 ASSERT_EQ(2U, s.size()); 95 ASSERT_EQ(2U, s.size());
96 EXPECT_EQ(kX64Add32, s[0]->arch_opcode()); 96 EXPECT_EQ(kX64Add32, s[0]->arch_opcode());
97 ASSERT_EQ(2U, s[0]->InputCount()); 97 ASSERT_EQ(2U, s[0]->InputCount());
98 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); 98 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
99 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); 99 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0)));
100 } 100 }
101 101
102 102
103 TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { 103 TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) {
104 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 104 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
105 Node* param1 = m.Parameter(0); 105 Node* param1 = m.Parameter(0);
106 Node* param2 = m.Parameter(1); 106 Node* param2 = m.Parameter(1);
107 Node* mul = m.Int32Mul(param1, param2); 107 Node* mul = m.Int32Mul(param1, param2);
108 m.Return(m.Int32Mul(mul, param1)); 108 m.Return(m.Int32Mul(mul, param1));
109 Stream s = m.Build(); 109 Stream s = m.Build();
110 ASSERT_EQ(2U, s.size()); 110 ASSERT_EQ(2U, s.size());
111 EXPECT_EQ(kX64Imul32, s[0]->arch_opcode()); 111 EXPECT_EQ(kX64Imul32, s[0]->arch_opcode());
112 ASSERT_EQ(2U, s[0]->InputCount()); 112 ASSERT_EQ(2U, s[0]->InputCount());
113 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); 113 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
114 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); 114 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0)));
115 } 115 }
116 116
117 117
118 // ----------------------------------------------------------------------------- 118 // -----------------------------------------------------------------------------
119 // Loads and stores 119 // Loads and stores
120 120
121 namespace { 121 namespace {
122 122
123 struct MemoryAccess { 123 struct MemoryAccess {
124 MachineType type; 124 MachineType type;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 Stream s = m.Build(); 408 Stream s = m.Build();
409 ASSERT_EQ(1U, s.size()); 409 ASSERT_EQ(1U, s.size());
410 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode()); 410 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode());
411 if (m_param.lea_expected) { 411 if (m_param.lea_expected) {
412 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode()); 412 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
413 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount()); 413 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount());
414 } else { 414 } else {
415 EXPECT_EQ(kX64Imul32, s[0]->arch_opcode()); 415 EXPECT_EQ(kX64Imul32, s[0]->arch_opcode());
416 ASSERT_EQ(2U, s[0]->InputCount()); 416 ASSERT_EQ(2U, s[0]->InputCount());
417 } 417 }
418 EXPECT_EQ(param->id(), s.ToVreg(s[0]->InputAt(0))); 418 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->InputAt(0)));
419 } 419 }
420 420
421 421
422 TEST_P(InstructionSelectorMultTest, Mult64) { 422 TEST_P(InstructionSelectorMultTest, Mult64) {
423 const MultParam m_param = GetParam(); 423 const MultParam m_param = GetParam();
424 StreamBuilder m(this, kMachInt64, kMachInt64); 424 StreamBuilder m(this, kMachInt64, kMachInt64);
425 Node* param = m.Parameter(0); 425 Node* param = m.Parameter(0);
426 Node* mult = m.Int64Mul(param, m.Int64Constant(m_param.value)); 426 Node* mult = m.Int64Mul(param, m.Int64Constant(m_param.value));
427 m.Return(mult); 427 m.Return(mult);
428 Stream s = m.Build(); 428 Stream s = m.Build();
429 ASSERT_EQ(1U, s.size()); 429 ASSERT_EQ(1U, s.size());
430 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode()); 430 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode());
431 if (m_param.lea_expected) { 431 if (m_param.lea_expected) {
432 EXPECT_EQ(kX64Lea, s[0]->arch_opcode()); 432 EXPECT_EQ(kX64Lea, s[0]->arch_opcode());
433 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount()); 433 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount());
434 EXPECT_EQ(param->id(), s.ToVreg(s[0]->InputAt(0))); 434 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->InputAt(0)));
435 } else { 435 } else {
436 EXPECT_EQ(kX64Imul, s[0]->arch_opcode()); 436 EXPECT_EQ(kX64Imul, s[0]->arch_opcode());
437 ASSERT_EQ(2U, s[0]->InputCount()); 437 ASSERT_EQ(2U, s[0]->InputCount());
438 // TODO(dcarney): why is this happening? 438 // TODO(dcarney): why is this happening?
439 EXPECT_EQ(param->id(), s.ToVreg(s[0]->InputAt(1))); 439 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->InputAt(1)));
440 } 440 }
441 } 441 }
442 442
443 443
444 TEST_P(InstructionSelectorMultTest, MultAdd32) { 444 TEST_P(InstructionSelectorMultTest, MultAdd32) {
445 TRACED_FOREACH(int32_t, imm, kImmediates) { 445 TRACED_FOREACH(int32_t, imm, kImmediates) {
446 const MultParam m_param = GetParam(); 446 const MultParam m_param = GetParam();
447 StreamBuilder m(this, kMachInt32, kMachInt32); 447 StreamBuilder m(this, kMachInt32, kMachInt32);
448 Node* param = m.Parameter(0); 448 Node* param = m.Parameter(0);
449 Node* mult = m.Int32Add(m.Int32Mul(param, m.Int32Constant(m_param.value)), 449 Node* mult = m.Int32Add(m.Int32Mul(param, m.Int32Constant(m_param.value)),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 494 }
495 } 495 }
496 496
497 497
498 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest, 498 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest,
499 ::testing::ValuesIn(kMultParams)); 499 ::testing::ValuesIn(kMultParams));
500 500
501 } // namespace compiler 501 } // namespace compiler
502 } // namespace internal 502 } // namespace internal
503 } // namespace v8 503 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698