39 lines · cpp
1//===- standalone-plugin.cpp ------------------------------------*- C++ -*-===//2//3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/IR/MLIRContext.h"10#include "mlir/InitAllDialects.h"11#include "mlir/Tools/Plugins/DialectPlugin.h"12 13#include "Standalone/StandaloneDialect.h"14#include "Standalone/StandalonePasses.h"15#include "mlir/Tools/Plugins/PassPlugin.h"16#include "llvm/Config/llvm-config.h"17#include "llvm/Support/Compiler.h"18 19using namespace mlir;20 21/// Dialect plugin registration mechanism.22/// Observe that it also allows to register passes.23/// Necessary symbol to register the dialect plugin.24extern "C" LLVM_ATTRIBUTE_WEAK DialectPluginLibraryInfo25mlirGetDialectPluginInfo() {26 return {MLIR_PLUGIN_API_VERSION, "Standalone", LLVM_VERSION_STRING,27 [](DialectRegistry *registry) {28 registry->insert<mlir::standalone::StandaloneDialect>();29 mlir::standalone::registerPasses();30 }};31}32 33/// Pass plugin registration mechanism.34/// Necessary symbol to register the pass plugin.35extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo mlirGetPassPluginInfo() {36 return {MLIR_PLUGIN_API_VERSION, "StandalonePasses", LLVM_VERSION_STRING,37 []() { mlir::standalone::registerPasses(); }};38}39