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

//===- EnumsGen.cpp - MLIR enum utility generator -------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// EnumsGen generates common utility functions for enums.
//
//===----------------------------------------------------------------------===//

#include "FormatGen.h"
#include "mlir/TableGen/Attribute.h"
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"

formatv;
isDigit;
PrintFatalError;
raw_ostream;
Record;
RecordKeeper;
StringRef;
Attribute;
EnumAttr;
EnumAttrCase;
FmtContext;
tgfmt;

static std::string makeIdentifier(StringRef str) {}

static void emitEnumClass(const Record &enumDef, StringRef enumName,
                          StringRef underlyingType, StringRef description,
                          const std::vector<EnumAttrCase> &enumerants,
                          raw_ostream &os) {}

static void emitParserPrinter(const EnumAttr &enumAttr, StringRef qualName,
                              StringRef cppNamespace, raw_ostream &os) {}

static void emitDenseMapInfo(StringRef qualName, std::string underlyingType,
                             StringRef cppNamespace, raw_ostream &os) {}

static void emitMaxValueFn(const Record &enumDef, raw_ostream &os) {}

// Returns the EnumAttrCase whose value is zero if exists; returns std::nullopt
// otherwise.
static std::optional<EnumAttrCase>
getAllBitsUnsetCase(llvm::ArrayRef<EnumAttrCase> cases) {}

// Emits the following inline function for bit enums:
//
// inline constexpr <enum-type> operator|(<enum-type> a, <enum-type> b);
// inline constexpr <enum-type> operator&(<enum-type> a, <enum-type> b);
// inline constexpr <enum-type> operator^(<enum-type> a, <enum-type> b);
// inline constexpr <enum-type> operator~(<enum-type> bits);
// inline constexpr bool bitEnumContainsAll(<enum-type> bits, <enum-type> bit);
// inline constexpr bool bitEnumContainsAny(<enum-type> bits, <enum-type> bit);
// inline constexpr <enum-type> bitEnumClear(<enum-type> bits, <enum-type> bit);
// inline constexpr <enum-type> bitEnumSet(<enum-type> bits, <enum-type> bit,
// bool value=true);
static void emitOperators(const Record &enumDef, raw_ostream &os) {}

static void emitSymToStrFnForIntEnum(const Record &enumDef, raw_ostream &os) {}

static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) {}

static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) {}

static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) {}

static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef,
                                            raw_ostream &os) {}

static void emitSpecializedAttrDef(const Record &enumDef, raw_ostream &os) {}

static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef,
                                            raw_ostream &os) {}

static void emitEnumDecl(const Record &enumDef, raw_ostream &os) {}

static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {}

static void emitEnumDef(const Record &enumDef, raw_ostream &os) {}

static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {}

// Registers the enum utility generator to mlir-tblgen.
static mlir::GenRegistration
    genEnumDecls("gen-enum-decls", "Generate enum utility declarations",
                 [](const RecordKeeper &records, raw_ostream &os) {});

// Registers the enum utility generator to mlir-tblgen.
static mlir::GenRegistration
    genEnumDefs("gen-enum-defs", "Generate enum utility definitions",
                [](const RecordKeeper &records, raw_ostream &os) {});