PPC: remove mov_label_addr and use GetLabelAddress instead This is a followup CL to http://crrev.com/c/7807073. GetLabelAddress can safely be used in isolate independent code since it calculates the final address at runtime using LoadPC. GetLabelAddress will later be optimized for >=P10. IT: 10 Change-Id: Ic65cb2198d71b9b7feb421397ff0a7256feff5c3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7832768 Reviewed-by: John <junyan1@ibm.com> Commit-Queue: Milad Farazmand <mfarazma@ibm.com> Cr-Commit-Position: refs/heads/main@{#107198}
diff --git a/src/baseline/ppc/baseline-assembler-ppc-inl.h b/src/baseline/ppc/baseline-assembler-ppc-inl.h index 9112d27..281e874 100644 --- a/src/baseline/ppc/baseline-assembler-ppc-inl.h +++ b/src/baseline/ppc/baseline-assembler-ppc-inl.h
@@ -607,7 +607,8 @@ // 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); + DCHECK_NE(reg, r0); + __ GetLabelAddress(ip, &jump_table, r0); __ AddS64(reg, reg, ip); __ Jump(reg); __ b(&fallthrough);
diff --git a/src/codegen/ppc/assembler-ppc.cc b/src/codegen/ppc/assembler-ppc.cc index 92e984d..d652db4 100644 --- a/src/codegen/ppc/assembler-ppc.cc +++ b/src/codegen/ppc/assembler-ppc.cc
@@ -384,8 +384,7 @@ kUnboundMovLabelOffsetOpcode = 0 << 26, kUnboundAddLabelOffsetOpcode = 1 << 26, kUnboundAddLabelLongOffsetOpcode = 2 << 26, - kUnboundMovLabelAddrOpcode = 3 << 26, - kUnboundJumpTableEntryOpcode = 4 << 26 + kUnboundJumpTableEntryOpcode = 3 << 26 }; int Assembler::target_at(int pos) { @@ -405,7 +404,6 @@ case kUnboundMovLabelOffsetOpcode: case kUnboundAddLabelOffsetOpcode: case kUnboundAddLabelLongOffsetOpcode: - case kUnboundMovLabelAddrOpcode: case kUnboundJumpTableEntryOpcode: link = SIGN_EXT_IMM26(instr & kImm26Mask); link <<= 2; @@ -482,16 +480,6 @@ if (opcode == kUnboundAddLabelLongOffsetOpcode) patcher.nop(); break; } - case kUnboundMovLabelAddrOpcode: { - // Load the address of the label in a register. - Register dst = Register::from_code(instr_at(pos + kInstrSize)); - PatchingAssembler patcher(options(), - reinterpret_cast<uint8_t*>(buffer_start_ + pos), - kMovInstructionsNoConstantPool); - // Keep internal references relative until EmitRelocations. - patcher.bitwise_mov(dst, target_pos); - break; - } case kUnboundJumpTableEntryOpcode: { PatchingAssembler patcher(options(), reinterpret_cast<uint8_t*>(buffer_start_ + pos), @@ -518,7 +506,6 @@ return 16; case kUnboundMovLabelOffsetOpcode: case kUnboundAddLabelOffsetOpcode: - case kUnboundMovLabelAddrOpcode: case kUnboundJumpTableEntryOpcode: return 0; // no limit on reach } @@ -1504,35 +1491,6 @@ } } -void Assembler::mov_label_addr(Register dst, Label* label) { - CheckBuffer(); - RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); - int position = link(label); - if (label->is_bound()) { - // Keep internal references relative until EmitRelocations. - bitwise_mov(dst, position); - } else { - // Encode internal reference to unbound label. We use a dummy opcode - // such that it won't collide with any opcode that might appear in the - // label's chain. Encode the destination register in the 2nd instruction. - int link = position - pc_offset(); - DCHECK_EQ(0, link & 3); - link >>= 2; - DCHECK(is_int26(link)); - - // When the label is bound, these instructions will be patched - // with a multi-instruction mov sequence that will load the - // destination register with the address of the label. - // - // target_at extracts the link and target_at_put patches the instructions. - BlockTrampolinePoolScope block_trampoline_pool(this); - emit(kUnboundMovLabelAddrOpcode | (link & kImm26Mask)); - emit(dst.code()); - DCHECK_GE(kMovInstructionsNoConstantPool, 2); - for (int i = 0; i < kMovInstructionsNoConstantPool - 2; i++) nop(); - } -} - void Assembler::emit_label_addr(Label* label) { CheckBuffer(); RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE);
diff --git a/src/codegen/ppc/assembler-ppc.h b/src/codegen/ppc/assembler-ppc.h index c59631a..00e5959 100644 --- a/src/codegen/ppc/assembler-ppc.h +++ b/src/codegen/ppc/assembler-ppc.h
@@ -1058,10 +1058,6 @@ void add_label_offset(Register dst, Register base, Label* label, int delta = 0); - // Load the address of the label in a register and associate with an - // internal reference relocation. - void mov_label_addr(Register dst, Label* label); - // Emit the address of the label (i.e. a jump table entry) and associate with // an internal reference relocation. void emit_label_addr(Label* label);
diff --git a/src/compiler/backend/ppc/code-generator-ppc.cc b/src/compiler/backend/ppc/code-generator-ppc.cc index 5c56d1d..c30d90c 100644 --- a/src/compiler/backend/ppc/code-generator-ppc.cc +++ b/src/compiler/backend/ppc/code-generator-ppc.cc
@@ -3166,7 +3166,7 @@ __ bge(GetLabel(i.InputRpo(1))); UseScratchRegisterScope temps(masm()); Register scratch = temps.Acquire(); - __ mov_label_addr(scratch, table); + __ GetLabelAddress(scratch, table, r0); __ ShiftLeftU64(r0, input, Operand(kSystemPointerSizeLog2)); __ LoadU64(scratch, MemOperand(scratch, r0)); __ Jump(scratch);