| 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 12 matching lines...) Expand all Loading... |
| 23 namespace compiler { | 23 namespace compiler { |
| 24 | 24 |
| 25 class Schedule; | 25 class Schedule; |
| 26 | 26 |
| 27 class InstructionOperand { | 27 class InstructionOperand { |
| 28 public: | 28 public: |
| 29 static const int kInvalidVirtualRegister = -1; | 29 static const int kInvalidVirtualRegister = -1; |
| 30 | 30 |
| 31 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with | 31 // TODO(dcarney): recover bit. INVALID can be represented as UNALLOCATED with |
| 32 // kInvalidVirtualRegister and some DCHECKS. | 32 // kInvalidVirtualRegister and some DCHECKS. |
| 33 enum Kind { INVALID, UNALLOCATED, CONSTANT, IMMEDIATE, ALLOCATED }; | 33 enum Kind { |
| 34 INVALID, |
| 35 UNALLOCATED, |
| 36 CONSTANT, |
| 37 IMMEDIATE, |
| 38 ALLOCATED, |
| 39 STACK_POINTER, |
| 40 FRAME_POINTER |
| 41 }; |
| 34 | 42 |
| 35 InstructionOperand() : InstructionOperand(INVALID) {} | 43 InstructionOperand() : InstructionOperand(INVALID) {} |
| 36 | 44 |
| 37 Kind kind() const { return KindField::decode(value_); } | 45 Kind kind() const { return KindField::decode(value_); } |
| 38 | 46 |
| 39 #define INSTRUCTION_OPERAND_PREDICATE(name, type) \ | 47 #define INSTRUCTION_OPERAND_PREDICATE(name, type) \ |
| 40 bool Is##name() const { return kind() == type; } | 48 bool Is##name() const { return kind() == type; } |
| 41 INSTRUCTION_OPERAND_PREDICATE(Invalid, INVALID) | 49 INSTRUCTION_OPERAND_PREDICATE(Invalid, INVALID) |
| 42 INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED) | 50 INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED) |
| 43 INSTRUCTION_OPERAND_PREDICATE(Constant, CONSTANT) | 51 INSTRUCTION_OPERAND_PREDICATE(Constant, CONSTANT) |
| 44 INSTRUCTION_OPERAND_PREDICATE(Immediate, IMMEDIATE) | 52 INSTRUCTION_OPERAND_PREDICATE(Immediate, IMMEDIATE) |
| 45 INSTRUCTION_OPERAND_PREDICATE(Allocated, ALLOCATED) | 53 INSTRUCTION_OPERAND_PREDICATE(Allocated, ALLOCATED) |
| 54 INSTRUCTION_OPERAND_PREDICATE(StackPointer, STACK_POINTER) |
| 55 INSTRUCTION_OPERAND_PREDICATE(FramePointer, FRAME_POINTER) |
| 46 #undef INSTRUCTION_OPERAND_PREDICATE | 56 #undef INSTRUCTION_OPERAND_PREDICATE |
| 47 | 57 |
| 48 inline bool IsRegister() const; | 58 inline bool IsRegister() const; |
| 49 inline bool IsDoubleRegister() const; | 59 inline bool IsDoubleRegister() const; |
| 50 inline bool IsStackSlot() const; | 60 inline bool IsStackSlot() const; |
| 51 inline bool IsDoubleStackSlot() const; | 61 inline bool IsDoubleStackSlot() const; |
| 52 | 62 |
| 63 inline bool GeneratesRegister() const { |
| 64 return IsRegister() || IsStackPointer() || IsFramePointer(); |
| 65 } |
| 66 |
| 53 template <typename SubKindOperand> | 67 template <typename SubKindOperand> |
| 54 static SubKindOperand* New(Zone* zone, const SubKindOperand& op) { | 68 static SubKindOperand* New(Zone* zone, const SubKindOperand& op) { |
| 55 void* buffer = zone->New(sizeof(op)); | 69 void* buffer = zone->New(sizeof(op)); |
| 56 return new (buffer) SubKindOperand(op); | 70 return new (buffer) SubKindOperand(op); |
| 57 } | 71 } |
| 58 | 72 |
| 59 static void ReplaceWith(InstructionOperand* dest, | 73 static void ReplaceWith(InstructionOperand* dest, |
| 60 const InstructionOperand* src) { | 74 const InstructionOperand* src) { |
| 61 *dest = *src; | 75 *dest = *src; |
| 62 } | 76 } |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 418 |
| 405 INSTRUCTION_OPERAND_CASTS(AllocatedOperand, ALLOCATED); | 419 INSTRUCTION_OPERAND_CASTS(AllocatedOperand, ALLOCATED); |
| 406 | 420 |
| 407 STATIC_ASSERT(KindField::kSize == 3); | 421 STATIC_ASSERT(KindField::kSize == 3); |
| 408 class AllocatedKindField : public BitField64<AllocatedKind, 3, 2> {}; | 422 class AllocatedKindField : public BitField64<AllocatedKind, 3, 2> {}; |
| 409 class MachineTypeField : public BitField64<MachineType, 5, 16> {}; | 423 class MachineTypeField : public BitField64<MachineType, 5, 16> {}; |
| 410 class IndexField : public BitField64<int32_t, 35, 29> {}; | 424 class IndexField : public BitField64<int32_t, 35, 29> {}; |
| 411 }; | 425 }; |
| 412 | 426 |
| 413 | 427 |
| 428 class StackPointerOperand : public InstructionOperand { |
| 429 public: |
| 430 StackPointerOperand() : InstructionOperand(STACK_POINTER) {} |
| 431 |
| 432 static StackPointerOperand* New(Zone* zone) { |
| 433 return InstructionOperand::New(zone, StackPointerOperand()); |
| 434 } |
| 435 |
| 436 INSTRUCTION_OPERAND_CASTS(StackPointerOperand, STACK_POINTER); |
| 437 }; |
| 438 |
| 439 |
| 440 class FramePointerOperand : public InstructionOperand { |
| 441 public: |
| 442 FramePointerOperand() : InstructionOperand(FRAME_POINTER) {} |
| 443 |
| 444 static FramePointerOperand* New(Zone* zone) { |
| 445 return InstructionOperand::New(zone, FramePointerOperand()); |
| 446 } |
| 447 |
| 448 INSTRUCTION_OPERAND_CASTS(FramePointerOperand, STACK_POINTER); |
| 449 }; |
| 450 |
| 451 |
| 414 #undef INSTRUCTION_OPERAND_CASTS | 452 #undef INSTRUCTION_OPERAND_CASTS |
| 415 | 453 |
| 416 | 454 |
| 417 #define ALLOCATED_OPERAND_LIST(V) \ | 455 #define ALLOCATED_OPERAND_LIST(V) \ |
| 418 V(StackSlot, STACK_SLOT) \ | 456 V(StackSlot, STACK_SLOT) \ |
| 419 V(DoubleStackSlot, DOUBLE_STACK_SLOT) \ | 457 V(DoubleStackSlot, DOUBLE_STACK_SLOT) \ |
| 420 V(Register, REGISTER) \ | 458 V(Register, REGISTER) \ |
| 421 V(DoubleRegister, DOUBLE_REGISTER) | 459 V(DoubleRegister, DOUBLE_REGISTER) |
| 422 | 460 |
| 423 | 461 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 | 1241 |
| 1204 | 1242 |
| 1205 std::ostream& operator<<(std::ostream& os, | 1243 std::ostream& operator<<(std::ostream& os, |
| 1206 const PrintableInstructionSequence& code); | 1244 const PrintableInstructionSequence& code); |
| 1207 | 1245 |
| 1208 } // namespace compiler | 1246 } // namespace compiler |
| 1209 } // namespace internal | 1247 } // namespace internal |
| 1210 } // namespace v8 | 1248 } // namespace v8 |
| 1211 | 1249 |
| 1212 #endif // V8_COMPILER_INSTRUCTION_H_ | 1250 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |