Commit 95f8ac49 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

s390x: unify constant load and LoadRR as mov

Change-Id: I6d7e263b84d6871cb13cb01b2b51299b9249d961
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2586994Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#71720}
parent e677c91f
This diff is collapsed.
......@@ -307,7 +307,7 @@ void TurboAssembler::LoadRootRelative(Register destination, int32_t offset) {
void TurboAssembler::LoadRootRegisterOffset(Register destination,
intptr_t offset) {
if (offset == 0) {
LoadRR(destination, kRootRegister);
mov(destination, kRootRegister);
} else if (is_uint12(offset)) {
la(destination, MemOperand(kRootRegister, offset));
} else {
......@@ -485,7 +485,7 @@ void TurboAssembler::Move(Register dst, ExternalReference reference) {
void TurboAssembler::Move(Register dst, Register src, Condition cond) {
if (dst != src) {
if (cond == al) {
LoadRR(dst, src);
mov(dst, src);
} else {
LoadOnConditionP(cond, dst, src);
}
......@@ -560,7 +560,7 @@ void TurboAssembler::PushArray(Register array, Register size, Register scratch,
DCHECK_NE(scratch2, r0);
ShiftLeftP(scratch, size, Operand(kSystemPointerSizeLog2));
lay(scratch, MemOperand(array, scratch));
LoadRR(scratch2, array);
mov(scratch2, array);
bind(&loop);
CmpP(scratch2, scratch);
bge(&done);
......@@ -1270,7 +1270,7 @@ int TurboAssembler::LeaveFrame(StackFrame::Type type, int stack_adjustment) {
Operand(StandardFrameConstants::kCallerSPOffset + stack_adjustment));
}
LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
LoadRR(sp, r1);
mov(sp, r1);
int frame_ends = pc_offset();
return frame_ends;
}
......@@ -1457,7 +1457,7 @@ void TurboAssembler::PrepareForTailCall(Register callee_args_count,
Register tmp_reg = scratch1;
Label loop;
AddP(tmp_reg, callee_args_count, Operand(1)); // +1 for receiver
LoadRR(r1, tmp_reg);
mov(r1, tmp_reg);
bind(&loop);
LoadP(tmp_reg, MemOperand(src_reg, -kSystemPointerSize));
StoreU64(tmp_reg, MemOperand(dst_reg, -kSystemPointerSize));
......@@ -1466,7 +1466,7 @@ void TurboAssembler::PrepareForTailCall(Register callee_args_count,
BranchOnCount(r1, &loop);
// Leave current frame.
LoadRR(sp, dst_reg);
mov(sp, dst_reg);
}
MemOperand MacroAssembler::StackLimitAsMemOperand(StackLimitKind kind) {
......@@ -1532,12 +1532,12 @@ void MacroAssembler::InvokePrologue(Register expected_parameter_count,
{
Label copy, check;
Register num = r7, src = r8, dest = ip; // r7 and r8 are context and root.
LoadRR(src, sp);
mov(src, sp);
// Update stack pointer.
ShiftLeftP(scratch, expected_parameter_count,
Operand(kSystemPointerSizeLog2));
SubP(sp, sp, scratch);
LoadRR(dest, sp);
mov(dest, sp);
ltgr(num, actual_parameter_count);
b(&check);
bind(&copy);
......@@ -1781,7 +1781,7 @@ void MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit,
Label* on_in_range) {
if (lower_limit != 0) {
Register scratch = r0;
LoadRR(scratch, value);
mov(scratch, value);
slgfi(scratch, Operand(lower_limit));
CmpLogicalP(scratch, Operand(higher_limit - lower_limit));
} else {
......@@ -2093,7 +2093,7 @@ void TurboAssembler::PrepareCallCFunction(int num_reg_arguments,
if (frame_alignment > kSystemPointerSize) {
// Make stack end at alignment and make room for stack arguments
// -- preserving original value of sp.
LoadRR(scratch, sp);
mov(scratch, sp);
lay(sp, MemOperand(sp, -(stack_passed_arguments + 1) * kSystemPointerSize));
DCHECK(base::bits::IsPowerOfTwo(frame_alignment));
ClearRightImm(sp, sp,
......@@ -2279,15 +2279,13 @@ Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3,
UNREACHABLE();
}
void TurboAssembler::mov(Register dst, Register src) { lgr(dst, src); }
void TurboAssembler::mov(Register dst, const Operand& src) {
#if V8_TARGET_ARCH_S390X
int64_t value;
#else
int value;
#endif
int64_t value = 0;
if (src.is_heap_object_request()) {
RequestHeapObject(src.heap_object_request());
value = 0;
} else {
value = src.immediate();
}
......@@ -2297,15 +2295,35 @@ void TurboAssembler::mov(Register dst, const Operand& src) {
RecordRelocInfo(src.rmode(), value);
}
#if V8_TARGET_ARCH_S390X
int32_t hi_32 = static_cast<int64_t>(value) >> 32;
int32_t hi_32 = static_cast<int32_t>(value >> 32);
int32_t lo_32 = static_cast<int32_t>(value);
if (src.rmode() == RelocInfo::NONE) {
if (hi_32 == 0) {
if (is_uint16(lo_32)) {
llill(dst, Operand(lo_32));
return;
}
llilf(dst, Operand(lo_32));
return;
} else if (lo_32 == 0) {
if (is_uint16(hi_32)) {
llihl(dst, Operand(hi_32));
return;
}
llihf(dst, Operand(hi_32));
return;
} else if (is_int16(value)) {
lghi(dst, Operand(value));
return;
} else if (is_int32(value)) {
lgfi(dst, Operand(value));
return;
}
}
iihf(dst, Operand(hi_32));
iilf(dst, Operand(lo_32));
#else
iilf(dst, Operand(value));
#endif
}
void TurboAssembler::Mul32(Register dst, const MemOperand& src1) {
......@@ -2691,7 +2709,7 @@ void TurboAssembler::AddP(Register dst, Register src, const Operand& opnd) {
AddPImm_RRI(dst, src, opnd);
return;
}
LoadRR(dst, src);
mov(dst, src);
}
AddP(dst, opnd);
}
......@@ -2740,7 +2758,7 @@ void TurboAssembler::AddP(Register dst, Register src1, Register src2) {
AddP_RRR(dst, src1, src2);
return;
} else {
LoadRR(dst, src1);
mov(dst, src1);
}
} else if (dst == src2) {
src2 = src1;
......@@ -2761,7 +2779,7 @@ void TurboAssembler::AddP_ExtendSrc(Register dst, Register src1,
lgfr(dst, src2);
agr(dst, src1);
} else {
if (dst != src1) LoadRR(dst, src1);
if (dst != src1) mov(dst, src1);
agfr(dst, src2);
}
#else
......@@ -2960,7 +2978,7 @@ void TurboAssembler::SubP(Register dst, Register src1, Register src2) {
SubP_RRR(dst, src1, src2);
return;
}
if (dst != src1 && dst != src2) LoadRR(dst, src1);
if (dst != src1 && dst != src2) mov(dst, src1);
// In scenario where we have dst = src - dst, we need to swap and negate
if (dst != src1 && dst == src2) {
Label done;
......@@ -2980,7 +2998,7 @@ void TurboAssembler::SubP(Register dst, Register src1, Register src2) {
void TurboAssembler::SubP_ExtendSrc(Register dst, Register src1,
Register src2) {
#if V8_TARGET_ARCH_S390X
if (dst != src1 && dst != src2) LoadRR(dst, src1);
if (dst != src1 && dst != src2) mov(dst, src1);
// In scenario where we have dst = src - dst, we need to swap and negate
if (dst != src1 && dst == src2) {
......@@ -3118,7 +3136,7 @@ void TurboAssembler::AndP(Register dst, Register src1, Register src2) {
AndP_RRR(dst, src1, src2);
return;
} else {
LoadRR(dst, src1);
mov(dst, src1);
}
} else if (dst == src2) {
src2 = src1;
......@@ -3205,7 +3223,7 @@ void TurboAssembler::AndP(Register dst, Register src, const Operand& opnd) {
}
// If we are &'ing zero, we can just whack the dst register and skip copy
if (dst != src && (0 != value)) LoadRR(dst, src);
if (dst != src && (0 != value)) mov(dst, src);
AndP(dst, opnd);
}
......@@ -3241,7 +3259,7 @@ void TurboAssembler::OrP(Register dst, Register src1, Register src2) {
OrP_RRR(dst, src1, src2);
return;
} else {
LoadRR(dst, src1);
mov(dst, src1);
}
} else if (dst == src2) {
src2 = src1;
......@@ -3293,7 +3311,7 @@ void TurboAssembler::Or(Register dst, Register src, const Operand& opnd) {
// OR Pointer Size - dst = src & imm
void TurboAssembler::OrP(Register dst, Register src, const Operand& opnd) {
if (dst != src) LoadRR(dst, src);
if (dst != src) mov(dst, src);
OrP(dst, opnd);
}
......@@ -3329,7 +3347,7 @@ void TurboAssembler::XorP(Register dst, Register src1, Register src2) {
XorP_RRR(dst, src1, src2);
return;
} else {
LoadRR(dst, src1);
mov(dst, src1);
}
} else if (dst == src2) {
src2 = src1;
......@@ -3378,7 +3396,7 @@ void TurboAssembler::Xor(Register dst, Register src, const Operand& opnd) {
// XOR Pointer Size - dst = src & imm
void TurboAssembler::XorP(Register dst, Register src, const Operand& opnd) {
if (dst != src) LoadRR(dst, src);
if (dst != src) mov(dst, src);
XorP(dst, opnd);
}
......@@ -3673,7 +3691,7 @@ void TurboAssembler::StoreU64(const MemOperand& mem, const Operand& opnd,
mvhi(mem, opnd);
#endif
} else {
LoadImmP(scratch, opnd);
mov(scratch, opnd);
StoreU64(scratch, mem);
}
}
......@@ -4299,7 +4317,7 @@ void TurboAssembler::ClearRightImm(Register dst, Register src,
uint64_t hexMask = ~((1L << numBitsToClear) - 1);
// S390 AND instr clobbers source. Make a copy if necessary
if (dst != src) LoadRR(dst, src);
if (dst != src) mov(dst, src);
if (numBitsToClear <= 16) {
nill(dst, Operand(static_cast<uint16_t>(hexMask)));
......@@ -4342,16 +4360,16 @@ void TurboAssembler::Popcnt64(Register dst, Register src) {
void TurboAssembler::SwapP(Register src, Register dst, Register scratch) {
if (src == dst) return;
DCHECK(!AreAliased(src, dst, scratch));
LoadRR(scratch, src);
LoadRR(src, dst);
LoadRR(dst, scratch);
mov(scratch, src);
mov(src, dst);
mov(dst, scratch);
}
void TurboAssembler::SwapP(Register src, MemOperand dst, Register scratch) {
if (dst.rx() != r0) DCHECK(!AreAliased(src, dst.rx(), scratch));
if (dst.rb() != r0) DCHECK(!AreAliased(src, dst.rb(), scratch));
DCHECK(!AreAliased(src, scratch));
LoadRR(scratch, src);
mov(scratch, src);
LoadP(src, dst);
StoreU64(scratch, dst);
}
......
......@@ -73,9 +73,7 @@ Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg,
#define XorP_RRR xgrk
// Load / Store
#define LoadRR lgr
#define LoadAndTestRR ltgr
#define LoadImmP lghi
// Compare
#define CmpPH cghi
......@@ -110,9 +108,7 @@ Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg,
#define XorP_RRR xrk
// Load / Store
#define LoadRR lr
#define LoadAndTestRR ltr
#define LoadImmP lhi
// Compare
#define CmpPH chi
......@@ -504,6 +500,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
#endif
void mov(Register dst, const Operand& src);
void mov(Register dst, Register src);
void CleanUInt32(Register x) {
#ifdef V8_TARGET_ARCH_S390X
......@@ -899,7 +896,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
if (rangeEnd > 0) // Don't need to shift if rangeEnd is zero.
ShiftRightP(dst, src, Operand(rangeEnd));
else if (dst != src) // If we didn't shift, we might need to copy
LoadRR(dst, src);
mov(dst, src);
int width = rangeStart - rangeEnd + 1;
#if V8_TARGET_ARCH_S390X
uint64_t mask = (static_cast<uint64_t>(1) << width) - 1;
......
......@@ -35,14 +35,14 @@ void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) {
// - Leave the frame.
// - Restart the frame by calling the function.
__ LoadRR(fp, r3);
__ mov(fp, r3);
__ LoadP(r3, MemOperand(fp, StandardFrameConstants::kFunctionOffset));
__ LeaveFrame(StackFrame::INTERNAL);
__ LoadTaggedPointerField(
r2, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset));
__ LoadU16(
r2, FieldMemOperand(r2, SharedFunctionInfo::kFormalParameterCountOffset));
__ LoadRR(r4, r2);
__ mov(r4, r2);
__ InvokeFunction(r3, r4, r2, JUMP_FUNCTION);
}
......
......@@ -5892,29 +5892,35 @@ EVALUATE(OILL) {
}
EVALUATE(LLIHH) {
UNIMPLEMENTED();
USE(instr);
return 0;
DCHECK_OPCODE(LLIHL);
DECODE_RI_A_INSTRUCTION(instr, r1, i2);
uint64_t imm = static_cast<uint64_t>(i2) & 0xffff;
set_register(r1, imm << 48);
return length;
}
EVALUATE(LLIHL) {
UNIMPLEMENTED();
USE(instr);
return 0;
DCHECK_OPCODE(LLIHL);
DECODE_RI_A_INSTRUCTION(instr, r1, i2);
uint64_t imm = static_cast<uint64_t>(i2) & 0xffff;
set_register(r1, imm << 32);
return length;
}
EVALUATE(LLILH) {
DCHECK_OPCODE(LLILH);
DECODE_RI_A_INSTRUCTION(instr, r1, i2);
uint64_t imm = static_cast<uint64_t>(i2);
set_register(r1, (imm << 48) >> 32);
uint64_t imm = static_cast<uint64_t>(i2) & 0xffff;
set_register(r1, imm << 16);
return length;
}
EVALUATE(LLILL) {
UNIMPLEMENTED();
USE(instr);
return 0;
DCHECK_OPCODE(LLILL);
DECODE_RI_A_INSTRUCTION(instr, r1, i2);
uint64_t imm = static_cast<uint64_t>(i2) & 0xffff;
set_register(r1, imm);
return length;
}
inline static int TestUnderMask(uint16_t val, uint16_t mask,
......
......@@ -121,7 +121,7 @@ RegExpMacroAssemblerS390::RegExpMacroAssemblerS390(Isolate* isolate, Zone* zone,
// If the code gets too big or corrupted, an internal exception will be
// raised, and we will exit right away.
__ bind(&internal_failure_label_);
__ LoadImmP(r2, Operand(FAILURE));
__ mov(r2, Operand(FAILURE));
__ Ret();
__ bind(&start_label_); // And then continue from here.
}
......@@ -338,9 +338,9 @@ void RegExpMacroAssemblerS390::CheckNotBackReferenceIgnoreCase(
// Address of start of capture.
__ AddP(r2, end_of_input_address());
// Length of capture.
__ LoadRR(r4, r3);
__ mov(r4, r3);
// Save length in callee-save register for use on return.
__ LoadRR(r6, r3);
__ mov(r6, r3);
// Address of current input position.
__ AddP(r3, current_input_offset(), end_of_input_address());
if (read_backward) {
......@@ -620,7 +620,7 @@ bool RegExpMacroAssemblerS390::CheckSpecialCharacterClass(uc16 type,
}
void RegExpMacroAssemblerS390::Fail() {
__ LoadImmP(r2, Operand(FAILURE));
__ mov(r2, Operand(FAILURE));
__ b(&exit_label_);
}
......@@ -674,13 +674,13 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
//
// Set frame pointer in space for it if this is not a direct call
// from generated code.
__ LoadRR(frame_pointer(), sp);
__ mov(frame_pointer(), sp);
__ lay(sp, MemOperand(sp, -10 * kSystemPointerSize));
STATIC_ASSERT(kSuccessfulCaptures == kInputString - kSystemPointerSize);
__ mov(r1, Operand::Zero()); // success counter
STATIC_ASSERT(kStringStartMinusOne ==
kSuccessfulCaptures - kSystemPointerSize);
__ LoadRR(r0, r1); // offset of location
__ mov(r0, r1); // offset of location
__ StoreMultipleP(r0, r9, MemOperand(sp, 0));
STATIC_ASSERT(kBacktrackCount == kStringStartMinusOne - kSystemPointerSize);
__ Push(r1); // The backtrack counter.
......@@ -723,7 +723,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
__ LoadP(r3, MemOperand(frame_pointer(), kStartIndex));
// Set r1 to address of char before start of the input string
// (effectively string position -1).
__ LoadRR(r1, r4);
__ mov(r1, r4);
__ SubP(r1, current_input_offset(), Operand(char_size()));
if (mode_ == UC16) {
__ ShiftLeftP(r0, r3, Operand(1));
......@@ -885,7 +885,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
__ b(&load_char_start_regexp);
} else {
__ LoadImmP(r2, Operand(SUCCESS));
__ mov(r2, Operand(SUCCESS));
}
}
......@@ -897,7 +897,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
__ bind(&return_r2);
// Skip sp past regexp registers and local variables..
__ LoadRR(sp, frame_pointer());
__ mov(sp, frame_pointer());
// Restore registers r6..r15.
__ LoadMultipleP(r6, sp, MemOperand(sp, 6 * kSystemPointerSize));
......@@ -934,7 +934,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
// Call GrowStack(backtrack_stackpointer(), &stack_base)
static const int num_arguments = 3;
__ PrepareCallCFunction(num_arguments, r2);
__ LoadRR(r2, backtrack_stackpointer());
__ mov(r2, backtrack_stackpointer());
__ AddP(r3, frame_pointer(), Operand(kStackHighEnd));
__ mov(r4, Operand(ExternalReference::isolate_address(isolate())));
ExternalReference grow_stack = ExternalReference::re_grow_stack(isolate());
......@@ -944,7 +944,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
__ CmpP(r2, Operand::Zero());
__ beq(&exit_with_exception);
// Otherwise use return value as new stack pointer.
__ LoadRR(backtrack_stackpointer(), r2);
__ mov(backtrack_stackpointer(), r2);
// Restore saved registers and continue.
SafeReturn();
}
......@@ -953,13 +953,13 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
// If any of the code above needed to exit with an exception.
__ bind(&exit_with_exception);
// Exit with Result EXCEPTION(-1) to signal thrown exception.
__ LoadImmP(r2, Operand(EXCEPTION));
__ mov(r2, Operand(EXCEPTION));
__ b(&return_r2);
}
if (fallback_label_.is_linked()) {
__ bind(&fallback_label_);
__ LoadImmP(r2, Operand(FALLBACK_TO_EXPERIMENTAL));
__ mov(r2, Operand(FALLBACK_TO_EXPERIMENTAL));
__ b(&return_r2);
}
......@@ -1098,7 +1098,7 @@ void RegExpMacroAssemblerS390::CallCheckStackGuardState(Register scratch) {
static constexpr int num_arguments = 3;
__ PrepareCallCFunction(num_arguments, scratch);
// RegExp code frame pointer.
__ LoadRR(r4, frame_pointer());
__ mov(r4, frame_pointer());
// Code of self.
__ mov(r3, Operand(masm_->CodeObject()));
// r2 becomes return address pointer.
......@@ -1208,7 +1208,7 @@ void RegExpMacroAssemblerS390::SafeReturn() {
void RegExpMacroAssemblerS390::SafeCallTarget(Label* name) {
__ bind(name);
__ CleanseP(r14);
__ LoadRR(r0, r14);
__ mov(r0, r14);
__ mov(ip, Operand(masm_->CodeObject()));
__ SubP(r0, r0, ip);
__ push(r0);
......
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