Page MenuHomePhabricator

D65678.id213440.diff
No OneTemporary

File Metadata

Created
Thu, Apr 9, 10:51 AM

D65678.id213440.diff

Index: llvm/trunk/include/llvm/CodeGen/Register.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/Register.h
+++ llvm/trunk/include/llvm/CodeGen/Register.h
@@ -113,6 +113,19 @@
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
Index: llvm/trunk/include/llvm/MC/MCRegister.h
===================================================================
--- llvm/trunk/include/llvm/MC/MCRegister.h
+++ llvm/trunk/include/llvm/MC/MCRegister.h
@@ -63,6 +63,19 @@
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); }
};
// Provide DenseMapInfo for MCRegister

Event Timeline