Commit 48123d6b authored by Junliang Yan's avatar Junliang Yan Committed by V8 LUCI CQ

ppc64: [baseline] implement Switch function

Change-Id: Iae749161f5a6f2347a64f45579d9bd9d5e0ccaf6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3613387Reviewed-by: 's avatarMilad Farazmand <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/main@{#80266}
parent a3f66927
......@@ -616,7 +616,29 @@ void BaselineAssembler::AddSmi(Register lhs, Smi rhs) {
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, reg, Operand(-case_value_base));
}
// Mostly copied from code-generator-arm.cc
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));
__ mov_label_addr(ip, &jump_table);
__ AddS64(reg, reg, ip);
__ Jump(reg);
__ b(&fallthrough);
__ bind(&jump_table);
Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_);
for (int i = 0; i < num_labels; ++i) {
__ b(labels[i]);
__ nop();
}
__ bind(&fallthrough);
}
void BaselineAssembler::Word32And(Register output, Register lhs, int rhs) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment