Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions mlir/tools/mlir-tblgen/AttrOrTypeCAPIGen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===- AttrOrTypeCAPIGen.cpp - MLIR Attribute and Type CAPI generation ----===//
//
// 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/TableGen/GenInfo.h"
#include "mlir/TableGen/Pass.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"

using namespace mlir;
using namespace mlir::tblgen;
using llvm::formatv;
using llvm::RecordKeeper;

static llvm::cl::OptionCategory
passGenCat("Options for -gen-attr-or-type-capi-header and "
"-gen-attr-or-type-capi-impl");

const char *const gettorDecl = R"(
MLIR_CAPI_EXPORTED MlirType mlir{0}TypeGet({1});

)";

const char *const gettorDefn = R"(
MLIR_CAPI_EXPORTED MlirType mlir{0}TypeGet({1})
{
return wrap({0}Type::get({2}));
}

)";

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

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

static mlir::GenRegistration
genCAPIHeader("gen-attr-or-type-capi-header",
"Generate Attribute or Type C API header", &emitCAPIHeader);

static mlir::GenRegistration
genCAPIImpl("gen-attr-or-type-capi-impl",
"Generate Attribute or Type C API implementation",
&emitCAPIImpl);
1 change: 1 addition & 0 deletions mlir/tools/mlir-tblgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
add_tablegen(mlir-tblgen MLIR
DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
EXPORT MLIR
AttrOrTypeCAPIGen.cpp
AttrOrTypeDefGen.cpp
AttrOrTypeFormatGen.cpp
BytecodeDialectGen.cpp
Expand Down
Loading