| OLD | NEW |
| 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "test/compiler-unittests/instruction-selector-unittest.h" | 7 #include "test/compiler-unittests/instruction-selector-unittest.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 EXPECT_EQ(1U, s[0]->OutputCount()); | 127 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 | 130 |
| 131 TEST_P(InstructionSelectorLogicalTest, Immediate) { | 131 TEST_P(InstructionSelectorLogicalTest, Immediate) { |
| 132 const DPI dpi = GetParam(); | 132 const DPI dpi = GetParam(); |
| 133 const MachineType type = dpi.machine_type; | 133 const MachineType type = dpi.machine_type; |
| 134 // TODO(all): Add support for testing 64-bit immediates. | 134 // TODO(all): Add support for testing 64-bit immediates. |
| 135 if (type == kMachInt32) { | 135 if (type == kMachInt32) { |
| 136 // Immediate on the right. | 136 // Immediate on the right. |
| 137 TRACED_FOREACH(uint32_t, imm, kLogicalImmediates) { | 137 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { |
| 138 StreamBuilder m(this, type, type); | 138 StreamBuilder m(this, type, type); |
| 139 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 139 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 140 Stream s = m.Build(); | 140 Stream s = m.Build(); |
| 141 ASSERT_EQ(1U, s.size()); | 141 ASSERT_EQ(1U, s.size()); |
| 142 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 142 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 143 ASSERT_EQ(2U, s[0]->InputCount()); | 143 ASSERT_EQ(2U, s[0]->InputCount()); |
| 144 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 144 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 145 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 145 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 146 EXPECT_EQ(1U, s[0]->OutputCount()); | 146 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // Immediate on the left; all logical ops should commute. | 149 // Immediate on the left; all logical ops should commute. |
| 150 TRACED_FOREACH(uint32_t, imm, kLogicalImmediates) { | 150 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { |
| 151 StreamBuilder m(this, type, type); | 151 StreamBuilder m(this, type, type); |
| 152 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); | 152 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); |
| 153 Stream s = m.Build(); | 153 Stream s = m.Build(); |
| 154 ASSERT_EQ(1U, s.size()); | 154 ASSERT_EQ(1U, s.size()); |
| 155 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 155 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 156 ASSERT_EQ(2U, s[0]->InputCount()); | 156 ASSERT_EQ(2U, s[0]->InputCount()); |
| 157 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 157 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 159 EXPECT_EQ(1U, s[0]->OutputCount()); | 159 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 160 } | 160 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 StreamBuilder m(this, kMachInt32, kMachInt64); | 294 StreamBuilder m(this, kMachInt32, kMachInt64); |
| 295 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); | 295 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); |
| 296 Stream s = m.Build(); | 296 Stream s = m.Build(); |
| 297 ASSERT_EQ(1U, s.size()); | 297 ASSERT_EQ(1U, s.size()); |
| 298 EXPECT_EQ(kArm64Mov32, s[0]->arch_opcode()); | 298 EXPECT_EQ(kArm64Mov32, s[0]->arch_opcode()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace compiler | 301 } // namespace compiler |
| 302 } // namespace internal | 302 } // namespace internal |
| 303 } // namespace v8 | 303 } // namespace v8 |
| OLD | NEW |