diff options
Diffstat (limited to 'backend/unittests/CodeGen')
6 files changed, 18 insertions, 12 deletions
diff --git a/backend/unittests/CodeGen/MachineConstantPoolTest.cpp b/backend/unittests/CodeGen/MachineConstantPoolTest.cpp index 7343fdb..08b69e2 100644 --- a/backend/unittests/CodeGen/MachineConstantPoolTest.cpp +++ b/backend/unittests/CodeGen/MachineConstantPoolTest.cpp @@ -128,8 +128,8 @@ struct PoolTargetConstant final { [[nodiscard]] rcc::MachineConstantPoolEntryDesc genericDescription(rcc::ConstantPoolMergeKind Merge) { rcc::MachineConstantPoolEntryDesc Description; - Description.Value = - rcc::GenericConstantData{"i32", {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}}}; + auto Integer = rcc::IntegerImmediate::fromUnsigned(32, 0x04030201U); + Description.Value = std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); Description.Size = 4; Description.Align = *rcc::Alignment::create(4); Description.Merge = Merge; diff --git a/backend/unittests/CodeGen/MachineFrameInfoTest.cpp b/backend/unittests/CodeGen/MachineFrameInfoTest.cpp index c67339d..78987c0 100644 --- a/backend/unittests/CodeGen/MachineFrameInfoTest.cpp +++ b/backend/unittests/CodeGen/MachineFrameInfoTest.cpp @@ -109,7 +109,8 @@ void testInvalidDescriptions(TestContext &Context) { "fixed-size stack object must reject a missing size"); auto ZeroSize = fixedObject(0, 1); - Context.expect(!Frame.createObject(ZeroSize), "fixed-size stack object must reject zero size"); + Context.expect(Frame.createObject(ZeroSize).has_value(), + "fixed-size stack objects must preserve LLVM MIR zero-sized objects"); rcc::StackObjectDesc InvalidVariable; InvalidVariable.Kind = rcc::StackObjectKind::DynamicAlloca; diff --git a/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp b/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp index 9c8a447..9d8ffd2 100644 --- a/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp +++ b/backend/unittests/CodeGen/MachineFunctionClonerTest.cpp @@ -335,8 +335,9 @@ struct SourceFixture final { return false; rcc::MachineConstantPoolEntryDesc HistoricalConstant; + auto HistoricalInteger = rcc::IntegerImmediate::fromUnsigned(32, 0x01010101U); HistoricalConstant.Value = - rcc::GenericConstantData{"i32", std::vector<std::byte>(4, std::byte{1})}; + std::move(*rcc::GenericConstantData::integer(std::move(*HistoricalInteger))); HistoricalConstant.Size = 4; HistoricalConstant.Align = *rcc::Alignment::create(4); auto HistoricalConstantIndex = Function.constantPool().addEntry(std::move(HistoricalConstant)); @@ -367,7 +368,7 @@ struct SourceFixture final { "source jump table history must contain a tombstone"); rcc::MachineJumpTableDesc JumpTable; - JumpTable.Encoding = rcc::JumpTableEntryEncoding::RelativeToTableBase; + JumpTable.Encoding = rcc::JumpTableEntryEncoding::GPRelative32BlockAddress; JumpTable.EntrySize = 4; JumpTable.Align = *rcc::Alignment::create(4); JumpTable.Targets = {Fixture.Exit, Fixture.Entry, Fixture.Exit}; diff --git a/backend/unittests/CodeGen/MachineIRBuilderTest.cpp b/backend/unittests/CodeGen/MachineIRBuilderTest.cpp index 9f5cf5e..00ffffc 100644 --- a/backend/unittests/CodeGen/MachineIRBuilderTest.cpp +++ b/backend/unittests/CodeGen/MachineIRBuilderTest.cpp @@ -426,8 +426,9 @@ 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); ConstantDescription.Value = - rcc::GenericConstantData{"i64", std::vector<std::byte>(8, std::byte{0x2a})}; + std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); ConstantDescription.Size = 8; ConstantDescription.Align = *rcc::Alignment::create(8); auto ConstantIndex = Function->constantPool().addEntry(std::move(ConstantDescription)); diff --git a/backend/unittests/CodeGen/MachineJumpTableInfoTest.cpp b/backend/unittests/CodeGen/MachineJumpTableInfoTest.cpp index 0273801..106a2a6 100644 --- a/backend/unittests/CodeGen/MachineJumpTableInfoTest.cpp +++ b/backend/unittests/CodeGen/MachineJumpTableInfoTest.cpp @@ -51,7 +51,7 @@ createFunction(TestContext &Context, std::string Name, std::uint64_t ID) { [[nodiscard]] rcc::MachineJumpTableDesc tableDescription(rcc::MachineBasicBlock &First, rcc::MachineBasicBlock &Second) { rcc::MachineJumpTableDesc Description; - Description.Encoding = rcc::JumpTableEntryEncoding::RelativeToTableBase; + Description.Encoding = rcc::JumpTableEntryEncoding::GPRelative32BlockAddress; Description.EntrySize = 4; Description.Align = *rcc::Alignment::create(4); Description.Targets = {&First, &Second, &Second}; @@ -90,14 +90,15 @@ void testTableLifecycle(TestContext &Context) { Function->jumpTableInfo().table(*First) == nullptr, "erasing a jump table must leave a tombstone"); auto CompressedDescription = tableDescription(*Entry, *Exit); - CompressedDescription.Encoding = rcc::JumpTableEntryEncoding::CompressedOffset; - CompressedDescription.EntrySize = 2; + CompressedDescription.Encoding = rcc::JumpTableEntryEncoding::Custom32; + CompressedDescription.EntrySize = 4; auto Compressed = Function->jumpTableInfo().createTable(std::move(CompressedDescription)); Context.expect(Compressed && Compressed->value() == 2, "jump table tombstone indices must never be reused"); auto Updated = tableDescription(*Entry, *Exit); - Updated.Encoding = rcc::JumpTableEntryEncoding::RelativeToEntry; + Updated.Encoding = rcc::JumpTableEntryEncoding::LabelDifference64; + Updated.EntrySize = 8; Context.expect(Function->jumpTableInfo().updateTable(*Target, std::move(Updated)).has_value() && Function->jumpTableInfo().verify().has_value() && Function->jumpTableInfo().freeze().has_value() && @@ -145,7 +146,8 @@ void testInvalidTables(TestContext &Context) { "generic jump table encoding must reject target encoding IDs"); auto OversizedCompressed = tableDescription(*Block, *Block); - OversizedCompressed.Encoding = rcc::JumpTableEntryEncoding::CompressedOffset; + OversizedCompressed.Encoding = rcc::JumpTableEntryEncoding::Custom32; + OversizedCompressed.EntrySize = 8; OversizedCompressed.EntrySize = 8; Context.expect(!Function->jumpTableInfo().createTable(std::move(OversizedCompressed)), "compressed jump table must reject oversized entries"); diff --git a/backend/unittests/CodeGen/MachineVerifierTest.cpp b/backend/unittests/CodeGen/MachineVerifierTest.cpp index a803c08..ca265a7 100644 --- a/backend/unittests/CodeGen/MachineVerifierTest.cpp +++ b/backend/unittests/CodeGen/MachineVerifierTest.cpp @@ -522,8 +522,9 @@ void testTableReferenceFailures(TestContext &Context) { return; rcc::MachineConstantPoolEntryDesc ConstantDescription; + auto Integer = rcc::IntegerImmediate::fromUnsigned(32, 0x01010101U); ConstantDescription.Value = - rcc::GenericConstantData{"i32", std::vector<std::byte>(4, std::byte{1})}; + std::move(*rcc::GenericConstantData::integer(std::move(*Integer))); ConstantDescription.Size = 4; ConstantDescription.Align = *rcc::Alignment::create(4); auto ConstantIndex = ConstantFunction->constantPool().addEntry(std::move(ConstantDescription)); |
