aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/RegisterMask.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-01 05:01:57 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-01 05:01:57 +0800
commite2505772ab260c79d0075728082c907a90dab7ca (patch)
treed84c7d00611039dbcc0e8c303f3f7b2e34b88cd1 /backend/lib/CodeGen/RegisterMask.cpp
parent916b05ee8d79b22147c098cf52bba7fe86858f3f (diff)
downloadrcc-project-e2505772ab260c79d0075728082c907a90dab7ca.tar.gz
rcc-project-e2505772ab260c79d0075728082c907a90dab7ca.tar.xz
[CodeGen] Add machine IR value semantics
Add strongly typed machine indices, lane masks, instruction flags, fixed-point branch probabilities, and preserved-register masks. Model immutable machine memory operands with explicit base identity, size, alignment, address space, alias information, and validated atomic operation and ordering rules. Cover normal, boundary, and invalid combinations in standalone tests.
Diffstat (limited to 'backend/lib/CodeGen/RegisterMask.cpp')
-rw-r--r--backend/lib/CodeGen/RegisterMask.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/backend/lib/CodeGen/RegisterMask.cpp b/backend/lib/CodeGen/RegisterMask.cpp
new file mode 100644
index 0000000..027ee26
--- /dev/null
+++ b/backend/lib/CodeGen/RegisterMask.cpp
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "rcc/CodeGen/RegisterMask.h"
+
+namespace rcc {
+
+bool RegisterMask::preserves(PhysicalRegister PhysReg) const noexcept {
+ if (!PhysReg.isValid())
+ return false;
+
+ constexpr std::uint32_t BitsPerWord = 64;
+ const std::uint32_t RegisterNumber = PhysReg.number();
+ const std::size_t WordIndex = RegisterNumber / BitsPerWord;
+ if (WordIndex >= PreservedWords.size())
+ return false;
+
+ const std::uint32_t BitIndex = RegisterNumber % BitsPerWord;
+ return (PreservedWords[WordIndex] & (std::uint64_t{1} << BitIndex)) != 0;
+}
+
+} // namespace rcc