aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/MIR/LLVMConstantSyntax.h
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-07 01:27:41 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-07 01:27:41 +0800
commit76d89700953ddd81cf31ab8f260eddf67e93aa85 (patch)
treec96a453164154b2d1559cea36910df52103f0f19 /backend/include/rcc/MIR/LLVMConstantSyntax.h
parent183e2354e9fdd107be420cbb185c1d239434aa48 (diff)
downloadrcc-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/include/rcc/MIR/LLVMConstantSyntax.h')
-rw-r--r--backend/include/rcc/MIR/LLVMConstantSyntax.h52
1 files changed, 52 insertions, 0 deletions
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 <cstddef>
+#include <cstdint>
+#include <span>
+#include <string>
+#include <string_view>
+
+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<const LLVMNamedTypeDefinition> 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<GenericConstantData>
+parseLLVMConstant(std::string_view Text, LLVMConstantSyntaxOptions Options = {});
+
+[[nodiscard]] Expected<GenericConstantType> parseLLVMType(std::string_view Text,
+ LLVMConstantSyntaxOptions Options = {});
+
+[[nodiscard]] Expected<std::string> printLLVMConstant(const GenericConstantData &Constant);
+
+[[nodiscard]] Expected<std::uint64_t>
+llvmConstantStorageSize(const GenericConstantType &Type, LLVMConstantSyntaxOptions Options = {});
+
+[[nodiscard]] Expected<Alignment>
+llvmConstantPreferredAlignment(const GenericConstantType &Type,
+ LLVMConstantSyntaxOptions Options = {});
+
+[[nodiscard]] Expected<std::uint32_t> llvmPointerSizeInBits(std::uint32_t AddressSpace,
+ LLVMConstantSyntaxOptions Options = {});
+
+} // namespace rcc::mir
+
+#endif // RCC_MIR_LLVMCONSTANTSYNTAX_H