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 "src/compiler/instruction-selector-unittest.h" | 5 #include "src/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
11 // ----------------------------------------------------------------------------- | 11 // ----------------------------------------------------------------------------- |
12 // Conversions. | 12 // Conversions. |
13 | 13 |
14 | 14 |
| 15 TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { |
| 16 StreamBuilder m(this, kMachFloat32, kMachFloat64); |
| 17 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); |
| 18 Stream s = m.Build(); |
| 19 ASSERT_EQ(1U, s.size()); |
| 20 EXPECT_EQ(kSSECvtss2sd, s[0]->arch_opcode()); |
| 21 EXPECT_EQ(1U, s[0]->InputCount()); |
| 22 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 23 } |
| 24 |
| 25 |
15 TEST_F(InstructionSelectorTest, ChangeInt32ToInt64WithParameter) { | 26 TEST_F(InstructionSelectorTest, ChangeInt32ToInt64WithParameter) { |
16 StreamBuilder m(this, kMachInt64, kMachInt32); | 27 StreamBuilder m(this, kMachInt64, kMachInt32); |
17 m.Return(m.ChangeInt32ToInt64(m.Parameter(0))); | 28 m.Return(m.ChangeInt32ToInt64(m.Parameter(0))); |
18 Stream s = m.Build(); | 29 Stream s = m.Build(); |
19 ASSERT_EQ(1U, s.size()); | 30 ASSERT_EQ(1U, s.size()); |
20 EXPECT_EQ(kX64Movsxlq, s[0]->arch_opcode()); | 31 EXPECT_EQ(kX64Movsxlq, s[0]->arch_opcode()); |
21 } | 32 } |
22 | 33 |
23 | 34 |
24 TEST_F(InstructionSelectorTest, ChangeUint32ToUint64WithParameter) { | 35 TEST_F(InstructionSelectorTest, ChangeUint32ToUint64WithParameter) { |
25 StreamBuilder m(this, kMachUint64, kMachUint32); | 36 StreamBuilder m(this, kMachUint64, kMachUint32); |
26 m.Return(m.ChangeUint32ToUint64(m.Parameter(0))); | 37 m.Return(m.ChangeUint32ToUint64(m.Parameter(0))); |
27 Stream s = m.Build(); | 38 Stream s = m.Build(); |
28 ASSERT_EQ(1U, s.size()); | 39 ASSERT_EQ(1U, s.size()); |
29 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); | 40 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); |
30 } | 41 } |
31 | 42 |
32 | 43 |
| 44 TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { |
| 45 StreamBuilder m(this, kMachFloat64, kMachFloat32); |
| 46 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); |
| 47 Stream s = m.Build(); |
| 48 ASSERT_EQ(1U, s.size()); |
| 49 EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode()); |
| 50 EXPECT_EQ(1U, s[0]->InputCount()); |
| 51 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 52 } |
| 53 |
| 54 |
33 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) { | 55 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) { |
34 StreamBuilder m(this, kMachInt32, kMachInt64); | 56 StreamBuilder m(this, kMachInt32, kMachInt64); |
35 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); | 57 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); |
36 Stream s = m.Build(); | 58 Stream s = m.Build(); |
37 ASSERT_EQ(1U, s.size()); | 59 ASSERT_EQ(1U, s.size()); |
38 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); | 60 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); |
39 } | 61 } |
40 | 62 |
41 | 63 |
42 // ----------------------------------------------------------------------------- | 64 // ----------------------------------------------------------------------------- |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 124 } |
103 | 125 |
104 | 126 |
105 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 127 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
106 InstructionSelectorMemoryAccessTest, | 128 InstructionSelectorMemoryAccessTest, |
107 ::testing::ValuesIn(kMemoryAccesses)); | 129 ::testing::ValuesIn(kMemoryAccesses)); |
108 | 130 |
109 } // namespace compiler | 131 } // namespace compiler |
110 } // namespace internal | 132 } // namespace internal |
111 } // namespace v8 | 133 } // namespace v8 |
OLD | NEW |