aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/Description/TargetDescriptionGenerator.h
blob: 9a03aa0e4284038c8d453c311bcb60e9855d4d7e (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
// SPDX-License-Identifier: GPL-3.0-or-later

// The private header has no stable include-root-relative guard name.
// NOLINTNEXTLINE(llvm-header-guard)
#ifndef RCC_TARGET_DESCRIPTION_TARGETDESCRIPTIONGENERATOR_H
#define RCC_TARGET_DESCRIPTION_TARGETDESCRIPTIONGENERATOR_H

#include "rcc/Support/TextDiagnostic.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]] DescriptionGenerationResult generateDescription(const std::string &SourceName,
                                                              std::string SourceText);

} // namespace rcc::targetgen

#endif // RCC_TARGET_DESCRIPTION_TARGETDESCRIPTIONGENERATOR_H