Skip to content

Commit

Permalink
Merge pull request #6327 from Akira1Saitoh/aarch64SystemLinkageVectorReg
Browse files Browse the repository at this point in the history
AArch64: Preserve vector registers across calls on system linkage
  • Loading branch information
knn-k authored Feb 3, 2022
2 parents aea0efc + abc5a41 commit 96a484d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
12 changes: 11 additions & 1 deletion compiler/aarch64/codegen/ARM64SystemLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,14 @@ int32_t TR::ARM64SystemLinkage::buildArgs(TR::Node *callNode,
}
}

/* Spills all vector registers */
if (killsVectorRegisters())
{
TR::Register *tmpReg = cg()->allocateRegister();
dependencies->addPostCondition(tmpReg, TR::RealRegister::KillVectorRegs);
cg()->stopUsingRegister(tmpReg);
}

if (numMemArgs > 0)
{
TR::RealRegister *sp = cg()->machine()->getRealRegister(properties.getStackPointerRegister());
Expand All @@ -935,10 +943,12 @@ TR::Register *TR::ARM64SystemLinkage::buildDirectDispatch(TR::Node *callNode)
const TR::ARM64LinkageProperties &pp = getProperties();
TR::RealRegister *sp = cg()->machine()->getRealRegister(pp.getStackPointerRegister());

// Extra post dependency for killing vector registers (see KillVectorRegs)
const int extraPostReg = killsVectorRegisters() ? 1 : 0;
TR::RegisterDependencyConditions *dependencies =
new (trHeapMemory()) TR::RegisterDependencyConditions(
pp.getNumberOfDependencyGPRegisters(),
pp.getNumberOfDependencyGPRegisters(), trMemory());
pp.getNumberOfDependencyGPRegisters() + extraPostReg, trMemory());

int32_t totalSize = buildArgs(callNode, dependencies);
if (totalSize > 0)
Expand Down
8 changes: 8 additions & 0 deletions compiler/aarch64/codegen/OMRLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "codegen/GenerateInstructions.hpp"
#include "codegen/Linkage.hpp"
#include "codegen/Linkage_inlines.hpp"
#include "codegen/LiveRegister.hpp"
#include "codegen/MemoryReference.hpp"
#include "compile/Compilation.hpp"
#include "il/Node.hpp"
Expand Down Expand Up @@ -409,3 +410,10 @@ TR::Instruction *OMR::ARM64::Linkage::copyParametersToHomeLocation(TR::Instructi
//
return loadCursor? loadCursor : cursor;
}

bool OMR::ARM64::Linkage::killsVectorRegisters()
{
// We need to kill vector registers if there is any live one.
TR_LiveRegisters *liveRegs = cg()->getLiveRegisters(TR_VRF);
return (!liveRegs || liveRegs->getNumberOfLiveRegisters() > 0);
}
7 changes: 7 additions & 0 deletions compiler/aarch64/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,13 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
* @return The instruction cursor after copies inserted.
*/
TR::Instruction *copyParametersToHomeLocation(TR::Instruction *cursor, bool parmsHaveBeenStored = false);

/**
* @brief Answers if vector registers need to be spilled
*
* @return true if vector registers need to be spilled.
*/
bool killsVectorRegisters();
};
} // ARM64
} // TR
Expand Down

0 comments on commit 96a484d

Please sign in to comment.