From 6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Tue, 11 Aug 2026 17:37:42 +0800 Subject: [MIR] Accept fixed-baseline LLVM syntax --- backend/include/rcc/MIR/EmbeddedIR.h | 9 +++++++++ backend/include/rcc/MIR/MIDebugSyntax.h | 9 +++++++++ backend/include/rcc/MIR/MIParser.h | 1 + 3 files changed, 19 insertions(+) (limited to 'backend/include/rcc/MIR') diff --git a/backend/include/rcc/MIR/EmbeddedIR.h b/backend/include/rcc/MIR/EmbeddedIR.h index 522a217..99f1493 100644 --- a/backend/include/rcc/MIR/EmbeddedIR.h +++ b/backend/include/rcc/MIR/EmbeddedIR.h @@ -6,6 +6,7 @@ #include "rcc/Support/TextDiagnostic.h" #include +#include #include #include #include @@ -52,6 +53,10 @@ public: return IsDefinition; } + [[nodiscard]] bool isUnnamed() const noexcept { + return IsUnnamed; + } + [[nodiscard]] std::span blocks() const noexcept { return Blocks; } @@ -80,9 +85,12 @@ private: std::string Name; TextRange NameRange; bool IsDefinition = false; + bool IsUnnamed = false; + std::uint64_t NextUnnamedSlot = 0; std::vector Blocks; std::vector Allocas; std::vector Values; + std::vector LocalReferences; std::unordered_map> BlockNameToIndex; std::unordered_map> AllocaNameToIndex; std::unordered_map> ValueNameToIndex; @@ -131,6 +139,7 @@ public: } [[nodiscard]] const EmbeddedIRFunction *function(std::string_view Name) const noexcept; + [[nodiscard]] const EmbeddedIRFunction *unnamedFunction(std::size_t Ordinal) const noexcept; [[nodiscard]] const EmbeddedIRReference *globalObject(std::string_view Name) const noexcept; [[nodiscard]] const EmbeddedIRMetadataDefinition *metadata(std::string_view Name) const noexcept; [[nodiscard]] const EmbeddedIRTypeDefinition * diff --git a/backend/include/rcc/MIR/MIDebugSyntax.h b/backend/include/rcc/MIR/MIDebugSyntax.h index a8427dc..4952128 100644 --- a/backend/include/rcc/MIR/MIDebugSyntax.h +++ b/backend/include/rcc/MIR/MIDebugSyntax.h @@ -5,6 +5,8 @@ #include #include +#include +#include #include namespace rcc::mir { @@ -12,6 +14,13 @@ namespace rcc::mir { [[nodiscard]] std::optional parseDIExpressionOpcodeName(std::string_view Name) noexcept; +[[nodiscard]] std::optional +parseDIExpressionAttributeEncodingName(std::string_view Name) noexcept; + +[[nodiscard]] std::string invalidDIExpressionElementMessage(std::string_view Name); + +[[nodiscard]] std::string formatDIExpression(std::span Elements); + } // namespace rcc::mir #endif // RCC_MIR_MIDEBUGSYNTAX_H diff --git a/backend/include/rcc/MIR/MIParser.h b/backend/include/rcc/MIR/MIParser.h index 116a97f..16af534 100644 --- a/backend/include/rcc/MIR/MIParser.h +++ b/backend/include/rcc/MIR/MIParser.h @@ -65,6 +65,7 @@ struct MIParserContext final { std::vector JumpTables; std::vector Metadata; std::vector SyncScopes; + std::function HasIRBlock; std::function(std::string_view)> InternSyncScope; std::function(std::uint32_t)> PointerSizeInBits; std::uint32_t DefaultPointerSizeInBits = 0; -- cgit v1.2.3