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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <map> | 10 #include <map> |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 InstructionCode opcode() const { return opcode_; } | 506 InstructionCode opcode() const { return opcode_; } |
507 ArchOpcode arch_opcode() const { return ArchOpcodeField::decode(opcode()); } | 507 ArchOpcode arch_opcode() const { return ArchOpcodeField::decode(opcode()); } |
508 AddressingMode addressing_mode() const { | 508 AddressingMode addressing_mode() const { |
509 return AddressingModeField::decode(opcode()); | 509 return AddressingModeField::decode(opcode()); |
510 } | 510 } |
511 FlagsMode flags_mode() const { return FlagsModeField::decode(opcode()); } | 511 FlagsMode flags_mode() const { return FlagsModeField::decode(opcode()); } |
512 FlagsCondition flags_condition() const { | 512 FlagsCondition flags_condition() const { |
513 return FlagsConditionField::decode(opcode()); | 513 return FlagsConditionField::decode(opcode()); |
514 } | 514 } |
515 | 515 |
516 // TODO(titzer): make control and call into flags. | 516 // TODO(titzer): make call into a flags. |
517 static Instruction* New(Zone* zone, InstructionCode opcode) { | 517 static Instruction* New(Zone* zone, InstructionCode opcode) { |
518 return New(zone, opcode, 0, NULL, 0, NULL, 0, NULL); | 518 return New(zone, opcode, 0, NULL, 0, NULL, 0, NULL); |
519 } | 519 } |
520 | 520 |
521 static Instruction* New(Zone* zone, InstructionCode opcode, | 521 static Instruction* New(Zone* zone, InstructionCode opcode, |
522 size_t output_count, InstructionOperand* outputs, | 522 size_t output_count, InstructionOperand* outputs, |
523 size_t input_count, InstructionOperand* inputs, | 523 size_t input_count, InstructionOperand* inputs, |
524 size_t temp_count, InstructionOperand* temps) { | 524 size_t temp_count, InstructionOperand* temps) { |
525 DCHECK(opcode >= 0); | 525 DCHECK(opcode >= 0); |
526 DCHECK(output_count == 0 || outputs != NULL); | 526 DCHECK(output_count == 0 || outputs != NULL); |
527 DCHECK(input_count == 0 || inputs != NULL); | 527 DCHECK(input_count == 0 || inputs != NULL); |
528 DCHECK(temp_count == 0 || temps != NULL); | 528 DCHECK(temp_count == 0 || temps != NULL); |
529 size_t total_extra_ops = output_count + input_count + temp_count; | 529 size_t total_extra_ops = output_count + input_count + temp_count; |
530 if (total_extra_ops != 0) total_extra_ops--; | 530 if (total_extra_ops != 0) total_extra_ops--; |
531 int size = static_cast<int>( | 531 int size = static_cast<int>( |
532 RoundUp(sizeof(Instruction), sizeof(InstructionOperand)) + | 532 RoundUp(sizeof(Instruction), sizeof(InstructionOperand)) + |
533 total_extra_ops * sizeof(InstructionOperand)); | 533 total_extra_ops * sizeof(InstructionOperand)); |
534 return new (zone->New(size)) Instruction( | 534 return new (zone->New(size)) Instruction( |
535 opcode, output_count, outputs, input_count, inputs, temp_count, temps); | 535 opcode, output_count, outputs, input_count, inputs, temp_count, temps); |
536 } | 536 } |
537 | 537 |
538 // TODO(titzer): another holdover from lithium days; register allocator | |
539 // should not need to know about control instructions. | |
540 Instruction* MarkAsControl() { | |
541 bit_field_ = IsControlField::update(bit_field_, true); | |
542 return this; | |
543 } | |
544 Instruction* MarkAsCall() { | 538 Instruction* MarkAsCall() { |
545 bit_field_ = IsCallField::update(bit_field_, true); | 539 bit_field_ = IsCallField::update(bit_field_, true); |
546 return this; | 540 return this; |
547 } | 541 } |
548 bool IsControl() const { return IsControlField::decode(bit_field_); } | |
549 bool IsCall() const { return IsCallField::decode(bit_field_); } | 542 bool IsCall() const { return IsCallField::decode(bit_field_); } |
550 bool NeedsPointerMap() const { return IsCall(); } | 543 bool NeedsPointerMap() const { return IsCall(); } |
551 bool HasPointerMap() const { return pointer_map_ != NULL; } | 544 bool HasPointerMap() const { return pointer_map_ != NULL; } |
552 | 545 |
553 bool IsGapMoves() const { return opcode() == kGapInstruction; } | 546 bool IsGapMoves() const { return opcode() == kGapInstruction; } |
554 bool IsSourcePosition() const { | 547 bool IsSourcePosition() const { |
555 return opcode() == kSourcePositionInstruction; | 548 return opcode() == kSourcePositionInstruction; |
556 } | 549 } |
557 | 550 |
558 bool ClobbersRegisters() const { return IsCall(); } | 551 bool ClobbersRegisters() const { return IsCall(); } |
(...skipping 22 matching lines...) Expand all Loading... |
581 explicit Instruction(InstructionCode opcode); | 574 explicit Instruction(InstructionCode opcode); |
582 Instruction(InstructionCode opcode, size_t output_count, | 575 Instruction(InstructionCode opcode, size_t output_count, |
583 InstructionOperand* outputs, size_t input_count, | 576 InstructionOperand* outputs, size_t input_count, |
584 InstructionOperand* inputs, size_t temp_count, | 577 InstructionOperand* inputs, size_t temp_count, |
585 InstructionOperand* temps); | 578 InstructionOperand* temps); |
586 | 579 |
587 typedef BitField<size_t, 0, 8> OutputCountField; | 580 typedef BitField<size_t, 0, 8> OutputCountField; |
588 typedef BitField<size_t, 8, 16> InputCountField; | 581 typedef BitField<size_t, 8, 16> InputCountField; |
589 typedef BitField<size_t, 24, 6> TempCountField; | 582 typedef BitField<size_t, 24, 6> TempCountField; |
590 typedef BitField<bool, 30, 1> IsCallField; | 583 typedef BitField<bool, 30, 1> IsCallField; |
591 typedef BitField<bool, 31, 1> IsControlField; | |
592 | 584 |
593 InstructionCode opcode_; | 585 InstructionCode opcode_; |
594 uint32_t bit_field_; | 586 uint32_t bit_field_; |
595 PointerMap* pointer_map_; | 587 PointerMap* pointer_map_; |
596 InstructionOperand operands_[1]; | 588 InstructionOperand operands_[1]; |
597 | 589 |
598 private: | 590 private: |
599 DISALLOW_COPY_AND_ASSIGN(Instruction); | 591 DISALLOW_COPY_AND_ASSIGN(Instruction); |
600 }; | 592 }; |
601 | 593 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1090 |
1099 | 1091 |
1100 std::ostream& operator<<(std::ostream& os, | 1092 std::ostream& operator<<(std::ostream& os, |
1101 const PrintableInstructionSequence& code); | 1093 const PrintableInstructionSequence& code); |
1102 | 1094 |
1103 } // namespace compiler | 1095 } // namespace compiler |
1104 } // namespace internal | 1096 } // namespace internal |
1105 } // namespace v8 | 1097 } // namespace v8 |
1106 | 1098 |
1107 #endif // V8_COMPILER_INSTRUCTION_H_ | 1099 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |