Skip to content

Commit

Permalink
Add Post Initialization for class Z::CPU
Browse files Browse the repository at this point in the history
After the construction of the CPU class, the processor type and
processor features are "true values" from the port library. Post
initialization will change some of the values there needed for
the compiler.

Issue: #4339

Signed-off-by: Harry Yu <harryyu1994@gmail.com>
  • Loading branch information
harryyu1994 committed Mar 4, 2020
1 parent 3070301 commit 5582de6
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
9 changes: 9 additions & 0 deletions compiler/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ OMR::CPU::initializeByHostQuery()
#endif

}

TR::CPU
OMR::CPU::detect(OMRPortLibrary * const omrPortLib)
{
OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);
OMRProcessorDesc processorDescription;
omrsysinfo_get_processor_description(&processorDescription);
return TR::CPU(processorDescription);
}
7 changes: 7 additions & 0 deletions compiler/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class CPU

TR::CPU *self();

/**
* @brief Detects the underlying processor type and features using the port library and constructs a TR::CPU object
* @param[in] omrPortLib : the port library
* @return TR::CPU
*/
TR::CPU detect(OMRPortLibrary * const omrPortLib);

// Initialize CPU info by querying the host processor at compile-time
//
void initializeByHostQuery();
Expand Down
68 changes: 67 additions & 1 deletion compiler/z/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,65 @@

#include "env/CPU.hpp"

TR::CPU
OMR::Z::CPU::detect(OMRPortLibrary * const omrPortLib)
{
OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);
OMRProcessorDesc processorDescription;
omrsysinfo_get_processor_description(&processorDescription);

if (processorDescription.processor >= OMR_PROCESSOR_S390_Z10 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZ10))
processorDescription.processor = OMR_PROCESSOR_S390_FIRST;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_Z196 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZ196))
processorDescription.processor = OMR_PROCESSOR_S390_Z10;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_ZEC12 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZEC12))
processorDescription.processor = OMR_PROCESSOR_S390_Z196;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_Z13 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZ13))
processorDescription.processor = OMR_PROCESSOR_S390_ZEC12;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_Z14 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZ14))
processorDescription.processor = OMR_PROCESSOR_S390_Z13;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_Z15 && TR::Options::getCmdLineOptions()->getOption(TR_DisableZ15))
processorDescription.processor = OMR_PROCESSOR_S390_Z14;
else if (processorDescription.processor >= OMR_PROCESSOR_S390_ZNEXT && TR::Options::getCmdLineOptions()->getOption(TR_DisableZNext))
processorDescription.processor = OMR_PROCESSOR_S390_Z15;

if (processorDescription.processor < OMR_PROCESSOR_S390_Z10)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_DFP);
}

if (processorDescription.processor < OMR_PROCESSOR_S390_Z196)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_HIGH_WORD);
}

if (processorDescription.processor < OMR_PROCESSOR_S390_ZEC12)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_TE);
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_RI);
}

if (processorDescription.processor < OMR_PROCESSOR_S390_Z13)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY);
}

if (processorDescription.processor < OMR_PROCESSOR_S390_Z14)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL);
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE);
}

if (processorDescription.processor < OMR_PROCESSOR_S390_Z15)
{
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_3);
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_2);
omrsysinfo_processor_disable_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY);
}

return TR::CPU(processorDescription);
}

const char*
OMR::Z::CPU::getProcessorName(int32_t machineId)
{
Expand Down Expand Up @@ -112,7 +171,13 @@ OMR::Z::CPU::CPU()
:
OMR::CPU(),
_supportedArch(z9)
{}
{
}

OMR::Z::CPU::postInitialization()
{

}

bool
OMR::Z::CPU::getSupportsArch(Architecture arch)
Expand Down Expand Up @@ -403,3 +468,4 @@ OMR::Z::CPU::isTargetWithinBranchRelativeRILRange(intptrj_t targetAddress, intpt
return (targetAddress == sourceAddress + ((intptrj_t)((int32_t)((targetAddress - sourceAddress) / 2))) * 2) &&
(targetAddress % 2 == 0);
}

4 changes: 2 additions & 2 deletions compiler/z/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class CPU : public OMR::CPU
*/
static const char* getProcessorName(int32_t machineId);

static TR::CPU detect(OMRPortLibrary * const omrPortLib);

public:

bool getSupportsArch(Architecture arch);
Expand Down Expand Up @@ -262,8 +264,6 @@ class CPU : public OMR::CPU

CPU();

protected:

enum
{
// Available = 0x00000001,
Expand Down

0 comments on commit 5582de6

Please sign in to comment.