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 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 kMachFloat64}, | 213 kMachFloat64}, |
214 {&RawMachineAssembler::Float64Mul, "Float64Mul", kArm64Float64Mul, | 214 {&RawMachineAssembler::Float64Mul, "Float64Mul", kArm64Float64Mul, |
215 kMachFloat64}, | 215 kMachFloat64}, |
216 {&RawMachineAssembler::Float64Div, "Float64Div", kArm64Float64Div, | 216 {&RawMachineAssembler::Float64Div, "Float64Div", kArm64Float64Div, |
217 kMachFloat64}}; | 217 kMachFloat64}}; |
218 | 218 |
219 | 219 |
220 struct FPCmp { | 220 struct FPCmp { |
221 MachInst2 mi; | 221 MachInst2 mi; |
222 FlagsCondition cond; | 222 FlagsCondition cond; |
| 223 FlagsCondition commuted_cond; |
223 }; | 224 }; |
224 | 225 |
225 | 226 |
226 std::ostream& operator<<(std::ostream& os, const FPCmp& cmp) { | 227 std::ostream& operator<<(std::ostream& os, const FPCmp& cmp) { |
227 return os << cmp.mi; | 228 return os << cmp.mi; |
228 } | 229 } |
229 | 230 |
230 | 231 |
231 // ARM64 FP comparison instructions. | 232 // ARM64 FP comparison instructions. |
232 const FPCmp kFPCmpInstructions[] = { | 233 const FPCmp kFPCmpInstructions[] = { |
233 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kArm64Float64Cmp, | 234 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kArm64Float64Cmp, |
234 kMachFloat64}, | 235 kMachFloat64}, |
235 kEqual}, | 236 kEqual, kEqual}, |
236 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", | 237 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", |
237 kArm64Float64Cmp, kMachFloat64}, | 238 kArm64Float64Cmp, kMachFloat64}, |
238 kFloatLessThan}, | 239 kFloatLessThan, kFloatGreaterThan}, |
239 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", | 240 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", |
240 kArm64Float64Cmp, kMachFloat64}, | 241 kArm64Float64Cmp, kMachFloat64}, |
241 kFloatLessThanOrEqual}, | 242 kFloatLessThanOrEqual, kFloatGreaterThanOrEqual}, |
242 {{&RawMachineAssembler::Float32Equal, "Float32Equal", kArm64Float32Cmp, | 243 {{&RawMachineAssembler::Float32Equal, "Float32Equal", kArm64Float32Cmp, |
243 kMachFloat32}, | 244 kMachFloat32}, |
244 kEqual}, | 245 kEqual, kEqual}, |
245 {{&RawMachineAssembler::Float32LessThan, "Float32LessThan", | 246 {{&RawMachineAssembler::Float32LessThan, "Float32LessThan", |
246 kArm64Float32Cmp, kMachFloat32}, | 247 kArm64Float32Cmp, kMachFloat32}, |
247 kFloatLessThan}, | 248 kFloatLessThan, kFloatGreaterThan}, |
248 {{&RawMachineAssembler::Float32LessThanOrEqual, "Float32LessThanOrEqual", | 249 {{&RawMachineAssembler::Float32LessThanOrEqual, "Float32LessThanOrEqual", |
249 kArm64Float32Cmp, kMachFloat32}, | 250 kArm64Float32Cmp, kMachFloat32}, |
250 kFloatLessThanOrEqual}}; | 251 kFloatLessThanOrEqual, kFloatGreaterThanOrEqual}}; |
251 | 252 |
252 | 253 |
253 struct Conversion { | 254 struct Conversion { |
254 // The machine_type field in MachInst1 represents the destination type. | 255 // The machine_type field in MachInst1 represents the destination type. |
255 MachInst1 mi; | 256 MachInst1 mi; |
256 MachineType src_machine_type; | 257 MachineType src_machine_type; |
257 }; | 258 }; |
258 | 259 |
259 | 260 |
260 std::ostream& operator<<(std::ostream& os, const Conversion& conv) { | 261 std::ostream& operator<<(std::ostream& os, const Conversion& conv) { |
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 } else { | 1947 } else { |
1947 m.Return((m.*cmp.mi.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); | 1948 m.Return((m.*cmp.mi.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); |
1948 } | 1949 } |
1949 Stream s = m.Build(); | 1950 Stream s = m.Build(); |
1950 ASSERT_EQ(1U, s.size()); | 1951 ASSERT_EQ(1U, s.size()); |
1951 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); | 1952 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); |
1952 EXPECT_EQ(2U, s[0]->InputCount()); | 1953 EXPECT_EQ(2U, s[0]->InputCount()); |
1953 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 1954 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
1954 EXPECT_EQ(1U, s[0]->OutputCount()); | 1955 EXPECT_EQ(1U, s[0]->OutputCount()); |
1955 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1956 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1956 EXPECT_EQ(CommuteFlagsCondition(cmp.cond), s[0]->flags_condition()); | 1957 EXPECT_EQ(cmp.commuted_cond, s[0]->flags_condition()); |
1957 } | 1958 } |
1958 | 1959 |
1959 | 1960 |
1960 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest, | 1961 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFPCmpTest, |
1961 ::testing::ValuesIn(kFPCmpInstructions)); | 1962 ::testing::ValuesIn(kFPCmpInstructions)); |
1962 | 1963 |
1963 | 1964 |
1964 // ----------------------------------------------------------------------------- | 1965 // ----------------------------------------------------------------------------- |
1965 // Conversions. | 1966 // Conversions. |
1966 | 1967 |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3049 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); | 3050 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); |
3050 ASSERT_EQ(1U, s[0]->InputCount()); | 3051 ASSERT_EQ(1U, s[0]->InputCount()); |
3051 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 3052 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
3052 ASSERT_EQ(1U, s[0]->OutputCount()); | 3053 ASSERT_EQ(1U, s[0]->OutputCount()); |
3053 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 3054 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
3054 } | 3055 } |
3055 | 3056 |
3056 } // namespace compiler | 3057 } // namespace compiler |
3057 } // namespace internal | 3058 } // namespace internal |
3058 } // namespace v8 | 3059 } // namespace v8 |
OLD | NEW |