From fde3e045d4dcc5c404cb4216389e18b0e720b8e0 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Thu, 13 Aug 2026 12:55:12 +0800 Subject: [IR] Split LL parsing, assembly writing, and data layout --- backend/lib/CodeGen/MIRParser/MIRParser.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'backend/lib/CodeGen/MIRParser/MIRParser.cpp') diff --git a/backend/lib/CodeGen/MIRParser/MIRParser.cpp b/backend/lib/CodeGen/MIRParser/MIRParser.cpp index e22f1bc..3b89491 100644 --- a/backend/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/backend/lib/CodeGen/MIRParser/MIRParser.cpp @@ -18,7 +18,7 @@ #include "rcc/CodeGen/TargetDescription.h" #include "rcc/CodeGen/TargetMIRTextInfo.h" #include "rcc/CodeGen/TargetRegisterInfo.h" -#include "rcc/MIR/LLVMConstantSyntax.h" +#include "rcc/IR/DataLayout.h" #include #include @@ -74,11 +74,8 @@ std::string_view MIRDocumentParser::effectiveDataLayout() const noexcept { return {}; } -LLVMConstantSyntaxOptions MIRDocumentParser::pointerLayoutOptions() const noexcept { - return { - .DataLayout = effectiveDataLayout(), - .NamedTypes = {}, - }; +Expected MIRDocumentParser::dataLayout() const { + return DataLayout::parse(effectiveDataLayout()); } bool MIRDocumentParser::requireKind(const yaml::Node &Node, yaml::NodeKind Kind, @@ -160,7 +157,13 @@ MIRDocumentParseResult MIRDocumentParser::run() { } if (!effectiveDataLayout().empty()) { - auto PointerSize = llvmPointerSizeInBits(0, pointerLayoutOptions()); + auto Layout = dataLayout(); + if (!Layout) { + static_cast( + importError(Stream->documents()[FirstContent].Range, Layout.error(), "mir-data-layout")); + return std::move(Result); + } + auto PointerSize = Layout->getPointerSizeInBits(); if (!PointerSize) { static_cast(importError(Stream->documents()[FirstContent].Range, PointerSize.error(), "mir-data-layout")); -- cgit v1.2.3