llvm/mlir/tools/mlir-tblgen/BytecodeDialectGen.cpp

//===- BytecodeDialectGen.cpp - Dialect bytecode read/writer gen  ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "mlir/Support/IndentedOstream.h"
#include "mlir/TableGen/GenInfo.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include <regex>

usingnamespacellvm;

static llvm::cl::OptionCategory dialectGenCat("Options for -gen-bytecode");
static llvm::cl::opt<std::string>
    selectedBcDialect("bytecode-dialect",
                      llvm::cl::desc("The dialect to gen for"),
                      llvm::cl::cat(dialectGenCat), llvm::cl::CommaSeparated);

namespace {

/// Helper class to generate C++ bytecode parser helpers.
class Generator {};
} // namespace

/// Helper to replace set of from strings to target in `s`.
/// Assumed: non-overlapping replacements.
static std::string format(StringRef templ,
                          std::map<std::string, std::string> &&map) {}

/// Return string with first character capitalized.
static std::string capitalize(StringRef str) {}

/// Return the C++ type for the given record.
static std::string getCType(Record *def) {}

void Generator::emitParseDispatch(StringRef kind, ArrayRef<Record *> vec) {}

void Generator::emitParse(StringRef kind, Record &x) {}

void printParseConditional(mlir::raw_indented_ostream &ios,
                           ArrayRef<Init *> args,
                           ArrayRef<std::string> argNames) {}

void Generator::emitParseHelper(StringRef kind, StringRef returnType,
                                StringRef builder, ArrayRef<Init *> args,
                                ArrayRef<std::string> argNames,
                                StringRef failure,
                                mlir::raw_indented_ostream &ios) {}

void Generator::emitPrint(StringRef kind, StringRef type,
                          ArrayRef<std::pair<int64_t, Record *>> vec) {}

void Generator::emitPrintHelper(Record *memberRec, StringRef kind,
                                StringRef parent, StringRef name,
                                mlir::raw_indented_ostream &ios) {}

void Generator::emitPrintDispatch(StringRef kind, ArrayRef<std::string> vec) {}

namespace {
/// Container of Attribute or Type for Dialect.
struct AttrOrType {};
} // namespace

static bool emitBCRW(const RecordKeeper &records, raw_ostream &os) {}

static mlir::GenRegistration
    genBCRW("gen-bytecode", "Generate dialect bytecode readers/writers",
            [](const RecordKeeper &records, raw_ostream &os) {});