Skip to content

Commit

Permalink
Merge pull request #6301 from keithc-ca/gcc10
Browse files Browse the repository at this point in the history
Fix problems compiling with gcc 10
  • Loading branch information
jdmpapin authored Jan 20, 2022
2 parents 58cf69c + e27c697 commit 4dc0bc5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
54 changes: 42 additions & 12 deletions compiler/codegen/OMRRegisterDependency.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -33,8 +33,8 @@

#ifndef OMR_REGISTER_DEPENDENCY_GROUP_CONNECTOR
#define OMR_REGISTER_DEPENDENCY_GROUP_CONNECTOR
namespace OMR { class RegisterDependencyGroup; }
namespace OMR { typedef OMR::RegisterDependencyGroup RegisterDependencyGroupConnector; }
namespace OMR { class RegisterDependencyGroup; }
namespace OMR { typedef OMR::RegisterDependencyGroup RegisterDependencyGroupConnector; }
#endif

#include "env/TRMemory.hpp"
Expand All @@ -50,17 +50,25 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

TR_ALLOC_WITHOUT_NEW(TR_Memory::RegisterDependencyGroup)

RegisterDependencyGroup() {}
RegisterDependencyGroup()
#if defined(OMR_ARCH_S390)
: _numUses(0)
#elif defined(OMR_ARCH_X86) /* defined(OMR_ARCH_S390) */
: _mayNeedToPopFPRegisters(false), _needToClearFPStack(false)
#elif defined(__GNUC__) && !defined(__clang__) /* defined(OMR_ARCH_S390) */
: _unused('\0')
#endif /* defined(OMR_ARCH_S390) */
{}

TR::RegisterDependencyGroup *self();

void *operator new(size_t s, int32_t numDependencies, TR_Memory *m)
{
if (numDependencies > NUM_DEFAULT_DEPENDENCIES)
{
s += (numDependencies - NUM_DEFAULT_DEPENDENCIES) * sizeof(TR::RegisterDependency);
}

TR_ASSERT(numDependencies >= 0, "Number of dependencies must be non-negative");
s += numDependencies * sizeof(TR::RegisterDependency);
#if defined(__clang__) || !defined(__GNUC__)
s -= NUM_DEFAULT_DEPENDENCIES * sizeof(TR::RegisterDependency);
#endif /* defined(__clang__) || !defined(__GNUC__) */
return m->allocateHeapMemory(s, TR_MemoryBase::RegisterDependencyGroup);
}

Expand Down Expand Up @@ -195,15 +203,37 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

protected:

#if defined(OMR_ARCH_S390)
int8_t _numUses;
#elif defined(OMR_ARCH_X86) /* defined(OMR_ARCH_S390) */
bool _mayNeedToPopFPRegisters;
bool _needToClearFPStack;
#elif defined(__GNUC__) && !defined(__clang__) /* defined(OMR_ARCH_S390) */
/* a flexible array cannot be the only member of a class */
private:
char _unused;
protected:
#endif /* defined(OMR_ARCH_S390) */

#if defined(__GNUC__) && !defined(__clang__)
TR::RegisterDependency _dependencies[];
#else /* defined(__GNUC__) && !defined(__clang__) */
/*
* Only GCC appears to support extending a classs with a flexible array member,
* so, for other compilers, we declare the length to be 1 and adjust accordingly
* in the new operator.
*/
private:
static const size_t NUM_DEFAULT_DEPENDENCIES = 1;

protected:
TR::RegisterDependency _dependencies[NUM_DEFAULT_DEPENDENCIES];
#endif /* defined(__GNUC__) && !defined(__clang__) */
};

class RegisterDependencyConditions
{
protected:
RegisterDependencyConditions() {};
RegisterDependencyConditions() {}

public:
TR_ALLOC(TR_Memory::RegisterDependencyConditions)
Expand Down Expand Up @@ -382,4 +412,4 @@ class RegisterDependencyMap
};
}

#endif
#endif /* OMR_REGISTER_DEPENDENCY_INCL */
19 changes: 6 additions & 13 deletions compiler/x/codegen/OMRRegisterDependency.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -35,8 +35,8 @@

#ifndef OMR_REGISTER_DEPENDENCY_GROUP_CONNECTOR
#define OMR_REGISTER_DEPENDENCY_GROUP_CONNECTOR
namespace OMR { namespace X86 { class RegisterDependencyGroup; } }
namespace OMR { typedef OMR::X86::RegisterDependencyGroup RegisterDependencyGroupConnector; }
namespace OMR { namespace X86 { class RegisterDependencyGroup; } }
namespace OMR { typedef OMR::X86::RegisterDependencyGroup RegisterDependencyGroupConnector; }
#endif

