Skip to content

Commit

Permalink
Merge pull request #4628 from knn-k/aarch64memref14
Browse files Browse the repository at this point in the history
AArch64: Allow negative immediate offset for memory access
  • Loading branch information
0xdaryl authored Dec 6, 2019
2 parents 59e8793 + 02c7167 commit 736596e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions compiler/aarch64/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ uint8_t *OMR::ARM64::MemoryReference::generateBinaryEncoding(TR::Instruction *cu
}
else
{
TR_ASSERT(false, "Unsupported instruction type.");
TR_ASSERT_FATAL(false, "Unsupported instruction type.");
}
}
else
Expand All @@ -804,7 +804,7 @@ uint8_t *OMR::ARM64::MemoryReference::generateBinaryEncoding(TR::Instruction *cu
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
else if (isImm12OffsetInstruction(enc))
Expand All @@ -824,7 +824,16 @@ uint8_t *OMR::ARM64::MemoryReference::generateBinaryEncoding(TR::Instruction *cu
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
if (op.getMnemonic() == TR::InstOpCode::ldrimmw && displacement < 0 && constantIsImm9(displacement))
{
*wcursor &= 0xFEFFFFFF; /* rewrite the instruction ldrimmw -> ldurw */
*wcursor |= (displacement & 0x1ff) << 12; /* imm9 */
cursor += ARM64_INSTRUCTION_LENGTH;
}
else
{
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
}
else if (isExclusiveMemAccessInstruction(op.getMnemonic()))
Expand Down Expand Up @@ -853,7 +862,7 @@ uint8_t *OMR::ARM64::MemoryReference::generateBinaryEncoding(TR::Instruction *cu
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
}
Expand Down Expand Up @@ -891,7 +900,7 @@ uint32_t OMR::ARM64::MemoryReference::estimateBinaryLength(TR::InstOpCode op)
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
else if (isImm12OffsetInstruction(enc))
Expand All @@ -910,7 +919,15 @@ uint32_t OMR::ARM64::MemoryReference::estimateBinaryLength(TR::InstOpCode op)
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
if (op.getMnemonic() == TR::InstOpCode::ldrimmw && displacement < 0 && constantIsImm9(displacement))
{
/* rewrite the instruction ldrimmw -> ldurw in generateBinaryEncoding() */
return ARM64_INSTRUCTION_LENGTH;
}
else
{
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
}
else if (isExclusiveMemAccessInstruction(op.getMnemonic()))
Expand All @@ -936,7 +953,7 @@ uint32_t OMR::ARM64::MemoryReference::estimateBinaryLength(TR::InstOpCode op)
}
else
{
TR_ASSERT(false, "Offset is too large for specified instruction.");
TR_ASSERT_FATAL(false, "Offset is too large for specified instruction.");
}
}
}
Expand Down

0 comments on commit 736596e

Please sign in to comment.