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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 TEST_F(Int64LoweringTest, Int64Load) { | 126 TEST_F(Int64LoweringTest, Int64Load) { |
127 int32_t base = 0x1234; | 127 int32_t base = 0x1234; |
128 int32_t index = 0x5678; | 128 int32_t index = 0x5678; |
129 | 129 |
130 LowerGraph(graph()->NewNode(machine()->Load(MachineType::Int64()), | 130 LowerGraph(graph()->NewNode(machine()->Load(MachineType::Int64()), |
131 Int32Constant(base), Int32Constant(index), | 131 Int32Constant(base), Int32Constant(index), |
132 start(), start()), | 132 start(), start()), |
133 MachineRepresentation::kWord64); | 133 MachineRepresentation::kWord64); |
134 | 134 |
135 Capture<Node*> high_word_load; | 135 Capture<Node*> high_word_load; |
| 136 #if defined(V8_TARGET_LITTLE_ENDIAN) |
136 Matcher<Node*> high_word_load_matcher = | 137 Matcher<Node*> high_word_load_matcher = |
137 IsLoad(MachineType::Int32(), IsInt32Constant(base), | 138 IsLoad(MachineType::Int32(), IsInt32Constant(base), |
138 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), start(), | 139 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), start(), |
139 start()); | 140 start()); |
140 | 141 |
141 EXPECT_THAT( | 142 EXPECT_THAT( |
142 graph()->end()->InputAt(1), | 143 graph()->end()->InputAt(1), |
143 IsReturn2(IsLoad(MachineType::Int32(), IsInt32Constant(base), | 144 IsReturn2(IsLoad(MachineType::Int32(), IsInt32Constant(base), |
144 IsInt32Constant(index), AllOf(CaptureEq(&high_word_load), | 145 IsInt32Constant(index), AllOf(CaptureEq(&high_word_load), |
145 high_word_load_matcher), | 146 high_word_load_matcher), |
146 start()), | 147 start()), |
147 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), | 148 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), |
148 start(), start())); | 149 start(), start())); |
| 150 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 151 Matcher<Node*> high_word_load_matcher = |
| 152 IsLoad(MachineType::Int32(), IsInt32Constant(base), |
| 153 IsInt32Constant(index), start(), start()); |
| 154 |
| 155 EXPECT_THAT( |
| 156 graph()->end()->InputAt(1), |
| 157 IsReturn2( |
| 158 IsLoad(MachineType::Int32(), IsInt32Constant(base), |
| 159 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), |
| 160 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), |
| 161 start()), |
| 162 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(), |
| 163 start())); |
| 164 #endif |
149 } | 165 } |
150 | 166 |
151 TEST_F(Int64LoweringTest, Int64Store) { | 167 TEST_F(Int64LoweringTest, Int64Store) { |
152 // We have to build the TF graph explicitly here because Store does not return | 168 // We have to build the TF graph explicitly here because Store does not return |
153 // a value. | 169 // a value. |
154 | 170 |
155 int32_t base = 1111; | 171 int32_t base = 1111; |
156 int32_t index = 2222; | 172 int32_t index = 2222; |
157 int32_t return_value = 0x5555; | 173 int32_t return_value = 0x5555; |
158 | 174 |
(...skipping 11 matching lines...) Expand all Loading... |
170 | 186 |
171 NodeProperties::MergeControlToEnd(graph(), common(), ret); | 187 NodeProperties::MergeControlToEnd(graph(), common(), ret); |
172 | 188 |
173 Int64Lowering lowering(graph(), machine(), common(), zone(), | 189 Int64Lowering lowering(graph(), machine(), common(), zone(), |
174 sig_builder.Build()); | 190 sig_builder.Build()); |
175 lowering.LowerGraph(); | 191 lowering.LowerGraph(); |
176 | 192 |
177 const StoreRepresentation rep(MachineRepresentation::kWord32, | 193 const StoreRepresentation rep(MachineRepresentation::kWord32, |
178 kNoWriteBarrier); | 194 kNoWriteBarrier); |
179 | 195 |
| 196 #if defined(V8_TARGET_LITTLE_ENDIAN) |
180 EXPECT_THAT( | 197 EXPECT_THAT( |
181 graph()->end()->InputAt(1), | 198 graph()->end()->InputAt(1), |
182 IsReturn( | 199 IsReturn( |
183 IsInt32Constant(return_value), | 200 IsInt32Constant(return_value), |
184 IsStore( | 201 IsStore( |
185 rep, IsInt32Constant(base), IsInt32Constant(index), | 202 rep, IsInt32Constant(base), IsInt32Constant(index), |
186 IsInt32Constant(low_word_value(0)), | 203 IsInt32Constant(low_word_value(0)), |
187 IsStore(rep, IsInt32Constant(base), | 204 IsStore(rep, IsInt32Constant(base), |
188 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), | 205 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), |
189 IsInt32Constant(high_word_value(0)), start(), start()), | 206 IsInt32Constant(high_word_value(0)), start(), start()), |
190 start()), | 207 start()), |
191 start())); | 208 start())); |
| 209 #elif defined(V8_TARGET_BIG_ENDIAN) |
| 210 EXPECT_THAT( |
| 211 graph()->end()->InputAt(1), |
| 212 IsReturn( |
| 213 IsInt32Constant(return_value), |
| 214 IsStore( |
| 215 rep, IsInt32Constant(base), |
| 216 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), |
| 217 IsInt32Constant(low_word_value(0)), |
| 218 IsStore(rep, IsInt32Constant(base), IsInt32Constant(index), |
| 219 IsInt32Constant(high_word_value(0)), start(), start()), |
| 220 start()), |
| 221 start())); |
| 222 #endif |
192 } | 223 } |
193 | 224 |
194 TEST_F(Int64LoweringTest, Int64And) { | 225 TEST_F(Int64LoweringTest, Int64And) { |
195 LowerGraph(graph()->NewNode(machine()->Word64And(), Int64Constant(value(0)), | 226 LowerGraph(graph()->NewNode(machine()->Word64And(), Int64Constant(value(0)), |
196 Int64Constant(value(1))), | 227 Int64Constant(value(1))), |
197 MachineRepresentation::kWord64); | 228 MachineRepresentation::kWord64); |
198 EXPECT_THAT(graph()->end()->InputAt(1), | 229 EXPECT_THAT(graph()->end()->InputAt(1), |
199 IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)), | 230 IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)), |
200 IsInt32Constant(low_word_value(1))), | 231 IsInt32Constant(low_word_value(1))), |
201 IsWord32And(IsInt32Constant(high_word_value(0)), | 232 IsWord32And(IsInt32Constant(high_word_value(0)), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 550 |
520 Capture<Node*> stack_slot_capture; | 551 Capture<Node*> stack_slot_capture; |
521 Matcher<Node*> stack_slot_matcher = | 552 Matcher<Node*> stack_slot_matcher = |
522 IsStackSlot(MachineRepresentation::kWord64); | 553 IsStackSlot(MachineRepresentation::kWord64); |
523 | 554 |
524 Capture<Node*> store_capture; | 555 Capture<Node*> store_capture; |
525 Matcher<Node*> store_matcher = | 556 Matcher<Node*> store_matcher = |
526 IsStore(StoreRepresentation(MachineRepresentation::kWord32, | 557 IsStore(StoreRepresentation(MachineRepresentation::kWord32, |
527 WriteBarrierKind::kNoWriteBarrier), | 558 WriteBarrierKind::kNoWriteBarrier), |
528 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), | 559 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), |
529 IsInt32Constant(0), IsInt32Constant(low_word_value(0)), | 560 IsInt32Constant(Int64Lowering::kLowerWordOffset), |
| 561 IsInt32Constant(low_word_value(0)), |
530 IsStore(StoreRepresentation(MachineRepresentation::kWord32, | 562 IsStore(StoreRepresentation(MachineRepresentation::kWord32, |
531 WriteBarrierKind::kNoWriteBarrier), | 563 WriteBarrierKind::kNoWriteBarrier), |
532 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), | 564 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), |
533 IsInt32Constant(4), IsInt32Constant(high_word_value(0)), | 565 IsInt32Constant(Int64Lowering::kHigherWordOffset), |
534 start(), start()), | 566 IsInt32Constant(high_word_value(0)), start(), start()), |
535 start()); | 567 start()); |
536 | 568 |
537 EXPECT_THAT( | 569 EXPECT_THAT( |
538 graph()->end()->InputAt(1), | 570 graph()->end()->InputAt(1), |
539 IsReturn(IsLoad(MachineType::Float64(), | 571 IsReturn(IsLoad(MachineType::Float64(), |
540 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), | 572 AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher), |
541 IsInt32Constant(0), | 573 IsInt32Constant(0), |
542 AllOf(CaptureEq(&store_capture), store_matcher), start()), | 574 AllOf(CaptureEq(&store_capture), store_matcher), start()), |
543 start(), start())); | 575 start(), start())); |
544 } | 576 } |
(...skipping 11 matching lines...) Expand all Loading... |
556 Matcher<Node*> store_matcher = IsStore( | 588 Matcher<Node*> store_matcher = IsStore( |
557 StoreRepresentation(MachineRepresentation::kFloat64, | 589 StoreRepresentation(MachineRepresentation::kFloat64, |
558 WriteBarrierKind::kNoWriteBarrier), | 590 WriteBarrierKind::kNoWriteBarrier), |
559 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), IsInt32Constant(0), | 591 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), IsInt32Constant(0), |
560 IsFloat64Constant(bit_cast<double>(value(0))), start(), start()); | 592 IsFloat64Constant(bit_cast<double>(value(0))), start(), start()); |
561 | 593 |
562 EXPECT_THAT( | 594 EXPECT_THAT( |
563 graph()->end()->InputAt(1), | 595 graph()->end()->InputAt(1), |
564 IsReturn2(IsLoad(MachineType::Int32(), | 596 IsReturn2(IsLoad(MachineType::Int32(), |
565 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), | 597 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), |
566 IsInt32Constant(0), | 598 IsInt32Constant(Int64Lowering::kLowerWordOffset), |
567 AllOf(CaptureEq(&store), store_matcher), start()), | 599 AllOf(CaptureEq(&store), store_matcher), start()), |
568 IsLoad(MachineType::Int32(), | 600 IsLoad(MachineType::Int32(), |
569 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), | 601 AllOf(CaptureEq(&stack_slot), stack_slot_matcher), |
570 IsInt32Constant(0x4), | 602 IsInt32Constant(Int64Lowering::kHigherWordOffset), |
571 AllOf(CaptureEq(&store), store_matcher), start()), | 603 AllOf(CaptureEq(&store), store_matcher), start()), |
572 start(), start())); | 604 start(), start())); |
573 } | 605 } |
574 | 606 |
575 TEST_F(Int64LoweringTest, I64Clz) { | 607 TEST_F(Int64LoweringTest, I64Clz) { |
576 LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))), | 608 LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))), |
577 MachineRepresentation::kWord64); | 609 MachineRepresentation::kWord64); |
578 | 610 |
579 Capture<Node*> branch_capture; | 611 Capture<Node*> branch_capture; |
580 Matcher<Node*> branch_matcher = IsBranch( | 612 Matcher<Node*> branch_matcher = IsBranch( |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 Float32Constant(2.5)); | 815 Float32Constant(2.5)); |
784 } | 816 } |
785 | 817 |
786 TEST_F(Int64LoweringTest, I64PhiWord32) { | 818 TEST_F(Int64LoweringTest, I64PhiWord32) { |
787 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), | 819 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), |
788 Float32Constant(2)); | 820 Float32Constant(2)); |
789 } | 821 } |
790 } // namespace compiler | 822 } // namespace compiler |
791 } // namespace internal | 823 } // namespace internal |
792 } // namespace v8 | 824 } // namespace v8 |
OLD | NEW |