Commit aa89c107 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

s390x: cleanup Load/LoadXXXLiteral

Change-Id: I9761b80f32beeb53e466fc67ee1c535075e4225c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2586993Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#71717}
parent 8ffbf0d2
......@@ -591,11 +591,11 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ LoadAndTestP(scrach, MemOperand(r7));
__ bne(&non_outermost_js, Label::kNear);
__ StoreU64(fp, MemOperand(r7));
__ Load(scrach, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
__ mov(scrach, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME));
Label cont;
__ b(&cont, Label::kNear);
__ bind(&non_outermost_js);
__ Load(scrach, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ mov(scrach, Operand(StackFrame::INNER_JSENTRY_FRAME));
__ bind(&cont);
__ StoreU64(scrach, MemOperand(sp)); // frame-type
......@@ -1878,7 +1878,7 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(r2);
__ Load(r6, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
__ mov(r6, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR)));
// Stack updated as such:
// old SP --->
// R14 Return Addr
......@@ -2927,7 +2927,7 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
// which we would need to shift right the high part of the mantissa.
// Scratch contains exponent - 1.
// Load scratch with 52 - exponent (load with 51 - (exponent - 1)).
__ Load(r0, Operand(51));
__ mov(r0, Operand(51));
__ SubP(scratch, r0, scratch);
__ CmpP(scratch, Operand::Zero());
__ ble(&only_low, Label::kNear);
......@@ -2937,12 +2937,12 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
// Scratch contains: 52 - exponent.
// We needs: exponent - 20.
// So we use: 32 - scratch = 32 - 52 + exponent = exponent - 20.
__ Load(r0, Operand(32));
__ mov(r0, Operand(32));
__ SubP(scratch, r0, scratch);
__ ExtractBitMask(result_reg, scratch_high, HeapNumber::kMantissaMask);
// Set the implicit 1 before the mantissa part in scratch_high.
STATIC_ASSERT(HeapNumber::kMantissaBitsInTopWord >= 16);
__ Load(r0, Operand(1 << ((HeapNumber::kMantissaBitsInTopWord)-16)));
__ mov(r0, Operand(1 << ((HeapNumber::kMantissaBitsInTopWord)-16)));
__ ShiftLeftP(r0, r0, Operand(16));
__ OrP(result_reg, result_reg, r0);
__ ShiftLeft(r0, result_reg, scratch);
......
......@@ -1235,7 +1235,7 @@ void TurboAssembler::StubPrologue(StackFrame::Type type, Register base,
int prologue_offset) {
{
ConstantPoolUnavailableScope constant_pool_unavailable(this);
Load(r1, Operand(StackFrame::TypeToMarker(type)));
mov(r1, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(r1);
}
}
......@@ -1254,7 +1254,7 @@ void TurboAssembler::EnterFrame(StackFrame::Type type,
// type
// CodeObject <-- new sp
Load(ip, Operand(StackFrame::TypeToMarker(type)));
mov(ip, Operand(StackFrame::TypeToMarker(type)));
PushCommonFrame(ip);
}
......@@ -1311,7 +1311,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
// all of the pushes that have happened inside of V8
// since we were called from C code
CleanseP(r14);
Load(r1, Operand(StackFrame::TypeToMarker(frame_type)));
mov(r1, Operand(StackFrame::TypeToMarker(frame_type)));
PushCommonFrame(r1);
// Reserve room for saved entry sp.
lay(sp, MemOperand(fp, -ExitFrameConstants::kFixedFrameSizeFromFp));
......@@ -3401,49 +3401,6 @@ void TurboAssembler::NotP(Register dst, Register src) {
#endif
}
// works the same as mov
void TurboAssembler::Load(Register dst, const Operand& opnd) {
intptr_t value = opnd.immediate();
if (is_int16(value)) {
#if V8_TARGET_ARCH_S390X
lghi(dst, opnd);
#else
lhi(dst, opnd);
#endif
} else if (is_int32(value)) {
#if V8_TARGET_ARCH_S390X
lgfi(dst, opnd);
#else
iilf(dst, opnd);
#endif
} else if (is_uint32(value)) {
#if V8_TARGET_ARCH_S390X
llilf(dst, opnd);
#else
iilf(dst, opnd);
#endif
} else {
int32_t hi_32 = static_cast<int64_t>(value) >> 32;
int32_t lo_32 = static_cast<int32_t>(value);
iihf(dst, Operand(hi_32));
iilf(dst, Operand(lo_32));
}
}
void TurboAssembler::Load(Register dst, const MemOperand& opnd) {
DCHECK(is_int20(opnd.offset()));
#if V8_TARGET_ARCH_S390X
lgf(dst, opnd); // 64<-32
#else
if (is_uint12(opnd.offset())) {
l(dst, opnd);
} else {
ly(dst, opnd);
}
#endif
}
void TurboAssembler::LoadPositiveP(Register result, Register input) {
#if V8_TARGET_ARCH_S390X
lpgr(result, input);
......@@ -3625,10 +3582,6 @@ void TurboAssembler::BranchOnCount(Register r1, Label* l) {
}
}
void TurboAssembler::LoadIntLiteral(Register dst, int value) {
Load(dst, Operand(value));
}
void TurboAssembler::LoadSmiLiteral(Register dst, Smi smi) {
intptr_t value = static_cast<intptr_t>(smi.ptr());
#if defined(V8_COMPRESS_POINTERS) || defined(V8_31BIT_SMIS_ON_64BIT_ARCH)
......@@ -3640,37 +3593,6 @@ void TurboAssembler::LoadSmiLiteral(Register dst, Smi smi) {
#endif
}
void TurboAssembler::LoadDoubleLiteral(DoubleRegister result, uint64_t value,
Register scratch) {
uint32_t hi_32 = value >> 32;
uint32_t lo_32 = static_cast<uint32_t>(value);
// Load the 64-bit value into a GPR, then transfer it to FPR via LDGR
if (value == 0) {
lzdr(result);
} else if (lo_32 == 0) {
llihf(scratch, Operand(hi_32));
ldgr(result, scratch);
} else {
iihf(scratch, Operand(hi_32));
iilf(scratch, Operand(lo_32));
ldgr(result, scratch);
}
}
void TurboAssembler::LoadDoubleLiteral(DoubleRegister result, double value,
Register scratch) {
uint64_t int_val = bit_cast<uint64_t, double>(value);
LoadDoubleLiteral(result, int_val, scratch);
}
void TurboAssembler::LoadFloat32Literal(DoubleRegister result, float value,
Register scratch) {
uint64_t int_val = static_cast<uint64_t>(bit_cast<uint32_t, float>(value))
<< 32;
LoadDoubleLiteral(result, int_val, scratch);
}
void TurboAssembler::CmpSmiLiteral(Register src1, Smi smi, Register scratch) {
#if defined(V8_COMPRESS_POINTERS) || defined(V8_31BIT_SMIS_ON_64BIT_ARCH)
// CFI takes 32-bit immediate.
......@@ -3695,7 +3617,7 @@ void TurboAssembler::LoadP(Register dst, const MemOperand& mem,
if (!is_int20(offset)) {
DCHECK(scratch != no_reg && scratch != r0 && mem.rx() == r0);
DCHECK(scratch != mem.rb());
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
src = MemOperand(mem.rb(), scratch);
}
lg(dst, src);
......@@ -3707,7 +3629,7 @@ void TurboAssembler::LoadP(Register dst, const MemOperand& mem,
} else {
DCHECK(scratch != no_reg && scratch != r0 && mem.rx() == r0);
DCHECK(scratch != mem.rb());
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
l(dst, MemOperand(mem.rb(), scratch));
}
#endif
......@@ -3719,7 +3641,7 @@ void TurboAssembler::StoreU64(Register src, const MemOperand& mem,
if (!is_int20(mem.offset())) {
DCHECK(scratch != no_reg);
DCHECK(scratch != r0);
LoadIntLiteral(scratch, mem.offset());
mov(scratch, Operand(mem.offset()));
#if V8_TARGET_ARCH_S390X
stg(src, MemOperand(mem.rb(), scratch));
#else
......@@ -3822,7 +3744,7 @@ void TurboAssembler::LoadS32(Register dst, const MemOperand& mem,
if (!is_int20(offset)) {
DCHECK(scratch != no_reg);
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
#if V8_TARGET_ARCH_S390X
lgf(dst, MemOperand(mem.rb(), scratch));
#else
......@@ -3862,7 +3784,7 @@ void TurboAssembler::LoadU32(Register dst, const MemOperand& mem,
llgf(dst, mem);
} else if (scratch != no_reg) {
// Materialize offset into scratch register.
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
llgf(dst, MemOperand(base, scratch));
} else {
DCHECK(false);
......@@ -3878,7 +3800,7 @@ void TurboAssembler::LoadU32(Register dst, const MemOperand& mem,
use_RXYform = true;
} else if (scratch != no_reg) {
// Materialize offset into scratch register.
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
} else {
DCHECK(false);
}
......@@ -4171,7 +4093,7 @@ void TurboAssembler::StoreU32(Register src, const MemOperand& mem,
use_RXYform = true;
} else if (scratch != no_reg) {
// Materialize offset into scratch register.
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
} else {
// scratch is no_reg
DCHECK(false);
......@@ -4203,7 +4125,7 @@ void TurboAssembler::LoadS16(Register dst, const MemOperand& mem,
if (!is_int20(offset)) {
DCHECK(scratch != no_reg);
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
#if V8_TARGET_ARCH_S390X
lgh(dst, MemOperand(base, scratch));
#else
......@@ -4235,7 +4157,7 @@ void TurboAssembler::StoreU16(Register src, const MemOperand& mem,
sthy(src, mem);
} else {
DCHECK(scratch != no_reg);
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
sth(src, MemOperand(base, scratch));
}
}
......@@ -4253,7 +4175,7 @@ void TurboAssembler::StoreU8(Register src, const MemOperand& mem,
stcy(src, mem);
} else {
DCHECK(scratch != no_reg);
LoadIntLiteral(scratch, offset);
mov(scratch, Operand(offset));
stc(src, MemOperand(base, scratch));
}
}
......
......@@ -391,8 +391,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CmpLogicalByte(const MemOperand& mem, const Operand& imm);
// Load 32bit
void Load(Register dst, const MemOperand& opnd);
void Load(Register dst, const Operand& opnd);
void LoadS32(Register dst, const MemOperand& opnd, Register scratch = no_reg);
void LoadS32(Register dst, Register src);
void LoadU32(Register dst, const MemOperand& opnd, Register scratch = no_reg);
......@@ -721,18 +719,42 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// new S390 macro-assembler interfaces that are slightly higher level
// than assembler-s390 and may generate variable length sequences
// load a literal signed int value <value> to GPR <dst>
void LoadIntLiteral(Register dst, int value);
// load an SMI value <value> to GPR <dst>
void LoadSmiLiteral(Register dst, Smi smi);
// load a literal double value <value> to FPR <result>
void LoadDoubleLiteral(DoubleRegister result, double value, Register scratch);
void LoadDoubleLiteral(DoubleRegister result, uint64_t value,
Register scratch);
template <class T>
void LoadF64(DoubleRegister result, T value, Register scratch) {
static_assert(sizeof(T) == kDoubleSize, "Expect input size to be 8");
uint64_t int_val = bit_cast<uint64_t, T>(value);
// Load the 64-bit value into a GPR, then transfer it to FPR via LDGR
uint32_t hi_32 = int_val >> 32;
uint32_t lo_32 = static_cast<uint32_t>(int_val);
if (int_val == 0) {
lzdr(result);
} else if (lo_32 == 0) {
llihf(scratch, Operand(hi_32));
ldgr(result, scratch);
} else {
iihf(scratch, Operand(hi_32));
iilf(scratch, Operand(lo_32));
ldgr(result, scratch);
}
}
template <class T>
void LoadF32(DoubleRegister result, T value, Register scratch) {
static_assert(sizeof(T) == kFloatSize, "Expect input size to be 4");
uint32_t int_val = bit_cast<uint32_t, T>(value);
LoadF64(result, static_cast<uint64_t>(int_val) << 32, scratch);
}
// void LoadF64(DoubleRegister result, double value, Register scratch);
// void LoadF64(DoubleRegister result, uint64_t value,
// Register scratch);
void LoadFloat32Literal(DoubleRegister result, float value, Register scratch);
// void LoadF32(DoubleRegister result, float value, Register scratch);
void StoreU32(Register src, const MemOperand& mem, Register scratch = no_reg);
......
......@@ -4599,7 +4599,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
#endif
__ mov(dst, Operand(src.ToInt32(), src.rmode()));
} else {
__ Load(dst, Operand(src.ToInt32()));
__ mov(dst, Operand(src.ToInt32()));
}
break;
case Constant::kInt64:
......@@ -4607,7 +4607,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (RelocInfo::IsWasmReference(src.rmode())) {
__ mov(dst, Operand(src.ToInt64(), src.rmode()));
} else {
__ Load(dst, Operand(src.ToInt64()));
__ mov(dst, Operand(src.ToInt64()));
}
#else
__ mov(dst, Operand(src.ToInt64()));
......@@ -4661,9 +4661,9 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
? src.ToFloat32()
: src.ToFloat64().value();
if (src.type() == Constant::kFloat32) {
__ LoadFloat32Literal(dst, src.ToFloat32(), kScratchReg);
__ LoadF32<float>(dst, src.ToFloat32(), kScratchReg);
} else {
__ LoadDoubleLiteral(dst, value, kScratchReg);
__ LoadF64<double>(dst, value, kScratchReg);
}
if (destination->IsFloatStackSlot()) {
......
......@@ -758,7 +758,7 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) {
// One slot beyond address of register 0.
__ lay(r3,
MemOperand(frame_pointer(), kRegisterZero + kSystemPointerSize));
__ Load(r4, Operand(num_saved_registers_));
__ mov(r4, Operand(num_saved_registers_));
Label init_loop;
__ bind(&init_loop);
__ StoreU64(r1, MemOperand(r3, -kSystemPointerSize));
......
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