Skip to content

Commit

Permalink
Fix -Wenum-compare
Browse files Browse the repository at this point in the history
```
warning: comparison between ‘enum OMR::RealRegister::RegNum’ and ‘enum OMR::RealRegister::RegDep’ [-Wenum-compare]
```
  • Loading branch information
fjeremic committed Jun 29, 2021
1 parent 186ac2f commit bd2c683
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion compiler/codegen/OMRRealRegister.hpp
Expand Up @@ -87,7 +87,6 @@ class OMR_EXTENSIBLE RealRegister : public TR::Register
#include "codegen/PseudoRegisterEnum.hpp"
} RegDep;


protected:

RealRegister(TR::CodeGenerator *cg, RegNum n);
Expand Down Expand Up @@ -165,6 +164,44 @@ class OMR_EXTENSIBLE RealRegister : public TR::Register
TR::CodeGenerator *_cg;
};

inline bool operator<(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
// Cannot use std::underlying_type here because of lack of support in xlC
auto lhsValue = static_cast<int32_t>(lhs);
auto rhsValue = static_cast<int32_t>(rhs);
return lhsValue < rhsValue;
}

inline bool operator>(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
// Cannot use std::underlying_type here because of lack of support in xlC
auto lhsValue = static_cast<int32_t>(lhs);
auto rhsValue = static_cast<int32_t>(rhs);
return lhsValue > rhsValue;
}

inline bool operator<=(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
return !(lhs > rhs);
}

inline bool operator>=(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
return !(lhs < rhs);
}

inline bool operator==(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
// Cannot use std::underlying_type here because of lack of support in xlC
auto lhsValue = static_cast<int32_t>(lhs);
auto rhsValue = static_cast<int32_t>(rhs);
return lhsValue == rhsValue;
}

inline bool operator!=(const RealRegister::RegNum& lhs, const RealRegister::RegDep& rhs)
{
return !(lhs == rhs);
}
}

#endif

0 comments on commit bd2c683

Please sign in to comment.