aboutsummaryrefslogtreecommitdiff
path: root/backend/utils/TableGen/TableGenBackends.h
blob: 7835efb552c27212e2925771683c592ec122d400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 <optional>
#include <string>
#include <string_view>
#include <vector>

namespace rcc::targetgen {

struct GeneratedDescription final {
  std::string RegisterHeader;
  std::string InstructionHeader;
  std::string TargetTables;
};

struct DescriptionGenerationResult final {
  std::optional<GeneratedDescription> Output;
  std::vector<TextDiagnostic> 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