[PATCH] D65678: Register/MCRegister: Add conversion operators to avoid use of implicit convert to unsigned. NFC
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 12:50:27 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367916: Register/MCRegister: Add conversion operators to avoid use of implicit convert… (authored by dsanders, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D65678?vs=213134&id=213440#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65678/new/
https://reviews.llvm.org/D65678
Files:
llvm/trunk/include/llvm/CodeGen/Register.h
llvm/trunk/include/llvm/MC/MCRegister.h
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65678.213440.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190805/c1dc1f5d/attachment.bin>
More information about the llvm-commits
mailing list