Skip to content

Commit

Permalink
Add Platform Agnostic TM Query
Browse files Browse the repository at this point in the history
This commit adds a wrapper API around existing Transactional Memory (TM)
queries in order to have a single query that is common across all
platforms.

Signed-off-by: Irwin D'Souza <dsouzai@ca.ibm.com>
  • Loading branch information
Irwin D'Souza committed May 14, 2019
1 parent 7c6ddd3 commit 0193bf0
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
6 changes: 6 additions & 0 deletions compiler/env/OMRCPU.hpp
Expand Up @@ -131,6 +131,12 @@ class CPU
bool isI386() { return _minorArch == TR::m_arch_i386; }
bool isAMD64() { return _minorArch == TR::m_arch_amd64; }

/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
*
* @return false; this is the default answer unless overridden by an extending class.
*/
bool supportsTransactionalMemoryInstructions() { return false; }

private:
TR_Processor _processor;

Expand Down
6 changes: 6 additions & 0 deletions compiler/p/env/OMRCPU.cpp
Expand Up @@ -33,6 +33,12 @@ OMR::Power::CPU::getPPCis64bit()
return (p >= TR_FirstPPC64BitProcessor)? true : false;
}

bool
OMR::Power::CPU::supportsTransactionalMemoryInstructions()
{
return self()->getPPCSupportsTM();
}

bool
OMR::Power::CPU::isTargetWithinIFormBranchRange(intptrj_t targetAddress, intptrj_t sourceAddress)
{
Expand Down
7 changes: 7 additions & 0 deletions compiler/p/env/OMRCPU.hpp
Expand Up @@ -65,6 +65,13 @@ class CPU : public OMR::CPU
bool getPPCSupportsTM() { return false; }
bool getPPCSupportsLM() { return false; }

/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
* Alias of getPPCSupportsTM() as a platform agnostic query.
*
* @return true if TM is available, false otherwise.
*/
bool supportsTransactionalMemoryInstructions();

/**
* @brief Provides the maximum forward branch displacement in bytes reachable
* with an I-Form branch instruction.
Expand Down
8 changes: 8 additions & 0 deletions compiler/x/env/OMRCPU.cpp
Expand Up @@ -24,6 +24,7 @@
#include "env/CPU.hpp"
#include "env/JitConfig.hpp"
#include "env/ProcessorInfo.hpp"
#include "infra/Flags.hpp"
#include "x/runtime/X86Runtime.hpp"


Expand Down Expand Up @@ -112,3 +113,10 @@ OMR::X86::CPU::testOSForSSESupport()
{
return false;
}

bool
OMR::X86::CPU::supportsTransactionalMemoryInstructions()
{
flags32_t processorFeatureFlags8(self()->getX86ProcessorFeatureFlags8());
return processorFeatureFlags8.testAny(TR_RTM);
}
7 changes: 7 additions & 0 deletions compiler/x/env/OMRCPU.hpp
Expand Up @@ -64,6 +64,13 @@ class CPU : public OMR::CPU

bool testOSForSSESupport();


/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
*
* @return true if TM is available, false otherwise.
*/
bool supportsTransactionalMemoryInstructions();

/**
* @brief Answers whether the distance between a target and source address
* is within the reachable RIP displacement range.
Expand Down
8 changes: 7 additions & 1 deletion compiler/z/env/OMRCPU.cpp
Expand Up @@ -207,6 +207,12 @@ OMR::Z::CPU::getSupportsTransactionalMemoryFacility()
return _flags.testAny(S390SupportsTM);
}

bool
OMR::Z::CPU::supportsTransactionalMemoryInstructions()
{
return self()->getSupportsTransactionalMemoryFacility();
}


bool
OMR::Z::CPU::setSupportsTransactionalMemoryFacility(bool value)
Expand Down Expand Up @@ -375,4 +381,4 @@ OMR::Z::CPU::isTargetWithinBranchRelativeRILRange(intptrj_t targetAddress, intpt
{
return (targetAddress == sourceAddress + ((intptrj_t)((int32_t)((targetAddress - sourceAddress) / 2))) * 2) &&
(targetAddress % 2 == 0);
}
}
6 changes: 6 additions & 0 deletions compiler/z/env/OMRCPU.hpp
Expand Up @@ -122,6 +122,12 @@ class CPU : public OMR::CPU
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
*/
bool getSupportsTransactionalMemoryFacility();

/** \brief
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
* Alias of getSupportsTransactionalMemoryFacility() as a platform agnostic query.
*/
bool supportsTransactionalMemoryInstructions();

/** \brief
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
Expand Down

0 comments on commit 0193bf0

Please sign in to comment.