#include "mlir/Dialect/IRDL/IR/IRDL.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/TableGen/AttrOrTypeDef.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/GenNameParser.h"
#include "mlir/TableGen/Interfaces.h"
#include "mlir/TableGen/Operator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Main.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/TableGenBackend.h"
usingnamespacellvm;
usingnamespacemlir;
NamedTypeConstraint;
static llvm::cl::OptionCategory dialectGenCat("Options for -gen-irdl-dialect");
llvm::cl::opt<std::string>
selectedDialect("dialect", llvm::cl::desc("The dialect to gen for"),
llvm::cl::cat(dialectGenCat), llvm::cl::Required);
Value createPredicate(OpBuilder &builder, tblgen::Pred pred) { … }
Value typeToConstraint(OpBuilder &builder, Type type) { … }
Value baseToConstraint(OpBuilder &builder, StringRef baseClass) { … }
std::optional<Type> recordToType(MLIRContext *ctx, const Record &predRec) { … }
Value createTypeConstraint(OpBuilder &builder, tblgen::Constraint constraint) { … }
Value createAttrConstraint(OpBuilder &builder, tblgen::Constraint constraint) { … }
Value createRegionConstraint(OpBuilder &builder, tblgen::Region constraint) { … }
static StringRef getOperatorName(tblgen::Operator &tblgenOp) { … }
static StringRef getTypeName(tblgen::TypeDef &tblgenType) { … }
static StringRef getAttrName(tblgen::AttrDef &tblgenType) { … }
irdl::OperationOp createIRDLOperation(OpBuilder &builder,
tblgen::Operator &tblgenOp) { … }
irdl::TypeOp createIRDLType(OpBuilder &builder, tblgen::TypeDef &tblgenType) { … }
irdl::AttributeOp createIRDLAttr(OpBuilder &builder,
tblgen::AttrDef &tblgenAttr) { … }
static irdl::DialectOp createIRDLDialect(OpBuilder &builder) { … }
static bool emitDialectIRDLDefs(const RecordKeeper &records, raw_ostream &os) { … }
static mlir::GenRegistration
genOpDefs("gen-dialect-irdl-defs", "Generate IRDL dialect definitions",
[](const RecordKeeper &records, raw_ostream &os) { … });