aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/include/rcc/CodeGen/MachineIRTypes.h14
-rw-r--r--backend/lib/CodeGen/LiveIntervals.cpp6
-rw-r--r--backend/lib/CodeGen/LiveRegUnits.cpp8
-rw-r--r--backend/lib/CodeGen/LiveVariables.cpp8
4 files changed, 19 insertions, 17 deletions
diff --git a/backend/include/rcc/CodeGen/MachineIRTypes.h b/backend/include/rcc/CodeGen/MachineIRTypes.h
index 66369e0..abd547e 100644
--- a/backend/include/rcc/CodeGen/MachineIRTypes.h
+++ b/backend/include/rcc/CodeGen/MachineIRTypes.h
@@ -173,6 +173,20 @@ public:
return RawValue;
}
+ [[nodiscard]] constexpr LaneMask operator~() const noexcept {
+ return LaneMask(~RawValue);
+ }
+
+ constexpr LaneMask &operator|=(LaneMask Other) noexcept {
+ RawValue |= Other.RawValue;
+ return *this;
+ }
+
+ constexpr LaneMask &operator&=(LaneMask Other) noexcept {
+ RawValue &= Other.RawValue;
+ return *this;
+ }
+
friend constexpr bool operator==(LaneMask Left, LaneMask Right) noexcept = default;
friend constexpr LaneMask operator|(LaneMask Left, LaneMask Right) noexcept {
diff --git a/backend/lib/CodeGen/LiveIntervals.cpp b/backend/lib/CodeGen/LiveIntervals.cpp
index 5a01693..dc25af8 100644
--- a/backend/lib/CodeGen/LiveIntervals.cpp
+++ b/backend/lib/CodeGen/LiveIntervals.cpp
@@ -23,10 +23,6 @@
namespace rcc {
namespace {
-[[nodiscard]] LaneMask subtractLanes(LaneMask Left, LaneMask Right) noexcept {
- return LaneMask::fromRaw(Left.rawValue() & ~Right.rawValue());
-}
-
[[nodiscard]] bool maskIntersects(LaneMask Access, std::optional<LaneMask> Filter) noexcept {
return !Filter || Access.intersects(*Filter);
}
@@ -242,7 +238,7 @@ partitionVirtualRegisterLanes(Register Reg, MachineFunction &Function,
std::vector<LaneMask> Refined;
for (const LaneMask Group : Groups) {
const LaneMask Intersection = Group & Access;
- const LaneMask Difference = subtractLanes(Group, Access);
+ const LaneMask Difference = Group & ~Access;
if (!Intersection.empty())
Refined.push_back(Intersection);
if (!Difference.empty())
diff --git a/backend/lib/CodeGen/LiveRegUnits.cpp b/backend/lib/CodeGen/LiveRegUnits.cpp
index e0aa992..935478e 100644
--- a/backend/lib/CodeGen/LiveRegUnits.cpp
+++ b/backend/lib/CodeGen/LiveRegUnits.cpp
@@ -21,10 +21,6 @@
namespace rcc {
namespace {
-[[nodiscard]] LaneMask subtractLanes(LaneMask Left, LaneMask Right) noexcept {
- return LaneMask::fromRaw(Left.rawValue() & ~Right.rawValue());
-}
-
template <typename KeyT>
void addLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask Lanes) {
if (Lanes.empty())
@@ -34,7 +30,7 @@ void addLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask Lan
Values.emplace(Key, Lanes);
return;
}
- Position->second = Position->second | Lanes;
+ Position->second |= Lanes;
}
template <typename KeyT>
@@ -42,7 +38,7 @@ void removeLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask
const auto Position = Values.find(Key);
if (Position == Values.end() || Lanes.empty())
return;
- Position->second = subtractLanes(Position->second, Lanes);
+ Position->second &= ~Lanes;
if (Position->second.empty())
Values.erase(Position);
}
diff --git a/backend/lib/CodeGen/LiveVariables.cpp b/backend/lib/CodeGen/LiveVariables.cpp
index 5efdbd4..4f65f72 100644
--- a/backend/lib/CodeGen/LiveVariables.cpp
+++ b/backend/lib/CodeGen/LiveVariables.cpp
@@ -33,10 +33,6 @@
namespace rcc {
namespace {
-[[nodiscard]] LaneMask subtractLanes(LaneMask Left, LaneMask Right) noexcept {
- return LaneMask::fromRaw(Left.rawValue() & ~Right.rawValue());
-}
-
template <typename KeyT>
void addLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask Lanes) {
if (Lanes.empty())
@@ -46,7 +42,7 @@ void addLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask Lan
Values.emplace(Key, Lanes);
return;
}
- Position->second = Position->second | Lanes;
+ Position->second |= Lanes;
}
template <typename KeyT>
@@ -54,7 +50,7 @@ void removeLanes(std::unordered_map<KeyT, LaneMask> &Values, KeyT Key, LaneMask
const auto Position = Values.find(Key);
if (Position == Values.end() || Lanes.empty())
return;
- Position->second = subtractLanes(Position->second, Lanes);
+ Position->second &= ~Lanes;
if (Position->second.empty())
Values.erase(Position);
}