#include "AttrOrTypeFormatGen.h"
#include "mlir/TableGen/AttrOrTypeDef.h"
#include "mlir/TableGen/Class.h"
#include "mlir/TableGen/CodeGenHelpers.h"
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/Interfaces.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/TableGenBackend.h"
#define DEBUG_TYPE …
usingnamespacemlir;
usingnamespacemlir::tblgen;
static void collectAllDefs(StringRef selectedDialect,
ArrayRef<const llvm::Record *> records,
SmallVectorImpl<AttrOrTypeDef> &resultDefs) { … }
namespace {
class DefGen { … };
}
DefGen::DefGen(const AttrOrTypeDef &def)
: … { … }
void DefGen::createParentWithTraits() { … }
static std::string formatExtraDeclarations(const AttrOrTypeDef &def) { … }
static std::string formatExtraDefinitions(const AttrOrTypeDef &def) { … }
void DefGen::emitTopLevelDeclarations() { … }
void DefGen::emitName() { … }
void DefGen::emitDialectName() { … }
void DefGen::emitBuilders() { … }
void DefGen::emitVerifierDecl() { … }
static const char *const patternParameterVerificationCode = …;
void DefGen::emitInvariantsVerifierImpl() { … }
void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) { … }
void DefGen::emitParserPrinter() { … }
void DefGen::emitAccessors() { … }
void DefGen::emitInterfaceMethods() { … }
SmallVector<MethodParameter>
DefGen::getBuilderParams(std::initializer_list<MethodParameter> prefix) const { … }
void DefGen::emitDefaultBuilder() { … }
void DefGen::emitCheckedBuilder() { … }
static SmallVector<MethodParameter>
getCustomBuilderParams(std::initializer_list<MethodParameter> prefix,
const AttrOrTypeBuilder &builder) { … }
void DefGen::emitCustomBuilder(const AttrOrTypeBuilder &builder) { … }
static std::string replaceInStr(std::string str, StringRef from, StringRef to) { … }
void DefGen::emitCheckedCustomBuilder(const AttrOrTypeBuilder &builder) { … }
void DefGen::emitTraitMethods(const InterfaceTrait &trait) { … }
void DefGen::emitTraitMethod(const InterfaceMethod &method) { … }
void DefGen::emitStorageConstructor() { … }
void DefGen::emitKeyType() { … }
void DefGen::emitEquals() { … }
void DefGen::emitHashKey() { … }
void DefGen::emitConstruct() { … }
void DefGen::emitStorageClass() { … }
namespace {
class DefGenerator { … };
struct AttrDefGenerator : public DefGenerator { … };
struct TypeDefGenerator : public DefGenerator { … };
}
static const char *const typeDefDeclHeader = …;
bool DefGenerator::emitDecls(StringRef selectedDialect) { … }
void DefGenerator::emitTypeDefList(ArrayRef<AttrOrTypeDef> defs) { … }
static const char *const dialectDefaultAttrPrinterParserDispatch = …;
static const char *const dialectDynamicAttrParserDispatch = …;
static const char *const dialectDynamicAttrPrinterDispatch = …;
static const char *const dialectDefaultTypePrinterParserDispatch = …;
static const char *const dialectDynamicTypeParserDispatch = …;
static const char *const dialectDynamicTypePrinterDispatch = …;
void DefGenerator::emitParsePrintDispatch(ArrayRef<AttrOrTypeDef> defs) { … }
bool DefGenerator::emitDefs(StringRef selectedDialect) { … }
static std::vector<Constraint>
getAllTypeConstraints(const llvm::RecordKeeper &records) { … }
static void emitTypeConstraintDecls(const llvm::RecordKeeper &records,
raw_ostream &os) { … }
static void emitTypeConstraintDefs(const llvm::RecordKeeper &records,
raw_ostream &os) { … }
static llvm::cl::OptionCategory attrdefGenCat("Options for -gen-attrdef-*");
static llvm::cl::opt<std::string>
attrDialect("attrdefs-dialect",
llvm::cl::desc("Generate attributes for this dialect"),
llvm::cl::cat(attrdefGenCat), llvm::cl::CommaSeparated);
static mlir::GenRegistration
genAttrDefs("gen-attrdef-defs", "Generate AttrDef definitions",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });
static mlir::GenRegistration
genAttrDecls("gen-attrdef-decls", "Generate AttrDef declarations",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });
static llvm::cl::OptionCategory typedefGenCat("Options for -gen-typedef-*");
static llvm::cl::opt<std::string>
typeDialect("typedefs-dialect",
llvm::cl::desc("Generate types for this dialect"),
llvm::cl::cat(typedefGenCat), llvm::cl::CommaSeparated);
static mlir::GenRegistration
genTypeDefs("gen-typedef-defs", "Generate TypeDef definitions",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });
static mlir::GenRegistration
genTypeDecls("gen-typedef-decls", "Generate TypeDef declarations",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });
static mlir::GenRegistration
genTypeConstrDefs("gen-type-constraint-defs",
"Generate type constraint definitions",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });
static mlir::GenRegistration
genTypeConstrDecls("gen-type-constraint-decls",
"Generate type constraint declarations",
[](const llvm::RecordKeeper &records, raw_ostream &os) { … });