aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-02 21:17:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-01-07 23:04:38 +0000
commit0e1e0ce556810ad5f9d45485e686f0653530516c (patch)
treeab02ce7c4fafc0518430e9cec77d41201bce23f0 /contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h
parentc3eb0b7c19221f3a2133ab14d3ffffa61ec0c4bc (diff)
downloadsrc-0e1e0ce556810ad5f9d45485e686f0653530516c.tar.gz
src-0e1e0ce556810ad5f9d45485e686f0653530516c.zip
Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the last commit before the upstream release/17.x branch was created. PR: 273753 MFC after: 1 month (cherry picked from commit 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h')
-rw-r--r--contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h72
1 files changed, 37 insertions, 35 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h b/contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h
index 2f2d58f5185b..e1456f81d467 100644
--- a/contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h
+++ b/contrib/llvm-project/llvm/include/llvm/CodeGen/Register.h
@@ -20,8 +20,8 @@ class Register {
unsigned Reg;
public:
- constexpr Register(unsigned Val = 0): Reg(Val) {}
- constexpr Register(MCRegister Val): Reg(Val) {}
+ constexpr Register(unsigned Val = 0) : Reg(Val) {}
+ constexpr Register(MCRegister Val) : Reg(Val) {}
// Register numbers can represent physical registers, virtual registers, and
// sometimes stack slots. The unsigned values are divided into these ranges:
@@ -41,12 +41,12 @@ public:
/// returns true if Reg is in the range used for stack slots.
///
/// FIXME: remove in favor of member.
- static bool isStackSlot(unsigned Reg) {
+ static constexpr bool isStackSlot(unsigned Reg) {
return MCRegister::isStackSlot(Reg);
}
/// Return true if this is a stack slot.
- bool isStack() const { return MCRegister::isStackSlot(Reg); }
+ constexpr bool isStack() const { return MCRegister::isStackSlot(Reg); }
/// Compute the frame index from a register value representing a stack slot.
static int stackSlot2Index(Register Reg) {
@@ -62,13 +62,13 @@ public:
/// Return true if the specified register number is in
/// the physical register namespace.
- static bool isPhysicalRegister(unsigned Reg) {
+ static constexpr bool isPhysicalRegister(unsigned Reg) {
return MCRegister::isPhysicalRegister(Reg);
}
/// Return true if the specified register number is in
/// the virtual register namespace.
- static bool isVirtualRegister(unsigned Reg) {
+ static constexpr bool isVirtualRegister(unsigned Reg) {
return Reg & MCRegister::VirtualRegFlag;
}
@@ -88,31 +88,21 @@ public:
/// Return true if the specified register number is in the virtual register
/// namespace.
- bool isVirtual() const {
- return isVirtualRegister(Reg);
- }
+ constexpr bool isVirtual() const { return isVirtualRegister(Reg); }
/// Return true if the specified register number is in the physical register
/// namespace.
- bool isPhysical() const {
- return isPhysicalRegister(Reg);
- }
+ constexpr bool isPhysical() const { return isPhysicalRegister(Reg); }
/// Convert a virtual register number to a 0-based index. The first virtual
/// register in a function will get the index 0.
- unsigned virtRegIndex() const {
- return virtReg2Index(Reg);
- }
+ unsigned virtRegIndex() const { return virtReg2Index(Reg); }
- constexpr operator unsigned() const {
- return Reg;
- }
+ constexpr operator unsigned() const { return Reg; }
- unsigned id() const { return Reg; }
+ constexpr unsigned id() const { return Reg; }
- operator MCRegister() const {
- return MCRegister(Reg);
- }
+ constexpr operator MCRegister() const { return MCRegister(Reg); }
/// Utility to check-convert this value to a MCRegister. The caller is
/// expected to have already validated that this Register is, indeed,
@@ -123,29 +113,41 @@ public:
return MCRegister(Reg);
}
- bool isValid() const { return Reg != MCRegister::NoRegister; }
+ constexpr bool isValid() const { return Reg != MCRegister::NoRegister; }
/// Comparisons between register objects
- bool operator==(const Register &Other) const { return Reg == Other.Reg; }
- bool operator!=(const Register &Other) const { return Reg != Other.Reg; }
- bool operator==(const MCRegister &Other) const { return Reg == Other.id(); }
- bool operator!=(const MCRegister &Other) const { return Reg != Other.id(); }
+ constexpr bool operator==(const Register &Other) const {
+ return Reg == Other.Reg;
+ }
+ constexpr bool operator!=(const Register &Other) const {
+ return Reg != Other.Reg;
+ }
+ constexpr bool operator==(const MCRegister &Other) const {
+ return Reg == Other.id();
+ }
+ constexpr bool operator!=(const MCRegister &Other) const {
+ return Reg != Other.id();
+ }
/// 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); }
+ constexpr bool operator==(unsigned Other) const { return Reg == Other; }
+ constexpr bool operator!=(unsigned Other) const { return Reg != Other; }
+ constexpr bool operator==(int Other) const { return Reg == unsigned(Other); }
+ constexpr 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); }
+ constexpr bool operator==(MCPhysReg Other) const {
+ return Reg == unsigned(Other);
+ }
+ constexpr bool operator!=(MCPhysReg Other) const {
+ return Reg != unsigned(Other);
+ }
};
// Provide DenseMapInfo for Register
-template<> struct DenseMapInfo<Register> {
+template <> struct DenseMapInfo<Register> {
static inline unsigned getEmptyKey() {
return DenseMapInfo<unsigned>::getEmptyKey();
}
@@ -160,6 +162,6 @@ template<> struct DenseMapInfo<Register> {
}
};
-}
+} // namespace llvm
#endif // LLVM_CODEGEN_REGISTER_H