aboutsummaryrefslogtreecommitdiff
path: root/backend/utils/TableGen/CodeEmitterGen.cpp
blob: 7d0d9e69f6ada2d91ebb819ea67005aeda8b632d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-License-Identifier: GPL-3.0-or-later

#include "TableGenBackends.h"

#include <sstream>
#include <string>

namespace rcc::targetgen {

std::string emitCodeEmitter(const NormalizedTargetModel &Model) {
  std::ostringstream Output;
  Output << "constexpr std::array<EncodingCategoryInfo, " << Model.EncodingCategories.size()
         << "> GeneratedEncodingCategories = {{\n";
  for (const NormalizedEncodingCategory &Category : Model.EncodingCategories) {
    Output << "    {EncodingCategoryID::fromValue(" << Category.ID << "), ";
    appendQuoted(Output, Category.Name);
    Output << ", " << Category.SizeInBytes << "},\n";
  }
  Output << "}};\n\n";
  return Output.str();
}

} // namespace rcc::targetgen