| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
| 6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 int64_t value(int i) { return value_[i]; } | 79 int64_t value(int i) { return value_[i]; } |
| 80 | 80 |
| 81 int32_t low_word_value(int i) { | 81 int32_t low_word_value(int i) { |
| 82 return static_cast<int32_t>(value_[i] & 0xffffffff); | 82 return static_cast<int32_t>(value_[i] & 0xffffffff); |
| 83 } | 83 } |
| 84 | 84 |
| 85 int32_t high_word_value(int i) { | 85 int32_t high_word_value(int i) { |
| 86 return static_cast<int32_t>(value_[i] >> 32); | 86 return static_cast<int32_t>(value_[i] >> 32); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void TestComparison( |
| 90 const Operator* op, |
| 91 Matcher<Node*> (*high_word_matcher)(const Matcher<Node*>& lhs_matcher, |
| 92 const Matcher<Node*>& rhs_matcher), |
| 93 Matcher<Node*> (*low_word_matcher)(const Matcher<Node*>& lhs_matcher, |
| 94 const Matcher<Node*>& rhs_matcher)) { |
| 95 LowerGraph( |
| 96 graph()->NewNode(op, Int64Constant(value(0)), Int64Constant(value(1))), |
| 97 MachineRepresentation::kWord32); |
| 98 EXPECT_THAT( |
| 99 graph()->end()->InputAt(1), |
| 100 IsReturn(IsWord32Or( |
| 101 high_word_matcher(IsInt32Constant(high_word_value(0)), |
| 102 IsInt32Constant(high_word_value(1))), |
| 103 IsWord32And( |
| 104 IsWord32Equal(IsInt32Constant(high_word_value(0)), |
| 105 IsInt32Constant(high_word_value(1))), |
| 106 low_word_matcher(IsInt32Constant(low_word_value(0)), |
| 107 IsInt32Constant(low_word_value(1))))), |
| 108 start(), start())); |
| 109 } |
| 110 |
| 89 private: | 111 private: |
| 90 MachineOperatorBuilder machine_; | 112 MachineOperatorBuilder machine_; |
| 91 int64_t value_[3]; | 113 int64_t value_[3]; |
| 92 }; | 114 }; |
| 93 | 115 |
| 94 TEST_F(Int64LoweringTest, Int64Constant) { | 116 TEST_F(Int64LoweringTest, Int64Constant) { |
| 95 if (4 != kPointerSize) return; | 117 if (4 != kPointerSize) return; |
| 96 | 118 |
| 97 LowerGraph(Int64Constant(value(0)), MachineRepresentation::kWord64); | 119 LowerGraph(Int64Constant(value(0)), MachineRepresentation::kWord64); |
| 98 EXPECT_THAT(graph()->end()->InputAt(1), | 120 EXPECT_THAT(graph()->end()->InputAt(1), |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)), | 371 IsWord32Or(IsWord32Xor(IsInt32Constant(low_word_value(0)), |
| 350 IsInt32Constant(low_word_value(1))), | 372 IsInt32Constant(low_word_value(1))), |
| 351 IsWord32Xor(IsInt32Constant(high_word_value(0)), | 373 IsWord32Xor(IsInt32Constant(high_word_value(0)), |
| 352 IsInt32Constant(high_word_value(1)))), | 374 IsInt32Constant(high_word_value(1)))), |
| 353 IsInt32Constant(0)), | 375 IsInt32Constant(0)), |
| 354 start(), start())); | 376 start(), start())); |
| 355 } | 377 } |
| 356 | 378 |
| 357 // kExprI64Ne: | 379 // kExprI64Ne: |
| 358 // kExprI64LtS: | 380 // kExprI64LtS: |
| 381 TEST_F(Int64LoweringTest, Int64LtS) { |
| 382 if (4 != kPointerSize) return; |
| 383 TestComparison(machine()->Int64LessThan(), IsInt32LessThan, IsUint32LessThan); |
| 384 } |
| 359 // kExprI64LeS: | 385 // kExprI64LeS: |
| 386 TEST_F(Int64LoweringTest, Int64LeS) { |
| 387 if (4 != kPointerSize) return; |
| 388 TestComparison(machine()->Int64LessThanOrEqual(), IsInt32LessThan, |
| 389 IsUint32LessThanOrEqual); |
| 390 } |
| 360 // kExprI64LtU: | 391 // kExprI64LtU: |
| 392 TEST_F(Int64LoweringTest, Int64LtU) { |
| 393 if (4 != kPointerSize) return; |
| 394 TestComparison(machine()->Uint64LessThan(), IsUint32LessThan, |
| 395 IsUint32LessThan); |
| 396 } |
| 361 // kExprI64LeU: | 397 // kExprI64LeU: |
| 362 // kExprI64GtS: | 398 TEST_F(Int64LoweringTest, Int64LeU) { |
| 363 // kExprI64GeS: | 399 if (4 != kPointerSize) return; |
| 364 // kExprI64GtU: | 400 TestComparison(machine()->Uint64LessThanOrEqual(), IsUint32LessThan, |
| 365 // kExprI64GeU: | 401 IsUint32LessThanOrEqual); |
| 402 } |
| 366 | 403 |
| 367 // kExprI32ConvertI64: | 404 // kExprI32ConvertI64: |
| 368 // kExprI64SConvertI32: | 405 // kExprI64SConvertI32: |
| 369 // kExprI64UConvertI32: | 406 // kExprI64UConvertI32: |
| 370 | 407 |
| 371 // kExprF64ReinterpretI64: | 408 // kExprF64ReinterpretI64: |
| 372 // kExprI64ReinterpretF64: | 409 // kExprI64ReinterpretF64: |
| 373 | 410 |
| 374 // kExprI64Clz: | 411 // kExprI64Clz: |
| 375 // kExprI64Ctz: | 412 // kExprI64Ctz: |
| 376 // kExprI64Popcnt: | 413 // kExprI64Popcnt: |
| 377 | 414 |
| 378 // kExprF32SConvertI64: | 415 // kExprF32SConvertI64: |
| 379 // kExprF32UConvertI64: | 416 // kExprF32UConvertI64: |
| 380 // kExprF64SConvertI64: | 417 // kExprF64SConvertI64: |
| 381 // kExprF64UConvertI64: | 418 // kExprF64UConvertI64: |
| 382 // kExprI64SConvertF32: | 419 // kExprI64SConvertF32: |
| 383 // kExprI64SConvertF64: | 420 // kExprI64SConvertF64: |
| 384 // kExprI64UConvertF32: | 421 // kExprI64UConvertF32: |
| 385 // kExprI64UConvertF64: | 422 // kExprI64UConvertF64: |
| 386 | 423 |
| 387 } // namespace compiler | 424 } // namespace compiler |
| 388 } // namespace internal | 425 } // namespace internal |
| 389 } // namespace v8 | 426 } // namespace v8 |
| OLD | NEW |