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/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 #include "src/compiler-intrinsics.h" | 7 #include "src/compiler-intrinsics.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 | 299 |
300 static void VisitBinop(InstructionSelector* selector, Node* node, | 300 static void VisitBinop(InstructionSelector* selector, Node* node, |
301 InstructionCode opcode, InstructionCode reverse_opcode) { | 301 InstructionCode opcode, InstructionCode reverse_opcode) { |
302 FlagsContinuation cont; | 302 FlagsContinuation cont; |
303 VisitBinop(selector, node, opcode, reverse_opcode, &cont); | 303 VisitBinop(selector, node, opcode, reverse_opcode, &cont); |
304 } | 304 } |
305 | 305 |
306 | 306 |
307 void InstructionSelector::VisitLoad(Node* node) { | 307 void InstructionSelector::VisitLoad(Node* node) { |
308 MachineType rep = OpParameter<MachineType>(node); | 308 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
309 ArmOperandGenerator g(this); | 309 ArmOperandGenerator g(this); |
310 Node* base = node->InputAt(0); | 310 Node* base = node->InputAt(0); |
311 Node* index = node->InputAt(1); | 311 Node* index = node->InputAt(1); |
312 | 312 |
313 InstructionOperand* result = rep == kMachineFloat64 | 313 InstructionOperand* result = rep == rFloat64 ? g.DefineAsDoubleRegister(node) |
314 ? g.DefineAsDoubleRegister(node) | 314 : g.DefineAsRegister(node); |
315 : g.DefineAsRegister(node); | |
316 | 315 |
317 ArchOpcode opcode; | 316 ArchOpcode opcode; |
| 317 // TODO(titzer): signed/unsigned small loads |
318 switch (rep) { | 318 switch (rep) { |
319 case kMachineFloat64: | 319 case rFloat64: |
320 opcode = kArmFloat64Load; | 320 opcode = kArmFloat64Load; |
321 break; | 321 break; |
322 case kMachineWord8: | 322 case rBit: // Fall through. |
| 323 case rWord8: |
323 opcode = kArmLoadWord8; | 324 opcode = kArmLoadWord8; |
324 break; | 325 break; |
325 case kMachineWord16: | 326 case rWord16: |
326 opcode = kArmLoadWord16; | 327 opcode = kArmLoadWord16; |
327 break; | 328 break; |
328 case kMachineTagged: // Fall through. | 329 case rTagged: // Fall through. |
329 case kMachineWord32: | 330 case rWord32: |
330 opcode = kArmLoadWord32; | 331 opcode = kArmLoadWord32; |
331 break; | 332 break; |
332 default: | 333 default: |
333 UNREACHABLE(); | 334 UNREACHABLE(); |
334 return; | 335 return; |
335 } | 336 } |
336 | 337 |
337 if (g.CanBeImmediate(index, opcode)) { | 338 if (g.CanBeImmediate(index, opcode)) { |
338 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), result, | 339 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), result, |
339 g.UseRegister(base), g.UseImmediate(index)); | 340 g.UseRegister(base), g.UseImmediate(index)); |
340 } else if (g.CanBeImmediate(base, opcode)) { | 341 } else if (g.CanBeImmediate(base, opcode)) { |
341 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), result, | 342 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), result, |
342 g.UseRegister(index), g.UseImmediate(base)); | 343 g.UseRegister(index), g.UseImmediate(base)); |
343 } else { | 344 } else { |
344 Emit(opcode | AddressingModeField::encode(kMode_Offset_RR), result, | 345 Emit(opcode | AddressingModeField::encode(kMode_Offset_RR), result, |
345 g.UseRegister(base), g.UseRegister(index)); | 346 g.UseRegister(base), g.UseRegister(index)); |
346 } | 347 } |
347 } | 348 } |
348 | 349 |
349 | 350 |
350 void InstructionSelector::VisitStore(Node* node) { | 351 void InstructionSelector::VisitStore(Node* node) { |
351 ArmOperandGenerator g(this); | 352 ArmOperandGenerator g(this); |
352 Node* base = node->InputAt(0); | 353 Node* base = node->InputAt(0); |
353 Node* index = node->InputAt(1); | 354 Node* index = node->InputAt(1); |
354 Node* value = node->InputAt(2); | 355 Node* value = node->InputAt(2); |
355 | 356 |
356 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 357 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
357 MachineType rep = store_rep.rep; | 358 MachineType rep = RepresentationOf(store_rep.machine_type); |
358 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 359 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
359 DCHECK(rep == kMachineTagged); | 360 DCHECK(rep == rTagged); |
360 // TODO(dcarney): refactor RecordWrite function to take temp registers | 361 // TODO(dcarney): refactor RecordWrite function to take temp registers |
361 // and pass them here instead of using fixed regs | 362 // and pass them here instead of using fixed regs |
362 // TODO(dcarney): handle immediate indices. | 363 // TODO(dcarney): handle immediate indices. |
363 InstructionOperand* temps[] = {g.TempRegister(r5), g.TempRegister(r6)}; | 364 InstructionOperand* temps[] = {g.TempRegister(r5), g.TempRegister(r6)}; |
364 Emit(kArmStoreWriteBarrier, NULL, g.UseFixed(base, r4), | 365 Emit(kArmStoreWriteBarrier, NULL, g.UseFixed(base, r4), |
365 g.UseFixed(index, r5), g.UseFixed(value, r6), ARRAY_SIZE(temps), | 366 g.UseFixed(index, r5), g.UseFixed(value, r6), ARRAY_SIZE(temps), |
366 temps); | 367 temps); |
367 return; | 368 return; |
368 } | 369 } |
369 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 370 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
370 InstructionOperand* val = rep == kMachineFloat64 ? g.UseDoubleRegister(value) | 371 InstructionOperand* val = |
371 : g.UseRegister(value); | 372 rep == rFloat64 ? g.UseDoubleRegister(value) : g.UseRegister(value); |
372 | 373 |
373 ArchOpcode opcode; | 374 ArchOpcode opcode; |
374 switch (rep) { | 375 switch (rep) { |
375 case kMachineFloat64: | 376 case rFloat64: |
376 opcode = kArmFloat64Store; | 377 opcode = kArmFloat64Store; |
377 break; | 378 break; |
378 case kMachineWord8: | 379 case rBit: // Fall through. |
| 380 case rWord8: |
379 opcode = kArmStoreWord8; | 381 opcode = kArmStoreWord8; |
380 break; | 382 break; |
381 case kMachineWord16: | 383 case rWord16: |
382 opcode = kArmStoreWord16; | 384 opcode = kArmStoreWord16; |
383 break; | 385 break; |
384 case kMachineTagged: // Fall through. | 386 case rTagged: // Fall through. |
385 case kMachineWord32: | 387 case rWord32: |
386 opcode = kArmStoreWord32; | 388 opcode = kArmStoreWord32; |
387 break; | 389 break; |
388 default: | 390 default: |
389 UNREACHABLE(); | 391 UNREACHABLE(); |
390 return; | 392 return; |
391 } | 393 } |
392 | 394 |
393 if (g.CanBeImmediate(index, opcode)) { | 395 if (g.CanBeImmediate(index, opcode)) { |
394 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), NULL, | 396 Emit(opcode | AddressingModeField::encode(kMode_Offset_RI), NULL, |
395 g.UseRegister(base), g.UseImmediate(index), val); | 397 g.UseRegister(base), g.UseImmediate(index), val); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 DCHECK(cont->IsSet()); | 936 DCHECK(cont->IsSet()); |
935 Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), | 937 Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), |
936 g.UseDoubleRegister(m.left().node()), | 938 g.UseDoubleRegister(m.left().node()), |
937 g.UseDoubleRegister(m.right().node())); | 939 g.UseDoubleRegister(m.right().node())); |
938 } | 940 } |
939 } | 941 } |
940 | 942 |
941 } // namespace compiler | 943 } // namespace compiler |
942 } // namespace internal | 944 } // namespace internal |
943 } // namespace v8 | 945 } // namespace v8 |
OLD | NEW |