s390x: [baseline] implement Switch

Change-Id: I9a4ba92f9da9cc964056d5c563b0534d9d172fcb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3412809
Reviewed-by: Milad Farazmand <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/main@{#78749}
This commit is contained in:
Junliang Yan 2022-01-24 16:06:49 -05:00 committed by V8 LUCI CQ
parent d4385a99a2
commit eb62fd0f5a

View File

@ -475,7 +475,29 @@ void BaselineAssembler::AddSmi(Register lhs, Smi rhs) { UNIMPLEMENTED(); }
void BaselineAssembler::Switch(Register reg, int case_value_base,
Label** labels, int num_labels) {
UNIMPLEMENTED();
ASM_CODE_COMMENT(masm_);
Label fallthrough, jump_table;
if (case_value_base != 0) {
__ AddS64(reg, Operand(-case_value_base));
}
// Mostly copied from code-generator-arm.cc
ScratchRegisterScope scope(this);
JumpIf(Condition::kUnsignedGreaterThanEqual, reg, Operand(num_labels),
&fallthrough);
// Ensure to emit the constant pool first if necessary.
int entry_size_log2 = 3;
__ ShiftLeftU32(reg, reg, Operand(entry_size_log2));
__ larl(r1, &jump_table);
__ lay(reg, MemOperand(reg, r1));
__ b(reg);
__ b(&fallthrough);
__ bind(&jump_table);
for (int i = 0; i < num_labels; ++i) {
__ b(labels[i], Label::kFar);
__ nop();
}
__ bind(&fallthrough);
}
#undef __