Commit 5615807b authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

[arm64] Do not use literal pool for non-relocatable constants.

Use a sequence of move instructions instead.

Bug: 
Change-Id: I63a45ce7baaa9ebcba0d3e86910839e2ddedecd5
Reviewed-on: https://chromium-review.googlesource.com/888561Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Cr-Commit-Position: refs/heads/master@{#50906}
parent 68c85fe0
......@@ -4742,6 +4742,9 @@ void Assembler::GrowBuffer() {
void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) {
// Non-relocatable constants should not end up in the literal pool.
DCHECK(!RelocInfo::IsNone(rmode));
// We do not try to reuse pool constants.
RelocInfo rinfo(reinterpret_cast<byte*>(pc_), rmode, data, nullptr);
bool write_reloc_info = true;
......
......@@ -651,10 +651,12 @@ void TurboAssembler::Fmov(VRegister vd, double imm) {
if (bits == 0) {
fmov(vd, xzr);
} else {
Ldr(vd, imm);
UseScratchRegisterScope temps(this);
Register tmp = temps.AcquireX();
Mov(tmp, bits);
fmov(vd, tmp);
}
} else {
// TODO(all): consider NEON support for load literal.
Movi(vd, bits);
}
}
......@@ -678,12 +680,10 @@ void TurboAssembler::Fmov(VRegister vd, float imm) {
} else {
UseScratchRegisterScope temps(this);
Register tmp = temps.AcquireW();
// TODO(all): Use Assembler::ldr(const VRegister& ft, float imm).
Mov(tmp, bit_cast<uint32_t>(imm));
Fmov(vd, tmp);
}
} else {
// TODO(all): consider NEON support for load literal.
Movi(vd, bits);
}
}
......@@ -748,12 +748,6 @@ void TurboAssembler::Ldr(const CPURegister& rt, const Operand& operand) {
ldr(rt, operand);
}
void TurboAssembler::Ldr(const CPURegister& rt, double imm) {
DCHECK(allow_macro_instructions());
DCHECK(rt.Is64Bits());
ldr(rt, Immediate(bit_cast<uint64_t>(imm)));
}
void TurboAssembler::Lsl(const Register& rd, const Register& rn,
unsigned shift) {
DCHECK(allow_macro_instructions());
......
......@@ -670,8 +670,6 @@ class TurboAssembler : public Assembler {
// Load a literal from the inline constant pool.
inline void Ldr(const CPURegister& rt, const Operand& imm);
// Helper function for double immediate.
inline void Ldr(const CPURegister& rt, double imm);
// Claim or drop stack space without actually accessing memory.
//
......
......@@ -6686,13 +6686,23 @@ TEST(ldur_stur) {
TEARDOWN();
}
namespace {
void LoadLiteral(MacroAssembler* masm, Register reg, uint64_t imm) {
// Since we do not allow non-relocatable entries in the literal pool, we need
// to fake a relocation mode that is not NONE here.
masm->Ldr(reg, Immediate(imm, RelocInfo::RUNTIME_ENTRY));
}
} // namespace
TEST(ldr_pcrel_large_offset) {
INIT_V8();
SETUP_SIZE(1 * MB);
START();
__ Ldr(x1, Immediate(0x1234567890ABCDEFUL));
LoadLiteral(&masm, x1, 0x1234567890ABCDEFUL);
{
v8::internal::PatchingAssembler::BlockPoolsScope scope(&masm);
......@@ -6702,7 +6712,7 @@ TEST(ldr_pcrel_large_offset) {
}
}
__ Ldr(x2, Immediate(0x1234567890ABCDEFUL));
LoadLiteral(&masm, x2, 0x1234567890ABCDEFUL);
END();
......@@ -6719,14 +6729,13 @@ TEST(ldr_literal) {
SETUP();
START();
__ Ldr(x2, Immediate(0x1234567890ABCDEFUL));
__ Ldr(d13, 1.234);
LoadLiteral(&masm, x2, 0x1234567890ABCDEFUL);
END();
RUN();
CHECK_EQUAL_64(0x1234567890ABCDEFUL, x2);
CHECK_EQUAL_FP64(1.234, d13);
TEARDOWN();
}
......@@ -6758,8 +6767,8 @@ static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option,
__ CheckConstPool(true, true);
CHECK_CONSTANT_POOL_SIZE(0);
__ Ldr(x0, Immediate(0x1234567890ABCDEFUL));
__ Ldr(d0, 1.234);
LoadLiteral(&masm, x0, 0x1234567890ABCDEFUL);
LoadLiteral(&masm, x1, 0xABCDEF1234567890UL);
CHECK_CONSTANT_POOL_SIZE(16);
code_size += 2 * kInstructionSize;
......@@ -6799,8 +6808,8 @@ static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option,
CHECK_CONSTANT_POOL_SIZE(0);
// These loads should be after the pool (and will require a new one).
__ Ldr(x4, Immediate(0x34567890ABCDEF12UL));
__ Ldr(d4, 123.4);
LoadLiteral(&masm, x4, 0x34567890ABCDEF12UL);
LoadLiteral(&masm, x5, 0xABCDEF0123456789UL);
CHECK_CONSTANT_POOL_SIZE(16);
END();
......@@ -6808,9 +6817,9 @@ static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option,
// Check that the literals loaded correctly.
CHECK_EQUAL_64(0x1234567890ABCDEFUL, x0);
CHECK_EQUAL_FP64(1.234, d0);
CHECK_EQUAL_64(0xABCDEF1234567890UL, x1);
CHECK_EQUAL_64(0x34567890ABCDEF12UL, x4);
CHECK_EQUAL_FP64(123.4, d4);
CHECK_EQUAL_64(0xABCDEF0123456789UL, x5);
TEARDOWN();
}
......
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