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/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 high_node = graph()->NewNode(store_op, base, index_high, | 160 high_node = graph()->NewNode(store_op, base, index_high, |
161 GetReplacementHigh(value)); | 161 GetReplacementHigh(value)); |
162 } | 162 } |
163 | 163 |
164 node->ReplaceInput(2, GetReplacementLow(value)); | 164 node->ReplaceInput(2, GetReplacementLow(value)); |
165 NodeProperties::ChangeOp(node, store_op); | 165 NodeProperties::ChangeOp(node, store_op); |
166 ReplaceNode(node, node, high_node); | 166 ReplaceNode(node, node, high_node); |
167 } | 167 } |
168 break; | 168 break; |
169 } | 169 } |
170 case IrOpcode::kWord64And: { | |
171 DCHECK(node->InputCount() == 2); | |
172 Node* left = node->InputAt(0); | |
173 Node* right = node->InputAt(1); | |
174 | |
175 Node* low_node = | |
176 graph()->NewNode(machine()->Word32And(), GetReplacementLow(left), | |
177 GetReplacementLow(right)); | |
178 Node* high_node = | |
179 graph()->NewNode(machine()->Word32And(), GetReplacementHigh(left), | |
180 GetReplacementHigh(right)); | |
181 ReplaceNode(node, low_node, high_node); | |
182 break; | |
183 } | |
184 case IrOpcode::kTruncateInt64ToInt32: { | |
185 DCHECK(node->InputCount() == 1); | |
186 Node* input = node->InputAt(0); | |
187 ReplaceNode(node, GetReplacementLow(input), nullptr); | |
188 node->NullAllInputs(); | |
189 break; | |
190 } | |
191 case IrOpcode::kStart: { | 170 case IrOpcode::kStart: { |
192 int parameter_count = GetParameterCountAfterLowering(signature()); | 171 int parameter_count = GetParameterCountAfterLowering(signature()); |
193 // Only exchange the node if the parameter count actually changed. | 172 // Only exchange the node if the parameter count actually changed. |
194 if (parameter_count != signature()->parameter_count()) { | 173 if (parameter_count != signature()->parameter_count()) { |
195 int delta = | 174 int delta = |
196 parameter_count - static_cast<int>(signature()->parameter_count()); | 175 parameter_count - static_cast<int>(signature()->parameter_count()); |
197 int new_output_count = node->op()->ValueOutputCount() + delta; | 176 int new_output_count = node->op()->ValueOutputCount() + delta; |
198 NodeProperties::ChangeOp(node, common()->Start(new_output_count)); | 177 NodeProperties::ChangeOp(node, common()->Start(new_output_count)); |
199 } | 178 } |
200 break; | 179 break; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 220 } |
242 if (descriptor->ReturnCount() == 1 && | 221 if (descriptor->ReturnCount() == 1 && |
243 descriptor->GetReturnType(0) == MachineType::Int64()) { | 222 descriptor->GetReturnType(0) == MachineType::Int64()) { |
244 // We access the additional return values through projections. | 223 // We access the additional return values through projections. |
245 Node* low_node = graph()->NewNode(common()->Projection(0), node); | 224 Node* low_node = graph()->NewNode(common()->Projection(0), node); |
246 Node* high_node = graph()->NewNode(common()->Projection(1), node); | 225 Node* high_node = graph()->NewNode(common()->Projection(1), node); |
247 ReplaceNode(node, low_node, high_node); | 226 ReplaceNode(node, low_node, high_node); |
248 } | 227 } |
249 break; | 228 break; |
250 } | 229 } |
| 230 case IrOpcode::kWord64And: { |
| 231 DCHECK(node->InputCount() == 2); |
| 232 Node* left = node->InputAt(0); |
| 233 Node* right = node->InputAt(1); |
| 234 |
| 235 Node* low_node = |
| 236 graph()->NewNode(machine()->Word32And(), GetReplacementLow(left), |
| 237 GetReplacementLow(right)); |
| 238 Node* high_node = |
| 239 graph()->NewNode(machine()->Word32And(), GetReplacementHigh(left), |
| 240 GetReplacementHigh(right)); |
| 241 ReplaceNode(node, low_node, high_node); |
| 242 break; |
| 243 } |
| 244 case IrOpcode::kTruncateInt64ToInt32: { |
| 245 DCHECK(node->InputCount() == 1); |
| 246 Node* input = node->InputAt(0); |
| 247 ReplaceNode(node, GetReplacementLow(input), nullptr); |
| 248 node->NullAllInputs(); |
| 249 break; |
| 250 } |
| 251 // todo(ahaas): I added a list of missing instructions here to make merging |
| 252 // easier when I do them one by one. |
| 253 // kExprI64Add: |
| 254 // kExprI64Sub: |
| 255 // kExprI64Mul: |
| 256 // kExprI64DivS: |
| 257 // kExprI64DivU: |
| 258 // kExprI64RemS: |
| 259 // kExprI64RemU: |
| 260 // kExprI64Ior: |
| 261 case IrOpcode::kWord64Or: { |
| 262 DCHECK(node->InputCount() == 2); |
| 263 Node* left = node->InputAt(0); |
| 264 Node* right = node->InputAt(1); |
| 265 |
| 266 Node* low_node = |
| 267 graph()->NewNode(machine()->Word32Or(), GetReplacementLow(left), |
| 268 GetReplacementLow(right)); |
| 269 Node* high_node = |
| 270 graph()->NewNode(machine()->Word32Or(), GetReplacementHigh(left), |
| 271 GetReplacementHigh(right)); |
| 272 ReplaceNode(node, low_node, high_node); |
| 273 break; |
| 274 } |
| 275 |
| 276 // kExprI64Xor: |
| 277 // kExprI64Shl: |
| 278 // kExprI64ShrU: |
| 279 // kExprI64ShrS: |
| 280 // kExprI64Eq: |
| 281 // kExprI64Ne: |
| 282 // kExprI64LtS: |
| 283 // kExprI64LeS: |
| 284 // kExprI64LtU: |
| 285 // kExprI64LeU: |
| 286 // kExprI64GtS: |
| 287 // kExprI64GeS: |
| 288 // kExprI64GtU: |
| 289 // kExprI64GeU: |
| 290 |
| 291 // kExprI64SConvertI32: |
| 292 // kExprI64UConvertI32: |
| 293 |
| 294 // kExprF64ReinterpretI64: |
| 295 // kExprI64ReinterpretF64: |
| 296 |
| 297 // kExprI64Clz: |
| 298 // kExprI64Ctz: |
| 299 // kExprI64Popcnt: |
| 300 |
| 301 // kExprF32SConvertI64: |
| 302 // kExprF32UConvertI64: |
| 303 // kExprF64SConvertI64: |
| 304 // kExprF64UConvertI64: |
| 305 // kExprI64SConvertF32: |
| 306 // kExprI64SConvertF64: |
| 307 // kExprI64UConvertF32: |
| 308 // kExprI64UConvertF64: |
251 default: { DefaultLowering(node); } | 309 default: { DefaultLowering(node); } |
252 } | 310 } |
253 } | 311 } |
254 | 312 |
255 bool Int64Lowering::DefaultLowering(Node* node) { | 313 bool Int64Lowering::DefaultLowering(Node* node) { |
256 bool something_changed = false; | 314 bool something_changed = false; |
257 for (int i = NodeProperties::PastValueIndex(node) - 1; i >= 0; i--) { | 315 for (int i = NodeProperties::PastValueIndex(node) - 1; i >= 0; i--) { |
258 Node* input = node->InputAt(i); | 316 Node* input = node->InputAt(i); |
259 if (HasReplacementLow(input)) { | 317 if (HasReplacementLow(input)) { |
260 something_changed = true; | 318 something_changed = true; |
(...skipping 29 matching lines...) Expand all Loading... |
290 } | 348 } |
291 | 349 |
292 Node* Int64Lowering::GetReplacementHigh(Node* node) { | 350 Node* Int64Lowering::GetReplacementHigh(Node* node) { |
293 Node* result = replacements_[node->id()].high; | 351 Node* result = replacements_[node->id()].high; |
294 DCHECK(result); | 352 DCHECK(result); |
295 return result; | 353 return result; |
296 } | 354 } |
297 } // namespace compiler | 355 } // namespace compiler |
298 } // namespace internal | 356 } // namespace internal |
299 } // namespace v8 | 357 } // namespace v8 |
OLD | NEW |