From 183e2354e9fdd107be420cbb185c1d239434aa48 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Tue, 4 Aug 2026 05:34:15 +0800 Subject: [MIR] Add machine instruction parser and printer Parse MachineFunction bodies in two passes and serialize the same MachineIR model in complete or readable form. Extend instruction attachments and memory operands required by the fixed LLVM MIR grammar, and cover deterministic parse-print round trips. --- backend/include/rcc/CodeGen/MachineMemOperand.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'backend/include/rcc/CodeGen/MachineMemOperand.h') diff --git a/backend/include/rcc/CodeGen/MachineMemOperand.h b/backend/include/rcc/CodeGen/MachineMemOperand.h index b6cb07f..a9e19a6 100644 --- a/backend/include/rcc/CodeGen/MachineMemOperand.h +++ b/backend/include/rcc/CodeGen/MachineMemOperand.h @@ -5,6 +5,7 @@ #include "rcc/CodeGen/LowLevelType.h" #include "rcc/CodeGen/MachineIRTypes.h" +#include "rcc/CodeGen/MachineMetadata.h" #include #include @@ -138,6 +139,14 @@ public: JumpTable, GlobalSymbol, ExternalSymbol, + IRValue, + Stack, + GOT, + ConstantPoolPseudo, + JumpTablePseudo, + CallEntryGlobal, + CallEntryExternal, + Custom, }; MemoryBase() = default; @@ -147,6 +156,14 @@ public: [[nodiscard]] static MemoryBase jumpTable(JumpTableIndex Index); [[nodiscard]] static MemoryBase globalSymbol(std::string Name); [[nodiscard]] static MemoryBase externalSymbol(std::string Name); + [[nodiscard]] static MemoryBase irValue(std::string Name); + [[nodiscard]] static MemoryBase stack(); + [[nodiscard]] static MemoryBase got(); + [[nodiscard]] static MemoryBase constantPoolPseudo(); + [[nodiscard]] static MemoryBase jumpTablePseudo(); + [[nodiscard]] static MemoryBase callEntryGlobal(std::string Name); + [[nodiscard]] static MemoryBase callEntryExternal(std::string Name); + [[nodiscard]] static MemoryBase custom(std::string Name); [[nodiscard]] Kind kind() const noexcept { return BaseKind; @@ -177,11 +194,17 @@ struct MachineMemOperandDesc final { SyncScopeID SyncScope; MemorySize Size; Alignment Align; + std::optional BaseAlign; std::uint32_t AddressSpace = 0; MemoryBase Base; std::int64_t Offset = 0; std::optional OffsetRange; std::optional AliasSource; + std::optional TBAA; + std::optional AliasScope; + std::optional NoAlias; + std::optional NoAliasAddressSpace; + std::optional RangeMetadata; std::uint16_t TargetFlags = 0; friend bool operator==(const MachineMemOperandDesc &Left, -- cgit v1.2.3