diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 04:17:52 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 04:17:52 +0800 |
| commit | a2f8d7c5e22b510965327383410bd576f7cf28e7 (patch) | |
| tree | 6c0c3d1b80132aaa4932a4adc2fb0ceacdbddd2e /backend/unittests/CodeGen/LiveRegUnitsTest.cpp | |
| parent | d2cd152d658955a7fb64fb9a1329bc5bee4d8317 (diff) | |
| download | rcc-project-a2f8d7c5e22b510965327383410bd576f7cf28e7.tar.gz rcc-project-a2f8d7c5e22b510965327383410bd576f7cf28e7.tar.xz | |
[CodeGen] Split machine liveness components
Diffstat (limited to 'backend/unittests/CodeGen/LiveRegUnitsTest.cpp')
| -rw-r--r-- | backend/unittests/CodeGen/LiveRegUnitsTest.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/backend/unittests/CodeGen/LiveRegUnitsTest.cpp b/backend/unittests/CodeGen/LiveRegUnitsTest.cpp new file mode 100644 index 0000000..7f224ac --- /dev/null +++ b/backend/unittests/CodeGen/LiveRegUnitsTest.cpp @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "rcc/CodeGen/LiveRegUnits.h" + +#include "LiveTestSupport.h" + +namespace { + +using namespace rcc::test::liveness; + +void testLiveRegUnits(TestContext &Context) { + const rcc::RegisterUnitID Unit = rcc::RegisterUnitID::fromValue(9); + rcc::LiveRegUnits Present; + rcc::LiveRegUnits Removed; + Present.add(Unit, rcc::LaneMask::fromRaw(0x3)); + Removed.add(Unit, rcc::LaneMask::fromRaw(0x2)); + Present.subtract(Removed); + Context.expect(Present.lanes(Unit) == rcc::LaneMask::fromRaw(0x1) && + Present.contains(Unit, rcc::LaneMask::fromRaw(0x1)) && + !Present.intersects(Unit, rcc::LaneMask::fromRaw(0x2)), + "LiveRegUnits must preserve partial union and subtraction"); + Present.unite(Removed); + Context.expect(Present.contains(Unit, rcc::LaneMask::fromRaw(0x3)), + "LiveRegUnits union must restore all selected lanes"); +} + +} // namespace + +int main() { + TestContext Context; + auto Target = createTarget(); + Context.expect(Target.has_value(), "liveness TestTarget must be created"); + if (!Target) + return Context.result(); + testLiveRegUnits(Context); + return Context.result(); +} |
