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 "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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 m.Return(ret); | 1127 m.Return(ret); |
1128 Stream s = m.Build(); | 1128 Stream s = m.Build(); |
1129 ASSERT_EQ(4U, s.size()); | 1129 ASSERT_EQ(4U, s.size()); |
1130 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); | 1130 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); |
1131 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); | 1131 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); |
1132 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); | 1132 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); |
1133 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); | 1133 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); |
1134 } | 1134 } |
1135 } | 1135 } |
1136 | 1136 |
1137 | |
1138 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { | |
1139 { | |
1140 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); | |
1141 Node* const p0 = m.Parameter(0); | |
1142 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | |
1143 m.Return(n); | |
1144 Stream s = m.Build(); | |
1145 ASSERT_EQ(1U, s.size()); | |
1146 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode()); | |
1147 ASSERT_EQ(1U, s[0]->InputCount()); | |
1148 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
1149 ASSERT_EQ(1U, s[0]->OutputCount()); | |
1150 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
1151 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
1152 } | |
1153 { | |
1154 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); | |
1155 Node* const p0 = m.Parameter(0); | |
1156 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | |
1157 m.Return(n); | |
1158 Stream s = m.Build(AVX); | |
1159 ASSERT_EQ(1U, s.size()); | |
1160 EXPECT_EQ(kAVXFloat32Neg, s[0]->arch_opcode()); | |
1161 ASSERT_EQ(1U, s[0]->InputCount()); | |
1162 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
1163 ASSERT_EQ(1U, s[0]->OutputCount()); | |
1164 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
1165 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
1166 } | |
1167 } | |
1168 | |
1169 | |
1170 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { | |
1171 { | |
1172 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); | |
1173 Node* const p0 = m.Parameter(0); | |
1174 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | |
1175 m.Return(n); | |
1176 Stream s = m.Build(); | |
1177 ASSERT_EQ(1U, s.size()); | |
1178 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); | |
1179 ASSERT_EQ(1U, s[0]->InputCount()); | |
1180 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
1181 ASSERT_EQ(1U, s[0]->OutputCount()); | |
1182 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
1183 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
1184 } | |
1185 { | |
1186 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); | |
1187 Node* const p0 = m.Parameter(0); | |
1188 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | |
1189 m.Return(n); | |
1190 Stream s = m.Build(AVX); | |
1191 ASSERT_EQ(1U, s.size()); | |
1192 EXPECT_EQ(kAVXFloat64Neg, s[0]->arch_opcode()); | |
1193 ASSERT_EQ(1U, s[0]->InputCount()); | |
1194 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
1195 ASSERT_EQ(1U, s[0]->OutputCount()); | |
1196 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
1197 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
1198 } | |
1199 } | |
1200 | |
1201 | |
1202 // ----------------------------------------------------------------------------- | 1137 // ----------------------------------------------------------------------------- |
1203 // Miscellaneous. | 1138 // Miscellaneous. |
1204 | 1139 |
1205 | 1140 |
1206 TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { | 1141 TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { |
1207 StreamBuilder m(this, MachineType::Bool()); | 1142 StreamBuilder m(this, MachineType::Bool()); |
1208 Node* const sl = m.Load( | 1143 Node* const sl = m.Load( |
1209 MachineType::Pointer(), | 1144 MachineType::Pointer(), |
1210 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); | 1145 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); |
1211 Node* const sp = m.LoadStackPointer(); | 1146 Node* const sp = m.LoadStackPointer(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); | 1265 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); |
1331 ASSERT_EQ(1U, s[0]->InputCount()); | 1266 ASSERT_EQ(1U, s[0]->InputCount()); |
1332 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1267 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1333 ASSERT_EQ(1U, s[0]->OutputCount()); | 1268 ASSERT_EQ(1U, s[0]->OutputCount()); |
1334 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1269 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1335 } | 1270 } |
1336 | 1271 |
1337 } // namespace compiler | 1272 } // namespace compiler |
1338 } // namespace internal | 1273 } // namespace internal |
1339 } // namespace v8 | 1274 } // namespace v8 |
OLD | NEW |