diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 06:52:15 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 06:52:15 +0800 |
| commit | aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28 (patch) | |
| tree | 20d94c4debfe4900e362c6c7f8443bcfbd58ec28 /backend/unittests/CodeGen | |
| parent | d62f022c92fcc3ebe2269273628943a0089683fd (diff) | |
| download | rcc-project-aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28.tar.gz rcc-project-aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28.tar.xz | |
[Support] Split APInt and APFloat ownership
Diffstat (limited to 'backend/unittests/CodeGen')
7 files changed, 25 insertions, 26 deletions
diff --git a/backend/unittests/CodeGen/GenericOpcodesTest.cpp b/backend/unittests/CodeGen/GenericOpcodesTest.cpp index 6240c6d..73c1c36 100644 --- a/backend/unittests/CodeGen/GenericOpcodesTest.cpp +++ b/backend/unittests/CodeGen/GenericOpcodesTest.cpp @@ -326,7 +326,7 @@ void testShapesAndTypes(TestContext &Context) { (*Function)->registerInfo()), "G_ADD must reject a source from a different LLT equality group"); - auto ZeroImmediate = rcc::IntegerImmediate::fromUnsigned(64, 0); + auto ZeroImmediate = rcc::APInt::fromUnsigned(64, 0); std::vector<rcc::MachineOperand> PointerConstant; PointerConstant.push_back(registerOperand(*Address, true)); if (ZeroImmediate) @@ -489,7 +489,7 @@ void testShapesAndTypes(TestContext &Context) { "G_FPEXTLOAD must reject an integer result"); const std::array<std::uint64_t, 1> FloatWords{0}; - auto FloatBits = rcc::FloatingPointBits::create(rcc::FloatSemantics::IEEESingle, FloatWords); + auto FloatBits = rcc::APFloat::create(rcc::FloatSemantics::IEEESingle, FloatWords); if (!FloatBits) std::terminate(); std::vector<rcc::MachineOperand> FConstantOperands; @@ -505,7 +505,7 @@ void testShapesAndTypes(TestContext &Context) { "G_FCONSTANT must reject mismatched floating semantics"); const std::array<std::uint64_t, 1> BFloatWords{0}; - auto BFloatBits = rcc::FloatingPointBits::create(rcc::FloatSemantics::BFloat, BFloatWords); + auto BFloatBits = rcc::APFloat::create(rcc::FloatSemantics::BFloat, BFloatWords); if (!BFloatBits) std::terminate(); FConstantOperands[0] = registerOperand(Scalar16, true); diff --git a/backend/unittests/CodeGen/MachineConstantPoolTest.cpp b/backend/unittests/CodeGen/MachineConstantPoolTest.cpp index 08b69e2..39323d5 100644 --- a/backend/unittests/CodeGen/MachineConstantPoolTest.cpp +++ b/backend/unittests/CodeGen/MachineConstantPoolTest.cpp @@ -128,7 +128,7 @@ struct PoolTargetConstant final { [[nodiscard]] rcc::MachineConstantPoolEntryDesc genericDescription(rcc::ConstantPoolMergeKind Merge) { rcc::MachineConstantPoolEntryDesc Description; - auto Integer = rcc::IntegerImmediate::fromUnsigned(32, 0x04030201U); + auto Integer = rcc::APInt::fromUnsigned(32, 0x04030201U); Description.Value = std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); Description.Size = 4; Description.Align = *rcc::Alignment::create(4); diff --git a/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp b/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp index e923108..e5acc04 100644 --- a/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp +++ b/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp @@ -335,7 +335,7 @@ struct SourceFixture final { return false; rcc::MachineConstantPoolEntryDesc HistoricalConstant; - auto HistoricalInteger = rcc::IntegerImmediate::fromUnsigned(32, 0x01010101U); + auto HistoricalInteger = rcc::APInt::fromUnsigned(32, 0x01010101U); HistoricalConstant.Value = std::move(*rcc::GenericConstantData::integer(std::move(*HistoricalInteger))); HistoricalConstant.Size = 4; diff --git a/backend/unittests/CodeGen/MachineIRBuilderTest.cpp b/backend/unittests/CodeGen/MachineIRBuilderTest.cpp index c4d5767..44a0e32 100644 --- a/backend/unittests/CodeGen/MachineIRBuilderTest.cpp +++ b/backend/unittests/CodeGen/MachineIRBuilderTest.cpp @@ -426,7 +426,7 @@ void testImplicitAndMemoryValidation(TestContext &Context) { "builder must reject unknown constant-pool and jump-table indices before allocation"); rcc::MachineConstantPoolEntryDesc ConstantDescription; - auto Integer = rcc::IntegerImmediate::fromUnsigned(64, 0x2a2a2a2a2a2a2a2aULL); + auto Integer = rcc::APInt::fromUnsigned(64, 0x2a2a2a2a2a2a2a2aULL); ConstantDescription.Value = std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); ConstantDescription.Size = 8; ConstantDescription.Align = *rcc::Alignment::create(8); diff --git a/backend/unittests/CodeGen/MachineIRCoreTest.cpp b/backend/unittests/CodeGen/MachineIRCoreTest.cpp index 7982b04..6365e59 100644 --- a/backend/unittests/CodeGen/MachineIRCoreTest.cpp +++ b/backend/unittests/CodeGen/MachineIRCoreTest.cpp @@ -102,7 +102,7 @@ void testOperandKinds(TestContext &Context) { return; const std::array<std::uint64_t, 1> HalfWords{0x3c00}; - auto HalfBits = rcc::FloatingPointBits::create(rcc::FloatSemantics::IEEEHalf, HalfWords); + auto HalfBits = rcc::APFloat::create(rcc::FloatSemantics::IEEEHalf, HalfWords); Context.expect(HalfBits.has_value(), "well-sized floating immediate must be accepted"); if (!HalfBits) return; @@ -110,10 +110,10 @@ void testOperandKinds(TestContext &Context) { "floating immediate must preserve semantics and raw bits"); const std::array<std::uint64_t, 1> OverflowHalfWords{0x10000}; - Context.expect(!rcc::FloatingPointBits::create(rcc::FloatSemantics::IEEEHalf, OverflowHalfWords), + Context.expect(!rcc::APFloat::create(rcc::FloatSemantics::IEEEHalf, OverflowHalfWords), "floating immediate bits above semantics width must be rejected"); const std::array<std::uint64_t, 2> TooManyHalfWords{0, 0}; - Context.expect(!rcc::FloatingPointBits::create(rcc::FloatSemantics::IEEEHalf, TooManyHalfWords), + Context.expect(!rcc::APFloat::create(rcc::FloatSemantics::IEEEHalf, TooManyHalfWords), "floating immediate word-count mismatch must be rejected"); auto Virtual = Function->registerInfo().createVirtualRegister(*rcc::LLT::makeInteger(32)); diff --git a/backend/unittests/CodeGen/MachineOperandTest.cpp b/backend/unittests/CodeGen/MachineOperandTest.cpp index 3cc7060..96f1f19 100644 --- a/backend/unittests/CodeGen/MachineOperandTest.cpp +++ b/backend/unittests/CodeGen/MachineOperandTest.cpp @@ -108,7 +108,7 @@ buildOperandInstruction(rcc::MachineFunction &Function, const rcc::TargetDescrip 0x0123456789abcdefULL, 0xfedcba9876543210ULL, }; - auto Integer = rcc::IntegerImmediate::create(128, Words); + auto Integer = rcc::APInt::create(128, Words); if (!Integer) return std::unexpected(Integer.error()); @@ -149,35 +149,34 @@ void testIntegerImmediate(TestContext &Context) { 0x0123456789abcdefULL, 0x0000000000000001ULL, }; - auto Integer = rcc::IntegerImmediate::create(65, Words); + auto Integer = rcc::APInt::create(65, Words); Context.expect(Integer.has_value() && Integer->bitWidth() == 65 && Integer->words().size() == 2 && Integer->words()[0] == Words[0] && Integer->words()[1] == Words[1] && Integer->isNegative() && !Integer->isZero(), "arbitrary-width integer must preserve exact little-endian words"); - Context.expect(!rcc::IntegerImmediate::create(0, std::span<const std::uint64_t>{}) && - !rcc::IntegerImmediate::create(rcc::IntegerImmediate::MaxBitWidth + 1, - std::span<const std::uint64_t>{}), - "integer immediate must reject unsupported bit widths"); + Context.expect( + !rcc::APInt::create(0, std::span<const std::uint64_t>{}) && + !rcc::APInt::create(rcc::APInt::MaxBitWidth + 1, std::span<const std::uint64_t>{}), + "integer immediate must reject unsupported bit widths"); const std::array<std::uint64_t, 2> TwoWords{1, 0}; const std::array<std::uint64_t, 1> HighBits{0x100}; - Context.expect(!rcc::IntegerImmediate::create(64, TwoWords) && - !rcc::IntegerImmediate::create(8, HighBits), + Context.expect(!rcc::APInt::create(64, TwoWords) && !rcc::APInt::create(8, HighBits), "integer immediate must reject word-count and high-bit mismatches"); - auto UnsignedMaximum = rcc::IntegerImmediate::fromUnsigned(8, 255); - auto UnsignedOverflow = rcc::IntegerImmediate::fromUnsigned(8, 256); - auto SignedMinimum = rcc::IntegerImmediate::fromSigned(8, -128); - auto SignedMaximum = rcc::IntegerImmediate::fromSigned(8, 127); - auto SignedUnderflow = rcc::IntegerImmediate::fromSigned(8, -129); - auto SignedOverflow = rcc::IntegerImmediate::fromSigned(8, 128); + auto UnsignedMaximum = rcc::APInt::fromUnsigned(8, 255); + auto UnsignedOverflow = rcc::APInt::fromUnsigned(8, 256); + auto SignedMinimum = rcc::APInt::fromSigned(8, -128); + auto SignedMaximum = rcc::APInt::fromSigned(8, 127); + auto SignedUnderflow = rcc::APInt::fromSigned(8, -129); + auto SignedOverflow = rcc::APInt::fromSigned(8, 128); Context.expect(UnsignedMaximum && UnsignedMaximum->words()[0] == 255 && !UnsignedOverflow && SignedMinimum && SignedMinimum->words()[0] == 128 && SignedMaximum && SignedMaximum->words()[0] == 127 && !SignedUnderflow && !SignedOverflow, "integer immediate scalar factories must enforce signedness and width"); - auto SignExtended = rcc::IntegerImmediate::fromSigned(128, -1); - auto Zero = rcc::IntegerImmediate::fromUnsigned(128, 0); + auto SignExtended = rcc::APInt::fromSigned(128, -1); + auto Zero = rcc::APInt::fromUnsigned(128, 0); Context.expect(SignExtended && SignExtended->isNegative() && SignExtended->words().size() == 2 && SignExtended->words()[0] == std::numeric_limits<std::uint64_t>::max() && SignExtended->words()[1] == std::numeric_limits<std::uint64_t>::max() && diff --git a/backend/unittests/CodeGen/MachineVerifierTest.cpp b/backend/unittests/CodeGen/MachineVerifierTest.cpp index 528ff3b..c8c512f 100644 --- a/backend/unittests/CodeGen/MachineVerifierTest.cpp +++ b/backend/unittests/CodeGen/MachineVerifierTest.cpp @@ -642,7 +642,7 @@ void testTableReferenceFailures(TestContext &Context) { return; rcc::MachineConstantPoolEntryDesc ConstantDescription; - auto Integer = rcc::IntegerImmediate::fromUnsigned(32, 0x01010101U); + auto Integer = rcc::APInt::fromUnsigned(32, 0x01010101U); ConstantDescription.Value = std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); ConstantDescription.Size = 4; ConstantDescription.Align = *rcc::Alignment::create(4); |
