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_RAW_MACHINE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
7 | 7 |
| 8 #include "src/assembler.h" |
8 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/graph-builder.h" | 10 #include "src/compiler/graph-builder.h" |
10 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
11 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
12 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
13 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
14 | 15 |
15 | |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 namespace compiler { | 18 namespace compiler { |
19 | 19 |
20 class BasicBlock; | 20 class BasicBlock; |
21 class Schedule; | 21 class Schedule; |
22 | 22 |
23 | 23 |
24 class RawMachineAssembler : public GraphBuilder { | 24 class RawMachineAssembler : public GraphBuilder { |
25 public: | 25 public: |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 // Memory Operations. | 103 // Memory Operations. |
104 Node* Load(MachineType rep, Node* base) { | 104 Node* Load(MachineType rep, Node* base) { |
105 return Load(rep, base, IntPtrConstant(0)); | 105 return Load(rep, base, IntPtrConstant(0)); |
106 } | 106 } |
107 Node* Load(MachineType rep, Node* base, Node* index) { | 107 Node* Load(MachineType rep, Node* base, Node* index) { |
108 return NewNode(machine()->Load(rep), base, index, graph()->start(), | 108 return NewNode(machine()->Load(rep), base, index, graph()->start(), |
109 graph()->start()); | 109 graph()->start()); |
110 } | 110 } |
111 void Store(MachineType rep, Node* base, Node* value) { | 111 Node* Store(MachineType rep, Node* base, Node* value) { |
112 Store(rep, base, IntPtrConstant(0), value); | 112 return Store(rep, base, IntPtrConstant(0), value); |
113 } | 113 } |
114 void Store(MachineType rep, Node* base, Node* index, Node* value) { | 114 Node* Store(MachineType rep, Node* base, Node* index, Node* value) { |
115 NewNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), base, | 115 return NewNode(machine()->Store(StoreRepresentation(rep, kNoWriteBarrier)), |
116 index, value, graph()->start(), graph()->start()); | 116 base, index, value, graph()->start(), graph()->start()); |
117 } | 117 } |
118 // Arithmetic Operations. | 118 // Arithmetic Operations. |
119 Node* WordAnd(Node* a, Node* b) { | 119 Node* WordAnd(Node* a, Node* b) { |
120 return NewNode(machine()->WordAnd(), a, b); | 120 return NewNode(machine()->WordAnd(), a, b); |
121 } | 121 } |
122 Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); } | 122 Node* WordOr(Node* a, Node* b) { return NewNode(machine()->WordOr(), a, b); } |
123 Node* WordXor(Node* a, Node* b) { | 123 Node* WordXor(Node* a, Node* b) { |
124 return NewNode(machine()->WordXor(), a, b); | 124 return NewNode(machine()->WordXor(), a, b); |
125 } | 125 } |
126 Node* WordShl(Node* a, Node* b) { | 126 Node* WordShl(Node* a, Node* b) { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 Node* LoadStackPointer() { return NewNode(machine()->LoadStackPointer()); } | 448 Node* LoadStackPointer() { return NewNode(machine()->LoadStackPointer()); } |
449 Node* LoadFramePointer() { return NewNode(machine()->LoadFramePointer()); } | 449 Node* LoadFramePointer() { return NewNode(machine()->LoadFramePointer()); } |
450 | 450 |
451 // Parameters. | 451 // Parameters. |
452 Node* Parameter(size_t index); | 452 Node* Parameter(size_t index); |
453 | 453 |
454 // Pointer utilities. | 454 // Pointer utilities. |
455 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { | 455 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { |
456 return Load(rep, PointerConstant(address), Int32Constant(offset)); | 456 return Load(rep, PointerConstant(address), Int32Constant(offset)); |
457 } | 457 } |
458 void StoreToPointer(void* address, MachineType rep, Node* node) { | 458 Node* StoreToPointer(void* address, MachineType rep, Node* node) { |
459 Store(rep, PointerConstant(address), node); | 459 return Store(rep, PointerConstant(address), node); |
460 } | 460 } |
461 Node* StringConstant(const char* string) { | 461 Node* StringConstant(const char* string) { |
462 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); | 462 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); |
463 } | 463 } |
464 | 464 |
465 // Control flow. | 465 // Control flow. |
466 void Goto(Label* label); | 466 void Goto(Label* label); |
467 void Branch(Node* condition, Label* true_val, Label* false_val); | 467 void Branch(Node* condition, Label* true_val, Label* false_val); |
468 void Switch(Node* index, Label* default_label, int32_t* case_values, | 468 void Switch(Node* index, Label* default_label, int32_t* case_values, |
469 Label** case_labels, size_t case_count); | 469 Label** case_labels, size_t case_count); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { | 504 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3) { |
505 return NewNode(common()->Phi(type, 3), n1, n2, n3); | 505 return NewNode(common()->Phi(type, 3), n1, n2, n3); |
506 } | 506 } |
507 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { | 507 Node* Phi(MachineType type, Node* n1, Node* n2, Node* n3, Node* n4) { |
508 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); | 508 return NewNode(common()->Phi(type, 4), n1, n2, n3, n4); |
509 } | 509 } |
510 | 510 |
511 // MachineAssembler is invalid after export. | 511 // MachineAssembler is invalid after export. |
512 Schedule* Export(); | 512 Schedule* Export(); |
513 | 513 |
| 514 Schedule* schedule() { |
| 515 DCHECK(ScheduleValid()); |
| 516 return schedule_; |
| 517 } |
| 518 |
| 519 BasicBlock* CurrentBlock(); |
| 520 |
514 protected: | 521 protected: |
515 Node* MakeNode(const Operator* op, int input_count, Node** inputs, | 522 Node* MakeNode(const Operator* op, int input_count, Node** inputs, |
516 bool incomplete) final; | 523 bool incomplete) final; |
517 | 524 |
518 bool ScheduleValid() { return schedule_ != NULL; } | 525 bool ScheduleValid() { return schedule_ != NULL; } |
519 | 526 |
520 Schedule* schedule() { | |
521 DCHECK(ScheduleValid()); | |
522 return schedule_; | |
523 } | |
524 | |
525 private: | 527 private: |
526 BasicBlock* Use(Label* label); | 528 BasicBlock* Use(Label* label); |
527 BasicBlock* EnsureBlock(Label* label); | 529 BasicBlock* EnsureBlock(Label* label); |
528 BasicBlock* CurrentBlock(); | |
529 | 530 |
530 Schedule* schedule_; | 531 Schedule* schedule_; |
531 MachineOperatorBuilder machine_; | 532 MachineOperatorBuilder machine_; |
532 CommonOperatorBuilder common_; | 533 CommonOperatorBuilder common_; |
533 CallDescriptor* call_descriptor_; | 534 CallDescriptor* call_descriptor_; |
534 Node** parameters_; | 535 Node** parameters_; |
535 BasicBlock* current_block_; | 536 BasicBlock* current_block_; |
536 | 537 |
537 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); | 538 DISALLOW_COPY_AND_ASSIGN(RawMachineAssembler); |
538 }; | 539 }; |
539 | 540 |
540 } // namespace compiler | 541 } // namespace compiler |
541 } // namespace internal | 542 } // namespace internal |
542 } // namespace v8 | 543 } // namespace v8 |
543 | 544 |
544 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 545 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
OLD | NEW |