diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-04 05:34:15 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-04 05:34:15 +0800 |
| commit | 183e2354e9fdd107be420cbb185c1d239434aa48 (patch) | |
| tree | ce5c42cb6e9790072d5dcf00d1d55cb7f6573ddc /backend/include/rcc/MIR/MIPrinter.h | |
| parent | 67d6231fba98e776c0f442e5b6908e279c35e346 (diff) | |
| download | rcc-project-183e2354e9fdd107be420cbb185c1d239434aa48.tar.gz rcc-project-183e2354e9fdd107be420cbb185c1d239434aa48.tar.xz | |
[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.
Diffstat (limited to 'backend/include/rcc/MIR/MIPrinter.h')
| -rw-r--r-- | backend/include/rcc/MIR/MIPrinter.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/backend/include/rcc/MIR/MIPrinter.h b/backend/include/rcc/MIR/MIPrinter.h new file mode 100644 index 0000000..663859e --- /dev/null +++ b/backend/include/rcc/MIR/MIPrinter.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_MIR_MIPRINTER_H +#define RCC_MIR_MIPRINTER_H + +#include "rcc/MIR/MIParser.h" +#include "rcc/Support/Error.h" + +#include <string> + +namespace rcc { + +class MachineFunction; +class TargetDescription; + +namespace mir { + +enum class MIPrintMode : unsigned char { + Complete, + Readable, +}; + +struct MIPrinterOptions final { + MIPrintMode Mode = MIPrintMode::Complete; +}; + +[[nodiscard]] Expected<std::string> printMachineFunctionBody(const MachineFunction &Function, + const TargetDescription &Target, + const MIParserContext &Context = {}, + MIPrinterOptions Options = {}); + +} // namespace mir +} // namespace rcc + +#endif // RCC_MIR_MIPRINTER_H |
