From 444db30751380e8fe459bfeae4c5bb2a93c596eb Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Thu, 13 Aug 2026 13:10:47 +0800 Subject: [TableGen] Split the target description generator --- backend/utils/TableGen/TableGenBackends.h | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 backend/utils/TableGen/TableGenBackends.h (limited to 'backend/utils/TableGen/TableGenBackends.h') diff --git a/backend/utils/TableGen/TableGenBackends.h b/backend/utils/TableGen/TableGenBackends.h new file mode 100644 index 0000000..7835efb --- /dev/null +++ b/backend/utils/TableGen/TableGenBackends.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// NOLINTNEXTLINE(llvm-header-guard) +#ifndef RCC_UTILS_TABLEGEN_TABLEGENBACKENDS_H +#define RCC_UTILS_TABLEGEN_TABLEGENBACKENDS_H + +#include "Common/CodeGenTarget.h" + +#include +#include +#include +#include + +namespace rcc::targetgen { + +struct GeneratedDescription final { + std::string RegisterHeader; + std::string InstructionHeader; + std::string TargetTables; +}; + +struct DescriptionGenerationResult final { + std::optional Output; + std::vector Diagnostics; + + [[nodiscard]] bool succeeded() const noexcept { + return Output.has_value() && Diagnostics.empty(); + } +}; + +[[nodiscard]] std::string emitRegisterHeader(const NormalizedTargetModel &Model, + std::string_view SourceName); +[[nodiscard]] std::string emitRegisterInfo(const NormalizedTargetModel &Model, + std::string_view SourceName); +[[nodiscard]] std::string emitRegisterBanks(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitInstructionHeader(const NormalizedTargetModel &Model, + std::string_view SourceName); +[[nodiscard]] std::string emitInstructionInfo(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitCallingConventions(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitCodeEmitter(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitAssemblyWriter(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitSubtarget(const NormalizedTargetModel &Model); +[[nodiscard]] std::string emitSearchableTables(const NormalizedTargetModel &Model); + +[[nodiscard]] DescriptionGenerationResult generateDescription(const std::string &SourceName, + std::string SourceText); + +} // namespace rcc::targetgen + +#endif // RCC_UTILS_TABLEGEN_TABLEGENBACKENDS_H -- cgit v1.2.3