#include "compiler/codegen/OMRRegisterDependency.hpp"
Expand All @@ -63,15 +63,9 @@ namespace X86
{
class OMR_EXTENSIBLE RegisterDependencyGroup : public OMR::RegisterDependencyGroup
{
bool _mayNeedToPopFPRegisters;
bool _needToClearFPStack;

public:

RegisterDependencyGroup()
: _mayNeedToPopFPRegisters(false),
_needToClearFPStack(false)
{}
RegisterDependencyGroup() : OMR::RegisterDependencyGroup() {}

void setDependencyInfo(uint32_t index,
TR::Register *vr,
Expand All @@ -80,7 +74,6 @@ class OMR_EXTENSIBLE RegisterDependencyGroup : public OMR::RegisterDependencyGro
uint8_t flag = UsesDependentRegister,
bool isAssocRegDependency = false);


TR::RegisterDependency *findDependency(TR::Register *vr, uint32_t stop)
{
TR::RegisterDependency *result = NULL;
Expand Down Expand Up @@ -285,7 +278,7 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
uint32_t numConditions,
char *prefix,
FILE *pOutFile);
#endif
#endif /* defined(DEBUG) || defined(PROD_WITH_ASSUMES) */

};
}
Expand All @@ -298,4 +291,4 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
TR::RegisterDependencyConditions * generateRegisterDependencyConditions(TR::Node *, TR::CodeGenerator *, uint32_t = 0, List<TR::Register> * = 0);
TR::RegisterDependencyConditions * generateRegisterDependencyConditions(uint32_t, uint32_t, TR::CodeGenerator *);

#endif
#endif /* OMR_X86_REGISTER_DEPENDENCY_INCL */
23 changes: 11 additions & 12 deletions compiler/z/codegen/OMRRegisterDependency.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2020 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -73,7 +73,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup : public OMR::RegisterDependencyGro
{
public:

RegisterDependencyGroup() : _numUses(0) {}
RegisterDependencyGroup() : OMR::RegisterDependencyGroup() {}

uint32_t genBitMapOfAssignableGPRs(TR::CodeGenerator *cg, uint32_t numberOfRegisters);

Expand All @@ -91,7 +91,6 @@ class OMR_EXTENSIBLE RegisterDependencyGroup : public OMR::RegisterDependencyGro

protected:

int8_t _numUses;
};

class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
Expand Down Expand Up @@ -124,16 +123,16 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
TR::CodeGenerator *cg);

RegisterDependencyConditions(TR::RegisterDependencyGroup *_preConditions,
TR::RegisterDependencyGroup *_postConditions,
uint16_t numPreConds, uint16_t numPostConds, TR::CodeGenerator *cg)
TR::RegisterDependencyGroup *_postConditions,
uint16_t numPreConds, uint16_t numPostConds, TR::CodeGenerator *cg)
: _preConditions(_preConditions),
_postConditions(_postConditions),
_numPreConditions(numPreConds),
_addCursorForPre(numPreConds),
_numPostConditions(numPostConds),
_addCursorForPost(numPostConds),
_isUsed(false),
_cg(cg)
_cg(cg)
{}

RegisterDependencyConditions()
Expand All @@ -144,7 +143,7 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
_numPostConditions(0),
_addCursorForPost(0),
_isUsed(false),
_cg(NULL)
_cg(NULL)
{}

//VMThread work: implicitly add an extra post condition for a possible vm thread
Expand Down Expand Up @@ -269,10 +268,10 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
bool addPreConditionIfNotAlreadyInserted(TR::RegisterDependency *regDep);
bool addPreConditionIfNotAlreadyInserted(TR::Register *vr,
TR::RealRegister::RegNum rr,
uint8_t flag = ReferencesDependentRegister);
uint8_t flag = ReferencesDependentRegister);
bool addPreConditionIfNotAlreadyInserted(TR::Register *vr,
TR::RealRegister::RegDep rr,
uint8_t flag = ReferencesDependentRegister);
uint8_t flag = ReferencesDependentRegister);

/**
* @brief Adds the provided \c TR::RegisterDependency to the set of postconditions if it
Expand All @@ -286,10 +285,10 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions

bool addPostConditionIfNotAlreadyInserted(TR::Register *vr,
TR::RealRegister::RegNum rr,
uint8_t flag = ReferencesDependentRegister);
uint8_t flag = ReferencesDependentRegister);
bool addPostConditionIfNotAlreadyInserted(TR::Register *vr,
TR::RealRegister::RegDep rr,
uint8_t flag = ReferencesDependentRegister);
uint8_t flag = ReferencesDependentRegister);

TR::RegisterDependencyConditions *clone(TR::CodeGenerator *cg, int32_t additionalRegDeps);

Expand Down Expand Up @@ -335,4 +334,4 @@ class RegisterDependencyConditions: public OMR::RegisterDependencyConditions
}
}

#endif
#endif /* OMR_Z_REGISTER_DEPENDENCY_INCL */

0 comments on commit 4dc0bc5

Please sign in to comment.