mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Re-commit Register/MCRegister: Add conversion operators to avoid use of implicit convert to unsigned. NFC
Added two more conversions to satisfy MSVC and moved the declaration of MCPhysReg to MCRegister.h to enable that This reverts r367932 (git commit eac86ec25f5cd5d7a973c913d3c2ca8c90b24115) llvm-svn: 367965
This commit is contained in:
parent
b24b122e73
commit
1582e9ea20
@ -113,6 +113,19 @@ public:
|
||||
bool isValid() const {
|
||||
return Reg != 0;
|
||||
}
|
||||
|
||||
/// Comparisons between register objects
|
||||
bool operator==(const Register &Other) const { return Reg == Other.Reg; }
|
||||
bool operator!=(const Register &Other) const { return Reg != Other.Reg; }
|
||||
|
||||
/// Comparisons against register constants. E.g.
|
||||
/// * R == AArch64::WZR
|
||||
/// * R == 0
|
||||
/// * R == VirtRegMap::NO_PHYS_REG
|
||||
bool operator==(unsigned Other) const { return Reg == Other; }
|
||||
bool operator!=(unsigned Other) const { return Reg != Other; }
|
||||
bool operator==(int Other) const { return Reg == unsigned(Other); }
|
||||
bool operator!=(int Other) const { return Reg != unsigned(Other); }
|
||||
};
|
||||
|
||||
// Provide DenseMapInfo for Register
|
||||
|
@ -14,6 +14,10 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// An unsigned integer type large enough to represent all physical registers,
|
||||
/// but not necessarily virtual registers.
|
||||
using MCPhysReg = uint16_t;
|
||||
|
||||
/// Wrapper class representing physical registers. Should be passed by value.
|
||||
class MCRegister {
|
||||
unsigned Reg;
|
||||
@ -63,6 +67,22 @@ public:
|
||||
bool isValid() const {
|
||||
return Reg != 0;
|
||||
}
|
||||
|
||||
/// Comparisons between register objects
|
||||
bool operator==(const MCRegister &Other) const { return Reg == Other.Reg; }
|
||||
bool operator!=(const MCRegister &Other) const { return Reg != Other.Reg; }
|
||||
|
||||
/// Comparisons against register constants. E.g.
|
||||
/// * R == AArch64::WZR
|
||||
/// * R == 0
|
||||
/// * R == VirtRegMap::NO_PHYS_REG
|
||||
bool operator==(unsigned Other) const { return Reg == Other; }
|
||||
bool operator!=(unsigned Other) const { return Reg != Other; }
|
||||
bool operator==(int Other) const { return Reg == unsigned(Other); }
|
||||
bool operator!=(int Other) const { return Reg != unsigned(Other); }
|
||||
// MSVC requires that we explicitly declare these two as well.
|
||||
bool operator==(MCPhysReg Other) const { return Reg == unsigned(Other); }
|
||||
bool operator!=(MCPhysReg Other) const { return Reg != unsigned(Other); }
|
||||
};
|
||||
|
||||
// Provide DenseMapInfo for MCRegister
|
||||
|
@ -25,10 +25,6 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// An unsigned integer type large enough to represent all physical registers,
|
||||
/// but not necessarily virtual registers.
|
||||
using MCPhysReg = uint16_t;
|
||||
|
||||
/// MCRegisterClass - Base class of TargetRegisterClass.
|
||||
class MCRegisterClass {
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user