From 76d89700953ddd81cf31ab8f260eddf67e93aa85 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Fri, 7 Aug 2026 01:27:41 +0800 Subject: [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. --- backend/include/rcc/MIR/LLVMConstantSyntax.h | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 backend/include/rcc/MIR/LLVMConstantSyntax.h (limited to 'backend/include/rcc/MIR/LLVMConstantSyntax.h') diff --git a/backend/include/rcc/MIR/LLVMConstantSyntax.h b/backend/include/rcc/MIR/LLVMConstantSyntax.h new file mode 100644 index 0000000..9d7a7d4 --- /dev/null +++ b/backend/include/rcc/MIR/LLVMConstantSyntax.h @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_MIR_LLVMCONSTANTSYNTAX_H +#define RCC_MIR_LLVMCONSTANTSYNTAX_H + +#include "rcc/CodeGen/GenericConstant.h" +#include "rcc/Support/Error.h" + +#include +#include +#include +#include +#include + +namespace rcc::mir { + +struct LLVMNamedTypeDefinition final { + std::string_view Name; + std::string_view Definition; + bool NumericName = false; +}; + +struct LLVMConstantSyntaxOptions final { + std::uint32_t DefaultPointerSizeInBits = 0; + std::string_view DataLayout; + std::span NamedTypes; + std::size_t MaximumDepth = 1024; + std::size_t MaximumNodes = std::size_t{1} << 24U; + std::size_t MaximumTokenLength = std::size_t{1} << 24U; +}; + +[[nodiscard]] Expected +parseLLVMConstant(std::string_view Text, LLVMConstantSyntaxOptions Options = {}); + +[[nodiscard]] Expected parseLLVMType(std::string_view Text, + LLVMConstantSyntaxOptions Options = {}); + +[[nodiscard]] Expected printLLVMConstant(const GenericConstantData &Constant); + +[[nodiscard]] Expected +llvmConstantStorageSize(const GenericConstantType &Type, LLVMConstantSyntaxOptions Options = {}); + +[[nodiscard]] Expected +llvmConstantPreferredAlignment(const GenericConstantType &Type, + LLVMConstantSyntaxOptions Options = {}); + +[[nodiscard]] Expected llvmPointerSizeInBits(std::uint32_t AddressSpace, + LLVMConstantSyntaxOptions Options = {}); + +} // namespace rcc::mir + +#endif // RCC_MIR_LLVMCONSTANTSYNTAX_H -- cgit v1.2.3