Skip to content

Commit

Permalink
Z: Use LARL when possible for patchable address constants
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Comin <spencer.comin@ibm.com>
  • Loading branch information
Spencer-Comin committed Apr 29, 2024
1 parent c454372 commit 03ab3ec
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions compiler/z/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,16 @@ genLoadAddressConstant(TR::CodeGenerator * cg, TR::Node * node, uintptr_t value,
// the address constant may need patched, must use a recognizable instruction sequence
// for TR_UnloadedClassPicSite::compensate and TR_RedefinedClassPicSite::compensate to
// be able to patch the address correctly
cursor = generateRILInstruction(cg, comp->target().is64Bit() ? TR::InstOpCode::LLILF : TR::InstOpCode::IILF, node, targetRegister, static_cast<uint32_t>(value), cursor);
bool usedLARL = false;
if (cg->canUseRelativeLongInstructions(static_cast<int64_t>(value)))
{
cursor = generateRILInstruction(cg, TR::InstOpCode::LARL, node, targetRegister, reinterpret_cast<void*>(value));
usedLARL = true;
}
else
{
cursor = generateRILInstruction(cg, comp->target().is64Bit() ? TR::InstOpCode::LLILF : TR::InstOpCode::IILF, node, targetRegister, static_cast<uint32_t>(value), cursor);
}

bool isCompressedClassPointer = false;

Expand All @@ -2546,8 +2555,8 @@ genLoadAddressConstant(TR::CodeGenerator * cg, TR::Node * node, uintptr_t value,
}

TR_ASSERT(!isCompressedClassPointer || ((value & CONSTANT64(0xFFFFFFFF00000000)) == 0), "Compressed class pointers are assumed to fit in 32 bits");
// IIHF is only needed when addresses do not fit into 32 bits
if (comp->target().is64Bit() && !isCompressedClassPointer)
// IIHF is only needed when addresses do not fit into 32 bits and LARL could not be used
if (!usedLARL && comp->target().is64Bit() && !isCompressedClassPointer)
{
toS390RILInstruction(cursor)->setisFirstOfAddressPair();
uint32_t high32 = static_cast<uint32_t>(value >> 32);
Expand Down

0 comments on commit 03ab3ec

Please sign in to comment.