Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: src/compiler/schedule.cc

Issue 892513003: [turbofan] Initial support for Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Wuschelstudio build. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/schedule.cc
diff --git a/src/compiler/schedule.cc b/src/compiler/schedule.cc
index 0ee32e340811dabbe691de381ba92b093b80e1ef..8924ae54401a0c8919281228d7f7bdd70a8adfd9 100644
--- a/src/compiler/schedule.cc
+++ b/src/compiler/schedule.cc
@@ -102,6 +102,8 @@ std::ostream& operator<<(std::ostream& os, const BasicBlock::Control& c) {
return os << "goto";
case BasicBlock::kBranch:
return os << "branch";
+ case BasicBlock::kSwitch:
+ return os << "switch";
case BasicBlock::kReturn:
return os << "return";
case BasicBlock::kThrow:
@@ -209,6 +211,18 @@ void Schedule::AddBranch(BasicBlock* block, Node* branch, BasicBlock* tblock,
}
+void Schedule::AddSwitch(BasicBlock* block, Node* sw, BasicBlock** succ_blocks,
+ size_t succ_count) {
+ DCHECK_EQ(BasicBlock::kNone, block->control());
+ DCHECK_EQ(IrOpcode::kSwitch, sw->opcode());
+ block->set_control(BasicBlock::kSwitch);
+ for (size_t index = 0; index < succ_count; ++index) {
+ AddSuccessor(block, succ_blocks[index]);
+ }
+ SetControlInput(block, sw);
+}
+
+
void Schedule::AddReturn(BasicBlock* block, Node* input) {
DCHECK(block->control() == BasicBlock::kNone);
block->set_control(BasicBlock::kReturn);
@@ -234,13 +248,30 @@ void Schedule::InsertBranch(BasicBlock* block, BasicBlock* end, Node* branch,
MoveSuccessors(block, end);
AddSuccessor(block, tblock);
AddSuccessor(block, fblock);
- if (block->control_input() != NULL) {
+ if (block->control_input() != nullptr) {
SetControlInput(end, block->control_input());
}
SetControlInput(block, branch);
}
+void Schedule::InsertSwitch(BasicBlock* block, BasicBlock* end, Node* sw,
+ BasicBlock** succ_blocks, size_t succ_count) {
+ DCHECK_NE(BasicBlock::kNone, block->control());
+ DCHECK_EQ(BasicBlock::kNone, end->control());
+ end->set_control(block->control());
+ block->set_control(BasicBlock::kSwitch);
+ MoveSuccessors(block, end);
+ for (size_t index = 0; index < succ_count; ++index) {
+ AddSuccessor(block, succ_blocks[index]);
+ }
+ if (block->control_input() != nullptr) {
+ SetControlInput(end, block->control_input());
+ }
+ SetControlInput(block, sw);
+}
+
+
void Schedule::AddSuccessor(BasicBlock* block, BasicBlock* succ) {
block->AddSuccessor(succ);
succ->AddPredecessor(block);
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698