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/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/diamond.h" | 7 #include "src/compiler/diamond.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 common()->Int32Constant(static_cast<int32_t>(value >> 32))); | 110 common()->Int32Constant(static_cast<int32_t>(value >> 32))); |
111 ReplaceNode(node, low_node, high_node); | 111 ReplaceNode(node, low_node, high_node); |
112 break; | 112 break; |
113 } | 113 } |
114 case IrOpcode::kLoad: { | 114 case IrOpcode::kLoad: { |
115 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); | 115 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); |
116 | 116 |
117 if (load_rep.representation() == MachineRepresentation::kWord64) { | 117 if (load_rep.representation() == MachineRepresentation::kWord64) { |
118 Node* base = node->InputAt(0); | 118 Node* base = node->InputAt(0); |
119 Node* index = node->InputAt(1); | 119 Node* index = node->InputAt(1); |
120 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
titzer
2016/06/21 21:22:59
Can you factor this out into a common subroutine?
| |
121 Node* index_low = index; | |
120 Node* index_high = | 122 Node* index_high = |
121 graph()->NewNode(machine()->Int32Add(), index, | 123 graph()->NewNode(machine()->Int32Add(), index, |
122 graph()->NewNode(common()->Int32Constant(4))); | 124 graph()->NewNode(common()->Int32Constant(4))); |
123 | 125 #elif defined(V8_TARGET_BIG_ENDIAN) |
126 Node* index_low = | |
127 graph()->NewNode(machine()->Int32Add(), index, | |
128 graph()->NewNode(common()->Int32Constant(4))); | |
129 Node* index_high = index; | |
130 #endif | |
124 const Operator* load_op = machine()->Load(MachineType::Int32()); | 131 const Operator* load_op = machine()->Load(MachineType::Int32()); |
125 Node* high_node; | 132 Node* high_node; |
126 if (node->InputCount() > 2) { | 133 if (node->InputCount() > 2) { |
127 Node* effect_high = node->InputAt(2); | 134 Node* effect_high = node->InputAt(2); |
128 Node* control_high = node->InputAt(3); | 135 Node* control_high = node->InputAt(3); |
129 high_node = graph()->NewNode(load_op, base, index_high, effect_high, | 136 high_node = graph()->NewNode(load_op, base, index_high, effect_high, |
130 control_high); | 137 control_high); |
131 // change the effect change from old_node --> old_effect to | 138 // change the effect change from old_node --> old_effect to |
132 // old_node --> high_node --> old_effect. | 139 // old_node --> high_node --> old_effect. |
133 node->ReplaceInput(2, high_node); | 140 node->ReplaceInput(2, high_node); |
134 } else { | 141 } else { |
135 high_node = graph()->NewNode(load_op, base, index_high); | 142 high_node = graph()->NewNode(load_op, base, index_high); |
136 } | 143 } |
144 node->ReplaceInput(1, index_low); | |
137 NodeProperties::ChangeOp(node, load_op); | 145 NodeProperties::ChangeOp(node, load_op); |
138 ReplaceNode(node, node, high_node); | 146 ReplaceNode(node, node, high_node); |
139 } else { | 147 } else { |
140 DefaultLowering(node); | 148 DefaultLowering(node); |
141 } | 149 } |
142 break; | 150 break; |
143 } | 151 } |
144 case IrOpcode::kStore: { | 152 case IrOpcode::kStore: { |
145 StoreRepresentation store_rep = StoreRepresentationOf(node->op()); | 153 StoreRepresentation store_rep = StoreRepresentationOf(node->op()); |
146 if (store_rep.representation() == MachineRepresentation::kWord64) { | 154 if (store_rep.representation() == MachineRepresentation::kWord64) { |
147 // We change the original store node to store the low word, and create | 155 // We change the original store node to store the low word, and create |
148 // a new store node to store the high word. The effect and control edges | 156 // a new store node to store the high word. The effect and control edges |
149 // are copied from the original store to the new store node, the effect | 157 // are copied from the original store to the new store node, the effect |
150 // edge of the original store is redirected to the new store. | 158 // edge of the original store is redirected to the new store. |
151 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); | 159 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); |
152 | 160 |
153 Node* base = node->InputAt(0); | 161 Node* base = node->InputAt(0); |
154 Node* index = node->InputAt(1); | 162 Node* index = node->InputAt(1); |
163 #if defined(V8_TARGET_LITTLE_ENDIAN) | |
164 Node* index_low = index; | |
155 Node* index_high = | 165 Node* index_high = |
156 graph()->NewNode(machine()->Int32Add(), index, | 166 graph()->NewNode(machine()->Int32Add(), index, |
157 graph()->NewNode(common()->Int32Constant(4))); | 167 graph()->NewNode(common()->Int32Constant(4))); |
158 | 168 #elif defined(V8_TARGET_BIG_ENDIAN) |
169 Node* index_low = | |
170 graph()->NewNode(machine()->Int32Add(), index, | |
171 graph()->NewNode(common()->Int32Constant(4))); | |
172 Node* index_high = index; | |
173 #endif | |
159 Node* value = node->InputAt(2); | 174 Node* value = node->InputAt(2); |
160 DCHECK(HasReplacementLow(value)); | 175 DCHECK(HasReplacementLow(value)); |
161 DCHECK(HasReplacementHigh(value)); | 176 DCHECK(HasReplacementHigh(value)); |
162 | 177 |
163 const Operator* store_op = machine()->Store(StoreRepresentation( | 178 const Operator* store_op = machine()->Store(StoreRepresentation( |
164 MachineRepresentation::kWord32, write_barrier_kind)); | 179 MachineRepresentation::kWord32, write_barrier_kind)); |
165 | 180 |
166 Node* high_node; | 181 Node* high_node; |
167 if (node->InputCount() > 3) { | 182 if (node->InputCount() > 3) { |
168 Node* effect_high = node->InputAt(3); | 183 Node* effect_high = node->InputAt(3); |
169 Node* control_high = node->InputAt(4); | 184 Node* control_high = node->InputAt(4); |
170 high_node = graph()->NewNode(store_op, base, index_high, | 185 high_node = graph()->NewNode(store_op, base, index_high, |
171 GetReplacementHigh(value), effect_high, | 186 GetReplacementHigh(value), effect_high, |
172 control_high); | 187 control_high); |
173 node->ReplaceInput(3, high_node); | 188 node->ReplaceInput(3, high_node); |
174 | 189 |
175 } else { | 190 } else { |
176 high_node = graph()->NewNode(store_op, base, index_high, | 191 high_node = graph()->NewNode(store_op, base, index_high, |
177 GetReplacementHigh(value)); | 192 GetReplacementHigh(value)); |
178 } | 193 } |
179 | 194 |
195 node->ReplaceInput(1, index_low); | |
180 node->ReplaceInput(2, GetReplacementLow(value)); | 196 node->ReplaceInput(2, GetReplacementLow(value)); |
181 NodeProperties::ChangeOp(node, store_op); | 197 NodeProperties::ChangeOp(node, store_op); |
182 ReplaceNode(node, node, high_node); | 198 ReplaceNode(node, node, high_node); |
183 } else { | 199 } else { |
184 if (HasReplacementLow(node->InputAt(2))) { | 200 if (HasReplacementLow(node->InputAt(2))) { |
185 node->ReplaceInput(2, GetReplacementLow(node->InputAt(2))); | 201 node->ReplaceInput(2, GetReplacementLow(node->InputAt(2))); |
186 } | 202 } |
187 } | 203 } |
188 break; | 204 break; |
189 } | 205 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 case IrOpcode::kBitcastInt64ToFloat64: { | 500 case IrOpcode::kBitcastInt64ToFloat64: { |
485 DCHECK(node->InputCount() == 1); | 501 DCHECK(node->InputCount() == 1); |
486 Node* input = node->InputAt(0); | 502 Node* input = node->InputAt(0); |
487 Node* stack_slot = graph()->NewNode( | 503 Node* stack_slot = graph()->NewNode( |
488 machine()->StackSlot(MachineRepresentation::kWord64)); | 504 machine()->StackSlot(MachineRepresentation::kWord64)); |
489 | 505 |
490 Node* store_high_word = graph()->NewNode( | 506 Node* store_high_word = graph()->NewNode( |
491 machine()->Store( | 507 machine()->Store( |
492 StoreRepresentation(MachineRepresentation::kWord32, | 508 StoreRepresentation(MachineRepresentation::kWord32, |
493 WriteBarrierKind::kNoWriteBarrier)), | 509 WriteBarrierKind::kNoWriteBarrier)), |
494 stack_slot, graph()->NewNode(common()->Int32Constant(4)), | 510 stack_slot, |
511 graph()->NewNode(common()->Int32Constant(GetHigherWordOffset())), | |
495 GetReplacementHigh(input), graph()->start(), graph()->start()); | 512 GetReplacementHigh(input), graph()->start(), graph()->start()); |
496 | 513 |
497 Node* store_low_word = graph()->NewNode( | 514 Node* store_low_word = graph()->NewNode( |
498 machine()->Store( | 515 machine()->Store( |
499 StoreRepresentation(MachineRepresentation::kWord32, | 516 StoreRepresentation(MachineRepresentation::kWord32, |
500 WriteBarrierKind::kNoWriteBarrier)), | 517 WriteBarrierKind::kNoWriteBarrier)), |
501 stack_slot, graph()->NewNode(common()->Int32Constant(0)), | 518 stack_slot, |
519 graph()->NewNode(common()->Int32Constant(GetLowerWordOffset())), | |
502 GetReplacementLow(input), store_high_word, graph()->start()); | 520 GetReplacementLow(input), store_high_word, graph()->start()); |
503 | 521 |
504 Node* load = | 522 Node* load = |
505 graph()->NewNode(machine()->Load(MachineType::Float64()), stack_slot, | 523 graph()->NewNode(machine()->Load(MachineType::Float64()), stack_slot, |
506 graph()->NewNode(common()->Int32Constant(0)), | 524 graph()->NewNode(common()->Int32Constant(0)), |
507 store_low_word, graph()->start()); | 525 store_low_word, graph()->start()); |
508 | 526 |
509 ReplaceNode(node, load, nullptr); | 527 ReplaceNode(node, load, nullptr); |
510 break; | 528 break; |
511 } | 529 } |
512 case IrOpcode::kBitcastFloat64ToInt64: { | 530 case IrOpcode::kBitcastFloat64ToInt64: { |
513 DCHECK(node->InputCount() == 1); | 531 DCHECK(node->InputCount() == 1); |
514 Node* input = node->InputAt(0); | 532 Node* input = node->InputAt(0); |
515 if (HasReplacementLow(input)) { | 533 if (HasReplacementLow(input)) { |
516 input = GetReplacementLow(input); | 534 input = GetReplacementLow(input); |
517 } | 535 } |
518 Node* stack_slot = graph()->NewNode( | 536 Node* stack_slot = graph()->NewNode( |
519 machine()->StackSlot(MachineRepresentation::kWord64)); | 537 machine()->StackSlot(MachineRepresentation::kWord64)); |
520 Node* store = graph()->NewNode( | 538 Node* store = graph()->NewNode( |
521 machine()->Store( | 539 machine()->Store( |
522 StoreRepresentation(MachineRepresentation::kFloat64, | 540 StoreRepresentation(MachineRepresentation::kFloat64, |
523 WriteBarrierKind::kNoWriteBarrier)), | 541 WriteBarrierKind::kNoWriteBarrier)), |
524 stack_slot, graph()->NewNode(common()->Int32Constant(0)), input, | 542 stack_slot, graph()->NewNode(common()->Int32Constant(0)), input, |
525 graph()->start(), graph()->start()); | 543 graph()->start(), graph()->start()); |
526 | 544 |
527 Node* high_node = | 545 Node* high_node = graph()->NewNode( |
528 graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot, | 546 machine()->Load(MachineType::Int32()), stack_slot, |
529 graph()->NewNode(common()->Int32Constant(4)), store, | 547 graph()->NewNode(common()->Int32Constant(GetHigherWordOffset())), |
530 graph()->start()); | 548 store, graph()->start()); |
531 | 549 |
532 Node* low_node = | 550 Node* low_node = graph()->NewNode( |
533 graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot, | 551 machine()->Load(MachineType::Int32()), stack_slot, |
534 graph()->NewNode(common()->Int32Constant(0)), store, | 552 graph()->NewNode(common()->Int32Constant(GetLowerWordOffset())), |
535 graph()->start()); | 553 store, graph()->start()); |
536 ReplaceNode(node, low_node, high_node); | 554 ReplaceNode(node, low_node, high_node); |
537 break; | 555 break; |
538 } | 556 } |
539 case IrOpcode::kWord64Ror: { | 557 case IrOpcode::kWord64Ror: { |
540 DCHECK(node->InputCount() == 2); | 558 DCHECK(node->InputCount() == 2); |
541 Node* input = node->InputAt(0); | 559 Node* input = node->InputAt(0); |
542 Node* shift = HasReplacementLow(node->InputAt(1)) | 560 Node* shift = HasReplacementLow(node->InputAt(1)) |
543 ? GetReplacementLow(node->InputAt(1)) | 561 ? GetReplacementLow(node->InputAt(1)) |
544 : node->InputAt(1); | 562 : node->InputAt(1); |
545 Int32Matcher m(shift); | 563 Int32Matcher m(shift); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 common()->Phi(MachineRepresentation::kWord32, value_count), | 818 common()->Phi(MachineRepresentation::kWord32, value_count), |
801 value_count + 1, inputs_low, false), | 819 value_count + 1, inputs_low, false), |
802 graph()->NewNode( | 820 graph()->NewNode( |
803 common()->Phi(MachineRepresentation::kWord32, value_count), | 821 common()->Phi(MachineRepresentation::kWord32, value_count), |
804 value_count + 1, inputs_high, false)); | 822 value_count + 1, inputs_high, false)); |
805 } | 823 } |
806 } | 824 } |
807 } // namespace compiler | 825 } // namespace compiler |
808 } // namespace internal | 826 } // namespace internal |
809 } // namespace v8 | 827 } // namespace v8 |
OLD | NEW |