diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-07 01:27:41 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-07 01:27:41 +0800 |
| commit | 76d89700953ddd81cf31ab8f260eddf67e93aa85 (patch) | |
| tree | c96a453164154b2d1559cea36910df52103f0f19 /backend/unittests/MIR/EmbeddedIRTest.cpp | |
| parent | 183e2354e9fdd107be420cbb185c1d239434aa48 (diff) | |
| download | rcc-project-76d89700953ddd81cf31ab8f260eddf67e93aa85.tar.gz rcc-project-76d89700953ddd81cf31ab8f260eddf67e93aa85.tar.xz | |
[MIR] Complete document parsing and printing
Implement the single LLVM-compatible MIR document path with structured\nembedded-IR references, YAML mappings, constants, and deterministic printing.\n\nKeep pointer LLT widths DataLayout-derived, reject layout-dependent output\nwhen embedded IR is omitted, and record the fixed-baseline compatibility\ncontract and regression coverage.
Diffstat (limited to 'backend/unittests/MIR/EmbeddedIRTest.cpp')
| -rw-r--r-- | backend/unittests/MIR/EmbeddedIRTest.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/backend/unittests/MIR/EmbeddedIRTest.cpp b/backend/unittests/MIR/EmbeddedIRTest.cpp index 58c6162..bbac841 100644 --- a/backend/unittests/MIR/EmbeddedIRTest.cpp +++ b/backend/unittests/MIR/EmbeddedIRTest.cpp @@ -17,6 +17,7 @@ int testReferenceIndex() { const std::string Input = "; @commented = global i8 0\n" "target datalayout = \"e-m:e-p:64:64\"\n" "target triple = \"riscv64-unknown-linux-gnu\"\n" + "%pair = type { i32, i32 }\n" "@ordinary = global i32 0\n" "@\"space\\20global\" = external global i8\n" "declare void @declared()\n" @@ -25,12 +26,12 @@ int testReferenceIndex() { ") {\n" "entry:\n" " %slot = alloca i32, align 4\n" - " %not_an_alloca = add i32 1, 2\n" + " %not_an_alloca = add i32 %argument, 2\n" " br label %\"exit\\20block\"\n" "\"exit\\20block\":\n" " ret void\n" "}\n" - "!0 = !{}\n" + "!0 = !DILocation(line: 1, scope: !1)\n" "!llvm.module.flags = !{!0}\n"; rcc::mir::EmbeddedIRIndexResult Result = rcc::mir::indexEmbeddedIR("embedded.ll", Input); @@ -54,6 +55,9 @@ int testReferenceIndex() { if (Function->allocas().size() != 1 || Function->alloca("slot") == nullptr || Function->alloca("not_an_alloca") != nullptr) return fail("Embedded IR indexing must distinguish named allocas from other local values"); + if (Function->values().size() != 3 || Function->value("argument") == nullptr || + Function->value("slot") == nullptr || Function->value("not_an_alloca") == nullptr) + return fail("Embedded IR indexing must retain arguments and instruction results"); if (!Index->hasGlobalValue("ordinary") || !Index->hasGlobalValue("space global") || !Index->hasGlobalValue("declared") || Index->hasGlobalValue("commented")) @@ -61,6 +65,12 @@ int testReferenceIndex() { if (Index->metadata("0") == nullptr || Index->metadata("llvm.module.flags") == nullptr || Index->metadataDefinitions().size() != 2) return fail("Embedded IR indexing must retain numeric and named metadata definitions"); + if (Index->metadata("0")->DynamicType != "DILocation" || + Index->metadata("llvm.module.flags")->DynamicType != "MDTuple") + return fail("Embedded IR indexing must classify metadata dynamic types"); + if (Index->typeDefinitions().size() != 1 || Index->typeDefinition("pair") == nullptr || + Index->typeDefinition("pair")->Definition != "{ i32, i32 }") + return fail("Embedded IR indexing must retain named type definitions"); return 0; } |
