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

Unified Diff: src/compiler/ia32/code-generator-ia32.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/common-operator.cc ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ia32/code-generator-ia32.cc
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc
index 54336dc31ee6f8abf1d321b22bfe16d2673cfcf9..f88cd106766c50fa4f3146727e7a7286295841a4 100644
--- a/src/compiler/ia32/code-generator-ia32.cc
+++ b/src/compiler/ia32/code-generator-ia32.cc
@@ -310,6 +310,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kArchJmp:
AssembleArchJump(i.InputRpo(0));
break;
+ case kArchSwitch:
+ AssembleArchSwitch(instr);
+ break;
case kArchNop:
// don't emit code for nops.
break;
@@ -758,6 +761,18 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) {
}
+void CodeGenerator::AssembleArchSwitch(Instruction* instr) {
+ IA32OperandConverter i(this, instr);
+ size_t const label_count = instr->InputCount() - 1;
+ Label** labels = zone()->NewArray<Label*>(label_count);
+ for (size_t index = 0; index < label_count; ++index) {
+ labels[index] = GetLabel(i.InputRpo(index + 1));
+ }
+ Label* const table = AddJumpTable(labels, label_count);
+ __ jmp(Operand::JumpTable(i.InputRegister(0), times_4, table));
+}
+
+
// Assembles boolean materializations after an instruction.
void CodeGenerator::AssembleArchBoolean(Instruction* instr,
FlagsCondition condition) {
@@ -1214,6 +1229,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
}
+void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
+ for (size_t index = 0; index < target_count; ++index) {
+ __ dd(targets[index]);
+ }
+}
+
+
void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); }
« no previous file with comments | « src/compiler/common-operator.cc ('k') | src/compiler/instruction-codes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698